Moved Device object dependency to the demo handlers.

This commit is contained in:
skarg
2011-10-03 22:24:57 +00:00
parent ed4a72ed0a
commit 9c1f651458
4 changed files with 17 additions and 18 deletions
+5
View File
@@ -117,6 +117,11 @@ void handler_read_property(
rpdata.application_data = &Handler_Transmit_Buffer[npdu_len + apdu_len]; rpdata.application_data = &Handler_Transmit_Buffer[npdu_len + apdu_len];
rpdata.application_data_len = rpdata.application_data_len =
sizeof(Handler_Transmit_Buffer) - (npdu_len + apdu_len); sizeof(Handler_Transmit_Buffer) - (npdu_len + apdu_len);
/* Test for case of indefinite Device object instance */
if ((rpdata.object_type == OBJECT_DEVICE) &&
(rpdata.object_instance == BACNET_MAX_INSTANCE)) {
rpdata.object_instance = Device_Object_Instance_Number();
}
len = Device_Read_Property(&rpdata); len = Device_Read_Property(&rpdata);
if (len >= 0) { if (len >= 0) {
apdu_len += len; apdu_len += len;
+5
View File
@@ -126,6 +126,11 @@ static int RPM_Encode_Property(
len = 0; len = 0;
rpdata.error_class = ERROR_CLASS_OBJECT; rpdata.error_class = ERROR_CLASS_OBJECT;
rpdata.error_code = ERROR_CODE_UNKNOWN_OBJECT; rpdata.error_code = ERROR_CODE_UNKNOWN_OBJECT;
/* Test for case of indefinite Device object instance */
if ((rpmdata->object_type == OBJECT_DEVICE) &&
(rpmdata->object_instance == BACNET_MAX_INSTANCE)) {
rpmdata->object_instance = Device_Object_Instance_Number();
}
rpdata.object_type = rpmdata->object_type; rpdata.object_type = rpmdata->object_type;
rpdata.object_instance = rpmdata->object_instance; rpdata.object_instance = rpmdata->object_instance;
rpdata.object_property = rpmdata->object_property; rpdata.object_property = rpmdata->object_property;
+4 -9
View File
@@ -147,7 +147,6 @@ 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 */
@@ -155,15 +154,11 @@ int rp_ack_encode_apdu_init(
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,
obj_instance); rpdata->object_type,
rpdata->object_instance);
apdu_len += len; apdu_len += len;
len = len =
encode_context_enumerated(&apdu[apdu_len], 1, encode_context_enumerated(&apdu[apdu_len], 1,
@@ -205,7 +200,7 @@ 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) {
/* Do the initial encoding */ /* Do the initial encoding */
apdu_len = rp_ack_encode_apdu_init(apdu, invoke_id, rpdata); apdu_len = rp_ack_encode_apdu_init(apdu, invoke_id, rpdata);
/* propertyValue */ /* propertyValue */
for (len = 0; len < rpdata->application_data_len; len++) { for (len = 0; len < rpdata->application_data_len; len++) {
+1 -7
View File
@@ -336,18 +336,12 @@ 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,
obj_instance); rpmdata->object_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);
} }