Bugfix/ucov-timestamp-handler-and-notification (#1030)
* Added the ability for apps/ucov to send property specific application tagged data using -1 argument for tag. * Added known property decoding in UnconfirmedCOVNotification handler.
This commit is contained in:
@@ -5050,6 +5050,148 @@ int bacapp_property_value_decode(
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decode one BACnetPropertyValue value for a specific object type
|
||||
*
|
||||
* BACnetPropertyValue ::= SEQUENCE {
|
||||
* property-identifier [0] BACnetPropertyIdentifier,
|
||||
* property-array-index [1] Unsigned OPTIONAL,
|
||||
* -- used only with array datatypes
|
||||
* -- if omitted with an array the entire array is referenced
|
||||
* property-value [2] ABSTRACT-SYNTAX.&Type,
|
||||
* -- any datatype appropriate for the specified property
|
||||
* priority [3] Unsigned (1..16) OPTIONAL
|
||||
* -- used only when property is commandable
|
||||
* }
|
||||
*
|
||||
* @param apdu Pointer to the buffer of encoded value
|
||||
* @param apdu_size Size of the buffer holding the encode value
|
||||
* @param value Pointer to the service data used for encoding values
|
||||
*
|
||||
* @return Bytes decoded or BACNET_STATUS_ERROR on error.
|
||||
*/
|
||||
int bacapp_object_property_value_decode(
|
||||
const uint8_t *apdu,
|
||||
uint32_t apdu_size,
|
||||
BACNET_PROPERTY_VALUE *value,
|
||||
BACNET_OBJECT_TYPE object_type)
|
||||
{
|
||||
int len = 0;
|
||||
int apdu_len = 0;
|
||||
int tag_len = 0;
|
||||
uint32_t enumerated_value = 0;
|
||||
uint32_t len_value_type = 0;
|
||||
BACNET_UNSIGNED_INTEGER unsigned_value = 0;
|
||||
BACNET_PROPERTY_ID property_identifier = PROP_ALL;
|
||||
uint32_t array_index = BACNET_ARRAY_ALL;
|
||||
BACNET_APPLICATION_DATA_VALUE *app_data = NULL;
|
||||
|
||||
/* property-identifier [0] BACnetPropertyIdentifier */
|
||||
len = bacnet_enumerated_context_decode(
|
||||
&apdu[apdu_len], apdu_size - apdu_len, 0, &enumerated_value);
|
||||
if (len > 0) {
|
||||
property_identifier = enumerated_value;
|
||||
if (value) {
|
||||
value->propertyIdentifier = property_identifier;
|
||||
}
|
||||
apdu_len += len;
|
||||
} else {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
/* property-array-index [1] Unsigned OPTIONAL */
|
||||
if (bacnet_is_context_tag_number(
|
||||
&apdu[apdu_len], apdu_size - apdu_len, 1, &len, &len_value_type)) {
|
||||
apdu_len += len;
|
||||
len = bacnet_unsigned_decode(
|
||||
&apdu[apdu_len], apdu_size - apdu_len, len_value_type,
|
||||
&unsigned_value);
|
||||
if (len > 0) {
|
||||
if (unsigned_value > UINT32_MAX) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
} else {
|
||||
apdu_len += len;
|
||||
if (value) {
|
||||
value->propertyArrayIndex = unsigned_value;
|
||||
array_index = value->propertyArrayIndex;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
} else {
|
||||
if (value) {
|
||||
value->propertyArrayIndex = BACNET_ARRAY_ALL;
|
||||
}
|
||||
}
|
||||
/* property-value [2] ABSTRACT-SYNTAX.&Type */
|
||||
if (bacnet_is_opening_tag_number(
|
||||
&apdu[apdu_len], apdu_size - apdu_len, 2, &len)) {
|
||||
if (value) {
|
||||
apdu_len += len;
|
||||
app_data = &value->value;
|
||||
while (app_data != NULL) {
|
||||
len = bacapp_decode_known_array_property(
|
||||
&apdu[apdu_len], apdu_size - apdu_len, app_data,
|
||||
object_type, property_identifier, array_index);
|
||||
if (len < 0) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
apdu_len += len;
|
||||
if (bacnet_is_closing_tag_number(
|
||||
&apdu[apdu_len], apdu_size - apdu_len, 2, &len)) {
|
||||
break;
|
||||
}
|
||||
app_data = app_data->next;
|
||||
}
|
||||
} else {
|
||||
/* this len function needs to start at the opening tag
|
||||
to match opening/closing tags like a stack.
|
||||
However, it returns the len between the tags.
|
||||
Therefore, store the length of the opening tag first */
|
||||
tag_len = len;
|
||||
len = bacnet_enclosed_data_length(
|
||||
&apdu[apdu_len], apdu_size - apdu_len);
|
||||
apdu_len += len;
|
||||
/* add the opening tag length to the totals */
|
||||
apdu_len += tag_len;
|
||||
}
|
||||
if (bacnet_is_closing_tag_number(
|
||||
&apdu[apdu_len], apdu_size - apdu_len, 2, &len)) {
|
||||
apdu_len += len;
|
||||
} else {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
} else {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
/* priority [3] Unsigned (1..16) OPTIONAL */
|
||||
if (bacnet_is_context_tag_number(
|
||||
&apdu[apdu_len], apdu_size - apdu_len, 3, &len, &len_value_type)) {
|
||||
apdu_len += len;
|
||||
len = bacnet_unsigned_decode(
|
||||
&apdu[apdu_len], apdu_size - apdu_len, len_value_type,
|
||||
&unsigned_value);
|
||||
if (len > 0) {
|
||||
if (unsigned_value > UINT8_MAX) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
} else {
|
||||
apdu_len += len;
|
||||
if (value) {
|
||||
value->priority = unsigned_value;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
} else {
|
||||
if (value) {
|
||||
value->priority = BACNET_NO_PRIORITY;
|
||||
}
|
||||
}
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
/* generic - can be used by other unit tests
|
||||
returns true if matching or same, false if different */
|
||||
bool bacapp_same_value(
|
||||
|
||||
@@ -243,6 +243,12 @@ int bacapp_property_value_encode(
|
||||
BACNET_STACK_EXPORT
|
||||
int bacapp_property_value_decode(
|
||||
const uint8_t *apdu, uint32_t apdu_size, BACNET_PROPERTY_VALUE *value);
|
||||
BACNET_STACK_EXPORT
|
||||
int bacapp_object_property_value_decode(
|
||||
const uint8_t *apdu,
|
||||
uint32_t apdu_size,
|
||||
BACNET_PROPERTY_VALUE *value,
|
||||
BACNET_OBJECT_TYPE object_type);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int bacapp_encode_data(
|
||||
|
||||
+2
-2
@@ -264,8 +264,8 @@ int cov_notify_decode_service_request(
|
||||
/* the first value includes a pointer to the next value, etc */
|
||||
value = data->listOfValues;
|
||||
while (value != NULL) {
|
||||
value_len = bacapp_property_value_decode(
|
||||
&apdu[len], apdu_size - len, value);
|
||||
value_len = bacapp_object_property_value_decode(
|
||||
&apdu[len], apdu_size - len, value, decoded_type);
|
||||
if (value_len == BACNET_STATUS_ERROR) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user