Fix You-Are-Request encoding and decoding to use object-id instead of unsigned. (#1220)
This commit is contained in:
+9
-8
@@ -64,7 +64,7 @@ int you_are_request_encode(
|
||||
apdu += len;
|
||||
}
|
||||
if (device_id < BACNET_MAX_INSTANCE) {
|
||||
len = encode_application_unsigned(apdu, device_id);
|
||||
len = encode_application_object_id(apdu, OBJECT_DEVICE, device_id);
|
||||
apdu_len += len;
|
||||
if (apdu) {
|
||||
apdu += len;
|
||||
@@ -148,6 +148,8 @@ int you_are_request_decode(
|
||||
{
|
||||
int len = 0, apdu_len = 0;
|
||||
BACNET_UNSIGNED_INTEGER unsigned_value = 0;
|
||||
BACNET_OBJECT_TYPE object_type;
|
||||
uint32_t object_instance;
|
||||
|
||||
if (!apdu) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
@@ -183,17 +185,16 @@ int you_are_request_decode(
|
||||
} else {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
len = bacnet_unsigned_application_decode(
|
||||
&apdu[apdu_len], apdu_size - apdu_len, &unsigned_value);
|
||||
len = bacnet_object_id_application_decode(
|
||||
&apdu[apdu_len], apdu_size - apdu_len, &object_type, &object_instance);
|
||||
if (len > 0) {
|
||||
apdu_len += len;
|
||||
if (unsigned_value <= UINT32_MAX) {
|
||||
if (device_id) {
|
||||
*device_id = (uint32_t)unsigned_value;
|
||||
}
|
||||
} else {
|
||||
if (object_type != OBJECT_DEVICE) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
if (device_id) {
|
||||
*device_id = object_instance;
|
||||
}
|
||||
} else if (len == 0) {
|
||||
/* optional - skip apdu_len increment */
|
||||
if (device_id) {
|
||||
|
||||
Reference in New Issue
Block a user