diff --git a/CHANGELOG.md b/CHANGELOG.md index f2eaa922..ea14ee8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -145,6 +145,8 @@ The git repositories are hosted at the following sites: ### Fixed +* Added CHANNEL_VALUE_ALL define and fixed the API integration for the + additional datatypes now supported in the Channel object. (#1135) * Fixed the error class returned for AlarmAcknowledgment (#1131) * Fixed object creation failure when create is called before init. (#1122) * Fixed octetstring_copy_value() and added unit tests. (#1121) diff --git a/src/bacnet/channel_value.c b/src/bacnet/channel_value.c index 75773655..15c07621 100644 --- a/src/bacnet/channel_value.c +++ b/src/bacnet/channel_value.c @@ -388,12 +388,12 @@ bool bacnet_channel_value_same( #endif #if defined(CHANNEL_CHARACTER_STRING) case BACNET_APPLICATION_TAG_CHARACTER_STRING: - return characterstring_value_same( + return characterstring_same( &value1->type.Character_String, &value2->type.Character_String); #endif #if defined(CHANNEL_BIT_STRING) case BACNET_APPLICATION_TAG_BIT_STRING: - return bitstring_value_same( + return bitstring_same( &value1->type.Bit_String, &value2->type.Bit_String); #endif #if defined(CHANNEL_ENUMERATED) @@ -402,16 +402,18 @@ bool bacnet_channel_value_same( #endif #if defined(CHANNEL_DATE) case BACNET_APPLICATION_TAG_DATE: - return date_value_same(&value1->type.Date, &value2->type.Date); + return datetime_date_same(&value1->type.Date, &value2->type.Date); + break; #endif #if defined(CHANNEL_TIME) case BACNET_APPLICATION_TAG_TIME: - return time_value_same(&value1->type.Time, &value2->type.Time); + return datetime_time_same(&value1->type.Time, &value2->type.Time); #endif #if defined(CHANNEL_OBJECT_ID) case BACNET_APPLICATION_TAG_OBJECT_ID: - return object_id_value_same( - &value1->type.Object_Id, &value2->type.Object_Id); + return bacnet_object_id_same( + value1->type.Object_Id.type, value1->type.Object_Id.instance, + value2->type.Object_Id.type, value2->type.Object_Id.instance); #endif #if defined(CHANNEL_LIGHTING_COMMAND) case BACNET_APPLICATION_TAG_LIGHTING_COMMAND: @@ -498,11 +500,13 @@ bool bacnet_channel_value_copy( #endif #if defined(CHANNEL_DATE) case BACNET_APPLICATION_TAG_DATE: - return datetime_copy_date(&dest->type.Date, &src->type.Date); + datetime_copy_date(&dest->type.Date, &src->type.Date); + return true; #endif #if defined(CHANNEL_TIME) case BACNET_APPLICATION_TAG_TIME: - return datetime_copy_time(&dest->type.Time, &src->type.Time); + datetime_copy_time(&dest->type.Time, &src->type.Time); + return true; #endif #if defined(CHANNEL_OBJECT_ID) case BACNET_APPLICATION_TAG_OBJECT_ID: diff --git a/src/bacnet/channel_value.h b/src/bacnet/channel_value.h index 1bab0504..0324a132 100644 --- a/src/bacnet/channel_value.h +++ b/src/bacnet/channel_value.h @@ -13,6 +13,8 @@ #include /* BACnet Stack defines - first */ #include "bacnet/bacdef.h" +#include "bacnet/bacstr.h" +#include "bacnet/datetime.h" #include "bacnet/lighting.h" /* BACNET_CHANNEL_VALUE decodes WriteProperty service requests @@ -26,8 +28,16 @@ defined(CHANNEL_ENUMERATED) || defined(CHANNEL_DATE) || \ defined(CHANNEL_TIME) || defined(CHANNEL_OBJECT_ID) || \ defined(CHANNEL_LIGHTING_COMMAND) || defined(CHANNEL_XY_COLOR) || \ - defined(CHANNEL_COLOR_COMMAND)) + defined(CHANNEL_COLOR_COMMAND) || defined(CHANNEL_VALUE_ALL)) #define CHANNEL_NUMERIC +#elif defined(CHANNEL_VALUE_ALL) +#define CHANNEL_NUMERIC +#define CHANNEL_OCTET_STRING +#define CHANNEL_CHARACTER_STRING +#define CHANNEL_BIT_STRING +#define CHANNEL_DATE +#define CHANNEL_TIME +#define CHANNEL_OBJECT_ID #endif #if defined(CHANNEL_NUMERIC) diff --git a/src/bacnet/datetime.c b/src/bacnet/datetime.c index d06065c8..88dbb9a9 100644 --- a/src/bacnet/datetime.c +++ b/src/bacnet/datetime.c @@ -304,6 +304,25 @@ int datetime_compare_date(const BACNET_DATE *date1, const BACNET_DATE *date2) return diff; } +/** + * @brief Determine if date1 is the same as date2 + * @param date1 - Pointer to a BACNET_DATE structure + * @param date2 - Pointer to a BACNET_DATE structure + * @return true if same, false if different + */ +bool datetime_date_same(const BACNET_DATE *date1, const BACNET_DATE *date2) +{ + bool status = false; + int diff = 0; + + diff = datetime_compare_date(date1, date2); + if (diff == 0) { + status = true; + } + + return status; +} + /** * If the time1 is the same as time2, return is 0. * If time1 is after time2, returns positive. @@ -334,6 +353,25 @@ int datetime_compare_time(const BACNET_TIME *time1, const BACNET_TIME *time2) return diff; } +/** + * @brief Determine if time1 is the same as time2 + * @param time1 - Pointer to a BACNET_TIME structure + * @param time2 - Pointer to a BACNET_TIME structure + * @return true if same, false if different + */ +bool datetime_time_same(const BACNET_TIME *time1, const BACNET_TIME *time2) +{ + bool status = false; + int diff = 0; + + diff = datetime_compare_time(time1, time2); + if (diff == 0) { + status = true; + } + + return status; +} + /** * If the datetime1 is the same datetime2, return is 0. * If datetime1 is after datetime2, returns positive. @@ -357,6 +395,26 @@ int datetime_compare( return diff; } +/** + * @brief Determine if the datetime1 is the same as datetime2 + * @param datetime1 - Pointer to a BACNET_DATE_TIME structure + * @param datetime2 - Pointer to a BACNET_DATE_TIME structure + * @return true if same, false if different + */ +bool datetime_same( + const BACNET_DATE_TIME *datetime1, const BACNET_DATE_TIME *datetime2) +{ + bool status = false; + int diff = 0; + + diff = datetime_compare(datetime1, datetime2); + if (diff == 0) { + status = true; + } + + return status; +} + int datetime_wildcard_compare_date( const BACNET_DATE *date1, const BACNET_DATE *date2) { diff --git a/src/bacnet/datetime.h b/src/bacnet/datetime.h index d2047862..136bbccc 100644 --- a/src/bacnet/datetime.h +++ b/src/bacnet/datetime.h @@ -159,10 +159,17 @@ uint16_t datetime_minutes_since_midnight(const BACNET_TIME *btime); BACNET_STACK_EXPORT int datetime_compare_date(const BACNET_DATE *date1, const BACNET_DATE *date2); BACNET_STACK_EXPORT +bool datetime_date_same(const BACNET_DATE *date1, const BACNET_DATE *date2); +BACNET_STACK_EXPORT int datetime_compare_time(const BACNET_TIME *time1, const BACNET_TIME *time2); BACNET_STACK_EXPORT +bool datetime_time_same(const BACNET_TIME *time1, const BACNET_TIME *time2); +BACNET_STACK_EXPORT int datetime_compare( const BACNET_DATE_TIME *datetime1, const BACNET_DATE_TIME *datetime2); +BACNET_STACK_EXPORT +bool datetime_same( + const BACNET_DATE_TIME *datetime1, const BACNET_DATE_TIME *datetime2); /* full comparison functions: * taking into account FF fields in date and time structures, diff --git a/test/bacnet/channel_value/CMakeLists.txt b/test/bacnet/channel_value/CMakeLists.txt index 375b9217..bcdea293 100644 --- a/test/bacnet/channel_value/CMakeLists.txt +++ b/test/bacnet/channel_value/CMakeLists.txt @@ -23,7 +23,8 @@ set(ZTST_DIR "${TST_DIR}/ztest/src") add_compile_definitions( BIG_ENDIAN=0 CONFIG_ZTEST=1 - BACAPP_ALL + CHANNEL_VALUE_ALL=1 + BACAPP_ALL=1 ) include_directories(