Changed RR handler to call Device_Objects_RR_Info directly.
Removed handler_rr_object_set and associated info. Simplified parameter passing to rr info functions by passing ptr to BACnet_Read_Range_Data.
This commit is contained in:
@@ -36,20 +36,12 @@
|
|||||||
#include "npdu.h"
|
#include "npdu.h"
|
||||||
#include "abort.h"
|
#include "abort.h"
|
||||||
#include "readrange.h"
|
#include "readrange.h"
|
||||||
|
#include "device.h"
|
||||||
|
|
||||||
/** @file h_rr.c Handles Read Range requests. */
|
/** @file h_rr.c Handles Read Range requests. */
|
||||||
|
|
||||||
static uint8_t Temp_Buf[MAX_APDU] = { 0 };
|
static uint8_t Temp_Buf[MAX_APDU] = { 0 };
|
||||||
|
|
||||||
|
|
||||||
static get_rr_info_fn get_rr_info;
|
|
||||||
|
|
||||||
void handler_rr_object_set(
|
|
||||||
get_rr_info_fn pFunction1)
|
|
||||||
{
|
|
||||||
get_rr_info = pFunction1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Encodes the property APDU and returns the length,
|
/* Encodes the property APDU and returns the length,
|
||||||
or sets the error, and returns -1 */
|
or sets the error, and returns -1 */
|
||||||
int Encode_RR_payload(
|
int Encode_RR_payload(
|
||||||
@@ -65,9 +57,9 @@ int Encode_RR_payload(
|
|||||||
pRequest->error_code = ERROR_CODE_OTHER;
|
pRequest->error_code = ERROR_CODE_OTHER;
|
||||||
|
|
||||||
/* handle each object type */
|
/* handle each object type */
|
||||||
info_fn_ptr = *get_rr_info(pRequest->object_type);
|
info_fn_ptr = Device_Objects_RR_Info(pRequest->object_type);
|
||||||
|
|
||||||
if ((get_rr_info != NULL) && (info_fn_ptr(pRequest->object_instance, pRequest->object_property, &PropInfo, &pRequest->error_class, &pRequest->error_code) != false)) {
|
if ((info_fn_ptr != NULL) && (info_fn_ptr(pRequest, &PropInfo) != false)) {
|
||||||
/* We try and do some of the more generic error checking here to cut down on duplication of effort */
|
/* We try and do some of the more generic error checking here to cut down on duplication of effort */
|
||||||
|
|
||||||
if((pRequest->RequestType == RR_BY_POSITION) && (pRequest->Range.RefIndex == 0)) {/* First index is 1 so can't accept 0 */
|
if((pRequest->RequestType == RR_BY_POSITION) && (pRequest->Range.RefIndex == 0)) {/* First index is 1 so can't accept 0 */
|
||||||
|
|||||||
@@ -1395,8 +1395,6 @@ void Device_Init(
|
|||||||
{
|
{
|
||||||
struct object_functions *pObject = NULL;
|
struct object_functions *pObject = NULL;
|
||||||
|
|
||||||
handler_rr_object_set(Device_Objects_RR_Info);
|
|
||||||
|
|
||||||
pObject = &Object_Table[0];
|
pObject = &Object_Table[0];
|
||||||
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
|
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
|
||||||
if (pObject->Object_Init) {
|
if (pObject->Object_Init) {
|
||||||
@@ -1407,16 +1405,12 @@ void Device_Init(
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool DeviceGetRRInfo(
|
bool DeviceGetRRInfo(
|
||||||
uint32_t object, /* Which particular object - obviously not important for device object */
|
BACNET_READ_RANGE_DATA *pRequest, /* Info on the request */
|
||||||
BACNET_PROPERTY_ID property, /* Which property */
|
RR_PROP_INFO *pInfo) /* Where to put the response */
|
||||||
RR_PROP_INFO *pInfo, /* Where to put the information */
|
|
||||||
BACNET_ERROR_CLASS *error_class,
|
|
||||||
BACNET_ERROR_CODE *error_code)
|
|
||||||
{
|
{
|
||||||
bool status = false; /* return value */
|
bool status = false; /* return value */
|
||||||
|
|
||||||
object = object;
|
switch(pRequest->object_property) {
|
||||||
switch(property) {
|
|
||||||
case PROP_VT_CLASSES_SUPPORTED:
|
case PROP_VT_CLASSES_SUPPORTED:
|
||||||
case PROP_ACTIVE_VT_SESSIONS:
|
case PROP_ACTIVE_VT_SESSIONS:
|
||||||
case PROP_LIST_OF_SESSION_KEYS:
|
case PROP_LIST_OF_SESSION_KEYS:
|
||||||
@@ -1426,8 +1420,8 @@ bool DeviceGetRRInfo(
|
|||||||
case PROP_RESTART_NOTIFICATION_RECIPIENTS:
|
case PROP_RESTART_NOTIFICATION_RECIPIENTS:
|
||||||
case PROP_UTC_TIME_SYNCHRONIZATION_RECIPIENTS:
|
case PROP_UTC_TIME_SYNCHRONIZATION_RECIPIENTS:
|
||||||
pInfo->RequestTypes = RR_BY_POSITION;
|
pInfo->RequestTypes = RR_BY_POSITION;
|
||||||
*error_class = ERROR_CLASS_PROPERTY;
|
pRequest->error_class = ERROR_CLASS_PROPERTY;
|
||||||
*error_code = ERROR_CODE_UNKNOWN_PROPERTY;
|
pRequest->error_code = ERROR_CODE_UNKNOWN_PROPERTY;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_DEVICE_ADDRESS_BINDING:
|
case PROP_DEVICE_ADDRESS_BINDING:
|
||||||
@@ -1438,12 +1432,12 @@ bool DeviceGetRRInfo(
|
|||||||
|
|
||||||
case PROP_ACTIVE_COV_SUBSCRIPTIONS:
|
case PROP_ACTIVE_COV_SUBSCRIPTIONS:
|
||||||
pInfo->RequestTypes = RR_BY_POSITION;
|
pInfo->RequestTypes = RR_BY_POSITION;
|
||||||
*error_class = ERROR_CLASS_PROPERTY;
|
pRequest->error_class = ERROR_CLASS_PROPERTY;
|
||||||
*error_code = ERROR_CODE_UNKNOWN_PROPERTY;
|
pRequest->error_code = ERROR_CODE_UNKNOWN_PROPERTY;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
*error_class = ERROR_CLASS_SERVICES;
|
pRequest->error_class = ERROR_CLASS_SERVICES;
|
||||||
*error_code = ERROR_CODE_PROPERTY_IS_NOT_A_LIST;
|
pRequest->error_code = ERROR_CODE_PROPERTY_IS_NOT_A_LIST;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -907,22 +907,19 @@ void TrendLog_Init(
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool TrendLogGetRRInfo(
|
bool TrendLogGetRRInfo(
|
||||||
uint32_t Object, /* Which particular object */
|
BACNET_READ_RANGE_DATA *pRequest, /* Info on the request */
|
||||||
BACNET_PROPERTY_ID Property, /* Which property */
|
RR_PROP_INFO *pInfo) /* Where to put the information */
|
||||||
RR_PROP_INFO *pInfo, /* Where to put the information */
|
|
||||||
BACNET_ERROR_CLASS *error_class,
|
|
||||||
BACNET_ERROR_CODE *error_code)
|
|
||||||
{
|
{
|
||||||
if(Object >= MAX_TREND_LOGS) {
|
if(pRequest->object_instance >= MAX_TREND_LOGS) {
|
||||||
*error_class = ERROR_CLASS_OBJECT;
|
pRequest->error_class = ERROR_CLASS_OBJECT;
|
||||||
*error_code = ERROR_CODE_UNKNOWN_OBJECT;
|
pRequest->error_code = ERROR_CODE_UNKNOWN_OBJECT;
|
||||||
} else if(Property == PROP_LOG_BUFFER) {
|
} else if(pRequest->object_property == PROP_LOG_BUFFER) {
|
||||||
pInfo->RequestTypes = RR_BY_POSITION | RR_BY_TIME | RR_BY_SEQUENCE;
|
pInfo->RequestTypes = RR_BY_POSITION | RR_BY_TIME | RR_BY_SEQUENCE;
|
||||||
pInfo->Handler = rr_trend_log_encode;
|
pInfo->Handler = rr_trend_log_encode;
|
||||||
return(true);
|
return(true);
|
||||||
} else {
|
} else {
|
||||||
*error_class = ERROR_CLASS_SERVICES;
|
pRequest->error_class = ERROR_CLASS_SERVICES;
|
||||||
*error_code = ERROR_CODE_PROPERTY_IS_NOT_A_LIST;
|
pRequest->error_code = ERROR_CODE_PROPERTY_IS_NOT_A_LIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(false);
|
return(false);
|
||||||
|
|||||||
@@ -73,6 +73,9 @@ extern "C" {
|
|||||||
bool Device_Reinitialize(
|
bool Device_Reinitialize(
|
||||||
BACNET_REINITIALIZE_DEVICE_DATA *rd_data);
|
BACNET_REINITIALIZE_DEVICE_DATA *rd_data);
|
||||||
|
|
||||||
|
rr_info_function Device_Objects_RR_Info(
|
||||||
|
BACNET_OBJECT_TYPE object_type);
|
||||||
|
|
||||||
void Device_Property_Lists(
|
void Device_Property_Lists(
|
||||||
const int **pRequired,
|
const int **pRequired,
|
||||||
const int **pOptional,
|
const int **pOptional,
|
||||||
@@ -174,11 +177,8 @@ extern "C" {
|
|||||||
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
||||||
|
|
||||||
bool DeviceGetRRInfo(
|
bool DeviceGetRRInfo(
|
||||||
uint32_t Object, /* Which particular object - obviously not important for device object */
|
BACNET_READ_RANGE_DATA *pRequest, /* Info on the request */
|
||||||
BACNET_PROPERTY_ID Property, /* Which property */
|
RR_PROP_INFO *pInfo); /* Where to put the information */
|
||||||
RR_PROP_INFO *pInfo, /* Where to put the information */
|
|
||||||
BACNET_ERROR_CLASS *error_class,
|
|
||||||
BACNET_ERROR_CODE *error_code);
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -80,9 +80,6 @@ extern "C" {
|
|||||||
BACNET_ADDRESS * src,
|
BACNET_ADDRESS * src,
|
||||||
BACNET_CONFIRMED_SERVICE_DATA * service_data);
|
BACNET_CONFIRMED_SERVICE_DATA * service_data);
|
||||||
|
|
||||||
void handler_rr_object_set(
|
|
||||||
get_rr_info_fn pFunction1);
|
|
||||||
|
|
||||||
void handler_read_property_ack(
|
void handler_read_property_ack(
|
||||||
uint8_t * service_request,
|
uint8_t * service_request,
|
||||||
uint16_t service_len,
|
uint16_t service_len,
|
||||||
|
|||||||
@@ -127,14 +127,8 @@ typedef struct rrpropertyinfo {
|
|||||||
/* Function pointer for ReadRange information retrieval function */
|
/* Function pointer for ReadRange information retrieval function */
|
||||||
|
|
||||||
typedef bool (*rr_info_function) (
|
typedef bool (*rr_info_function) (
|
||||||
uint32_t Object, /* Which particular object instance (we know the type implicetly) */
|
BACNET_READ_RANGE_DATA *pRequest, /* Info on the request */
|
||||||
BACNET_PROPERTY_ID Property, /* Which property */
|
RR_PROP_INFO *pInfo); /* Where to write the response to */
|
||||||
RR_PROP_INFO *pInfo, /* Where to write the response to */
|
|
||||||
BACNET_ERROR_CLASS *error_class, /* Somewhere to write error responses to */
|
|
||||||
BACNET_ERROR_CODE *error_code);
|
|
||||||
|
|
||||||
typedef rr_info_function (*get_rr_info_fn) (
|
|
||||||
BACNET_OBJECT_TYPE object_type);
|
|
||||||
|
|
||||||
int rr_encode_apdu(
|
int rr_encode_apdu(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
|
|||||||
@@ -97,11 +97,8 @@ extern "C" {
|
|||||||
BACNET_READ_RANGE_DATA *pRequest);
|
BACNET_READ_RANGE_DATA *pRequest);
|
||||||
|
|
||||||
bool TrendLogGetRRInfo(
|
bool TrendLogGetRRInfo(
|
||||||
uint32_t Object, /* Which particular object */
|
BACNET_READ_RANGE_DATA *pRequest, /* Info on the request */
|
||||||
BACNET_PROPERTY_ID Property, /* Which property */
|
RR_PROP_INFO *pInfo); /* Where to put the information */
|
||||||
RR_PROP_INFO *pInfo, /* Where to put the information */
|
|
||||||
BACNET_ERROR_CLASS *error_class,
|
|
||||||
BACNET_ERROR_CODE *error_code);
|
|
||||||
|
|
||||||
int rr_trend_log_encode(
|
int rr_trend_log_encode(
|
||||||
uint8_t *apdu,
|
uint8_t *apdu,
|
||||||
|
|||||||
Reference in New Issue
Block a user