make pretty
This commit is contained in:
+155
-165
@@ -87,8 +87,8 @@ int bacapp_encode_application_data(
|
||||
#endif
|
||||
#if defined(BACAPP_UNSIGNED)
|
||||
case BACNET_APPLICATION_TAG_UNSIGNED_INT:
|
||||
apdu_len = encode_application_unsigned(
|
||||
apdu, value->type.Unsigned_Int);
|
||||
apdu_len =
|
||||
encode_application_unsigned(apdu, value->type.Unsigned_Int);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_SIGNED)
|
||||
@@ -104,8 +104,7 @@ int bacapp_encode_application_data(
|
||||
#endif
|
||||
#if defined(BACAPP_DOUBLE)
|
||||
case BACNET_APPLICATION_TAG_DOUBLE:
|
||||
apdu_len =
|
||||
encode_application_double(apdu, value->type.Double);
|
||||
apdu_len = encode_application_double(apdu, value->type.Double);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_OCTET_STRING)
|
||||
@@ -122,14 +121,14 @@ int bacapp_encode_application_data(
|
||||
#endif
|
||||
#if defined(BACAPP_BIT_STRING)
|
||||
case BACNET_APPLICATION_TAG_BIT_STRING:
|
||||
apdu_len = encode_application_bitstring(
|
||||
apdu, &value->type.Bit_String);
|
||||
apdu_len =
|
||||
encode_application_bitstring(apdu, &value->type.Bit_String);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_ENUMERATED)
|
||||
case BACNET_APPLICATION_TAG_ENUMERATED:
|
||||
apdu_len = encode_application_enumerated(
|
||||
apdu, value->type.Enumerated);
|
||||
apdu_len =
|
||||
encode_application_enumerated(apdu, value->type.Enumerated);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_DATE)
|
||||
@@ -148,16 +147,15 @@ int bacapp_encode_application_data(
|
||||
value->type.Object_Id.type, value->type.Object_Id.instance);
|
||||
break;
|
||||
#endif
|
||||
#if defined (BACAPP_TYPES_EXTRA)
|
||||
#if defined(BACAPP_TYPES_EXTRA)
|
||||
case BACNET_APPLICATION_TAG_EMPTYLIST:
|
||||
/* Empty data list */
|
||||
apdu_len = 0; /* EMPTY */
|
||||
apdu_len = 0; /* EMPTY */
|
||||
break;
|
||||
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_DATETIME:
|
||||
apdu_len = bacapp_encode_datetime(apdu,
|
||||
&value->type.Date_Time);
|
||||
apdu_len = bacapp_encode_datetime(apdu, &value->type.Date_Time);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_LIGHTING_COMMAND:
|
||||
/* BACnetLightingCommand */
|
||||
@@ -166,13 +164,12 @@ int bacapp_encode_application_data(
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_XY_COLOR:
|
||||
/* BACnetxyColor */
|
||||
apdu_len = xy_color_encode(
|
||||
apdu, &value->type.XY_Color);
|
||||
apdu_len = xy_color_encode(apdu, &value->type.XY_Color);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_COLOR_COMMAND:
|
||||
/* BACnetColorCommand */
|
||||
apdu_len = color_command_encode(
|
||||
apdu, &value->type.Color_Command);
|
||||
apdu_len =
|
||||
color_command_encode(apdu, &value->type.Color_Command);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_WEEKLY_SCHEDULE:
|
||||
/* BACnetWeeklySchedule */
|
||||
@@ -181,8 +178,7 @@ int bacapp_encode_application_data(
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_HOST_N_PORT:
|
||||
/* BACnetHostNPort */
|
||||
apdu_len = host_n_port_encode(apdu,
|
||||
&value->type.Host_Address);
|
||||
apdu_len = host_n_port_encode(apdu, &value->type.Host_Address);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_DEVICE_OBJECT_PROPERTY_REFERENCE:
|
||||
/* BACnetDeviceObjectPropertyReference */
|
||||
@@ -251,8 +247,8 @@ int bacapp_decode_data(uint8_t *apdu,
|
||||
#endif
|
||||
#if defined(BACAPP_REAL)
|
||||
case BACNET_APPLICATION_TAG_REAL:
|
||||
len = decode_real_safe(
|
||||
apdu, len_value_type, &(value->type.Real));
|
||||
len =
|
||||
decode_real_safe(apdu, len_value_type, &(value->type.Real));
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_DOUBLE)
|
||||
@@ -287,8 +283,7 @@ int bacapp_decode_data(uint8_t *apdu,
|
||||
#endif
|
||||
#if defined(BACAPP_DATE)
|
||||
case BACNET_APPLICATION_TAG_DATE:
|
||||
len = decode_date_safe(
|
||||
apdu, len_value_type, &value->type.Date);
|
||||
len = decode_date_safe(apdu, len_value_type, &value->type.Date);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_TIME)
|
||||
@@ -307,10 +302,9 @@ int bacapp_decode_data(uint8_t *apdu,
|
||||
value->type.Object_Id.instance = instance;
|
||||
} break;
|
||||
#endif
|
||||
#if defined (BACAPP_TYPES_EXTRA)
|
||||
#if defined(BACAPP_TYPES_EXTRA)
|
||||
case BACNET_APPLICATION_TAG_DATETIME:
|
||||
len = bacapp_decode_datetime(apdu,
|
||||
&value->type.Date_Time);
|
||||
len = bacapp_decode_datetime(apdu, &value->type.Date_Time);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_LIGHTING_COMMAND:
|
||||
len = lighting_command_decode(
|
||||
@@ -332,8 +326,7 @@ int bacapp_decode_data(uint8_t *apdu,
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_HOST_N_PORT:
|
||||
len = host_n_port_decode(
|
||||
apdu, len_value_type, NULL,
|
||||
&value->type.Host_Address);
|
||||
apdu, len_value_type, NULL, &value->type.Host_Address);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_DEVICE_OBJECT_PROPERTY_REFERENCE:
|
||||
/* BACnetDeviceObjectPropertyReference */
|
||||
@@ -347,8 +340,7 @@ int bacapp_decode_data(uint8_t *apdu,
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_OBJECT_PROPERTY_REFERENCE:
|
||||
/* BACnetObjectPropertyReference */
|
||||
len = bacapp_decode_obj_property_ref(
|
||||
apdu, len_value_type,
|
||||
len = bacapp_decode_obj_property_ref(apdu, len_value_type,
|
||||
&value->type.Object_Property_Reference);
|
||||
break;
|
||||
#endif
|
||||
@@ -601,8 +593,8 @@ int bacapp_encode_context_data_value(uint8_t *apdu,
|
||||
#endif
|
||||
#if defined(BACAPP_CHARACTER_STRING)
|
||||
case BACNET_APPLICATION_TAG_CHARACTER_STRING:
|
||||
apdu_len = encode_context_character_string(apdu,
|
||||
context_tag_number, &value->type.Character_String);
|
||||
apdu_len = encode_context_character_string(
|
||||
apdu, context_tag_number, &value->type.Character_String);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_BIT_STRING)
|
||||
@@ -631,19 +623,18 @@ int bacapp_encode_context_data_value(uint8_t *apdu,
|
||||
#endif
|
||||
#if defined(BACAPP_OBJECT_ID)
|
||||
case BACNET_APPLICATION_TAG_OBJECT_ID:
|
||||
apdu_len = encode_context_object_id(apdu,
|
||||
context_tag_number, value->type.Object_Id.type,
|
||||
value->type.Object_Id.instance);
|
||||
apdu_len = encode_context_object_id(apdu, context_tag_number,
|
||||
value->type.Object_Id.type, value->type.Object_Id.instance);
|
||||
break;
|
||||
#endif
|
||||
#if defined (BACAPP_TYPES_EXTRA)
|
||||
#if defined(BACAPP_TYPES_EXTRA)
|
||||
case BACNET_APPLICATION_TAG_DATETIME:
|
||||
apdu_len = bacapp_encode_context_datetime(apdu,
|
||||
context_tag_number, &value->type.Date_Time);
|
||||
apdu_len = bacapp_encode_context_datetime(
|
||||
apdu, context_tag_number, &value->type.Date_Time);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_LIGHTING_COMMAND:
|
||||
apdu_len = lighting_command_encode_context(apdu,
|
||||
context_tag_number, &value->type.Lighting_Command);
|
||||
apdu_len = lighting_command_encode_context(
|
||||
apdu, context_tag_number, &value->type.Lighting_Command);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_XY_COLOR:
|
||||
/* BACnetxyColor */
|
||||
@@ -661,26 +652,24 @@ int bacapp_encode_context_data_value(uint8_t *apdu,
|
||||
apdu, context_tag_number, &value->type.Color_Command);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_HOST_N_PORT:
|
||||
apdu_len = host_n_port_context_encode(apdu,
|
||||
context_tag_number, &value->type.Host_Address);
|
||||
apdu_len = host_n_port_context_encode(
|
||||
apdu, context_tag_number, &value->type.Host_Address);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_DEVICE_OBJECT_PROPERTY_REFERENCE:
|
||||
/* BACnetDeviceObjectPropertyReference */
|
||||
apdu_len = bacapp_encode_context_device_obj_property_ref(
|
||||
apdu, context_tag_number,
|
||||
apdu_len = bacapp_encode_context_device_obj_property_ref(apdu,
|
||||
context_tag_number,
|
||||
&value->type.Device_Object_Property_Reference);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_DEVICE_OBJECT_REFERENCE:
|
||||
/* BACnetDeviceObjectReference */
|
||||
apdu_len = bacapp_encode_context_device_obj_ref(
|
||||
apdu, context_tag_number,
|
||||
&value->type.Device_Object_Reference);
|
||||
apdu_len = bacapp_encode_context_device_obj_ref(apdu,
|
||||
context_tag_number, &value->type.Device_Object_Reference);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_OBJECT_PROPERTY_REFERENCE:
|
||||
/* BACnetObjectPropertyReference */
|
||||
apdu_len = bacapp_encode_context_obj_property_ref(
|
||||
apdu, context_tag_number,
|
||||
&value->type.Object_Property_Reference);
|
||||
apdu_len = bacapp_encode_context_obj_property_ref(apdu,
|
||||
context_tag_number, &value->type.Object_Property_Reference);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
@@ -962,7 +951,7 @@ int bacapp_decode_context_data(uint8_t *apdu,
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
#if defined (BACAPP_TYPES_EXTRA)
|
||||
#if defined(BACAPP_TYPES_EXTRA)
|
||||
/**
|
||||
* @brief Context or Application tagged property value decoding
|
||||
*
|
||||
@@ -972,10 +961,9 @@ int bacapp_decode_context_data(uint8_t *apdu,
|
||||
* @param property - context property identifier
|
||||
* @return number of bytes decoded, or ERROR if errors occur
|
||||
*/
|
||||
int bacapp_decode_generic_property(
|
||||
uint8_t * apdu,
|
||||
int bacapp_decode_generic_property(uint8_t *apdu,
|
||||
int max_apdu_len,
|
||||
BACNET_APPLICATION_DATA_VALUE * value,
|
||||
BACNET_APPLICATION_DATA_VALUE *value,
|
||||
BACNET_PROPERTY_ID prop)
|
||||
{
|
||||
int len = 0;
|
||||
@@ -1029,8 +1017,7 @@ static int decode_priority_value(uint8_t *apdu,
|
||||
|
||||
#if defined(BACAPP_TYPES_EXTRA)
|
||||
int bacapp_known_property_tag(
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
BACNET_PROPERTY_ID property)
|
||||
BACNET_OBJECT_TYPE object_type, BACNET_PROPERTY_ID property)
|
||||
{
|
||||
switch (property) {
|
||||
case PROP_MEMBER_OF:
|
||||
@@ -1211,7 +1198,7 @@ int bacapp_decode_known_property(uint8_t *apdu,
|
||||
case PROP_LAST_ACCESS_POINT:
|
||||
/* Properties using BACnetDeviceObjectReference */
|
||||
len = bacapp_decode_device_obj_ref(
|
||||
apdu, &value->type.Device_Object_Reference);
|
||||
apdu, &value->type.Device_Object_Reference);
|
||||
break;
|
||||
|
||||
case PROP_TIME_OF_ACTIVE_TIME_RESET:
|
||||
@@ -1238,8 +1225,8 @@ int bacapp_decode_known_property(uint8_t *apdu,
|
||||
case PROP_LOG_DEVICE_OBJECT_PROPERTY:
|
||||
case PROP_LIST_OF_OBJECT_PROPERTY_REFERENCES:
|
||||
/* Properties using BACnetDeviceObjectPropertyReference */
|
||||
len = bacapp_decode_device_obj_property_ref(apdu,
|
||||
&value->type.Device_Object_Property_Reference);
|
||||
len = bacapp_decode_device_obj_property_ref(
|
||||
apdu, &value->type.Device_Object_Property_Reference);
|
||||
break;
|
||||
|
||||
case PROP_MANIPULATED_VARIABLE_REFERENCE:
|
||||
@@ -1247,8 +1234,7 @@ int bacapp_decode_known_property(uint8_t *apdu,
|
||||
case PROP_INPUT_REFERENCE:
|
||||
/* Properties using BACnetObjectPropertyReference */
|
||||
len = bacapp_decode_obj_property_ref(
|
||||
apdu, max_apdu_len,
|
||||
&value->type.Object_Property_Reference);
|
||||
apdu, max_apdu_len, &value->type.Object_Property_Reference);
|
||||
break;
|
||||
|
||||
case PROP_EVENT_TIME_STAMPS:
|
||||
@@ -1261,33 +1247,32 @@ int bacapp_decode_known_property(uint8_t *apdu,
|
||||
|
||||
case PROP_DEFAULT_COLOR:
|
||||
/* Properties using BACnetxyColor */
|
||||
len = xy_color_decode(apdu, max_apdu_len,
|
||||
&value->type.XY_Color);
|
||||
len = xy_color_decode(apdu, max_apdu_len, &value->type.XY_Color);
|
||||
break;
|
||||
|
||||
case PROP_TRACKING_VALUE:
|
||||
case PROP_PRESENT_VALUE:
|
||||
if (object_type == OBJECT_COLOR) {
|
||||
/* Properties using BACnetxyColor */
|
||||
len = xy_color_decode(apdu, max_apdu_len,
|
||||
&value->type.XY_Color);
|
||||
len =
|
||||
xy_color_decode(apdu, max_apdu_len, &value->type.XY_Color);
|
||||
} else {
|
||||
/* Decode a "classic" simple property */
|
||||
len = bacapp_decode_generic_property(apdu, max_apdu_len, value,
|
||||
property);
|
||||
len = bacapp_decode_generic_property(
|
||||
apdu, max_apdu_len, value, property);
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_COLOR_COMMAND:
|
||||
/* Properties using BACnetColorCommand */
|
||||
len = color_command_decode(apdu, max_apdu_len, NULL,
|
||||
&value->type.Color_Command);
|
||||
len = color_command_decode(
|
||||
apdu, max_apdu_len, NULL, &value->type.Color_Command);
|
||||
break;
|
||||
|
||||
case PROP_LIGHTING_COMMAND:
|
||||
/* Properties using BACnetLightingCommand */
|
||||
len = lighting_command_decode(apdu, max_apdu_len,
|
||||
&value->type.Lighting_Command);
|
||||
len = lighting_command_decode(
|
||||
apdu, max_apdu_len, &value->type.Lighting_Command);
|
||||
break;
|
||||
|
||||
case PROP_PRIORITY_ARRAY:
|
||||
@@ -1301,7 +1286,8 @@ int bacapp_decode_known_property(uint8_t *apdu,
|
||||
apdu, max_apdu_len, &value->type.Weekly_Schedule);
|
||||
break;
|
||||
|
||||
/* properties without a specific decoder - fall through to default */
|
||||
/* properties without a specific decoder - fall through to default
|
||||
*/
|
||||
|
||||
case PROP_LIST_OF_GROUP_MEMBERS:
|
||||
/* Properties using ReadAccessSpecification */
|
||||
@@ -1326,8 +1312,8 @@ int bacapp_decode_known_property(uint8_t *apdu,
|
||||
case PROP_ACTION:
|
||||
default:
|
||||
/* Decode a "classic" simple property */
|
||||
len = bacapp_decode_generic_property(apdu, max_apdu_len, value,
|
||||
property);
|
||||
len = bacapp_decode_generic_property(
|
||||
apdu, max_apdu_len, value, property);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1335,7 +1321,7 @@ int bacapp_decode_known_property(uint8_t *apdu,
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (BACAPP_TYPES_EXTRA)
|
||||
#if defined(BACAPP_TYPES_EXTRA)
|
||||
/**
|
||||
* @brief Determine the BACnet Context Data number of APDU bytes consumed
|
||||
*
|
||||
@@ -1470,16 +1456,15 @@ bool bacapp_copy(BACNET_APPLICATION_DATA_VALUE *dest_value,
|
||||
src_value->type.Object_Id.instance;
|
||||
break;
|
||||
#endif
|
||||
#if defined (BACAPP_TYPES_EXTRA)
|
||||
#if defined(BACAPP_TYPES_EXTRA)
|
||||
case BACNET_APPLICATION_TAG_LIGHTING_COMMAND:
|
||||
status =
|
||||
lighting_command_copy(&dest_value->type.Lighting_Command,
|
||||
&src_value->type.Lighting_Command);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_HOST_N_PORT:
|
||||
status =
|
||||
host_n_port_copy(&dest_value->type.Host_Address,
|
||||
&src_value->type.Host_Address);
|
||||
status = host_n_port_copy(&dest_value->type.Host_Address,
|
||||
&src_value->type.Host_Address);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
@@ -1537,7 +1522,7 @@ int bacapp_data_len(
|
||||
opening_tag_number_counter--;
|
||||
}
|
||||
} else if (IS_CONTEXT_SPECIFIC(apdu[apdu_len])) {
|
||||
#if defined (BACAPP_TYPES_EXTRA)
|
||||
#if defined(BACAPP_TYPES_EXTRA)
|
||||
/* context-specific tagged data */
|
||||
len = bacapp_decode_context_data_len(
|
||||
&apdu[apdu_len], apdu_len_max - apdu_len, property);
|
||||
@@ -1586,9 +1571,9 @@ static int bacapp_snprintf_date(char *str, size_t str_len, BACNET_DATE *bdate)
|
||||
/* false positive cppcheck - snprintf allows null pointers */
|
||||
/* cppcheck-suppress nullPointer */
|
||||
/* cppcheck-suppress ctunullpointer */
|
||||
slen = snprintf(str, str_len, "%s, %s",
|
||||
bactext_day_of_week_name(bdate->wday),
|
||||
bactext_month_name(bdate->month));
|
||||
slen =
|
||||
snprintf(str, str_len, "%s, %s", bactext_day_of_week_name(bdate->wday),
|
||||
bactext_month_name(bdate->month));
|
||||
if (str) {
|
||||
str += slen;
|
||||
if (str_len >= slen) {
|
||||
@@ -1601,8 +1586,7 @@ static int bacapp_snprintf_date(char *str, size_t str_len, BACNET_DATE *bdate)
|
||||
if (bdate->day == 255) {
|
||||
slen = snprintf(str, str_len, " (unspecified), ");
|
||||
} else {
|
||||
slen = snprintf(str, str_len, " %u, ",
|
||||
(unsigned)bdate->day);
|
||||
slen = snprintf(str, str_len, " %u, ", (unsigned)bdate->day);
|
||||
}
|
||||
if (str) {
|
||||
str += slen;
|
||||
@@ -1616,8 +1600,7 @@ static int bacapp_snprintf_date(char *str, size_t str_len, BACNET_DATE *bdate)
|
||||
if (bdate->year == 2155) {
|
||||
slen = snprintf(str, str_len, "(unspecified)");
|
||||
} else {
|
||||
slen = snprintf(str, str_len, "%u",
|
||||
(unsigned)bdate->year);
|
||||
slen = snprintf(str, str_len, "%u", (unsigned)bdate->year);
|
||||
}
|
||||
ret_val += slen;
|
||||
|
||||
@@ -1641,8 +1624,7 @@ static int bacapp_snprintf_time(char *str, size_t str_len, BACNET_TIME *btime)
|
||||
} else {
|
||||
/* false positive cppcheck - snprintf allows null pointers */
|
||||
/* cppcheck-suppress nullPointer */
|
||||
slen = snprintf(str, str_len, "%02u:",
|
||||
(unsigned)btime->hour);
|
||||
slen = snprintf(str, str_len, "%02u:", (unsigned)btime->hour);
|
||||
}
|
||||
if (str) {
|
||||
str += slen;
|
||||
@@ -1656,8 +1638,7 @@ static int bacapp_snprintf_time(char *str, size_t str_len, BACNET_TIME *btime)
|
||||
if (btime->min == 255) {
|
||||
slen = snprintf(str, str_len, "**:");
|
||||
} else {
|
||||
slen = snprintf(str, str_len, "%02u:",
|
||||
(unsigned)btime->min);
|
||||
slen = snprintf(str, str_len, "%02u:", (unsigned)btime->min);
|
||||
}
|
||||
if (str) {
|
||||
str += slen;
|
||||
@@ -1671,8 +1652,7 @@ static int bacapp_snprintf_time(char *str, size_t str_len, BACNET_TIME *btime)
|
||||
if (btime->sec == 255) {
|
||||
slen = snprintf(str, str_len, "**.");
|
||||
} else {
|
||||
slen = snprintf(str, str_len, "%02u.",
|
||||
(unsigned)btime->sec);
|
||||
slen = snprintf(str, str_len, "%02u.", (unsigned)btime->sec);
|
||||
}
|
||||
if (str) {
|
||||
str += slen;
|
||||
@@ -1686,8 +1666,7 @@ static int bacapp_snprintf_time(char *str, size_t str_len, BACNET_TIME *btime)
|
||||
if (btime->hundredths == 255) {
|
||||
slen = snprintf(str, str_len, "**");
|
||||
} else {
|
||||
slen = snprintf(str, str_len, "%02u",
|
||||
(unsigned)btime->hundredths);
|
||||
slen = snprintf(str, str_len, "%02u", (unsigned)btime->hundredths);
|
||||
}
|
||||
ret_val += slen;
|
||||
|
||||
@@ -1696,8 +1675,7 @@ static int bacapp_snprintf_time(char *str, size_t str_len, BACNET_TIME *btime)
|
||||
#endif
|
||||
|
||||
#if defined(BACAPP_TYPES_EXTRA)
|
||||
static int bacapp_snprintf_weeklyschedule(
|
||||
char *str,
|
||||
static int bacapp_snprintf_weeklyschedule(char *str,
|
||||
size_t str_len,
|
||||
BACNET_WEEKLY_SCHEDULE *ws,
|
||||
BACNET_ARRAY_INDEX arrayIndex)
|
||||
@@ -1708,9 +1686,8 @@ static int bacapp_snprintf_weeklyschedule(
|
||||
BACNET_OBJECT_PROPERTY_VALUE dummyPropValue;
|
||||
BACNET_APPLICATION_DATA_VALUE dummyDataValue;
|
||||
|
||||
const char *weekdaynames[7] = {
|
||||
"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"
|
||||
};
|
||||
const char *weekdaynames[7] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
|
||||
"Sun" };
|
||||
const int loopend = ((arrayIndex == BACNET_ARRAY_ALL) ? 7 : 1);
|
||||
|
||||
// Find what inner type it uses
|
||||
@@ -1732,7 +1709,8 @@ static int bacapp_snprintf_weeklyschedule(
|
||||
} else if (inner_tag == -2) {
|
||||
slen = snprintf(str, str_len, "(MIXED_TYPES; ");
|
||||
} else {
|
||||
slen = snprintf(str, str_len, "(%s; ", bactext_application_tag_name(inner_tag));
|
||||
slen = snprintf(
|
||||
str, str_len, "(%s; ", bactext_application_tag_name(inner_tag));
|
||||
}
|
||||
ret_val += slen;
|
||||
if (str) {
|
||||
@@ -1749,10 +1727,10 @@ static int bacapp_snprintf_weeklyschedule(
|
||||
if (arrayIndex == BACNET_ARRAY_ALL) {
|
||||
slen = snprintf(str, str_len, "%s: [", weekdaynames[wi]);
|
||||
} else {
|
||||
slen = snprintf(
|
||||
str, str_len, "%s: [",
|
||||
(arrayIndex >= 1 && arrayIndex <= 7) ? weekdaynames[arrayIndex - 1] : "???"
|
||||
);
|
||||
slen = snprintf(str, str_len, "%s: [",
|
||||
(arrayIndex >= 1 && arrayIndex <= 7)
|
||||
? weekdaynames[arrayIndex - 1]
|
||||
: "???");
|
||||
}
|
||||
ret_val += slen;
|
||||
if (str) {
|
||||
@@ -1765,7 +1743,8 @@ static int bacapp_snprintf_weeklyschedule(
|
||||
}
|
||||
|
||||
for (ti = 0; ti < ds->TV_Count; ti++) {
|
||||
slen = bacapp_snprintf_time(str, str_len, &ds->Time_Values[ti].Time);
|
||||
slen =
|
||||
bacapp_snprintf_time(str, str_len, &ds->Time_Values[ti].Time);
|
||||
ret_val += slen;
|
||||
if (str) {
|
||||
str += slen;
|
||||
@@ -1837,7 +1816,6 @@ static int bacapp_snprintf_weeklyschedule(
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @brief Extract the value into a text string
|
||||
* @param str - the buffer to store the extracted value, or NULL for length
|
||||
@@ -1856,7 +1834,7 @@ int bacapp_snprintf_value(
|
||||
BACNET_OBJECT_TYPE object_type = MAX_BACNET_OBJECT_TYPE;
|
||||
int ret_val = 0;
|
||||
int slen = 0;
|
||||
#if defined(BACAPP_OCTET_STRING) || defined (BACAPP_TYPES_EXTRA)
|
||||
#if defined(BACAPP_OCTET_STRING) || defined(BACAPP_TYPES_EXTRA)
|
||||
uint8_t *octet_str;
|
||||
#endif
|
||||
#ifdef __STDC_ISO_10646__
|
||||
@@ -1939,7 +1917,7 @@ int bacapp_snprintf_value(
|
||||
}
|
||||
}
|
||||
ret_val += slen;
|
||||
#ifdef __STDC_ISO_10646__
|
||||
#ifdef __STDC_ISO_10646__
|
||||
if (characterstring_encoding(&value->type.Character_String) ==
|
||||
CHARACTER_UTF8) {
|
||||
while (len > 0) {
|
||||
@@ -1975,7 +1953,7 @@ int bacapp_snprintf_value(
|
||||
}
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
#endif
|
||||
{
|
||||
for (i = 0; i < len; i++) {
|
||||
if (isprint(*((unsigned char *)char_str))) {
|
||||
@@ -2075,7 +2053,7 @@ int bacapp_snprintf_value(
|
||||
break;
|
||||
case PROP_UNITS:
|
||||
if (bactext_engineering_unit_name_proprietary(
|
||||
(unsigned)value->type.Enumerated)) {
|
||||
(unsigned)value->type.Enumerated)) {
|
||||
ret_val = snprintf(str, str_len, "proprietary %lu",
|
||||
(unsigned long)value->type.Enumerated);
|
||||
} else {
|
||||
@@ -2125,14 +2103,12 @@ int bacapp_snprintf_value(
|
||||
#endif
|
||||
#if defined(BACAPP_DATE)
|
||||
case BACNET_APPLICATION_TAG_DATE:
|
||||
ret_val = bacapp_snprintf_date(str, str_len,
|
||||
&value->type.Date);
|
||||
ret_val = bacapp_snprintf_date(str, str_len, &value->type.Date);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_TIME)
|
||||
case BACNET_APPLICATION_TAG_TIME:
|
||||
ret_val = bacapp_snprintf_time(str, str_len,
|
||||
&value->type.Time);
|
||||
ret_val = bacapp_snprintf_time(str, str_len, &value->type.Time);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_OBJECT_ID)
|
||||
@@ -2172,10 +2148,9 @@ int bacapp_snprintf_value(
|
||||
ret_val += slen;
|
||||
break;
|
||||
#endif
|
||||
#if defined (BACAPP_TYPES_EXTRA)
|
||||
#if defined(BACAPP_TYPES_EXTRA)
|
||||
case BACNET_APPLICATION_TAG_DATETIME:
|
||||
slen = bacapp_snprintf_date(str, str_len,
|
||||
&value->type.Date);
|
||||
slen = bacapp_snprintf_date(str, str_len, &value->type.Date);
|
||||
ret_val += slen;
|
||||
if (str) {
|
||||
str += slen;
|
||||
@@ -2185,8 +2160,7 @@ int bacapp_snprintf_value(
|
||||
str_len = 0;
|
||||
}
|
||||
}
|
||||
slen = bacapp_snprintf_time(str, str_len,
|
||||
&value->type.Time);
|
||||
slen = bacapp_snprintf_time(str, str_len, &value->type.Time);
|
||||
ret_val += slen;
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_LIGHTING_COMMAND:
|
||||
@@ -2252,18 +2226,16 @@ int bacapp_snprintf_value(
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_WEEKLY_SCHEDULE:
|
||||
/* BACnetWeeklySchedule */
|
||||
ret_val = bacapp_snprintf_weeklyschedule(
|
||||
str, str_len, &value->type.Weekly_Schedule, object_value->array_index);
|
||||
ret_val = bacapp_snprintf_weeklyschedule(str, str_len,
|
||||
&value->type.Weekly_Schedule, object_value->array_index);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_HOST_N_PORT:
|
||||
if (value->type.Host_Address.host_ip_address) {
|
||||
octet_str = octetstring_value(
|
||||
&value->type.Host_Address.host.ip_address);
|
||||
slen = snprintf(str, str_len, "%u.%u.%u.%u:%u",
|
||||
(unsigned)octet_str[0],
|
||||
(unsigned)octet_str[1],
|
||||
(unsigned)octet_str[2],
|
||||
(unsigned)octet_str[3],
|
||||
(unsigned)octet_str[0], (unsigned)octet_str[1],
|
||||
(unsigned)octet_str[2], (unsigned)octet_str[3],
|
||||
(unsigned)value->type.Host_Address.port);
|
||||
ret_val += slen;
|
||||
} else if (value->type.Host_Address.host_name) {
|
||||
@@ -2304,7 +2276,8 @@ int bacapp_snprintf_value(
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
ret_val = snprintf(str, str_len, "UnknownType(tag=%d)", value->tag);
|
||||
ret_val =
|
||||
snprintf(str, str_len, "UnknownType(tag=%d)", value->tag);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2332,17 +2305,17 @@ bool bacapp_print_value(
|
||||
/* get the string length first */
|
||||
str_len = bacapp_snprintf_value(NULL, 0, object_value);
|
||||
if (str_len > 0) {
|
||||
#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
||||
char str[str_len+1];
|
||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
||||
char str[str_len + 1];
|
||||
#else
|
||||
char *str;
|
||||
str = calloc(sizeof(char), str_len+1);
|
||||
str = calloc(sizeof(char), str_len + 1);
|
||||
#endif
|
||||
bacapp_snprintf_value(str, str_len+1, object_value);
|
||||
bacapp_snprintf_value(str, str_len + 1, object_value);
|
||||
if (stream) {
|
||||
fprintf(stream, "%s", str);
|
||||
}
|
||||
#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
||||
/* nothing to do with stack based RAM */
|
||||
#else
|
||||
if (str) {
|
||||
@@ -2357,35 +2330,40 @@ bool bacapp_print_value(
|
||||
#endif
|
||||
|
||||
#ifdef BACAPP_PRINT_ENABLED
|
||||
static char* ltrim(char *str, const char *trimmedchars) {
|
||||
static char *ltrim(char *str, const char *trimmedchars)
|
||||
{
|
||||
if (str[0] == 0) {
|
||||
return str;
|
||||
}
|
||||
while(strchr(trimmedchars, *str)) {
|
||||
while (strchr(trimmedchars, *str)) {
|
||||
str++;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
static char* rtrim(char *str, const char *trimmedchars) {
|
||||
static char *rtrim(char *str, const char *trimmedchars)
|
||||
{
|
||||
if (str[0] == 0) {
|
||||
return str;
|
||||
}
|
||||
char *end = str + strlen(str) - 1;
|
||||
while (strchr(trimmedchars, *end)) {
|
||||
*end = 0;
|
||||
if (end == str) break;
|
||||
if (end == str)
|
||||
break;
|
||||
end--;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
static char* trim(char *str, const char *trimmedchars) {
|
||||
static char *trim(char *str, const char *trimmedchars)
|
||||
{
|
||||
return ltrim(rtrim(str, trimmedchars), trimmedchars);
|
||||
}
|
||||
|
||||
#if defined (BACAPP_TYPES_EXTRA)
|
||||
static bool parse_weeklyschedule(char *str, BACNET_APPLICATION_DATA_VALUE *value)
|
||||
#if defined(BACAPP_TYPES_EXTRA)
|
||||
static bool parse_weeklyschedule(
|
||||
char *str, BACNET_APPLICATION_DATA_VALUE *value)
|
||||
{
|
||||
char *chunk, *comma, *space, *t, *v;
|
||||
int daynum = 0, tvnum = 0;
|
||||
@@ -2396,12 +2374,14 @@ static bool parse_weeklyschedule(char *str, BACNET_APPLICATION_DATA_VALUE *value
|
||||
/*
|
||||
Format:
|
||||
|
||||
(1; Mon: [02:00:00.00 FALSE, 07:35:00.00 active, 07:40:00.00 inactive]; Tue: [02:00:00.00 inactive]; ...)
|
||||
(1; Mon: [02:00:00.00 FALSE, 07:35:00.00 active, 07:40:00.00 inactive];
|
||||
Tue: [02:00:00.00 inactive]; ...)
|
||||
|
||||
- the first number is the inner tag (e.g. 1 = boolean, 4 = real, 9 = enum)
|
||||
- Day name prefix is optional and ignored.
|
||||
- Entries are separated by semicolons.
|
||||
- There can be a full week, or only one entry - when using array index to modify a single day
|
||||
- There can be a full week, or only one entry - when using array index to
|
||||
modify a single day
|
||||
- time-value array can be empty: []
|
||||
*/
|
||||
|
||||
@@ -2410,7 +2390,9 @@ static bool parse_weeklyschedule(char *str, BACNET_APPLICATION_DATA_VALUE *value
|
||||
// Parse the inner tag
|
||||
chunk = strtok(str, ";");
|
||||
chunk = ltrim(chunk, "(");
|
||||
if (false == bacapp_parse_application_data(BACNET_APPLICATION_TAG_UNSIGNED_INT, chunk, &dummy_value)) {
|
||||
if (false ==
|
||||
bacapp_parse_application_data(
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT, chunk, &dummy_value)) {
|
||||
// Try searching it by name
|
||||
if (false == bactext_application_tag_index(chunk, &inner_tag)) {
|
||||
return false;
|
||||
@@ -2421,7 +2403,7 @@ static bool parse_weeklyschedule(char *str, BACNET_APPLICATION_DATA_VALUE *value
|
||||
|
||||
chunk = strtok(NULL, ";");
|
||||
|
||||
while(chunk != NULL) {
|
||||
while (chunk != NULL) {
|
||||
dsch = &value->type.Weekly_Schedule.weeklySchedule[daynum];
|
||||
|
||||
// Strip day name prefix, if present
|
||||
@@ -2455,18 +2437,22 @@ static bool parse_weeklyschedule(char *str, BACNET_APPLICATION_DATA_VALUE *value
|
||||
|
||||
// Extract time and value
|
||||
t = chunk;
|
||||
// value starts one byte after the space, and there can be multiple spaces
|
||||
// value starts one byte after the space, and there can be
|
||||
// multiple spaces
|
||||
chunk = ltrim(space + 1, " ");
|
||||
v = chunk;
|
||||
|
||||
// Parse time
|
||||
if (false == bacapp_parse_application_data(BACNET_APPLICATION_TAG_TIME, t, &dummy_value)) {
|
||||
if (false ==
|
||||
bacapp_parse_application_data(
|
||||
BACNET_APPLICATION_TAG_TIME, t, &dummy_value)) {
|
||||
return false;
|
||||
}
|
||||
dsch->Time_Values[tvnum].Time = dummy_value.type.Time;
|
||||
|
||||
// Parse value
|
||||
if (false == bacapp_parse_application_data(inner_tag, v, &dummy_value)) {
|
||||
if (false ==
|
||||
bacapp_parse_application_data(inner_tag, v, &dummy_value)) {
|
||||
return false;
|
||||
}
|
||||
if (BACNET_STATUS_OK !=
|
||||
@@ -2570,7 +2556,7 @@ bool bacapp_parse_application_data(BACNET_APPLICATION_TAG tag_number,
|
||||
int count = 0;
|
||||
#if defined(BACAPP_TYPES_EXTRA)
|
||||
unsigned a[4] = { 0 }, p = 0;
|
||||
float x,y;
|
||||
float x, y;
|
||||
#endif
|
||||
|
||||
if (value && (tag_number != MAX_BACNET_APPLICATION_TAG)) {
|
||||
@@ -2579,9 +2565,11 @@ bool bacapp_parse_application_data(BACNET_APPLICATION_TAG tag_number,
|
||||
switch (tag_number) {
|
||||
#if defined(BACAPP_BOOLEAN)
|
||||
case BACNET_APPLICATION_TAG_BOOLEAN:
|
||||
if (strcasecmp(argv, "true") == 0 || strcasecmp(argv, "active") == 0) {
|
||||
if (strcasecmp(argv, "true") == 0 ||
|
||||
strcasecmp(argv, "active") == 0) {
|
||||
value->type.Boolean = true;
|
||||
} else if (strcasecmp(argv, "false") == 0 || strcasecmp(argv, "inactive") == 0) {
|
||||
} else if (strcasecmp(argv, "false") == 0 ||
|
||||
strcasecmp(argv, "inactive") == 0) {
|
||||
value->type.Boolean = false;
|
||||
} else {
|
||||
status = strtol_checked(argv, &long_value);
|
||||
@@ -2611,10 +2599,11 @@ bool bacapp_parse_application_data(BACNET_APPLICATION_TAG tag_number,
|
||||
#if defined(BACAPP_SIGNED)
|
||||
case BACNET_APPLICATION_TAG_SIGNED_INT:
|
||||
status = strtol_checked(argv, &long_value);
|
||||
if (!status || long_value > INT32_MAX || long_value < INT32_MIN) {
|
||||
if (!status || long_value > INT32_MAX ||
|
||||
long_value < INT32_MIN) {
|
||||
return false;
|
||||
}
|
||||
value->type.Signed_Int = (int32_t) long_value;
|
||||
value->type.Signed_Int = (int32_t)long_value;
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_REAL)
|
||||
@@ -2658,7 +2647,7 @@ bool bacapp_parse_application_data(BACNET_APPLICATION_TAG tag_number,
|
||||
if (!status || unsigned_long_value > UINT32_MAX) {
|
||||
return false;
|
||||
}
|
||||
value->type.Enumerated = (uint32_t) unsigned_long_value;
|
||||
value->type.Enumerated = (uint32_t)unsigned_long_value;
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_DATE)
|
||||
@@ -2713,14 +2702,13 @@ bool bacapp_parse_application_data(BACNET_APPLICATION_TAG tag_number,
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#if defined (BACAPP_TYPES_EXTRA)
|
||||
#if defined(BACAPP_TYPES_EXTRA)
|
||||
case BACNET_APPLICATION_TAG_LIGHTING_COMMAND:
|
||||
/* FIXME: add parsing for lighting command */
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_XY_COLOR:
|
||||
/* BACnetxyColor */
|
||||
count = sscanf(
|
||||
argv, "%f,%f", &x, &y);
|
||||
count = sscanf(argv, "%f,%f", &x, &y);
|
||||
if (count == 2) {
|
||||
value->type.XY_Color.x_coordinate = x;
|
||||
value->type.XY_Color.y_coordinate = y;
|
||||
@@ -2735,8 +2723,8 @@ bool bacapp_parse_application_data(BACNET_APPLICATION_TAG tag_number,
|
||||
status = parse_weeklyschedule(argv, value);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_HOST_N_PORT:
|
||||
count = sscanf(argv, "%3u.%3u.%3u.%3u:%5u",
|
||||
&a[0], &a[1], &a[2], &a[3], &p);
|
||||
count = sscanf(argv, "%3u.%3u.%3u.%3u:%5u", &a[0], &a[1], &a[2],
|
||||
&a[3], &p);
|
||||
if ((count == 4) || (count == 5)) {
|
||||
uint8_t address[4];
|
||||
value->type.Host_Address.host_ip_address = true;
|
||||
@@ -2745,7 +2733,8 @@ bool bacapp_parse_application_data(BACNET_APPLICATION_TAG tag_number,
|
||||
address[1] = (uint8_t)a[1];
|
||||
address[2] = (uint8_t)a[2];
|
||||
address[3] = (uint8_t)a[3];
|
||||
octetstring_init(&value->type.Host_Address.host.ip_address, address, 4);
|
||||
octetstring_init(
|
||||
&value->type.Host_Address.host.ip_address, address, 4);
|
||||
if (count == 4) {
|
||||
value->type.Host_Address.port = 0xBAC0U;
|
||||
} else {
|
||||
@@ -2928,10 +2917,10 @@ bool bacapp_same_value(BACNET_APPLICATION_DATA_VALUE *value,
|
||||
&value->type.Bit_String, &test_value->type.Bit_String);
|
||||
break;
|
||||
#endif
|
||||
#if defined (BACAPP_TYPES_EXTRA)
|
||||
#if defined(BACAPP_TYPES_EXTRA)
|
||||
case BACNET_APPLICATION_TAG_DATETIME:
|
||||
if (datetime_compare(&value->type.Date_Time,
|
||||
&test_value->type.Date_Time) == 0) {
|
||||
&test_value->type.Date_Time) == 0) {
|
||||
status = true;
|
||||
}
|
||||
break;
|
||||
@@ -2941,8 +2930,8 @@ bool bacapp_same_value(BACNET_APPLICATION_DATA_VALUE *value,
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_XY_COLOR:
|
||||
/* BACnetxyColor */
|
||||
status = xy_color_same(&value->type.XY_Color,
|
||||
&test_value->type.XY_Color);
|
||||
status = xy_color_same(
|
||||
&value->type.XY_Color, &test_value->type.XY_Color);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_COLOR_COMMAND:
|
||||
/* BACnetColorCommand */
|
||||
@@ -2951,12 +2940,13 @@ bool bacapp_same_value(BACNET_APPLICATION_DATA_VALUE *value,
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_WEEKLY_SCHEDULE:
|
||||
/* BACnetWeeklySchedule */
|
||||
status = bacnet_weeklyschedule_same(&value->type.Weekly_Schedule,
|
||||
&test_value->type.Weekly_Schedule);
|
||||
status =
|
||||
bacnet_weeklyschedule_same(&value->type.Weekly_Schedule,
|
||||
&test_value->type.Weekly_Schedule);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_HOST_N_PORT:
|
||||
status = host_n_port_same(&value->type.Host_Address,
|
||||
&value->type.Host_Address);
|
||||
status = host_n_port_same(
|
||||
&value->type.Host_Address, &value->type.Host_Address);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
|
||||
+12
-17
@@ -691,8 +691,7 @@ int encode_application_boolean(uint8_t *apdu, bool boolean_value)
|
||||
} else {
|
||||
len_value = 0;
|
||||
}
|
||||
len =
|
||||
encode_tag(apdu, BACNET_APPLICATION_TAG_BOOLEAN, false, len_value);
|
||||
len = encode_tag(apdu, BACNET_APPLICATION_TAG_BOOLEAN, false, len_value);
|
||||
|
||||
return len;
|
||||
}
|
||||
@@ -1011,8 +1010,7 @@ int encode_context_bitstring(
|
||||
*
|
||||
* @return the number of apdu bytes consumed
|
||||
*/
|
||||
int decode_object_id_safe(
|
||||
uint8_t *apdu,
|
||||
int decode_object_id_safe(uint8_t *apdu,
|
||||
uint32_t len_value_type,
|
||||
BACNET_OBJECT_TYPE *object_type,
|
||||
uint32_t *instance)
|
||||
@@ -1025,8 +1023,8 @@ int decode_object_id_safe(
|
||||
if (apdu) {
|
||||
/* value is meaningless if apdu was NULL */
|
||||
if (object_type) {
|
||||
*object_type = (BACNET_OBJECT_TYPE)(
|
||||
((value >> BACNET_INSTANCE_BITS) & BACNET_MAX_OBJECT));
|
||||
*object_type = (BACNET_OBJECT_TYPE)((
|
||||
(value >> BACNET_INSTANCE_BITS) & BACNET_MAX_OBJECT));
|
||||
}
|
||||
if (instance) {
|
||||
*instance = (value & BACNET_MAX_INSTANCE);
|
||||
@@ -1049,9 +1047,7 @@ int decode_object_id_safe(
|
||||
* @return the number of apdu bytes consumed
|
||||
*/
|
||||
int decode_object_id(
|
||||
uint8_t *apdu,
|
||||
BACNET_OBJECT_TYPE *object_type,
|
||||
uint32_t *instance)
|
||||
uint8_t *apdu, BACNET_OBJECT_TYPE *object_type, uint32_t *instance)
|
||||
{
|
||||
const uint32_t len_value = 4;
|
||||
|
||||
@@ -1079,8 +1075,8 @@ int bacnet_object_id_decode(uint8_t *apdu,
|
||||
|
||||
len = decode_object_id_safe(NULL, len_value_type, object_type, instance);
|
||||
if (len <= apdu_len_max) {
|
||||
return decode_object_id_safe(apdu, len_value_type, object_type,
|
||||
instance);
|
||||
return decode_object_id_safe(
|
||||
apdu, len_value_type, object_type, instance);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -1316,8 +1312,8 @@ int encode_application_octet_string(
|
||||
uint8_t *apdu_offset = NULL;
|
||||
|
||||
if (octet_string) {
|
||||
len = encode_tag(apdu, BACNET_APPLICATION_TAG_OCTET_STRING,
|
||||
false, octetstring_length(octet_string));
|
||||
len = encode_tag(apdu, BACNET_APPLICATION_TAG_OCTET_STRING, false,
|
||||
octetstring_length(octet_string));
|
||||
if (apdu) {
|
||||
apdu_offset = &apdu[len];
|
||||
}
|
||||
@@ -1505,8 +1501,8 @@ int encode_application_character_string(
|
||||
uint8_t *apdu_offset = NULL;
|
||||
|
||||
len = encode_bacnet_character_string(NULL, char_string);
|
||||
len = encode_tag(apdu, BACNET_APPLICATION_TAG_CHARACTER_STRING,
|
||||
false, (uint32_t)len);
|
||||
len = encode_tag(
|
||||
apdu, BACNET_APPLICATION_TAG_CHARACTER_STRING, false, (uint32_t)len);
|
||||
if (apdu) {
|
||||
apdu_offset = &apdu[len];
|
||||
}
|
||||
@@ -2980,8 +2976,7 @@ int encode_bacnet_address(uint8_t *apdu, BACNET_ADDRESS *destination)
|
||||
|
||||
if (destination) {
|
||||
/* network number */
|
||||
apdu_len +=
|
||||
encode_application_unsigned(apdu, destination->net);
|
||||
apdu_len += encode_application_unsigned(apdu, destination->net);
|
||||
/* encode mac address as an octet-string */
|
||||
if (destination->len != 0) {
|
||||
octetstring_init(&mac_addr, destination->adr, destination->len);
|
||||
|
||||
@@ -153,17 +153,14 @@ int bacapp_decode_device_obj_property_ref(
|
||||
uint32_t enumValue = 0;
|
||||
|
||||
/* object-identifier [0] BACnetObjectIdentifier */
|
||||
len =
|
||||
decode_context_object_id(&apdu[apdu_len], 0,
|
||||
&value->objectIdentifier.type,
|
||||
&value->objectIdentifier.instance);
|
||||
len = decode_context_object_id(&apdu[apdu_len], 0,
|
||||
&value->objectIdentifier.type, &value->objectIdentifier.instance);
|
||||
if (len == BACNET_STATUS_ERROR) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
apdu_len += len;
|
||||
/* property-identifier [1] BACnetPropertyIdentifier */
|
||||
len =
|
||||
decode_context_enumerated(&apdu[apdu_len], 1, &enumValue);
|
||||
len = decode_context_enumerated(&apdu[apdu_len], 1, &enumValue);
|
||||
if (len == BACNET_STATUS_ERROR) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
@@ -172,8 +169,7 @@ int bacapp_decode_device_obj_property_ref(
|
||||
/* property-array-index [2] Unsigned OPTIONAL */
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 2) &&
|
||||
!decode_is_closing_tag(&apdu[apdu_len])) {
|
||||
len = decode_context_unsigned(
|
||||
&apdu[apdu_len], 2, &value->arrayIndex);
|
||||
len = decode_context_unsigned(&apdu[apdu_len], 2, &value->arrayIndex);
|
||||
if (len == BACNET_STATUS_ERROR) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
@@ -210,8 +206,7 @@ int bacapp_decode_device_obj_property_ref(
|
||||
*
|
||||
* @return Bytes decoded or BACNET_STATUS_ERROR on failure.
|
||||
*/
|
||||
int bacapp_decode_context_device_obj_property_ref(
|
||||
uint8_t *apdu,
|
||||
int bacapp_decode_context_device_obj_property_ref(uint8_t *apdu,
|
||||
uint8_t tag_number,
|
||||
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE *value)
|
||||
{
|
||||
@@ -255,9 +250,7 @@ int bacapp_decode_context_device_obj_property_ref(
|
||||
* @return Bytes encoded or 0 on failure.
|
||||
*/
|
||||
int bacapp_encode_context_device_obj_ref(
|
||||
uint8_t *apdu,
|
||||
uint8_t tag_number,
|
||||
BACNET_DEVICE_OBJECT_REFERENCE *value)
|
||||
uint8_t *apdu, uint8_t tag_number, BACNET_DEVICE_OBJECT_REFERENCE *value)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
@@ -291,8 +284,7 @@ int bacapp_encode_context_device_obj_ref(
|
||||
* @return Bytes encoded or 0 on failure.
|
||||
*/
|
||||
int bacapp_encode_device_obj_ref(
|
||||
uint8_t * apdu,
|
||||
BACNET_DEVICE_OBJECT_REFERENCE * value)
|
||||
uint8_t *apdu, BACNET_DEVICE_OBJECT_REFERENCE *value)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
@@ -307,9 +299,8 @@ int bacapp_encode_device_obj_ref(
|
||||
apdu_len += len;
|
||||
}
|
||||
/* object-identifier [1] BACnetObjectIdentifier */
|
||||
len =
|
||||
encode_context_object_id(&apdu[apdu_len], 1,
|
||||
value->objectIdentifier.type, value->objectIdentifier.instance);
|
||||
len = encode_context_object_id(&apdu[apdu_len], 1,
|
||||
value->objectIdentifier.type, value->objectIdentifier.instance);
|
||||
apdu_len += len;
|
||||
|
||||
return apdu_len;
|
||||
@@ -330,8 +321,7 @@ int bacapp_encode_device_obj_ref(
|
||||
* @return Bytes decoded or BACNET_STATUS_ERROR on failure.
|
||||
*/
|
||||
int bacapp_decode_device_obj_ref(
|
||||
uint8_t * apdu,
|
||||
BACNET_DEVICE_OBJECT_REFERENCE * value)
|
||||
uint8_t *apdu, BACNET_DEVICE_OBJECT_REFERENCE *value)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
@@ -339,10 +329,8 @@ int bacapp_decode_device_obj_ref(
|
||||
/* device-identifier [0] BACnetObjectIdentifier OPTIONAL */
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 0) &&
|
||||
!decode_is_closing_tag(&apdu[apdu_len])) {
|
||||
len =
|
||||
decode_context_object_id(&apdu[apdu_len], 0,
|
||||
&value->deviceIdentifier.type,
|
||||
&value->deviceIdentifier.instance);
|
||||
len = decode_context_object_id(&apdu[apdu_len], 0,
|
||||
&value->deviceIdentifier.type, &value->deviceIdentifier.instance);
|
||||
if (len == BACNET_STATUS_ERROR) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
@@ -352,10 +340,8 @@ int bacapp_decode_device_obj_ref(
|
||||
value->deviceIdentifier.instance = BACNET_NO_DEV_ID;
|
||||
}
|
||||
/* object-identifier [1] BACnetObjectIdentifier */
|
||||
len =
|
||||
decode_context_object_id(&apdu[apdu_len], 1,
|
||||
&value->objectIdentifier.type,
|
||||
&value->objectIdentifier.instance);
|
||||
len = decode_context_object_id(&apdu[apdu_len], 1,
|
||||
&value->objectIdentifier.type, &value->objectIdentifier.instance);
|
||||
if (len == BACNET_STATUS_ERROR) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
@@ -376,9 +362,7 @@ int bacapp_decode_device_obj_ref(
|
||||
* @return Bytes decoded or BACNET_STATUS_ERROR on failure.
|
||||
*/
|
||||
int bacapp_decode_context_device_obj_ref(
|
||||
uint8_t * apdu,
|
||||
uint8_t tag_number,
|
||||
BACNET_DEVICE_OBJECT_REFERENCE * value)
|
||||
uint8_t *apdu, uint8_t tag_number, BACNET_DEVICE_OBJECT_REFERENCE *value)
|
||||
{
|
||||
int len = 0;
|
||||
int section_length;
|
||||
@@ -402,7 +386,6 @@ int bacapp_decode_context_device_obj_ref(
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Encode a BACnetObjectPropertyReference
|
||||
*
|
||||
@@ -418,8 +401,8 @@ int bacapp_decode_context_device_obj_ref(
|
||||
* @param reference - BACnetObjectPropertyReference
|
||||
* @return length of the APDU buffer
|
||||
*/
|
||||
int bacapp_encode_obj_property_ref(uint8_t *apdu,
|
||||
BACNET_OBJECT_PROPERTY_REFERENCE *reference)
|
||||
int bacapp_encode_obj_property_ref(
|
||||
uint8_t *apdu, BACNET_OBJECT_PROPERTY_REFERENCE *reference)
|
||||
{
|
||||
int len = 0;
|
||||
uint8_t *apdu_offset = NULL;
|
||||
@@ -540,16 +523,15 @@ int bacapp_decode_obj_property_ref(uint8_t *apdu,
|
||||
if (reference) {
|
||||
reference->object_identifier.type = object_identifier.type;
|
||||
reference->object_identifier.instance = object_identifier.instance;
|
||||
reference->property_identifier =
|
||||
reference->property_identifier =
|
||||
(BACNET_PROPERTY_ID)property_identifier;
|
||||
reference->property_array_index = BACNET_ARRAY_ALL;
|
||||
}
|
||||
/* property-array-index [2] Unsigned OPTIONAL */
|
||||
if (apdu_len_max > apdu_len) {
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 2)) {
|
||||
len = bacnet_unsigned_context_decode(
|
||||
&apdu[apdu_len], apdu_len_max - apdu_len, 2,
|
||||
&unsigned_value);
|
||||
len = bacnet_unsigned_context_decode(&apdu[apdu_len],
|
||||
apdu_len_max - apdu_len, 2, &unsigned_value);
|
||||
if (len > 0) {
|
||||
apdu_len += len;
|
||||
if (unsigned_value > UINT32_MAX) {
|
||||
@@ -580,11 +562,10 @@ int bacapp_decode_obj_property_ref(uint8_t *apdu,
|
||||
*
|
||||
* @return Bytes decoded or BACNET_STATUS_ERROR on failure.
|
||||
*/
|
||||
int bacapp_decode_context_obj_property_ref(
|
||||
uint8_t * apdu,
|
||||
int bacapp_decode_context_obj_property_ref(uint8_t *apdu,
|
||||
uint16_t apdu_len_max,
|
||||
uint8_t tag_number,
|
||||
BACNET_OBJECT_PROPERTY_REFERENCE * value)
|
||||
BACNET_OBJECT_PROPERTY_REFERENCE *value)
|
||||
{
|
||||
int len = 0;
|
||||
int apdu_len = 0;
|
||||
@@ -597,8 +578,8 @@ int bacapp_decode_context_obj_property_ref(
|
||||
} else {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
len = bacapp_decode_obj_property_ref(&apdu[apdu_len],
|
||||
apdu_len_max - apdu_len, value);
|
||||
len = bacapp_decode_obj_property_ref(
|
||||
&apdu[apdu_len], apdu_len_max - apdu_len, value);
|
||||
if (len == 0) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
} else {
|
||||
|
||||
@@ -74,7 +74,6 @@ int decode_real(uint8_t *apdu, float *real_value)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 4;
|
||||
}
|
||||
|
||||
|
||||
+10
-11
@@ -48,8 +48,8 @@
|
||||
* emitting a warning, forcing Zephyr's sanitycheck() script to stop.
|
||||
* Until this is chased down, the definition is being provided here.
|
||||
*/
|
||||
#if __ZEPHYR__ && ! CONFIG_NATIVE_APPLICATION
|
||||
size_t strnlen (const char *, size_t);
|
||||
#if __ZEPHYR__ && !CONFIG_NATIVE_APPLICATION
|
||||
size_t strnlen(const char *, size_t);
|
||||
#endif
|
||||
|
||||
/** @file bacstr.c Manipulate Bit/Char/Octet Strings */
|
||||
@@ -58,7 +58,7 @@ size_t strnlen (const char *, size_t);
|
||||
#endif
|
||||
|
||||
/* check the limits of bitstring capacity */
|
||||
#if ((MAX_BITSTRING_BYTES * 8) > (UINT8_MAX+1))
|
||||
#if ((MAX_BITSTRING_BYTES * 8) > (UINT8_MAX + 1))
|
||||
#error "MAX_BITSTRING_BYTES cannot exceed 32!"
|
||||
#endif
|
||||
#if (((MAX_BITSTRING_BYTES * 8) > UINT8_MAX) && (UINT_MAX <= UINT8_MAX))
|
||||
@@ -231,9 +231,7 @@ bool bitstring_set_octet(
|
||||
* @return true on success or false on error.
|
||||
*/
|
||||
bool bitstring_set_bits_used(
|
||||
BACNET_BIT_STRING * bit_string,
|
||||
uint8_t bytes_used,
|
||||
uint8_t unused_bits)
|
||||
BACNET_BIT_STRING *bit_string, uint8_t bytes_used, uint8_t unused_bits)
|
||||
{
|
||||
bool status = false;
|
||||
|
||||
@@ -256,10 +254,10 @@ bool bitstring_set_bits_used(
|
||||
unsigned bitstring_bits_capacity(BACNET_BIT_STRING *bit_string)
|
||||
{
|
||||
if (bit_string) {
|
||||
if ((MAX_BITSTRING_BYTES * 8) <= (UINT8_MAX+1)) {
|
||||
if ((MAX_BITSTRING_BYTES * 8) <= (UINT8_MAX + 1)) {
|
||||
return (MAX_BITSTRING_BYTES * 8);
|
||||
} else {
|
||||
return (UINT8_MAX+1);
|
||||
return (UINT8_MAX + 1);
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
@@ -479,7 +477,7 @@ bool characterstring_copy(
|
||||
{
|
||||
if (dest && src) {
|
||||
return characterstring_init(dest, characterstring_encoding(src),
|
||||
characterstring_value(src), characterstring_length(src));
|
||||
characterstring_value(src), characterstring_length(src));
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -500,7 +498,8 @@ bool characterstring_ansi_copy(
|
||||
size_t i; /* counter */
|
||||
|
||||
if (dest && src) {
|
||||
if ((src->encoding == CHARACTER_ANSI_X34) && (src->length < dest_max_len)) {
|
||||
if ((src->encoding == CHARACTER_ANSI_X34) &&
|
||||
(src->length < dest_max_len)) {
|
||||
for (i = 0; i < dest_max_len; i++) {
|
||||
if (i < src->length) {
|
||||
dest[i] = src->value[i];
|
||||
@@ -839,7 +838,7 @@ bool utf8_isvalid(const char *str, size_t length)
|
||||
return false;
|
||||
}
|
||||
/* Check characters. */
|
||||
pend = (unsigned char *) str + length;
|
||||
pend = (unsigned char *)str + length;
|
||||
for (p = (const unsigned char *)str; p < pend; p++) {
|
||||
c = *p;
|
||||
/* null in middle of string */
|
||||
|
||||
@@ -129,8 +129,8 @@ const char *bactext_unconfirmed_service_name(unsigned index)
|
||||
bacnet_unconfirmed_service_names, index, ASHRAE_Reserved_String);
|
||||
}
|
||||
|
||||
INDTEXT_DATA bacnet_application_tag_names[] = {
|
||||
{ BACNET_APPLICATION_TAG_NULL, "Null" },
|
||||
INDTEXT_DATA bacnet_application_tag_names[] = { { BACNET_APPLICATION_TAG_NULL,
|
||||
"Null" },
|
||||
{ BACNET_APPLICATION_TAG_BOOLEAN, "Boolean" },
|
||||
{ BACNET_APPLICATION_TAG_UNSIGNED_INT, "Unsigned Int" },
|
||||
{ BACNET_APPLICATION_TAG_SIGNED_INT, "Signed Int" },
|
||||
@@ -166,8 +166,7 @@ INDTEXT_DATA bacnet_application_tag_names[] = {
|
||||
{ BACNET_APPLICATION_TAG_READ_ACCESS_SPECIFICATION,
|
||||
"BACnetReadAccessSpecification" },
|
||||
{ BACNET_APPLICATION_TAG_LIGHTING_COMMAND, "BACnetLightingCommand" },
|
||||
{ BACNET_APPLICATION_TAG_HOST_N_PORT, "BACnetHostNPort" },
|
||||
{ 0, NULL } };
|
||||
{ BACNET_APPLICATION_TAG_HOST_N_PORT, "BACnetHostNPort" }, { 0, NULL } };
|
||||
|
||||
const char *bactext_application_tag_name(unsigned index)
|
||||
{
|
||||
@@ -744,8 +743,7 @@ INDTEXT_DATA bacnet_property_names[] = {
|
||||
{ PROP_COLOR_COMMAND, "color-command" },
|
||||
{ PROP_HIGH_END_TRIM, "high-end-trim" },
|
||||
{ PROP_LOW_END_TRIM, "low-end-trim" },
|
||||
{ PROP_TRIM_FADE_TIME, "trim-fade-time" },
|
||||
{ 0, NULL }
|
||||
{ PROP_TRIM_FADE_TIME, "trim-fade-time" }, { 0, NULL }
|
||||
};
|
||||
|
||||
bool bactext_property_name_proprietary(unsigned index)
|
||||
|
||||
+34
-26
@@ -39,32 +39,33 @@
|
||||
#include "bacnet/bactimevalue.h"
|
||||
#include "bacnet/bacapp.h"
|
||||
|
||||
static bool is_data_value_schedule_compatible(uint8_t tag) {
|
||||
static bool is_data_value_schedule_compatible(uint8_t tag)
|
||||
{
|
||||
switch (tag) {
|
||||
/* Every member of the union must be listed here to allow decoding */
|
||||
case BACNET_APPLICATION_TAG_NULL:
|
||||
return true;
|
||||
#if defined (BACAPP_BOOLEAN)
|
||||
#if defined(BACAPP_BOOLEAN)
|
||||
case BACNET_APPLICATION_TAG_BOOLEAN:
|
||||
return true;
|
||||
#endif
|
||||
#if defined (BACAPP_UNSIGNED)
|
||||
#if defined(BACAPP_UNSIGNED)
|
||||
case BACNET_APPLICATION_TAG_UNSIGNED_INT:
|
||||
return true;
|
||||
#endif
|
||||
#if defined (BACAPP_SIGNED)
|
||||
#if defined(BACAPP_SIGNED)
|
||||
case BACNET_APPLICATION_TAG_SIGNED_INT:
|
||||
return true;
|
||||
#endif
|
||||
#if defined (BACAPP_REAL)
|
||||
#if defined(BACAPP_REAL)
|
||||
case BACNET_APPLICATION_TAG_REAL:
|
||||
return true;
|
||||
#endif
|
||||
#if defined (BACAPP_DOUBLE)
|
||||
#if defined(BACAPP_DOUBLE)
|
||||
case BACNET_APPLICATION_TAG_DOUBLE:
|
||||
return true;
|
||||
#endif
|
||||
#if defined (BACAPP_ENUMERATED)
|
||||
#if defined(BACAPP_ENUMERATED)
|
||||
case BACNET_APPLICATION_TAG_ENUMERATED:
|
||||
return true;
|
||||
#endif
|
||||
@@ -102,7 +103,8 @@ int bacnet_time_value_encode(uint8_t *apdu, BACNET_TIME_VALUE *value)
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int bacapp_encode_time_value(uint8_t *apdu, BACNET_TIME_VALUE *value) {
|
||||
int bacapp_encode_time_value(uint8_t *apdu, BACNET_TIME_VALUE *value)
|
||||
{
|
||||
return bacnet_time_value_encode(apdu, value);
|
||||
}
|
||||
|
||||
@@ -134,7 +136,8 @@ int bacnet_time_value_context_encode(
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int bacapp_encode_context_time_value(uint8_t *apdu, uint8_t tag_number, BACNET_TIME_VALUE *value)
|
||||
int bacapp_encode_context_time_value(
|
||||
uint8_t *apdu, uint8_t tag_number, BACNET_TIME_VALUE *value)
|
||||
{
|
||||
return bacnet_time_value_context_encode(apdu, tag_number, value);
|
||||
}
|
||||
@@ -156,8 +159,8 @@ int bacnet_application_to_primitive_data_value(
|
||||
|
||||
/** returns 0 if OK, -1 on error */
|
||||
int bacnet_primitive_to_application_data_value(
|
||||
struct BACnet_Application_Data_Value * dest,
|
||||
const struct BACnet_Primitive_Data_Value * src)
|
||||
struct BACnet_Application_Data_Value *dest,
|
||||
const struct BACnet_Primitive_Data_Value *src)
|
||||
{
|
||||
// make sure the value passed is valid
|
||||
if (!dest || !src) {
|
||||
@@ -169,19 +172,22 @@ int bacnet_primitive_to_application_data_value(
|
||||
return BACNET_STATUS_OK; /* OK */
|
||||
}
|
||||
|
||||
int bacnet_time_value_decode(uint8_t *apdu, int max_apdu_len, BACNET_TIME_VALUE *value)
|
||||
int bacnet_time_value_decode(
|
||||
uint8_t *apdu, int max_apdu_len, BACNET_TIME_VALUE *value)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
BACNET_APPLICATION_DATA_VALUE full_data_value = { 0 };
|
||||
|
||||
len = bacnet_time_application_decode(&apdu[apdu_len], max_apdu_len, &value->Time);
|
||||
len = bacnet_time_application_decode(
|
||||
&apdu[apdu_len], max_apdu_len, &value->Time);
|
||||
if (len <= 0) {
|
||||
return -1;
|
||||
}
|
||||
apdu_len += len;
|
||||
|
||||
len = bacapp_decode_application_data(&apdu[apdu_len], max_apdu_len - apdu_len, &full_data_value);
|
||||
len = bacapp_decode_application_data(
|
||||
&apdu[apdu_len], max_apdu_len - apdu_len, &full_data_value);
|
||||
if (len <= 0) {
|
||||
return -1;
|
||||
}
|
||||
@@ -200,25 +206,31 @@ int bacapp_decode_time_value(uint8_t *apdu, BACNET_TIME_VALUE *value)
|
||||
return bacnet_time_value_decode(apdu, MAX_APDU, value);
|
||||
}
|
||||
|
||||
int bacnet_time_value_context_decode(uint8_t *apdu, int max_apdu_len, uint8_t tag_number, BACNET_TIME_VALUE *value)
|
||||
int bacnet_time_value_context_decode(uint8_t *apdu,
|
||||
int max_apdu_len,
|
||||
uint8_t tag_number,
|
||||
BACNET_TIME_VALUE *value)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
|
||||
if ((max_apdu_len - apdu_len) >= 1 && decode_is_opening_tag_number(&apdu[apdu_len], tag_number)) {
|
||||
if ((max_apdu_len - apdu_len) >= 1 &&
|
||||
decode_is_opening_tag_number(&apdu[apdu_len], tag_number)) {
|
||||
apdu_len += 1;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
len = bacnet_time_value_decode(&apdu[apdu_len], max_apdu_len - apdu_len, value);
|
||||
len = bacnet_time_value_decode(
|
||||
&apdu[apdu_len], max_apdu_len - apdu_len, value);
|
||||
if (len > 0) {
|
||||
apdu_len += len;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((max_apdu_len - apdu_len) >= 1 && decode_is_closing_tag_number(&apdu[apdu_len], tag_number)) {
|
||||
if ((max_apdu_len - apdu_len) >= 1 &&
|
||||
decode_is_closing_tag_number(&apdu[apdu_len], tag_number)) {
|
||||
apdu_len += 1;
|
||||
} else {
|
||||
return -1;
|
||||
@@ -233,8 +245,7 @@ int bacapp_decode_context_time_value(
|
||||
return bacnet_time_value_context_decode(apdu, MAX_APDU, tag_number, value);
|
||||
}
|
||||
|
||||
int bacnet_time_values_context_decode(
|
||||
uint8_t * apdu,
|
||||
int bacnet_time_values_context_decode(uint8_t *apdu,
|
||||
const int max_apdu_len,
|
||||
const uint8_t tag_number,
|
||||
BACNET_TIME_VALUE *time_values,
|
||||
@@ -277,7 +288,7 @@ int bacnet_time_values_context_decode(
|
||||
if (apdu_len >= max_apdu_len) {
|
||||
return -1;
|
||||
}
|
||||
apdu_len++; /* closing tag */
|
||||
apdu_len++; /* closing tag */
|
||||
if (out_count) {
|
||||
*out_count = count_values;
|
||||
}
|
||||
@@ -287,8 +298,7 @@ int bacnet_time_values_context_decode(
|
||||
}
|
||||
|
||||
/* Encodes a : [x] SEQUENCE OF BACnetTimeValue into a fixed-size buffer */
|
||||
int bacnet_time_values_context_encode(
|
||||
uint8_t * apdu,
|
||||
int bacnet_time_values_context_encode(uint8_t *apdu,
|
||||
uint8_t tag_number,
|
||||
BACNET_TIME_VALUE *time_values,
|
||||
unsigned int max_time_values)
|
||||
@@ -312,9 +322,7 @@ int bacnet_time_values_context_encode(
|
||||
if (apdu) {
|
||||
apdu_offset = &apdu[apdu_len];
|
||||
}
|
||||
len =
|
||||
bacnet_time_value_encode(apdu_offset,
|
||||
&time_values[j]);
|
||||
len = bacnet_time_value_encode(apdu_offset, &time_values[j]);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
apdu_len += len;
|
||||
|
||||
@@ -784,9 +784,8 @@ int bvlc_bbmd_disabled_handler(BACNET_IP_ADDRESS *addr,
|
||||
npdu = &mtu[offset];
|
||||
if (npdu_confirmed_service(npdu, npdu_len)) {
|
||||
offset = 0;
|
||||
debug_print_string(
|
||||
"Original-Broadcast-NPDU: "
|
||||
"Confirmed Service! Discard!");
|
||||
debug_print_string("Original-Broadcast-NPDU: "
|
||||
"Confirmed Service! Discard!");
|
||||
} else {
|
||||
debug_print_npdu(
|
||||
"Original-Broadcast-NPDU", offset, npdu_len);
|
||||
@@ -1105,14 +1104,13 @@ int bvlc_bbmd_enabled_handler(BACNET_IP_ADDRESS *addr,
|
||||
network layer. */
|
||||
if (npdu_confirmed_service(npdu, npdu_len)) {
|
||||
offset = 0;
|
||||
debug_print_string(
|
||||
"Original-Broadcast-NPDU: "
|
||||
"Confirmed Service! Discard!");
|
||||
debug_print_string("Original-Broadcast-NPDU: "
|
||||
"Confirmed Service! Discard!");
|
||||
} else {
|
||||
(void)bbmd_fdt_forward_npdu(addr, npdu, npdu_len, true);
|
||||
(void)bbmd_bdt_forward_npdu(addr, npdu, npdu_len, true);
|
||||
debug_print_npdu("Original-Broadcast-NPDU",
|
||||
offset, npdu_len);
|
||||
debug_print_npdu(
|
||||
"Original-Broadcast-NPDU", offset, npdu_len);
|
||||
}
|
||||
} else {
|
||||
debug_print_string(
|
||||
@@ -1211,8 +1209,7 @@ int bvlc_register_with_bbmd(BACNET_IP_ADDRESS *bbmd_addr, uint16_t ttl_seconds)
|
||||
* 0 if no registration request is sent, or
|
||||
* -1 if registration fails.
|
||||
*/
|
||||
void bvlc_remote_bbmd_address(
|
||||
BACNET_IP_ADDRESS *bbmd_addr)
|
||||
void bvlc_remote_bbmd_address(BACNET_IP_ADDRESS *bbmd_addr)
|
||||
{
|
||||
bvlc_address_copy(bbmd_addr, &Remote_BBMD);
|
||||
}
|
||||
@@ -1222,8 +1219,7 @@ void bvlc_remote_bbmd_address(
|
||||
* Register Foreign Device
|
||||
* @return Lease time in seconds to use when registering.
|
||||
*/
|
||||
uint16_t bvlc_remote_bbmd_lifetime(
|
||||
void)
|
||||
uint16_t bvlc_remote_bbmd_lifetime(void)
|
||||
{
|
||||
return Remote_BBMD_TTL_Seconds;
|
||||
}
|
||||
|
||||
@@ -44,15 +44,14 @@
|
||||
#include "bacnet/basic/bbmd6/vmac.h"
|
||||
#include "bacnet/basic/bbmd6/h_bbmd6.h"
|
||||
|
||||
|
||||
static bool BVLC6_Debug;
|
||||
#if PRINT_ENABLED
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) \
|
||||
if (BVLC6_Debug) { \
|
||||
fprintf(stderr,__VA_ARGS__); \
|
||||
fflush(stderr); \
|
||||
#define PRINTF(...) \
|
||||
if (BVLC6_Debug) { \
|
||||
fprintf(stderr, __VA_ARGS__); \
|
||||
fflush(stderr); \
|
||||
}
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
@@ -709,7 +708,7 @@ int bvlc6_bbmd_disabled_handler(BACNET_IP6_ADDRESS *addr,
|
||||
offset = header_len + (function_len - npdu_len);
|
||||
} else {
|
||||
PRINTF("BIP6: Original-Unicast-NPDU: "
|
||||
"VMAC is not me!\n");
|
||||
"VMAC is not me!\n");
|
||||
}
|
||||
} else {
|
||||
PRINTF(
|
||||
@@ -740,13 +739,12 @@ int bvlc6_bbmd_disabled_handler(BACNET_IP6_ADDRESS *addr,
|
||||
npdu = &mtu[offset];
|
||||
if (npdu_confirmed_service(npdu, npdu_len)) {
|
||||
offset = 0;
|
||||
PRINTF(
|
||||
"BIP6: Original-Broadcast-NPDU: "
|
||||
"Confirmed Service! Discard!");
|
||||
PRINTF("BIP6: Original-Broadcast-NPDU: "
|
||||
"Confirmed Service! Discard!");
|
||||
}
|
||||
} else {
|
||||
PRINTF("BIP6: Original-Broadcast-NPDU: Unable to "
|
||||
"decode!\n");
|
||||
"decode!\n");
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -766,8 +764,7 @@ int bvlc6_bbmd_disabled_handler(BACNET_IP6_ADDRESS *addr,
|
||||
bvlc6_vmac_address_set(src, vmac_src);
|
||||
offset = header_len + (function_len - npdu_len);
|
||||
} else {
|
||||
PRINTF(
|
||||
"BIP6: Forwarded-NPDU: Unable to decode!\n");
|
||||
PRINTF("BIP6: Forwarded-NPDU: Unable to decode!\n");
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -908,9 +905,8 @@ int bvlc6_bbmd_enabled_handler(BACNET_IP6_ADDRESS *addr,
|
||||
network layer. */
|
||||
if (npdu_confirmed_service(npdu, npdu_len)) {
|
||||
offset = 0;
|
||||
PRINTF(
|
||||
"BIP6: Original-Broadcast-NPDU: "
|
||||
"Confirmed Service! Discard!");
|
||||
PRINTF("BIP6: Original-Broadcast-NPDU: "
|
||||
"Confirmed Service! Discard!");
|
||||
} else {
|
||||
/* Upon receipt of a BVLL Original-Broadcast-NPDU
|
||||
message from the local multicast domain, a BBMD
|
||||
|
||||
@@ -47,10 +47,10 @@ static bool VMAC_Debug = false;
|
||||
#if PRINT_ENABLED
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) \
|
||||
if (VMAC_Debug) { \
|
||||
fprintf(stderr,__VA_ARGS__); \
|
||||
fflush(stderr); \
|
||||
#define PRINTF(...) \
|
||||
if (VMAC_Debug) { \
|
||||
fprintf(stderr, __VA_ARGS__); \
|
||||
fflush(stderr); \
|
||||
}
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
|
||||
@@ -484,7 +484,7 @@ void address_set_device_TTL(
|
||||
pMatch->TimeToLive = TimeOut;
|
||||
}
|
||||
} else {
|
||||
/* For unbound we can only set the time to live */
|
||||
/* For unbound we can only set the time to live */
|
||||
pMatch->TimeToLive = TimeOut;
|
||||
}
|
||||
break; /* Exit now if found at all - bound or unbound */
|
||||
@@ -601,7 +601,7 @@ void address_add(uint32_t device_id, unsigned max_apdu, BACNET_ADDRESS *src)
|
||||
/* Opportunistic entry so leave on short fuse */
|
||||
pMatch->TimeToLive = BAC_ADDR_SHORT_TIME;
|
||||
} else {
|
||||
/* Renewing existing entry */
|
||||
/* Renewing existing entry */
|
||||
pMatch->TimeToLive = BAC_ADDR_LONG_TIME;
|
||||
}
|
||||
/* Clear bind request flag just in case */
|
||||
@@ -1036,7 +1036,7 @@ int rr_address_list_encode(uint8_t *apdu, BACNET_READ_RANGE_DATA *pRequest)
|
||||
pMatch++;
|
||||
/* Shall not happen as the count has been checked first. */
|
||||
if (pMatch > &Address_Cache[MAX_ADDRESS_CACHE - 1]) {
|
||||
/* Issue with the table. */
|
||||
/* Issue with the table. */
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
@@ -1053,7 +1053,7 @@ int rr_address_list_encode(uint8_t *apdu, BACNET_READ_RANGE_DATA *pRequest)
|
||||
}
|
||||
/* Shall not happen as the count has been checked first. */
|
||||
if (pMatch > &Address_Cache[MAX_ADDRESS_CACHE - 1]) {
|
||||
/* Issue with the table. */
|
||||
/* Issue with the table. */
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
@@ -1104,7 +1104,7 @@ int rr_address_list_encode(uint8_t *apdu, BACNET_READ_RANGE_DATA *pRequest)
|
||||
pMatch++;
|
||||
/* Can normally not happen. */
|
||||
if (pMatch > &Address_Cache[MAX_ADDRESS_CACHE - 1]) {
|
||||
/* Issue with the table. */
|
||||
/* Issue with the table. */
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ uint16_t npdu_network_number(void)
|
||||
*/
|
||||
void npdu_network_number_set(uint16_t net)
|
||||
{
|
||||
Local_Network_Number = net;
|
||||
Local_Network_Number = net;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,8 +69,8 @@ void npdu_network_number_set(uint16_t net)
|
||||
* @param status - 0=learned, 1=assigned
|
||||
* @return number of bytes sent
|
||||
*/
|
||||
int npdu_send_network_number_is(BACNET_ADDRESS *dst,
|
||||
uint16_t net, uint8_t status)
|
||||
int npdu_send_network_number_is(
|
||||
BACNET_ADDRESS *dst, uint16_t net, uint8_t status)
|
||||
{
|
||||
uint16_t len = 0;
|
||||
int pdu_len = 0;
|
||||
@@ -84,13 +84,11 @@ int npdu_send_network_number_is(BACNET_ADDRESS *dst,
|
||||
transmit a local broadcast Network-Number-Is message
|
||||
back to the source device. */
|
||||
datalink_get_my_address(&my_address);
|
||||
npdu_encode_npdu_network(&npdu_data,
|
||||
NETWORK_MESSAGE_NETWORK_NUMBER_IS,
|
||||
npdu_encode_npdu_network(&npdu_data, NETWORK_MESSAGE_NETWORK_NUMBER_IS,
|
||||
data_expecting_reply, MESSAGE_PRIORITY_NORMAL);
|
||||
pdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], dst,
|
||||
&my_address, &npdu_data);
|
||||
len = encode_unsigned16(
|
||||
&Handler_Transmit_Buffer[pdu_len], net);
|
||||
pdu_len = npdu_encode_pdu(
|
||||
&Handler_Transmit_Buffer[0], dst, &my_address, &npdu_data);
|
||||
len = encode_unsigned16(&Handler_Transmit_Buffer[pdu_len], net);
|
||||
pdu_len += len;
|
||||
Handler_Transmit_Buffer[pdu_len] = status;
|
||||
pdu_len++;
|
||||
@@ -120,17 +118,14 @@ int npdu_send_what_is_network_number(BACNET_ADDRESS *dst)
|
||||
datalink_get_broadcast_address(&daddr);
|
||||
}
|
||||
datalink_get_my_address(&saddr);
|
||||
npdu_encode_npdu_network(&npdu_data,
|
||||
NETWORK_MESSAGE_WHAT_IS_NETWORK_NUMBER,
|
||||
npdu_encode_npdu_network(&npdu_data, NETWORK_MESSAGE_WHAT_IS_NETWORK_NUMBER,
|
||||
data_expecting_reply, MESSAGE_PRIORITY_NORMAL);
|
||||
pdu_len = npdu_encode_pdu(
|
||||
&Handler_Transmit_Buffer[0],
|
||||
&daddr, &saddr, &npdu_data);
|
||||
&Handler_Transmit_Buffer[0], &daddr, &saddr, &npdu_data);
|
||||
|
||||
/* Now send the message */
|
||||
return datalink_send_pdu(
|
||||
dst, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
|
||||
}
|
||||
|
||||
/** @file h_npdu.c Handles messages at the NPDU level of the BACnet stack. */
|
||||
@@ -163,8 +158,8 @@ static void network_control_handler(BACNET_ADDRESS *src,
|
||||
case NETWORK_MESSAGE_WHAT_IS_NETWORK_NUMBER:
|
||||
if (src->net == 0) {
|
||||
if (Local_Network_Number) {
|
||||
npdu_send_network_number_is(src, Local_Network_Number,
|
||||
Local_Network_Number_Status);
|
||||
npdu_send_network_number_is(
|
||||
src, Local_Network_Number, Local_Network_Number_Status);
|
||||
} else {
|
||||
/* Upon receipt of a What-Is-Network-Number message,
|
||||
a device that does not know the local network number
|
||||
@@ -225,9 +220,7 @@ static void network_control_handler(BACNET_ADDRESS *src,
|
||||
* @param pdu [in] Buffer containing the NPDU and APDU of the received packet.
|
||||
* @param pdu_len [in] The size of the received message in the pdu[] buffer.
|
||||
*/
|
||||
void npdu_handler(BACNET_ADDRESS *src,
|
||||
uint8_t *pdu,
|
||||
uint16_t pdu_len)
|
||||
void npdu_handler(BACNET_ADDRESS *src, uint8_t *pdu, uint16_t pdu_len)
|
||||
{
|
||||
int apdu_offset = 0;
|
||||
BACNET_ADDRESS dest = { 0 };
|
||||
@@ -243,8 +236,8 @@ void npdu_handler(BACNET_ADDRESS *src,
|
||||
bacnet_npdu_decode(&pdu[0], pdu_len, &dest, src, &npdu_data);
|
||||
if (npdu_data.network_layer_message) {
|
||||
if ((dest.net == 0) || (dest.net == BACNET_BROADCAST_NETWORK)) {
|
||||
network_control_handler(src, &npdu_data,
|
||||
&pdu[apdu_offset], (uint16_t)(pdu_len - apdu_offset));
|
||||
network_control_handler(src, &npdu_data, &pdu[apdu_offset],
|
||||
(uint16_t)(pdu_len - apdu_offset));
|
||||
} else {
|
||||
debug_printf("NPDU: message for router. Discarded!\n");
|
||||
}
|
||||
|
||||
@@ -317,6 +317,5 @@ void Send_Network_Number_Is(BACNET_ADDRESS *dst, int dnet, int status)
|
||||
iArgs[0] = dnet;
|
||||
iArgs[1] = status;
|
||||
|
||||
Send_Network_Layer_Message(
|
||||
NETWORK_MESSAGE_NETWORK_NUMBER_IS, dst, iArgs);
|
||||
Send_Network_Layer_Message(NETWORK_MESSAGE_NETWORK_NUMBER_IS, dst, iArgs);
|
||||
}
|
||||
|
||||
@@ -69,13 +69,13 @@ void Accumulator_Property_Lists(
|
||||
{
|
||||
if (pRequired) {
|
||||
*pRequired = Properties_Required;
|
||||
}
|
||||
}
|
||||
if (pOptional) {
|
||||
*pOptional = Properties_Optional;
|
||||
}
|
||||
}
|
||||
if (pProprietary) {
|
||||
*pProprietary = Properties_Proprietary;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -91,7 +91,7 @@ bool Accumulator_Valid_Instance(uint32_t object_instance)
|
||||
{
|
||||
if (object_instance < MAX_ACCUMULATORS) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -134,7 +134,7 @@ unsigned Accumulator_Instance_To_Index(uint32_t object_instance)
|
||||
|
||||
if (object_instance < MAX_ACCUMULATORS) {
|
||||
index = object_instance;
|
||||
}
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
@@ -342,8 +342,8 @@ bool Access_Credential_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
Access_Credential_Instance_To_Index(wp_data->object_instance);
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_GLOBAL_IDENTIFIER:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
ac_descr[object_index].global_identifier =
|
||||
value.type.Unsigned_Int;
|
||||
|
||||
@@ -462,8 +462,8 @@ bool Access_Door_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
object_index = Access_Door_Instance_To_Index(wp_data->object_instance);
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_PRESENT_VALUE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
if (status) {
|
||||
/* Command priority 6 is reserved for use by Minimum On/Off
|
||||
algorithm and may not be used for other purposes in any
|
||||
@@ -482,8 +482,8 @@ bool Access_Door_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
}
|
||||
} else {
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_NULL);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_NULL);
|
||||
if (status) {
|
||||
status = Access_Door_Present_Value_Relinquish(
|
||||
wp_data->object_instance, wp_data->priority);
|
||||
@@ -495,8 +495,8 @@ bool Access_Door_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
Access_Door_Out_Of_Service_Set(
|
||||
wp_data->object_instance, value.type.Boolean);
|
||||
@@ -504,8 +504,8 @@ bool Access_Door_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
case PROP_DOOR_STATUS:
|
||||
if (Access_Door_Out_Of_Service(wp_data->object_instance)) {
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
if (status) {
|
||||
ad_descr[object_index].door_status =
|
||||
(BACNET_DOOR_STATUS)value.type.Enumerated;
|
||||
@@ -517,8 +517,8 @@ bool Access_Door_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
case PROP_LOCK_STATUS:
|
||||
if (Access_Door_Out_Of_Service(wp_data->object_instance)) {
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
if (status) {
|
||||
ad_descr[object_index].lock_status =
|
||||
(BACNET_LOCK_STATUS)value.type.Enumerated;
|
||||
@@ -530,8 +530,8 @@ bool Access_Door_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
case PROP_DOOR_ALARM_STATE:
|
||||
if (Access_Door_Out_Of_Service(wp_data->object_instance)) {
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
if (status) {
|
||||
ad_descr[object_index].door_alarm_state =
|
||||
(BACNET_DOOR_ALARM_STATE)value.type.Enumerated;
|
||||
|
||||
@@ -308,8 +308,8 @@ bool Access_Rights_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
object_index = Access_Rights_Instance_To_Index(wp_data->object_instance);
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_GLOBAL_IDENTIFIER:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
ar_descr[object_index].global_identifier =
|
||||
value.type.Unsigned_Int;
|
||||
|
||||
@@ -250,8 +250,8 @@ bool Access_User_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
object_index = Access_User_Instance_To_Index(wp_data->object_instance);
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_GLOBAL_IDENTIFIER:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
au_descr[object_index].global_identifier =
|
||||
value.type.Unsigned_Int;
|
||||
@@ -276,4 +276,3 @@ bool Access_User_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
@@ -301,8 +301,8 @@ bool Access_Zone_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
object_index = Access_Zone_Instance_To_Index(wp_data->object_instance);
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_GLOBAL_IDENTIFIER:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
az_descr[object_index].global_identifier =
|
||||
value.type.Unsigned_Int;
|
||||
@@ -310,8 +310,8 @@ bool Access_Zone_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
case PROP_RELIABILITY:
|
||||
if (Access_Zone_Out_Of_Service(wp_data->object_instance)) {
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
if (status) {
|
||||
az_descr[object_index].reliability =
|
||||
(BACNET_RELIABILITY)value.type.Enumerated;
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
|
||||
#if PRINT_ENABLED
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) fprintf(stderr,__VA_ARGS__)
|
||||
#define PRINTF(...) fprintf(stderr, __VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#endif
|
||||
@@ -300,8 +300,8 @@ bool Analog_Input_Encode_Value_List(
|
||||
}
|
||||
out_of_service = AI_Descr[index].Out_Of_Service;
|
||||
present_value = AI_Descr[index].Present_Value;
|
||||
status = cov_value_list_encode_real(value_list, present_value,
|
||||
in_alarm, fault, overridden, out_of_service);
|
||||
status = cov_value_list_encode_real(value_list, present_value, in_alarm,
|
||||
fault, overridden, out_of_service);
|
||||
}
|
||||
|
||||
return status;
|
||||
@@ -420,7 +420,7 @@ int Analog_Input_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
bitstring_init(&bit_string);
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_IN_ALARM,
|
||||
Analog_Input_Event_State(rpdata->object_instance) !=
|
||||
EVENT_STATE_NORMAL);
|
||||
EVENT_STATE_NORMAL);
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_FAULT, false);
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_OVERRIDDEN, false);
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_OUT_OF_SERVICE,
|
||||
@@ -430,9 +430,8 @@ int Analog_Input_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
break;
|
||||
|
||||
case PROP_EVENT_STATE:
|
||||
apdu_len =
|
||||
encode_application_enumerated(&apdu[0],
|
||||
Analog_Input_Event_State(rpdata->object_instance));
|
||||
apdu_len = encode_application_enumerated(
|
||||
&apdu[0], Analog_Input_Event_State(rpdata->object_instance));
|
||||
break;
|
||||
|
||||
case PROP_RELIABILITY:
|
||||
@@ -633,8 +632,8 @@ bool Analog_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
|
||||
switch ((int)wp_data->object_property) {
|
||||
case PROP_PRESENT_VALUE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_REAL);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_REAL);
|
||||
if (status) {
|
||||
if (CurrentAI->Out_Of_Service == true) {
|
||||
Analog_Input_Present_Value_Set(
|
||||
@@ -648,8 +647,8 @@ bool Analog_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
Analog_Input_Out_Of_Service_Set(
|
||||
wp_data->object_instance, value.type.Boolean);
|
||||
@@ -657,16 +656,16 @@ bool Analog_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_UNITS:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
if (status) {
|
||||
CurrentAI->Units = value.type.Enumerated;
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_COV_INCREMENT:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_REAL);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_REAL);
|
||||
if (status) {
|
||||
if (value.type.Real >= 0.0) {
|
||||
Analog_Input_COV_Increment_Set(
|
||||
@@ -681,8 +680,8 @@ bool Analog_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
|
||||
#if defined(INTRINSIC_REPORTING)
|
||||
case PROP_TIME_DELAY:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
CurrentAI->Time_Delay = value.type.Unsigned_Int;
|
||||
CurrentAI->Remaining_Time_Delay = CurrentAI->Time_Delay;
|
||||
@@ -690,40 +689,40 @@ bool Analog_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_NOTIFICATION_CLASS:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
CurrentAI->Notification_Class = value.type.Unsigned_Int;
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_HIGH_LIMIT:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_REAL);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_REAL);
|
||||
if (status) {
|
||||
CurrentAI->High_Limit = value.type.Real;
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_LOW_LIMIT:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_REAL);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_REAL);
|
||||
if (status) {
|
||||
CurrentAI->Low_Limit = value.type.Real;
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_DEADBAND:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_REAL);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_REAL);
|
||||
if (status) {
|
||||
CurrentAI->Deadband = value.type.Real;
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_LIMIT_ENABLE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BIT_STRING);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BIT_STRING);
|
||||
if (status) {
|
||||
if (value.type.Bit_String.bits_used == 2) {
|
||||
CurrentAI->Limit_Enable = value.type.Bit_String.value[0];
|
||||
@@ -736,8 +735,8 @@ bool Analog_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_EVENT_ENABLE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BIT_STRING);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BIT_STRING);
|
||||
if (status) {
|
||||
if (value.type.Bit_String.bits_used == 3) {
|
||||
CurrentAI->Event_Enable = value.type.Bit_String.value[0];
|
||||
@@ -750,8 +749,8 @@ bool Analog_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_NOTIFY_TYPE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
if (status) {
|
||||
switch ((BACNET_NOTIFY_TYPE)value.type.Enumerated) {
|
||||
case NOTIFY_EVENT:
|
||||
@@ -968,8 +967,7 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
|
||||
break;
|
||||
} /* switch (ToState) */
|
||||
PRINTF("Analog-Input[%d]: Event_State goes from %s to %s.\n",
|
||||
object_instance,
|
||||
bactext_event_state_name(FromState),
|
||||
object_instance, bactext_event_state_name(FromState),
|
||||
bactext_event_state_name(ToState));
|
||||
/* Notify Type */
|
||||
event_data.notifyType = CurrentAI->Notify_Type;
|
||||
@@ -1014,18 +1012,15 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
|
||||
switch (ToState) {
|
||||
case EVENT_STATE_HIGH_LIMIT:
|
||||
case EVENT_STATE_LOW_LIMIT:
|
||||
datetime_copy(
|
||||
&event_data.timeStamp.value.dateTime,
|
||||
datetime_copy(&event_data.timeStamp.value.dateTime,
|
||||
&CurrentAI->Event_Time_Stamps[TRANSITION_TO_OFFNORMAL]);
|
||||
break;
|
||||
case EVENT_STATE_FAULT:
|
||||
datetime_copy(
|
||||
&event_data.timeStamp.value.dateTime,
|
||||
datetime_copy(&event_data.timeStamp.value.dateTime,
|
||||
&CurrentAI->Event_Time_Stamps[TRANSITION_TO_FAULT]);
|
||||
break;
|
||||
case EVENT_STATE_NORMAL:
|
||||
datetime_copy(
|
||||
&event_data.timeStamp.value.dateTime,
|
||||
datetime_copy(&event_data.timeStamp.value.dateTime,
|
||||
&CurrentAI->Event_Time_Stamps[TRANSITION_TO_NORMAL]);
|
||||
break;
|
||||
default:
|
||||
@@ -1083,16 +1078,16 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
|
||||
|
||||
/* add data from notification class */
|
||||
PRINTF("Analog-Input[%d]: Notification Class[%d]-%s "
|
||||
"%u/%u/%u-%u:%u:%u.%u!\n",
|
||||
object_instance, event_data.notificationClass,
|
||||
bactext_event_type_name(event_data.eventType),
|
||||
(unsigned)event_data.timeStamp.value.dateTime.date.year,
|
||||
(unsigned)event_data.timeStamp.value.dateTime.date.month,
|
||||
(unsigned)event_data.timeStamp.value.dateTime.date.day,
|
||||
(unsigned)event_data.timeStamp.value.dateTime.time.hour,
|
||||
(unsigned)event_data.timeStamp.value.dateTime.time.min,
|
||||
(unsigned)event_data.timeStamp.value.dateTime.time.sec,
|
||||
(unsigned)event_data.timeStamp.value.dateTime.time.hundredths);
|
||||
"%u/%u/%u-%u:%u:%u.%u!\n",
|
||||
object_instance, event_data.notificationClass,
|
||||
bactext_event_type_name(event_data.eventType),
|
||||
(unsigned)event_data.timeStamp.value.dateTime.date.year,
|
||||
(unsigned)event_data.timeStamp.value.dateTime.date.month,
|
||||
(unsigned)event_data.timeStamp.value.dateTime.date.day,
|
||||
(unsigned)event_data.timeStamp.value.dateTime.time.hour,
|
||||
(unsigned)event_data.timeStamp.value.dateTime.time.min,
|
||||
(unsigned)event_data.timeStamp.value.dateTime.time.sec,
|
||||
(unsigned)event_data.timeStamp.value.dateTime.time.hundredths);
|
||||
Notification_Class_common_reporting_function(&event_data);
|
||||
|
||||
/* Ack required */
|
||||
|
||||
@@ -367,7 +367,7 @@ int Analog_Output_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
} else {
|
||||
real_value =
|
||||
(float)Analog_Output_Level[object_index]
|
||||
[rpdata->array_index - 1];
|
||||
[rpdata->array_index - 1];
|
||||
apdu_len =
|
||||
encode_application_real(&apdu[0], real_value);
|
||||
}
|
||||
@@ -425,8 +425,8 @@ bool Analog_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_PRESENT_VALUE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_REAL);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_REAL);
|
||||
if (status) {
|
||||
/* Command priority 6 is reserved for use by Minimum On/Off
|
||||
algorithm and may not be used for other purposes in any
|
||||
@@ -445,8 +445,8 @@ bool Analog_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
}
|
||||
} else {
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_NULL);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_NULL);
|
||||
if (status) {
|
||||
status = Analog_Output_Present_Value_Relinquish(
|
||||
wp_data->object_instance, wp_data->priority);
|
||||
@@ -458,8 +458,8 @@ bool Analog_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
Analog_Output_Out_Of_Service_Set(
|
||||
wp_data->object_instance, value.type.Boolean);
|
||||
|
||||
@@ -382,8 +382,8 @@ bool Analog_Value_Encode_Value_List(
|
||||
bitstring_set_bit(&value_list->value.type.Bit_String,
|
||||
STATUS_FLAG_IN_ALARM, false);
|
||||
} else {
|
||||
bitstring_set_bit(&value_list->value.type.Bit_String,
|
||||
STATUS_FLAG_IN_ALARM, true);
|
||||
bitstring_set_bit(
|
||||
&value_list->value.type.Bit_String, STATUS_FLAG_IN_ALARM, true);
|
||||
}
|
||||
bitstring_set_bit(
|
||||
&value_list->value.type.Bit_String, STATUS_FLAG_FAULT, false);
|
||||
@@ -526,7 +526,7 @@ int Analog_Value_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
bitstring_init(&bit_string);
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_IN_ALARM,
|
||||
Analog_Value_Event_State(rpdata->object_instance) !=
|
||||
EVENT_STATE_NORMAL);
|
||||
EVENT_STATE_NORMAL);
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_FAULT, false);
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_OVERRIDDEN, false);
|
||||
bitstring_set_bit(&bit_string, STATUS_FLAG_OUT_OF_SERVICE,
|
||||
@@ -745,8 +745,8 @@ bool Analog_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_PRESENT_VALUE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_REAL);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_REAL);
|
||||
if (status) {
|
||||
/* Command priority 6 is reserved for use by Minimum On/Off
|
||||
algorithm and may not be used for other purposes in any
|
||||
@@ -772,24 +772,24 @@ bool Analog_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
CurrentAV->Out_Of_Service = value.type.Boolean;
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_UNITS:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
if (status) {
|
||||
CurrentAV->Units = value.type.Enumerated;
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_COV_INCREMENT:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_REAL);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_REAL);
|
||||
if (status) {
|
||||
if (value.type.Real >= 0.0) {
|
||||
Analog_Value_COV_Increment_Set(
|
||||
@@ -804,8 +804,8 @@ bool Analog_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
|
||||
#if defined(INTRINSIC_REPORTING)
|
||||
case PROP_TIME_DELAY:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
CurrentAV->Time_Delay = value.type.Unsigned_Int;
|
||||
CurrentAV->Remaining_Time_Delay = CurrentAV->Time_Delay;
|
||||
@@ -813,40 +813,40 @@ bool Analog_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_NOTIFICATION_CLASS:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
CurrentAV->Notification_Class = value.type.Unsigned_Int;
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_HIGH_LIMIT:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_REAL);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_REAL);
|
||||
if (status) {
|
||||
CurrentAV->High_Limit = value.type.Real;
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_LOW_LIMIT:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_REAL);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_REAL);
|
||||
if (status) {
|
||||
CurrentAV->Low_Limit = value.type.Real;
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_DEADBAND:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_REAL);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_REAL);
|
||||
if (status) {
|
||||
CurrentAV->Deadband = value.type.Real;
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_LIMIT_ENABLE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BIT_STRING);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BIT_STRING);
|
||||
if (status) {
|
||||
if (value.type.Bit_String.bits_used == 2) {
|
||||
CurrentAV->Limit_Enable = value.type.Bit_String.value[0];
|
||||
@@ -859,8 +859,8 @@ bool Analog_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_EVENT_ENABLE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BIT_STRING);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BIT_STRING);
|
||||
if (status) {
|
||||
if (value.type.Bit_String.bits_used == 3) {
|
||||
CurrentAV->Event_Enable = value.type.Bit_String.value[0];
|
||||
@@ -873,8 +873,8 @@ bool Analog_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_NOTIFY_TYPE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
if (status) {
|
||||
switch ((BACNET_NOTIFY_TYPE)value.type.Enumerated) {
|
||||
case NOTIFY_EVENT:
|
||||
@@ -1097,8 +1097,7 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "Event_State for (%s,%u) goes from %s to %s.\n",
|
||||
bactext_object_type_name(OBJECT_ANALOG_VALUE),
|
||||
(unsigned)object_instance,
|
||||
bactext_event_state_name(FromState),
|
||||
(unsigned)object_instance, bactext_event_state_name(FromState),
|
||||
bactext_event_state_name(ToState));
|
||||
#endif /* PRINT_ENABLED */
|
||||
|
||||
|
||||
@@ -309,8 +309,8 @@ bool bacfile_write_property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
property shall be logical TRUE only if no changes have been
|
||||
made to the file data by internal processes or through File
|
||||
Access Services since the last time the object was archived. */
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
if (value.type.Boolean) {
|
||||
/* FIXME: do something to wp_data->object_instance */
|
||||
@@ -323,8 +323,8 @@ bool bacfile_write_property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
/* If the file size can be changed by writing to the file,
|
||||
and File_Access_Method is STREAM_ACCESS, then this property
|
||||
shall be writable. */
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
/* FIXME: do something with value.type.Unsigned
|
||||
to wp_data->object_instance */
|
||||
|
||||
@@ -429,8 +429,8 @@ bool Binary_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_PRESENT_VALUE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
if (status) {
|
||||
if (value.type.Enumerated <= MAX_BINARY_PV) {
|
||||
Binary_Input_Present_Value_Set(wp_data->object_instance,
|
||||
@@ -443,16 +443,16 @@ bool Binary_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
Binary_Input_Out_Of_Service_Set(
|
||||
wp_data->object_instance, value.type.Boolean);
|
||||
}
|
||||
break;
|
||||
case PROP_POLARITY:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
if (status) {
|
||||
if (value.type.Enumerated < MAX_POLARITY) {
|
||||
Binary_Input_Polarity_Set(wp_data->object_instance,
|
||||
|
||||
@@ -363,8 +363,8 @@ bool Binary_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_PRESENT_VALUE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
if (status) {
|
||||
priority = wp_data->priority;
|
||||
/* Command priority 6 is reserved for use by Minimum On/Off
|
||||
@@ -396,8 +396,8 @@ bool Binary_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
}
|
||||
} else {
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_NULL);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_NULL);
|
||||
if (status) {
|
||||
level = BINARY_NULL;
|
||||
object_index = Binary_Output_Instance_To_Index(
|
||||
@@ -422,8 +422,8 @@ bool Binary_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
object_index =
|
||||
Binary_Output_Instance_To_Index(wp_data->object_instance);
|
||||
|
||||
@@ -457,8 +457,8 @@ bool Binary_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_PRESENT_VALUE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
if (status) {
|
||||
priority = wp_data->priority;
|
||||
/* Command priority 6 is reserved for use by Minimum On/Off
|
||||
@@ -488,8 +488,8 @@ bool Binary_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
}
|
||||
} else {
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_NULL);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_NULL);
|
||||
if (status) {
|
||||
level = BINARY_NULL;
|
||||
priority = wp_data->priority;
|
||||
@@ -512,8 +512,8 @@ bool Binary_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
Binary_Value_Out_Of_Service_Set(
|
||||
wp_data->object_instance, value.type.Boolean);
|
||||
|
||||
@@ -1513,8 +1513,8 @@ bool Channel_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
status = Channel_Present_Value_Set(wp_data, &value);
|
||||
break;
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
Channel_Out_Of_Service_Set(
|
||||
wp_data->object_instance, value.type.Boolean);
|
||||
@@ -1531,16 +1531,16 @@ bool Channel_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
ERROR_CODE_OPTIONAL_FUNCTIONALITY_NOT_SUPPORTED;
|
||||
break;
|
||||
case PROP_CHANNEL_NUMBER:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
Channel_Number_Set(
|
||||
wp_data->object_instance, value.type.Unsigned_Int);
|
||||
}
|
||||
break;
|
||||
case PROP_CONTROL_GROUPS:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
if (wp_data->array_index == 0) {
|
||||
/* Array element zero is the number of elements in the array
|
||||
|
||||
@@ -833,70 +833,57 @@ int Color_Temperature_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
encode_application_enumerated(&apdu[0], rpdata->object_type);
|
||||
break;
|
||||
case PROP_PRESENT_VALUE:
|
||||
apdu_len =
|
||||
encode_application_unsigned(apdu,
|
||||
Color_Temperature_Present_Value(
|
||||
rpdata->object_instance));
|
||||
apdu_len = encode_application_unsigned(
|
||||
apdu, Color_Temperature_Present_Value(rpdata->object_instance));
|
||||
break;
|
||||
case PROP_MIN_PRES_VALUE:
|
||||
apdu_len =
|
||||
encode_application_unsigned(apdu,
|
||||
Color_Temperature_Min_Pres_Value(
|
||||
rpdata->object_instance));
|
||||
apdu_len = encode_application_unsigned(apdu,
|
||||
Color_Temperature_Min_Pres_Value(rpdata->object_instance));
|
||||
break;
|
||||
case PROP_MAX_PRES_VALUE:
|
||||
apdu_len =
|
||||
encode_application_unsigned(apdu,
|
||||
Color_Temperature_Max_Pres_Value(
|
||||
rpdata->object_instance));
|
||||
apdu_len = encode_application_unsigned(apdu,
|
||||
Color_Temperature_Max_Pres_Value(rpdata->object_instance));
|
||||
break;
|
||||
case PROP_TRACKING_VALUE:
|
||||
apdu_len =
|
||||
encode_application_unsigned(apdu,
|
||||
Color_Temperature_Tracking_Value(
|
||||
rpdata->object_instance));
|
||||
apdu_len = encode_application_unsigned(apdu,
|
||||
Color_Temperature_Tracking_Value(rpdata->object_instance));
|
||||
break;
|
||||
case PROP_COLOR_COMMAND:
|
||||
if (Color_Temperature_Command(rpdata->object_instance, &color_command)) {
|
||||
if (Color_Temperature_Command(
|
||||
rpdata->object_instance, &color_command)) {
|
||||
apdu_len = color_command_encode(apdu, &color_command);
|
||||
}
|
||||
break;
|
||||
case PROP_IN_PROGRESS:
|
||||
apdu_len =
|
||||
encode_application_enumerated(apdu,
|
||||
Color_Temperature_In_Progress(rpdata->object_instance));
|
||||
apdu_len = encode_application_enumerated(
|
||||
apdu, Color_Temperature_In_Progress(rpdata->object_instance));
|
||||
break;
|
||||
case PROP_DEFAULT_COLOR_TEMPERATURE:
|
||||
apdu_len =
|
||||
encode_application_unsigned(apdu,
|
||||
apdu_len = encode_application_unsigned(apdu,
|
||||
Color_Temperature_Default_Color_Temperature(
|
||||
rpdata->object_instance));
|
||||
break;
|
||||
case PROP_DEFAULT_FADE_TIME:
|
||||
apdu_len =
|
||||
encode_application_unsigned(apdu,
|
||||
apdu_len = encode_application_unsigned(apdu,
|
||||
Color_Temperature_Default_Fade_Time(rpdata->object_instance));
|
||||
break;
|
||||
case PROP_DEFAULT_RAMP_RATE:
|
||||
apdu_len =
|
||||
encode_application_unsigned(apdu,
|
||||
apdu_len = encode_application_unsigned(apdu,
|
||||
Color_Temperature_Default_Ramp_Rate(rpdata->object_instance));
|
||||
break;
|
||||
case PROP_DEFAULT_STEP_INCREMENT:
|
||||
apdu_len =
|
||||
encode_application_unsigned(apdu,
|
||||
Color_Temperature_Default_Step_Increment(rpdata->object_instance));
|
||||
apdu_len = encode_application_unsigned(apdu,
|
||||
Color_Temperature_Default_Step_Increment(
|
||||
rpdata->object_instance));
|
||||
break;
|
||||
case PROP_TRANSITION:
|
||||
apdu_len =
|
||||
encode_application_enumerated(apdu,
|
||||
Color_Temperature_Transition(rpdata->object_instance));
|
||||
apdu_len = encode_application_enumerated(
|
||||
apdu, Color_Temperature_Transition(rpdata->object_instance));
|
||||
break;
|
||||
case PROP_DESCRIPTION:
|
||||
characterstring_init_ansi(
|
||||
&char_string, Color_Temperature_Description(rpdata->object_instance));
|
||||
apdu_len =
|
||||
encode_application_character_string(apdu, &char_string);
|
||||
characterstring_init_ansi(&char_string,
|
||||
Color_Temperature_Description(rpdata->object_instance));
|
||||
apdu_len = encode_application_character_string(apdu, &char_string);
|
||||
break;
|
||||
default:
|
||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||
|
||||
@@ -195,8 +195,7 @@ int cl_decode_apdu(uint8_t *apdu,
|
||||
if (tag_number != 2) {
|
||||
return BACNET_STATUS_REJECT;
|
||||
}
|
||||
len = decode_enumerated(
|
||||
&apdu[dec_len], len_value_type, &enum_value);
|
||||
len = decode_enumerated(&apdu[dec_len], len_value_type, &enum_value);
|
||||
if (len < 0) {
|
||||
return BACNET_STATUS_REJECT;
|
||||
}
|
||||
@@ -783,8 +782,8 @@ bool Command_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
|
||||
switch ((int)wp_data->object_property) {
|
||||
case PROP_PRESENT_VALUE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
if (value.type.Unsigned_Int >= MAX_COMMAND_ACTIONS) {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
|
||||
@@ -333,8 +333,8 @@ bool Credential_Data_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
case PROP_RELIABILITY:
|
||||
if (Credential_Data_Input_Out_Of_Service(
|
||||
wp_data->object_instance)) {
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
if (status) {
|
||||
cdi_descr[object_index].reliability =
|
||||
(BACNET_RELIABILITY)value.type.Enumerated;
|
||||
|
||||
@@ -268,8 +268,7 @@ static void CharacterString_Value_Out_Of_Service_Set(
|
||||
* @param object_instance - object-instance number of the object
|
||||
* @return the COV change flag status
|
||||
*/
|
||||
bool CharacterString_Value_Change_Of_Value(
|
||||
uint32_t object_instance)
|
||||
bool CharacterString_Value_Change_Of_Value(uint32_t object_instance)
|
||||
{
|
||||
bool changed = false;
|
||||
unsigned index = 0; /* offset from instance lookup */
|
||||
@@ -286,8 +285,7 @@ bool CharacterString_Value_Change_Of_Value(
|
||||
* @brief Clear the COV change flag
|
||||
* @param object_instance - object-instance number of the object
|
||||
*/
|
||||
void CharacterString_Value_Change_Of_Value_Clear(
|
||||
uint32_t object_instance)
|
||||
void CharacterString_Value_Change_Of_Value_Clear(uint32_t object_instance)
|
||||
{
|
||||
unsigned index = 0; /* offset from instance lookup */
|
||||
|
||||
@@ -298,14 +296,14 @@ void CharacterString_Value_Change_Of_Value_Clear(
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief For a given object instance-number, loads the value_list with the COV data.
|
||||
* @brief For a given object instance-number, loads the value_list with the COV
|
||||
* data.
|
||||
* @param object_instance - object-instance number of the object
|
||||
* @param value_list - list of COV data
|
||||
* @return true if the value list is encoded
|
||||
*/
|
||||
bool CharacterString_Value_Encode_Value_List(
|
||||
uint32_t object_instance,
|
||||
BACNET_PROPERTY_VALUE * value_list)
|
||||
uint32_t object_instance, BACNET_PROPERTY_VALUE *value_list)
|
||||
{
|
||||
bool status = false;
|
||||
const bool in_alarm = false;
|
||||
@@ -589,8 +587,8 @@ bool CharacterString_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_PRESENT_VALUE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_CHARACTER_STRING);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_CHARACTER_STRING);
|
||||
if (status) {
|
||||
status = CharacterString_Value_Present_Value_Set(
|
||||
wp_data->object_instance, &value.type.Character_String);
|
||||
@@ -601,8 +599,8 @@ bool CharacterString_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
CharacterString_Value_Out_Of_Service_Set(
|
||||
wp_data->object_instance, value.type.Boolean);
|
||||
|
||||
@@ -228,12 +228,11 @@ static object_functions_t My_Object_Table[] = {
|
||||
NULL /* COV */, NULL /* COV Clear */, NULL /* Intrinsic Reporting */ },
|
||||
#endif
|
||||
#if (BACNET_PROTOCOL_REVISION >= 24)
|
||||
{ OBJECT_COLOR, Color_Init, Color_Count,
|
||||
Color_Index_To_Instance, Color_Valid_Instance,
|
||||
Color_Object_Name, Color_Read_Property,
|
||||
Color_Write_Property, Color_Property_Lists,
|
||||
NULL /* ReadRangeInfo */, NULL /* Iterator */, NULL /* Value_Lists */,
|
||||
NULL /* COV */, NULL /* COV Clear */, NULL /* Intrinsic Reporting */ },
|
||||
{ OBJECT_COLOR, Color_Init, Color_Count, Color_Index_To_Instance,
|
||||
Color_Valid_Instance, Color_Object_Name, Color_Read_Property,
|
||||
Color_Write_Property, Color_Property_Lists, NULL /* ReadRangeInfo */,
|
||||
NULL /* Iterator */, NULL /* Value_Lists */, NULL /* COV */,
|
||||
NULL /* COV Clear */, NULL /* Intrinsic Reporting */ },
|
||||
{ OBJECT_COLOR_TEMPERATURE, Color_Temperature_Init, Color_Temperature_Count,
|
||||
Color_Temperature_Index_To_Instance, Color_Temperature_Valid_Instance,
|
||||
Color_Temperature_Object_Name, Color_Temperature_Read_Property,
|
||||
@@ -1353,8 +1352,7 @@ static int Read_Property_Common(
|
||||
}
|
||||
apdu = rpdata->application_data;
|
||||
if (property_list_common(rpdata->object_property)) {
|
||||
apdu_len = property_list_common_encode(rpdata,
|
||||
Object_Instance_Number);
|
||||
apdu_len = property_list_common_encode(rpdata, Object_Instance_Number);
|
||||
} else if (rpdata->object_property == PROP_OBJECT_NAME) {
|
||||
/* only array properties can have array options */
|
||||
if (rpdata->array_index != BACNET_ARRAY_ALL) {
|
||||
@@ -1374,9 +1372,8 @@ static int Read_Property_Common(
|
||||
} else if (rpdata->object_property == PROP_PROPERTY_LIST) {
|
||||
Device_Objects_Property_List(
|
||||
rpdata->object_type, rpdata->object_instance, &property_list);
|
||||
apdu_len = property_list_encode(rpdata,
|
||||
property_list.Required.pList, property_list.Optional.pList,
|
||||
property_list.Proprietary.pList);
|
||||
apdu_len = property_list_encode(rpdata, property_list.Required.pList,
|
||||
property_list.Optional.pList, property_list.Proprietary.pList);
|
||||
#endif
|
||||
} else if (pObject->Object_Read_Property) {
|
||||
apdu_len = pObject->Object_Read_Property(rpdata);
|
||||
@@ -1451,8 +1448,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
/* FIXME: len < application_data_len: more data? */
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_OBJECT_IDENTIFIER:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_OBJECT_ID);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_OBJECT_ID);
|
||||
if (status) {
|
||||
if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
|
||||
(Device_Set_Object_Instance_Number(
|
||||
@@ -1467,32 +1464,32 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_NUMBER_OF_APDU_RETRIES:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
/* FIXME: bounds check? */
|
||||
apdu_retries_set((uint8_t)value.type.Unsigned_Int);
|
||||
}
|
||||
break;
|
||||
case PROP_APDU_TIMEOUT:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
/* FIXME: bounds check? */
|
||||
apdu_timeout_set((uint16_t)value.type.Unsigned_Int);
|
||||
}
|
||||
break;
|
||||
case PROP_VENDOR_IDENTIFIER:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
/* FIXME: bounds check? */
|
||||
Device_Set_Vendor_Identifier((uint16_t)value.type.Unsigned_Int);
|
||||
}
|
||||
break;
|
||||
case PROP_SYSTEM_STATUS:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
if (status) {
|
||||
result = Device_Set_System_Status(
|
||||
(BACNET_DEVICE_STATUS)value.type.Enumerated, false);
|
||||
@@ -1510,8 +1507,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_OBJECT_NAME:
|
||||
status = write_property_string_valid(wp_data, &value,
|
||||
characterstring_capacity(&My_Object_Name));
|
||||
status = write_property_string_valid(
|
||||
wp_data, &value, characterstring_capacity(&My_Object_Name));
|
||||
if (status) {
|
||||
/* All the object names in a device must be unique */
|
||||
if (Device_Valid_Object_Name(&value.type.Character_String,
|
||||
@@ -1531,8 +1528,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_LOCATION:
|
||||
status = write_property_empty_string_valid(wp_data, &value,
|
||||
MAX_DEV_LOC_LEN);
|
||||
status = write_property_empty_string_valid(
|
||||
wp_data, &value, MAX_DEV_LOC_LEN);
|
||||
if (status) {
|
||||
Device_Set_Location(
|
||||
characterstring_value(&value.type.Character_String),
|
||||
@@ -1541,8 +1538,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_DESCRIPTION:
|
||||
status = write_property_empty_string_valid(wp_data, &value,
|
||||
MAX_DEV_DESC_LEN);
|
||||
status = write_property_empty_string_valid(
|
||||
wp_data, &value, MAX_DEV_DESC_LEN);
|
||||
if (status) {
|
||||
Device_Set_Description(
|
||||
characterstring_value(&value.type.Character_String),
|
||||
@@ -1550,8 +1547,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_MODEL_NAME:
|
||||
status = write_property_empty_string_valid(wp_data, &value,
|
||||
MAX_DEV_MOD_LEN);
|
||||
status = write_property_empty_string_valid(
|
||||
wp_data, &value, MAX_DEV_MOD_LEN);
|
||||
if (status) {
|
||||
Device_Set_Model_Name(
|
||||
characterstring_value(&value.type.Character_String),
|
||||
@@ -1560,8 +1557,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
#if defined(BACNET_TIME_MASTER)
|
||||
case PROP_TIME_SYNCHRONIZATION_INTERVAL:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
if (value.type.Unsigned_Int < 65535) {
|
||||
minutes = value.type.Unsigned_Int;
|
||||
@@ -1574,16 +1571,16 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_ALIGN_INTERVALS:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
Device_Align_Intervals_Set(value.type.Boolean);
|
||||
status = true;
|
||||
}
|
||||
break;
|
||||
case PROP_INTERVAL_OFFSET:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
if (value.type.Unsigned_Int < 65535) {
|
||||
minutes = value.type.Unsigned_Int;
|
||||
@@ -1604,8 +1601,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
#endif
|
||||
case PROP_UTC_OFFSET:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_SIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_SIGNED_INT);
|
||||
if (status) {
|
||||
if ((value.type.Signed_Int < (12 * 60)) &&
|
||||
(value.type.Signed_Int > (-12 * 60))) {
|
||||
@@ -1619,8 +1616,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
#if defined(BACDL_MSTP)
|
||||
case PROP_MAX_INFO_FRAMES:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
if (value.type.Unsigned_Int <= 255) {
|
||||
dlmstp_set_max_info_frames(
|
||||
@@ -1633,8 +1630,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_MAX_MASTER:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
if ((value.type.Unsigned_Int > 0) &&
|
||||
(value.type.Unsigned_Int <= 127)) {
|
||||
|
||||
@@ -213,8 +213,7 @@ void routed_get_my_address(BACNET_ADDRESS *my_address)
|
||||
* meaning MAC broadcast, so it's an automatic match).
|
||||
* Else False if no match or invalid idx is given.
|
||||
*/
|
||||
bool Routed_Device_Address_Lookup(
|
||||
int idx, uint8_t dlen, uint8_t *dadr)
|
||||
bool Routed_Device_Address_Lookup(int idx, uint8_t dlen, uint8_t *dadr)
|
||||
{
|
||||
bool result = false;
|
||||
DEVICE_OBJECT_DATA *pDev = &Devices[idx];
|
||||
@@ -371,15 +370,12 @@ uint32_t Routed_Device_Index_To_Instance(unsigned index)
|
||||
* @param object_instance - object-instance number of the object
|
||||
* @return index for the given instance-number, or 0 if not valid.
|
||||
*/
|
||||
static uint32_t Routed_Device_Instance_To_Index(
|
||||
uint32_t Instance_Number)
|
||||
static uint32_t Routed_Device_Instance_To_Index(uint32_t Instance_Number)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for ( i=0; i < MAX_NUM_DEVICES; i++) {
|
||||
if (Devices[i].bacObj.Object_Instance_Number == Instance_Number)
|
||||
{
|
||||
for (i = 0; i < MAX_NUM_DEVICES; i++) {
|
||||
if (Devices[i].bacObj.Object_Instance_Number == Instance_Number) {
|
||||
/* Found Instance, so return the Device Index Number */
|
||||
return i;
|
||||
}
|
||||
@@ -388,7 +384,6 @@ static uint32_t Routed_Device_Instance_To_Index(
|
||||
/* We did not find instance... so simply return an Index of 0
|
||||
All gateways will have at least a single root Device Object */
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -492,8 +487,8 @@ bool Routed_Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
/* FIXME: len < application_data_len: more data? */
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_OBJECT_IDENTIFIER:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_OBJECT_ID);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_OBJECT_ID);
|
||||
if (status) {
|
||||
if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
|
||||
(Routed_Device_Set_Object_Instance_Number(
|
||||
@@ -508,8 +503,8 @@ bool Routed_Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_OBJECT_NAME:
|
||||
status = write_property_string_valid(wp_data, &value,
|
||||
MAX_DEV_NAME_LEN);
|
||||
status =
|
||||
write_property_string_valid(wp_data, &value, MAX_DEV_NAME_LEN);
|
||||
if (status) {
|
||||
Routed_Device_Set_Object_Name(
|
||||
characterstring_encoding(&value.type.Character_String),
|
||||
|
||||
@@ -431,16 +431,16 @@ bool Integer_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_PRESENT_VALUE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_SIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_SIGNED_INT);
|
||||
if (status) {
|
||||
Integer_Value_Present_Value_Set(wp_data->object_instance,
|
||||
value.type.Signed_Int, wp_data->priority);
|
||||
}
|
||||
break;
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
Integer_Value_Out_Of_Service_Set(
|
||||
wp_data->object_instance, value.type.Boolean);
|
||||
|
||||
@@ -880,7 +880,7 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
/* error while decoding - a smaller larger than we can handle */
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* decode the some of the request */
|
||||
@@ -909,7 +909,8 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
wp_data->application_data_len, &value,
|
||||
PROP_REQUESTED_SHED_LEVEL);
|
||||
if (len == BACNET_STATUS_ERROR) {
|
||||
PRINTF("Load_Control_Write_Property() failure detected point D\n");
|
||||
PRINTF(
|
||||
"Load_Control_Write_Property() failure detected point D\n");
|
||||
/* error! */
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_INVALID_DATA_TYPE;
|
||||
@@ -935,7 +936,8 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
value.type.Real;
|
||||
status = true;
|
||||
} else {
|
||||
PRINTF("Load_Control_Write_Property() failure detected point E\n");
|
||||
PRINTF(
|
||||
"Load_Control_Write_Property() failure detected point E\n");
|
||||
/* error! */
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_INVALID_DATA_TYPE;
|
||||
@@ -946,10 +948,11 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_START_TIME:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_DATE);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_DATE);
|
||||
if (!status) {
|
||||
PRINTF("Load_Control_Write_Property() failure detected point F\n");
|
||||
PRINTF(
|
||||
"Load_Control_Write_Property() failure detected point F\n");
|
||||
/* don't continue if we don't have a valid date */
|
||||
break;
|
||||
}
|
||||
@@ -959,8 +962,8 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
bacapp_decode_application_data(wp_data->application_data + len,
|
||||
wp_data->application_data_len - len, &value);
|
||||
if (len) {
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_TIME);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_TIME);
|
||||
if (status) {
|
||||
/* Write time and date and set written flag */
|
||||
Start_Time[object_index].date = start_date;
|
||||
@@ -968,7 +971,8 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
Start_Time_Property_Written[object_index] = true;
|
||||
}
|
||||
} else {
|
||||
PRINTF("Load_Control_Write_Property() failure detected point G\n");
|
||||
PRINTF(
|
||||
"Load_Control_Write_Property() failure detected point G\n");
|
||||
status = false;
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
@@ -976,19 +980,20 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_SHED_DURATION:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
Shed_Duration[object_index] = value.type.Unsigned_Int;
|
||||
Load_Control_Request_Written[object_index] = true;
|
||||
} else {
|
||||
PRINTF("Load_Control_Write_Property() failure detected point H\n");
|
||||
PRINTF(
|
||||
"Load_Control_Write_Property() failure detected point H\n");
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_DUTY_WINDOW:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
Duty_Window[object_index] = value.type.Unsigned_Int;
|
||||
Load_Control_Request_Written[object_index] = true;
|
||||
@@ -996,8 +1001,8 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_SHED_LEVELS:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
/* re-write the size of the array? */
|
||||
if (wp_data->array_index == 0) {
|
||||
@@ -1020,8 +1025,8 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_ENABLE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
Load_Control_Enable[object_index] = value.type.Boolean;
|
||||
}
|
||||
|
||||
@@ -1111,8 +1111,8 @@ bool Lighting_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_PRESENT_VALUE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_REAL);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_REAL);
|
||||
if (status) {
|
||||
/* Command priority 6 is reserved for use by Minimum On/Off
|
||||
algorithm and may not be used for other purposes in any
|
||||
@@ -1131,8 +1131,8 @@ bool Lighting_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
}
|
||||
} else {
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_NULL);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_NULL);
|
||||
if (status) {
|
||||
if (wp_data->priority == 6) {
|
||||
/* Command priority 6 is reserved for use by Minimum
|
||||
@@ -1154,8 +1154,8 @@ bool Lighting_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_LIGHTING_COMMAND:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_LIGHTING_COMMAND);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_LIGHTING_COMMAND);
|
||||
if (status) {
|
||||
status = Lighting_Output_Lighting_Command_Set(
|
||||
wp_data->object_instance, &value.type.Lighting_Command);
|
||||
@@ -1166,8 +1166,8 @@ bool Lighting_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
Lighting_Output_Out_Of_Service_Set(
|
||||
wp_data->object_instance, value.type.Boolean);
|
||||
|
||||
@@ -322,8 +322,8 @@ bool Life_Safety_Point_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_MODE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
if (status) {
|
||||
if (value.type.Enumerated <= MAX_LIFE_SAFETY_MODE) {
|
||||
object_index = Life_Safety_Point_Instance_To_Index(
|
||||
@@ -338,8 +338,8 @@ bool Life_Safety_Point_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
object_index = Life_Safety_Point_Instance_To_Index(
|
||||
wp_data->object_instance);
|
||||
|
||||
@@ -603,8 +603,8 @@ bool Multistate_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_OBJECT_NAME:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_CHARACTER_STRING);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_CHARACTER_STRING);
|
||||
if (status) {
|
||||
/* All the object names in a device must be unique */
|
||||
if (Device_Valid_Object_Name(&value.type.Character_String,
|
||||
@@ -626,8 +626,8 @@ bool Multistate_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_DESCRIPTION:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_CHARACTER_STRING);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_CHARACTER_STRING);
|
||||
if (status) {
|
||||
status = Multistate_Input_Description_Write(
|
||||
wp_data->object_instance, &value.type.Character_String,
|
||||
@@ -635,8 +635,8 @@ bool Multistate_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_PRESENT_VALUE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
status = Multistate_Input_Present_Value_Set(
|
||||
wp_data->object_instance, value.type.Unsigned_Int);
|
||||
@@ -647,8 +647,8 @@ bool Multistate_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
Multistate_Input_Out_Of_Service_Set(
|
||||
wp_data->object_instance, value.type.Boolean);
|
||||
@@ -675,8 +675,8 @@ bool Multistate_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
if (element_len) {
|
||||
status = Multistate_Input_State_Text_Write(
|
||||
wp_data->object_instance, array_index,
|
||||
&value.type.Character_String,
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
&value.type.Character_String, &wp_data->error_class,
|
||||
&wp_data->error_code);
|
||||
}
|
||||
max_states--;
|
||||
array_index++;
|
||||
@@ -686,8 +686,7 @@ bool Multistate_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
wp_data->application_data_len - len, &value);
|
||||
if (element_len < 0) {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code =
|
||||
ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
break;
|
||||
}
|
||||
len += element_len;
|
||||
|
||||
@@ -375,8 +375,8 @@ bool Multistate_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_PRESENT_VALUE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
priority = wp_data->priority;
|
||||
/* Command priority 6 is reserved for use by Minimum On/Off
|
||||
@@ -410,8 +410,8 @@ bool Multistate_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
}
|
||||
} else {
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_NULL);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_NULL);
|
||||
if (status) {
|
||||
level = MULTISTATE_NULL;
|
||||
object_index = Multistate_Output_Instance_To_Index(
|
||||
@@ -437,8 +437,8 @@ bool Multistate_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
Multistate_Output_Out_Of_Service_Set(
|
||||
wp_data->object_instance, value.type.Boolean);
|
||||
|
||||
@@ -538,8 +538,8 @@ bool Multistate_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_PRESENT_VALUE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
status = Multistate_Value_Present_Value_Set(
|
||||
wp_data->object_instance, value.type.Unsigned_Int);
|
||||
@@ -550,8 +550,8 @@ bool Multistate_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
Multistate_Value_Out_Of_Service_Set(
|
||||
wp_data->object_instance, value.type.Boolean);
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
|
||||
#if PRINT_ENABLED
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) fprintf(stderr,__VA_ARGS__)
|
||||
#define PRINTF(...) fprintf(stderr, __VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#endif
|
||||
@@ -101,25 +101,24 @@ void Notification_Class_Init(void)
|
||||
255; /* PRINTF lowest priority for Normal message. */
|
||||
/* configure for every day, all day long */
|
||||
for (i = 0; i < MAX_BACNET_DAYS_OF_WEEK; i++) {
|
||||
NC_Info[NotifyIdx].Recipient_List->ValidDays |= (1<<i);
|
||||
NC_Info[NotifyIdx].Recipient_List->ValidDays |= (1 << i);
|
||||
}
|
||||
NC_Info[NotifyIdx].Recipient_List->FromTime.hour = 0;
|
||||
NC_Info[NotifyIdx].Recipient_List->FromTime.min = 0;
|
||||
NC_Info[NotifyIdx].Recipient_List->FromTime.sec = 0;
|
||||
NC_Info[NotifyIdx].Recipient_List->FromTime.hundredths = 0;
|
||||
NC_Info[NotifyIdx].Recipient_List->ToTime.hour = 23;
|
||||
NC_Info[NotifyIdx].Recipient_List->ToTime.min = 59;
|
||||
NC_Info[NotifyIdx].Recipient_List->ToTime.sec = 59;
|
||||
NC_Info[NotifyIdx].Recipient_List->ToTime.hundredths = 0;
|
||||
NC_Info[NotifyIdx].Recipient_List->Transitions =
|
||||
TRANSITION_TO_OFFNORMAL_MASKED |
|
||||
TRANSITION_TO_FAULT_MASKED |
|
||||
NC_Info[NotifyIdx].Recipient_List->FromTime.hour = 0;
|
||||
NC_Info[NotifyIdx].Recipient_List->FromTime.min = 0;
|
||||
NC_Info[NotifyIdx].Recipient_List->FromTime.sec = 0;
|
||||
NC_Info[NotifyIdx].Recipient_List->FromTime.hundredths = 0;
|
||||
NC_Info[NotifyIdx].Recipient_List->ToTime.hour = 23;
|
||||
NC_Info[NotifyIdx].Recipient_List->ToTime.min = 59;
|
||||
NC_Info[NotifyIdx].Recipient_List->ToTime.sec = 59;
|
||||
NC_Info[NotifyIdx].Recipient_List->ToTime.hundredths = 0;
|
||||
NC_Info[NotifyIdx].Recipient_List->Transitions =
|
||||
TRANSITION_TO_OFFNORMAL_MASKED | TRANSITION_TO_FAULT_MASKED |
|
||||
TRANSITION_TO_NORMAL_MASKED;
|
||||
NC_Info[NotifyIdx].Recipient_List->ConfirmedNotify = false;
|
||||
NC_Info[NotifyIdx].Recipient_List->ConfirmedNotify = false;
|
||||
NC_Info[NotifyIdx].Recipient_List->Recipient.RecipientType =
|
||||
NC_Info[NotifyIdx].Recipient_List->ConfirmedNotify = false;
|
||||
NC_Info[NotifyIdx].Recipient_List->ConfirmedNotify = false;
|
||||
NC_Info[NotifyIdx].Recipient_List->Recipient.RecipientType =
|
||||
RECIPIENT_TYPE_DEVICE;
|
||||
NC_Info[NotifyIdx].Recipient_List->Recipient._.DeviceIdentifier =
|
||||
NC_Info[NotifyIdx].Recipient_List->Recipient._.DeviceIdentifier =
|
||||
4194303;
|
||||
}
|
||||
|
||||
@@ -418,8 +417,8 @@ bool Notification_Class_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_PRIORITY:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
if (wp_data->array_index == 0) {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
@@ -471,8 +470,8 @@ bool Notification_Class_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_ACK_REQUIRED:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BIT_STRING);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BIT_STRING);
|
||||
if (status) {
|
||||
if (value.type.Bit_String.bits_used == 3) {
|
||||
CurrentNotify->Ack_Required =
|
||||
|
||||
@@ -613,8 +613,8 @@ bool Network_Port_MAC_Address(
|
||||
memcpy(
|
||||
&ip_mac[0], &Object_List[index].Network.IPv4.IP_Address, 4);
|
||||
/* convert port from host-byte-order to network-byte-order */
|
||||
encode_unsigned16(&ip_mac[4],
|
||||
Object_List[index].Network.IPv4.Port);
|
||||
encode_unsigned16(
|
||||
&ip_mac[4], Object_List[index].Network.IPv4.Port);
|
||||
mac = &ip_mac[0];
|
||||
mac_len = sizeof(ip_mac);
|
||||
break;
|
||||
@@ -1326,9 +1326,7 @@ void *Network_Port_BBMD_BD_Table(uint32_t object_instance)
|
||||
* @return true if the Broadcast Distribution Table linked list head
|
||||
* property value was set
|
||||
*/
|
||||
bool Network_Port_BBMD_BD_Table_Set(
|
||||
uint32_t object_instance,
|
||||
void *bdt_head)
|
||||
bool Network_Port_BBMD_BD_Table_Set(uint32_t object_instance, void *bdt_head)
|
||||
{
|
||||
bool status = false;
|
||||
unsigned index = 0;
|
||||
@@ -1379,9 +1377,7 @@ void *Network_Port_BBMD_FD_Table(uint32_t object_instance)
|
||||
*
|
||||
* @return true if the BBMD-Accept-FD-Registrations property value was set
|
||||
*/
|
||||
bool Network_Port_BBMD_FD_Table_Set(
|
||||
uint32_t object_instance,
|
||||
void *fdt_head)
|
||||
bool Network_Port_BBMD_FD_Table_Set(uint32_t object_instance, void *fdt_head)
|
||||
{
|
||||
bool status = false;
|
||||
unsigned index = 0;
|
||||
@@ -1449,8 +1445,7 @@ static bool Network_Port_Remote_BBMD_IP_Address_And_Port(
|
||||
* @return true if ip-address was retrieved
|
||||
*/
|
||||
bool Network_Port_Remote_BBMD_IP_Address(
|
||||
uint32_t object_instance,
|
||||
uint8_t *a, uint8_t *b, uint8_t *c, uint8_t *d)
|
||||
uint32_t object_instance, uint8_t *a, uint8_t *b, uint8_t *c, uint8_t *d)
|
||||
{
|
||||
unsigned index = 0; /* offset from instance lookup */
|
||||
bool status = false;
|
||||
@@ -1539,8 +1534,8 @@ uint16_t Network_Port_Remote_BBMD_BIP_Port(uint32_t object_instance)
|
||||
*
|
||||
* @return true if values are within range and property is set.
|
||||
*/
|
||||
bool Network_Port_Remote_BBMD_BIP_Port_Set(uint32_t object_instance,
|
||||
uint16_t value)
|
||||
bool Network_Port_Remote_BBMD_BIP_Port_Set(
|
||||
uint32_t object_instance, uint16_t value)
|
||||
{
|
||||
bool status = false;
|
||||
unsigned index = 0;
|
||||
@@ -1591,8 +1586,8 @@ uint16_t Network_Port_Remote_BBMD_BIP_Lifetime(uint32_t object_instance)
|
||||
*
|
||||
* @return true if values are within range and property is set.
|
||||
*/
|
||||
bool Network_Port_Remote_BBMD_BIP_Lifetime_Set(uint32_t object_instance,
|
||||
uint16_t value)
|
||||
bool Network_Port_Remote_BBMD_BIP_Lifetime_Set(
|
||||
uint32_t object_instance, uint16_t value)
|
||||
{
|
||||
bool status = false;
|
||||
unsigned index = 0;
|
||||
@@ -2357,13 +2352,12 @@ int Network_Port_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
case PROP_FD_BBMD_ADDRESS:
|
||||
Network_Port_Remote_BBMD_IP_Address_And_Port(
|
||||
rpdata->object_instance, &ip_address);
|
||||
apdu_len = bvlc_foreign_device_bbmd_host_address_encode(&apdu[0],
|
||||
apdu_size, &ip_address);
|
||||
apdu_len = bvlc_foreign_device_bbmd_host_address_encode(
|
||||
&apdu[0], apdu_size, &ip_address);
|
||||
break;
|
||||
case PROP_FD_SUBSCRIPTION_LIFETIME:
|
||||
apdu_len = encode_application_unsigned(
|
||||
&apdu[0], Network_Port_Remote_BBMD_BIP_Lifetime(
|
||||
rpdata->object_instance));
|
||||
apdu_len = encode_application_unsigned(&apdu[0],
|
||||
Network_Port_Remote_BBMD_BIP_Lifetime(rpdata->object_instance));
|
||||
break;
|
||||
#endif
|
||||
case PROP_BACNET_IPV6_MODE:
|
||||
@@ -2497,8 +2491,8 @@ bool Network_Port_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
/* FIXME: len < application_data_len: more data? */
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_MAX_MASTER:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
if (value.type.Unsigned_Int <= 255) {
|
||||
status = Network_Port_MSTP_Max_Master_Set(
|
||||
@@ -2514,8 +2508,8 @@ bool Network_Port_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_MAX_INFO_FRAMES:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
if (value.type.Unsigned_Int <= 255) {
|
||||
status = Network_Port_MSTP_Max_Info_Frames_Set(
|
||||
|
||||
@@ -123,7 +123,7 @@ bool objects_device_delete(int index)
|
||||
Keylist_Delete(pDevice->Object_List);
|
||||
}
|
||||
free(pDevice);
|
||||
result = true;
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -303,8 +303,8 @@ bool OctetString_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_PRESENT_VALUE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_OCTET_STRING);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_OCTET_STRING);
|
||||
if (status) {
|
||||
/* Command priority 6 is reserved for use by Minimum On/Off
|
||||
algorithm and may not be used for other purposes in any
|
||||
@@ -327,8 +327,8 @@ bool OctetString_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
CurrentAV->Out_Of_Service = value.type.Boolean;
|
||||
}
|
||||
|
||||
@@ -309,8 +309,8 @@ bool PositiveInteger_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_PRESENT_VALUE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
/* Command priority 6 is reserved for use by Minimum On/Off
|
||||
algorithm and may not be used for other purposes in any
|
||||
@@ -333,8 +333,8 @@ bool PositiveInteger_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
CurrentAV->Out_Of_Service = value.type.Boolean;
|
||||
}
|
||||
|
||||
@@ -86,7 +86,8 @@ void Schedule_Init(void)
|
||||
for (j = 0; j < 7; j++) {
|
||||
psched->Weekly_Schedule[j].TV_Count = 0;
|
||||
}
|
||||
memcpy(&psched->Present_Value, &psched->Schedule_Default, sizeof(psched->Present_Value));
|
||||
memcpy(&psched->Present_Value, &psched->Schedule_Default,
|
||||
sizeof(psched->Present_Value));
|
||||
psched->Schedule_Default.context_specific = false;
|
||||
psched->Schedule_Default.tag = BACNET_APPLICATION_TAG_REAL;
|
||||
psched->Schedule_Default.type.Real = 21.0f; /* 21 C, room temperature */
|
||||
@@ -347,8 +348,8 @@ bool Schedule_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
suitable time for
|
||||
review by all interested parties. Say 6 months -> September
|
||||
2016 */
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
Schedule_Out_Of_Service_Set(
|
||||
wp_data->object_instance, value.type.Boolean);
|
||||
@@ -421,6 +422,7 @@ void Schedule_Recalculate_PV(
|
||||
}
|
||||
|
||||
if (desc->Present_Value.tag == BACNET_APPLICATION_TAG_NULL) {
|
||||
memcpy(&desc->Present_Value, &desc->Schedule_Default, sizeof(desc->Present_Value));
|
||||
memcpy(&desc->Present_Value, &desc->Schedule_Default,
|
||||
sizeof(desc->Present_Value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -458,8 +458,8 @@ bool Trend_Log_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_ENABLE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
/* Section 12.25.5 can't enable a full log with stop when full
|
||||
* set */
|
||||
@@ -500,8 +500,8 @@ bool Trend_Log_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_STOP_WHEN_FULL:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
/* Only trigger this on a change of state */
|
||||
if (CurrentLog->bStopWhenFull != value.type.Boolean) {
|
||||
@@ -532,8 +532,8 @@ bool Trend_Log_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_RECORD_COUNT:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
if (value.type.Unsigned_Int == 0) {
|
||||
/* Time to clear down the log */
|
||||
@@ -549,8 +549,8 @@ bool Trend_Log_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
/* logic
|
||||
* triggered and polled options.
|
||||
*/
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
if (status) {
|
||||
if (value.type.Enumerated != LOGGING_TYPE_COV) {
|
||||
CurrentLog->LoggingType =
|
||||
@@ -579,8 +579,8 @@ bool Trend_Log_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
|
||||
case PROP_START_TIME:
|
||||
/* Copy the date part to safe place */
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_DATE);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_DATE);
|
||||
if (!status) {
|
||||
break;
|
||||
}
|
||||
@@ -591,14 +591,14 @@ bool Trend_Log_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
wp_data->application_data_len - len, &value);
|
||||
|
||||
if (len) {
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_TIME);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_TIME);
|
||||
if (!status) {
|
||||
break;
|
||||
}
|
||||
/* First record the current enable state of the log */
|
||||
bEffectiveEnable = TL_Is_Enabled(log_index);
|
||||
/* Safe to copy the date now */
|
||||
/* Safe to copy the date now */
|
||||
CurrentLog->StartTime.date = start_date;
|
||||
CurrentLog->StartTime.time = value.type.Time;
|
||||
|
||||
@@ -630,8 +630,8 @@ bool Trend_Log_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
|
||||
case PROP_STOP_TIME:
|
||||
/* Copy the date part to safe place */
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_DATE);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_DATE);
|
||||
if (!status) {
|
||||
break;
|
||||
}
|
||||
@@ -642,14 +642,14 @@ bool Trend_Log_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
wp_data->application_data_len - len, &value);
|
||||
|
||||
if (len) {
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_TIME);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_TIME);
|
||||
if (!status) {
|
||||
break;
|
||||
}
|
||||
/* First record the current enable state of the log */
|
||||
bEffectiveEnable = TL_Is_Enabled(log_index);
|
||||
/* Safe to copy the date now */
|
||||
/* Safe to copy the date now */
|
||||
CurrentLog->StopTime.date = stop_date;
|
||||
CurrentLog->StopTime.time = value.type.Time;
|
||||
|
||||
@@ -684,7 +684,7 @@ bool Trend_Log_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
wp_data->application_data, &TempSource);
|
||||
if ((len < 0) ||
|
||||
(len > wp_data->application_data_len)) /* Hmm, that didn't go */
|
||||
/* as planned... */
|
||||
/* as planned... */
|
||||
{
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_OTHER;
|
||||
@@ -720,8 +720,8 @@ bool Trend_Log_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
|
||||
break;
|
||||
}
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
if ((CurrentLog->LoggingType == LOGGING_TYPE_POLLED) &&
|
||||
(value.type.Unsigned_Int == 0)) {
|
||||
@@ -745,8 +745,8 @@ bool Trend_Log_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_ALIGN_INTERVALS:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
CurrentLog->bAlignIntervals = value.type.Boolean;
|
||||
}
|
||||
@@ -755,16 +755,16 @@ bool Trend_Log_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
case PROP_INTERVAL_OFFSET:
|
||||
/* We only log to 1 sec accuracy so must divide by 100 before
|
||||
* passing it on */
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
CurrentLog->ulIntervalOffset = value.type.Unsigned_Int / 100;
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_TRIGGER:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
/* We will not allow triggered operation if polling with
|
||||
* aligning to the clock as that will produce non aligned
|
||||
|
||||
@@ -342,8 +342,7 @@ bool apdu_complex_error(uint8_t service_choice)
|
||||
* handling.
|
||||
*/
|
||||
void apdu_set_error_handler(
|
||||
BACNET_CONFIRMED_SERVICE service_choice,
|
||||
error_function pFunction)
|
||||
BACNET_CONFIRMED_SERVICE service_choice, error_function pFunction)
|
||||
{
|
||||
if ((service_choice < MAX_BACNET_CONFIRMED_SERVICE) &&
|
||||
(!apdu_complex_error(service_choice))) {
|
||||
@@ -359,8 +358,7 @@ void apdu_set_error_handler(
|
||||
* handling.
|
||||
*/
|
||||
void apdu_set_complex_error_handler(
|
||||
BACNET_CONFIRMED_SERVICE service_choice,
|
||||
complex_error_function pFunction)
|
||||
BACNET_CONFIRMED_SERVICE service_choice, complex_error_function pFunction)
|
||||
{
|
||||
if (apdu_complex_error(service_choice)) {
|
||||
Error_Function[service_choice].complex = pFunction;
|
||||
@@ -556,9 +554,9 @@ void apdu_handler(BACNET_ADDRESS *src,
|
||||
/* PDU Type */
|
||||
switch (apdu[0] & 0xF0) {
|
||||
case PDU_TYPE_CONFIRMED_SERVICE_REQUEST:
|
||||
len = apdu_decode_confirmed_service_request(
|
||||
&apdu[0], apdu_len, &service_data, &service_choice,
|
||||
&service_request, &service_request_len);
|
||||
len = apdu_decode_confirmed_service_request(&apdu[0], apdu_len,
|
||||
&service_data, &service_choice, &service_request,
|
||||
&service_request_len);
|
||||
if (len == 0) {
|
||||
/* service data unable to be decoded - simply drop */
|
||||
break;
|
||||
@@ -672,8 +670,8 @@ void apdu_handler(BACNET_ADDRESS *src,
|
||||
case SERVICE_CONFIRMED_VT_DATA:
|
||||
/* Security Services */
|
||||
case SERVICE_CONFIRMED_AUTHENTICATE:
|
||||
if (Confirmed_ACK_Function[service_choice].complex !=
|
||||
NULL) {
|
||||
if (Confirmed_ACK_Function[service_choice]
|
||||
.complex != NULL) {
|
||||
Confirmed_ACK_Function[service_choice].complex(
|
||||
service_request, service_request_len, src,
|
||||
&service_ack_data);
|
||||
@@ -697,16 +695,15 @@ void apdu_handler(BACNET_ADDRESS *src,
|
||||
if (apdu_complex_error(service_choice)) {
|
||||
if (Error_Function[service_choice].complex) {
|
||||
Error_Function[service_choice].complex(src,
|
||||
invoke_id, service_choice,
|
||||
&apdu[3], apdu_len - 3);
|
||||
invoke_id, service_choice, &apdu[3],
|
||||
apdu_len - 3);
|
||||
}
|
||||
} else if (service_choice < MAX_BACNET_CONFIRMED_SERVICE) {
|
||||
len = bacerror_decode_error_class_and_code(&apdu[3],
|
||||
apdu_len - 3, &error_class, &error_code);
|
||||
len = bacerror_decode_error_class_and_code(
|
||||
&apdu[3], apdu_len - 3, &error_class, &error_code);
|
||||
if ((len != 0) &&
|
||||
(Error_Function[service_choice].error)) {
|
||||
Error_Function[service_choice].error(src,
|
||||
invoke_id,
|
||||
Error_Function[service_choice].error(src, invoke_id,
|
||||
(BACNET_ERROR_CLASS)error_class,
|
||||
(BACNET_ERROR_CODE)error_code);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
/** @file h_ccov.c Handles Confirmed COV Notifications. */
|
||||
#if PRINT_ENABLED
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) fprintf(stderr,__VA_ARGS__)
|
||||
#define PRINTF(...) fprintf(stderr, __VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#endif
|
||||
@@ -60,8 +60,7 @@ static BACNET_COV_NOTIFICATION Confirmed_COV_Notification_Head;
|
||||
* @brief call the COV notification callbacks
|
||||
* @param cov_data - data decoded from the COV notification
|
||||
*/
|
||||
static void handler_ccov_notification_callback(
|
||||
BACNET_COV_DATA *cov_data)
|
||||
static void handler_ccov_notification_callback(BACNET_COV_DATA *cov_data)
|
||||
{
|
||||
BACNET_COV_NOTIFICATION *head;
|
||||
|
||||
@@ -78,8 +77,7 @@ static void handler_ccov_notification_callback(
|
||||
* @brief Add a Confirmed COV notification callback
|
||||
* @param cb - COV notification callback to be added
|
||||
*/
|
||||
void handler_ccov_notification_add(
|
||||
BACNET_COV_NOTIFICATION *cb)
|
||||
void handler_ccov_notification_add(BACNET_COV_NOTIFICATION *cb)
|
||||
{
|
||||
BACNET_COV_NOTIFICATION *head;
|
||||
|
||||
@@ -161,8 +159,7 @@ void handler_ccov_notification(uint8_t *service_request,
|
||||
PRINTF("%s ",
|
||||
bactext_property_name(pProperty_value->propertyIdentifier));
|
||||
} else {
|
||||
PRINTF("proprietary %u ",
|
||||
pProperty_value->propertyIdentifier);
|
||||
PRINTF("proprietary %u ", pProperty_value->propertyIdentifier);
|
||||
}
|
||||
if (pProperty_value->propertyArrayIndex != BACNET_ARRAY_ALL) {
|
||||
PRINTF("%u ", pProperty_value->propertyArrayIndex);
|
||||
|
||||
@@ -149,8 +149,7 @@ void handler_device_communication_control(uint8_t *service_request,
|
||||
#endif
|
||||
} else if (len == BACNET_STATUS_REJECT) {
|
||||
len = reject_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
service_data->invoke_id,
|
||||
REJECT_REASON_PARAMETER_OUT_OF_RANGE);
|
||||
service_data->invoke_id, REJECT_REASON_PARAMETER_OUT_OF_RANGE);
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "DCC: Sending Reject!\n");
|
||||
#endif
|
||||
|
||||
@@ -92,9 +92,9 @@ void handler_read_property(uint8_t *service_request,
|
||||
if (npdu_len <= 0) {
|
||||
/* If 0 or negative, there were problems with the data or encoding. */
|
||||
len = BACNET_STATUS_ABORT;
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "RP: npdu_encode_pdu error. Sending Abort!\n");
|
||||
#endif
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "RP: npdu_encode_pdu error. Sending Abort!\n");
|
||||
#endif
|
||||
} else if (service_data->segmented_message) {
|
||||
/* we don't support segmentation - send an abort */
|
||||
len = BACNET_STATUS_ABORT;
|
||||
@@ -103,17 +103,17 @@ void handler_read_property(uint8_t *service_request,
|
||||
#endif
|
||||
} else {
|
||||
len = rp_decode_service_request(service_request, service_len, &rpdata);
|
||||
#if PRINT_ENABLED
|
||||
#if PRINT_ENABLED
|
||||
if (len <= 0) {
|
||||
fprintf(stderr, "RP: Unable to decode Request!\n");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
if (len < 0) {
|
||||
/* bad decoding - skip to error/reject/abort handling */
|
||||
error = true;
|
||||
#if PRINT_ENABLED
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "RP: Bad Encoding.\n");
|
||||
#endif
|
||||
#endif
|
||||
} else {
|
||||
/* When the object-type in the Object Identifier parameter
|
||||
contains the value DEVICE and the instance in the 'Object
|
||||
@@ -140,9 +140,9 @@ void handler_read_property(uint8_t *service_request,
|
||||
rpdata.object_instance = Network_Port_Index_To_Instance(0);
|
||||
}
|
||||
#endif
|
||||
apdu_len = rp_ack_encode_apdu_init(
|
||||
&Handler_Transmit_Buffer[npdu_len], service_data->invoke_id,
|
||||
&rpdata);
|
||||
apdu_len =
|
||||
rp_ack_encode_apdu_init(&Handler_Transmit_Buffer[npdu_len],
|
||||
service_data->invoke_id, &rpdata);
|
||||
/* configure our storage */
|
||||
rpdata.application_data =
|
||||
&Handler_Transmit_Buffer[npdu_len + apdu_len];
|
||||
@@ -157,21 +157,22 @@ void handler_read_property(uint8_t *service_request,
|
||||
if (apdu_len > service_data->max_resp) {
|
||||
/* too big for the sender - send an abort!
|
||||
Setting of error code needed here as read property
|
||||
processing may have overridden the default set at start */
|
||||
processing may have overridden the default set at start
|
||||
*/
|
||||
rpdata.error_code =
|
||||
ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
|
||||
len = BACNET_STATUS_ABORT;
|
||||
#if PRINT_ENABLED
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "RP: Message too large.\n");
|
||||
#endif
|
||||
#endif
|
||||
} else {
|
||||
#if PRINT_ENABLED
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "RP: Sending Ack!\n");
|
||||
#endif
|
||||
#endif
|
||||
error = false;
|
||||
}
|
||||
} else {
|
||||
#if PRINT_ENABLED
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "RP: Device_Read_Property: ");
|
||||
if (len == BACNET_STATUS_ABORT) {
|
||||
fprintf(stderr, "Abort!\n");
|
||||
@@ -182,7 +183,7 @@ void handler_read_property(uint8_t *service_request,
|
||||
} else {
|
||||
fprintf(stderr, "Unknown Len=%d\n", len);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,8 +41,8 @@
|
||||
|
||||
#if PRINT_ENABLED
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) fprintf(stdout,__VA_ARGS__)
|
||||
#define PRINTF_ERR(...) fprintf(stderr,__VA_ARGS__)
|
||||
#define PRINTF(...) fprintf(stdout, __VA_ARGS__)
|
||||
#define PRINTF_ERR(...) fprintf(stderr, __VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#define PRINTF_ERR(...)
|
||||
@@ -73,9 +73,9 @@ void rp_ack_print_data(BACNET_READ_PROPERTY_DATA *data)
|
||||
/* FIXME: what if application_data_len is bigger than 255? */
|
||||
/* value? need to loop until all of the len is gone... */
|
||||
for (;;) {
|
||||
len = bacapp_decode_known_property(
|
||||
application_data, (unsigned)application_data_len, &value,
|
||||
data->object_type, data->object_property);
|
||||
len = bacapp_decode_known_property(application_data,
|
||||
(unsigned)application_data_len, &value, data->object_type,
|
||||
data->object_property);
|
||||
|
||||
if (len < 0) {
|
||||
PRINTF_ERR("RP Ack: unable to decode! %s:%s\n",
|
||||
|
||||
@@ -287,8 +287,9 @@ void handler_read_property_multiple(uint8_t *service_request,
|
||||
#endif
|
||||
error = len;
|
||||
berror = true;
|
||||
break; /* The berror flag ensures that both loops will */
|
||||
/* be broken! */
|
||||
break; /* The berror flag ensures that both loops will
|
||||
*/
|
||||
/* be broken! */
|
||||
}
|
||||
decode_len += len;
|
||||
/* handle the special properties */
|
||||
@@ -321,7 +322,7 @@ void handler_read_property_multiple(uint8_t *service_request,
|
||||
error = BACNET_STATUS_ABORT;
|
||||
berror = true;
|
||||
break; /* The berror flag ensures that both */
|
||||
/* loops will be broken! */
|
||||
/* loops will be broken! */
|
||||
}
|
||||
|
||||
apdu_len += len;
|
||||
@@ -343,7 +344,7 @@ void handler_read_property_multiple(uint8_t *service_request,
|
||||
error = BACNET_STATUS_ABORT;
|
||||
berror = true;
|
||||
break; /* The berror flag ensures that both */
|
||||
/* loops will be broken! */
|
||||
/* loops will be broken! */
|
||||
}
|
||||
apdu_len += len;
|
||||
} else {
|
||||
@@ -379,8 +380,9 @@ void handler_read_property_multiple(uint8_t *service_request,
|
||||
#endif
|
||||
error = len;
|
||||
berror = true;
|
||||
break; /* The berror flag ensures that */
|
||||
/* both loops will be broken! */
|
||||
break; /* The berror flag ensures that
|
||||
*/
|
||||
/* both loops will be broken! */
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -400,7 +402,7 @@ void handler_read_property_multiple(uint8_t *service_request,
|
||||
error = len;
|
||||
berror = true;
|
||||
break; /* The berror flag ensures that both loops */
|
||||
/* will be broken! */
|
||||
/* will be broken! */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -422,7 +424,7 @@ void handler_read_property_multiple(uint8_t *service_request,
|
||||
error = BACNET_STATUS_ABORT;
|
||||
berror = true;
|
||||
break; /* The berror flag ensures that both loops */
|
||||
/* will be broken! */
|
||||
/* will be broken! */
|
||||
} else {
|
||||
apdu_len += copy_len;
|
||||
}
|
||||
|
||||
@@ -41,8 +41,8 @@
|
||||
|
||||
#if PRINT_ENABLED
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) fprintf(stdout,__VA_ARGS__)
|
||||
#define PRINTF_ERR(...) fprintf(stderr,__VA_ARGS__)
|
||||
#define PRINTF(...) fprintf(stdout, __VA_ARGS__)
|
||||
#define PRINTF_ERR(...) fprintf(stderr, __VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#define PRINTF_ERR(...)
|
||||
@@ -124,9 +124,8 @@ int rpm_ack_decode_service_request(
|
||||
value = calloc(1, sizeof(BACNET_APPLICATION_DATA_VALUE));
|
||||
rpm_property->value = value;
|
||||
while (value && (apdu_len > 0)) {
|
||||
len = bacapp_decode_known_property(
|
||||
apdu, (unsigned)apdu_len, value,
|
||||
rpm_object->object_type,
|
||||
len = bacapp_decode_known_property(apdu, (unsigned)apdu_len,
|
||||
value, rpm_object->object_type,
|
||||
rpm_property->propertyIdentifier);
|
||||
/* If len == 0 then it's an empty structure, which is OK. */
|
||||
if (len < 0) {
|
||||
@@ -134,7 +133,7 @@ int rpm_ack_decode_service_request(
|
||||
PRINTF_ERR("RPM Ack: unable to decode! %s:%s\n",
|
||||
bactext_object_type_name(rpm_object->object_type),
|
||||
bactext_property_name(
|
||||
rpm_property->propertyIdentifier));
|
||||
rpm_property->propertyIdentifier));
|
||||
/* note: caller will free the memory */
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
@@ -155,7 +154,8 @@ int rpm_ack_decode_service_request(
|
||||
PRINTF_ERR("RPM Ack: decoded %s:%s len=%d\n",
|
||||
bactext_object_type_name(rpm_object->object_type),
|
||||
bactext_property_name(
|
||||
rpm_property->propertyIdentifier), len);
|
||||
rpm_property->propertyIdentifier),
|
||||
len);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -225,8 +225,7 @@ void rpm_ack_print_data(BACNET_READ_ACCESS_DATA *rpm_data)
|
||||
bool array_value = false;
|
||||
|
||||
if (rpm_data) {
|
||||
PRINTF("%s #%lu\r\n",
|
||||
bactext_object_type_name(rpm_data->object_type),
|
||||
PRINTF("%s #%lu\r\n", bactext_object_type_name(rpm_data->object_type),
|
||||
(unsigned long)rpm_data->object_instance);
|
||||
PRINTF("{\r\n");
|
||||
listOfProperties = rpm_data->listOfProperties;
|
||||
|
||||
@@ -153,17 +153,17 @@ void handler_read_range(uint8_t *service_request,
|
||||
} else {
|
||||
memset(&data, 0, sizeof(data)); /* start with blank canvas */
|
||||
len = rr_decode_service_request(service_request, service_len, &data);
|
||||
#if PRINT_ENABLED
|
||||
#if PRINT_ENABLED
|
||||
if (len <= 0)
|
||||
fprintf(stderr, "RR: Unable to decode Request!\n");
|
||||
#endif
|
||||
#endif
|
||||
if (len < 0) {
|
||||
/* bad decoding - send an abort */
|
||||
len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
service_data->invoke_id, ABORT_REASON_OTHER, true);
|
||||
#if PRINT_ENABLED
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "RR: Bad Encoding. Sending Abort!\n");
|
||||
#endif
|
||||
#endif
|
||||
} else {
|
||||
/* assume that there is an error */
|
||||
error = true;
|
||||
@@ -173,29 +173,31 @@ void handler_read_range(uint8_t *service_request,
|
||||
data.application_data = &Temp_Buf[0];
|
||||
data.application_data_len = len;
|
||||
/* FIXME: probably need a length limitation sent with encode */
|
||||
len = rr_ack_encode_apdu(
|
||||
&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id, &data);
|
||||
#if PRINT_ENABLED
|
||||
len = rr_ack_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
service_data->invoke_id, &data);
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "RR: Sending Ack!\n");
|
||||
#endif
|
||||
#endif
|
||||
error = false;
|
||||
}
|
||||
if (error) {
|
||||
if (len == -2) {
|
||||
/* BACnet APDU too small to fit data, so proper response is Abort */
|
||||
/* BACnet APDU too small to fit data, so proper response is
|
||||
* Abort */
|
||||
len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
service_data->invoke_id,
|
||||
ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true);
|
||||
#if PRINT_ENABLED
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "RR: Reply too big to fit into APDU!\n");
|
||||
#endif
|
||||
#endif
|
||||
} else {
|
||||
len = bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
len = bacerror_encode_apdu(
|
||||
&Handler_Transmit_Buffer[pdu_len],
|
||||
service_data->invoke_id, SERVICE_CONFIRMED_READ_RANGE,
|
||||
data.error_class, data.error_code);
|
||||
#if PRINT_ENABLED
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "RR: Sending Error!\n");
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
/** @file h_ucov.c Handles Unconfirmed COV Notifications. */
|
||||
#if PRINT_ENABLED
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) fprintf(stderr,__VA_ARGS__)
|
||||
#define PRINTF(...) fprintf(stderr, __VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#endif
|
||||
@@ -57,8 +57,7 @@ static BACNET_COV_NOTIFICATION Unconfirmed_COV_Notification_Head;
|
||||
* @brief call the COV notification callbacks
|
||||
* @param cov_data - data decoded from the COV notification
|
||||
*/
|
||||
static void handler_ucov_notification_callback(
|
||||
BACNET_COV_DATA *cov_data)
|
||||
static void handler_ucov_notification_callback(BACNET_COV_DATA *cov_data)
|
||||
{
|
||||
BACNET_COV_NOTIFICATION *head;
|
||||
|
||||
@@ -75,8 +74,7 @@ static void handler_ucov_notification_callback(
|
||||
* @brief Add a Confirmed COV notification callback
|
||||
* @param cb - COV notification callback to be added
|
||||
*/
|
||||
void handler_ucov_notification_add(
|
||||
BACNET_COV_NOTIFICATION *cb)
|
||||
void handler_ucov_notification_add(BACNET_COV_NOTIFICATION *cb)
|
||||
{
|
||||
BACNET_COV_NOTIFICATION *head;
|
||||
|
||||
@@ -122,9 +120,8 @@ void handler_ucov_notification(
|
||||
cov_data.listOfValues = &property_value[0];
|
||||
PRINTF("UCOV: Received Notification!\n");
|
||||
/* decode the service request only */
|
||||
len =
|
||||
cov_notify_decode_service_request(
|
||||
service_request, service_len, &cov_data);
|
||||
len = cov_notify_decode_service_request(
|
||||
service_request, service_len, &cov_data);
|
||||
if (len > 0) {
|
||||
handler_ucov_notification_callback(&cov_data);
|
||||
PRINTF("UCOV: PID=%u ", cov_data.subscriberProcessIdentifier);
|
||||
@@ -141,8 +138,7 @@ void handler_ucov_notification(
|
||||
PRINTF("%s ",
|
||||
bactext_property_name(pProperty_value->propertyIdentifier));
|
||||
} else {
|
||||
PRINTF("proprietary %u ",
|
||||
pProperty_value->propertyIdentifier);
|
||||
PRINTF("proprietary %u ", pProperty_value->propertyIdentifier);
|
||||
}
|
||||
if (pProperty_value->propertyArrayIndex != BACNET_ARRAY_ALL) {
|
||||
PRINTF("%u ", pProperty_value->propertyArrayIndex);
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
/** @file h_wpm.c Handles Write Property Multiple requests. */
|
||||
#if PRINT_ENABLED
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) fprintf(stderr,__VA_ARGS__)
|
||||
#define PRINTF(...) fprintf(stderr, __VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#endif
|
||||
@@ -61,8 +61,8 @@
|
||||
* @return number of bytes decoded, or BACNET_STATUS_REJECT,
|
||||
* or BACNET_STATUS_ERROR
|
||||
*/
|
||||
static int write_property_multiple_decode(
|
||||
uint8_t *apdu, uint16_t apdu_len,
|
||||
static int write_property_multiple_decode(uint8_t *apdu,
|
||||
uint16_t apdu_len,
|
||||
BACNET_WRITE_PROPERTY_DATA *wp_data,
|
||||
write_property_function device_write_property)
|
||||
{
|
||||
@@ -83,12 +83,12 @@ static int write_property_multiple_decode(
|
||||
(3) an optional 'Property Array Index'
|
||||
(4) a 'Property Value'
|
||||
(5) an optional 'Priority' */
|
||||
len = wpm_decode_object_property(&apdu[offset],
|
||||
apdu_len - offset, wp_data);
|
||||
len = wpm_decode_object_property(
|
||||
&apdu[offset], apdu_len - offset, wp_data);
|
||||
if (len > 0) {
|
||||
offset += len;
|
||||
PRINTF("WPM: type=%lu instance=%lu property=%lu "
|
||||
"priority=%lu index=%ld\n",
|
||||
"priority=%lu index=%ld\n",
|
||||
(unsigned long)wp_data->object_type,
|
||||
(unsigned long)wp_data->object_instance,
|
||||
(unsigned long)wp_data->object_property,
|
||||
@@ -160,11 +160,11 @@ void handler_write_property_multiple(uint8_t *service_request,
|
||||
PRINTF("WPM: Segmented message. Sending Abort!\n");
|
||||
} else {
|
||||
/* first time - detect malformed request before writing any data */
|
||||
len = write_property_multiple_decode(service_request, service_len,
|
||||
&wp_data, NULL);
|
||||
len = write_property_multiple_decode(
|
||||
service_request, service_len, &wp_data, NULL);
|
||||
if (len > 0) {
|
||||
len = write_property_multiple_decode(service_request, service_len,
|
||||
&wp_data, Device_Write_Property);
|
||||
len = write_property_multiple_decode(
|
||||
service_request, service_len, &wp_data, Device_Write_Property);
|
||||
}
|
||||
}
|
||||
/* encode the confirmed reply */
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
/** @file s_ack_alarm.c Send an Alarm Acknowledgment. */
|
||||
#if PRINT_ENABLED
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) fprintf(stderr,__VA_ARGS__)
|
||||
#define PRINTF(...) fprintf(stderr, __VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#endif
|
||||
@@ -58,8 +58,10 @@
|
||||
* @return invoke id of outgoing message, or 0 if communication is disabled,
|
||||
* or no tsm slot is available.
|
||||
*/
|
||||
uint8_t Send_Alarm_Acknowledgement_Address(uint8_t *pdu, uint16_t pdu_size,
|
||||
BACNET_ALARM_ACK_DATA *data, BACNET_ADDRESS *dest)
|
||||
uint8_t Send_Alarm_Acknowledgement_Address(uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
BACNET_ALARM_ACK_DATA *data,
|
||||
BACNET_ADDRESS *dest)
|
||||
{
|
||||
int len = 0;
|
||||
int pdu_len = 0;
|
||||
@@ -91,10 +93,9 @@ uint8_t Send_Alarm_Acknowledgement_Address(uint8_t *pdu, uint16_t pdu_size,
|
||||
we have a way to check for that and update the
|
||||
max_apdu in the address binding table. */
|
||||
if ((uint16_t)pdu_len < pdu_size) {
|
||||
tsm_set_confirmed_unsegmented_transaction(invoke_id, dest,
|
||||
&npdu_data, pdu, (uint16_t)pdu_len);
|
||||
bytes_sent =
|
||||
datalink_send_pdu(dest, &npdu_data, pdu, pdu_len);
|
||||
tsm_set_confirmed_unsegmented_transaction(
|
||||
invoke_id, dest, &npdu_data, pdu, (uint16_t)pdu_len);
|
||||
bytes_sent = datalink_send_pdu(dest, &npdu_data, pdu, pdu_len);
|
||||
if (bytes_sent <= 0) {
|
||||
PRINTF("Failed to Send Alarm Ack Request (%s)!\n",
|
||||
strerror(errno));
|
||||
@@ -103,7 +104,7 @@ uint8_t Send_Alarm_Acknowledgement_Address(uint8_t *pdu, uint16_t pdu_size,
|
||||
tsm_free_invoke_id(invoke_id);
|
||||
invoke_id = 0;
|
||||
PRINTF("Failed to Send Alarm Ack Request "
|
||||
"(exceeds destination maximum APDU)!\n");
|
||||
"(exceeds destination maximum APDU)!\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,8 +134,7 @@ uint8_t Send_Alarm_Acknowledgement(
|
||||
max_apdu = sizeof(Handler_Transmit_Buffer);
|
||||
}
|
||||
invoke_id = Send_Alarm_Acknowledgement_Address(
|
||||
Handler_Transmit_Buffer, max_apdu,
|
||||
data, &dest);
|
||||
Handler_Transmit_Buffer, max_apdu, data, &dest);
|
||||
}
|
||||
|
||||
return invoke_id;
|
||||
|
||||
@@ -47,8 +47,10 @@
|
||||
* @return invoke id of outgoing message, or 0 if communication is disabled,
|
||||
* or no tsm slot is available.
|
||||
*/
|
||||
uint8_t Send_CEvent_Notify_Address(uint8_t *pdu, uint16_t pdu_size,
|
||||
BACNET_EVENT_NOTIFICATION_DATA *data, BACNET_ADDRESS *dest)
|
||||
uint8_t Send_CEvent_Notify_Address(uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
BACNET_EVENT_NOTIFICATION_DATA *data,
|
||||
BACNET_ADDRESS *dest)
|
||||
{
|
||||
int len = 0;
|
||||
int pdu_len = 0;
|
||||
@@ -81,8 +83,8 @@ uint8_t Send_CEvent_Notify_Address(uint8_t *pdu, uint16_t pdu_size,
|
||||
we have a way to check for that and update the
|
||||
max_apdu in the address binding table. */
|
||||
if ((uint16_t)pdu_len < pdu_size) {
|
||||
tsm_set_confirmed_unsegmented_transaction(invoke_id, dest,
|
||||
&npdu_data, pdu, (uint16_t)pdu_len);
|
||||
tsm_set_confirmed_unsegmented_transaction(
|
||||
invoke_id, dest, &npdu_data, pdu, (uint16_t)pdu_len);
|
||||
#if PRINT_ENABLED
|
||||
bytes_sent =
|
||||
#endif
|
||||
@@ -131,8 +133,7 @@ uint8_t Send_CEvent_Notify(
|
||||
max_apdu = sizeof(Handler_Transmit_Buffer);
|
||||
}
|
||||
invoke_id = Send_CEvent_Notify_Address(
|
||||
Handler_Transmit_Buffer, max_apdu,
|
||||
data, &dest);
|
||||
Handler_Transmit_Buffer, max_apdu, data, &dest);
|
||||
}
|
||||
|
||||
return invoke_id;
|
||||
|
||||
@@ -144,7 +144,8 @@ uint8_t Send_COV_Subscribe(
|
||||
/* encode the APDU portion of the packet */
|
||||
if (cov_data->covSubscribeToProperty) {
|
||||
/* subscribe to 1 property */
|
||||
len = cov_subscribe_property_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
len = cov_subscribe_property_encode_apdu(
|
||||
&Handler_Transmit_Buffer[pdu_len],
|
||||
sizeof(Handler_Transmit_Buffer) - pdu_len, invoke_id, cov_data);
|
||||
} else {
|
||||
/* subscribe to object */
|
||||
|
||||
+110
-179
@@ -43,8 +43,12 @@ static double clamp(double d, double min, double max)
|
||||
* @param brightness - return brightness of the CIE xy color 0..255
|
||||
* @note http://en.wikipedia.org/wiki/Srgb
|
||||
*/
|
||||
void color_rgb_to_xy(uint8_t r, uint8_t g, uint8_t b,
|
||||
float *x_coordinate, float *y_coordinate, uint8_t *brightness)
|
||||
void color_rgb_to_xy(uint8_t r,
|
||||
uint8_t g,
|
||||
uint8_t b,
|
||||
float *x_coordinate,
|
||||
float *y_coordinate,
|
||||
uint8_t *brightness)
|
||||
{
|
||||
/* Get the RGB values from your color object
|
||||
and convert them to be between 0 and 1.
|
||||
@@ -63,15 +67,12 @@ void color_rgb_to_xy(uint8_t r, uint8_t g, uint8_t b,
|
||||
This gamma correction is also applied to the screen
|
||||
of your computer or phone, thus we need this to create
|
||||
the same color on the light as on screen. */
|
||||
red = (red > 0.04045f) ?
|
||||
pow((red + 0.055f) / (1.0f + 0.055f), 2.4f) :
|
||||
(red / 12.92f);
|
||||
green = (green > 0.04045f) ?
|
||||
pow((green + 0.055f) / (1.0f + 0.055f), 2.4f) :
|
||||
(green / 12.92f);
|
||||
blue = (blue > 0.04045f) ?
|
||||
pow((blue + 0.055f) / (1.0f + 0.055f), 2.4f) :
|
||||
(blue / 12.92f);
|
||||
red = (red > 0.04045f) ? pow((red + 0.055f) / (1.0f + 0.055f), 2.4f)
|
||||
: (red / 12.92f);
|
||||
green = (green > 0.04045f) ? pow((green + 0.055f) / (1.0f + 0.055f), 2.4f)
|
||||
: (green / 12.92f);
|
||||
blue = (blue > 0.04045f) ? pow((blue + 0.055f) / (1.0f + 0.055f), 2.4f)
|
||||
: (blue / 12.92f);
|
||||
|
||||
/* Convert the RGB values to XYZ using the
|
||||
Wide RGB D65 conversion formula */
|
||||
@@ -97,7 +98,7 @@ void color_rgb_to_xy(uint8_t r, uint8_t g, uint8_t b,
|
||||
/* Use the Y value of XYZ as brightness
|
||||
The Y value indicates the brightness
|
||||
of the converted color. */
|
||||
Y = Y*255.0f;
|
||||
Y = Y * 255.0f;
|
||||
Y = clamp(Y, 0.0f, 255.0f);
|
||||
if (brightness) {
|
||||
*brightness = (uint8_t)Y;
|
||||
@@ -114,8 +115,12 @@ void color_rgb_to_xy(uint8_t r, uint8_t g, uint8_t b,
|
||||
* @param brightness - brightness of the CIE xy color
|
||||
* @note http://en.wikipedia.org/wiki/Srgb
|
||||
*/
|
||||
void color_rgb_from_xy(uint8_t *red, uint8_t *green, uint8_t *blue,
|
||||
float x_coordinate, float y_coordinate, uint8_t brightness)
|
||||
void color_rgb_from_xy(uint8_t *red,
|
||||
uint8_t *green,
|
||||
uint8_t *blue,
|
||||
float x_coordinate,
|
||||
float y_coordinate,
|
||||
uint8_t brightness)
|
||||
{
|
||||
/* Calculate XYZ values */
|
||||
float x = x_coordinate;
|
||||
@@ -133,21 +138,21 @@ void color_rgb_from_xy(uint8_t *red, uint8_t *green, uint8_t *blue,
|
||||
float b = X * 0.0349342f - Y * 0.0968930f + Z * 1.2884099f;
|
||||
|
||||
/* Apply reverse gamma correction */
|
||||
r = r <= 0.0031308f ? 12.92f * r :
|
||||
(1.0f + 0.055f) * pow(r, (1.0f / 2.4f)) - 0.055f;
|
||||
g = g <= 0.0031308f ? 12.92f * g :
|
||||
(1.0f + 0.055f) * pow(g, (1.0f / 2.4f)) - 0.055f;
|
||||
b = b <= 0.0031308f ? 12.92f * b :
|
||||
(1.0f + 0.055f) * pow(b, (1.0f / 2.4f)) - 0.055f;
|
||||
r = r <= 0.0031308f ? 12.92f * r
|
||||
: (1.0f + 0.055f) * pow(r, (1.0f / 2.4f)) - 0.055f;
|
||||
g = g <= 0.0031308f ? 12.92f * g
|
||||
: (1.0f + 0.055f) * pow(g, (1.0f / 2.4f)) - 0.055f;
|
||||
b = b <= 0.0031308f ? 12.92f * b
|
||||
: (1.0f + 0.055f) * pow(b, (1.0f / 2.4f)) - 0.055f;
|
||||
|
||||
/* Convert the RGB values to your color object
|
||||
The rgb values from the above formulas are
|
||||
between 0.0 and 1.0. */
|
||||
r = r*255.0f;
|
||||
r = r * 255.0f;
|
||||
r = clamp(r, 0.0f, 255.0f);
|
||||
g = g*255;
|
||||
g = g * 255;
|
||||
g = clamp(g, 0.0f, 255.0f);
|
||||
b = b*255;
|
||||
b = b * 255;
|
||||
b = clamp(b, 0.0f, 255.0f);
|
||||
/* copy to return value if possible */
|
||||
if (red) {
|
||||
@@ -169,155 +174,81 @@ struct css_color_rgb {
|
||||
uint8_t blue;
|
||||
};
|
||||
static struct css_color_rgb CSS_Color_RGB_Table[] = {
|
||||
{"aliceblue", 240, 248, 255},
|
||||
{"antiquewhite", 250, 235, 215},
|
||||
{"aqua", 0, 255, 255},
|
||||
{"aquamarine", 127, 255, 212},
|
||||
{"azure", 240, 255, 255},
|
||||
{"beige", 245, 245, 220},
|
||||
{"bisque", 255, 228, 196},
|
||||
{"black", 0, 0, 0},
|
||||
{"blanchedalmond", 255, 235, 205},
|
||||
{"blue", 0, 0, 255},
|
||||
{"blueviolet", 138, 43, 226},
|
||||
{"brown", 165, 42, 42},
|
||||
{"burlywood", 222, 184, 135},
|
||||
{"cadetblue", 95, 158, 160},
|
||||
{"chartreuse", 127, 255, 0},
|
||||
{"chocolate", 210, 105, 30},
|
||||
{"coral", 255, 127, 80},
|
||||
{"cornflowerblue", 100, 149, 237},
|
||||
{"cornsilk", 255, 248, 220},
|
||||
{"crimson", 220, 20, 60},
|
||||
{"cyan", 0, 255, 255},
|
||||
{"darkblue", 0, 0, 139},
|
||||
{"darkcyan", 0, 139, 139},
|
||||
{"darkgoldenrod", 184, 134, 11},
|
||||
{"darkgray", 169, 169, 169},
|
||||
{"darkgreen", 0, 100, 0},
|
||||
{"darkgrey", 169, 169, 169},
|
||||
{"darkkhaki", 189, 183, 107},
|
||||
{"darkmagenta", 139, 0, 139},
|
||||
{"darkolivegreen", 85, 107, 47},
|
||||
{"darkorange", 255, 140, 0},
|
||||
{"darkorchid", 153, 50, 204},
|
||||
{"darkred", 139, 0, 0},
|
||||
{"darksalmon", 233, 150, 122},
|
||||
{"darkseagreen", 143, 188, 143},
|
||||
{"darkslateblue", 72, 61, 139},
|
||||
{"darkslategray", 47, 79, 79},
|
||||
{"darkslategrey", 47, 79, 79},
|
||||
{"darkturquoise", 0, 206, 209},
|
||||
{"darkviolet", 148, 0, 211},
|
||||
{"deeppink", 255, 20, 147},
|
||||
{"deepskyblue", 0, 191, 255},
|
||||
{"dimgray", 105, 105, 105},
|
||||
{"dimgrey", 105, 105, 105},
|
||||
{"dodgerblue", 30, 144, 255},
|
||||
{"firebrick", 178, 34, 34},
|
||||
{"floralwhite", 255, 250, 240},
|
||||
{"forestgreen", 34, 139, 34},
|
||||
{"fuchsia", 255, 0, 255},
|
||||
{"gainsboro", 220, 220, 220},
|
||||
{"ghostwhite", 248, 248, 255},
|
||||
{"gold", 255, 215, 0},
|
||||
{"goldenrod", 218, 165, 32},
|
||||
{"gray", 128, 128, 128},
|
||||
{"green", 0, 128, 0},
|
||||
{"greenyellow", 173, 255, 47},
|
||||
{"grey", 128, 128, 128},
|
||||
{"honeydew", 240, 255, 240},
|
||||
{"hotpink", 255, 105, 180},
|
||||
{"indianred", 205, 92, 92},
|
||||
{"indigo", 75, 0, 130},
|
||||
{"ivory", 255, 255, 240},
|
||||
{"khaki", 240, 230, 140},
|
||||
{"lavender", 230, 230, 250},
|
||||
{"lavenderblush", 255, 240, 245},
|
||||
{"lawngreen", 124, 252, 0},
|
||||
{"lemonchiffon", 255, 250, 205},
|
||||
{"lightblue", 173, 216, 230},
|
||||
{"lightcoral", 240, 128, 128},
|
||||
{"lightcyan", 224, 255, 255},
|
||||
{"lightgoldenrodyellow", 250, 250, 210},
|
||||
{"lightgray", 211, 211, 211},
|
||||
{"lightgreen", 144, 238, 144},
|
||||
{"lightgrey", 211, 211, 211},
|
||||
{"lightpink", 255, 182, 193},
|
||||
{"lightsalmon", 255, 160, 122},
|
||||
{"lightseagreen", 32, 178, 170},
|
||||
{"lightskyblue", 135, 206, 250},
|
||||
{"lightslategray", 119, 136, 153},
|
||||
{"lightslategrey", 119, 136, 153},
|
||||
{"lightsteelblue", 176, 196, 222},
|
||||
{"lightyellow", 255, 255, 224},
|
||||
{"lime", 0, 255, 0},
|
||||
{"limegreen", 50, 205, 50},
|
||||
{"linen", 250, 240, 230},
|
||||
{"magenta", 255, 0, 255},
|
||||
{"maroon", 128, 0, 0},
|
||||
{"mediumaquamarine", 102, 205, 170},
|
||||
{"mediumblue", 0, 0, 205},
|
||||
{"mediumorchid", 186, 85, 211},
|
||||
{"mediumpurple", 147, 112, 219},
|
||||
{"mediumseagreen", 60, 179, 113},
|
||||
{"mediumslateblue", 123, 104, 238},
|
||||
{"mediumspringgreen", 0, 250, 154},
|
||||
{"mediumturquoise", 72, 209, 204},
|
||||
{"mediumvioletred", 199, 21, 133},
|
||||
{"midnightblue", 25, 25, 112},
|
||||
{"mintcream", 245, 255, 250},
|
||||
{"mistyrose", 255, 228, 225},
|
||||
{"moccasin", 255, 228, 181},
|
||||
{"navajowhite", 255, 222, 173},
|
||||
{"navy", 0, 0, 128},
|
||||
{"navyblue", 0, 0, 128},
|
||||
{"oldlace", 253, 245, 230},
|
||||
{"olive", 128, 128, 0},
|
||||
{"olivedrab", 107, 142, 35},
|
||||
{"orange", 255, 165, 0},
|
||||
{"orangered", 255, 69, 0},
|
||||
{"orchid", 218, 112, 214},
|
||||
{"palegoldenrod", 238, 232, 170},
|
||||
{"palegreen", 152, 251, 152},
|
||||
{"paleturquoise", 175, 238, 238},
|
||||
{"palevioletred", 219, 112, 147},
|
||||
{"papayawhip", 255, 239, 213},
|
||||
{"peachpuff", 255, 218, 185},
|
||||
{"peru", 205, 133, 63},
|
||||
{"pink", 255, 192, 203},
|
||||
{"plum", 221, 160, 221},
|
||||
{"powderblue", 176, 224, 230},
|
||||
{"purple", 128, 0, 128},
|
||||
{"red", 255, 0, 0},
|
||||
{"rosybrown", 188, 143, 143},
|
||||
{"royalblue", 65, 105, 225},
|
||||
{"saddlebrown", 139, 69, 19},
|
||||
{"salmon", 250, 128, 114},
|
||||
{"sandybrown", 244, 164, 96},
|
||||
{"seagreen", 46, 139, 87},
|
||||
{"seashell", 255, 245, 238},
|
||||
{"sienna", 160, 82, 45},
|
||||
{"silver", 192, 192, 192},
|
||||
{"skyblue", 135, 206, 235},
|
||||
{"slateblue", 106, 90, 205},
|
||||
{"slategray", 112, 128, 144},
|
||||
{"slategrey", 112, 128, 144},
|
||||
{"snow", 255, 250, 250},
|
||||
{"springgreen", 0, 255, 127},
|
||||
{"steelblue", 70, 130, 180},
|
||||
{"tan", 210, 180, 140},
|
||||
{"teal", 0, 128, 128},
|
||||
{"thistle", 216, 191, 216},
|
||||
{"tomato", 255, 99, 71},
|
||||
{"turquoise", 64, 224, 208},
|
||||
{"violet", 238, 130, 238},
|
||||
{"wheat", 245, 222, 179},
|
||||
{"white", 255, 255, 255},
|
||||
{"whitesmoke", 245, 245, 245},
|
||||
{"yellow", 255, 255, 0},
|
||||
{"yellowgreen", 154, 205, 50},
|
||||
{NULL, 0, 0, 0}
|
||||
{ "aliceblue", 240, 248, 255 }, { "antiquewhite", 250, 235, 215 },
|
||||
{ "aqua", 0, 255, 255 }, { "aquamarine", 127, 255, 212 },
|
||||
{ "azure", 240, 255, 255 }, { "beige", 245, 245, 220 },
|
||||
{ "bisque", 255, 228, 196 }, { "black", 0, 0, 0 },
|
||||
{ "blanchedalmond", 255, 235, 205 }, { "blue", 0, 0, 255 },
|
||||
{ "blueviolet", 138, 43, 226 }, { "brown", 165, 42, 42 },
|
||||
{ "burlywood", 222, 184, 135 }, { "cadetblue", 95, 158, 160 },
|
||||
{ "chartreuse", 127, 255, 0 }, { "chocolate", 210, 105, 30 },
|
||||
{ "coral", 255, 127, 80 }, { "cornflowerblue", 100, 149, 237 },
|
||||
{ "cornsilk", 255, 248, 220 }, { "crimson", 220, 20, 60 },
|
||||
{ "cyan", 0, 255, 255 }, { "darkblue", 0, 0, 139 },
|
||||
{ "darkcyan", 0, 139, 139 }, { "darkgoldenrod", 184, 134, 11 },
|
||||
{ "darkgray", 169, 169, 169 }, { "darkgreen", 0, 100, 0 },
|
||||
{ "darkgrey", 169, 169, 169 }, { "darkkhaki", 189, 183, 107 },
|
||||
{ "darkmagenta", 139, 0, 139 }, { "darkolivegreen", 85, 107, 47 },
|
||||
{ "darkorange", 255, 140, 0 }, { "darkorchid", 153, 50, 204 },
|
||||
{ "darkred", 139, 0, 0 }, { "darksalmon", 233, 150, 122 },
|
||||
{ "darkseagreen", 143, 188, 143 }, { "darkslateblue", 72, 61, 139 },
|
||||
{ "darkslategray", 47, 79, 79 }, { "darkslategrey", 47, 79, 79 },
|
||||
{ "darkturquoise", 0, 206, 209 }, { "darkviolet", 148, 0, 211 },
|
||||
{ "deeppink", 255, 20, 147 }, { "deepskyblue", 0, 191, 255 },
|
||||
{ "dimgray", 105, 105, 105 }, { "dimgrey", 105, 105, 105 },
|
||||
{ "dodgerblue", 30, 144, 255 }, { "firebrick", 178, 34, 34 },
|
||||
{ "floralwhite", 255, 250, 240 }, { "forestgreen", 34, 139, 34 },
|
||||
{ "fuchsia", 255, 0, 255 }, { "gainsboro", 220, 220, 220 },
|
||||
{ "ghostwhite", 248, 248, 255 }, { "gold", 255, 215, 0 },
|
||||
{ "goldenrod", 218, 165, 32 }, { "gray", 128, 128, 128 },
|
||||
{ "green", 0, 128, 0 }, { "greenyellow", 173, 255, 47 },
|
||||
{ "grey", 128, 128, 128 }, { "honeydew", 240, 255, 240 },
|
||||
{ "hotpink", 255, 105, 180 }, { "indianred", 205, 92, 92 },
|
||||
{ "indigo", 75, 0, 130 }, { "ivory", 255, 255, 240 },
|
||||
{ "khaki", 240, 230, 140 }, { "lavender", 230, 230, 250 },
|
||||
{ "lavenderblush", 255, 240, 245 }, { "lawngreen", 124, 252, 0 },
|
||||
{ "lemonchiffon", 255, 250, 205 }, { "lightblue", 173, 216, 230 },
|
||||
{ "lightcoral", 240, 128, 128 }, { "lightcyan", 224, 255, 255 },
|
||||
{ "lightgoldenrodyellow", 250, 250, 210 }, { "lightgray", 211, 211, 211 },
|
||||
{ "lightgreen", 144, 238, 144 }, { "lightgrey", 211, 211, 211 },
|
||||
{ "lightpink", 255, 182, 193 }, { "lightsalmon", 255, 160, 122 },
|
||||
{ "lightseagreen", 32, 178, 170 }, { "lightskyblue", 135, 206, 250 },
|
||||
{ "lightslategray", 119, 136, 153 }, { "lightslategrey", 119, 136, 153 },
|
||||
{ "lightsteelblue", 176, 196, 222 }, { "lightyellow", 255, 255, 224 },
|
||||
{ "lime", 0, 255, 0 }, { "limegreen", 50, 205, 50 },
|
||||
{ "linen", 250, 240, 230 }, { "magenta", 255, 0, 255 },
|
||||
{ "maroon", 128, 0, 0 }, { "mediumaquamarine", 102, 205, 170 },
|
||||
{ "mediumblue", 0, 0, 205 }, { "mediumorchid", 186, 85, 211 },
|
||||
{ "mediumpurple", 147, 112, 219 }, { "mediumseagreen", 60, 179, 113 },
|
||||
{ "mediumslateblue", 123, 104, 238 }, { "mediumspringgreen", 0, 250, 154 },
|
||||
{ "mediumturquoise", 72, 209, 204 }, { "mediumvioletred", 199, 21, 133 },
|
||||
{ "midnightblue", 25, 25, 112 }, { "mintcream", 245, 255, 250 },
|
||||
{ "mistyrose", 255, 228, 225 }, { "moccasin", 255, 228, 181 },
|
||||
{ "navajowhite", 255, 222, 173 }, { "navy", 0, 0, 128 },
|
||||
{ "navyblue", 0, 0, 128 }, { "oldlace", 253, 245, 230 },
|
||||
{ "olive", 128, 128, 0 }, { "olivedrab", 107, 142, 35 },
|
||||
{ "orange", 255, 165, 0 }, { "orangered", 255, 69, 0 },
|
||||
{ "orchid", 218, 112, 214 }, { "palegoldenrod", 238, 232, 170 },
|
||||
{ "palegreen", 152, 251, 152 }, { "paleturquoise", 175, 238, 238 },
|
||||
{ "palevioletred", 219, 112, 147 }, { "papayawhip", 255, 239, 213 },
|
||||
{ "peachpuff", 255, 218, 185 }, { "peru", 205, 133, 63 },
|
||||
{ "pink", 255, 192, 203 }, { "plum", 221, 160, 221 },
|
||||
{ "powderblue", 176, 224, 230 }, { "purple", 128, 0, 128 },
|
||||
{ "red", 255, 0, 0 }, { "rosybrown", 188, 143, 143 },
|
||||
{ "royalblue", 65, 105, 225 }, { "saddlebrown", 139, 69, 19 },
|
||||
{ "salmon", 250, 128, 114 }, { "sandybrown", 244, 164, 96 },
|
||||
{ "seagreen", 46, 139, 87 }, { "seashell", 255, 245, 238 },
|
||||
{ "sienna", 160, 82, 45 }, { "silver", 192, 192, 192 },
|
||||
{ "skyblue", 135, 206, 235 }, { "slateblue", 106, 90, 205 },
|
||||
{ "slategray", 112, 128, 144 }, { "slategrey", 112, 128, 144 },
|
||||
{ "snow", 255, 250, 250 }, { "springgreen", 0, 255, 127 },
|
||||
{ "steelblue", 70, 130, 180 }, { "tan", 210, 180, 140 },
|
||||
{ "teal", 0, 128, 128 }, { "thistle", 216, 191, 216 },
|
||||
{ "tomato", 255, 99, 71 }, { "turquoise", 64, 224, 208 },
|
||||
{ "violet", 238, 130, 238 }, { "wheat", 245, 222, 179 },
|
||||
{ "white", 255, 255, 255 }, { "whitesmoke", 245, 245, 245 },
|
||||
{ "yellow", 255, 255, 0 }, { "yellowgreen", 154, 205, 50 },
|
||||
{ NULL, 0, 0, 0 }
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -330,9 +261,9 @@ static struct css_color_rgb CSS_Color_RGB_Table[] = {
|
||||
* https://www.w3.org/TR/2010/PR-css3-color-20101028/#html4
|
||||
* names do not have spaces
|
||||
*/
|
||||
const char * color_rgb_to_ascii(uint8_t red, uint8_t green, uint8_t blue)
|
||||
const char *color_rgb_to_ascii(uint8_t red, uint8_t green, uint8_t blue)
|
||||
{
|
||||
const char * name = "";
|
||||
const char *name = "";
|
||||
unsigned index = 0;
|
||||
|
||||
while (CSS_Color_RGB_Table[index].name) {
|
||||
@@ -355,8 +286,8 @@ const char * color_rgb_to_ascii(uint8_t red, uint8_t green, uint8_t blue)
|
||||
* @param name - CSS color name from W3C
|
||||
* @return index 0..color_rgb_count(), where color_rgb_count() is not found.
|
||||
*/
|
||||
unsigned color_rgb_from_ascii(uint8_t *red, uint8_t *green, uint8_t *blue,
|
||||
const char *name)
|
||||
unsigned color_rgb_from_ascii(
|
||||
uint8_t *red, uint8_t *green, uint8_t *blue, const char *name)
|
||||
{
|
||||
unsigned index = 0;
|
||||
|
||||
@@ -386,7 +317,8 @@ unsigned color_rgb_from_ascii(uint8_t *red, uint8_t *green, uint8_t *blue,
|
||||
* @param blue - return B value of sRGB
|
||||
* @return CSS ASCII color name from W3C or NULL if invalid index
|
||||
*/
|
||||
const char *color_rgb_from_index(unsigned target_index, uint8_t *red, uint8_t *green, uint8_t *blue)
|
||||
const char *color_rgb_from_index(
|
||||
unsigned target_index, uint8_t *red, uint8_t *green, uint8_t *blue)
|
||||
{
|
||||
unsigned index = 0;
|
||||
|
||||
@@ -431,8 +363,7 @@ unsigned color_rgb_count(void)
|
||||
* http://www.tannerhelland.com/4435/convert-temperature-rgb-algorithm-code/
|
||||
*/
|
||||
void color_rgb_from_temperature(
|
||||
uint16_t temperature_kelvin,
|
||||
uint8_t *r, uint8_t *g, uint8_t *b)
|
||||
uint16_t temperature_kelvin, uint8_t *r, uint8_t *g, uint8_t *b)
|
||||
{
|
||||
float red = 0, green = 0, blue = 0;
|
||||
|
||||
|
||||
+15
-20
@@ -24,7 +24,7 @@ bool days_is_leap_year(uint16_t year)
|
||||
{
|
||||
if ((year % 4) == 0 && ((year % 100) != 0 || (year % 400) == 0)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return (false);
|
||||
}
|
||||
@@ -47,7 +47,7 @@ uint8_t days_per_month(uint16_t year, uint8_t month)
|
||||
return (29);
|
||||
} else if (month >= 1 && month <= 12) {
|
||||
return (month_days[month]);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -200,20 +200,18 @@ uint32_t days_apart(uint16_t year1,
|
||||
* @param day - day of month (1-31)
|
||||
* @return number of days since epoch, or 0 if out of range
|
||||
*/
|
||||
uint32_t days_since_epoch(uint16_t epoch_year,
|
||||
uint16_t year,
|
||||
uint8_t month,
|
||||
uint8_t day)
|
||||
uint32_t days_since_epoch(
|
||||
uint16_t epoch_year, uint16_t year, uint8_t month, uint8_t day)
|
||||
{
|
||||
uint32_t days = 0; /* return value */
|
||||
uint16_t yy = 0; /* year */
|
||||
uint8_t mm = 0; /* months counter */
|
||||
uint8_t monthdays = 0; /* days in a month */
|
||||
uint32_t days = 0; /* return value */
|
||||
uint16_t yy = 0; /* year */
|
||||
uint8_t mm = 0; /* months counter */
|
||||
uint8_t monthdays = 0; /* days in a month */
|
||||
|
||||
/* validate the date conforms to our range */
|
||||
monthdays = days_per_month(year, month);
|
||||
if ((year >= epoch_year) && (year <= 9999) &&
|
||||
(monthdays > 0) && (day >= 1) && (day <= monthdays)) {
|
||||
if ((year >= epoch_year) && (year <= 9999) && (monthdays > 0) &&
|
||||
(day >= 1) && (day <= monthdays)) {
|
||||
for (yy = epoch_year; yy < year; yy++) {
|
||||
days += 365;
|
||||
if (days_is_leap_year(yy)) {
|
||||
@@ -238,12 +236,11 @@ uint32_t days_since_epoch(uint16_t epoch_year,
|
||||
* @param pDay - day of month (1-31)
|
||||
* @return nothing
|
||||
*/
|
||||
void days_since_epoch_to_date(
|
||||
uint16_t epoch_year,
|
||||
void days_since_epoch_to_date(uint16_t epoch_year,
|
||||
uint32_t days,
|
||||
uint16_t * pYear,
|
||||
uint8_t * pMonth,
|
||||
uint8_t * pDay)
|
||||
uint16_t *pYear,
|
||||
uint8_t *pMonth,
|
||||
uint8_t *pDay)
|
||||
{
|
||||
uint8_t month = 1;
|
||||
uint8_t day = 0;
|
||||
@@ -281,9 +278,7 @@ void days_since_epoch_to_date(
|
||||
* @param day - day of month (1-31)
|
||||
* @return true if the date is valid
|
||||
*/
|
||||
bool days_date_is_valid(uint16_t year,
|
||||
uint8_t month,
|
||||
uint8_t day)
|
||||
bool days_date_is_valid(uint16_t year, uint8_t month, uint8_t day)
|
||||
{
|
||||
uint8_t month_days = 0;
|
||||
bool valid = false; /* return value */
|
||||
|
||||
+27
-33
@@ -773,9 +773,8 @@ void cov_data_value_list_link(
|
||||
* @param out_of_service - value of out-of-service status-flags
|
||||
*
|
||||
* @return true if values were encoded
|
||||
*/
|
||||
bool cov_value_list_encode_real(
|
||||
BACNET_PROPERTY_VALUE * value_list,
|
||||
*/
|
||||
bool cov_value_list_encode_real(BACNET_PROPERTY_VALUE *value_list,
|
||||
float value,
|
||||
bool in_alarm,
|
||||
bool fault,
|
||||
@@ -800,10 +799,10 @@ bool cov_value_list_encode_real(
|
||||
value_list->value.context_specific = false;
|
||||
value_list->value.tag = BACNET_APPLICATION_TAG_BIT_STRING;
|
||||
bitstring_init(&value_list->value.type.Bit_String);
|
||||
bitstring_set_bit(&value_list->value.type.Bit_String,
|
||||
STATUS_FLAG_IN_ALARM, in_alarm);
|
||||
bitstring_set_bit(&value_list->value.type.Bit_String,
|
||||
STATUS_FLAG_FAULT, fault);
|
||||
bitstring_set_bit(
|
||||
&value_list->value.type.Bit_String, STATUS_FLAG_IN_ALARM, in_alarm);
|
||||
bitstring_set_bit(
|
||||
&value_list->value.type.Bit_String, STATUS_FLAG_FAULT, fault);
|
||||
bitstring_set_bit(&value_list->value.type.Bit_String,
|
||||
STATUS_FLAG_OVERRIDDEN, overridden);
|
||||
bitstring_set_bit(&value_list->value.type.Bit_String,
|
||||
@@ -827,9 +826,8 @@ bool cov_value_list_encode_real(
|
||||
* @param out_of_service - value of out-of-service status-flags
|
||||
*
|
||||
* @return true if values were encoded
|
||||
*/
|
||||
bool cov_value_list_encode_enumerated(
|
||||
BACNET_PROPERTY_VALUE * value_list,
|
||||
*/
|
||||
bool cov_value_list_encode_enumerated(BACNET_PROPERTY_VALUE *value_list,
|
||||
uint32_t value,
|
||||
bool in_alarm,
|
||||
bool fault,
|
||||
@@ -854,10 +852,10 @@ bool cov_value_list_encode_enumerated(
|
||||
value_list->value.context_specific = false;
|
||||
value_list->value.tag = BACNET_APPLICATION_TAG_BIT_STRING;
|
||||
bitstring_init(&value_list->value.type.Bit_String);
|
||||
bitstring_set_bit(&value_list->value.type.Bit_String,
|
||||
STATUS_FLAG_IN_ALARM, in_alarm);
|
||||
bitstring_set_bit(&value_list->value.type.Bit_String,
|
||||
STATUS_FLAG_FAULT, fault);
|
||||
bitstring_set_bit(
|
||||
&value_list->value.type.Bit_String, STATUS_FLAG_IN_ALARM, in_alarm);
|
||||
bitstring_set_bit(
|
||||
&value_list->value.type.Bit_String, STATUS_FLAG_FAULT, fault);
|
||||
bitstring_set_bit(&value_list->value.type.Bit_String,
|
||||
STATUS_FLAG_OVERRIDDEN, overridden);
|
||||
bitstring_set_bit(&value_list->value.type.Bit_String,
|
||||
@@ -881,9 +879,8 @@ bool cov_value_list_encode_enumerated(
|
||||
* @param out_of_service - value of out-of-service status-flags
|
||||
*
|
||||
* @return true if values were encoded
|
||||
*/
|
||||
bool cov_value_list_encode_unsigned(
|
||||
BACNET_PROPERTY_VALUE * value_list,
|
||||
*/
|
||||
bool cov_value_list_encode_unsigned(BACNET_PROPERTY_VALUE *value_list,
|
||||
uint32_t value,
|
||||
bool in_alarm,
|
||||
bool fault,
|
||||
@@ -908,10 +905,10 @@ bool cov_value_list_encode_unsigned(
|
||||
value_list->value.context_specific = false;
|
||||
value_list->value.tag = BACNET_APPLICATION_TAG_BIT_STRING;
|
||||
bitstring_init(&value_list->value.type.Bit_String);
|
||||
bitstring_set_bit(&value_list->value.type.Bit_String,
|
||||
STATUS_FLAG_IN_ALARM, in_alarm);
|
||||
bitstring_set_bit(&value_list->value.type.Bit_String,
|
||||
STATUS_FLAG_FAULT, fault);
|
||||
bitstring_set_bit(
|
||||
&value_list->value.type.Bit_String, STATUS_FLAG_IN_ALARM, in_alarm);
|
||||
bitstring_set_bit(
|
||||
&value_list->value.type.Bit_String, STATUS_FLAG_FAULT, fault);
|
||||
bitstring_set_bit(&value_list->value.type.Bit_String,
|
||||
STATUS_FLAG_OVERRIDDEN, overridden);
|
||||
bitstring_set_bit(&value_list->value.type.Bit_String,
|
||||
@@ -925,7 +922,7 @@ bool cov_value_list_encode_unsigned(
|
||||
return status;
|
||||
}
|
||||
|
||||
#if defined (BACAPP_CHARACTER_STRING)
|
||||
#if defined(BACAPP_CHARACTER_STRING)
|
||||
/**
|
||||
* @brief Encode the Value List for CHARACTER_STRING Present-Value and
|
||||
* Status-Flags
|
||||
@@ -937,10 +934,9 @@ bool cov_value_list_encode_unsigned(
|
||||
* @param out_of_service - value of out-of-service status-flags
|
||||
*
|
||||
* @return true if values were encoded
|
||||
*/
|
||||
bool cov_value_list_encode_character_string(
|
||||
BACNET_PROPERTY_VALUE * value_list,
|
||||
BACNET_CHARACTER_STRING * value,
|
||||
*/
|
||||
bool cov_value_list_encode_character_string(BACNET_PROPERTY_VALUE *value_list,
|
||||
BACNET_CHARACTER_STRING *value,
|
||||
bool in_alarm,
|
||||
bool fault,
|
||||
bool overridden,
|
||||
@@ -953,9 +949,7 @@ bool cov_value_list_encode_character_string(
|
||||
value_list->propertyArrayIndex = BACNET_ARRAY_ALL;
|
||||
value_list->value.context_specific = false;
|
||||
value_list->value.tag = BACNET_APPLICATION_TAG_CHARACTER_STRING;
|
||||
characterstring_copy(
|
||||
&value_list->value.type.Character_String,
|
||||
value);
|
||||
characterstring_copy(&value_list->value.type.Character_String, value);
|
||||
value_list->value.next = NULL;
|
||||
value_list->priority = BACNET_NO_PRIORITY;
|
||||
value_list = value_list->next;
|
||||
@@ -966,10 +960,10 @@ bool cov_value_list_encode_character_string(
|
||||
value_list->value.context_specific = false;
|
||||
value_list->value.tag = BACNET_APPLICATION_TAG_BIT_STRING;
|
||||
bitstring_init(&value_list->value.type.Bit_String);
|
||||
bitstring_set_bit(&value_list->value.type.Bit_String,
|
||||
STATUS_FLAG_IN_ALARM, in_alarm);
|
||||
bitstring_set_bit(&value_list->value.type.Bit_String,
|
||||
STATUS_FLAG_FAULT, fault);
|
||||
bitstring_set_bit(
|
||||
&value_list->value.type.Bit_String, STATUS_FLAG_IN_ALARM, in_alarm);
|
||||
bitstring_set_bit(
|
||||
&value_list->value.type.Bit_String, STATUS_FLAG_FAULT, fault);
|
||||
bitstring_set_bit(&value_list->value.type.Bit_String,
|
||||
STATUS_FLAG_OVERRIDDEN, overridden);
|
||||
bitstring_set_bit(&value_list->value.type.Bit_String,
|
||||
|
||||
@@ -37,20 +37,16 @@ License.
|
||||
#include "bacnet/bactimevalue.h"
|
||||
|
||||
int bacnet_dailyschedule_decode(
|
||||
uint8_t * apdu,
|
||||
int max_apdu_len,
|
||||
BACNET_DAILY_SCHEDULE * day)
|
||||
uint8_t *apdu, int max_apdu_len, 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);
|
||||
day->TV_Count = (uint16_t) tv_count;
|
||||
int retval = bacnet_time_values_context_decode(apdu, max_apdu_len, 0,
|
||||
&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_encode(uint8_t *apdu, BACNET_DAILY_SCHEDULE *day)
|
||||
{
|
||||
return bacnet_time_values_context_encode(
|
||||
apdu, 0, &day->Time_Values[0], day->TV_Count);
|
||||
|
||||
+24
-33
@@ -563,10 +563,10 @@ int bvlc_broadcast_distribution_table_encode(uint8_t *apdu,
|
||||
len = encode_opening_tag(&apdu[apdu_len], 0);
|
||||
apdu_len += len;
|
||||
/* CHOICE - ip-address [1] OCTET STRING */
|
||||
octetstring_init(&octet_string,
|
||||
&bdt_entry->dest_address.address[0], IP_ADDRESS_MAX);
|
||||
len = encode_context_octet_string(&apdu[apdu_len], 1,
|
||||
&octet_string);
|
||||
octetstring_init(&octet_string, &bdt_entry->dest_address.address[0],
|
||||
IP_ADDRESS_MAX);
|
||||
len =
|
||||
encode_context_octet_string(&apdu[apdu_len], 1, &octet_string);
|
||||
apdu_len += len;
|
||||
/* host [0] BACnetHostAddress - closing */
|
||||
len = encode_closing_tag(&apdu[apdu_len], 0);
|
||||
@@ -581,8 +581,8 @@ int bvlc_broadcast_distribution_table_encode(uint8_t *apdu,
|
||||
/* broadcast-mask [1] OCTET STRING */
|
||||
octetstring_init(&octet_string,
|
||||
&bdt_entry->broadcast_mask.address[0], IP_ADDRESS_MAX);
|
||||
len = encode_context_octet_string(&apdu[apdu_len], 1,
|
||||
&octet_string);
|
||||
len =
|
||||
encode_context_octet_string(&apdu[apdu_len], 1, &octet_string);
|
||||
apdu_len += len;
|
||||
}
|
||||
if (!entry_size) {
|
||||
@@ -657,13 +657,12 @@ int bvlc_broadcast_distribution_table_decode(uint8_t *apdu,
|
||||
}
|
||||
return BACNET_STATUS_REJECT;
|
||||
}
|
||||
len += decode_octet_string(&apdu[len], len_value_type,
|
||||
&octet_string);
|
||||
len += decode_octet_string(&apdu[len], len_value_type, &octet_string);
|
||||
if (len > apdu_len) {
|
||||
return BACNET_STATUS_REJECT;
|
||||
}
|
||||
(void)octetstring_copy_value(&bdt_entry->dest_address.address[0],
|
||||
IP_ADDRESS_MAX, &octet_string);
|
||||
(void)octetstring_copy_value(
|
||||
&bdt_entry->dest_address.address[0], IP_ADDRESS_MAX, &octet_string);
|
||||
/* host [0] BACnetHostAddress - closing */
|
||||
if (!decode_is_closing_tag_number(&apdu[len++], 0)) {
|
||||
if (error_code) {
|
||||
@@ -717,8 +716,7 @@ int bvlc_broadcast_distribution_table_decode(uint8_t *apdu,
|
||||
if (len > apdu_len) {
|
||||
return BACNET_STATUS_REJECT;
|
||||
}
|
||||
len += decode_octet_string(&apdu[len], len_value_type,
|
||||
&octet_string);
|
||||
len += decode_octet_string(&apdu[len], len_value_type, &octet_string);
|
||||
if (len > apdu_len) {
|
||||
return BACNET_STATUS_REJECT;
|
||||
}
|
||||
@@ -1148,13 +1146,11 @@ int bvlc_foreign_device_table_encode(uint8_t *apdu,
|
||||
while (fdt_entry) {
|
||||
if (fdt_entry->valid) {
|
||||
/* bacnetip-address [0] OCTET STRING */
|
||||
len = bvlc_encode_address(
|
||||
octetstring_value(&octet_string),
|
||||
octetstring_capacity(&octet_string),
|
||||
&fdt_entry->dest_address);
|
||||
len = bvlc_encode_address(octetstring_value(&octet_string),
|
||||
octetstring_capacity(&octet_string), &fdt_entry->dest_address);
|
||||
octetstring_truncate(&octet_string, len);
|
||||
len = encode_context_octet_string(
|
||||
&apdu[apdu_len], 0, &octet_string);
|
||||
len =
|
||||
encode_context_octet_string(&apdu[apdu_len], 0, &octet_string);
|
||||
apdu_len += len;
|
||||
/* time-to-live [1] Unsigned16 */
|
||||
len = encode_context_unsigned(
|
||||
@@ -1179,8 +1175,6 @@ int bvlc_foreign_device_table_encode(uint8_t *apdu,
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief J.2.7 Read-Foreign-Device-Table: encode
|
||||
*
|
||||
@@ -2162,13 +2156,13 @@ bool bvlc_address_from_ascii(BACNET_IP_ADDRESS *addr, const char *addrstr)
|
||||
return false;
|
||||
}
|
||||
if ((c == '.') || (c == 0) || (c == ' ')) {
|
||||
addr->address[i] = (uint8_t) tmp;
|
||||
addr->address[i] = (uint8_t)tmp;
|
||||
tmp = 0;
|
||||
} else if ((c >= '0') && (c <= '9')) {
|
||||
tmp = (tmp * 10) + (c - '0');
|
||||
if (tmp > UINT8_MAX) {
|
||||
if (tmp > UINT8_MAX) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@@ -2598,7 +2592,7 @@ const char *bvlc_result_code_name(uint16_t result_code)
|
||||
name = "Successful Completion";
|
||||
break;
|
||||
case BVLC_RESULT_WRITE_BROADCAST_DISTRIBUTION_TABLE_NAK:
|
||||
name= "Write-Broadcast-Distribution-Table NAK";
|
||||
name = "Write-Broadcast-Distribution-Table NAK";
|
||||
break;
|
||||
case BVLC_RESULT_READ_BROADCAST_DISTRIBUTION_TABLE_NAK:
|
||||
name = "Read-Broadcast-Distribution-Table NAK";
|
||||
@@ -2629,17 +2623,16 @@ const char *bvlc_result_code_name(uint16_t result_code)
|
||||
* @param ip_address - IP address and port number
|
||||
* @return length of the APDU buffer
|
||||
*/
|
||||
int bvlc_foreign_device_bbmd_host_address_encode(uint8_t *apdu,
|
||||
uint16_t apdu_size,
|
||||
BACNET_IP_ADDRESS *ip_address)
|
||||
int bvlc_foreign_device_bbmd_host_address_encode(
|
||||
uint8_t *apdu, uint16_t apdu_size, BACNET_IP_ADDRESS *ip_address)
|
||||
{
|
||||
BACNET_HOST_N_PORT address = { 0 };
|
||||
int apdu_len = 0;
|
||||
|
||||
address.host_ip_address = true;
|
||||
address.host_name = false;
|
||||
octetstring_init(&address.host.ip_address, &ip_address->address[0],
|
||||
IP_ADDRESS_MAX);
|
||||
octetstring_init(
|
||||
&address.host.ip_address, &ip_address->address[0], IP_ADDRESS_MAX);
|
||||
address.port = ip_address->port;
|
||||
apdu_len = host_n_port_encode(NULL, &address);
|
||||
if (apdu_len <= apdu_size) {
|
||||
@@ -2668,10 +2661,8 @@ int bvlc_foreign_device_bbmd_host_address_decode(uint8_t *apdu,
|
||||
if (len > 0) {
|
||||
if (address.host_ip_address) {
|
||||
ip_address->port = address.port;
|
||||
(void)octetstring_copy_value(
|
||||
&ip_address->address[0],
|
||||
IP_ADDRESS_MAX,
|
||||
&address.host.ip_address);
|
||||
(void)octetstring_copy_value(&ip_address->address[0],
|
||||
IP_ADDRESS_MAX, &address.host.ip_address);
|
||||
} else {
|
||||
len = BACNET_STATUS_REJECT;
|
||||
if (error_code) {
|
||||
|
||||
@@ -670,8 +670,7 @@ bool bvlc6_address_get(BACNET_IP6_ADDRESS *addr,
|
||||
* input, excluding the trailing null.
|
||||
* @note buf and buf_size may be null and zero to return only the size
|
||||
*/
|
||||
int bvlc6_address_to_ascii(BACNET_IP6_ADDRESS *addr, char *buf,
|
||||
size_t buf_size)
|
||||
int bvlc6_address_to_ascii(BACNET_IP6_ADDRESS *addr, char *buf, size_t buf_size)
|
||||
{
|
||||
uint16_t a;
|
||||
unsigned int i;
|
||||
@@ -685,7 +684,7 @@ int bvlc6_address_to_ascii(BACNET_IP6_ADDRESS *addr, char *buf,
|
||||
if (!buf) {
|
||||
return n;
|
||||
}
|
||||
for(i = 0; i < IP6_ADDRESS_MAX; i += 2) {
|
||||
for (i = 0; i < IP6_ADDRESS_MAX; i += 2) {
|
||||
a = (addr->address[i] << 8) + addr->address[i + 1];
|
||||
if ((a == 0) && (f >= 0)) {
|
||||
if (f++ == 0) {
|
||||
|
||||
@@ -86,8 +86,7 @@ uint32_t cobs_crc32k(uint8_t dataValue, uint32_t crc32kValue)
|
||||
* @return the length of the encoded data, or 0 if error
|
||||
* @note This function is copied mostly from the BACnet standard.
|
||||
*/
|
||||
size_t cobs_encode(
|
||||
uint8_t *buffer,
|
||||
size_t cobs_encode(uint8_t *buffer,
|
||||
size_t buffer_size,
|
||||
const uint8_t *from,
|
||||
size_t length,
|
||||
@@ -163,10 +162,7 @@ size_t cobs_encode(
|
||||
* @note This function is copied mostly from the BACnet standard.
|
||||
*/
|
||||
size_t cobs_frame_encode(
|
||||
uint8_t *buffer,
|
||||
size_t buffer_size,
|
||||
const uint8_t *from,
|
||||
size_t length)
|
||||
uint8_t *buffer, size_t buffer_size, const uint8_t *from, size_t length)
|
||||
{
|
||||
size_t cobs_data_len, cobs_crc_len;
|
||||
uint32_t crc32K;
|
||||
@@ -176,8 +172,8 @@ size_t cobs_frame_encode(
|
||||
/*
|
||||
* Prepare the Encoded Data field for transmission.
|
||||
*/
|
||||
cobs_data_len = cobs_encode(buffer, buffer_size, from, length,
|
||||
MSTP_PREAMBLE_X55);
|
||||
cobs_data_len =
|
||||
cobs_encode(buffer, buffer_size, from, length, MSTP_PREAMBLE_X55);
|
||||
if (cobs_data_len == 0) {
|
||||
return 0;
|
||||
}
|
||||
@@ -218,8 +214,7 @@ size_t cobs_frame_encode(
|
||||
* @return the length of the decoded buffer, or 0 if error
|
||||
* @note This function is copied directly from the BACnet standard.
|
||||
*/
|
||||
size_t cobs_decode(
|
||||
uint8_t *buffer,
|
||||
size_t cobs_decode(uint8_t *buffer,
|
||||
size_t buffer_size,
|
||||
const uint8_t *from,
|
||||
size_t length,
|
||||
@@ -282,10 +277,7 @@ size_t cobs_decode(
|
||||
* @note This function is copied directly from the BACnet standard.
|
||||
*/
|
||||
size_t cobs_frame_decode(
|
||||
uint8_t *buffer,
|
||||
size_t buffer_size,
|
||||
const uint8_t *from,
|
||||
size_t length)
|
||||
uint8_t *buffer, size_t buffer_size, const uint8_t *from, size_t length)
|
||||
{
|
||||
size_t data_len, crc_len;
|
||||
uint32_t crc32K;
|
||||
@@ -306,8 +298,8 @@ size_t cobs_frame_decode(
|
||||
/* See Clause G.3.1 */
|
||||
crc32K = cobs_crc32k(from[i], crc32K);
|
||||
}
|
||||
data_len = cobs_decode(buffer, buffer_size, from, data_len,
|
||||
MSTP_PREAMBLE_X55);
|
||||
data_len =
|
||||
cobs_decode(buffer, buffer_size, from, data_len, MSTP_PREAMBLE_X55);
|
||||
if (data_len == 0) {
|
||||
/* error during decode */
|
||||
return 0;
|
||||
@@ -315,8 +307,7 @@ size_t cobs_frame_decode(
|
||||
/*
|
||||
* Decode the Encoded CRC-32K field
|
||||
*/
|
||||
crc_len = cobs_decode(crc_buffer,
|
||||
sizeof(crc_buffer),
|
||||
crc_len = cobs_decode(crc_buffer, sizeof(crc_buffer),
|
||||
(uint8_t *)(from + length - COBS_ENCODED_CRC_SIZE),
|
||||
COBS_ENCODED_CRC_SIZE, MSTP_PREAMBLE_X55);
|
||||
/*
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#include "bacnet/basic/bbmd6/h_bbmd6.h"
|
||||
#include "bacnet/datalink/arcnet.h"
|
||||
#include "bacnet/datalink/dlmstp.h"
|
||||
#include <strings.h> /* for strcasecmp() */
|
||||
#include <strings.h> /* for strcasecmp() */
|
||||
|
||||
static enum {
|
||||
DATALINK_NONE = 0,
|
||||
@@ -114,24 +114,19 @@ int datalink_send_pdu(BACNET_ADDRESS *dest,
|
||||
bytes = pdu_len;
|
||||
break;
|
||||
case DATALINK_ARCNET:
|
||||
bytes = arcnet_send_pdu(
|
||||
dest, npdu_data, pdu, pdu_len);
|
||||
bytes = arcnet_send_pdu(dest, npdu_data, pdu, pdu_len);
|
||||
break;
|
||||
case DATALINK_ETHERNET:
|
||||
bytes = ethernet_send_pdu(
|
||||
dest, npdu_data, pdu, pdu_len);
|
||||
bytes = ethernet_send_pdu(dest, npdu_data, pdu, pdu_len);
|
||||
break;
|
||||
case DATALINK_BIP:
|
||||
bytes = bip_send_pdu(
|
||||
dest, npdu_data, pdu, pdu_len);
|
||||
bytes = bip_send_pdu(dest, npdu_data, pdu, pdu_len);
|
||||
break;
|
||||
case DATALINK_BIP6:
|
||||
bytes = bip6_send_pdu(
|
||||
dest, npdu_data, pdu, pdu_len);
|
||||
bytes = bip6_send_pdu(dest, npdu_data, pdu, pdu_len);
|
||||
break;
|
||||
case DATALINK_MSTP:
|
||||
bytes = dlmstp_send_pdu(
|
||||
dest, npdu_data, pdu, pdu_len);
|
||||
bytes = dlmstp_send_pdu(dest, npdu_data, pdu, pdu_len);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -149,24 +144,19 @@ uint16_t datalink_receive(
|
||||
case DATALINK_NONE:
|
||||
break;
|
||||
case DATALINK_ARCNET:
|
||||
bytes = arcnet_receive(
|
||||
src, pdu, max_pdu, timeout);
|
||||
bytes = arcnet_receive(src, pdu, max_pdu, timeout);
|
||||
break;
|
||||
case DATALINK_ETHERNET:
|
||||
bytes = ethernet_receive(
|
||||
src, pdu, max_pdu, timeout);
|
||||
bytes = ethernet_receive(src, pdu, max_pdu, timeout);
|
||||
break;
|
||||
case DATALINK_BIP:
|
||||
bytes = bip_receive(
|
||||
src, pdu, max_pdu, timeout);
|
||||
bytes = bip_receive(src, pdu, max_pdu, timeout);
|
||||
break;
|
||||
case DATALINK_BIP6:
|
||||
bytes = bip6_receive(
|
||||
src, pdu, max_pdu, timeout);
|
||||
bytes = bip6_receive(src, pdu, max_pdu, timeout);
|
||||
break;
|
||||
case DATALINK_MSTP:
|
||||
bytes = dlmstp_receive(
|
||||
src, pdu, max_pdu, timeout);
|
||||
bytes = dlmstp_receive(src, pdu, max_pdu, timeout);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -287,8 +287,8 @@ void dlenv_network_port_init(void)
|
||||
Network_Port_BBMD_FD_Table_Set(instance, bvlc_fdt_list());
|
||||
/* foreign device registration */
|
||||
bvlc_address_get(&BBMD_Address, &addr0, &addr1, &addr2, &addr3);
|
||||
Network_Port_Remote_BBMD_IP_Address_Set(instance,
|
||||
addr0, addr1, addr2, addr3);
|
||||
Network_Port_Remote_BBMD_IP_Address_Set(
|
||||
instance, addr0, addr1, addr2, addr3);
|
||||
Network_Port_Remote_BBMD_BIP_Port_Set(instance, BBMD_Address.port);
|
||||
Network_Port_Remote_BBMD_BIP_Lifetime_Set(instance, BBMD_TTL_Seconds);
|
||||
#endif
|
||||
|
||||
@@ -658,9 +658,9 @@ bool MSTP_Master_Node_FSM(volatile struct mstp_port_struct_t *mstp_port)
|
||||
break;
|
||||
case FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY:
|
||||
if ((mstp_port->DestinationAddress ==
|
||||
MSTP_BROADCAST_ADDRESS) &&
|
||||
MSTP_BROADCAST_ADDRESS) &&
|
||||
(npdu_confirmed_service(mstp_port->InputBuffer,
|
||||
mstp_port->DataLength))) {
|
||||
mstp_port->DataLength))) {
|
||||
/* BTL test: verifies that the IUT will quietly
|
||||
discard any Confirmed-Request-PDU, whose
|
||||
destination address is a multicast or
|
||||
|
||||
@@ -704,8 +704,8 @@ bacnet_time_t datetime_seconds_since_epoch(BACNET_DATE_TIME *bdatetime)
|
||||
* @param bdatetime [out] the starting date and time
|
||||
* @param seconds since epoch
|
||||
*/
|
||||
void datetime_since_epoch_seconds(BACNET_DATE_TIME *bdatetime,
|
||||
bacnet_time_t seconds)
|
||||
void datetime_since_epoch_seconds(
|
||||
BACNET_DATE_TIME *bdatetime, bacnet_time_t seconds)
|
||||
{
|
||||
uint32_t seconds_after_midnight = 0;
|
||||
uint32_t days = 0;
|
||||
|
||||
+1
-2
@@ -284,8 +284,7 @@ int dcc_decode_service_request(uint8_t *apdu,
|
||||
apdu_len_max - apdu_len, len_value_type, password);
|
||||
if (len > 0) {
|
||||
password_length = len_value_type - 1;
|
||||
if ((password_length >= 1) &&
|
||||
(password_length <= 20)) {
|
||||
if ((password_length >= 1) && (password_length <= 20)) {
|
||||
apdu_len += len;
|
||||
} else {
|
||||
return BACNET_STATUS_REJECT;
|
||||
|
||||
+98
-100
@@ -263,20 +263,18 @@ int event_notify_encode_service_request(
|
||||
|
||||
switch (data->notificationParams.commandFailure.tag) {
|
||||
case COMMAND_FAILURE_BINARY_PV:
|
||||
len =
|
||||
encode_application_enumerated(&apdu
|
||||
[apdu_len],
|
||||
data->notificationParams.commandFailure.
|
||||
commandValue.binaryValue);
|
||||
len = encode_application_enumerated(
|
||||
&apdu[apdu_len],
|
||||
data->notificationParams.commandFailure
|
||||
.commandValue.binaryValue);
|
||||
apdu_len += len;
|
||||
break;
|
||||
|
||||
case COMMAND_FAILURE_UNSIGNED:
|
||||
len =
|
||||
encode_application_unsigned(&apdu
|
||||
[apdu_len],
|
||||
data->notificationParams.commandFailure.
|
||||
commandValue.unsignedValue);
|
||||
encode_application_unsigned(&apdu[apdu_len],
|
||||
data->notificationParams.commandFailure
|
||||
.commandValue.unsignedValue);
|
||||
apdu_len += len;
|
||||
break;
|
||||
|
||||
@@ -287,10 +285,9 @@ int event_notify_encode_service_request(
|
||||
len = encode_closing_tag(&apdu[apdu_len], 0);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
encode_context_bitstring(&apdu[apdu_len], 1,
|
||||
&data->notificationParams.commandFailure.
|
||||
statusFlags);
|
||||
len = encode_context_bitstring(&apdu[apdu_len], 1,
|
||||
&data->notificationParams.commandFailure
|
||||
.statusFlags);
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_opening_tag(&apdu[apdu_len], 2);
|
||||
@@ -298,20 +295,18 @@ int event_notify_encode_service_request(
|
||||
|
||||
switch (data->notificationParams.commandFailure.tag) {
|
||||
case COMMAND_FAILURE_BINARY_PV:
|
||||
len =
|
||||
encode_application_enumerated(&apdu
|
||||
[apdu_len],
|
||||
data->notificationParams.commandFailure.
|
||||
feedbackValue.binaryValue);
|
||||
len = encode_application_enumerated(
|
||||
&apdu[apdu_len],
|
||||
data->notificationParams.commandFailure
|
||||
.feedbackValue.binaryValue);
|
||||
apdu_len += len;
|
||||
break;
|
||||
|
||||
case COMMAND_FAILURE_UNSIGNED:
|
||||
len =
|
||||
encode_application_unsigned(&apdu
|
||||
[apdu_len],
|
||||
data->notificationParams.commandFailure.
|
||||
feedbackValue.unsignedValue);
|
||||
encode_application_unsigned(&apdu[apdu_len],
|
||||
data->notificationParams.commandFailure
|
||||
.feedbackValue.unsignedValue);
|
||||
apdu_len += len;
|
||||
break;
|
||||
|
||||
@@ -454,43 +449,38 @@ int event_notify_encode_service_request(
|
||||
len = encode_opening_tag(&apdu[apdu_len], 13);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
encode_context_enumerated(&apdu[apdu_len], 0,
|
||||
len = encode_context_enumerated(&apdu[apdu_len], 0,
|
||||
data->notificationParams.accessEvent.accessEvent);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
encode_context_bitstring(&apdu[apdu_len], 1,
|
||||
len = encode_context_bitstring(&apdu[apdu_len], 1,
|
||||
&data->notificationParams.accessEvent.statusFlags);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
encode_context_unsigned(&apdu[apdu_len], 2,
|
||||
data->notificationParams.
|
||||
accessEvent.accessEventTag);
|
||||
len = encode_context_unsigned(&apdu[apdu_len], 2,
|
||||
data->notificationParams.accessEvent
|
||||
.accessEventTag);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
bacapp_encode_context_timestamp(&apdu[apdu_len], 3,
|
||||
&data->notificationParams.
|
||||
accessEvent.accessEventTime);
|
||||
&data->notificationParams.accessEvent
|
||||
.accessEventTime);
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
bacapp_encode_context_device_obj_ref(&apdu
|
||||
[apdu_len], 4,
|
||||
&data->notificationParams.
|
||||
accessEvent.accessCredential);
|
||||
len = bacapp_encode_context_device_obj_ref(
|
||||
&apdu[apdu_len], 4,
|
||||
&data->notificationParams.accessEvent
|
||||
.accessCredential);
|
||||
apdu_len += len;
|
||||
|
||||
if (data->notificationParams.
|
||||
accessEvent.authenticationFactor.format_type <
|
||||
if (data->notificationParams.accessEvent
|
||||
.authenticationFactor.format_type <
|
||||
AUTHENTICATION_FACTOR_MAX) {
|
||||
len =
|
||||
bacapp_encode_context_authentication_factor
|
||||
(&apdu[apdu_len], 5,
|
||||
&data->notificationParams.
|
||||
accessEvent.authenticationFactor);
|
||||
len = bacapp_encode_context_authentication_factor(
|
||||
&apdu[apdu_len], 5,
|
||||
&data->notificationParams.accessEvent
|
||||
.authenticationFactor);
|
||||
apdu_len += len;
|
||||
}
|
||||
|
||||
@@ -774,31 +764,31 @@ int event_notify_decode_service_request(
|
||||
}
|
||||
len++;
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_tag_number_and_value(&apdu[len],
|
||||
&tag_number, &len_value))) {
|
||||
if (-1 ==
|
||||
(section_length = decode_tag_number_and_value(
|
||||
&apdu[len], &tag_number, &len_value))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
|
||||
switch (tag_number) {
|
||||
case BACNET_APPLICATION_TAG_ENUMERATED:
|
||||
if (-1 == (section_length =
|
||||
decode_enumerated(&apdu[len],
|
||||
len_value,
|
||||
&enum_value))) {
|
||||
if (-1 ==
|
||||
(section_length = decode_enumerated(
|
||||
&apdu[len], len_value, &enum_value))) {
|
||||
return -1;
|
||||
}
|
||||
data->notificationParams.commandFailure.
|
||||
commandValue.binaryValue = enum_value;
|
||||
data->notificationParams.commandFailure
|
||||
.commandValue.binaryValue = enum_value;
|
||||
break;
|
||||
|
||||
case BACNET_APPLICATION_TAG_UNSIGNED_INT:
|
||||
if (-1 == (section_length =
|
||||
decode_unsigned(&apdu[len], len_value,
|
||||
&data->
|
||||
notificationParams.commandFailure.
|
||||
commandValue.unsignedValue))) {
|
||||
if (-1 ==
|
||||
(section_length = decode_unsigned(
|
||||
&apdu[len], len_value,
|
||||
&data->notificationParams
|
||||
.commandFailure.commandValue
|
||||
.unsignedValue))) {
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
@@ -813,10 +803,11 @@ int event_notify_decode_service_request(
|
||||
}
|
||||
len++;
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_bitstring(&apdu[len], 1,
|
||||
&data->notificationParams.commandFailure.
|
||||
statusFlags))) {
|
||||
if (-1 ==
|
||||
(section_length =
|
||||
decode_context_bitstring(&apdu[len], 1,
|
||||
&data->notificationParams.commandFailure
|
||||
.statusFlags))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
@@ -826,30 +817,31 @@ int event_notify_decode_service_request(
|
||||
}
|
||||
len++;
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_tag_number_and_value(&apdu[len],
|
||||
&tag_number, &len_value))) {
|
||||
if (-1 ==
|
||||
(section_length = decode_tag_number_and_value(
|
||||
&apdu[len], &tag_number, &len_value))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
|
||||
switch (tag_number) {
|
||||
case BACNET_APPLICATION_TAG_ENUMERATED:
|
||||
if (-1 == (section_length =
|
||||
decode_enumerated(&apdu[len], len_value,
|
||||
&enum_value))) {
|
||||
if (-1 ==
|
||||
(section_length = decode_enumerated(
|
||||
&apdu[len], len_value, &enum_value))) {
|
||||
return -1;
|
||||
}
|
||||
data->notificationParams.commandFailure.
|
||||
feedbackValue.binaryValue = enum_value;
|
||||
data->notificationParams.commandFailure
|
||||
.feedbackValue.binaryValue = enum_value;
|
||||
break;
|
||||
|
||||
case BACNET_APPLICATION_TAG_UNSIGNED_INT:
|
||||
if (-1 == (section_length =
|
||||
decode_unsigned(&apdu[len], len_value,
|
||||
&data->
|
||||
notificationParams.commandFailure.
|
||||
feedbackValue.unsignedValue))) {
|
||||
if (-1 ==
|
||||
(section_length = decode_unsigned(
|
||||
&apdu[len], len_value,
|
||||
&data->notificationParams
|
||||
.commandFailure.feedbackValue
|
||||
.unsignedValue))) {
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
@@ -1057,53 +1049,59 @@ int event_notify_decode_service_request(
|
||||
break;
|
||||
|
||||
case EVENT_ACCESS_EVENT:
|
||||
if (-1 == (section_length =
|
||||
decode_context_enumerated(&apdu[len], 0,
|
||||
&enum_value))) {
|
||||
if (-1 ==
|
||||
(section_length = decode_context_enumerated(
|
||||
&apdu[len], 0, &enum_value))) {
|
||||
return -1;
|
||||
}
|
||||
data->notificationParams.accessEvent.accessEvent =
|
||||
enum_value;
|
||||
len += section_length;
|
||||
if (-1 == (section_length =
|
||||
decode_context_bitstring(&apdu[len], 1,
|
||||
&data->notificationParams.
|
||||
accessEvent.statusFlags))) {
|
||||
if (-1 ==
|
||||
(section_length =
|
||||
decode_context_bitstring(&apdu[len], 1,
|
||||
&data->notificationParams.accessEvent
|
||||
.statusFlags))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
|
||||
if (-1 == (section_length =
|
||||
decode_context_unsigned(&apdu[len], 2,
|
||||
&data->notificationParams.
|
||||
accessEvent.accessEventTag))) {
|
||||
if (-1 ==
|
||||
(section_length =
|
||||
decode_context_unsigned(&apdu[len], 2,
|
||||
&data->notificationParams.accessEvent
|
||||
.accessEventTag))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
|
||||
if (-1 == (section_length =
|
||||
bacapp_decode_context_timestamp(&apdu[len], 3,
|
||||
&data->notificationParams.
|
||||
accessEvent.accessEventTime))) {
|
||||
if (-1 ==
|
||||
(section_length = bacapp_decode_context_timestamp(
|
||||
&apdu[len], 3,
|
||||
&data->notificationParams.accessEvent
|
||||
.accessEventTime))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
|
||||
if (-1 == (section_length =
|
||||
bacapp_decode_context_device_obj_ref(&apdu
|
||||
[len], 4,
|
||||
&data->notificationParams.
|
||||
accessEvent.accessCredential))) {
|
||||
if (-1 ==
|
||||
(section_length =
|
||||
bacapp_decode_context_device_obj_ref(
|
||||
&apdu[len], 4,
|
||||
&data->notificationParams.accessEvent
|
||||
.accessCredential))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
|
||||
if (!decode_is_closing_tag(&apdu[len])) {
|
||||
if (-1 == (section_length =
|
||||
bacapp_decode_context_authentication_factor
|
||||
(&apdu[len], 5,
|
||||
&data->notificationParams.
|
||||
accessEvent.authenticationFactor))) {
|
||||
if (-1 ==
|
||||
(section_length =
|
||||
bacapp_decode_context_authentication_factor(
|
||||
&apdu[len], 5,
|
||||
&data->notificationParams
|
||||
.accessEvent
|
||||
.authenticationFactor))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
|
||||
+24
-39
@@ -38,8 +38,7 @@
|
||||
* @param address - IP address and port number
|
||||
* @return length of the encoded APDU buffer
|
||||
*/
|
||||
int host_n_port_encode(uint8_t *apdu,
|
||||
BACNET_HOST_N_PORT *address)
|
||||
int host_n_port_encode(uint8_t *apdu, BACNET_HOST_N_PORT *address)
|
||||
{
|
||||
int len = 0;
|
||||
int apdu_len = 0;
|
||||
@@ -54,15 +53,16 @@ int host_n_port_encode(uint8_t *apdu,
|
||||
if (apdu) {
|
||||
apdu_offset = &apdu[apdu_len];
|
||||
}
|
||||
len = encode_context_octet_string(apdu_offset, 1, &address->host.ip_address);
|
||||
len = encode_context_octet_string(
|
||||
apdu_offset, 1, &address->host.ip_address);
|
||||
apdu_len += len;
|
||||
} else if (address->host_name) {
|
||||
/* CHOICE - name [2] CharacterString */
|
||||
if (apdu) {
|
||||
apdu_offset = &apdu[apdu_len];
|
||||
}
|
||||
len = encode_context_character_string(apdu_offset, 1,
|
||||
&address->host.name);
|
||||
len = encode_context_character_string(
|
||||
apdu_offset, 1, &address->host.name);
|
||||
apdu_len += len;
|
||||
} else {
|
||||
/* none */
|
||||
@@ -77,8 +77,7 @@ int host_n_port_encode(uint8_t *apdu,
|
||||
if (apdu) {
|
||||
apdu_offset = &apdu[apdu_len];
|
||||
}
|
||||
len = encode_context_unsigned(
|
||||
apdu_offset, 1, address->port);
|
||||
len = encode_context_unsigned(apdu_offset, 1, address->port);
|
||||
apdu_len += len;
|
||||
}
|
||||
|
||||
@@ -93,9 +92,7 @@ int host_n_port_encode(uint8_t *apdu,
|
||||
* @return length of the APDU buffer, or 0 if not able to encode
|
||||
*/
|
||||
int host_n_port_context_encode(
|
||||
uint8_t * apdu,
|
||||
uint8_t tag_number,
|
||||
BACNET_HOST_N_PORT *address)
|
||||
uint8_t *apdu, uint8_t tag_number, BACNET_HOST_N_PORT *address)
|
||||
{
|
||||
int len = 0;
|
||||
int apdu_len = 0;
|
||||
@@ -171,8 +168,8 @@ int host_n_port_decode(uint8_t *apdu,
|
||||
if (len > apdu_len) {
|
||||
return BACNET_STATUS_REJECT;
|
||||
}
|
||||
len += decode_tag_number_and_value(
|
||||
&apdu[len], &tag_number, &len_value_type);
|
||||
len +=
|
||||
decode_tag_number_and_value(&apdu[len], &tag_number, &len_value_type);
|
||||
if (tag_number == 0) {
|
||||
/* CHOICE - none [0] NULL */
|
||||
address->host_ip_address = false;
|
||||
@@ -181,23 +178,20 @@ int host_n_port_decode(uint8_t *apdu,
|
||||
/* CHOICE - ip-address [1] OCTET STRING */
|
||||
address->host_ip_address = true;
|
||||
address->host_name = false;
|
||||
len += decode_octet_string(&apdu[len], len_value_type,
|
||||
&octet_string);
|
||||
len += decode_octet_string(&apdu[len], len_value_type, &octet_string);
|
||||
if (len > apdu_len) {
|
||||
return BACNET_STATUS_REJECT;
|
||||
}
|
||||
(void)octetstring_copy(&address->host.ip_address,
|
||||
&octet_string);
|
||||
(void)octetstring_copy(&address->host.ip_address, &octet_string);
|
||||
} else if (tag_number == 2) {
|
||||
address->host_ip_address = false;
|
||||
address->host_name = true;
|
||||
len += decode_character_string(&apdu[len], len_value_type,
|
||||
&char_string);
|
||||
len +=
|
||||
decode_character_string(&apdu[len], len_value_type, &char_string);
|
||||
if (len > apdu_len) {
|
||||
return BACNET_STATUS_REJECT;
|
||||
}
|
||||
(void)characterstring_copy(&address->host.name,
|
||||
&char_string);
|
||||
(void)characterstring_copy(&address->host.name, &char_string);
|
||||
} else {
|
||||
if (error_code) {
|
||||
*error_code = ERROR_CODE_REJECT_INVALID_TAG;
|
||||
@@ -215,8 +209,8 @@ int host_n_port_decode(uint8_t *apdu,
|
||||
return BACNET_STATUS_REJECT;
|
||||
}
|
||||
/* port [1] Unsigned16 */
|
||||
len += decode_tag_number_and_value(
|
||||
&apdu[len], &tag_number, &len_value_type);
|
||||
len +=
|
||||
decode_tag_number_and_value(&apdu[len], &tag_number, &len_value_type);
|
||||
if (tag_number != 1) {
|
||||
if (error_code) {
|
||||
*error_code = ERROR_CODE_REJECT_INVALID_TAG;
|
||||
@@ -245,9 +239,7 @@ int host_n_port_decode(uint8_t *apdu,
|
||||
* @param src - source structure
|
||||
* @return true if successfully copied
|
||||
*/
|
||||
bool host_n_port_copy(
|
||||
BACNET_HOST_N_PORT * dst,
|
||||
BACNET_HOST_N_PORT * src)
|
||||
bool host_n_port_copy(BACNET_HOST_N_PORT *dst, BACNET_HOST_N_PORT *src)
|
||||
{
|
||||
bool status = false;
|
||||
|
||||
@@ -255,13 +247,10 @@ bool host_n_port_copy(
|
||||
dst->host_ip_address = src->host_ip_address;
|
||||
dst->host_name = src->host_name;
|
||||
if (src->host_ip_address) {
|
||||
status = octetstring_copy(
|
||||
&dst->host.ip_address,
|
||||
&src->host.ip_address);
|
||||
status =
|
||||
octetstring_copy(&dst->host.ip_address, &src->host.ip_address);
|
||||
} else if (src->host_name) {
|
||||
status = characterstring_copy(
|
||||
&dst->host.name,
|
||||
&src->host.name);
|
||||
status = characterstring_copy(&dst->host.name, &src->host.name);
|
||||
} else {
|
||||
status = true;
|
||||
}
|
||||
@@ -277,9 +266,7 @@ bool host_n_port_copy(
|
||||
* @param host2 - host 2 structure
|
||||
* @return true if successfully copied
|
||||
*/
|
||||
bool host_n_port_same(
|
||||
BACNET_HOST_N_PORT * host1,
|
||||
BACNET_HOST_N_PORT * host2)
|
||||
bool host_n_port_same(BACNET_HOST_N_PORT *host1, BACNET_HOST_N_PORT *host2)
|
||||
{
|
||||
bool status = false;
|
||||
|
||||
@@ -288,12 +275,10 @@ bool host_n_port_same(
|
||||
(host1->host_name == host2->host_name)) {
|
||||
if (host1->host_ip_address) {
|
||||
status = octetstring_value_same(
|
||||
&host1->host.ip_address,
|
||||
&host2->host.ip_address);
|
||||
&host1->host.ip_address, &host2->host.ip_address);
|
||||
} else if (host1->host_name) {
|
||||
status = characterstring_same(
|
||||
&host1->host.name,
|
||||
&host2->host.name);
|
||||
status =
|
||||
characterstring_same(&host1->host.name, &host2->host.name);
|
||||
} else {
|
||||
status = true;
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ int lighting_command_decode(
|
||||
uint32_t len_value_type = 0;
|
||||
uint32_t enum_value = 0;
|
||||
BACNET_UNSIGNED_INTEGER unsigned_value = 0;
|
||||
BACNET_LIGHTING_OPERATION operation= BACNET_LIGHTS_NONE;
|
||||
BACNET_LIGHTING_OPERATION operation = BACNET_LIGHTS_NONE;
|
||||
float real_value = 0.0;
|
||||
|
||||
/* check for value pointers */
|
||||
|
||||
+1
-3
@@ -537,9 +537,7 @@ int bacnet_npdu_decode(uint8_t *npdu,
|
||||
* @param pdu_len [in] The size of the received message in the pdu[] buffer.
|
||||
* @return true if the PDU is a confirmed APDU
|
||||
*/
|
||||
bool npdu_confirmed_service(
|
||||
uint8_t *pdu,
|
||||
uint16_t pdu_len)
|
||||
bool npdu_confirmed_service(uint8_t *pdu, uint16_t pdu_len)
|
||||
{
|
||||
bool status = false;
|
||||
int apdu_offset = 0;
|
||||
|
||||
@@ -398,16 +398,15 @@ static const int CharacterString_Value_Properties_Optional[] = {
|
||||
PROP_PROFILE_LOCATION, PROP_PROFILE_NAME, -1
|
||||
};
|
||||
|
||||
static const int Color_Properties_Required[] = {
|
||||
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
|
||||
PROP_PRESENT_VALUE, PROP_TRACKING_VALUE, PROP_COLOR_COMMAND,
|
||||
PROP_IN_PROGRESS, PROP_DEFAULT_COLOR, PROP_DEFAULT_FADE_TIME, -1
|
||||
};
|
||||
static const int Color_Properties_Required[] = { PROP_OBJECT_IDENTIFIER,
|
||||
PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_PRESENT_VALUE, PROP_TRACKING_VALUE,
|
||||
PROP_COLOR_COMMAND, PROP_IN_PROGRESS, PROP_DEFAULT_COLOR,
|
||||
PROP_DEFAULT_FADE_TIME, -1 };
|
||||
|
||||
static const int Color_Properties_Optional[] = { PROP_RELIABILITY,
|
||||
PROP_DESCRIPTION, PROP_TRANSITION, PROP_VALUE_SOURCE,
|
||||
PROP_AUDIT_LEVEL, PROP_AUDITABLE_OPERATIONS, PROP_TAGS,
|
||||
PROP_PROFILE_LOCATION, PROP_PROFILE_NAME, -1 };
|
||||
PROP_DESCRIPTION, PROP_TRANSITION, PROP_VALUE_SOURCE, PROP_AUDIT_LEVEL,
|
||||
PROP_AUDITABLE_OPERATIONS, PROP_TAGS, PROP_PROFILE_LOCATION,
|
||||
PROP_PROFILE_NAME, -1 };
|
||||
|
||||
static const int Credential_Data_Input_Properties_Required[] = {
|
||||
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
|
||||
|
||||
@@ -263,8 +263,8 @@ int property_list_encode(BACNET_READ_PROPERTY_DATA *rpdata,
|
||||
* @return number of APDU bytes in the response, or
|
||||
* BACNET_STATUS_ERROR on error.
|
||||
*/
|
||||
int property_list_common_encode(BACNET_READ_PROPERTY_DATA *rpdata,
|
||||
uint32_t device_instance_number)
|
||||
int property_list_common_encode(
|
||||
BACNET_READ_PROPERTY_DATA *rpdata, uint32_t device_instance_number)
|
||||
{
|
||||
int apdu_len = BACNET_STATUS_ERROR;
|
||||
uint8_t *apdu = NULL;
|
||||
|
||||
@@ -284,8 +284,7 @@ bool bacapp_timestamp_init_ascii(BACNET_TIMESTAMP *timestamp, const char *ascii)
|
||||
int sequence;
|
||||
int count = 0;
|
||||
|
||||
count = sscanf(
|
||||
ascii, "%3d:%3d:%3d.%3d", &hour, &min, &sec, &hundredths);
|
||||
count = sscanf(ascii, "%3d:%3d:%3d.%3d", &hour, &min, &sec, &hundredths);
|
||||
if (count == 4) {
|
||||
timestamp->tag = TIME_STAMP_TIME;
|
||||
timestamp->value.time.hour = (uint8_t)hour;
|
||||
@@ -309,13 +308,12 @@ bool bacapp_timestamp_init_ascii(BACNET_TIMESTAMP *timestamp, const char *ascii)
|
||||
status = true;
|
||||
}
|
||||
if (!status) {
|
||||
count =
|
||||
sscanf(ascii, "%4d/%3d/%3d-%3d:%3d:%3d.%3d",
|
||||
&year, &month, &day, &hour, &min, &sec, &hundredths);
|
||||
count = sscanf(ascii, "%4d/%3d/%3d-%3d:%3d:%3d.%3d", &year, &month,
|
||||
&day, &hour, &min, &sec, &hundredths);
|
||||
if (count >= 3) {
|
||||
timestamp->tag = TIME_STAMP_DATETIME;
|
||||
datetime_set_date(×tamp->value.dateTime.date,
|
||||
(uint16_t)year, (uint8_t)month, (uint8_t)day);
|
||||
datetime_set_date(×tamp->value.dateTime.date, (uint16_t)year,
|
||||
(uint8_t)month, (uint8_t)day);
|
||||
if (count >= 7) {
|
||||
datetime_set_time(×tamp->value.dateTime.time,
|
||||
(uint8_t)hour, (uint8_t)min, (uint8_t)sec,
|
||||
@@ -327,8 +325,8 @@ bool bacapp_timestamp_init_ascii(BACNET_TIMESTAMP *timestamp, const char *ascii)
|
||||
datetime_set_time(×tamp->value.dateTime.time,
|
||||
(uint8_t)hour, (uint8_t)min, 0, 0);
|
||||
} else if (count >= 4) {
|
||||
datetime_set_time(×tamp->value.dateTime.time,
|
||||
(uint8_t)hour, 0, 0, 0);
|
||||
datetime_set_time(
|
||||
×tamp->value.dateTime.time, (uint8_t)hour, 0, 0, 0);
|
||||
} else {
|
||||
datetime_set_time(×tamp->value.dateTime.time, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@@ -341,7 +341,7 @@ int timesync_decode_timesync_recipients(
|
||||
}
|
||||
if (!decode_is_closing_tag_number(&apdu[apdu_len], 1)) {
|
||||
return BACNET_STATUS_ABORT;
|
||||
}
|
||||
}
|
||||
apdu_len += 1;
|
||||
} else {
|
||||
return BACNET_STATUS_ABORT;
|
||||
|
||||
+19
-20
@@ -38,9 +38,7 @@ License.
|
||||
#include "bacapp.h"
|
||||
|
||||
int bacnet_weeklyschedule_decode(
|
||||
uint8_t * apdu,
|
||||
int max_apdu_len,
|
||||
BACNET_WEEKLY_SCHEDULE *value)
|
||||
uint8_t *apdu, int max_apdu_len, BACNET_WEEKLY_SCHEDULE *value)
|
||||
{
|
||||
int len = 0;
|
||||
int apdu_len = 0;
|
||||
@@ -48,8 +46,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_decode(&apdu[apdu_len],
|
||||
max_apdu_len - apdu_len, &value->weeklySchedule[wi]);
|
||||
if (len < 0) {
|
||||
if (wi == 1) {
|
||||
value->singleDay = true;
|
||||
@@ -62,9 +60,7 @@ int bacnet_weeklyschedule_decode(
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int bacnet_weeklyschedule_encode(
|
||||
uint8_t * apdu,
|
||||
BACNET_WEEKLY_SCHEDULE *value)
|
||||
int bacnet_weeklyschedule_encode(uint8_t *apdu, BACNET_WEEKLY_SCHEDULE *value)
|
||||
{
|
||||
int apdu_len = 0;
|
||||
int len = 0;
|
||||
@@ -76,8 +72,8 @@ int bacnet_weeklyschedule_encode(
|
||||
if (apdu) {
|
||||
apdu_offset = &apdu[apdu_len];
|
||||
}
|
||||
len =
|
||||
bacnet_dailyschedule_encode(apdu_offset, &value->weeklySchedule[wi]);
|
||||
len = bacnet_dailyschedule_encode(
|
||||
apdu_offset, &value->weeklySchedule[wi]);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
apdu_len += len;
|
||||
@@ -85,8 +81,6 @@ int bacnet_weeklyschedule_encode(
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Encode a context tagged WeeklySchedule complex data type
|
||||
* @param apdu - the APDU buffer
|
||||
@@ -120,26 +114,31 @@ int bacnet_weeklyschedule_context_encode(
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int bacnet_weeklyschedule_context_decode(
|
||||
uint8_t *apdu, int max_apdu_len, uint8_t tag_number,
|
||||
int bacnet_weeklyschedule_context_decode(uint8_t *apdu,
|
||||
int max_apdu_len,
|
||||
uint8_t tag_number,
|
||||
BACNET_WEEKLY_SCHEDULE *value)
|
||||
{
|
||||
int apdu_len = 0;
|
||||
int len;
|
||||
|
||||
if ((max_apdu_len - apdu_len) >= 1 && decode_is_opening_tag_number(&apdu[apdu_len], tag_number)) {
|
||||
if ((max_apdu_len - apdu_len) >= 1 &&
|
||||
decode_is_opening_tag_number(&apdu[apdu_len], tag_number)) {
|
||||
apdu_len += 1;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (-1 == (len = bacnet_weeklyschedule_decode(&apdu[apdu_len], max_apdu_len - apdu_len, value))) {
|
||||
if (-1 ==
|
||||
(len = bacnet_weeklyschedule_decode(
|
||||
&apdu[apdu_len], max_apdu_len - apdu_len, value))) {
|
||||
return -1;
|
||||
} else {
|
||||
apdu_len += len;
|
||||
}
|
||||
|
||||
if ((max_apdu_len - apdu_len) >= 1 && decode_is_closing_tag_number(&apdu[apdu_len], tag_number)) {
|
||||
if ((max_apdu_len - apdu_len) >= 1 &&
|
||||
decode_is_closing_tag_number(&apdu[apdu_len], tag_number)) {
|
||||
apdu_len += 1;
|
||||
} else {
|
||||
return -1;
|
||||
@@ -170,14 +169,14 @@ bool bacnet_weeklyschedule_same(
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO the conversion can be avoided by adding a "primitive" variant of bacapp_same_value(),
|
||||
// TODO the conversion can be avoided by adding a "primitive"
|
||||
// variant of bacapp_same_value(),
|
||||
// at the cost of some code duplication
|
||||
BACNET_APPLICATION_DATA_VALUE adv1, adv2;
|
||||
bacnet_primitive_to_application_data_value(&adv1, &tv1->Value);
|
||||
bacnet_primitive_to_application_data_value(&adv2, &tv2->Value);
|
||||
|
||||
if (!bacapp_same_value(&adv1, &adv2))
|
||||
{
|
||||
if (!bacapp_same_value(&adv1, &adv2)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+7
-10
@@ -205,9 +205,8 @@ int wp_decode_service_request(
|
||||
* @param value - #BACNET_APPLICATION_DATA_VALUE data, for the tag
|
||||
* @param expected_tag - the tag that is expected for this property value
|
||||
*/
|
||||
bool write_property_type_valid(
|
||||
BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
BACNET_APPLICATION_DATA_VALUE * value,
|
||||
bool write_property_type_valid(BACNET_WRITE_PROPERTY_DATA *wp_data,
|
||||
BACNET_APPLICATION_DATA_VALUE *value,
|
||||
uint8_t expected_tag)
|
||||
{
|
||||
/* assume success */
|
||||
@@ -231,9 +230,8 @@ bool write_property_type_valid(
|
||||
* @param value - #BACNET_APPLICATION_DATA_VALUE data, for the tag
|
||||
* @param expected_tag - the tag that is expected for this property value
|
||||
*/
|
||||
bool write_property_string_valid(
|
||||
BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
BACNET_APPLICATION_DATA_VALUE * value,
|
||||
bool write_property_string_valid(BACNET_WRITE_PROPERTY_DATA *wp_data,
|
||||
BACNET_APPLICATION_DATA_VALUE *value,
|
||||
int len_max)
|
||||
{
|
||||
bool valid = false;
|
||||
@@ -247,7 +245,7 @@ bool write_property_string_valid(
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
}
|
||||
} else if (!characterstring_printable(
|
||||
&value->type.Character_String)) {
|
||||
&value->type.Character_String)) {
|
||||
/* assumption: non-empty also means must be "printable" */
|
||||
if (wp_data) {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
@@ -287,9 +285,8 @@ bool write_property_string_valid(
|
||||
* @param value - #BACNET_APPLICATION_DATA_VALUE data, for the tag
|
||||
* @param expected_tag - the tag that is expected for this property value
|
||||
*/
|
||||
bool write_property_empty_string_valid(
|
||||
BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
BACNET_APPLICATION_DATA_VALUE * value,
|
||||
bool write_property_empty_string_valid(BACNET_WRITE_PROPERTY_DATA *wp_data,
|
||||
BACNET_APPLICATION_DATA_VALUE *value,
|
||||
int len_max)
|
||||
{
|
||||
bool valid = false;
|
||||
|
||||
+2
-2
@@ -485,8 +485,8 @@ int wpm_error_ack_decode_apdu(
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
len = bacerror_decode_error_class_and_code(apdu_offset, apdu_size,
|
||||
&error_class, &error_code);
|
||||
len = bacerror_decode_error_class_and_code(
|
||||
apdu_offset, apdu_size, &error_class, &error_code);
|
||||
if (len > 0) {
|
||||
if (wp_data) {
|
||||
wp_data->error_class = error_class;
|
||||
|
||||
Reference in New Issue
Block a user