now using simple ack handler for the write
This commit is contained in:
@@ -562,6 +562,25 @@ bool Device_Write_Property(
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PROP_OBJECT_NAME:
|
||||||
|
if (wp_data->value.tag == BACNET_APPLICATION_TAG_CHARACTER_STRING)
|
||||||
|
{
|
||||||
|
BACNET_CHARACTER_STRING Character_String = wp_data->value.type.Character_String;
|
||||||
|
|
||||||
|
char decoded_string[MAX_APDU] = { "" };
|
||||||
|
int decoded = 0;
|
||||||
|
//decoded = decode_character_string(&data->application_data[tag_len], len_value_type, &decoded_string[0], sizeof(decoded_string));
|
||||||
|
|
||||||
|
//Device_Set_Vendor_Name(const char *name);
|
||||||
|
status = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*error_class = ERROR_CLASS_PROPERTY;
|
||||||
|
*error_code = ERROR_CODE_INVALID_DATA_TYPE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
*error_class = ERROR_CLASS_PROPERTY;
|
*error_class = ERROR_CLASS_PROPERTY;
|
||||||
*error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
|
*error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
|
||||||
|
|||||||
+4
-11
@@ -273,7 +273,8 @@ bool Send_Write_Property_Request(
|
|||||||
&dest, // destination address
|
&dest, // destination address
|
||||||
&Tx_Buf[0],
|
&Tx_Buf[0],
|
||||||
pdu_len); // number of bytes of data
|
pdu_len); // number of bytes of data
|
||||||
if (bytes_sent > 0);// fprintf(stderr,"Sent ReadProperty Request!\n");
|
if (bytes_sent > 0)
|
||||||
|
fprintf(stderr,"Sent ReadProperty Request!\n");
|
||||||
else
|
else
|
||||||
fprintf(stderr,"Failed to Send WriteProperty Request (%s)!\n",
|
fprintf(stderr,"Failed to Send WriteProperty Request (%s)!\n",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
@@ -558,19 +559,11 @@ void ReadPropertyHandler(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void WritePropertyAckHandler(
|
void WritePropertyAckHandler(
|
||||||
uint8_t *service_request,
|
|
||||||
uint16_t service_len,
|
|
||||||
BACNET_ADDRESS *src,
|
BACNET_ADDRESS *src,
|
||||||
BACNET_CONFIRMED_SERVICE_ACK_DATA *service_data)
|
uint8_t invoke_id)
|
||||||
{
|
{
|
||||||
int len = 0;
|
|
||||||
BACNET_WRITE_PROPERTY_DATA data;
|
|
||||||
|
|
||||||
(void)src;
|
(void)src;
|
||||||
len = wp_ack_decode_service_request(
|
tsm_free_invoke_id(invoke_id);
|
||||||
service_request,
|
|
||||||
service_len,
|
|
||||||
&data);
|
|
||||||
fprintf(stderr,"Received Write-Property Ack!\n");
|
fprintf(stderr,"Received Write-Property Ack!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,10 +68,8 @@ void ReadPropertyHandler(
|
|||||||
BACNET_CONFIRMED_SERVICE_DATA *service_data);
|
BACNET_CONFIRMED_SERVICE_DATA *service_data);
|
||||||
|
|
||||||
void WritePropertyAckHandler(
|
void WritePropertyAckHandler(
|
||||||
uint8_t *service_request,
|
|
||||||
uint16_t service_len,
|
|
||||||
BACNET_ADDRESS *src,
|
BACNET_ADDRESS *src,
|
||||||
BACNET_CONFIRMED_SERVICE_ACK_DATA *service_data);
|
uint8_t invoke_id);
|
||||||
|
|
||||||
void WritePropertyHandler(
|
void WritePropertyHandler(
|
||||||
uint8_t *service_request,
|
uint8_t *service_request,
|
||||||
|
|||||||
@@ -183,64 +183,6 @@ int wp_decode_apdu(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int wp_ack_decode_service_request(
|
|
||||||
uint8_t *apdu,
|
|
||||||
int apdu_len, // total length of the apdu
|
|
||||||
BACNET_WRITE_PROPERTY_DATA *data)
|
|
||||||
{
|
|
||||||
uint8_t tag_number = 0;
|
|
||||||
uint32_t len_value_type = 0;
|
|
||||||
int tag_len = 0; // length of tag decode
|
|
||||||
int len = 0; // total length of decodes
|
|
||||||
int object = 0, property = 0; // for decoding
|
|
||||||
unsigned array_value = 0; // for decoding
|
|
||||||
|
|
||||||
// FIXME: check apdu_len against the len during decode
|
|
||||||
// Tag 0: Object ID
|
|
||||||
if (!decode_is_context_tag(&apdu[0], 0))
|
|
||||||
return -1;
|
|
||||||
len = 1;
|
|
||||||
len += decode_object_id(&apdu[len],
|
|
||||||
&object, &data->object_instance);
|
|
||||||
data->object_type = object;
|
|
||||||
// Tag 1: Property ID
|
|
||||||
len += decode_tag_number_and_value(&apdu[len],
|
|
||||||
&tag_number, &len_value_type);
|
|
||||||
if (tag_number != 1)
|
|
||||||
return -1;
|
|
||||||
len += decode_enumerated(&apdu[len],
|
|
||||||
len_value_type,
|
|
||||||
&property);
|
|
||||||
data->object_property = property;
|
|
||||||
// Tag 2: Optional Array Index
|
|
||||||
tag_len = decode_tag_number_and_value(&apdu[len],
|
|
||||||
&tag_number, &len_value_type);
|
|
||||||
if (tag_number == 2)
|
|
||||||
{
|
|
||||||
len += tag_len;
|
|
||||||
len += decode_unsigned(&apdu[len],
|
|
||||||
len_value_type, &array_value);
|
|
||||||
data->array_index = array_value;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
data->array_index = BACNET_ARRAY_ALL;
|
|
||||||
|
|
||||||
// Tag 3: opening context tag */
|
|
||||||
/*
|
|
||||||
if (decode_is_opening_tag_number(&apdu[len], 3))
|
|
||||||
{
|
|
||||||
// a tag number of 3 is not extended so only one octet
|
|
||||||
len++;
|
|
||||||
// don't decode the application tag number or its data here
|
|
||||||
data->application_data = &apdu[len];
|
|
||||||
data->application_data_len = apdu_len - len - 1; //closing tag
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return -1;
|
|
||||||
*/
|
|
||||||
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -71,10 +71,6 @@ int wp_decode_apdu(
|
|||||||
uint8_t *invoke_id,
|
uint8_t *invoke_id,
|
||||||
BACNET_WRITE_PROPERTY_DATA *data);
|
BACNET_WRITE_PROPERTY_DATA *data);
|
||||||
|
|
||||||
int wp_ack_decode_service_request(
|
|
||||||
uint8_t *apdu,
|
|
||||||
int apdu_len, // total length of the apdu
|
|
||||||
BACNET_WRITE_PROPERTY_DATA *data);
|
|
||||||
|
|
||||||
#ifdef TEST
|
#ifdef TEST
|
||||||
#include "ctest.h"
|
#include "ctest.h"
|
||||||
|
|||||||
Reference in New Issue
Block a user