Simplified write property code using new validation helper functions in h_wp.c.
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
#include "wp.h"
|
||||
#include "cov.h"
|
||||
#include "config.h" /* the custom stuff */
|
||||
#include "handlers.h"
|
||||
|
||||
#define MAX_BINARY_INPUTS 5
|
||||
|
||||
@@ -394,7 +395,7 @@ bool Binary_Input_Write_Property(
|
||||
/* FIXME: len == 0: unable to decode? */
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_PRESENT_VALUE:
|
||||
if (value.tag == BACNET_APPLICATION_TAG_ENUMERATED) {
|
||||
if(WPValidateArgType(&value, BACNET_APPLICATION_TAG_ENUMERATED, error_class, error_code) == true) {
|
||||
if (value.type.Enumerated <= MAX_BINARY_PV) {
|
||||
Binary_Input_Present_Value_Set(wp_data->object_instance,
|
||||
(BACNET_BINARY_PV) value.type.Enumerated);
|
||||
@@ -403,19 +404,12 @@ bool Binary_Input_Write_Property(
|
||||
*error_class = ERROR_CLASS_PROPERTY;
|
||||
*error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
}
|
||||
} else {
|
||||
*error_class = ERROR_CLASS_PROPERTY;
|
||||
*error_code = ERROR_CODE_INVALID_DATA_TYPE;
|
||||
}
|
||||
break;
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
if (value.tag == BACNET_APPLICATION_TAG_BOOLEAN) {
|
||||
if((status = WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN, error_class, error_code)) == true) {
|
||||
Binary_Input_Out_Of_Service_Set(wp_data->object_instance,
|
||||
value.type.Boolean);
|
||||
status = true;
|
||||
} else {
|
||||
*error_class = ERROR_CLASS_PROPERTY;
|
||||
*error_code = ERROR_CODE_INVALID_DATA_TYPE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user