Refactored ReadPropertyMultiple handler.
This commit is contained in:
+150
-238
@@ -52,6 +52,139 @@
|
|||||||
|
|
||||||
static uint8_t Temp_Buf[MAX_APDU] = { 0 };
|
static uint8_t Temp_Buf[MAX_APDU] = { 0 };
|
||||||
|
|
||||||
|
/* Encodes the property APDU and returns the length,
|
||||||
|
or sets the error, and returns -1 */
|
||||||
|
int Encode_Property_APDU(
|
||||||
|
uint8_t * apdu,
|
||||||
|
BACNET_OBJECT_TYPE object_type,
|
||||||
|
uint32_t object_instance,
|
||||||
|
BACNET_PROPERTY_ID property,
|
||||||
|
int32_t array_index,
|
||||||
|
BACNET_ERROR_CLASS * error_class,
|
||||||
|
BACNET_ERROR_CODE * error_code)
|
||||||
|
{
|
||||||
|
int apdu_len = -1;
|
||||||
|
|
||||||
|
/* initialize the default return values */
|
||||||
|
*error_class = ERROR_CLASS_OBJECT;
|
||||||
|
*error_code = ERROR_CODE_UNKNOWN_OBJECT;
|
||||||
|
/* handle each object type */
|
||||||
|
switch(object_type) {
|
||||||
|
case OBJECT_DEVICE:
|
||||||
|
if ((object_instance == Device_Object_Instance_Number()) ||
|
||||||
|
(object_instance == BACNET_MAX_INSTANCE)) {
|
||||||
|
apdu_len = Device_Encode_Property_APDU(
|
||||||
|
&apdu[0],
|
||||||
|
property,
|
||||||
|
array_index,
|
||||||
|
error_class, error_code);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case OBJECT_ANALOG_INPUT:
|
||||||
|
if (Analog_Input_Valid_Instance(object_instance)) {
|
||||||
|
apdu_len = Analog_Input_Encode_Property_APDU(
|
||||||
|
&apdu[0],
|
||||||
|
object_instance,
|
||||||
|
property,
|
||||||
|
array_index,
|
||||||
|
error_class, error_code);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case OBJECT_ANALOG_OUTPUT:
|
||||||
|
if (!Analog_Output_Valid_Instance(object_instance)) {
|
||||||
|
apdu_len = Analog_Output_Encode_Property_APDU(
|
||||||
|
&apdu[0],
|
||||||
|
object_instance,
|
||||||
|
property,
|
||||||
|
array_index,
|
||||||
|
error_class, error_code);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case OBJECT_ANALOG_VALUE:
|
||||||
|
if (Analog_Value_Valid_Instance(object_instance)) {
|
||||||
|
apdu_len = Analog_Value_Encode_Property_APDU(&Temp_Buf[0],
|
||||||
|
object_instance,
|
||||||
|
property,
|
||||||
|
array_index,
|
||||||
|
error_class, error_code);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case OBJECT_BINARY_INPUT:
|
||||||
|
if (Binary_Input_Valid_Instance(object_instance)) {
|
||||||
|
apdu_len = Binary_Input_Encode_Property_APDU(
|
||||||
|
&apdu[0],
|
||||||
|
object_instance,
|
||||||
|
property,
|
||||||
|
array_index,
|
||||||
|
error_class, error_code);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case OBJECT_BINARY_OUTPUT:
|
||||||
|
if (Binary_Output_Valid_Instance(object_instance)) {
|
||||||
|
apdu_len = Binary_Output_Encode_Property_APDU(
|
||||||
|
&apdu[0],
|
||||||
|
object_instance,
|
||||||
|
property,
|
||||||
|
array_index,
|
||||||
|
error_class, error_code);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case OBJECT_BINARY_VALUE:
|
||||||
|
if (Binary_Value_Valid_Instance(object_instance)) {
|
||||||
|
apdu_len = Binary_Value_Encode_Property_APDU(&Temp_Buf[0],
|
||||||
|
object_instance,
|
||||||
|
property,
|
||||||
|
array_index,
|
||||||
|
error_class, error_code);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case OBJECT_LIFE_SAFETY_POINT:
|
||||||
|
if (Life_Safety_Point_Valid_Instance(object_instance)) {
|
||||||
|
apdu_len = Life_Safety_Point_Encode_Property_APDU(&Temp_Buf[0],
|
||||||
|
object_instance,
|
||||||
|
property,
|
||||||
|
array_index,
|
||||||
|
error_class, error_code);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case OBJECT_LOAD_CONTROL:
|
||||||
|
if (Load_Control_Valid_Instance(object_instance)) {
|
||||||
|
apdu_len = Load_Control_Encode_Property_APDU(&Temp_Buf[0],
|
||||||
|
object_instance,
|
||||||
|
property,
|
||||||
|
array_index,
|
||||||
|
error_class, error_code);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case OBJECT_MULTI_STATE_OUTPUT:
|
||||||
|
if (Multistate_Output_Valid_Instance(object_instance)) {
|
||||||
|
apdu_len = Multistate_Output_Encode_Property_APDU(&Temp_Buf[0],
|
||||||
|
object_instance,
|
||||||
|
property,
|
||||||
|
array_index,
|
||||||
|
error_class, error_code);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#if BACFILE
|
||||||
|
case OBJECT_FILE:
|
||||||
|
if (bacfile_valid_instance(object_instance)) {
|
||||||
|
apdu_len = bacfile_encode_property_apdu(&Temp_Buf[0],
|
||||||
|
object_instance,
|
||||||
|
property,
|
||||||
|
array_index,
|
||||||
|
error_class, error_code);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
default:
|
||||||
|
*error_class = ERROR_CLASS_OBJECT;
|
||||||
|
*error_code = ERROR_CODE_UNSUPPORTED_OBJECT_TYPE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return apdu_len;
|
||||||
|
}
|
||||||
|
|
||||||
void handler_read_property(uint8_t * service_request,
|
void handler_read_property(uint8_t * service_request,
|
||||||
uint16_t service_len,
|
uint16_t service_len,
|
||||||
BACNET_ADDRESS * src, BACNET_CONFIRMED_SERVICE_DATA * service_data)
|
BACNET_ADDRESS * src, BACNET_CONFIRMED_SERVICE_DATA * service_data)
|
||||||
@@ -94,247 +227,26 @@ void handler_read_property(uint8_t * service_request,
|
|||||||
} else {
|
} else {
|
||||||
/* most cases will be error */
|
/* most cases will be error */
|
||||||
error = true;
|
error = true;
|
||||||
switch (data.object_type) {
|
len = Encode_Property_APDU(
|
||||||
case OBJECT_DEVICE:
|
&Temp_Buf[0],
|
||||||
|
data.object_type,
|
||||||
|
data.object_instance,
|
||||||
|
data.object_property,
|
||||||
|
data.array_index,
|
||||||
|
&error_class, &error_code);
|
||||||
|
if (len >= 0) {
|
||||||
|
/* encode the APDU portion of the packet */
|
||||||
|
data.application_data = &Temp_Buf[0];
|
||||||
|
data.application_data_len = len;
|
||||||
/* FIXME: probably need a length limitation sent with encode */
|
/* FIXME: probably need a length limitation sent with encode */
|
||||||
if (data.object_instance == Device_Object_Instance_Number()) {
|
len =
|
||||||
len = Device_Encode_Property_APDU(&Temp_Buf[0],
|
rp_ack_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||||
data.object_property,
|
service_data->invoke_id, &data);
|
||||||
data.array_index, &error_class, &error_code);
|
|
||||||
if (len >= 0) {
|
|
||||||
/* encode the APDU portion of the packet */
|
|
||||||
data.application_data = &Temp_Buf[0];
|
|
||||||
data.application_data_len = len;
|
|
||||||
/* FIXME: probably need a length limitation sent with encode */
|
|
||||||
len =
|
|
||||||
rp_ack_encode_apdu(&Handler_Transmit_Buffer
|
|
||||||
[pdu_len], service_data->invoke_id, &data);
|
|
||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Sending Read Property Ack for Device!\n");
|
"Sending Read Property Ack!\n");
|
||||||
#endif
|
#endif
|
||||||
error = false;
|
error = false;
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case OBJECT_ANALOG_INPUT:
|
|
||||||
if (Analog_Input_Valid_Instance(data.object_instance)) {
|
|
||||||
len = Analog_Input_Encode_Property_APDU(&Temp_Buf[0],
|
|
||||||
data.object_instance,
|
|
||||||
data.object_property,
|
|
||||||
data.array_index, &error_class, &error_code);
|
|
||||||
if (len >= 0) {
|
|
||||||
/* encode the APDU portion of the packet */
|
|
||||||
data.application_data = &Temp_Buf[0];
|
|
||||||
data.application_data_len = len;
|
|
||||||
/* FIXME: probably need a length limitation sent with encode */
|
|
||||||
len =
|
|
||||||
rp_ack_encode_apdu(&Handler_Transmit_Buffer
|
|
||||||
[pdu_len], service_data->invoke_id, &data);
|
|
||||||
#if PRINT_ENABLED
|
|
||||||
fprintf(stderr, "Sending Read Property Ack for AI!\n");
|
|
||||||
#endif
|
|
||||||
error = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case OBJECT_BINARY_INPUT:
|
|
||||||
if (Binary_Input_Valid_Instance(data.object_instance)) {
|
|
||||||
len = Binary_Input_Encode_Property_APDU(&Temp_Buf[0],
|
|
||||||
data.object_instance,
|
|
||||||
data.object_property,
|
|
||||||
data.array_index, &error_class, &error_code);
|
|
||||||
if (len >= 0) {
|
|
||||||
/* encode the APDU portion of the packet */
|
|
||||||
data.application_data = &Temp_Buf[0];
|
|
||||||
data.application_data_len = len;
|
|
||||||
/* FIXME: probably need a length limitation sent with encode */
|
|
||||||
len =
|
|
||||||
rp_ack_encode_apdu(&Handler_Transmit_Buffer
|
|
||||||
[pdu_len], service_data->invoke_id, &data);
|
|
||||||
#if PRINT_ENABLED
|
|
||||||
fprintf(stderr, "Sending Read Property Ack for BI!\n");
|
|
||||||
#endif
|
|
||||||
error = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case OBJECT_BINARY_OUTPUT:
|
|
||||||
if (Binary_Output_Valid_Instance(data.object_instance)) {
|
|
||||||
len = Binary_Output_Encode_Property_APDU(&Temp_Buf[0],
|
|
||||||
data.object_instance,
|
|
||||||
data.object_property,
|
|
||||||
data.array_index, &error_class, &error_code);
|
|
||||||
if (len >= 0) {
|
|
||||||
/* encode the APDU portion of the packet */
|
|
||||||
data.application_data = &Temp_Buf[0];
|
|
||||||
data.application_data_len = len;
|
|
||||||
/* FIXME: probably need a length limitation sent with encode */
|
|
||||||
len =
|
|
||||||
rp_ack_encode_apdu(&Handler_Transmit_Buffer
|
|
||||||
[pdu_len], service_data->invoke_id, &data);
|
|
||||||
#if PRINT_ENABLED
|
|
||||||
fprintf(stderr, "Sending Read Property Ack for BO!\n");
|
|
||||||
#endif
|
|
||||||
error = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case OBJECT_BINARY_VALUE:
|
|
||||||
if (Binary_Value_Valid_Instance(data.object_instance)) {
|
|
||||||
len = Binary_Value_Encode_Property_APDU(&Temp_Buf[0],
|
|
||||||
data.object_instance,
|
|
||||||
data.object_property,
|
|
||||||
data.array_index, &error_class, &error_code);
|
|
||||||
if (len >= 0) {
|
|
||||||
/* encode the APDU portion of the packet */
|
|
||||||
data.application_data = &Temp_Buf[0];
|
|
||||||
data.application_data_len = len;
|
|
||||||
/* FIXME: probably need a length limitation sent with encode */
|
|
||||||
len =
|
|
||||||
rp_ack_encode_apdu(&Handler_Transmit_Buffer
|
|
||||||
[pdu_len], service_data->invoke_id, &data);
|
|
||||||
#if PRINT_ENABLED
|
|
||||||
fprintf(stderr, "Sending Read Property Ack for BV!\n");
|
|
||||||
#endif
|
|
||||||
error = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case OBJECT_ANALOG_OUTPUT:
|
|
||||||
if (Analog_Output_Valid_Instance(data.object_instance)) {
|
|
||||||
len = Analog_Output_Encode_Property_APDU(&Temp_Buf[0],
|
|
||||||
data.object_instance,
|
|
||||||
data.object_property,
|
|
||||||
data.array_index, &error_class, &error_code);
|
|
||||||
if (len >= 0) {
|
|
||||||
/* encode the APDU portion of the packet */
|
|
||||||
data.application_data = &Temp_Buf[0];
|
|
||||||
data.application_data_len = len;
|
|
||||||
/* FIXME: probably need a length limitation sent with encode */
|
|
||||||
len =
|
|
||||||
rp_ack_encode_apdu(&Handler_Transmit_Buffer
|
|
||||||
[pdu_len], service_data->invoke_id, &data);
|
|
||||||
#if PRINT_ENABLED
|
|
||||||
fprintf(stderr, "Sending Read Property Ack for AO!\n");
|
|
||||||
#endif
|
|
||||||
error = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case OBJECT_ANALOG_VALUE:
|
|
||||||
if (Analog_Value_Valid_Instance(data.object_instance)) {
|
|
||||||
len = Analog_Value_Encode_Property_APDU(&Temp_Buf[0],
|
|
||||||
data.object_instance,
|
|
||||||
data.object_property,
|
|
||||||
data.array_index, &error_class, &error_code);
|
|
||||||
if (len >= 0) {
|
|
||||||
/* encode the APDU portion of the packet */
|
|
||||||
data.application_data = &Temp_Buf[0];
|
|
||||||
data.application_data_len = len;
|
|
||||||
/* FIXME: probably need a length limitation sent with encode */
|
|
||||||
len =
|
|
||||||
rp_ack_encode_apdu(&Handler_Transmit_Buffer
|
|
||||||
[pdu_len], service_data->invoke_id, &data);
|
|
||||||
#if PRINT_ENABLED
|
|
||||||
fprintf(stderr, "Sending Read Property Ack for AV!\n");
|
|
||||||
#endif
|
|
||||||
error = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case OBJECT_LIFE_SAFETY_POINT:
|
|
||||||
if (Life_Safety_Point_Valid_Instance(data.object_instance)) {
|
|
||||||
len = Life_Safety_Point_Encode_Property_APDU(&Temp_Buf[0],
|
|
||||||
data.object_instance,
|
|
||||||
data.object_property,
|
|
||||||
data.array_index, &error_class, &error_code);
|
|
||||||
if (len >= 0) {
|
|
||||||
/* encode the APDU portion of the packet */
|
|
||||||
data.application_data = &Temp_Buf[0];
|
|
||||||
data.application_data_len = len;
|
|
||||||
/* FIXME: probably need a length limitation sent with encode */
|
|
||||||
len =
|
|
||||||
rp_ack_encode_apdu(&Handler_Transmit_Buffer
|
|
||||||
[pdu_len], service_data->invoke_id, &data);
|
|
||||||
#if PRINT_ENABLED
|
|
||||||
fprintf(stderr,
|
|
||||||
"Sending Read Property Ack for LSP!\n");
|
|
||||||
#endif
|
|
||||||
error = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case OBJECT_LOAD_CONTROL:
|
|
||||||
if (Load_Control_Valid_Instance(data.object_instance)) {
|
|
||||||
len = Load_Control_Encode_Property_APDU(&Temp_Buf[0],
|
|
||||||
data.object_instance,
|
|
||||||
data.object_property,
|
|
||||||
data.array_index, &error_class, &error_code);
|
|
||||||
if (len >= 0) {
|
|
||||||
/* encode the APDU portion of the packet */
|
|
||||||
data.application_data = &Temp_Buf[0];
|
|
||||||
data.application_data_len = len;
|
|
||||||
/* FIXME: probably need a length limitation sent with encode */
|
|
||||||
len =
|
|
||||||
rp_ack_encode_apdu(&Handler_Transmit_Buffer
|
|
||||||
[pdu_len], service_data->invoke_id, &data);
|
|
||||||
#if PRINT_ENABLED
|
|
||||||
fprintf(stderr,
|
|
||||||
"Sending Read Property Ack for Load Control!\n");
|
|
||||||
#endif
|
|
||||||
error = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case OBJECT_MULTI_STATE_OUTPUT:
|
|
||||||
if (Multistate_Output_Valid_Instance(data.object_instance)) {
|
|
||||||
len = Multistate_Output_Encode_Property_APDU(&Temp_Buf[0],
|
|
||||||
data.object_instance,
|
|
||||||
data.object_property,
|
|
||||||
data.array_index, &error_class, &error_code);
|
|
||||||
if (len >= 0) {
|
|
||||||
/* encode the APDU portion of the packet */
|
|
||||||
data.application_data = &Temp_Buf[0];
|
|
||||||
data.application_data_len = len;
|
|
||||||
/* FIXME: probably need a length limitation sent with encode */
|
|
||||||
len =
|
|
||||||
rp_ack_encode_apdu(&Handler_Transmit_Buffer
|
|
||||||
[pdu_len], service_data->invoke_id, &data);
|
|
||||||
#if PRINT_ENABLED
|
|
||||||
fprintf(stderr,
|
|
||||||
"Sending Read Property Ack for MSO!\n");
|
|
||||||
#endif
|
|
||||||
error = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#if BACFILE
|
|
||||||
case OBJECT_FILE:
|
|
||||||
if (bacfile_valid_instance(data.object_instance)) {
|
|
||||||
len = bacfile_encode_property_apdu(&Temp_Buf[0],
|
|
||||||
data.object_instance,
|
|
||||||
data.object_property,
|
|
||||||
data.array_index, &error_class, &error_code);
|
|
||||||
if (len >= 0) {
|
|
||||||
/* encode the APDU portion of the packet */
|
|
||||||
data.application_data = &Temp_Buf[0];
|
|
||||||
data.application_data_len = len;
|
|
||||||
/* FIXME: probably need a length limitation sent with encode */
|
|
||||||
len =
|
|
||||||
rp_ack_encode_apdu(&Handler_Transmit_Buffer
|
|
||||||
[pdu_len], service_data->invoke_id, &data);
|
|
||||||
#if PRINT_ENABLED
|
|
||||||
fprintf(stderr,
|
|
||||||
"Sending Read Property Ack for File!\n");
|
|
||||||
#endif
|
|
||||||
error = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#endif /* BACFILE */
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|||||||
@@ -53,7 +53,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static uint8_t Temp_Buf[MAX_APDU] = { 0 };
|
static uint8_t Temp_Buf[MAX_APDU] = { 0 };
|
||||||
static uint8_t Application_Buf[MAX_APDU] = { 0 };
|
|
||||||
|
|
||||||
struct property_list_t
|
struct property_list_t
|
||||||
{
|
{
|
||||||
@@ -238,164 +237,55 @@ int apdu_copy(uint8_t *dest, uint8_t *src, int offset, int len, int max)
|
|||||||
return copy_len;
|
return copy_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Encodes the property APDU and returns the length,
|
/* Encode the RPM property returning the length of the encoding,
|
||||||
or sets the error, and returns -1 */
|
or 0 if there is no room to fit the encoding. */
|
||||||
int Encode_Property_APDU(
|
int RPM_Encode_Property(uint8_t *apdu,
|
||||||
uint8_t * apdu,
|
uint16_t offset,
|
||||||
|
uint16_t max_apdu,
|
||||||
BACNET_OBJECT_TYPE object_type,
|
BACNET_OBJECT_TYPE object_type,
|
||||||
uint32_t object_instance,
|
uint32_t object_instance,
|
||||||
BACNET_PROPERTY_ID property,
|
BACNET_PROPERTY_ID object_property,
|
||||||
int32_t array_index,
|
int32_t array_index)
|
||||||
BACNET_ERROR_CLASS * error_class,
|
|
||||||
BACNET_ERROR_CODE * error_code)
|
|
||||||
{
|
{
|
||||||
int apdu_len = -1;
|
int len = 0;
|
||||||
|
int apdu_len = 0;
|
||||||
|
BACNET_ERROR_CLASS error_class = ERROR_CLASS_OBJECT;
|
||||||
|
BACNET_ERROR_CODE error_code = ERROR_CODE_UNKNOWN_OBJECT;
|
||||||
|
|
||||||
switch(object_type) {
|
len = rpm_ack_encode_apdu_object_property(
|
||||||
case OBJECT_DEVICE:
|
&Temp_Buf[0],
|
||||||
if ((object_instance == Device_Object_Instance_Number()) ||
|
object_property,
|
||||||
(object_instance == BACNET_MAX_INSTANCE)) {
|
array_index);
|
||||||
apdu_len = Device_Encode_Property_APDU(
|
len = apdu_copy(&apdu[0], &Temp_Buf[0], offset, len, max_apdu);
|
||||||
&apdu[0],
|
if (!len)
|
||||||
property,
|
return 0;
|
||||||
array_index,
|
apdu_len += len;
|
||||||
error_class, error_code);
|
len = Encode_Property_APDU(
|
||||||
} else {
|
&Temp_Buf[0],
|
||||||
*error_class = ERROR_CLASS_OBJECT;
|
object_type,
|
||||||
*error_code = ERROR_CODE_UNKNOWN_OBJECT;
|
object_instance,
|
||||||
}
|
object_property,
|
||||||
break;
|
array_index,
|
||||||
case OBJECT_ANALOG_INPUT:
|
&error_class, &error_code);
|
||||||
if (Analog_Input_Valid_Instance(object_instance)) {
|
if (len < 0) {
|
||||||
apdu_len = Analog_Input_Encode_Property_APDU(
|
/* error was returned - encode that for the response */
|
||||||
&apdu[0],
|
len = rpm_ack_encode_apdu_object_property_error(
|
||||||
object_instance,
|
&Temp_Buf[0],
|
||||||
property,
|
error_class, error_code);
|
||||||
array_index,
|
len = apdu_copy(&apdu[0], &Temp_Buf[0], offset, len, max_apdu);
|
||||||
error_class, error_code);
|
if (!len)
|
||||||
} else {
|
return 0;
|
||||||
*error_class = ERROR_CLASS_OBJECT;
|
} else if ((offset+apdu_len+1+len+1) < max_apdu) {
|
||||||
*error_code = ERROR_CODE_UNKNOWN_OBJECT;
|
/* enough room to fit the property value and tags */
|
||||||
}
|
len = rpm_ack_encode_apdu_object_property_value(
|
||||||
break;
|
&apdu[offset+apdu_len],
|
||||||
case OBJECT_ANALOG_OUTPUT:
|
&Temp_Buf[0],
|
||||||
if (!Analog_Output_Valid_Instance(object_instance)) {
|
len);
|
||||||
apdu_len = Analog_Output_Encode_Property_APDU(
|
} else {
|
||||||
&apdu[0],
|
/* not enough room - abort! */
|
||||||
object_instance,
|
return 0;
|
||||||
property,
|
|
||||||
array_index,
|
|
||||||
error_class, error_code);
|
|
||||||
} else {
|
|
||||||
*error_class = ERROR_CLASS_OBJECT;
|
|
||||||
*error_code = ERROR_CODE_UNKNOWN_OBJECT;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case OBJECT_ANALOG_VALUE:
|
|
||||||
if (Analog_Value_Valid_Instance(object_instance)) {
|
|
||||||
apdu_len = Analog_Value_Encode_Property_APDU(&Temp_Buf[0],
|
|
||||||
object_instance,
|
|
||||||
property,
|
|
||||||
array_index,
|
|
||||||
error_class, error_code);
|
|
||||||
} else {
|
|
||||||
*error_class = ERROR_CLASS_OBJECT;
|
|
||||||
*error_code = ERROR_CODE_UNKNOWN_OBJECT;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case OBJECT_BINARY_INPUT:
|
|
||||||
if (Binary_Input_Valid_Instance(object_instance)) {
|
|
||||||
apdu_len = Binary_Input_Encode_Property_APDU(
|
|
||||||
&apdu[0],
|
|
||||||
object_instance,
|
|
||||||
property,
|
|
||||||
array_index,
|
|
||||||
error_class, error_code);
|
|
||||||
} else {
|
|
||||||
*error_class = ERROR_CLASS_OBJECT;
|
|
||||||
*error_code = ERROR_CODE_UNKNOWN_OBJECT;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case OBJECT_BINARY_OUTPUT:
|
|
||||||
if (Binary_Output_Valid_Instance(object_instance)) {
|
|
||||||
apdu_len = Binary_Output_Encode_Property_APDU(
|
|
||||||
&apdu[0],
|
|
||||||
object_instance,
|
|
||||||
property,
|
|
||||||
array_index,
|
|
||||||
error_class, error_code);
|
|
||||||
} else {
|
|
||||||
*error_class = ERROR_CLASS_OBJECT;
|
|
||||||
*error_code = ERROR_CODE_UNKNOWN_OBJECT;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case OBJECT_BINARY_VALUE:
|
|
||||||
if (Binary_Value_Valid_Instance(object_instance)) {
|
|
||||||
apdu_len = Binary_Value_Encode_Property_APDU(&Temp_Buf[0],
|
|
||||||
object_instance,
|
|
||||||
property,
|
|
||||||
array_index,
|
|
||||||
error_class, error_code);
|
|
||||||
} else {
|
|
||||||
*error_class = ERROR_CLASS_OBJECT;
|
|
||||||
*error_code = ERROR_CODE_UNKNOWN_OBJECT;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case OBJECT_LIFE_SAFETY_POINT:
|
|
||||||
if (Life_Safety_Point_Valid_Instance(object_instance)) {
|
|
||||||
apdu_len = Life_Safety_Point_Encode_Property_APDU(&Temp_Buf[0],
|
|
||||||
object_instance,
|
|
||||||
property,
|
|
||||||
array_index,
|
|
||||||
error_class, error_code);
|
|
||||||
} else {
|
|
||||||
*error_class = ERROR_CLASS_OBJECT;
|
|
||||||
*error_code = ERROR_CODE_UNKNOWN_OBJECT;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case OBJECT_LOAD_CONTROL:
|
|
||||||
if (Load_Control_Valid_Instance(object_instance)) {
|
|
||||||
apdu_len = Load_Control_Encode_Property_APDU(&Temp_Buf[0],
|
|
||||||
object_instance,
|
|
||||||
property,
|
|
||||||
array_index,
|
|
||||||
error_class, error_code);
|
|
||||||
} else {
|
|
||||||
*error_class = ERROR_CLASS_OBJECT;
|
|
||||||
*error_code = ERROR_CODE_UNKNOWN_OBJECT;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case OBJECT_MULTI_STATE_OUTPUT:
|
|
||||||
if (Multistate_Output_Valid_Instance(object_instance)) {
|
|
||||||
apdu_len = Multistate_Output_Encode_Property_APDU(&Temp_Buf[0],
|
|
||||||
object_instance,
|
|
||||||
property,
|
|
||||||
array_index,
|
|
||||||
error_class, error_code);
|
|
||||||
} else {
|
|
||||||
*error_class = ERROR_CLASS_OBJECT;
|
|
||||||
*error_code = ERROR_CODE_UNKNOWN_OBJECT;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#if BACFILE
|
|
||||||
case OBJECT_FILE:
|
|
||||||
if (bacfile_valid_instance(object_instance)) {
|
|
||||||
apdu_len = bacfile_encode_property_apdu(&Temp_Buf[0],
|
|
||||||
object_instance,
|
|
||||||
property,
|
|
||||||
array_index,
|
|
||||||
error_class, error_code);
|
|
||||||
} else {
|
|
||||||
*error_class = ERROR_CLASS_OBJECT;
|
|
||||||
*error_code = ERROR_CODE_UNKNOWN_OBJECT;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
*error_class = ERROR_CLASS_OBJECT;
|
|
||||||
*error_code = ERROR_CODE_UNSUPPORTED_OBJECT_TYPE;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
apdu_len += len;
|
||||||
|
|
||||||
return apdu_len;
|
return apdu_len;
|
||||||
}
|
}
|
||||||
@@ -409,18 +299,15 @@ void handler_read_property_multiple(
|
|||||||
int len = 0;
|
int len = 0;
|
||||||
int copy_len = 0;
|
int copy_len = 0;
|
||||||
int decode_len = 0;
|
int decode_len = 0;
|
||||||
int application_data_len = 0;
|
|
||||||
int pdu_len = 0;
|
int pdu_len = 0;
|
||||||
BACNET_NPDU_DATA npdu_data;
|
BACNET_NPDU_DATA npdu_data;
|
||||||
int bytes_sent;
|
int bytes_sent;
|
||||||
BACNET_ERROR_CLASS error_class = ERROR_CLASS_OBJECT;
|
|
||||||
BACNET_ERROR_CODE error_code = ERROR_CODE_UNKNOWN_OBJECT;
|
|
||||||
BACNET_ADDRESS my_address;
|
BACNET_ADDRESS my_address;
|
||||||
BACNET_OBJECT_TYPE object_type;
|
BACNET_OBJECT_TYPE object_type;
|
||||||
uint32_t object_instance = 0;
|
uint32_t object_instance = 0;
|
||||||
int apdu_len = 0;
|
int apdu_len = 0;
|
||||||
int npdu_len;
|
int npdu_len = 0;
|
||||||
BACNET_PROPERTY_ID object_property, temp_object_property;
|
BACNET_PROPERTY_ID object_property;
|
||||||
int32_t array_index = 0;
|
int32_t array_index = 0;
|
||||||
|
|
||||||
/* jps_debug - see if we are utilizing all the buffer */
|
/* jps_debug - see if we are utilizing all the buffer */
|
||||||
@@ -565,114 +452,55 @@ void handler_read_property_multiple(
|
|||||||
struct special_property_list_t property_list;
|
struct special_property_list_t property_list;
|
||||||
unsigned property_count = 0;
|
unsigned property_count = 0;
|
||||||
unsigned index = 0;
|
unsigned index = 0;
|
||||||
|
BACNET_PROPERTY_ID special_object_property;
|
||||||
|
|
||||||
|
special_object_property = object_property;
|
||||||
RPM_Property_List(object_type, &property_list);
|
RPM_Property_List(object_type, &property_list);
|
||||||
property_count = RPM_Object_Property_Count(
|
property_count = RPM_Object_Property_Count(
|
||||||
&property_list,
|
&property_list,
|
||||||
object_property);
|
special_object_property);
|
||||||
for (index = 0; index < property_count; index++)
|
for (index = 0; index < property_count; index++)
|
||||||
{
|
{
|
||||||
temp_object_property = RPM_Object_Property(
|
object_property = RPM_Object_Property(
|
||||||
&property_list,
|
&property_list,
|
||||||
object_property,
|
special_object_property,
|
||||||
index);
|
index);
|
||||||
len = rpm_ack_encode_apdu_object_property(
|
len = RPM_Encode_Property(
|
||||||
&Temp_Buf[0],
|
&Handler_Transmit_Buffer[0],
|
||||||
temp_object_property,
|
npdu_len + apdu_len,
|
||||||
array_index);
|
sizeof(Handler_Transmit_Buffer),
|
||||||
copy_len = apdu_copy(
|
|
||||||
&Handler_Transmit_Buffer[npdu_len], &Temp_Buf[0],
|
|
||||||
apdu_len, len,
|
|
||||||
sizeof(Handler_Transmit_Buffer));
|
|
||||||
if (!copy_len) {
|
|
||||||
apdu_len = abort_encode_apdu(
|
|
||||||
&Handler_Transmit_Buffer[npdu_len],
|
|
||||||
service_data->invoke_id,
|
|
||||||
ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true);
|
|
||||||
goto RPM_ABORT;
|
|
||||||
} else {
|
|
||||||
apdu_len += copy_len;
|
|
||||||
}
|
|
||||||
application_data_len = Encode_Property_APDU(
|
|
||||||
&Application_Buf[0],
|
|
||||||
object_type,
|
object_type,
|
||||||
object_instance,
|
object_instance,
|
||||||
temp_object_property,
|
object_property,
|
||||||
array_index,
|
array_index);
|
||||||
&error_class, &error_code);
|
if (len > 0) {
|
||||||
if (application_data_len < 0) {
|
apdu_len += len;
|
||||||
len = rpm_ack_encode_apdu_object_property_error(
|
|
||||||
&Temp_Buf[0],
|
|
||||||
error_class, error_code);
|
|
||||||
} else {
|
} else {
|
||||||
len = rpm_ack_encode_apdu_object_property_value(
|
|
||||||
&Temp_Buf[0],
|
|
||||||
&Application_Buf[0],
|
|
||||||
application_data_len);
|
|
||||||
}
|
|
||||||
copy_len = apdu_copy(
|
|
||||||
&Handler_Transmit_Buffer[npdu_len], &Temp_Buf[0],
|
|
||||||
apdu_len, len,
|
|
||||||
sizeof(Handler_Transmit_Buffer));
|
|
||||||
if (!copy_len) {
|
|
||||||
apdu_len = abort_encode_apdu(
|
apdu_len = abort_encode_apdu(
|
||||||
&Handler_Transmit_Buffer[npdu_len],
|
&Handler_Transmit_Buffer[npdu_len],
|
||||||
service_data->invoke_id,
|
service_data->invoke_id,
|
||||||
ABORT_REASON_SEGMENTATION_NOT_SUPPORTED,
|
ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true);
|
||||||
true);
|
goto RPM_ABORT;
|
||||||
goto RPM_ABORT;
|
|
||||||
} else {
|
|
||||||
apdu_len += copy_len;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* handle an individual property */
|
/* handle an individual property */
|
||||||
len = rpm_ack_encode_apdu_object_property(
|
len = RPM_Encode_Property(
|
||||||
&Temp_Buf[0],
|
&Handler_Transmit_Buffer[0],
|
||||||
object_property,
|
npdu_len + apdu_len,
|
||||||
array_index);
|
sizeof(Handler_Transmit_Buffer),
|
||||||
copy_len = apdu_copy(
|
|
||||||
&Handler_Transmit_Buffer[npdu_len], &Temp_Buf[0],
|
|
||||||
apdu_len, len,
|
|
||||||
sizeof(Handler_Transmit_Buffer));
|
|
||||||
if (!copy_len) {
|
|
||||||
apdu_len = abort_encode_apdu(
|
|
||||||
&Handler_Transmit_Buffer[npdu_len],
|
|
||||||
service_data->invoke_id,
|
|
||||||
ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true);
|
|
||||||
goto RPM_ABORT;
|
|
||||||
} else {
|
|
||||||
apdu_len += copy_len;
|
|
||||||
}
|
|
||||||
application_data_len = Encode_Property_APDU(
|
|
||||||
&Application_Buf[0],
|
|
||||||
object_type,
|
object_type,
|
||||||
object_instance,
|
object_instance,
|
||||||
object_property,
|
object_property,
|
||||||
array_index,
|
array_index);
|
||||||
&error_class, &error_code);
|
if (len > 0) {
|
||||||
if (application_data_len < 0) {
|
apdu_len += len;
|
||||||
len = rpm_ack_encode_apdu_object_property_error(
|
|
||||||
&Temp_Buf[0],
|
|
||||||
error_class, error_code);
|
|
||||||
} else {
|
} else {
|
||||||
len = rpm_ack_encode_apdu_object_property_value(
|
|
||||||
&Temp_Buf[0],
|
|
||||||
&Application_Buf[0],
|
|
||||||
application_data_len);
|
|
||||||
}
|
|
||||||
copy_len = apdu_copy(
|
|
||||||
&Handler_Transmit_Buffer[npdu_len], &Temp_Buf[0],
|
|
||||||
apdu_len, len,
|
|
||||||
sizeof(Handler_Transmit_Buffer));
|
|
||||||
if (!copy_len) {
|
|
||||||
apdu_len = abort_encode_apdu(
|
apdu_len = abort_encode_apdu(
|
||||||
&Handler_Transmit_Buffer[npdu_len],
|
&Handler_Transmit_Buffer[npdu_len],
|
||||||
service_data->invoke_id,
|
service_data->invoke_id,
|
||||||
ABORT_REASON_SEGMENTATION_NOT_SUPPORTED,
|
ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true);
|
||||||
true);
|
goto RPM_ABORT;
|
||||||
goto RPM_ABORT;
|
|
||||||
} else {
|
|
||||||
apdu_len += copy_len;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while(1);
|
} while(1);
|
||||||
|
|||||||
@@ -107,6 +107,19 @@ extern "C" {
|
|||||||
BACNET_ADDRESS * src,
|
BACNET_ADDRESS * src,
|
||||||
BACNET_CONFIRMED_SERVICE_DATA * service_data);
|
BACNET_CONFIRMED_SERVICE_DATA * service_data);
|
||||||
|
|
||||||
|
/* Encodes the property APDU and returns the length,
|
||||||
|
or sets the error, and returns -1 */
|
||||||
|
/* resides in h_rp.c */
|
||||||
|
int Encode_Property_APDU(
|
||||||
|
uint8_t * apdu,
|
||||||
|
BACNET_OBJECT_TYPE object_type,
|
||||||
|
uint32_t object_instance,
|
||||||
|
BACNET_PROPERTY_ID property,
|
||||||
|
int32_t array_index,
|
||||||
|
BACNET_ERROR_CLASS * error_class,
|
||||||
|
BACNET_ERROR_CODE * error_code);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user