Got rid of the handler-set functions for RP,RPM,WP,RD. Just referencing the device object functions directly.
This commit is contained in:
@@ -37,16 +37,11 @@
|
||||
#include "abort.h"
|
||||
#include "reject.h"
|
||||
#include "rd.h"
|
||||
/* custom handling in device object */
|
||||
#include "device.h"
|
||||
|
||||
/** @file h_rd.c Handles Reinitialize Device requests. */
|
||||
|
||||
static reinitialize_device_function Reinitialize_Device_Function;
|
||||
void handler_reinitialize_device_function_set(
|
||||
reinitialize_device_function pFunction)
|
||||
{
|
||||
Reinitialize_Device_Function = pFunction;
|
||||
}
|
||||
|
||||
void handler_reinitialize_device(
|
||||
uint8_t * service_request,
|
||||
uint16_t service_len,
|
||||
@@ -114,8 +109,7 @@ void handler_reinitialize_device(
|
||||
"ReinitializeDevice: Sending Reject - undefined enumeration\n");
|
||||
#endif
|
||||
} else {
|
||||
if (Reinitialize_Device_Function &&
|
||||
Reinitialize_Device_Function(&rd_data)) {
|
||||
if (Device_Reinitialize(&rd_data)) {
|
||||
len =
|
||||
encode_simple_ack(&Handler_Transmit_Buffer[pdu_len],
|
||||
service_data->invoke_id,
|
||||
@@ -130,7 +124,7 @@ void handler_reinitialize_device(
|
||||
rd_data.error_class, rd_data.error_code);
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr,
|
||||
"ReinitializeDevice: Sending Error - password failure.\n");
|
||||
"ReinitializeDevice: Sending Error.\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,18 +37,11 @@
|
||||
#include "npdu.h"
|
||||
#include "abort.h"
|
||||
#include "rp.h"
|
||||
/* device object has custom handler for all objects */
|
||||
#include "device.h"
|
||||
|
||||
/** @file h_rp.c Handles Read Property requests. */
|
||||
|
||||
/* function that handles the reading of properties from objects */
|
||||
static read_property_function Read_Property_Function;
|
||||
|
||||
void handler_read_property_function_set(
|
||||
read_property_function pFunction)
|
||||
{
|
||||
Read_Property_Function = pFunction;
|
||||
}
|
||||
|
||||
void handler_read_property(
|
||||
uint8_t * service_request,
|
||||
uint16_t service_len,
|
||||
@@ -100,37 +93,35 @@ void handler_read_property(
|
||||
}
|
||||
/* assume that there is an error */
|
||||
error = true;
|
||||
if (Read_Property_Function) {
|
||||
apdu_len = rp_ack_encode_apdu_init(
|
||||
&Handler_Transmit_Buffer[npdu_len],
|
||||
service_data->invoke_id,
|
||||
&rpdata);
|
||||
/* configure our storage */
|
||||
rpdata.application_data = &Handler_Transmit_Buffer[npdu_len+apdu_len];
|
||||
rpdata.application_data_len =
|
||||
sizeof(Handler_Transmit_Buffer) - (npdu_len + apdu_len);
|
||||
len = Read_Property_Function(&rpdata);
|
||||
if (len >= 0) {
|
||||
apdu_len += len;
|
||||
len = rp_ack_encode_apdu_object_property_end(
|
||||
&Handler_Transmit_Buffer[npdu_len+apdu_len]);
|
||||
apdu_len += len;
|
||||
if (apdu_len > service_data->max_resp) {
|
||||
/* too big for the sender - send an abort */
|
||||
apdu_len =
|
||||
abort_encode_apdu(&Handler_Transmit_Buffer[npdu_len],
|
||||
service_data->invoke_id, ABORT_REASON_SEGMENTATION_NOT_SUPPORTED,
|
||||
true);
|
||||
apdu_len = rp_ack_encode_apdu_init(
|
||||
&Handler_Transmit_Buffer[npdu_len],
|
||||
service_data->invoke_id,
|
||||
&rpdata);
|
||||
/* configure our storage */
|
||||
rpdata.application_data = &Handler_Transmit_Buffer[npdu_len+apdu_len];
|
||||
rpdata.application_data_len =
|
||||
sizeof(Handler_Transmit_Buffer) - (npdu_len + apdu_len);
|
||||
len = Device_Read_Property(&rpdata);
|
||||
if (len >= 0) {
|
||||
apdu_len += len;
|
||||
len = rp_ack_encode_apdu_object_property_end(
|
||||
&Handler_Transmit_Buffer[npdu_len+apdu_len]);
|
||||
apdu_len += len;
|
||||
if (apdu_len > service_data->max_resp) {
|
||||
/* too big for the sender - send an abort */
|
||||
apdu_len =
|
||||
abort_encode_apdu(&Handler_Transmit_Buffer[npdu_len],
|
||||
service_data->invoke_id, ABORT_REASON_SEGMENTATION_NOT_SUPPORTED,
|
||||
true);
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "RP: Message too large. Sending Abort!\n");
|
||||
fprintf(stderr, "RP: Message too large. Sending Abort!\n");
|
||||
#endif
|
||||
goto RP_ABORT;
|
||||
} else {
|
||||
goto RP_ABORT;
|
||||
} else {
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "RP: Sending Ack!\n");
|
||||
fprintf(stderr, "RP: Sending Ack!\n");
|
||||
#endif
|
||||
error = false;
|
||||
}
|
||||
error = false;
|
||||
}
|
||||
}
|
||||
if (error) {
|
||||
|
||||
@@ -38,25 +38,11 @@
|
||||
#include "abort.h"
|
||||
#include "rpm.h"
|
||||
#include "handlers.h"
|
||||
/* device object has custom handler for all objects */
|
||||
#include "device.h"
|
||||
|
||||
/** @file h_rpm.c Handles Read Property Multiple requests. */
|
||||
|
||||
/* function that handles the reading of properties from objects */
|
||||
static read_property_function Read_Property_Function;
|
||||
static rpm_object_property_lists_function RPM_Property_List;
|
||||
|
||||
void handler_rpm_function_set(
|
||||
read_property_function pFunction)
|
||||
{
|
||||
Read_Property_Function = pFunction;
|
||||
}
|
||||
|
||||
void handler_rpm_list_set(
|
||||
rpm_object_property_lists_function pFunction)
|
||||
{
|
||||
RPM_Property_List = pFunction;
|
||||
}
|
||||
|
||||
static uint8_t Temp_Buf[MAX_APDU] = { 0 };
|
||||
|
||||
static BACNET_PROPERTY_ID RPM_Object_Property(
|
||||
@@ -137,17 +123,15 @@ static int RPM_Encode_Property(
|
||||
}
|
||||
apdu_len += len;
|
||||
len = 0;
|
||||
if (Read_Property_Function) {
|
||||
rpdata.error_class = ERROR_CLASS_OBJECT;
|
||||
rpdata.error_code = ERROR_CODE_UNKNOWN_OBJECT;
|
||||
rpdata.object_type = object_type;
|
||||
rpdata.object_instance = object_instance;
|
||||
rpdata.object_property = object_property;
|
||||
rpdata.array_index = array_index;
|
||||
rpdata.application_data = &Temp_Buf[0];
|
||||
rpdata.application_data_len = sizeof(Temp_Buf);
|
||||
len = Read_Property_Function(&rpdata);
|
||||
}
|
||||
rpdata.error_class = ERROR_CLASS_OBJECT;
|
||||
rpdata.error_code = ERROR_CODE_UNKNOWN_OBJECT;
|
||||
rpdata.object_type = object_type;
|
||||
rpdata.object_instance = object_instance;
|
||||
rpdata.object_property = object_property;
|
||||
rpdata.array_index = array_index;
|
||||
rpdata.application_data = &Temp_Buf[0];
|
||||
rpdata.application_data_len = sizeof(Temp_Buf);
|
||||
len = Device_Read_Property(&rpdata);
|
||||
if (len < 0) {
|
||||
/* error was returned - encode that for the response */
|
||||
len =
|
||||
@@ -311,7 +295,7 @@ void handler_read_property_multiple(
|
||||
BACNET_PROPERTY_ID special_object_property;
|
||||
|
||||
special_object_property = object_property;
|
||||
RPM_Property_List(object_type, &property_list);
|
||||
Device_Objects_Property_List(object_type, &property_list);
|
||||
property_count =
|
||||
RPM_Object_Property_Count(&property_list,
|
||||
special_object_property);
|
||||
|
||||
Reference in New Issue
Block a user