Handle the case where Device ID is BACNET_MAX_INSTANCE: for RP and RPM, put the real device ID in the response.
This commit is contained in:
+10
-19
@@ -147,16 +147,23 @@ int rp_ack_encode_apdu_init(
|
|||||||
{
|
{
|
||||||
int len = 0; /* length of each encoding */
|
int len = 0; /* length of each encoding */
|
||||||
int apdu_len = 0; /* total length of the apdu, return value */
|
int apdu_len = 0; /* total length of the apdu, return value */
|
||||||
|
uint32_t obj_instance = rpdata->object_instance;
|
||||||
|
|
||||||
if (apdu) {
|
if (apdu) {
|
||||||
apdu[0] = PDU_TYPE_COMPLEX_ACK; /* complex ACK service */
|
apdu[0] = PDU_TYPE_COMPLEX_ACK; /* complex ACK service */
|
||||||
apdu[1] = invoke_id; /* original invoke id from request */
|
apdu[1] = invoke_id; /* original invoke id from request */
|
||||||
apdu[2] = SERVICE_CONFIRMED_READ_PROPERTY; /* service choice */
|
apdu[2] = SERVICE_CONFIRMED_READ_PROPERTY; /* service choice */
|
||||||
apdu_len = 3;
|
apdu_len = 3;
|
||||||
|
|
||||||
|
/* Test for case of indefinite Device object instance */
|
||||||
|
if ( (rpdata->object_type == OBJECT_DEVICE) &&
|
||||||
|
(obj_instance == BACNET_MAX_INSTANCE) )
|
||||||
|
obj_instance = Device_Object_Instance_Number();
|
||||||
|
|
||||||
/* service ack follows */
|
/* service ack follows */
|
||||||
len =
|
len =
|
||||||
encode_context_object_id(&apdu[apdu_len], 0, rpdata->object_type,
|
encode_context_object_id(&apdu[apdu_len], 0, rpdata->object_type,
|
||||||
rpdata->object_instance);
|
obj_instance);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
len =
|
len =
|
||||||
encode_context_enumerated(&apdu[apdu_len], 1,
|
encode_context_enumerated(&apdu[apdu_len], 1,
|
||||||
@@ -198,25 +205,9 @@ int rp_ack_encode_apdu(
|
|||||||
int apdu_len = 0; /* total length of the apdu, return value */
|
int apdu_len = 0; /* total length of the apdu, return value */
|
||||||
|
|
||||||
if (apdu) {
|
if (apdu) {
|
||||||
apdu[0] = PDU_TYPE_COMPLEX_ACK; /* complex ACK service */
|
/* Do the initial encoding */
|
||||||
apdu[1] = invoke_id; /* original invoke id from request */
|
apdu_len = rp_ack_encode_apdu_init(apdu, invoke_id, rpdata);
|
||||||
apdu[2] = SERVICE_CONFIRMED_READ_PROPERTY; /* service choice */
|
|
||||||
apdu_len = 3;
|
|
||||||
/* service ack follows */
|
|
||||||
apdu_len +=
|
|
||||||
encode_context_object_id(&apdu[apdu_len], 0, rpdata->object_type,
|
|
||||||
rpdata->object_instance);
|
|
||||||
apdu_len +=
|
|
||||||
encode_context_enumerated(&apdu[apdu_len], 1,
|
|
||||||
rpdata->object_property);
|
|
||||||
/* context 2 array index is optional */
|
|
||||||
if (rpdata->array_index != BACNET_ARRAY_ALL) {
|
|
||||||
apdu_len +=
|
|
||||||
encode_context_unsigned(&apdu[apdu_len], 2,
|
|
||||||
rpdata->array_index);
|
|
||||||
}
|
|
||||||
/* propertyValue */
|
/* propertyValue */
|
||||||
apdu_len += encode_opening_tag(&apdu[apdu_len], 3);
|
|
||||||
for (len = 0; len < rpdata->application_data_len; len++) {
|
for (len = 0; len < rpdata->application_data_len; len++) {
|
||||||
apdu[apdu_len++] = rpdata->application_data[len];
|
apdu[apdu_len++] = rpdata->application_data[len];
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-1
@@ -108,6 +108,14 @@ int rpm_encode_apdu_object_end(
|
|||||||
return apdu_len;
|
return apdu_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Encode an RPM request, to be sent.
|
||||||
|
*
|
||||||
|
* @param apdu [in,out] Buffer to hold encoded bytes.
|
||||||
|
* @param max_apdu [in] Length of apdu buffer.
|
||||||
|
* @param invoke_id [in] The Invoke ID to use for this message.
|
||||||
|
* @param read_access_data [in] The RPM data to be requested.
|
||||||
|
* @return Length of encoded bytes, or 0 on failure.
|
||||||
|
*/
|
||||||
int rpm_encode_apdu(
|
int rpm_encode_apdu(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
size_t max_apdu,
|
size_t max_apdu,
|
||||||
@@ -328,12 +336,18 @@ int rpm_ack_encode_apdu_object_begin(
|
|||||||
BACNET_RPM_DATA * rpmdata)
|
BACNET_RPM_DATA * rpmdata)
|
||||||
{
|
{
|
||||||
int apdu_len = 0; /* total length of the apdu, return value */
|
int apdu_len = 0; /* total length of the apdu, return value */
|
||||||
|
uint32_t obj_instance = rpmdata->object_instance;
|
||||||
|
|
||||||
if (apdu) {
|
if (apdu) {
|
||||||
|
/* Test for case of indefinite Device object instance */
|
||||||
|
if ( (rpmdata->object_type == OBJECT_DEVICE) &&
|
||||||
|
(obj_instance == BACNET_MAX_INSTANCE) )
|
||||||
|
obj_instance = Device_Object_Instance_Number();
|
||||||
|
|
||||||
/* Tag 0: objectIdentifier */
|
/* Tag 0: objectIdentifier */
|
||||||
apdu_len =
|
apdu_len =
|
||||||
encode_context_object_id(&apdu[0], 0, rpmdata->object_type,
|
encode_context_object_id(&apdu[0], 0, rpmdata->object_type,
|
||||||
rpmdata->object_instance);
|
obj_instance);
|
||||||
/* Tag 1: listOfResults */
|
/* Tag 1: listOfResults */
|
||||||
apdu_len += encode_opening_tag(&apdu[apdu_len], 1);
|
apdu_len += encode_opening_tag(&apdu[apdu_len], 1);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user