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:
tbrennan3
2011-09-19 13:06:55 +00:00
parent 7b3a6b3465
commit 24bea2eb82
2 changed files with 25 additions and 20 deletions
+15 -1
View File
@@ -108,6 +108,14 @@ int rpm_encode_apdu_object_end(
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(
uint8_t * apdu,
size_t max_apdu,
@@ -328,12 +336,18 @@ int rpm_ack_encode_apdu_object_begin(
BACNET_RPM_DATA * rpmdata)
{
int apdu_len = 0; /* total length of the apdu, return value */
uint32_t obj_instance = rpmdata->object_instance;
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 */
apdu_len =
encode_context_object_id(&apdu[0], 0, rpmdata->object_type,
rpmdata->object_instance);
obj_instance);
/* Tag 1: listOfResults */
apdu_len += encode_opening_tag(&apdu[apdu_len], 1);
}