Changed Object Table from a global to a local variable and added a Device function to initialize it.
This commit is contained in:
@@ -52,9 +52,9 @@
|
||||
#include "dlenv.h"
|
||||
|
||||
/* All included BACnet objects */
|
||||
object_functions_t Object_Table[] = {
|
||||
{DEVICE_OBJ_FUNCTIONS},
|
||||
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
||||
static object_functions_t Object_Table[] = {
|
||||
{DEVICE_OBJ_FUNCTIONS},
|
||||
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
||||
};
|
||||
|
||||
/* buffer used for receive */
|
||||
@@ -122,6 +122,7 @@ void MyDeviceCommunicationControlSimpleAckHandler(
|
||||
static void Init_Service_Handlers(
|
||||
void)
|
||||
{
|
||||
Device_Initialize_Object_Functions(&Object_Table[0]);
|
||||
Device_Init();
|
||||
/* we need to handle who-is
|
||||
to support dynamic device binding to us */
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
* @{ */
|
||||
|
||||
/* All included BACnet objects */
|
||||
object_functions_t Object_Table[] = {
|
||||
static object_functions_t Object_Table[] = {
|
||||
{DEVICE_OBJ_FUNCTIONS},
|
||||
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
||||
};
|
||||
@@ -270,6 +270,7 @@ void MyReadPropertyMultipleAckHandler(
|
||||
static void Init_Service_Handlers(
|
||||
void)
|
||||
{
|
||||
Device_Initialize_Object_Functions(&Object_Table[0]);
|
||||
Device_Init();
|
||||
|
||||
#if BAC_ROUTING
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
/*@{*/
|
||||
|
||||
/* All included BACnet objects */
|
||||
object_functions_t Object_Table[] = {
|
||||
static object_functions_t Object_Table[] = {
|
||||
{DEVICE_OBJ_FUNCTIONS},
|
||||
{ANALOG_INPUT_OBJ_FUNCTIONS},
|
||||
{ANALOG_OUTPUT_OBJ_FUNCTIONS},
|
||||
@@ -155,6 +155,7 @@ void Devices_Init(
|
||||
static void Init_Service_Handlers(
|
||||
uint32_t first_object_instance )
|
||||
{
|
||||
Device_Initialize_Object_Functions(&Object_Table[0]);
|
||||
Routing_Device_Init( first_object_instance );
|
||||
|
||||
/* we need to handle who-is to support dynamic device binding
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
#include "dlenv.h"
|
||||
|
||||
/* All included BACnet objects */
|
||||
object_functions_t Object_Table[] = {
|
||||
static object_functions_t Object_Table[] = {
|
||||
{DEVICE_OBJ_FUNCTIONS},
|
||||
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
||||
};
|
||||
@@ -90,6 +90,7 @@ void MyRejectHandler(
|
||||
static void Init_Service_Handlers(
|
||||
void)
|
||||
{
|
||||
Device_Initialize_Object_Functions(&Object_Table[0]);
|
||||
Device_Init();
|
||||
/* we need to handle who-is
|
||||
to support dynamic device binding to us */
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
#include "dlenv.h"
|
||||
|
||||
/* All included BACnet objects */
|
||||
object_functions_t Object_Table[] = {
|
||||
static object_functions_t Object_Table[] = {
|
||||
{DEVICE_OBJ_FUNCTIONS},
|
||||
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
||||
};
|
||||
@@ -220,6 +220,7 @@ static void My_NPDU_Handler(
|
||||
static void Init_Service_Handlers(
|
||||
void)
|
||||
{
|
||||
Device_Initialize_Object_Functions(&Object_Table[0]);
|
||||
Device_Init();
|
||||
/* we need to handle who-is
|
||||
to support dynamic device binding to us */
|
||||
|
||||
@@ -64,7 +64,7 @@ extern bool Routed_Device_Write_Property_Local(
|
||||
|
||||
/* Defined in user application;
|
||||
object functions for all included BACnet objects */
|
||||
extern object_functions_t Object_Table[];
|
||||
static object_functions_t *Object_Table;
|
||||
|
||||
/** Glue function to let the Device object, when called by a handler,
|
||||
* lookup which Object type needs to be invoked.
|
||||
@@ -1321,6 +1321,17 @@ bool Device_Write_Property(
|
||||
return (status);
|
||||
}
|
||||
|
||||
/** Initialize the group of object helper functions for any supported Object.
|
||||
* @ingroup ObjIntf
|
||||
* @param object_table [in,out] array of structure with object functions.
|
||||
* Each Child Object must provide some implementation of each of these
|
||||
* functions in order to properly support the default handlers.
|
||||
*/
|
||||
void Device_Initialize_Object_Functions(
|
||||
object_functions_t *object_table)
|
||||
{
|
||||
Object_Table = object_table;
|
||||
}
|
||||
|
||||
/** Initialize the Device Object and each of its child Object instances.
|
||||
* @ingroup ObjIntf
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
#include "dlenv.h"
|
||||
|
||||
/* All included BACnet objects */
|
||||
object_functions_t Object_Table[] = {
|
||||
static object_functions_t Object_Table[] = {
|
||||
{DEVICE_OBJ_FUNCTIONS},
|
||||
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
||||
};
|
||||
@@ -185,6 +185,7 @@ static void LocalIAmHandler(
|
||||
static void Init_Service_Handlers(
|
||||
void)
|
||||
{
|
||||
Device_Initialize_Object_Functions(&Object_Table[0]);
|
||||
Device_Init();
|
||||
/* we need to handle who-is
|
||||
to support dynamic device binding to us */
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
#include "dlenv.h"
|
||||
|
||||
/* All included BACnet objects */
|
||||
object_functions_t Object_Table[] = {
|
||||
static object_functions_t Object_Table[] = {
|
||||
{DEVICE_OBJ_FUNCTIONS},
|
||||
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
||||
};
|
||||
@@ -149,6 +149,7 @@ void My_Read_Property_Ack_Handler(
|
||||
static void Init_Service_Handlers(
|
||||
void)
|
||||
{
|
||||
Device_Initialize_Object_Functions(&Object_Table[0]);
|
||||
Device_Init();
|
||||
/* we need to handle who-is
|
||||
to support dynamic device binding to us */
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
#include "dlenv.h"
|
||||
|
||||
/* All included BACnet objects */
|
||||
object_functions_t Object_Table[] = {
|
||||
static object_functions_t Object_Table[] = {
|
||||
{DEVICE_OBJ_FUNCTIONS},
|
||||
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
||||
};
|
||||
@@ -194,6 +194,7 @@ void My_Read_Property_Multiple_Ack_Handler(
|
||||
static void Init_Service_Handlers(
|
||||
void)
|
||||
{
|
||||
Device_Initialize_Object_Functions(&Object_Table[0]);
|
||||
Device_Init();
|
||||
/* we need to handle who-is
|
||||
to support dynamic device binding to us */
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
#include "dlenv.h"
|
||||
|
||||
/* All included BACnet objects */
|
||||
object_functions_t Object_Table[] = {
|
||||
static object_functions_t Object_Table[] = {
|
||||
{DEVICE_OBJ_FUNCTIONS},
|
||||
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
||||
};
|
||||
@@ -120,6 +120,7 @@ void MyReinitializeDeviceSimpleAckHandler(
|
||||
static void Init_Service_Handlers(
|
||||
void)
|
||||
{
|
||||
Device_Initialize_Object_Functions(&Object_Table[0]);
|
||||
Device_Init();
|
||||
/* we need to handle who-is
|
||||
to support dynamic device binding to us */
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
#endif
|
||||
|
||||
/* All included BACnet objects */
|
||||
object_functions_t Object_Table[] = {
|
||||
static object_functions_t Object_Table[] = {
|
||||
{DEVICE_OBJ_FUNCTIONS},
|
||||
{ANALOG_INPUT_OBJ_FUNCTIONS},
|
||||
{ANALOG_OUTPUT_OBJ_FUNCTIONS},
|
||||
@@ -101,6 +101,7 @@ static uint8_t Rx_Buf[MAX_MPDU] = { 0 };
|
||||
static void Init_Service_Handlers(
|
||||
void)
|
||||
{
|
||||
Device_Initialize_Object_Functions(&Object_Table[0]);
|
||||
Device_Init();
|
||||
/* we need to handle who-is to support dynamic device binding */
|
||||
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is);
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
#include "dlenv.h"
|
||||
|
||||
/* All included BACnet objects */
|
||||
object_functions_t Object_Table[] = {
|
||||
static object_functions_t Object_Table[] = {
|
||||
{DEVICE_OBJ_FUNCTIONS},
|
||||
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
||||
};
|
||||
@@ -92,6 +92,7 @@ void MyRejectHandler(
|
||||
static void Init_Service_Handlers(
|
||||
void)
|
||||
{
|
||||
Device_Initialize_Object_Functions(&Object_Table[0]);
|
||||
Device_Init();
|
||||
/* we need to handle who-is
|
||||
to support dynamic device binding to us */
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
#include "dlenv.h"
|
||||
|
||||
/* All included BACnet objects */
|
||||
object_functions_t Object_Table[] = {
|
||||
static object_functions_t Object_Table[] = {
|
||||
{DEVICE_OBJ_FUNCTIONS},
|
||||
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
||||
};
|
||||
@@ -59,6 +59,7 @@ object_functions_t Object_Table[] = {
|
||||
static void Init_Service_Handlers(
|
||||
void)
|
||||
{
|
||||
Device_Initialize_Object_Functions(&Object_Table[0]);
|
||||
Device_Init();
|
||||
/* we need to handle who-is
|
||||
to support dynamic device binding to us */
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
#include "dlenv.h"
|
||||
|
||||
/* All included BACnet objects */
|
||||
object_functions_t Object_Table[] = {
|
||||
static object_functions_t Object_Table[] = {
|
||||
{DEVICE_OBJ_FUNCTIONS},
|
||||
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
||||
};
|
||||
@@ -95,6 +95,7 @@ void MyRejectHandler(
|
||||
static void Init_Service_Handlers(
|
||||
void)
|
||||
{
|
||||
Device_Initialize_Object_Functions(&Object_Table[0]);
|
||||
Device_Init();
|
||||
/* we need to handle who-is
|
||||
to support dynamic device binding to us */
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
#include "dlenv.h"
|
||||
|
||||
/* All included BACnet objects */
|
||||
object_functions_t Object_Table[] = {
|
||||
static object_functions_t Object_Table[] = {
|
||||
{DEVICE_OBJ_FUNCTIONS},
|
||||
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
||||
};
|
||||
@@ -95,6 +95,7 @@ void MyRejectHandler(
|
||||
static void Init_Service_Handlers(
|
||||
void)
|
||||
{
|
||||
Device_Initialize_Object_Functions(&Object_Table[0]);
|
||||
Device_Init();
|
||||
/* Note: this applications doesn't need to handle who-is
|
||||
it is confusing for the user! */
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
#include "dlenv.h"
|
||||
|
||||
/* All included BACnet objects */
|
||||
object_functions_t Object_Table[] = {
|
||||
static object_functions_t Object_Table[] = {
|
||||
{DEVICE_OBJ_FUNCTIONS},
|
||||
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
||||
};
|
||||
@@ -175,6 +175,7 @@ void My_NPDU_Handler(
|
||||
static void Init_Service_Handlers(
|
||||
void)
|
||||
{
|
||||
Device_Initialize_Object_Functions(&Object_Table[0]);
|
||||
Device_Init();
|
||||
/* we need to handle who-is
|
||||
to support dynamic device binding to us */
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
#include "dlenv.h"
|
||||
|
||||
/* All included BACnet objects */
|
||||
object_functions_t Object_Table[] = {
|
||||
static object_functions_t Object_Table[] = {
|
||||
{DEVICE_OBJ_FUNCTIONS},
|
||||
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
||||
};
|
||||
@@ -139,6 +139,7 @@ static void LocalIAmHandler(
|
||||
static void Init_Service_Handlers(
|
||||
void)
|
||||
{
|
||||
Device_Initialize_Object_Functions(&Object_Table[0]);
|
||||
Device_Init();
|
||||
/* we need to handle who-is
|
||||
to support dynamic device binding to us */
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
#endif
|
||||
|
||||
/* All included BACnet objects */
|
||||
object_functions_t Object_Table[] = {
|
||||
static object_functions_t Object_Table[] = {
|
||||
{DEVICE_OBJ_FUNCTIONS},
|
||||
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
||||
};
|
||||
@@ -140,6 +140,7 @@ void MyWritePropertySimpleAckHandler(
|
||||
static void Init_Service_Handlers(
|
||||
void)
|
||||
{
|
||||
Device_Initialize_Object_Functions(&Object_Table[0]);
|
||||
Device_Init();
|
||||
/* we need to handle who-is
|
||||
to support dynamic device binding to us */
|
||||
|
||||
@@ -134,20 +134,20 @@ typedef struct object_functions {
|
||||
typedef struct commonBacObj_s
|
||||
{
|
||||
|
||||
/** The BACnet type of this object (ie, what class is this object from?).
|
||||
* This property, of type BACnetObjectType, indicates membership in a
|
||||
* particular object type class. Each inherited class will be of one type.
|
||||
*/
|
||||
BACNET_OBJECT_TYPE mObject_Type;
|
||||
/** The BACnet type of this object (ie, what class is this object from?).
|
||||
* This property, of type BACnetObjectType, indicates membership in a
|
||||
* particular object type class. Each inherited class will be of one type.
|
||||
*/
|
||||
BACNET_OBJECT_TYPE mObject_Type;
|
||||
|
||||
/** The instance number for this class instance. */
|
||||
uint32_t Object_Instance_Number;
|
||||
/** The instance number for this class instance. */
|
||||
uint32_t Object_Instance_Number;
|
||||
|
||||
/** Object Name; must be unique.
|
||||
* This property, of type CharacterString, shall represent a name for
|
||||
* the object that is unique within the BACnet Device that maintains it.
|
||||
*/
|
||||
char Object_Name[MAX_DEV_NAME_LEN];
|
||||
/** Object Name; must be unique.
|
||||
* This property, of type CharacterString, shall represent a name for
|
||||
* the object that is unique within the BACnet Device that maintains it.
|
||||
*/
|
||||
char Object_Name[MAX_DEV_NAME_LEN];
|
||||
|
||||
} COMMON_BAC_OBJECT;
|
||||
|
||||
@@ -162,17 +162,17 @@ typedef struct commonBacObj_s
|
||||
*/
|
||||
typedef struct devObj_s
|
||||
{
|
||||
/** The BACnet Device Address for this device; ->len depends on DLL type. */
|
||||
BACNET_ADDRESS bacDevAddr;
|
||||
/** The BACnet Device Address for this device; ->len depends on DLL type. */
|
||||
BACNET_ADDRESS bacDevAddr;
|
||||
|
||||
/** Structure for the Object Properties common to all Objects. */
|
||||
COMMON_BAC_OBJECT bacObj;
|
||||
/** Structure for the Object Properties common to all Objects. */
|
||||
COMMON_BAC_OBJECT bacObj;
|
||||
|
||||
/** Device Description. */
|
||||
char Description[MAX_DEV_DESC_LEN];
|
||||
/** Device Description. */
|
||||
char Description[MAX_DEV_DESC_LEN];
|
||||
|
||||
/** The upcounter that shows if the Device ID or object structure has changed. */
|
||||
uint32_t Database_Revision;
|
||||
/** The upcounter that shows if the Device ID or object structure has changed. */
|
||||
uint32_t Database_Revision;
|
||||
} DEVICE_OBJECT_DATA;
|
||||
|
||||
|
||||
@@ -182,6 +182,8 @@ extern "C" {
|
||||
|
||||
void Device_Init(
|
||||
void);
|
||||
void Device_Initialize_Object_Functions(
|
||||
object_functions_t *object_table);
|
||||
|
||||
bool Device_Reinitialize(
|
||||
BACNET_REINITIALIZE_DEVICE_DATA * rd_data);
|
||||
@@ -309,31 +311,31 @@ extern "C" {
|
||||
* in the build (lib/Makefile).
|
||||
*/
|
||||
void Routing_Device_Init(
|
||||
uint32_t first_object_instance );
|
||||
uint32_t first_object_instance );
|
||||
|
||||
uint16_t Add_Routed_Device(
|
||||
uint32_t Object_Instance,
|
||||
const char * Object_Name,
|
||||
const char * Description );
|
||||
uint32_t Object_Instance,
|
||||
const char * Object_Name,
|
||||
const char * Description );
|
||||
DEVICE_OBJECT_DATA * Get_Routed_Device_Object(
|
||||
int idx );
|
||||
int idx );
|
||||
BACNET_ADDRESS * Get_Routed_Device_Address(
|
||||
int idx );
|
||||
int idx );
|
||||
|
||||
void routed_get_my_address(
|
||||
BACNET_ADDRESS * my_address);
|
||||
|
||||
bool Routed_Device_Address_Lookup(
|
||||
int idx,
|
||||
uint8_t address_len,
|
||||
uint8_t * mac_adress );
|
||||
int idx,
|
||||
uint8_t address_len,
|
||||
uint8_t * mac_adress );
|
||||
bool Routed_Device_GetNext(
|
||||
BACNET_ADDRESS * dest,
|
||||
int * DNET_list,
|
||||
int * cursor );
|
||||
BACNET_ADDRESS * dest,
|
||||
int * DNET_list,
|
||||
int * cursor );
|
||||
bool Routed_Device_Is_Valid_Network(
|
||||
uint16_t dest_net,
|
||||
int * DNET_list );
|
||||
uint16_t dest_net,
|
||||
int * DNET_list );
|
||||
|
||||
uint32_t Routed_Device_Index_To_Instance(
|
||||
unsigned index);
|
||||
|
||||
Reference in New Issue
Block a user