now using simple ack handler for the write

This commit is contained in:
bigjohngoulah
2005-12-18 00:37:16 +00:00
parent 1f34710f24
commit de586de7a6
5 changed files with 24 additions and 76 deletions
+19
View File
@@ -562,6 +562,25 @@ bool Device_Write_Property(
}
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:
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
+4 -11
View File
@@ -273,7 +273,8 @@ bool Send_Write_Property_Request(
&dest, // destination address
&Tx_Buf[0],
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
fprintf(stderr,"Failed to Send WriteProperty Request (%s)!\n",
strerror(errno));
@@ -558,19 +559,11 @@ void ReadPropertyHandler(
}
void WritePropertyAckHandler(
uint8_t *service_request,
uint16_t service_len,
BACNET_ADDRESS *src,
BACNET_CONFIRMED_SERVICE_ACK_DATA *service_data)
uint8_t invoke_id)
{
int len = 0;
BACNET_WRITE_PROPERTY_DATA data;
(void)src;
len = wp_ack_decode_service_request(
service_request,
service_len,
&data);
tsm_free_invoke_id(invoke_id);
fprintf(stderr,"Received Write-Property Ack!\n");
}
+1 -3
View File
@@ -68,10 +68,8 @@ void ReadPropertyHandler(
BACNET_CONFIRMED_SERVICE_DATA *service_data);
void WritePropertyAckHandler(
uint8_t *service_request,
uint16_t service_len,
BACNET_ADDRESS *src,
BACNET_CONFIRMED_SERVICE_ACK_DATA *service_data);
uint8_t invoke_id);
void WritePropertyHandler(
uint8_t *service_request,
-58
View File
@@ -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;
}
-4
View File
@@ -71,10 +71,6 @@ int wp_decode_apdu(
uint8_t *invoke_id,
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
#include "ctest.h"