mirror of
https://github.com/stargieg/bacnet-stack
synced 2025-10-19 23:25:23 +08:00
[3126] NC added/corrected validation and also parse Priority as array
This commit is contained in:
parent
e8332aa9d2
commit
ae96a1b852
|
|
@ -797,9 +797,10 @@ bool Notification_Class_Write_Property(
|
|||
NOTIFICATION_CLASS_DESCR *CurrentNC;
|
||||
NOTIFICATION_CLASS_DESCR TmpNotify;
|
||||
BACNET_APPLICATION_DATA_VALUE value;
|
||||
uint8_t TmpPriority[MAX_BACNET_EVENT_TRANSITION]; /* BACnetARRAY[3] of Unsigned */
|
||||
bool status = false;
|
||||
int iOffset = 0;
|
||||
uint8_t idx = 0;
|
||||
int iOffset;
|
||||
uint8_t idx;
|
||||
int len = 0;
|
||||
unsigned index = 0;
|
||||
int object_type = 0;
|
||||
|
|
@ -882,14 +883,50 @@ bool Notification_Class_Write_Property(
|
|||
if (wp_data->array_index == 0) {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_INVALID_ARRAY_INDEX;
|
||||
status = false;
|
||||
} else if (wp_data->array_index == BACNET_ARRAY_ALL) {
|
||||
/* FIXME: wite all array */
|
||||
iOffset = 0;
|
||||
for (idx = 0; idx < MAX_BACNET_EVENT_TRANSITION; idx++)
|
||||
{
|
||||
len =
|
||||
bacapp_decode_application_data(&wp_data->
|
||||
application_data[iOffset], wp_data->application_data_len,
|
||||
&value);
|
||||
if ((len == 0) ||
|
||||
(value.tag != BACNET_APPLICATION_TAG_UNSIGNED_INT))
|
||||
{
|
||||
/* Bad decode, wrong tag or following required parameter missing */
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_INVALID_DATA_TYPE;
|
||||
status = false;
|
||||
break;
|
||||
}
|
||||
if (value.type.Unsigned_Int > 255) {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
status = false;
|
||||
break;
|
||||
}
|
||||
TmpPriority[idx] = (uint8_t) value.type.Unsigned_Int;
|
||||
iOffset += len;
|
||||
}
|
||||
if (status == true) {
|
||||
for (idx = 0; idx < MAX_BACNET_EVENT_TRANSITION; idx++)
|
||||
CurrentNotify->Priority[idx] = TmpPriority[idx];
|
||||
}
|
||||
} else if (wp_data->array_index <= 3) {
|
||||
if (value.type.Unsigned_Int > 255) {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
status = false;
|
||||
}
|
||||
else
|
||||
CurrentNC->Priority[wp_data->array_index - 1] =
|
||||
value.type.Unsigned_Int;
|
||||
} else {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_INVALID_ARRAY_INDEX;
|
||||
status = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
@ -920,6 +957,8 @@ bool Notification_Class_Write_Property(
|
|||
if (!ctx)
|
||||
fprintf(stderr, "Failed to open config file bacnet_nc\n");
|
||||
#endif
|
||||
idx = 0;
|
||||
iOffset = 0;
|
||||
/* decode all packed */
|
||||
while (iOffset < wp_data->application_data_len) {
|
||||
/* Decode Valid Days */
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user