added ReadPropertyMultiple client demo application, bacrpm.
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
#include "bacdcode.h"
|
||||
#include "bacdef.h"
|
||||
#include "bacapp.h"
|
||||
#include "memcopy.h"
|
||||
#include "rpm.h"
|
||||
|
||||
/* encode the initial portion of the service */
|
||||
@@ -105,6 +106,75 @@ int rpm_encode_apdu_object_end(
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int rpm_encode_apdu(
|
||||
uint8_t * apdu,
|
||||
size_t max_apdu,
|
||||
uint8_t invoke_id,
|
||||
BACNET_READ_ACCESS_DATA *read_access_data)
|
||||
{
|
||||
int apdu_len = 0; /* total length of the apdu, return value */
|
||||
int len = 0; /* length of the data */
|
||||
BACNET_READ_ACCESS_DATA *rpm_object; /* current object */
|
||||
uint8_t apdu_temp[16]; /* temp for data before copy */
|
||||
BACNET_PROPERTY_REFERENCE *rpm_property; /* current property */
|
||||
|
||||
len = rpm_encode_apdu_init(&apdu_temp[0], invoke_id);
|
||||
len = memcopy(&apdu[0], &apdu_temp[0], apdu_len, len, max_apdu);
|
||||
if (len == 0) {
|
||||
return 0;
|
||||
}
|
||||
apdu_len += len;
|
||||
rpm_object = read_access_data;
|
||||
while (rpm_object) {
|
||||
len = encode_context_object_id(&apdu_temp[0], 0,
|
||||
rpm_object->object_type,
|
||||
rpm_object->object_instance);
|
||||
len = memcopy(&apdu[0], &apdu_temp[0], apdu_len, len, max_apdu);
|
||||
if (len == 0) {
|
||||
return 0;
|
||||
}
|
||||
apdu_len += len;
|
||||
/* Tag 1: sequence of ReadAccessSpecification */
|
||||
len = encode_opening_tag(&apdu_temp[0], 1);
|
||||
len = memcopy(&apdu[0], &apdu_temp[0], apdu_len, len, max_apdu);
|
||||
if (len == 0) {
|
||||
return 0;
|
||||
}
|
||||
apdu_len += len;
|
||||
rpm_property = rpm_object->listOfProperties;
|
||||
while (rpm_property) {
|
||||
/* stuff as many properties into it as APDU length will allow */
|
||||
len = encode_context_enumerated(&apdu_temp[0], 0,
|
||||
rpm_property->propertyIdentifier);
|
||||
len = memcopy(&apdu[0], &apdu_temp[0], apdu_len, len, max_apdu);
|
||||
if (len == 0) {
|
||||
return 0;
|
||||
}
|
||||
apdu_len += len;
|
||||
/* optional array index */
|
||||
if (rpm_property->propertyArrayIndex != BACNET_ARRAY_ALL) {
|
||||
len = encode_context_unsigned(&apdu_temp[0], 1,
|
||||
rpm_property->propertyArrayIndex);
|
||||
len = memcopy(&apdu[0], &apdu_temp[0], apdu_len, len, max_apdu);
|
||||
if (len == 0) {
|
||||
return 0;
|
||||
}
|
||||
apdu_len += len;
|
||||
}
|
||||
rpm_property = rpm_property->next;
|
||||
}
|
||||
len = encode_closing_tag(&apdu_temp[0], 1);
|
||||
len = memcopy(&apdu[0], &apdu_temp[0], apdu_len, len, max_apdu);
|
||||
if (len == 0) {
|
||||
return 0;
|
||||
}
|
||||
apdu_len += len;
|
||||
rpm_object = rpm_object->next;
|
||||
}
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
/* decode the object portion of the service request only */
|
||||
int rpm_decode_object_id(
|
||||
uint8_t * apdu,
|
||||
|
||||
Reference in New Issue
Block a user