Implement missing data types for calendar and schedule (#474)
* Added the SpecialEvent struct for the Exception_Schedule property of Schedule, encode/decode/same functions, unit tests, and integrated into bacapp functions. * Added the CalendarEntry struct for the Date_List property of Calendar and the SpecialEvent struct, encode/decode functions, unit tests, and integrated into bacapp functions. * Added the DateRange struct for the Effective_Period property of Schedule, encode/decode functions, unit tests, and integrated into bacapp functions. --------- Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
@@ -151,6 +151,8 @@ add_library(${PROJECT_NAME}
|
||||
src/bacnet/dailyschedule.h
|
||||
src/bacnet/weeklyschedule.c
|
||||
src/bacnet/weeklyschedule.h
|
||||
src/bacnet/special_event.c
|
||||
src/bacnet/special_event.h
|
||||
$<$<BOOL:${BACDL_BIP}>:src/bacnet/basic/bbmd/h_bbmd.c>
|
||||
$<$<BOOL:${BACDL_BIP}>:src/bacnet/basic/bbmd/h_bbmd.h>
|
||||
$<$<BOOL:${BACDL_BIP6}>:src/bacnet/basic/bbmd6/h_bbmd6.c>
|
||||
@@ -389,6 +391,8 @@ add_library(${PROJECT_NAME}
|
||||
src/bacnet/bits.h
|
||||
src/bacnet/bytes.h
|
||||
src/bacnet/config.h
|
||||
src/bacnet/calendar_entry.c
|
||||
src/bacnet/calendar_entry.h
|
||||
src/bacnet/cov.c
|
||||
src/bacnet/cov.h
|
||||
src/bacnet/create_object.c
|
||||
|
||||
@@ -164,6 +164,8 @@ set(BACNET_PROJECT_SOURCE
|
||||
${LIBRARY_BACNET_CORE}/timestamp.c
|
||||
${LIBRARY_BACNET_CORE}/weeklyschedule.c
|
||||
${LIBRARY_BACNET_CORE}/dailyschedule.c
|
||||
${LIBRARY_BACNET_CORE}/calendar_entry.c
|
||||
${LIBRARY_BACNET_CORE}/special_event.c
|
||||
${LIBRARY_BACNET_CORE}/bactimevalue.c
|
||||
${LIBRARY_BACNET_CORE}/whohas.c
|
||||
${LIBRARY_BACNET_CORE}/whois.c
|
||||
|
||||
@@ -115,6 +115,8 @@ CORESRC = $(BACNET_CORE)/abort.c \
|
||||
$(BACNET_CORE)/weeklyschedule.c \
|
||||
$(BACNET_CORE)/dailyschedule.c \
|
||||
$(BACNET_CORE)/bactimevalue.c \
|
||||
$(BACNET_CORE)/calendar_entry.c \
|
||||
$(BACNET_CORE)/special_event.c \
|
||||
$(BACNET_CORE)/whohas.c \
|
||||
$(BACNET_CORE)/whois.c \
|
||||
$(BACNET_CORE)/wp.c
|
||||
|
||||
@@ -80,6 +80,8 @@ BACNET_SRC = \
|
||||
$(BACNET_CORE)/weeklyschedule.c \
|
||||
$(BACNET_CORE)/dailyschedule.c \
|
||||
$(BACNET_CORE)/bactimevalue.c \
|
||||
$(BACNET_CORE)/calendar_entry.c \
|
||||
$(BACNET_CORE)/special_event.c \
|
||||
$(BACNET_CORE)/whohas.c \
|
||||
$(BACNET_CORE)/whois.c \
|
||||
$(BACNET_CORE)/wp.c
|
||||
|
||||
@@ -196,6 +196,8 @@ set(BACNET_PROJECT_SOURCE
|
||||
${LIBRARY_BACNET_CORE}/timestamp.c
|
||||
${LIBRARY_BACNET_CORE}/weeklyschedule.c
|
||||
${LIBRARY_BACNET_CORE}/dailyschedule.c
|
||||
${LIBRARY_BACNET_CORE}/calendar_entry.c
|
||||
${LIBRARY_BACNET_CORE}/special_event.c
|
||||
${LIBRARY_BACNET_CORE}/bactimevalue.c
|
||||
${LIBRARY_BACNET_CORE}/whohas.c
|
||||
${LIBRARY_BACNET_CORE}/whois.c
|
||||
|
||||
@@ -81,6 +81,8 @@ BACNET_SRC = \
|
||||
$(BACNET_CORE)/timestamp.c \
|
||||
$(BACNET_CORE)/weeklyschedule.c \
|
||||
$(BACNET_CORE)/dailyschedule.c \
|
||||
$(BACNET_CORE)/calendar_entry.c \
|
||||
$(BACNET_CORE)/special_event.c \
|
||||
$(BACNET_CORE)/bactimevalue.c \
|
||||
$(BACNET_CORE)/whohas.c \
|
||||
$(BACNET_CORE)/whois.c \
|
||||
|
||||
@@ -189,6 +189,8 @@
|
||||
<ClCompile Include="..\..\..\..\src\bacnet\timestamp.c" />
|
||||
<ClCompile Include="..\..\..\..\src\bacnet\timesync.c" />
|
||||
<ClCompile Include="..\..\..\..\src\bacnet\weeklyschedule.c" />
|
||||
<ClCompile Include="..\..\..\..\src\bacnet\calendar_entry.c" />
|
||||
<ClCompile Include="..\..\..\..\src\bacnet\special_event.c" />
|
||||
<ClCompile Include="..\..\..\..\src\bacnet\whohas.c" />
|
||||
<ClCompile Include="..\..\..\..\src\bacnet\whois.c" />
|
||||
<ClCompile Include="..\..\..\..\src\bacnet\wp.c" />
|
||||
|
||||
@@ -204,6 +204,12 @@
|
||||
<ClCompile Include="..\..\..\..\src\bacnet\weeklyschedule.c">
|
||||
<Filter>Source Files\src\bacnet</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\..\src\bacnet\calendar_entry.c">
|
||||
<Filter>Source Files\src\bacnet</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\..\src\bacnet\special_event.c">
|
||||
<Filter>Source Files\src\bacnet</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\..\src\bacnet\whohas.c">
|
||||
<Filter>Source Files\src\bacnet</Filter>
|
||||
</ClCompile>
|
||||
|
||||
+149
-12
@@ -55,6 +55,8 @@
|
||||
#include "bacnet/lighting.h"
|
||||
#include "bacnet/hostnport.h"
|
||||
#include "bacnet/weeklyschedule.h"
|
||||
#include "bacnet/calendar_entry.h"
|
||||
#include "bacnet/special_event.h"
|
||||
#include "bacnet/basic/sys/platform.h"
|
||||
|
||||
/** @file bacapp.c Utilities for the BACnet_Application_Data_Value */
|
||||
@@ -157,6 +159,11 @@ int bacapp_encode_application_data(
|
||||
apdu_len = bacapp_encode_datetime(apdu, &value->type.Date_Time);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_DATERANGE)
|
||||
case BACNET_APPLICATION_TAG_DATERANGE:
|
||||
apdu_len = bacnet_daterange_encode(apdu, &value->type.Date_Range);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_LIGHTING_COMMAND)
|
||||
case BACNET_APPLICATION_TAG_LIGHTING_COMMAND:
|
||||
/* BACnetLightingCommand */
|
||||
@@ -184,6 +191,20 @@ int bacapp_encode_application_data(
|
||||
apdu, &value->type.Weekly_Schedule);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_CALENDAR_ENTRY)
|
||||
case BACNET_APPLICATION_TAG_CALENDAR_ENTRY:
|
||||
/* BACnetCalendarEntry */
|
||||
apdu_len = bacnet_calendar_entry_encode(
|
||||
apdu, &value->type.Calendar_Entry);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_SPECIAL_EVENT)
|
||||
case BACNET_APPLICATION_TAG_SPECIAL_EVENT:
|
||||
/* BACnetSpecialEvent */
|
||||
apdu_len = bacnet_special_event_encode(
|
||||
apdu, &value->type.Special_Event);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_HOST_N_PORT)
|
||||
case BACNET_APPLICATION_TAG_HOST_N_PORT:
|
||||
/* BACnetHostNPort */
|
||||
@@ -336,6 +357,12 @@ int bacapp_decode_data(uint8_t *apdu,
|
||||
apdu, len_value_type, &value->type.Date_Time);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_DATERANGE)
|
||||
case BACNET_APPLICATION_TAG_DATERANGE:
|
||||
len = bacnet_daterange_decode(apdu, len_value_type,
|
||||
&value->type.Date_Range);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_LIGHTING_COMMAND)
|
||||
case BACNET_APPLICATION_TAG_LIGHTING_COMMAND:
|
||||
len = lighting_command_decode(
|
||||
@@ -359,7 +386,19 @@ int bacapp_decode_data(uint8_t *apdu,
|
||||
#if defined(BACAPP_WEEKLY_SCHEDULE)
|
||||
case BACNET_APPLICATION_TAG_WEEKLY_SCHEDULE:
|
||||
len = bacnet_weeklyschedule_decode(
|
||||
apdu, len_value_type, &value->type.Weekly_Schedule);
|
||||
apdu, (int) len_value_type, &value->type.Weekly_Schedule);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_CALENDAR_ENTRY)
|
||||
case BACNET_APPLICATION_TAG_CALENDAR_ENTRY:
|
||||
len = bacnet_calendar_entry_decode(
|
||||
apdu, len_value_type, &value->type.Calendar_Entry);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_SPECIAL_EVENT)
|
||||
case BACNET_APPLICATION_TAG_SPECIAL_EVENT:
|
||||
len = bacnet_special_event_decode(
|
||||
apdu, (int) len_value_type, &value->type.Special_Event);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_HOST_N_PORT)
|
||||
@@ -692,6 +731,12 @@ int bacapp_encode_context_data_value(uint8_t *apdu,
|
||||
apdu, context_tag_number, &value->type.Date_Time);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_DATERANGE)
|
||||
case BACNET_APPLICATION_TAG_DATERANGE:
|
||||
apdu_len = bacnet_daterange_context_encode(
|
||||
apdu, context_tag_number, &value->type.Date_Range);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_LIGHTING_COMMAND)
|
||||
case BACNET_APPLICATION_TAG_LIGHTING_COMMAND:
|
||||
apdu_len = lighting_command_encode_context(
|
||||
@@ -705,6 +750,20 @@ int bacapp_encode_context_data_value(uint8_t *apdu,
|
||||
apdu, context_tag_number, &value->type.XY_Color);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_CALENDAR_ENTRY)
|
||||
case BACNET_APPLICATION_TAG_CALENDAR_ENTRY:
|
||||
/* BACnetWeeklySchedule */
|
||||
apdu_len = bacnet_calendar_entry_context_encode(
|
||||
apdu, context_tag_number, &value->type.Calendar_Entry);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_SPECIAL_EVENT)
|
||||
case BACNET_APPLICATION_TAG_SPECIAL_EVENT:
|
||||
/* BACnetWeeklySchedule */
|
||||
apdu_len = bacnet_special_event_context_encode(
|
||||
apdu, context_tag_number, &value->type.Special_Event);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_COLOR_COMMAND)
|
||||
case BACNET_APPLICATION_TAG_COLOR_COMMAND:
|
||||
/* BACnetColorCommand */
|
||||
@@ -1216,19 +1275,19 @@ int bacapp_known_property_tag(
|
||||
|
||||
case PROP_EXCEPTION_SCHEDULE:
|
||||
/* BACnetSpecialEvent (Schedule) */
|
||||
return -1;
|
||||
return BACNET_APPLICATION_TAG_SPECIAL_EVENT;
|
||||
|
||||
case PROP_DATE_LIST:
|
||||
/* FIXME: Properties using : BACnetCalendarEntry */
|
||||
return -1;
|
||||
/* BACnetCalendarEntry */
|
||||
return BACNET_APPLICATION_TAG_CALENDAR_ENTRY;
|
||||
|
||||
case PROP_ACTIVE_COV_SUBSCRIPTIONS:
|
||||
/* FIXME: BACnetCOVSubscription */
|
||||
return -1;
|
||||
|
||||
case PROP_EFFECTIVE_PERIOD:
|
||||
/* FIXME: Properties using BACnetDateRange (Schedule) */
|
||||
return -1;
|
||||
/* BACnetDateRange (Schedule) */
|
||||
return BACNET_APPLICATION_TAG_DATERANGE;
|
||||
|
||||
case PROP_RECIPIENT_LIST:
|
||||
/* Properties using BACnetDestination */
|
||||
@@ -1417,19 +1476,37 @@ int bacapp_decode_known_property(uint8_t *apdu,
|
||||
#endif
|
||||
break;
|
||||
|
||||
case PROP_DATE_LIST:
|
||||
#ifdef BACAPP_CALENDAR_ENTRY
|
||||
/* List of BACnetCalendarEntry */
|
||||
len = bacnet_calendar_entry_decode(
|
||||
apdu, max_apdu_len, &value->type.Calendar_Entry);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case PROP_EXCEPTION_SCHEDULE:
|
||||
#ifdef BACAPP_SPECIAL_EVENT
|
||||
/* List of BACnetSpecialEvent (Schedule) */
|
||||
len = bacnet_special_event_decode(
|
||||
apdu, max_apdu_len, &value->type.Special_Event);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case PROP_EFFECTIVE_PERIOD:
|
||||
#ifdef BACAPP_DATERANGE
|
||||
/* BACnetDateRange (Schedule) */
|
||||
len = bacnet_daterange_decode(
|
||||
apdu, max_apdu_len, &value->type.Date_Range);
|
||||
#endif
|
||||
break;
|
||||
|
||||
/* properties without a specific decoder - fall through to default
|
||||
*/
|
||||
|
||||
case PROP_LIST_OF_GROUP_MEMBERS:
|
||||
/* Properties using ReadAccessSpecification */
|
||||
case PROP_EXCEPTION_SCHEDULE:
|
||||
/* BACnetSpecialEvent (Schedule) */
|
||||
case PROP_DATE_LIST:
|
||||
/* FIXME: Properties using : BACnetCalendarEntry */
|
||||
case PROP_ACTIVE_COV_SUBSCRIPTIONS:
|
||||
/* FIXME: BACnetCOVSubscription */
|
||||
case PROP_EFFECTIVE_PERIOD:
|
||||
/* FIXME: Properties using BACnetDateRange (Schedule) */
|
||||
case PROP_TIME_SYNCHRONIZATION_RECIPIENTS:
|
||||
case PROP_RESTART_NOTIFICATION_RECIPIENTS:
|
||||
case PROP_UTC_TIME_SYNCHRONIZATION_RECIPIENTS:
|
||||
@@ -2305,6 +2382,26 @@ int bacapp_snprintf_value(
|
||||
ret_val += slen;
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_DATERANGE)
|
||||
case BACNET_APPLICATION_TAG_DATERANGE:
|
||||
slen = bacapp_snprintf_date(str, str_len, &value->type.Date_Range.startdate);
|
||||
ret_val += slen;
|
||||
if (str) {
|
||||
str += slen;
|
||||
if (str_len >= slen) {
|
||||
str_len -= slen;
|
||||
} else {
|
||||
str_len = 0;
|
||||
}
|
||||
}
|
||||
|
||||
slen = snprintf(str, str_len, "..");
|
||||
ret_val += slen;
|
||||
|
||||
slen = bacapp_snprintf_date(str, str_len, &value->type.Date_Range.enddate);
|
||||
ret_val += slen;
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_TIMESTAMP)
|
||||
case BACNET_APPLICATION_TAG_TIMESTAMP:
|
||||
/*ISO 8601 format */
|
||||
@@ -2389,6 +2486,20 @@ int bacapp_snprintf_value(
|
||||
&value->type.Weekly_Schedule, object_value->array_index);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_SPECIAL_EVENT)
|
||||
case BACNET_APPLICATION_TAG_SPECIAL_EVENT:
|
||||
/* FIXME: add printing for BACnetSpecialEvent */
|
||||
ret_val =
|
||||
snprintf(str, str_len, "SpecialEvent(TODO)");
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_CALENDAR_ENTRY)
|
||||
case BACNET_APPLICATION_TAG_CALENDAR_ENTRY:
|
||||
/* FIXME: add printing for BACnetCalendarEntry */
|
||||
ret_val =
|
||||
snprintf(str, str_len, "CalendarEntry(TODO)");
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_HOST_N_PORT)
|
||||
case BACNET_APPLICATION_TAG_HOST_N_PORT:
|
||||
/* BACnetHostNPort */
|
||||
@@ -2901,6 +3012,16 @@ bool bacapp_parse_application_data(BACNET_APPLICATION_TAG tag_number,
|
||||
status = parse_weeklyschedule(argv, value);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_SPECIAL_EVENT)
|
||||
case BACNET_APPLICATION_TAG_SPECIAL_EVENT:
|
||||
/* FIXME: add parsing for BACnetSpecialEvent */
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_CALENDAR_ENTRY)
|
||||
case BACNET_APPLICATION_TAG_CALENDAR_ENTRY:
|
||||
/* FIXME: add parsing for BACnetCalendarEntry */
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_HOST_N_PORT)
|
||||
case BACNET_APPLICATION_TAG_HOST_N_PORT:
|
||||
status =
|
||||
@@ -3360,6 +3481,22 @@ bool bacapp_same_value(BACNET_APPLICATION_DATA_VALUE *value,
|
||||
&test_value->type.Weekly_Schedule);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_CALENDAR_ENTRY)
|
||||
case BACNET_APPLICATION_TAG_CALENDAR_ENTRY:
|
||||
/* BACnetCalendarEntry */
|
||||
status =
|
||||
bacnet_calendar_entry_same(&value->type.Calendar_Entry,
|
||||
&test_value->type.Calendar_Entry);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_SPECIAL_EVENT)
|
||||
case BACNET_APPLICATION_TAG_SPECIAL_EVENT:
|
||||
/* BACnetSpecialEvent */
|
||||
status =
|
||||
bacnet_special_event_same(&value->type.Special_Event,
|
||||
&test_value->type.Special_Event);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_HOST_N_PORT)
|
||||
case BACNET_APPLICATION_TAG_HOST_N_PORT:
|
||||
status = host_n_port_same(
|
||||
|
||||
@@ -38,6 +38,8 @@
|
||||
#include "bacnet/hostnport.h"
|
||||
#include "bacnet/timestamp.h"
|
||||
#include "bacnet/weeklyschedule.h"
|
||||
#include "bacnet/calendar_entry.h"
|
||||
#include "bacnet/special_event.h"
|
||||
|
||||
struct BACnet_Application_Data_Value;
|
||||
typedef struct BACnet_Application_Data_Value {
|
||||
@@ -88,6 +90,9 @@ typedef struct BACnet_Application_Data_Value {
|
||||
#if defined (BACAPP_DATETIME)
|
||||
BACNET_DATE_TIME Date_Time;
|
||||
#endif
|
||||
#if defined (BACAPP_DATERANGE)
|
||||
BACNET_DATE_RANGE Date_Range;
|
||||
#endif
|
||||
#if defined (BACAPP_LIGHTING_COMMAND)
|
||||
BACNET_LIGHTING_COMMAND Lighting_Command;
|
||||
#endif
|
||||
@@ -117,6 +122,12 @@ typedef struct BACnet_Application_Data_Value {
|
||||
#endif
|
||||
#if defined (BACAPP_DESTINATION)
|
||||
BACNET_DESTINATION Destination;
|
||||
#endif
|
||||
#if defined (BACAPP_CALENDAR_ENTRY)
|
||||
BACNET_CALENDAR_ENTRY Calendar_Entry;
|
||||
#endif
|
||||
#if defined (BACAPP_SPECIAL_EVENT)
|
||||
BACNET_SPECIAL_EVENT Special_Event;
|
||||
#endif
|
||||
} type;
|
||||
/* simple linked list if needed */
|
||||
|
||||
@@ -0,0 +1,363 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief BACnetCalendarEntry complex data type encode and decode
|
||||
* @author Ondřej Hruška <ondra@ondrovo.com>
|
||||
* @author Steve Karg <skarg@users.sourceforge.net>
|
||||
* @date May 2022
|
||||
* @section LICENSE
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later WITH GCC-exception-2.0
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include "bacnet/calendar_entry.h"
|
||||
#include "bacnet/bacapp.h"
|
||||
#include "bacnet/bacdcode.h"
|
||||
#include "bacnet/bactimevalue.h"
|
||||
#include "bacnet/datetime.h"
|
||||
#include "bacnet/basic/sys/days.h"
|
||||
|
||||
/** @file calendar_entry.c Manipulate BACnet calendar entry values */
|
||||
|
||||
/*
|
||||
* @brief Encode the BACnetCalendarEntry complex data
|
||||
*
|
||||
* BACnetCalendarEntry ::= CHOICE {
|
||||
* date [0] Date,
|
||||
* date-range [1] BACnetDateRange,
|
||||
* weekNDay [2] BACnetWeekNDay
|
||||
* }
|
||||
*
|
||||
* @param apdu Pointer to the buffer for encoding, or NULL for only length
|
||||
* @param value Pointer to the property data to be encoded.
|
||||
* @return bytes encoded or zero on error.
|
||||
*/
|
||||
int bacnet_calendar_entry_encode(uint8_t *apdu, BACNET_CALENDAR_ENTRY *value)
|
||||
{
|
||||
int len = 0;
|
||||
int apdu_len = 0;
|
||||
BACNET_OCTET_STRING octetstring = { 0 };
|
||||
|
||||
switch (value->tag) {
|
||||
case BACNET_CALENDAR_DATE:
|
||||
len = encode_context_date(apdu, value->tag, &value->type.Date);
|
||||
apdu_len += len;
|
||||
break;
|
||||
case BACNET_CALENDAR_DATE_RANGE:
|
||||
len = bacnet_daterange_context_encode(
|
||||
apdu, value->tag, &value->type.DateRange);
|
||||
apdu_len += len;
|
||||
break;
|
||||
case BACNET_CALENDAR_WEEK_N_DAY:
|
||||
octetstring.value[0] = value->type.WeekNDay.month;
|
||||
octetstring.value[1] = value->type.WeekNDay.weekofmonth;
|
||||
octetstring.value[2] = value->type.WeekNDay.dayofweek;
|
||||
octetstring.length = 3;
|
||||
len = encode_context_octet_string(apdu, value->tag, &octetstring);
|
||||
apdu_len += len;
|
||||
break;
|
||||
default:
|
||||
/* do nothing */
|
||||
break;
|
||||
}
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Encodes into bytes from the calendar-entry structure
|
||||
* a context tagged chunk (opening and closing tag)
|
||||
* @param apdu Pointer to the buffer for encoding, or NULL for only length
|
||||
* @param tag_number - tag number to encode this chunk
|
||||
* @param value - calendar entry value to encode
|
||||
* @return number of bytes encoded, or 0 if unable to encode.
|
||||
*/
|
||||
int bacnet_calendar_entry_context_encode(
|
||||
uint8_t *apdu, uint8_t tag_number, BACNET_CALENDAR_ENTRY *value)
|
||||
{
|
||||
int len = 0;
|
||||
int apdu_len = 0;
|
||||
|
||||
if (value) {
|
||||
len = encode_opening_tag(apdu, tag_number);
|
||||
apdu_len += len;
|
||||
if (apdu) {
|
||||
apdu += len;
|
||||
}
|
||||
len = bacnet_calendar_entry_encode(apdu, value);
|
||||
apdu_len += len;
|
||||
if (apdu) {
|
||||
apdu += len;
|
||||
}
|
||||
len = encode_closing_tag(apdu, tag_number);
|
||||
apdu_len += len;
|
||||
}
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decodes from bytes into the calendar-entry structure
|
||||
* @param apdu - buffer to hold the bytes
|
||||
* @param apdu_size - number of bytes in the buffer to decode
|
||||
* @param entry - calendar entry value to place the decoded values
|
||||
* @return number of bytes decoded, or BACNET_STATUS_REJECT
|
||||
*/
|
||||
int bacnet_calendar_entry_decode(
|
||||
uint8_t *apdu, uint32_t apdu_size, BACNET_CALENDAR_ENTRY *entry)
|
||||
{
|
||||
int apdu_len = 0;
|
||||
int len = 0;
|
||||
BACNET_TAG tag = { 0 };
|
||||
BACNET_OCTET_STRING octet_string = { 0 };
|
||||
|
||||
if (!apdu || !entry) {
|
||||
return BACNET_STATUS_REJECT;
|
||||
}
|
||||
len = bacnet_tag_decode(&apdu[apdu_len], apdu_size - apdu_len, &tag);
|
||||
if (len <= 0) {
|
||||
return BACNET_STATUS_REJECT;
|
||||
}
|
||||
if (tag.context || tag.opening) {
|
||||
entry->tag = tag.number;
|
||||
} else {
|
||||
return BACNET_STATUS_REJECT;
|
||||
}
|
||||
switch (entry->tag) {
|
||||
case BACNET_CALENDAR_DATE:
|
||||
len = bacnet_date_context_decode(&apdu[apdu_len],
|
||||
apdu_size - apdu_len, entry->tag, &entry->type.Date);
|
||||
if (len <= 0) {
|
||||
return BACNET_STATUS_REJECT;
|
||||
}
|
||||
apdu_len += len;
|
||||
break;
|
||||
|
||||
case BACNET_CALENDAR_DATE_RANGE:
|
||||
len = bacnet_daterange_context_decode(&apdu[apdu_len],
|
||||
apdu_size - apdu_len, entry->tag, &entry->type.DateRange);
|
||||
if (len <= 0) {
|
||||
return BACNET_STATUS_REJECT;
|
||||
}
|
||||
apdu_len += len;
|
||||
break;
|
||||
|
||||
case BACNET_CALENDAR_WEEK_N_DAY:
|
||||
len = bacnet_octet_string_context_decode(&apdu[apdu_len],
|
||||
apdu_size - apdu_len, entry->tag, &octet_string);
|
||||
if (len <= 0) {
|
||||
return BACNET_STATUS_REJECT;
|
||||
}
|
||||
apdu_len += len;
|
||||
/* additional checks for valid Week-n-Day */
|
||||
if (octet_string.length != 3) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
entry->type.WeekNDay.month = octet_string.value[0];
|
||||
entry->type.WeekNDay.weekofmonth = octet_string.value[1];
|
||||
entry->type.WeekNDay.dayofweek = octet_string.value[2];
|
||||
break;
|
||||
default:
|
||||
/* none */
|
||||
return BACNET_STATUS_REJECT;
|
||||
}
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decodes from bytes into the calendar-entry structure
|
||||
* a context tagged chunk (opening and closing tag)
|
||||
* @param apdu - buffer to hold the bytes
|
||||
* @param apdu_size - number of bytes in the buffer to decode
|
||||
* @param tag_number - tag number to encode this chunk
|
||||
* @param value - calendar entry value to place the decoded values
|
||||
*
|
||||
* @return number of bytes decoded, or BACNET_STATUS_REJECT
|
||||
*/
|
||||
int bacnet_calendar_entry_context_decode(uint8_t *apdu,
|
||||
uint32_t apdu_size,
|
||||
uint8_t tag_number,
|
||||
BACNET_CALENDAR_ENTRY *value)
|
||||
{
|
||||
int apdu_len = 0;
|
||||
int len = 0;
|
||||
|
||||
if (bacnet_is_opening_tag_number(
|
||||
&apdu[apdu_len], apdu_size - apdu_len, tag_number, &len)) {
|
||||
apdu_len += len;
|
||||
} else {
|
||||
return BACNET_STATUS_REJECT;
|
||||
}
|
||||
len = bacnet_calendar_entry_decode(
|
||||
&apdu[apdu_len], apdu_size - apdu_len, value);
|
||||
if (len <= 0) {
|
||||
return BACNET_STATUS_REJECT;
|
||||
} else {
|
||||
apdu_len += len;
|
||||
}
|
||||
if (bacnet_is_closing_tag_number(
|
||||
&apdu[apdu_len], apdu_size - apdu_len, tag_number, &len)) {
|
||||
apdu_len += len;
|
||||
} else {
|
||||
return BACNET_STATUS_REJECT;
|
||||
}
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Compare a month to a BACnetDate value month
|
||||
* @param date - BACnetDate with a month value to compare
|
||||
* @param month - month to compare
|
||||
* @return true if the same month including special values, else false
|
||||
*/
|
||||
static bool month_match(BACNET_DATE *date, uint8_t month)
|
||||
{
|
||||
if (month == 0xff) {
|
||||
return true;
|
||||
}
|
||||
if (!date) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return ((month == date->month) ||
|
||||
((month == 13) && (date->month % 2 == 1)) ||
|
||||
((month == 14) && (date->month % 2 == 0)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Compare a week of the month to a BACnetDate value
|
||||
* @param date - BACnetDate value to compare
|
||||
* @param weekofmonth - week of the month to compare
|
||||
* @return true if the same week of the month including special values
|
||||
*/
|
||||
static bool weekofmonth_match(BACNET_DATE *date, uint8_t weekofmonth)
|
||||
{
|
||||
bool st = false;
|
||||
uint8_t day_to_end_month;
|
||||
|
||||
switch (weekofmonth) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
if (date) {
|
||||
st = (weekofmonth == (date->day - 1) % 7 + 1);
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
if (date) {
|
||||
day_to_end_month =
|
||||
days_per_month(date->year, date->month) - date->day;
|
||||
st = ((weekofmonth - 6) == day_to_end_month % 7);
|
||||
}
|
||||
break;
|
||||
case 0xff:
|
||||
st = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return st;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Compare a day of the week to a BACnetDate value
|
||||
* @param date - BACnetDate value to compare
|
||||
* @param dayofweek - day of the week to compare
|
||||
* @return true if the same day of the week including special values
|
||||
*/
|
||||
static bool dayofweek_match(BACNET_DATE *date, uint8_t dayofweek)
|
||||
{
|
||||
if (dayofweek == 0xff) {
|
||||
return true;
|
||||
}
|
||||
if (!date) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (dayofweek == date->wday);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Determine if a BACnetCalendarEntry includes a BACnetDate value
|
||||
* @param date - BACnetDate value to compare
|
||||
* @param entry - BACnetCalendarEntry value to compare
|
||||
* @return true if a BACnetCalendarEntry includes the BACnetDate value
|
||||
*/
|
||||
bool bacapp_date_in_calendar_entry(
|
||||
BACNET_DATE *date, BACNET_CALENDAR_ENTRY *entry)
|
||||
{
|
||||
if (!entry) {
|
||||
return false;
|
||||
}
|
||||
switch (entry->tag) {
|
||||
case BACNET_CALENDAR_DATE:
|
||||
if (datetime_compare_date(date, &entry->type.Date) == 0) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case BACNET_CALENDAR_DATE_RANGE:
|
||||
if ((datetime_compare_date(
|
||||
&entry->type.DateRange.startdate, date) <= 0) &&
|
||||
(datetime_compare_date(date, &entry->type.DateRange.enddate) <=
|
||||
0)) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case BACNET_CALENDAR_WEEK_N_DAY:
|
||||
if (month_match(date, entry->type.WeekNDay.month) &&
|
||||
weekofmonth_match(date, entry->type.WeekNDay.weekofmonth) &&
|
||||
dayofweek_match(date, entry->type.WeekNDay.dayofweek)) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
/* do nothing */
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Determine if two BACnetCalendarEntry are the same
|
||||
* @param value1 - BACnetCalendarEntry value to compare
|
||||
* @param value2 - BACnetCalendarEntry value to compare
|
||||
* @return true if both BACnetCalendarEntry are the same
|
||||
*/
|
||||
bool bacnet_calendar_entry_same(
|
||||
BACNET_CALENDAR_ENTRY *value1, BACNET_CALENDAR_ENTRY *value2)
|
||||
{
|
||||
if (!value1 || !value2) {
|
||||
return false;
|
||||
}
|
||||
if (value1->tag != value2->tag) {
|
||||
return false;
|
||||
}
|
||||
switch (value1->tag) {
|
||||
case BACNET_CALENDAR_DATE:
|
||||
return datetime_compare_date(
|
||||
&value1->type.Date, &value2->type.Date) == 0;
|
||||
case BACNET_CALENDAR_DATE_RANGE:
|
||||
return (datetime_compare_date(&value1->type.DateRange.startdate,
|
||||
&value2->type.DateRange.startdate) == 0) &&
|
||||
(datetime_compare_date(&value2->type.DateRange.enddate,
|
||||
&value2->type.DateRange.enddate) == 0);
|
||||
case BACNET_CALENDAR_WEEK_N_DAY:
|
||||
return (value1->type.WeekNDay.month ==
|
||||
value2->type.WeekNDay.month) &&
|
||||
(value1->type.WeekNDay.weekofmonth ==
|
||||
value2->type.WeekNDay.weekofmonth) &&
|
||||
(value1->type.WeekNDay.dayofweek ==
|
||||
value2->type.WeekNDay.dayofweek);
|
||||
default:
|
||||
/* should be unreachable */
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief API for BACnetCalendarEntry complex data type encode and decode
|
||||
* @author Ondřej Hruška <ondra@ondrovo.com>
|
||||
* @author Steve Karg <skarg@users.sourceforge.net>
|
||||
* @date August 2023
|
||||
* @section LICENSE
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
#ifndef BACNET_CALENDAR_ENTRY_H
|
||||
#define BACNET_CALENDAR_ENTRY_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "bacnet/bacnet_stack_exports.h"
|
||||
#include "bacnet/bactimevalue.h"
|
||||
#include "bacnet/datetime.h"
|
||||
|
||||
/*
|
||||
BACnetCalendarEntry ::= CHOICE {
|
||||
date [0] Date,
|
||||
date-range [1] BACnetDateRange,
|
||||
weekNDay [2] BACnetWeekNDay
|
||||
}
|
||||
*/
|
||||
|
||||
typedef enum BACnet_CalendarEntry_Tags {
|
||||
BACNET_CALENDAR_DATE = 0,
|
||||
BACNET_CALENDAR_DATE_RANGE = 1,
|
||||
BACNET_CALENDAR_WEEK_N_DAY = 2
|
||||
} BACNET_CALENDAR_ENTRY_TAGS;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef struct BACnetCalendarEntry_T {
|
||||
uint8_t tag;
|
||||
union {
|
||||
BACNET_DATE Date;
|
||||
BACNET_DATE_RANGE DateRange;
|
||||
BACNET_WEEKNDAY WeekNDay;
|
||||
} type;
|
||||
/* simple linked list if needed */
|
||||
struct BACnetCalendarEntry_T *next;
|
||||
} BACNET_CALENDAR_ENTRY;
|
||||
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bacnet_calendar_entry_encode(uint8_t *apdu, BACNET_CALENDAR_ENTRY *value);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bacnet_calendar_entry_context_encode(
|
||||
uint8_t *apdu, uint8_t tag_number, BACNET_CALENDAR_ENTRY *value);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bacnet_calendar_entry_decode(
|
||||
uint8_t *apdu, uint32_t apdu_max_len, BACNET_CALENDAR_ENTRY *entry);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bacnet_calendar_entry_context_decode(
|
||||
uint8_t *apdu, uint32_t apdu_max_len, uint8_t tag_number,
|
||||
BACNET_CALENDAR_ENTRY *value);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bacapp_date_in_calendar_entry(BACNET_DATE *date,
|
||||
BACNET_CALENDAR_ENTRY *entry);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bacnet_calendar_entry_same(
|
||||
BACNET_CALENDAR_ENTRY *value1, BACNET_CALENDAR_ENTRY *value2);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif
|
||||
|
||||
@@ -157,10 +157,13 @@
|
||||
defined(BACAPP_TIME) || \
|
||||
defined(BACAPP_OBJECT_ID) || \
|
||||
defined(BACAPP_DATETIME) || \
|
||||
defined(BACAPP_DATERANGE) || \
|
||||
defined(BACAPP_LIGHTING_COMMAND) || \
|
||||
defined(BACAPP_XY_COLOR) || \
|
||||
defined(BACAPP_COLOR_COMMAND) || \
|
||||
defined(BACAPP_WEEKLY_SCHEDULE) || \
|
||||
defined(BACAPP_CALENDAR_ENTRY) || \
|
||||
defined(BACAPP_SPECIAL_EVENT) || \
|
||||
defined(BACAPP_HOST_N_PORT) || \
|
||||
defined(BACAPP_DEVICE_OBJECT_PROPERTY_REFERENCE) || \
|
||||
defined(BACAPP_DEVICE_OBJECT_REFERENCE) || \
|
||||
@@ -194,10 +197,13 @@
|
||||
#define BACAPP_DOUBLE
|
||||
#define BACAPP_TIMESTAMP
|
||||
#define BACAPP_DATETIME
|
||||
#define BACAPP_DATERANGE
|
||||
#define BACAPP_LIGHTING_COMMAND
|
||||
#define BACAPP_XY_COLOR
|
||||
#define BACAPP_COLOR_COMMAND
|
||||
#define BACAPP_WEEKLY_SCHEDULE
|
||||
#define BACAPP_CALENDAR_ENTRY
|
||||
#define BACAPP_SPECIAL_EVENT
|
||||
#define BACAPP_HOST_N_PORT
|
||||
#define BACAPP_DEVICE_OBJECT_PROPERTY_REFERENCE
|
||||
#define BACAPP_DEVICE_OBJECT_REFERENCE
|
||||
@@ -207,10 +213,13 @@
|
||||
|
||||
#if defined(BACAPP_DOUBLE) || \
|
||||
defined(BACAPP_DATETIME) || \
|
||||
defined(BACAPP_DATERANGE) || \
|
||||
defined(BACAPP_LIGHTING_COMMAND) || \
|
||||
defined(BACAPP_XY_COLOR) || \
|
||||
defined(BACAPP_COLOR_COMMAND) || \
|
||||
defined(BACAPP_WEEKLY_SCHEDULE) || \
|
||||
defined(BACAPP_CALENDAR_ENTRY) || \
|
||||
defined(BACAPP_SPECIAL_EVENT) || \
|
||||
defined(BACAPP_HOST_N_PORT) || \
|
||||
defined(BACAPP_DEVICE_OBJECT_PROPERTY_REFERENCE) || \
|
||||
defined(BACAPP_DEVICE_OBJECT_REFERENCE) || \
|
||||
|
||||
@@ -36,18 +36,21 @@ License.
|
||||
#include "bacnet/dailyschedule.h"
|
||||
#include "bacnet/bactimevalue.h"
|
||||
|
||||
int bacnet_dailyschedule_decode(
|
||||
uint8_t *apdu, int max_apdu_len, BACNET_DAILY_SCHEDULE *day)
|
||||
int bacnet_dailyschedule_context_decode(uint8_t *apdu,
|
||||
int max_apdu_len,
|
||||
uint8_t tag_number,
|
||||
BACNET_DAILY_SCHEDULE *day)
|
||||
{
|
||||
unsigned int tv_count = 0;
|
||||
int retval = bacnet_time_values_context_decode(apdu, max_apdu_len, 0,
|
||||
&day->Time_Values[0], MAX_DAY_SCHEDULE_VALUES, &tv_count);
|
||||
int retval = bacnet_time_values_context_decode(apdu, max_apdu_len,
|
||||
tag_number, &day->Time_Values[0], MAX_DAY_SCHEDULE_VALUES, &tv_count);
|
||||
day->TV_Count = (uint16_t)tv_count;
|
||||
return retval;
|
||||
}
|
||||
|
||||
int bacnet_dailyschedule_encode(uint8_t *apdu, BACNET_DAILY_SCHEDULE *day)
|
||||
int bacnet_dailyschedule_context_encode(
|
||||
uint8_t *apdu, uint8_t tag_number, BACNET_DAILY_SCHEDULE *day)
|
||||
{
|
||||
return bacnet_time_values_context_encode(
|
||||
apdu, 0, &day->Time_Values[0], day->TV_Count);
|
||||
apdu, tag_number, &day->Time_Values[0], day->TV_Count);
|
||||
}
|
||||
|
||||
@@ -51,15 +51,17 @@ extern "C" {
|
||||
|
||||
/** Decode DailySchedule (sequence of times and values) */
|
||||
BACNET_STACK_EXPORT
|
||||
int bacnet_dailyschedule_decode(
|
||||
int bacnet_dailyschedule_context_decode(
|
||||
uint8_t * apdu,
|
||||
int max_apdu_len,
|
||||
uint8_t tag_number,
|
||||
BACNET_DAILY_SCHEDULE * day);
|
||||
|
||||
/** Encode DailySchedule (sequence of times and values) */
|
||||
BACNET_STACK_EXPORT
|
||||
int bacnet_dailyschedule_encode(
|
||||
int bacnet_dailyschedule_context_encode(
|
||||
uint8_t * apdu,
|
||||
uint8_t tag_number,
|
||||
BACNET_DAILY_SCHEDULE * day);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
+161
-33
@@ -1,36 +1,15 @@
|
||||
/*####COPYRIGHTBEGIN####
|
||||
-------------------------------------------
|
||||
Copyright (C) 2007 Steve Karg <skarg@users.sourceforge.net>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to:
|
||||
The Free Software Foundation, Inc.
|
||||
59 Temple Place - Suite 330
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
As a special exception, if other files instantiate templates or
|
||||
use macros or inline functions from this file, or you compile
|
||||
this file and link it with other works to produce a work based
|
||||
on this file, this file does not by itself cause the resulting
|
||||
work to be covered by the GNU General Public License. However
|
||||
the source code for this file must still be made available in
|
||||
accordance with section (3) of the GNU General Public License.
|
||||
|
||||
This exception does not invalidate any other reasons why a work
|
||||
based on this file might be covered by the GNU General Public
|
||||
License.
|
||||
-------------------------------------------
|
||||
####COPYRIGHTEND####*/
|
||||
/**
|
||||
* @file
|
||||
* @brief BACnetDate, BACnetTime, BACnetDateTime, BACnetDateRange complex data
|
||||
* type encode and decode functions
|
||||
* @author Steve Karg <skarg@users.sourceforge.net>
|
||||
* @author Greg Shue <greg.shue@outlook.com>
|
||||
* @author Ondřej Hruška <ondra@ondrovo.com>
|
||||
* @date 2012
|
||||
* @section LICENSE
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later WITH GCC-exception-2.0
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
@@ -1182,12 +1161,161 @@ int bacnet_datetime_context_decode(uint8_t *apdu,
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decodes a context tagged BACnetDateTime value from APDU buffer
|
||||
* @param apdu - the APDU buffer
|
||||
* @param tag_number - context tag number to be encoded
|
||||
* @param value - parameter to store the value after decoding
|
||||
* @return length of the APDU buffer decoded, or BACNET_STATUS_ERROR
|
||||
* @deprecated - use bacnet_datetime_context_decode() instead
|
||||
*/
|
||||
int bacapp_decode_context_datetime(
|
||||
uint8_t *apdu, uint8_t tag_number, BACNET_DATE_TIME *value)
|
||||
{
|
||||
return bacnet_datetime_context_decode(apdu, MAX_APDU, tag_number, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Encode BACnetDateRange complex data type
|
||||
*
|
||||
* BACnetDateRange ::= SEQUENCE { -- see Clause 20.2.12 for restrictions
|
||||
* start-date Date,
|
||||
* end-date Date
|
||||
* }
|
||||
*
|
||||
* @param apdu - apdu buffer; NULL to only measure capacity needed
|
||||
* @param value - value to encode
|
||||
* @return number of bytes emitted, BACNET_STATUS_ERROR on error
|
||||
*/
|
||||
int bacnet_daterange_encode(uint8_t *apdu, BACNET_DATE_RANGE *value)
|
||||
{
|
||||
int len = 0;
|
||||
int apdu_len = 0;
|
||||
|
||||
len = encode_application_date(apdu, &value->startdate);
|
||||
if (len < 0) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
apdu_len += len;
|
||||
if (apdu) {
|
||||
apdu += len;
|
||||
}
|
||||
|
||||
len = encode_application_date(apdu, &value->enddate);
|
||||
if (len < 0) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
apdu_len += len;
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decode BACnetDateRange complex data type
|
||||
* @param apdu - apdu buffer; NULL to only measure capacity needed
|
||||
* @param apdu_size - apdu buffer size
|
||||
* @param value - value to decode
|
||||
* @return number of bytes emitted, BACNET_STATUS_ERROR on error
|
||||
*/
|
||||
int bacnet_daterange_decode(
|
||||
uint8_t *apdu, uint32_t apdu_size, BACNET_DATE_RANGE *value)
|
||||
{
|
||||
int len = 0;
|
||||
int apdu_len = 0;
|
||||
|
||||
if (!apdu || !value) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
len = bacnet_date_application_decode(
|
||||
&apdu[apdu_len], apdu_size - apdu_len, &value->startdate);
|
||||
if (len <= 0) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
apdu_len += len;
|
||||
len = bacnet_date_application_decode(
|
||||
&apdu[apdu_len], apdu_size - apdu_len, &value->enddate);
|
||||
if (len <= 0) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
apdu_len += len;
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Encode daterange with context tag
|
||||
* @param apdu - apdu buffer; NULL to only measure capacity needed
|
||||
* @param tag_number - context tag number
|
||||
* @param value - value to encode
|
||||
* @return number of bytes decoded, or BACNET_STATUS_ERROR on error
|
||||
*/
|
||||
int bacnet_daterange_context_encode(
|
||||
uint8_t *apdu, uint8_t tag_number, BACNET_DATE_RANGE *value)
|
||||
{
|
||||
int len = 0;
|
||||
int apdu_len = 0;
|
||||
|
||||
if (value) {
|
||||
len = encode_opening_tag(apdu, tag_number);
|
||||
apdu_len += len;
|
||||
if (apdu) {
|
||||
apdu += len;
|
||||
}
|
||||
len = bacnet_daterange_encode(apdu, value);
|
||||
if (len <= 0) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
apdu_len += len;
|
||||
if (apdu) {
|
||||
apdu += len;
|
||||
}
|
||||
len = encode_closing_tag(apdu, tag_number);
|
||||
apdu_len += len;
|
||||
}
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decode BACnetDateRange complex data with context tag
|
||||
* @param apdu - apdu buffer to decode
|
||||
* @param apdu_size - apdu buffer size
|
||||
* @param tag_number - context tag number
|
||||
* @param value - value to encode
|
||||
* @return number of bytes decoded, BACNET_STATUS_ERROR on error
|
||||
*/
|
||||
int bacnet_daterange_context_decode(uint8_t *apdu,
|
||||
uint32_t apdu_size,
|
||||
uint8_t tag_number,
|
||||
BACNET_DATE_RANGE *value)
|
||||
{
|
||||
int apdu_len = 0;
|
||||
int len = 0;
|
||||
|
||||
if (!apdu || !value) {
|
||||
return -1;
|
||||
}
|
||||
if (bacnet_is_opening_tag_number(
|
||||
&apdu[apdu_len], apdu_size - apdu_len, tag_number, &len)) {
|
||||
apdu_len += len;
|
||||
} else {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
len = bacnet_daterange_decode(&apdu[apdu_len], apdu_size - apdu_len, value);
|
||||
if (len <= 0) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
} else {
|
||||
apdu_len += len;
|
||||
}
|
||||
if (bacnet_is_closing_tag_number(
|
||||
&apdu[apdu_len], apdu_size - apdu_len, tag_number, &len)) {
|
||||
apdu_len += len;
|
||||
} else {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Parse an ascii string for the date 2021/12/31 or 2021/12/31:1
|
||||
* @param bdate - #BACNET_DATE structure
|
||||
|
||||
+29
-25
@@ -1,28 +1,17 @@
|
||||
/**************************************************************************
|
||||
/**
|
||||
* @file
|
||||
* @brief API for BACnetDate, BACnetTime, BACnetDateTime, BACnetDateRange
|
||||
* complex data type encode and decode
|
||||
* @author Steve Karg <skarg@users.sourceforge.net>
|
||||
* @author Greg Shue <greg.shue@outlook.com>
|
||||
* @author Ondřej Hruška <ondra@ondrovo.com>
|
||||
* @date 2012
|
||||
* @section LICENSE
|
||||
*
|
||||
* Copyright (C) 2012 Steve Karg <skarg@users.sourceforge.net>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*********************************************************************/
|
||||
#ifndef DATE_TIME_H
|
||||
#define DATE_TIME_H
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
#ifndef BACNET_DATE_TIME_H
|
||||
#define BACNET_DATE_TIME_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
@@ -288,6 +277,21 @@ int bacapp_decode_context_datetime(uint8_t *apdu,
|
||||
uint8_t tag_number,
|
||||
BACNET_DATE_TIME *value);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bacnet_daterange_encode(uint8_t *apdu, BACNET_DATE_RANGE *value);
|
||||
BACNET_STACK_EXPORT
|
||||
int bacnet_daterange_decode(uint8_t *apdu,
|
||||
uint32_t apdu_size,
|
||||
BACNET_DATE_RANGE *value);
|
||||
BACNET_STACK_EXPORT
|
||||
int bacnet_daterange_context_encode(
|
||||
uint8_t *apdu, uint8_t tag_number, BACNET_DATE_RANGE *value);
|
||||
BACNET_STACK_EXPORT
|
||||
int bacnet_daterange_context_decode(uint8_t *apdu,
|
||||
uint32_t apdu_size,
|
||||
uint8_t tag_number,
|
||||
BACNET_DATE_RANGE *value);
|
||||
|
||||
/* implementation agnostic functions - create your own! */
|
||||
BACNET_STACK_EXPORT
|
||||
bool datetime_local(BACNET_DATE *bdate,
|
||||
@@ -300,4 +304,4 @@ void datetime_init(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* DATE_TIME_H */
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,266 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief BACnetSpecialEvent complex data type encode and decode
|
||||
* @author Ondřej Hruška <ondra@ondrovo.com>
|
||||
* @author Steve Karg <skarg@users.sourceforge.net>
|
||||
* @date May 2022
|
||||
* @section LICENSE
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later WITH GCC-exception-2.0
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "bacnet/special_event.h"
|
||||
#include "bacnet/bacdcode.h"
|
||||
#include "bacapp.h"
|
||||
|
||||
/**
|
||||
* @brief Decode a BACnetSpecialEvent complex data type
|
||||
*
|
||||
* BACnetSpecialEvent ::= SEQUENCE {
|
||||
* period CHOICE {
|
||||
* calendar-entry [0] BACnetCalendarEntry,
|
||||
* calendar-reference [1] BACnetObjectIdentifier
|
||||
* },
|
||||
* list-of-time-values [2] SEQUENCE OF BACnetTimeValue,
|
||||
* event-priority [3] Unsigned (1..16)
|
||||
* }
|
||||
*
|
||||
* @param apdu - the APDU buffer
|
||||
* @param apdu_size - the size of the APDU buffer
|
||||
* @param value - BACnetSpecialEvent structure
|
||||
* @return length of the APDU buffer, or BACNET_STATUS_ERROR if unable to decode
|
||||
*/
|
||||
int bacnet_special_event_decode(
|
||||
uint8_t *apdu, int apdu_size, BACNET_SPECIAL_EVENT *value)
|
||||
{
|
||||
int len = 0;
|
||||
int apdu_len = 0;
|
||||
BACNET_UNSIGNED_INTEGER priority = 0;
|
||||
BACNET_TAG tag = { 0 };
|
||||
|
||||
if (!apdu || !value) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
len = bacnet_tag_decode(&apdu[apdu_len], apdu_size - apdu_len, &tag);
|
||||
if (len <= 0) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
if (tag.opening &&
|
||||
(tag.number == BACNET_SPECIAL_EVENT_PERIOD_CALENDAR_ENTRY)) {
|
||||
value->periodTag = BACNET_SPECIAL_EVENT_PERIOD_CALENDAR_ENTRY;
|
||||
len = bacnet_calendar_entry_context_decode(&apdu[apdu_len],
|
||||
apdu_size - apdu_len, BACNET_SPECIAL_EVENT_PERIOD_CALENDAR_ENTRY,
|
||||
&value->period.calendarEntry);
|
||||
if (len < 0) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
apdu_len += len;
|
||||
} else if (tag.context &&
|
||||
(tag.number == BACNET_SPECIAL_EVENT_PERIOD_CALENDAR_REFERENCE)) {
|
||||
value->periodTag = BACNET_SPECIAL_EVENT_PERIOD_CALENDAR_REFERENCE;
|
||||
len = bacnet_object_id_context_decode(&apdu[apdu_len],
|
||||
apdu_size - apdu_len,
|
||||
BACNET_SPECIAL_EVENT_PERIOD_CALENDAR_REFERENCE,
|
||||
&value->period.calendarReference.type,
|
||||
&value->period.calendarReference.instance);
|
||||
if (len < 0) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
apdu_len += len;
|
||||
} else {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
/* Values [2] */
|
||||
len = bacnet_dailyschedule_context_decode(
|
||||
&apdu[apdu_len], apdu_size - apdu_len, 2, &value->timeValues);
|
||||
if (len < 0) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
apdu_len += len;
|
||||
|
||||
/* Priority [3] */
|
||||
len = bacnet_unsigned_context_decode(
|
||||
&apdu[apdu_len], apdu_size - apdu_len, 3, &priority);
|
||||
if (len < 0) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
if (priority > BACNET_MAX_PRIORITY) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
value->priority = (uint8_t)priority;
|
||||
apdu_len += len;
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Encode a BACnetSpecialEvent complex data type
|
||||
* @param apdu - the APDU buffer (NULL to determine the length)
|
||||
* @param value - BACnetSpecialEvent structure
|
||||
* @return length of the APDU buffer, or 0 if not able to encode
|
||||
*/
|
||||
int bacnet_special_event_encode(uint8_t *apdu, BACNET_SPECIAL_EVENT *value)
|
||||
{
|
||||
int apdu_len = 0;
|
||||
int len;
|
||||
|
||||
if (value->periodTag == BACNET_SPECIAL_EVENT_PERIOD_CALENDAR_ENTRY) {
|
||||
len = bacnet_calendar_entry_context_encode(apdu,
|
||||
BACNET_SPECIAL_EVENT_PERIOD_CALENDAR_ENTRY,
|
||||
&value->period.calendarEntry);
|
||||
if (len < 0) {
|
||||
return -1;
|
||||
}
|
||||
apdu_len += len;
|
||||
if (apdu) {
|
||||
apdu += len;
|
||||
}
|
||||
} else {
|
||||
len = encode_context_object_id(apdu,
|
||||
BACNET_SPECIAL_EVENT_PERIOD_CALENDAR_REFERENCE,
|
||||
value->period.calendarReference.type,
|
||||
value->period.calendarReference.instance);
|
||||
if (len < 0) {
|
||||
return -1;
|
||||
}
|
||||
apdu_len += len;
|
||||
if (apdu) {
|
||||
apdu += len;
|
||||
}
|
||||
}
|
||||
|
||||
len = bacnet_dailyschedule_context_encode(apdu, 2, &value->timeValues);
|
||||
if (len < 0) {
|
||||
return -1;
|
||||
}
|
||||
apdu_len += len;
|
||||
if (apdu) {
|
||||
apdu += len;
|
||||
}
|
||||
|
||||
len = encode_context_unsigned(apdu, 3, value->priority);
|
||||
if (len < 0) {
|
||||
return -1;
|
||||
}
|
||||
apdu_len += len;
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Encode a context tagged BACnetSpecialEvent complex data type
|
||||
* @param apdu - the APDU buffer (NULL to determine the length)
|
||||
* @param tag_number - tag number to context encode
|
||||
* @param value - BACnetSpecialEvent structure
|
||||
* @return length of the APDU buffer, or 0 if not able to encode
|
||||
*/
|
||||
int bacnet_special_event_context_encode(
|
||||
uint8_t *apdu, uint8_t tag_number, BACNET_SPECIAL_EVENT *value)
|
||||
{
|
||||
int len = 0;
|
||||
int apdu_len = 0;
|
||||
|
||||
if (value) {
|
||||
len = encode_opening_tag(apdu, tag_number);
|
||||
apdu_len += len;
|
||||
if (apdu) {
|
||||
apdu += len;
|
||||
}
|
||||
len = bacnet_special_event_encode(apdu, value);
|
||||
apdu_len += len;
|
||||
if (apdu) {
|
||||
apdu += len;
|
||||
}
|
||||
len = encode_closing_tag(apdu, tag_number);
|
||||
apdu_len += len;
|
||||
}
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decode a context tagged BACnetSpecialEvent complex data type
|
||||
* @param apdu - the APDU buffer
|
||||
* @param apdu_size - the size of the APDU buffer
|
||||
* @param tag_number - tag number to context decode
|
||||
* @param value - BACnetSpecialEvent structure
|
||||
* @return length of the APDU buffer, or BACNET_STATUS_ERROR if unable to decode
|
||||
*/
|
||||
int bacnet_special_event_context_decode(uint8_t *apdu,
|
||||
int apdu_size,
|
||||
uint8_t tag_number,
|
||||
BACNET_SPECIAL_EVENT *value)
|
||||
{
|
||||
int apdu_len = 0;
|
||||
int len = 0;
|
||||
|
||||
if (bacnet_is_opening_tag_number(
|
||||
&apdu[apdu_len], apdu_size - apdu_len, tag_number, &len)) {
|
||||
apdu_len += len;
|
||||
} else {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
len = bacnet_special_event_decode(
|
||||
&apdu[apdu_len], apdu_size - apdu_len, value);
|
||||
if (len < 0) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
} else {
|
||||
apdu_len += len;
|
||||
}
|
||||
if (bacnet_is_closing_tag_number(
|
||||
&apdu[apdu_len], apdu_size - apdu_len, tag_number, &len)) {
|
||||
apdu_len += len;
|
||||
} else {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Compare the BACnetSpecialEvent complex data
|
||||
* @param value1 - BACNET_SPECIAL_EVENT structure
|
||||
* @param value2 - BACNET_SPECIAL_EVENT structure
|
||||
* @return true if the same
|
||||
*/
|
||||
bool bacnet_special_event_same(
|
||||
BACNET_SPECIAL_EVENT *value1, BACNET_SPECIAL_EVENT *value2)
|
||||
{
|
||||
BACNET_APPLICATION_DATA_VALUE adv1, adv2;
|
||||
BACNET_TIME_VALUE *tv1, *tv2;
|
||||
int ti;
|
||||
|
||||
if (value1->periodTag != value2->periodTag ||
|
||||
value1->priority != value2->priority) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (value1->periodTag == BACNET_SPECIAL_EVENT_PERIOD_CALENDAR_ENTRY) {
|
||||
if (!bacnet_calendar_entry_same(
|
||||
&value1->period.calendarEntry, &value2->period.calendarEntry)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO extract shared code with `bacnet_weeklyschedule_same` */
|
||||
if (value1->timeValues.TV_Count != value2->timeValues.TV_Count) {
|
||||
return false;
|
||||
}
|
||||
for (ti = 0; ti < value1->timeValues.TV_Count; ti++) {
|
||||
tv1 = &value1->timeValues.Time_Values[ti];
|
||||
tv2 = &value2->timeValues.Time_Values[ti];
|
||||
if (0 != datetime_compare_time(&tv1->Time, &tv2->Time)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bacnet_primitive_to_application_data_value(&adv1, &tv1->Value);
|
||||
bacnet_primitive_to_application_data_value(&adv2, &tv2->Value);
|
||||
|
||||
if (!bacapp_same_value(&adv1, &adv2)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief API for BACnetSpecialEvent complex data type encode and decode
|
||||
* @author Ondřej Hruška <ondra@ondrovo.com>
|
||||
* @author Steve Karg <skarg@users.sourceforge.net>
|
||||
* @date August 2023
|
||||
* @section LICENSE
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
#ifndef BACNET_SPECIAL_EVENT_H
|
||||
#define BACNET_SPECIAL_EVENT_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "bacnet/bacnet_stack_exports.h"
|
||||
#include "bacnet/bactimevalue.h"
|
||||
#include "bacnet/calendar_entry.h"
|
||||
#include "bacnet/dailyschedule.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
typedef enum BACnet_SpecialEventPeriod_Tags {
|
||||
BACNET_SPECIAL_EVENT_PERIOD_CALENDAR_ENTRY = 0,
|
||||
BACNET_SPECIAL_EVENT_PERIOD_CALENDAR_REFERENCE = 1
|
||||
} BACNET_SPECIAL_EVENT_PERIOD_TAG;
|
||||
|
||||
typedef struct BACnet_Special_Event {
|
||||
BACNET_SPECIAL_EVENT_PERIOD_TAG periodTag;
|
||||
union {
|
||||
BACNET_CALENDAR_ENTRY calendarEntry;
|
||||
BACNET_OBJECT_ID calendarReference;
|
||||
} period;
|
||||
/* We reuse the daily schedule struct and its encoding/decoding - it's identical */
|
||||
BACNET_DAILY_SCHEDULE timeValues;
|
||||
uint8_t priority;
|
||||
} BACNET_SPECIAL_EVENT;
|
||||
|
||||
/** Decode Special Event */
|
||||
BACNET_STACK_EXPORT
|
||||
int bacnet_special_event_decode(
|
||||
uint8_t * apdu,
|
||||
int max_apdu_len,
|
||||
BACNET_SPECIAL_EVENT * value);
|
||||
|
||||
/** Encode Special Event */
|
||||
BACNET_STACK_EXPORT
|
||||
int bacnet_special_event_encode(
|
||||
uint8_t * apdu,
|
||||
BACNET_SPECIAL_EVENT * value);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bacnet_special_event_context_encode(
|
||||
uint8_t *apdu, uint8_t tag_number, BACNET_SPECIAL_EVENT *value);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bacnet_special_event_context_decode(
|
||||
uint8_t *apdu, int max_apdu_len, uint8_t tag_number,
|
||||
BACNET_SPECIAL_EVENT *value);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool bacnet_special_event_same(
|
||||
BACNET_SPECIAL_EVENT *value1, BACNET_SPECIAL_EVENT *value2);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* BACNET_SPECIAL_EVENT_H */
|
||||
@@ -59,8 +59,8 @@ int bacnet_weeklyschedule_decode(
|
||||
}
|
||||
value->singleDay = false;
|
||||
for (wi = 0; wi < 7; wi++) {
|
||||
len = bacnet_dailyschedule_decode(&apdu[apdu_len],
|
||||
max_apdu_len - apdu_len, &value->weeklySchedule[wi]);
|
||||
len = bacnet_dailyschedule_context_decode(&apdu[apdu_len],
|
||||
max_apdu_len - apdu_len, 0, &value->weeklySchedule[wi]);
|
||||
if (len < 0) {
|
||||
if (wi == 1) {
|
||||
value->singleDay = true;
|
||||
@@ -96,8 +96,8 @@ int bacnet_weeklyschedule_encode(uint8_t *apdu, BACNET_WEEKLY_SCHEDULE *value)
|
||||
if (apdu) {
|
||||
apdu_offset = &apdu[apdu_len];
|
||||
}
|
||||
len = bacnet_dailyschedule_encode(
|
||||
apdu_offset, &value->weeklySchedule[wi]);
|
||||
len = bacnet_dailyschedule_context_encode(
|
||||
apdu_offset, 0, &value->weeklySchedule[wi]);
|
||||
if (len < 0) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ if (CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID MATCHES "GNU")
|
||||
add_compile_options(-Wno-sign-conversion -Wno-conversion)
|
||||
add_compile_options(-Wno-sign-compare -Wno-long-long)
|
||||
add_compile_options(-Wno-implicit-fallthrough -Wno-attributes)
|
||||
add_compile_options(-Wno-missing-braces)
|
||||
# ignore some warnings that occur during unit testing
|
||||
add_compile_options(-Wno-unused-variable -Wno-unused-function)
|
||||
add_compile_options(-Wno-unused-parameter)
|
||||
@@ -87,6 +88,7 @@ list(APPEND testdirs
|
||||
bacnet/reject
|
||||
bacnet/rp
|
||||
bacnet/rpm
|
||||
bacnet/specialevent
|
||||
bacnet/timestamp
|
||||
bacnet/timesync
|
||||
bacnet/whohas
|
||||
|
||||
@@ -55,6 +55,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -38,6 +38,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/bacint.c
|
||||
${SRC_DIR}/bacnet/bacreal.c
|
||||
${SRC_DIR}/bacnet/bacstr.c
|
||||
${SRC_DIR}/bacnet/datetime.c
|
||||
${SRC_DIR}/bacnet/basic/sys/days.c
|
||||
${SRC_DIR}/bacnet/basic/sys/bigend.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
|
||||
+169
-19
@@ -7,10 +7,11 @@
|
||||
/* @file
|
||||
* @brief test BACnet integer encode/decode APIs
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <ctype.h> /* For isprint */
|
||||
#include <zephyr/ztest.h>
|
||||
#include <bacnet/bacdcode.h>
|
||||
#include <memory.h>
|
||||
|
||||
/**
|
||||
* @addtogroup bacnet_tests
|
||||
@@ -301,7 +302,7 @@ static void testBACDCodeReal(void)
|
||||
#if defined(BACNET_STACK_DEPRECATED_DISABLE)
|
||||
encode_bacnet_real(value, &real_apdu[0]);
|
||||
decode_real(&real_apdu[0], &decoded_value);
|
||||
zassert_equal(decoded_value, value, NULL);
|
||||
zassert_false(islessgreater(decoded_value, value), NULL);
|
||||
encode_bacnet_real(value, &encoded_apdu[0]);
|
||||
zassert_equal(
|
||||
memcmp(&real_apdu, &encoded_apdu, sizeof(real_apdu)), 0, NULL);
|
||||
@@ -320,7 +321,7 @@ static void testBACDCodeReal(void)
|
||||
zassert_equal(len, 1, NULL);
|
||||
zassert_equal(long_value, 4, NULL);
|
||||
decode_real(&apdu[len], &decoded_value);
|
||||
zassert_equal(decoded_value, value, NULL);
|
||||
zassert_false(islessgreater(decoded_value, value), NULL);
|
||||
#endif
|
||||
null_len = bacnet_real_application_decode(apdu, apdu_len, NULL);
|
||||
zassert_equal(apdu_len, null_len, NULL);
|
||||
@@ -331,7 +332,7 @@ static void testBACDCodeReal(void)
|
||||
zassert_equal(tag.number, BACNET_APPLICATION_TAG_REAL, NULL);
|
||||
zassert_true(tag.application, NULL);
|
||||
zassert_false(tag.context, NULL);
|
||||
zassert_equal(decoded_value, value, NULL);
|
||||
zassert_false(islessgreater(decoded_value, value), NULL);
|
||||
while (apdu_len) {
|
||||
apdu_len--;
|
||||
len = bacnet_real_application_decode(apdu, apdu_len, NULL);
|
||||
@@ -358,7 +359,7 @@ static void testBACDCodeDouble(void)
|
||||
#if defined(BACNET_STACK_DEPRECATED_DISABLE)
|
||||
encode_bacnet_double(value, &double_apdu[0]);
|
||||
decode_double(&double_apdu[0], &decoded_value);
|
||||
zassert_equal(decoded_value, value, NULL);
|
||||
zassert_false(islessgreater(decoded_value, value), NULL);
|
||||
encode_bacnet_double(value, &encoded_apdu[0]);
|
||||
zassert_equal(
|
||||
memcmp(&double_apdu, &encoded_apdu, sizeof(double_apdu)), 0, NULL);
|
||||
@@ -390,7 +391,7 @@ static void testBACDCodeDouble(void)
|
||||
zassert_false(tag.context, NULL);
|
||||
zassert_false(tag.closing, NULL);
|
||||
zassert_false(tag.opening, NULL);
|
||||
zassert_equal(decoded_value, value, NULL);
|
||||
zassert_false(islessgreater(decoded_value, value), NULL);
|
||||
while (apdu_len) {
|
||||
apdu_len--;
|
||||
len = bacnet_double_application_decode(apdu, apdu_len, NULL);
|
||||
@@ -400,6 +401,107 @@ static void testBACDCodeDouble(void)
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST(bacdcode_tests, testBACnetDateDecodes)
|
||||
#else
|
||||
static void testBACnetDateDecodes(void)
|
||||
#endif
|
||||
{
|
||||
uint8_t apdu[MAX_APDU];
|
||||
uint8_t sample[10] = { 0xa4, 0xff, 0xff, 0xff, 0xff };
|
||||
int inLen;
|
||||
int outLen;
|
||||
int outLen2;
|
||||
|
||||
BACNET_DATE in;
|
||||
BACNET_DATE out;
|
||||
|
||||
in.day = 3;
|
||||
in.month = 10;
|
||||
in.wday = 5;
|
||||
in.year = 1945;
|
||||
|
||||
inLen = encode_application_date(apdu, &in);
|
||||
outLen = decode_application_date(apdu, &out);
|
||||
|
||||
zassert_equal(inLen, outLen, NULL);
|
||||
zassert_equal(in.day, out.day, NULL);
|
||||
zassert_equal(in.month, out.month, NULL);
|
||||
zassert_equal(in.wday, out.wday, NULL);
|
||||
zassert_equal(in.year, out.year, NULL);
|
||||
|
||||
memset(&out, 0, sizeof(out));
|
||||
outLen = decode_application_date(sample, &out);
|
||||
|
||||
/* try decoding sample data captured from a bacnet device - all wildcards */
|
||||
zassert_equal(5, outLen, NULL);
|
||||
zassert_equal(0xff, out.day, NULL);
|
||||
zassert_equal(0xff, out.month, NULL);
|
||||
zassert_equal(0xff, out.wday, NULL);
|
||||
zassert_equal(2155, out.year, NULL);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST(bacdcode_tests, testBACnetDateRangeDecodes)
|
||||
#else
|
||||
static void testBACnetDateRangeDecodes(void)
|
||||
#endif
|
||||
{
|
||||
uint8_t apdu[MAX_APDU];
|
||||
uint8_t sample[10] = { 0xa4, 0xff, 0xff, 0xff, 0xff, 0xa4, 0xff, 0xff, 0xff,
|
||||
0xff };
|
||||
int len;
|
||||
int null_len;
|
||||
int test_len;
|
||||
int outLen2;
|
||||
|
||||
BACNET_DATE_RANGE data;
|
||||
BACNET_DATE_RANGE test_data;
|
||||
|
||||
memset(&test_data, 0, sizeof(test_data));
|
||||
|
||||
data.startdate.day = 3;
|
||||
data.startdate.month = 10;
|
||||
data.startdate.wday = 5;
|
||||
data.startdate.year = 1945;
|
||||
|
||||
data.enddate.day = 24;
|
||||
data.enddate.month = 8;
|
||||
data.enddate.wday = 4;
|
||||
data.enddate.year = 2023;
|
||||
|
||||
len = bacnet_daterange_encode(apdu, &data);
|
||||
null_len = bacnet_daterange_encode(NULL, &data);
|
||||
zassert_equal(len, null_len, NULL);
|
||||
|
||||
test_len = bacnet_daterange_decode(apdu, len, &test_data);
|
||||
zassert_equal(len, test_len, NULL);
|
||||
zassert_equal(data.startdate.day, test_data.startdate.day, NULL);
|
||||
zassert_equal(data.startdate.month, test_data.startdate.month, NULL);
|
||||
zassert_equal(data.startdate.wday, test_data.startdate.wday, NULL);
|
||||
zassert_equal(data.startdate.year, test_data.startdate.year, NULL);
|
||||
|
||||
zassert_equal(data.enddate.day, test_data.enddate.day, NULL);
|
||||
zassert_equal(data.enddate.month, test_data.enddate.month, NULL);
|
||||
zassert_equal(data.enddate.wday, test_data.enddate.wday, NULL);
|
||||
zassert_equal(data.enddate.year, test_data.enddate.year, NULL);
|
||||
|
||||
memset(&test_data, 0, sizeof(test_data));
|
||||
test_len = bacnet_daterange_decode(sample, len, &test_data);
|
||||
|
||||
/* try decoding sample data captured from a bacnet device - all wildcards */
|
||||
zassert_equal(10, test_len, NULL);
|
||||
zassert_equal(0xff, test_data.startdate.day, NULL);
|
||||
zassert_equal(0xff, test_data.startdate.month, NULL);
|
||||
zassert_equal(0xff, test_data.startdate.wday, NULL);
|
||||
zassert_equal(2155, test_data.startdate.year, NULL);
|
||||
|
||||
zassert_equal(0xff, test_data.enddate.day, NULL);
|
||||
zassert_equal(0xff, test_data.enddate.month, NULL);
|
||||
zassert_equal(0xff, test_data.enddate.wday, NULL);
|
||||
zassert_equal(2155, test_data.enddate.year, NULL);
|
||||
}
|
||||
|
||||
static void verifyBACDCodeUnsignedValue(BACNET_UNSIGNED_INTEGER value)
|
||||
{
|
||||
uint8_t array[5] = { 0 };
|
||||
@@ -413,7 +515,7 @@ static void verifyBACDCodeUnsignedValue(BACNET_UNSIGNED_INTEGER value)
|
||||
len_value = encode_application_unsigned(&array[0], value);
|
||||
len = decode_tag_number_and_value(&array[0], &tag_number, &len_value);
|
||||
len = decode_unsigned(&array[len], len_value, &decoded_value);
|
||||
zassert_equal(decoded_value, value, "value=%lu decoded_value=%lu\n",
|
||||
zassert_equal(decoded_value, value, "value=%lu decoded_value=%lu\n",
|
||||
(unsigned long)value, (unsigned long)decoded_value);
|
||||
encode_application_unsigned(&encoded_array[0], decoded_value);
|
||||
zassert_equal(memcmp(&array[0], &encoded_array[0], sizeof(array)), 0, NULL);
|
||||
@@ -1155,7 +1257,7 @@ static void testFloatContextDecodes(void)
|
||||
outLen2 = bacnet_real_context_decode(apdu, inLen, 9, &out);
|
||||
|
||||
zassert_equal(inLen, outLen, NULL);
|
||||
zassert_equal(in, out, NULL);
|
||||
zassert_false(islessgreater(in, out), NULL);
|
||||
zassert_equal(outLen2, 0, NULL);
|
||||
|
||||
inLen = encode_context_real(apdu, large_context_tag, in);
|
||||
@@ -1164,7 +1266,7 @@ static void testFloatContextDecodes(void)
|
||||
bacnet_real_context_decode(apdu, inLen, large_context_tag - 1, &out);
|
||||
|
||||
zassert_equal(inLen, outLen, NULL);
|
||||
zassert_equal(in, out, NULL);
|
||||
zassert_false(islessgreater(in, out), NULL);
|
||||
zassert_equal(outLen2, 0, NULL);
|
||||
|
||||
in = 0.0f;
|
||||
@@ -1173,7 +1275,7 @@ static void testFloatContextDecodes(void)
|
||||
outLen2 = bacnet_real_context_decode(apdu, inLen, 9, &out);
|
||||
|
||||
zassert_equal(inLen, outLen, NULL);
|
||||
zassert_equal(in, out, NULL);
|
||||
zassert_false(islessgreater(in, out), NULL);
|
||||
|
||||
inLen = encode_context_real(apdu, large_context_tag, in);
|
||||
outLen = bacnet_real_context_decode(apdu, inLen, large_context_tag, &out);
|
||||
@@ -1181,7 +1283,7 @@ static void testFloatContextDecodes(void)
|
||||
bacnet_real_context_decode(apdu, inLen, large_context_tag - 1, &out);
|
||||
|
||||
zassert_equal(inLen, outLen, NULL);
|
||||
zassert_equal(in, out, NULL);
|
||||
zassert_false(islessgreater(in, out), NULL);
|
||||
zassert_equal(outLen2, 0, NULL);
|
||||
while (inLen) {
|
||||
inLen--;
|
||||
@@ -1212,7 +1314,7 @@ static void testDoubleContextDecodes(void)
|
||||
outLen = bacnet_double_context_decode(apdu, inLen, 10, &out);
|
||||
outLen2 = bacnet_double_context_decode(apdu, inLen, 9, &out);
|
||||
zassert_equal(inLen, outLen, NULL);
|
||||
zassert_equal(in, out, NULL);
|
||||
zassert_false(islessgreater(in, out), NULL);
|
||||
zassert_equal(outLen2, 0, NULL);
|
||||
|
||||
inLen = encode_context_double(apdu, large_context_tag, in);
|
||||
@@ -1220,7 +1322,7 @@ static void testDoubleContextDecodes(void)
|
||||
outLen2 =
|
||||
bacnet_double_context_decode(apdu, inLen, large_context_tag - 1, &out);
|
||||
zassert_equal(inLen, outLen, NULL);
|
||||
zassert_equal(in, out, NULL);
|
||||
zassert_false(islessgreater(in, out), NULL);
|
||||
zassert_equal(outLen2, 0, NULL);
|
||||
|
||||
in = 0.0;
|
||||
@@ -1228,7 +1330,7 @@ static void testDoubleContextDecodes(void)
|
||||
outLen = bacnet_double_context_decode(apdu, inLen, 10, &out);
|
||||
outLen2 = bacnet_double_context_decode(apdu, inLen, 9, &out);
|
||||
zassert_equal(inLen, outLen, NULL);
|
||||
zassert_equal(in, out, NULL);
|
||||
zassert_false(islessgreater(in, out), NULL);
|
||||
zassert_equal(outLen2, 0, NULL);
|
||||
|
||||
inLen = encode_context_double(apdu, large_context_tag, in);
|
||||
@@ -1236,7 +1338,7 @@ static void testDoubleContextDecodes(void)
|
||||
outLen2 =
|
||||
bacnet_double_context_decode(apdu, inLen, large_context_tag - 1, &out);
|
||||
zassert_equal(inLen, outLen, NULL);
|
||||
zassert_equal(in, out, NULL);
|
||||
zassert_false(islessgreater(in, out), NULL);
|
||||
zassert_equal(outLen2, 0, NULL);
|
||||
while (inLen) {
|
||||
inLen--;
|
||||
@@ -1517,15 +1619,16 @@ static void testDateContextDecodes(void)
|
||||
/* Test large tags */
|
||||
inLen = encode_context_date(apdu, large_context_tag, &in);
|
||||
outLen = bacnet_date_context_decode(apdu, inLen, large_context_tag, &out);
|
||||
outLen2 =
|
||||
bacnet_date_context_decode(apdu, inLen, large_context_tag - 1, &out);
|
||||
|
||||
zassert_equal(inLen, outLen, NULL);
|
||||
zassert_equal(in.day, out.day, NULL);
|
||||
zassert_equal(in.month, out.month, NULL);
|
||||
zassert_equal(in.wday, out.wday, NULL);
|
||||
zassert_equal(in.year, out.year, NULL);
|
||||
|
||||
/* incorrect tag */
|
||||
outLen2 =
|
||||
bacnet_date_context_decode(apdu, inLen, large_context_tag - 1, &out);
|
||||
zassert_equal(outLen2, 0, NULL);
|
||||
/* short APDU */
|
||||
while (inLen) {
|
||||
inLen--;
|
||||
outLen2 =
|
||||
@@ -1534,6 +1637,50 @@ static void testDateContextDecodes(void)
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST(bacdcode_tests, testDateRangeContextDecodes)
|
||||
#else
|
||||
static void testDateRangeContextDecodes(void)
|
||||
#endif
|
||||
{
|
||||
uint8_t apdu[MAX_APDU];
|
||||
int len;
|
||||
int null_len;
|
||||
int test_len;
|
||||
|
||||
BACNET_DATE_RANGE data;
|
||||
BACNET_DATE_RANGE test_data;
|
||||
memset(&data, 0, sizeof(data));
|
||||
memset(&test_data, 0, sizeof(test_data));
|
||||
|
||||
data.startdate.day = 3;
|
||||
data.startdate.month = 10;
|
||||
data.startdate.wday = 5;
|
||||
data.startdate.year = 1945;
|
||||
|
||||
data.enddate.day = 24;
|
||||
data.enddate.month = 8;
|
||||
data.enddate.wday = 4;
|
||||
data.enddate.year = 2023;
|
||||
|
||||
len = bacnet_daterange_context_encode(apdu, 10, &data);
|
||||
null_len = bacnet_daterange_context_encode(NULL, 10, &data);
|
||||
zassert_equal(len, null_len, NULL);
|
||||
test_len = bacnet_daterange_context_decode(apdu, len, 10, &test_data);
|
||||
zassert_equal(len, test_len, NULL);
|
||||
zassert_equal(data.startdate.day, test_data.startdate.day, NULL);
|
||||
zassert_equal(data.startdate.month, test_data.startdate.month, NULL);
|
||||
zassert_equal(data.startdate.wday, test_data.startdate.wday, NULL);
|
||||
zassert_equal(data.startdate.year, test_data.startdate.year, NULL);
|
||||
zassert_equal(data.enddate.day, test_data.enddate.day, NULL);
|
||||
zassert_equal(data.enddate.month, test_data.enddate.month, NULL);
|
||||
zassert_equal(data.enddate.wday, test_data.enddate.wday, NULL);
|
||||
zassert_equal(data.enddate.year, test_data.enddate.year, NULL);
|
||||
/* incorrect tag number */
|
||||
test_len = bacnet_daterange_context_decode(apdu, len, 9, &test_data);
|
||||
zassert_equal(test_len, BACNET_STATUS_ERROR, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Encode a BACnetARRAY property element; a function template
|
||||
* @param object_instance [in] BACnet network port object instance number
|
||||
@@ -1629,6 +1776,8 @@ void test_main(void)
|
||||
ztest_unit_test(testBACDCodeUnsigned),
|
||||
ztest_unit_test(testBACnetUnsigned),
|
||||
ztest_unit_test(testBACDCodeSigned), ztest_unit_test(testBACnetSigned),
|
||||
ztest_unit_test(testBACnetDateDecodes),
|
||||
ztest_unit_test(testBACnetDateRangeDecodes),
|
||||
ztest_unit_test(testBACDCodeEnumerated),
|
||||
ztest_unit_test(testBACDCodeOctetString),
|
||||
ztest_unit_test(testBACDCodeCharacterString),
|
||||
@@ -1645,6 +1794,7 @@ void test_main(void)
|
||||
ztest_unit_test(testBitStringContextDecodes),
|
||||
ztest_unit_test(testTimeContextDecodes),
|
||||
ztest_unit_test(testDateContextDecodes),
|
||||
ztest_unit_test(testDateRangeContextDecodes),
|
||||
ztest_unit_test(testOctetStringContextDecodes),
|
||||
ztest_unit_test(testBACDCodeDouble),
|
||||
ztest_unit_test(test_bacnet_array_encode));
|
||||
|
||||
@@ -56,6 +56,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -57,6 +57,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
/* @file
|
||||
* @brief test BACnet real value encode/decode APIs
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <zephyr/ztest.h>
|
||||
#include <bacnet/bacreal.h>
|
||||
#include <bacnet/bacdef.h>
|
||||
@@ -34,7 +34,7 @@ static void testBACreal(void)
|
||||
zassert_equal(len, 4, NULL);
|
||||
test_len = decode_real(&apdu[0], &test_real_value);
|
||||
zassert_equal(test_len, len, NULL);
|
||||
zassert_equal(test_real_value, real_value, NULL);
|
||||
zassert_false(islessgreater(test_real_value, real_value), NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,7 +54,7 @@ static void testBACdouble(void)
|
||||
zassert_equal(len, 8, NULL);
|
||||
test_len = decode_double(&apdu[0], &test_double_value);
|
||||
zassert_equal(test_len, len, NULL);
|
||||
zassert_equal(test_double_value, double_value, NULL);
|
||||
zassert_false(islessgreater(test_double_value, double_value), NULL);
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -53,6 +53,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/timestamp.c
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -53,6 +53,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -53,6 +53,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -57,6 +57,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -54,6 +54,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -53,6 +53,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -55,6 +55,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -54,6 +54,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -58,6 +58,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -56,6 +56,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -57,6 +57,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
../mock/device_mock.c
|
||||
|
||||
@@ -56,6 +56,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -60,6 +60,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
../mock/apdu_mock.c
|
||||
|
||||
@@ -56,6 +56,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -57,6 +57,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
../mock/device_mock.c
|
||||
|
||||
@@ -57,6 +57,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
../mock/device_mock.c
|
||||
|
||||
@@ -54,6 +54,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -55,6 +55,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/wp.c
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
../mock/device_mock.c
|
||||
|
||||
@@ -58,6 +58,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
../mock/device_mock.c
|
||||
|
||||
@@ -58,6 +58,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
../mock/device_mock.c
|
||||
|
||||
@@ -54,6 +54,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -57,6 +57,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -55,6 +55,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
${SRC_DIR}/bacnet/memcopy.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
|
||||
@@ -96,6 +96,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/wp.c
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
./stubs.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
|
||||
@@ -54,6 +54,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -56,6 +56,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
./stubs.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
|
||||
@@ -58,6 +58,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
../mock/device_mock.c
|
||||
|
||||
@@ -55,6 +55,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -54,6 +54,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
../mock/device_mock.c
|
||||
|
||||
@@ -57,6 +57,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
../mock/device_mock.c
|
||||
|
||||
@@ -56,6 +56,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -59,6 +59,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/wp.c
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./stubs.c
|
||||
./src/main.c
|
||||
|
||||
@@ -57,6 +57,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -54,6 +54,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -54,6 +54,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -54,6 +54,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/wp.c
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -54,6 +54,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/wp.c
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
../mock/device_mock.c
|
||||
|
||||
@@ -54,6 +54,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -270,7 +270,8 @@ static void testCOVSubscribePropertyData(
|
||||
zassert_equal(
|
||||
test_data->covIncrementPresent, data->covIncrementPresent, NULL);
|
||||
if (test_data->covIncrementPresent) {
|
||||
zassert_equal(test_data->covIncrement, data->covIncrement, NULL);
|
||||
zassert_false(islessgreater(test_data->covIncrement,
|
||||
data->covIncrement), NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/bacstr.c
|
||||
${SRC_DIR}/bacnet/bactext.c
|
||||
${SRC_DIR}/bacnet/basic/sys/bigend.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/datetime.c
|
||||
${SRC_DIR}/bacnet/basic/sys/days.c
|
||||
${SRC_DIR}/bacnet/indtext.c
|
||||
@@ -55,6 +56,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -55,7 +55,9 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
# Test and test library files
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
${ZTST_DIR}/ztest.c
|
||||
|
||||
@@ -57,6 +57,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/lighting.c
|
||||
${SRC_DIR}/bacnet/timestamp.c
|
||||
${SRC_DIR}/bacnet/hostnport.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -291,8 +291,9 @@ static void testEventEventState(void)
|
||||
zassert_equal(data.notificationParams.changeOfValue.tag,
|
||||
data2.notificationParams.changeOfValue.tag, NULL);
|
||||
|
||||
zassert_equal(data.notificationParams.changeOfValue.newValue.changeValue,
|
||||
data2.notificationParams.changeOfValue.newValue.changeValue, NULL);
|
||||
zassert_false(islessgreater(
|
||||
data.notificationParams.changeOfValue.newValue.changeValue,
|
||||
data2.notificationParams.changeOfValue.newValue.changeValue), NULL);
|
||||
|
||||
/*
|
||||
** Event Type = EVENT_CHANGE_OF_VALUE - bitstring value
|
||||
@@ -462,14 +463,15 @@ static void testEventEventState(void)
|
||||
apdu_len, test_len, "apdu_len=%d test_len=%d", apdu_len, test_len);
|
||||
verifyBaseEventState();
|
||||
|
||||
zassert_equal(data.notificationParams.floatingLimit.referenceValue,
|
||||
data2.notificationParams.floatingLimit.referenceValue, NULL);
|
||||
|
||||
zassert_equal(data.notificationParams.floatingLimit.setPointValue,
|
||||
data2.notificationParams.floatingLimit.setPointValue, NULL);
|
||||
|
||||
zassert_equal(data.notificationParams.floatingLimit.errorLimit,
|
||||
data2.notificationParams.floatingLimit.errorLimit, NULL);
|
||||
zassert_false(islessgreater(
|
||||
data.notificationParams.floatingLimit.referenceValue,
|
||||
data2.notificationParams.floatingLimit.referenceValue), NULL);
|
||||
zassert_false(islessgreater(
|
||||
data.notificationParams.floatingLimit.setPointValue,
|
||||
data2.notificationParams.floatingLimit.setPointValue), NULL);
|
||||
zassert_false(islessgreater(
|
||||
data.notificationParams.floatingLimit.errorLimit,
|
||||
data2.notificationParams.floatingLimit.errorLimit), NULL);
|
||||
zassert_true(
|
||||
bitstring_same(&data.notificationParams.floatingLimit.statusFlags,
|
||||
&data2.notificationParams.floatingLimit.statusFlags),
|
||||
@@ -508,14 +510,16 @@ static void testEventEventState(void)
|
||||
zassert_equal(apdu_len, test_len, NULL);
|
||||
verifyBaseEventState();
|
||||
|
||||
zassert_equal(data.notificationParams.outOfRange.deadband,
|
||||
data2.notificationParams.outOfRange.deadband, NULL);
|
||||
zassert_false(islessgreater(data.notificationParams.outOfRange.deadband,
|
||||
data2.notificationParams.outOfRange.deadband), NULL);
|
||||
|
||||
zassert_equal(data.notificationParams.outOfRange.exceededLimit,
|
||||
data2.notificationParams.outOfRange.exceededLimit, NULL);
|
||||
zassert_false(islessgreater(
|
||||
data.notificationParams.outOfRange.exceededLimit,
|
||||
data2.notificationParams.outOfRange.exceededLimit), NULL);
|
||||
|
||||
zassert_equal(data.notificationParams.outOfRange.exceedingValue,
|
||||
data2.notificationParams.outOfRange.exceedingValue, NULL);
|
||||
zassert_false(islessgreater(
|
||||
data.notificationParams.outOfRange.exceedingValue,
|
||||
data2.notificationParams.outOfRange.exceedingValue), NULL);
|
||||
zassert_true(bitstring_same(&data.notificationParams.outOfRange.statusFlags,
|
||||
&data2.notificationParams.outOfRange.statusFlags),
|
||||
NULL);
|
||||
|
||||
@@ -54,6 +54,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -54,6 +54,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -55,6 +55,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -55,6 +55,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -55,6 +55,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -54,6 +54,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -56,6 +56,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
|
||||
|
||||
get_filename_component(basename ${CMAKE_CURRENT_SOURCE_DIR} NAME)
|
||||
project(test_${basename}
|
||||
VERSION 1.0.0
|
||||
LANGUAGES C)
|
||||
|
||||
|
||||
string(REGEX REPLACE
|
||||
"/test/bacnet/[a-zA-Z_/-]*$"
|
||||
"/src"
|
||||
SRC_DIR
|
||||
${CMAKE_CURRENT_SOURCE_DIR})
|
||||
string(REGEX REPLACE
|
||||
"/test/bacnet/[a-zA-Z_/-]*$"
|
||||
"/test"
|
||||
TST_DIR
|
||||
${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set(ZTST_DIR "${TST_DIR}/ztest/src")
|
||||
|
||||
add_compile_definitions(
|
||||
BIG_ENDIAN=0
|
||||
CONFIG_ZTEST=1
|
||||
BACAPP_ALL
|
||||
)
|
||||
|
||||
include_directories(
|
||||
${SRC_DIR}
|
||||
${TST_DIR}/ztest/include
|
||||
)
|
||||
|
||||
add_executable(${PROJECT_NAME}
|
||||
# File(s) under test
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Support files and stubs (pathname alphabetical)
|
||||
${SRC_DIR}/bacnet/bacaddr.c
|
||||
${SRC_DIR}/bacnet/bacapp.c
|
||||
${SRC_DIR}/bacnet/bacdcode.c
|
||||
${SRC_DIR}/bacnet/bacdest.c
|
||||
${SRC_DIR}/bacnet/bacdevobjpropref.c
|
||||
${SRC_DIR}/bacnet/bacint.c
|
||||
${SRC_DIR}/bacnet/bacreal.c
|
||||
${SRC_DIR}/bacnet/bacstr.c
|
||||
${SRC_DIR}/bacnet/bactext.c
|
||||
${SRC_DIR}/bacnet/basic/sys/bigend.c
|
||||
${SRC_DIR}/bacnet/datetime.c
|
||||
${SRC_DIR}/bacnet/basic/sys/days.c
|
||||
${SRC_DIR}/bacnet/indtext.c
|
||||
${SRC_DIR}/bacnet/hostnport.c
|
||||
${SRC_DIR}/bacnet/lighting.c
|
||||
${SRC_DIR}/bacnet/timestamp.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
${ZTST_DIR}/ztest.c
|
||||
)
|
||||
@@ -0,0 +1,377 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief Unit test for BACnetSpecialEvent. This test also indirectly tests
|
||||
* BACnetCalendarEntry
|
||||
* @author Ondřej Hruška <ondra@ondrovo.com>
|
||||
* @date Aug 2023
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <zephyr/ztest.h>
|
||||
#include "bacnet/bactimevalue.h"
|
||||
#include "bacnet/special_event.h"
|
||||
#include "bacnet/calendar_entry.h"
|
||||
#include "bacnet/datetime.h"
|
||||
#include "bacnet/bacapp.h"
|
||||
|
||||
/**
|
||||
* @addtogroup bacnet_tests
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Test encode/decode API
|
||||
*/
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST(BACnetSpecialEvent_tests, test_BACnetSpecialEvent_CalendarRef)
|
||||
#else
|
||||
static void test_BACnetSpecialEvent_CalendarRef(void)
|
||||
#endif
|
||||
{
|
||||
int len, apdu_len, null_len;
|
||||
uint8_t apdu[MAX_APDU] = { 0 };
|
||||
|
||||
BACNET_SPECIAL_EVENT in = {
|
||||
.periodTag = BACNET_SPECIAL_EVENT_PERIOD_CALENDAR_REFERENCE,
|
||||
.period = {
|
||||
.calendarReference = {
|
||||
.instance = 5,
|
||||
.type = OBJECT_CALENDAR,
|
||||
}
|
||||
},
|
||||
.timeValues = {
|
||||
.TV_Count = 2,
|
||||
.Time_Values = {
|
||||
{
|
||||
.Time = {
|
||||
.hour = 12,
|
||||
.min = 30,
|
||||
.sec = 15,
|
||||
.hundredths = 5
|
||||
},
|
||||
.Value = {
|
||||
.tag = BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
||||
.type = {
|
||||
.Unsigned_Int = 15,
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
.Time = {
|
||||
.hour = 16,
|
||||
.min = 1,
|
||||
.sec = 2,
|
||||
.hundredths = 3
|
||||
},
|
||||
.Value = {
|
||||
.tag = BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
||||
.type = {
|
||||
.Unsigned_Int = 0,
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
.priority = 5,
|
||||
};
|
||||
BACNET_SPECIAL_EVENT out = { 0 };
|
||||
|
||||
len = bacnet_special_event_encode(apdu, &in);
|
||||
null_len = bacnet_special_event_encode(NULL, &in);
|
||||
zassert_equal(len, null_len, NULL);
|
||||
|
||||
apdu_len = bacnet_special_event_decode(apdu, len, &out);
|
||||
zassert_equal(len, apdu_len, NULL);
|
||||
|
||||
zassert_equal(in.periodTag, out.periodTag, NULL);
|
||||
zassert_equal(in.period.calendarReference.instance,
|
||||
out.period.calendarReference.instance, NULL);
|
||||
zassert_equal(in.period.calendarReference.type,
|
||||
out.period.calendarReference.type, NULL);
|
||||
zassert_equal(in.timeValues.TV_Count, out.timeValues.TV_Count, NULL);
|
||||
|
||||
zassert_equal(in.timeValues.Time_Values[0].Time.hour,
|
||||
out.timeValues.Time_Values[0].Time.hour, NULL);
|
||||
zassert_equal(in.timeValues.Time_Values[0].Time.min,
|
||||
out.timeValues.Time_Values[0].Time.min, NULL);
|
||||
zassert_equal(in.timeValues.Time_Values[0].Time.sec,
|
||||
out.timeValues.Time_Values[0].Time.sec, NULL);
|
||||
zassert_equal(in.timeValues.Time_Values[0].Time.hundredths,
|
||||
out.timeValues.Time_Values[0].Time.hundredths, NULL);
|
||||
|
||||
zassert_equal(in.timeValues.Time_Values[0].Value.tag,
|
||||
out.timeValues.Time_Values[0].Value.tag, NULL);
|
||||
zassert_equal(in.timeValues.Time_Values[0].Value.type.Unsigned_Int,
|
||||
out.timeValues.Time_Values[0].Value.type.Unsigned_Int, NULL);
|
||||
|
||||
zassert_equal(in.timeValues.Time_Values[1].Time.hour,
|
||||
out.timeValues.Time_Values[1].Time.hour, NULL);
|
||||
zassert_equal(in.timeValues.Time_Values[1].Time.min,
|
||||
out.timeValues.Time_Values[1].Time.min, NULL);
|
||||
zassert_equal(in.timeValues.Time_Values[1].Time.sec,
|
||||
out.timeValues.Time_Values[1].Time.sec, NULL);
|
||||
zassert_equal(in.timeValues.Time_Values[1].Time.hundredths,
|
||||
out.timeValues.Time_Values[1].Time.hundredths, NULL);
|
||||
|
||||
zassert_equal(in.timeValues.Time_Values[1].Value.tag,
|
||||
out.timeValues.Time_Values[1].Value.tag, NULL);
|
||||
zassert_equal(in.timeValues.Time_Values[1].Value.type.Unsigned_Int,
|
||||
out.timeValues.Time_Values[1].Value.type.Unsigned_Int, NULL);
|
||||
|
||||
zassert_equal(in.priority, out.priority, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test encode/decode API with Calendar Entry (Date variant)
|
||||
*/
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST(BACnetSpecialEvent_tests, test_BACnetSpecialEvent_Date)
|
||||
#else
|
||||
static void test_BACnetSpecialEvent_Date(void)
|
||||
#endif
|
||||
{
|
||||
int len, apdu_len, null_len;
|
||||
uint8_t apdu[MAX_APDU] = { 0 };
|
||||
|
||||
BACNET_SPECIAL_EVENT in = {
|
||||
.periodTag = BACNET_SPECIAL_EVENT_PERIOD_CALENDAR_ENTRY,
|
||||
.period = {
|
||||
.calendarEntry = {
|
||||
.tag = BACNET_CALENDAR_DATE,
|
||||
.type = {
|
||||
.Date = {
|
||||
.year = 2155,
|
||||
.month = 10,
|
||||
.day = 0xff,
|
||||
.wday = 0xff,
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
.timeValues = {
|
||||
.TV_Count = 0,
|
||||
.Time_Values = { 0 }
|
||||
},
|
||||
.priority = 16,
|
||||
};
|
||||
BACNET_SPECIAL_EVENT out = { 0 };
|
||||
|
||||
len = bacnet_special_event_encode(apdu, &in);
|
||||
null_len = bacnet_special_event_encode(NULL, &in);
|
||||
zassert_equal(len, null_len, NULL);
|
||||
|
||||
apdu_len = bacnet_special_event_decode(apdu, len, &out);
|
||||
zassert_equal(len, apdu_len, NULL);
|
||||
zassert_equal(in.periodTag, out.periodTag, NULL);
|
||||
zassert_equal(
|
||||
in.period.calendarEntry.tag, out.period.calendarEntry.tag, NULL);
|
||||
zassert_equal(in.period.calendarEntry.type.Date.wday,
|
||||
out.period.calendarEntry.type.Date.wday, NULL);
|
||||
zassert_equal(in.period.calendarEntry.type.Date.year,
|
||||
out.period.calendarEntry.type.Date.year, NULL);
|
||||
zassert_equal(in.period.calendarEntry.type.Date.month,
|
||||
out.period.calendarEntry.type.Date.month, NULL);
|
||||
zassert_equal(in.period.calendarEntry.type.Date.day,
|
||||
out.period.calendarEntry.type.Date.day, NULL);
|
||||
|
||||
zassert_equal(in.timeValues.TV_Count, out.timeValues.TV_Count, NULL);
|
||||
zassert_equal(in.priority, out.priority, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test encode/decode API with Calendar Entry (DateRange variant)
|
||||
*/
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST(BACnetSpecialEvent_tests, test_BACnetSpecialEvent_DateRange)
|
||||
#else
|
||||
static void test_BACnetSpecialEvent_DateRange(void)
|
||||
#endif
|
||||
{
|
||||
int len, apdu_len, null_len;
|
||||
uint8_t apdu[MAX_APDU] = { 0 };
|
||||
|
||||
BACNET_SPECIAL_EVENT in = {
|
||||
.periodTag = BACNET_SPECIAL_EVENT_PERIOD_CALENDAR_ENTRY,
|
||||
.period = {
|
||||
.calendarEntry = {
|
||||
.tag = BACNET_CALENDAR_DATE_RANGE,
|
||||
.type = {
|
||||
.DateRange = {
|
||||
.startdate = {
|
||||
.day = 1,
|
||||
.month = 12,
|
||||
.year = 2155,
|
||||
.wday = 0xff,
|
||||
},
|
||||
.enddate = {
|
||||
.day = 31,
|
||||
.month = 12,
|
||||
.year = 2155,
|
||||
.wday = 0xff,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
.timeValues = {
|
||||
.TV_Count = 0,
|
||||
.Time_Values = { 0 }
|
||||
},
|
||||
.priority = 0,
|
||||
};
|
||||
BACNET_SPECIAL_EVENT out = { 0 };
|
||||
|
||||
len = bacnet_special_event_encode(apdu, &in);
|
||||
null_len = bacnet_special_event_encode(NULL, &in);
|
||||
zassert_equal(len, null_len, NULL);
|
||||
|
||||
apdu_len = bacnet_special_event_decode(apdu, len, &out);
|
||||
zassert_equal(len, apdu_len, "apdu_len %d != len %d", apdu_len, len);
|
||||
zassert_equal(in.periodTag, out.periodTag, NULL);
|
||||
|
||||
zassert_equal(
|
||||
in.period.calendarEntry.tag, out.period.calendarEntry.tag, NULL);
|
||||
|
||||
zassert_equal(in.period.calendarEntry.type.DateRange.startdate.wday,
|
||||
out.period.calendarEntry.type.DateRange.startdate.wday, NULL);
|
||||
zassert_equal(in.period.calendarEntry.type.DateRange.startdate.year,
|
||||
out.period.calendarEntry.type.DateRange.startdate.year, NULL);
|
||||
zassert_equal(in.period.calendarEntry.type.DateRange.startdate.month,
|
||||
out.period.calendarEntry.type.DateRange.startdate.month, NULL);
|
||||
zassert_equal(in.period.calendarEntry.type.DateRange.startdate.day,
|
||||
out.period.calendarEntry.type.DateRange.startdate.day, NULL);
|
||||
|
||||
zassert_equal(in.period.calendarEntry.type.DateRange.enddate.wday,
|
||||
out.period.calendarEntry.type.DateRange.enddate.wday, NULL);
|
||||
zassert_equal(in.period.calendarEntry.type.DateRange.enddate.year,
|
||||
out.period.calendarEntry.type.DateRange.enddate.year, NULL);
|
||||
zassert_equal(in.period.calendarEntry.type.DateRange.enddate.month,
|
||||
out.period.calendarEntry.type.DateRange.enddate.month, NULL);
|
||||
zassert_equal(in.period.calendarEntry.type.DateRange.enddate.day,
|
||||
out.period.calendarEntry.type.DateRange.enddate.day, NULL);
|
||||
|
||||
zassert_equal(in.timeValues.TV_Count, out.timeValues.TV_Count, NULL);
|
||||
zassert_equal(in.priority, out.priority, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test encode/decode API with Calendar Entry (Date variant)
|
||||
*/
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST(BACnetSpecialEvent_tests, test_BACnetSpecialEvent_WeekNDate)
|
||||
#else
|
||||
static void test_BACnetSpecialEvent_WeekNDate(void)
|
||||
#endif
|
||||
{
|
||||
int len, apdu_len, null_len;
|
||||
uint8_t apdu[MAX_APDU] = { 0 };
|
||||
|
||||
BACNET_SPECIAL_EVENT in = {
|
||||
.periodTag = BACNET_SPECIAL_EVENT_PERIOD_CALENDAR_ENTRY,
|
||||
.period = {
|
||||
.calendarEntry = {
|
||||
.tag = BACNET_CALENDAR_WEEK_N_DAY,
|
||||
.type = {
|
||||
.WeekNDay = {
|
||||
.month = 0xff,
|
||||
.dayofweek = 1, /* mondays */
|
||||
.weekofmonth = 0xff,
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
.timeValues = {
|
||||
.TV_Count = 0,
|
||||
.Time_Values = { 0 }
|
||||
},
|
||||
.priority = 16,
|
||||
};
|
||||
BACNET_SPECIAL_EVENT out = { 0 };
|
||||
|
||||
len = bacnet_special_event_encode(apdu, &in);
|
||||
null_len = bacnet_special_event_encode(NULL, &in);
|
||||
zassert_equal(len, null_len, NULL);
|
||||
|
||||
apdu_len = bacnet_special_event_decode(apdu, len, &out);
|
||||
zassert_equal(len, apdu_len, NULL);
|
||||
zassert_equal(in.periodTag, out.periodTag, NULL);
|
||||
|
||||
zassert_equal(
|
||||
in.period.calendarEntry.tag, out.period.calendarEntry.tag, NULL);
|
||||
zassert_equal(in.period.calendarEntry.type.WeekNDay.month,
|
||||
out.period.calendarEntry.type.WeekNDay.month, NULL);
|
||||
zassert_equal(in.period.calendarEntry.type.WeekNDay.dayofweek,
|
||||
out.period.calendarEntry.type.WeekNDay.dayofweek, NULL);
|
||||
zassert_equal(in.period.calendarEntry.type.WeekNDay.weekofmonth,
|
||||
out.period.calendarEntry.type.WeekNDay.weekofmonth, NULL);
|
||||
|
||||
zassert_equal(in.timeValues.TV_Count, out.timeValues.TV_Count, NULL);
|
||||
zassert_equal(in.priority, out.priority, NULL);
|
||||
}
|
||||
|
||||
/** @brief try decoding a real sample from Siemens, captured with wireshark */
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST(BACnetSpecialEvent_tests, test_BACnetSpecialEvent_DecodeRealAPDU)
|
||||
#else
|
||||
static void test_BACnetSpecialEvent_DecodeRealAPDU(void)
|
||||
#endif
|
||||
{
|
||||
int len, apdu_len;
|
||||
BACNET_SPECIAL_EVENT out = { 0 };
|
||||
uint8_t sample[18] = { 0x0e, 0x0c, 0xff, 0x0a, 0x1c, 0xff, 0x0f, 0x2e, 0xb4,
|
||||
0x00, 0x00, 0x00, 0x00, 0x91, 0x00, 0x2f, 0x39, 0x10 };
|
||||
|
||||
apdu_len = bacnet_special_event_decode(sample, sizeof(sample), &out);
|
||||
zassert_equal(sizeof(sample), apdu_len, NULL);
|
||||
|
||||
zassert_equal(
|
||||
out.periodTag, BACNET_SPECIAL_EVENT_PERIOD_CALENDAR_ENTRY, NULL);
|
||||
zassert_equal(out.period.calendarEntry.tag, BACNET_CALENDAR_DATE, NULL);
|
||||
zassert_equal(out.period.calendarEntry.type.Date.day, 28, NULL);
|
||||
zassert_equal(out.period.calendarEntry.type.Date.month, 10, NULL);
|
||||
zassert_equal(
|
||||
out.period.calendarEntry.type.Date.year, 2155 /* any */, NULL);
|
||||
zassert_equal(
|
||||
out.period.calendarEntry.type.Date.wday, 0xff /* any */, NULL);
|
||||
|
||||
zassert_equal(out.timeValues.TV_Count, 1, NULL);
|
||||
|
||||
zassert_equal(out.timeValues.Time_Values[0].Time.hour, 0, NULL);
|
||||
zassert_equal(out.timeValues.Time_Values[0].Time.min, 0, NULL);
|
||||
zassert_equal(out.timeValues.Time_Values[0].Time.sec, 0, NULL);
|
||||
zassert_equal(out.timeValues.Time_Values[0].Time.hundredths, 0, NULL);
|
||||
|
||||
zassert_equal(out.timeValues.Time_Values[0].Value.tag,
|
||||
BACNET_APPLICATION_TAG_ENUMERATED, NULL);
|
||||
zassert_equal(
|
||||
out.timeValues.Time_Values[0].Value.type.Unsigned_Int, 0, NULL);
|
||||
|
||||
zassert_equal(out.priority, 16, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST_SUITE(BACnetSpecialEvent_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(BACnetSpecialEvent_tests,
|
||||
ztest_unit_test(test_BACnetSpecialEvent_CalendarRef),
|
||||
ztest_unit_test(test_BACnetSpecialEvent_Date),
|
||||
ztest_unit_test(test_BACnetSpecialEvent_DateRange),
|
||||
ztest_unit_test(test_BACnetSpecialEvent_WeekNDate),
|
||||
ztest_unit_test(test_BACnetSpecialEvent_DecodeRealAPDU));
|
||||
|
||||
ztest_run_test_suite(BACnetSpecialEvent_tests);
|
||||
}
|
||||
#endif
|
||||
@@ -55,6 +55,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -53,6 +53,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/hostnport.c
|
||||
${SRC_DIR}/bacnet/lighting.c
|
||||
${SRC_DIR}/bacnet/timestamp.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -54,6 +54,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
/* @file
|
||||
* @brief test BACnet integer encode/decode APIs
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <zephyr/ztest.h>
|
||||
#include <bacnet/wp.h>
|
||||
|
||||
@@ -129,7 +129,8 @@ static void testWritePropertyTag(BACNET_APPLICATION_DATA_VALUE *value)
|
||||
test_value.type.Signed_Int, value->type.Signed_Int, NULL);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_REAL:
|
||||
zassert_equal(test_value.type.Real, value->type.Real, NULL);
|
||||
zassert_false(islessgreater(test_value.type.Real, value->type.Real),
|
||||
NULL);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_ENUMERATED:
|
||||
zassert_equal(
|
||||
|
||||
@@ -55,6 +55,8 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/weeklyschedule.c
|
||||
${SRC_DIR}/bacnet/bactimevalue.c
|
||||
${SRC_DIR}/bacnet/dailyschedule.c
|
||||
${SRC_DIR}/bacnet/calendar_entry.c
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
|
||||
@@ -320,6 +320,10 @@ set(BACNETSTACK_SRCS
|
||||
${BACNETSTACK_SRC}/bacnet/weeklyschedule.h
|
||||
${BACNETSTACK_SRC}/bacnet/dailyschedule.c
|
||||
${BACNETSTACK_SRC}/bacnet/dailyschedule.h
|
||||
${BACNETSTACK_SRC}/bacnet/calendar_entry.c
|
||||
${BACNETSTACK_SRC}/bacnet/calendar_entry.h
|
||||
${BACNETSTACK_SRC}/bacnet/special_event.c
|
||||
${BACNETSTACK_SRC}/bacnet/special_event.h
|
||||
)
|
||||
|
||||
set(BACNETSTACK_BASIC_SRCS
|
||||
|
||||
@@ -46,6 +46,8 @@ if(BOARD STREQUAL unit_testing)
|
||||
${BACNET_SRC}/hostnport.c
|
||||
${BACNET_SRC}/dailyschedule.c
|
||||
${BACNET_SRC}/weeklyschedule.c
|
||||
${BACNET_SRC}/calendar_entry.c
|
||||
${BACNET_SRC}/special_event.c
|
||||
${BACNET_SRC}/basic/sys/bigend.c
|
||||
${BACNET_SRC}/bactimevalue.c
|
||||
)
|
||||
|
||||
@@ -49,6 +49,8 @@ if(BOARD STREQUAL unit_testing)
|
||||
${BACNET_SRC}/hostnport.c
|
||||
${BACNET_SRC}/dailyschedule.c
|
||||
${BACNET_SRC}/weeklyschedule.c
|
||||
${BACNET_SRC}/calendar_entry.c
|
||||
${BACNET_SRC}/special_event.c
|
||||
${BACNET_SRC}/basic/sys/bigend.c
|
||||
${BACNET_SRC}/bactimevalue.c
|
||||
)
|
||||
|
||||
@@ -53,6 +53,8 @@ if(BOARD STREQUAL unit_testing)
|
||||
${BACNET_SRC}/hostnport.c
|
||||
${BACNET_SRC}/dailyschedule.c
|
||||
${BACNET_SRC}/weeklyschedule.c
|
||||
${BACNET_SRC}/calendar_entry.c
|
||||
${BACNET_SRC}/special_event.c
|
||||
${BACNET_SRC}/basic/sys/bigend.c
|
||||
${BACNET_SRC}/bactimevalue.c
|
||||
)
|
||||
|
||||
@@ -50,6 +50,8 @@ if(BOARD STREQUAL unit_testing)
|
||||
${BACNET_SRC}/hostnport.c
|
||||
${BACNET_SRC}/dailyschedule.c
|
||||
${BACNET_SRC}/weeklyschedule.c
|
||||
${BACNET_SRC}/calendar_entry.c
|
||||
${BACNET_SRC}/special_event.c
|
||||
${BACNET_SRC}/basic/sys/bigend.c
|
||||
${BACNET_SRC}/bactimevalue.c
|
||||
)
|
||||
|
||||
@@ -49,6 +49,8 @@ if(BOARD STREQUAL unit_testing)
|
||||
${BACNET_SRC}/hostnport.c
|
||||
${BACNET_SRC}/dailyschedule.c
|
||||
${BACNET_SRC}/weeklyschedule.c
|
||||
${BACNET_SRC}/calendar_entry.c
|
||||
${BACNET_SRC}/special_event.c
|
||||
${BACNET_SRC}/basic/sys/bigend.c
|
||||
${BACNET_SRC}/bactimevalue.c
|
||||
)
|
||||
|
||||
@@ -51,6 +51,8 @@ if(BOARD STREQUAL unit_testing)
|
||||
${BACNET_SRC}/hostnport.c
|
||||
${BACNET_SRC}/dailyschedule.c
|
||||
${BACNET_SRC}/weeklyschedule.c
|
||||
${BACNET_SRC}/calendar_entry.c
|
||||
${BACNET_SRC}/special_event.c
|
||||
${BACNET_SRC}/basic/sys/bigend.c
|
||||
${BACNET_SRC}/bactimevalue.c
|
||||
)
|
||||
|
||||
@@ -50,6 +50,8 @@ if(BOARD STREQUAL unit_testing)
|
||||
${BACNET_SRC}/hostnport.c
|
||||
${BACNET_SRC}/dailyschedule.c
|
||||
${BACNET_SRC}/weeklyschedule.c
|
||||
${BACNET_SRC}/calendar_entry.c
|
||||
${BACNET_SRC}/special_event.c
|
||||
${BACNET_SRC}/basic/sys/bigend.c
|
||||
${BACNET_SRC}/bactimevalue.c
|
||||
)
|
||||
|
||||
@@ -50,6 +50,8 @@ if(BOARD STREQUAL unit_testing)
|
||||
${BACNET_SRC}/hostnport.c
|
||||
${BACNET_SRC}/dailyschedule.c
|
||||
${BACNET_SRC}/weeklyschedule.c
|
||||
${BACNET_SRC}/calendar_entry.c
|
||||
${BACNET_SRC}/special_event.c
|
||||
${BACNET_SRC}/basic/sys/bigend.c
|
||||
${BACNET_SRC}/bactimevalue.c
|
||||
)
|
||||
|
||||
@@ -52,6 +52,8 @@ if(BOARD STREQUAL unit_testing)
|
||||
${BACNET_SRC}/hostnport.c
|
||||
${BACNET_SRC}/dailyschedule.c
|
||||
${BACNET_SRC}/weeklyschedule.c
|
||||
${BACNET_SRC}/calendar_entry.c
|
||||
${BACNET_SRC}/special_event.c
|
||||
${BACNET_SRC}/basic/sys/bigend.c
|
||||
${BACNET_SRC}/bactimevalue.c
|
||||
)
|
||||
|
||||
@@ -50,6 +50,8 @@ if(BOARD STREQUAL unit_testing)
|
||||
${BACNET_SRC}/hostnport.c
|
||||
${BACNET_SRC}/dailyschedule.c
|
||||
${BACNET_SRC}/weeklyschedule.c
|
||||
${BACNET_SRC}/calendar_entry.c
|
||||
${BACNET_SRC}/special_event.c
|
||||
${BACNET_SRC}/basic/sys/bigend.c
|
||||
${BACNET_SRC}/bactimevalue.c
|
||||
)
|
||||
|
||||
@@ -50,6 +50,8 @@ if(BOARD STREQUAL unit_testing)
|
||||
${BACNET_SRC}/hostnport.c
|
||||
${BACNET_SRC}/dailyschedule.c
|
||||
${BACNET_SRC}/weeklyschedule.c
|
||||
${BACNET_SRC}/calendar_entry.c
|
||||
${BACNET_SRC}/special_event.c
|
||||
${BACNET_SRC}/basic/sys/bigend.c
|
||||
${BACNET_SRC}/bactimevalue.c
|
||||
)
|
||||
|
||||
@@ -50,6 +50,8 @@ if(BOARD STREQUAL unit_testing)
|
||||
${BACNET_SRC}/hostnport.c
|
||||
${BACNET_SRC}/dailyschedule.c
|
||||
${BACNET_SRC}/weeklyschedule.c
|
||||
${BACNET_SRC}/calendar_entry.c
|
||||
${BACNET_SRC}/special_event.c
|
||||
${BACNET_SRC}/basic/sys/bigend.c
|
||||
${BACNET_SRC}/bactimevalue.c
|
||||
)
|
||||
|
||||
@@ -50,6 +50,8 @@ if(BOARD STREQUAL unit_testing)
|
||||
${BACNET_SRC}/hostnport.c
|
||||
${BACNET_SRC}/dailyschedule.c
|
||||
${BACNET_SRC}/weeklyschedule.c
|
||||
${BACNET_SRC}/calendar_entry.c
|
||||
${BACNET_SRC}/special_event.c
|
||||
${BACNET_SRC}/basic/sys/bigend.c
|
||||
${BACNET_SRC}/bactimevalue.c
|
||||
${BACNET_SRC}/basic/sys/keylist.c
|
||||
|
||||
@@ -50,6 +50,8 @@ if(BOARD STREQUAL unit_testing)
|
||||
${BACNET_SRC}/hostnport.c
|
||||
${BACNET_SRC}/dailyschedule.c
|
||||
${BACNET_SRC}/weeklyschedule.c
|
||||
${BACNET_SRC}/calendar_entry.c
|
||||
${BACNET_SRC}/special_event.c
|
||||
${BACNET_SRC}/basic/sys/bigend.c
|
||||
${BACNET_SRC}/bactimevalue.c
|
||||
)
|
||||
|
||||
@@ -53,6 +53,8 @@ if(BOARD STREQUAL unit_testing)
|
||||
${BACNET_SRC}/wp.c
|
||||
${BACNET_SRC}/dailyschedule.c
|
||||
${BACNET_SRC}/weeklyschedule.c
|
||||
${BACNET_SRC}/calendar_entry.c
|
||||
${BACNET_SRC}/special_event.c
|
||||
${BACNET_SRC}/basic/sys/bigend.c
|
||||
${BACNET_SRC}/bactimevalue.c
|
||||
)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user