diff --git a/bacnet-stack/bacapp.c b/bacnet-stack/bacapp.c index b82e466f..2fb6afbd 100644 --- a/bacnet-stack/bacapp.c +++ b/bacnet-stack/bacapp.c @@ -210,8 +210,6 @@ int bacapp_decode_context_data(uint8_t * apdu, int tag_len = 0; uint8_t tag_number = 0; uint32_t len_value_type = 0; - int object_type = 0; - uint32_t instance = 0; /* FIXME: use max_apdu_len! */ (void) max_apdu_len; diff --git a/bacnet-stack/demo/handler/s_wp.c b/bacnet-stack/demo/handler/s_wp.c index ab960943..3586b7d5 100644 --- a/bacnet-stack/demo/handler/s_wp.c +++ b/bacnet-stack/demo/handler/s_wp.c @@ -80,7 +80,9 @@ uint8_t Send_Write_Property_Request(uint32_t device_id, /* destination device */ data.object_instance = object_instance; data.object_property = object_property; data.array_index = array_index; - bacapp_copy(&data.value, object_value); + data.application_data_len = + bacapp_encode_application_data( + &data.application_data[0],object_value); data.priority = priority; len = wp_encode_apdu(&Handler_Transmit_Buffer[pdu_len], invoke_id, &data); diff --git a/bacnet-stack/demo/object/bacfile.c b/bacnet-stack/demo/object/bacfile.c index 941de60f..3f7324f3 100644 --- a/bacnet-stack/demo/object/bacfile.c +++ b/bacnet-stack/demo/object/bacfile.c @@ -30,6 +30,7 @@ #include "config.h" #include "address.h" #include "bacdef.h" +#include "bacapp.h" #include "datalink.h" #include "bacdcode.h" #include "npdu.h" @@ -221,6 +222,8 @@ bool bacfile_write_property(BACNET_WRITE_PROPERTY_DATA * wp_data, BACNET_ERROR_CLASS * error_class, BACNET_ERROR_CODE * error_code) { bool status = false; /* return value */ + int len = 0; + BACNET_APPLICATION_DATA_VALUE value; if (!bacfile_valid_instance(wp_data->object_instance)) { *error_class = ERROR_CLASS_OBJECT; @@ -229,6 +232,12 @@ bool bacfile_write_property(BACNET_WRITE_PROPERTY_DATA * wp_data, } /* decode the some of the request */ + len = bacapp_decode_application_data( + wp_data->application_data, + wp_data->application_data_len, + &value); + /* FIXME: len < application_data_len: more data? */ + /* FIXME: len == 0: unable to decode? */ switch (wp_data->object_property) { case PROP_ARCHIVE: /* 12.13.8 Archive @@ -237,8 +246,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. */ - if (wp_data->value.tag == BACNET_APPLICATION_TAG_BOOLEAN) { - if (wp_data->value.type.Boolean) { + if (value.tag == BACNET_APPLICATION_TAG_BOOLEAN) { + if (value.type.Boolean) { /* FIXME: do something to wp_data->object_instance */ } else { /* FIXME: do something to wp_data->object_instance */ @@ -252,8 +261,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. */ - if (wp_data->value.tag == BACNET_APPLICATION_TAG_UNSIGNED_INT) { - /* FIXME: do something with wp_data->value.type.Unsigned + if (value.tag == BACNET_APPLICATION_TAG_UNSIGNED_INT) { + /* FIXME: do something with value.type.Unsigned to wp_data->object_instance */ } else { *error_class = ERROR_CLASS_PROPERTY; diff --git a/bacnet-stack/demo/object/device.c b/bacnet-stack/demo/object/device.c index 160ca3f6..dff7d0ae 100644 --- a/bacnet-stack/demo/object/device.c +++ b/bacnet-stack/demo/object/device.c @@ -854,10 +854,9 @@ bool Device_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data, Character_String); if (encoding == CHARACTER_ANSI_X34) { status = - Device_Set_Object_Name(characterstring_value(&wp_data-> - value.type.Character_String), - characterstring_length(&value.type. - Character_String)); + Device_Set_Object_Name( + characterstring_value(&value.type.Character_String), + characterstring_length(&value.type.Character_String)); if (!status) { *error_class = ERROR_CLASS_PROPERTY; *error_code = ERROR_CODE_NO_SPACE_TO_WRITE_PROPERTY; diff --git a/bacnet-stack/wp.c b/bacnet-stack/wp.c index 0c6a6c4d..69006074 100644 --- a/bacnet-stack/wp.c +++ b/bacnet-stack/wp.c @@ -97,6 +97,7 @@ int wp_decode_service_request(uint8_t * apdu, int type = 0; /* for decoding */ int property = 0; /* for decoding */ uint32_t unsigned_value = 0; + int i = 0; /* loop counter */ /* check for value pointers */ if (apdu_len && data) { @@ -131,6 +132,10 @@ int wp_decode_service_request(uint8_t * apdu, apdu_len-len, property); /* a tag number of 3 is not extended so only one octet */ len++; + /* copy the data from the APDU */ + for (i = 0; i < data->application_data_len; i++) { + data->application_data[i] = apdu[len+i]; + } /* add on the data length */ len += data->application_data_len; if (!decode_is_closing_tag_number(&apdu[len], 3)) diff --git a/bacnet-stack/wp.h b/bacnet-stack/wp.h index edc0eb22..57614039 100644 --- a/bacnet-stack/wp.h +++ b/bacnet-stack/wp.h @@ -48,7 +48,7 @@ typedef struct BACnet_Write_Property_Data { uint32_t object_instance; BACNET_PROPERTY_ID object_property; int32_t array_index; /* use BACNET_ARRAY_ALL when not setting */ - uint8_t *application_data; + uint8_t application_data[MAX_APDU]; int application_data_len; uint8_t priority; /* use BACNET_NO_PRIORITY if no priority */ } BACNET_WRITE_PROPERTY_DATA;