Changed Object Table from a global to a local variable and added a Device function to initialize it.
This commit is contained in:
@@ -52,7 +52,7 @@
|
|||||||
#include "dlenv.h"
|
#include "dlenv.h"
|
||||||
|
|
||||||
/* All included BACnet objects */
|
/* All included BACnet objects */
|
||||||
object_functions_t Object_Table[] = {
|
static object_functions_t Object_Table[] = {
|
||||||
{DEVICE_OBJ_FUNCTIONS},
|
{DEVICE_OBJ_FUNCTIONS},
|
||||||
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
||||||
};
|
};
|
||||||
@@ -122,6 +122,7 @@ void MyDeviceCommunicationControlSimpleAckHandler(
|
|||||||
static void Init_Service_Handlers(
|
static void Init_Service_Handlers(
|
||||||
void)
|
void)
|
||||||
{
|
{
|
||||||
|
Device_Initialize_Object_Functions(&Object_Table[0]);
|
||||||
Device_Init();
|
Device_Init();
|
||||||
/* we need to handle who-is
|
/* we need to handle who-is
|
||||||
to support dynamic device binding to us */
|
to support dynamic device binding to us */
|
||||||
|
|||||||
@@ -63,7 +63,7 @@
|
|||||||
* @{ */
|
* @{ */
|
||||||
|
|
||||||
/* All included BACnet objects */
|
/* All included BACnet objects */
|
||||||
object_functions_t Object_Table[] = {
|
static object_functions_t Object_Table[] = {
|
||||||
{DEVICE_OBJ_FUNCTIONS},
|
{DEVICE_OBJ_FUNCTIONS},
|
||||||
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
||||||
};
|
};
|
||||||
@@ -270,6 +270,7 @@ void MyReadPropertyMultipleAckHandler(
|
|||||||
static void Init_Service_Handlers(
|
static void Init_Service_Handlers(
|
||||||
void)
|
void)
|
||||||
{
|
{
|
||||||
|
Device_Initialize_Object_Functions(&Object_Table[0]);
|
||||||
Device_Init();
|
Device_Init();
|
||||||
|
|
||||||
#if BAC_ROUTING
|
#if BAC_ROUTING
|
||||||
|
|||||||
@@ -82,7 +82,7 @@
|
|||||||
/*@{*/
|
/*@{*/
|
||||||
|
|
||||||
/* All included BACnet objects */
|
/* All included BACnet objects */
|
||||||
object_functions_t Object_Table[] = {
|
static object_functions_t Object_Table[] = {
|
||||||
{DEVICE_OBJ_FUNCTIONS},
|
{DEVICE_OBJ_FUNCTIONS},
|
||||||
{ANALOG_INPUT_OBJ_FUNCTIONS},
|
{ANALOG_INPUT_OBJ_FUNCTIONS},
|
||||||
{ANALOG_OUTPUT_OBJ_FUNCTIONS},
|
{ANALOG_OUTPUT_OBJ_FUNCTIONS},
|
||||||
@@ -155,6 +155,7 @@ void Devices_Init(
|
|||||||
static void Init_Service_Handlers(
|
static void Init_Service_Handlers(
|
||||||
uint32_t first_object_instance )
|
uint32_t first_object_instance )
|
||||||
{
|
{
|
||||||
|
Device_Initialize_Object_Functions(&Object_Table[0]);
|
||||||
Routing_Device_Init( first_object_instance );
|
Routing_Device_Init( first_object_instance );
|
||||||
|
|
||||||
/* we need to handle who-is to support dynamic device binding
|
/* we need to handle who-is to support dynamic device binding
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
#include "dlenv.h"
|
#include "dlenv.h"
|
||||||
|
|
||||||
/* All included BACnet objects */
|
/* All included BACnet objects */
|
||||||
object_functions_t Object_Table[] = {
|
static object_functions_t Object_Table[] = {
|
||||||
{DEVICE_OBJ_FUNCTIONS},
|
{DEVICE_OBJ_FUNCTIONS},
|
||||||
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
||||||
};
|
};
|
||||||
@@ -90,6 +90,7 @@ void MyRejectHandler(
|
|||||||
static void Init_Service_Handlers(
|
static void Init_Service_Handlers(
|
||||||
void)
|
void)
|
||||||
{
|
{
|
||||||
|
Device_Initialize_Object_Functions(&Object_Table[0]);
|
||||||
Device_Init();
|
Device_Init();
|
||||||
/* we need to handle who-is
|
/* we need to handle who-is
|
||||||
to support dynamic device binding to us */
|
to support dynamic device binding to us */
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
#include "dlenv.h"
|
#include "dlenv.h"
|
||||||
|
|
||||||
/* All included BACnet objects */
|
/* All included BACnet objects */
|
||||||
object_functions_t Object_Table[] = {
|
static object_functions_t Object_Table[] = {
|
||||||
{DEVICE_OBJ_FUNCTIONS},
|
{DEVICE_OBJ_FUNCTIONS},
|
||||||
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
{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(
|
static void Init_Service_Handlers(
|
||||||
void)
|
void)
|
||||||
{
|
{
|
||||||
|
Device_Initialize_Object_Functions(&Object_Table[0]);
|
||||||
Device_Init();
|
Device_Init();
|
||||||
/* we need to handle who-is
|
/* we need to handle who-is
|
||||||
to support dynamic device binding to us */
|
to support dynamic device binding to us */
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ extern bool Routed_Device_Write_Property_Local(
|
|||||||
|
|
||||||
/* Defined in user application;
|
/* Defined in user application;
|
||||||
object functions for all included BACnet objects */
|
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,
|
/** Glue function to let the Device object, when called by a handler,
|
||||||
* lookup which Object type needs to be invoked.
|
* lookup which Object type needs to be invoked.
|
||||||
@@ -1321,6 +1321,17 @@ bool Device_Write_Property(
|
|||||||
return (status);
|
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.
|
/** Initialize the Device Object and each of its child Object instances.
|
||||||
* @ingroup ObjIntf
|
* @ingroup ObjIntf
|
||||||
|
|||||||
@@ -51,7 +51,7 @@
|
|||||||
#include "dlenv.h"
|
#include "dlenv.h"
|
||||||
|
|
||||||
/* All included BACnet objects */
|
/* All included BACnet objects */
|
||||||
object_functions_t Object_Table[] = {
|
static object_functions_t Object_Table[] = {
|
||||||
{DEVICE_OBJ_FUNCTIONS},
|
{DEVICE_OBJ_FUNCTIONS},
|
||||||
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
||||||
};
|
};
|
||||||
@@ -185,6 +185,7 @@ static void LocalIAmHandler(
|
|||||||
static void Init_Service_Handlers(
|
static void Init_Service_Handlers(
|
||||||
void)
|
void)
|
||||||
{
|
{
|
||||||
|
Device_Initialize_Object_Functions(&Object_Table[0]);
|
||||||
Device_Init();
|
Device_Init();
|
||||||
/* we need to handle who-is
|
/* we need to handle who-is
|
||||||
to support dynamic device binding to us */
|
to support dynamic device binding to us */
|
||||||
|
|||||||
@@ -54,7 +54,7 @@
|
|||||||
#include "dlenv.h"
|
#include "dlenv.h"
|
||||||
|
|
||||||
/* All included BACnet objects */
|
/* All included BACnet objects */
|
||||||
object_functions_t Object_Table[] = {
|
static object_functions_t Object_Table[] = {
|
||||||
{DEVICE_OBJ_FUNCTIONS},
|
{DEVICE_OBJ_FUNCTIONS},
|
||||||
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
{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(
|
static void Init_Service_Handlers(
|
||||||
void)
|
void)
|
||||||
{
|
{
|
||||||
|
Device_Initialize_Object_Functions(&Object_Table[0]);
|
||||||
Device_Init();
|
Device_Init();
|
||||||
/* we need to handle who-is
|
/* we need to handle who-is
|
||||||
to support dynamic device binding to us */
|
to support dynamic device binding to us */
|
||||||
|
|||||||
@@ -55,7 +55,7 @@
|
|||||||
#include "dlenv.h"
|
#include "dlenv.h"
|
||||||
|
|
||||||
/* All included BACnet objects */
|
/* All included BACnet objects */
|
||||||
object_functions_t Object_Table[] = {
|
static object_functions_t Object_Table[] = {
|
||||||
{DEVICE_OBJ_FUNCTIONS},
|
{DEVICE_OBJ_FUNCTIONS},
|
||||||
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
{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(
|
static void Init_Service_Handlers(
|
||||||
void)
|
void)
|
||||||
{
|
{
|
||||||
|
Device_Initialize_Object_Functions(&Object_Table[0]);
|
||||||
Device_Init();
|
Device_Init();
|
||||||
/* we need to handle who-is
|
/* we need to handle who-is
|
||||||
to support dynamic device binding to us */
|
to support dynamic device binding to us */
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
#include "dlenv.h"
|
#include "dlenv.h"
|
||||||
|
|
||||||
/* All included BACnet objects */
|
/* All included BACnet objects */
|
||||||
object_functions_t Object_Table[] = {
|
static object_functions_t Object_Table[] = {
|
||||||
{DEVICE_OBJ_FUNCTIONS},
|
{DEVICE_OBJ_FUNCTIONS},
|
||||||
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
||||||
};
|
};
|
||||||
@@ -120,6 +120,7 @@ void MyReinitializeDeviceSimpleAckHandler(
|
|||||||
static void Init_Service_Handlers(
|
static void Init_Service_Handlers(
|
||||||
void)
|
void)
|
||||||
{
|
{
|
||||||
|
Device_Initialize_Object_Functions(&Object_Table[0]);
|
||||||
Device_Init();
|
Device_Init();
|
||||||
/* we need to handle who-is
|
/* we need to handle who-is
|
||||||
to support dynamic device binding to us */
|
to support dynamic device binding to us */
|
||||||
|
|||||||
@@ -66,7 +66,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* All included BACnet objects */
|
/* All included BACnet objects */
|
||||||
object_functions_t Object_Table[] = {
|
static object_functions_t Object_Table[] = {
|
||||||
{DEVICE_OBJ_FUNCTIONS},
|
{DEVICE_OBJ_FUNCTIONS},
|
||||||
{ANALOG_INPUT_OBJ_FUNCTIONS},
|
{ANALOG_INPUT_OBJ_FUNCTIONS},
|
||||||
{ANALOG_OUTPUT_OBJ_FUNCTIONS},
|
{ANALOG_OUTPUT_OBJ_FUNCTIONS},
|
||||||
@@ -101,6 +101,7 @@ static uint8_t Rx_Buf[MAX_MPDU] = { 0 };
|
|||||||
static void Init_Service_Handlers(
|
static void Init_Service_Handlers(
|
||||||
void)
|
void)
|
||||||
{
|
{
|
||||||
|
Device_Initialize_Object_Functions(&Object_Table[0]);
|
||||||
Device_Init();
|
Device_Init();
|
||||||
/* we need to handle who-is to support dynamic device binding */
|
/* we need to handle who-is to support dynamic device binding */
|
||||||
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is);
|
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is);
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
#include "dlenv.h"
|
#include "dlenv.h"
|
||||||
|
|
||||||
/* All included BACnet objects */
|
/* All included BACnet objects */
|
||||||
object_functions_t Object_Table[] = {
|
static object_functions_t Object_Table[] = {
|
||||||
{DEVICE_OBJ_FUNCTIONS},
|
{DEVICE_OBJ_FUNCTIONS},
|
||||||
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
||||||
};
|
};
|
||||||
@@ -92,6 +92,7 @@ void MyRejectHandler(
|
|||||||
static void Init_Service_Handlers(
|
static void Init_Service_Handlers(
|
||||||
void)
|
void)
|
||||||
{
|
{
|
||||||
|
Device_Initialize_Object_Functions(&Object_Table[0]);
|
||||||
Device_Init();
|
Device_Init();
|
||||||
/* we need to handle who-is
|
/* we need to handle who-is
|
||||||
to support dynamic device binding to us */
|
to support dynamic device binding to us */
|
||||||
|
|||||||
@@ -51,7 +51,7 @@
|
|||||||
#include "dlenv.h"
|
#include "dlenv.h"
|
||||||
|
|
||||||
/* All included BACnet objects */
|
/* All included BACnet objects */
|
||||||
object_functions_t Object_Table[] = {
|
static object_functions_t Object_Table[] = {
|
||||||
{DEVICE_OBJ_FUNCTIONS},
|
{DEVICE_OBJ_FUNCTIONS},
|
||||||
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
{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(
|
static void Init_Service_Handlers(
|
||||||
void)
|
void)
|
||||||
{
|
{
|
||||||
|
Device_Initialize_Object_Functions(&Object_Table[0]);
|
||||||
Device_Init();
|
Device_Init();
|
||||||
/* we need to handle who-is
|
/* we need to handle who-is
|
||||||
to support dynamic device binding to us */
|
to support dynamic device binding to us */
|
||||||
|
|||||||
@@ -51,7 +51,7 @@
|
|||||||
#include "dlenv.h"
|
#include "dlenv.h"
|
||||||
|
|
||||||
/* All included BACnet objects */
|
/* All included BACnet objects */
|
||||||
object_functions_t Object_Table[] = {
|
static object_functions_t Object_Table[] = {
|
||||||
{DEVICE_OBJ_FUNCTIONS},
|
{DEVICE_OBJ_FUNCTIONS},
|
||||||
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
||||||
};
|
};
|
||||||
@@ -95,6 +95,7 @@ void MyRejectHandler(
|
|||||||
static void Init_Service_Handlers(
|
static void Init_Service_Handlers(
|
||||||
void)
|
void)
|
||||||
{
|
{
|
||||||
|
Device_Initialize_Object_Functions(&Object_Table[0]);
|
||||||
Device_Init();
|
Device_Init();
|
||||||
/* we need to handle who-is
|
/* we need to handle who-is
|
||||||
to support dynamic device binding to us */
|
to support dynamic device binding to us */
|
||||||
|
|||||||
@@ -50,7 +50,7 @@
|
|||||||
#include "dlenv.h"
|
#include "dlenv.h"
|
||||||
|
|
||||||
/* All included BACnet objects */
|
/* All included BACnet objects */
|
||||||
object_functions_t Object_Table[] = {
|
static object_functions_t Object_Table[] = {
|
||||||
{DEVICE_OBJ_FUNCTIONS},
|
{DEVICE_OBJ_FUNCTIONS},
|
||||||
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
||||||
};
|
};
|
||||||
@@ -95,6 +95,7 @@ void MyRejectHandler(
|
|||||||
static void Init_Service_Handlers(
|
static void Init_Service_Handlers(
|
||||||
void)
|
void)
|
||||||
{
|
{
|
||||||
|
Device_Initialize_Object_Functions(&Object_Table[0]);
|
||||||
Device_Init();
|
Device_Init();
|
||||||
/* Note: this applications doesn't need to handle who-is
|
/* Note: this applications doesn't need to handle who-is
|
||||||
it is confusing for the user! */
|
it is confusing for the user! */
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
#include "dlenv.h"
|
#include "dlenv.h"
|
||||||
|
|
||||||
/* All included BACnet objects */
|
/* All included BACnet objects */
|
||||||
object_functions_t Object_Table[] = {
|
static object_functions_t Object_Table[] = {
|
||||||
{DEVICE_OBJ_FUNCTIONS},
|
{DEVICE_OBJ_FUNCTIONS},
|
||||||
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
{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(
|
static void Init_Service_Handlers(
|
||||||
void)
|
void)
|
||||||
{
|
{
|
||||||
|
Device_Initialize_Object_Functions(&Object_Table[0]);
|
||||||
Device_Init();
|
Device_Init();
|
||||||
/* we need to handle who-is
|
/* we need to handle who-is
|
||||||
to support dynamic device binding to us */
|
to support dynamic device binding to us */
|
||||||
|
|||||||
@@ -51,7 +51,7 @@
|
|||||||
#include "dlenv.h"
|
#include "dlenv.h"
|
||||||
|
|
||||||
/* All included BACnet objects */
|
/* All included BACnet objects */
|
||||||
object_functions_t Object_Table[] = {
|
static object_functions_t Object_Table[] = {
|
||||||
{DEVICE_OBJ_FUNCTIONS},
|
{DEVICE_OBJ_FUNCTIONS},
|
||||||
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
||||||
};
|
};
|
||||||
@@ -139,6 +139,7 @@ static void LocalIAmHandler(
|
|||||||
static void Init_Service_Handlers(
|
static void Init_Service_Handlers(
|
||||||
void)
|
void)
|
||||||
{
|
{
|
||||||
|
Device_Initialize_Object_Functions(&Object_Table[0]);
|
||||||
Device_Init();
|
Device_Init();
|
||||||
/* we need to handle who-is
|
/* we need to handle who-is
|
||||||
to support dynamic device binding to us */
|
to support dynamic device binding to us */
|
||||||
|
|||||||
@@ -57,7 +57,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* All included BACnet objects */
|
/* All included BACnet objects */
|
||||||
object_functions_t Object_Table[] = {
|
static object_functions_t Object_Table[] = {
|
||||||
{DEVICE_OBJ_FUNCTIONS},
|
{DEVICE_OBJ_FUNCTIONS},
|
||||||
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
||||||
};
|
};
|
||||||
@@ -140,6 +140,7 @@ void MyWritePropertySimpleAckHandler(
|
|||||||
static void Init_Service_Handlers(
|
static void Init_Service_Handlers(
|
||||||
void)
|
void)
|
||||||
{
|
{
|
||||||
|
Device_Initialize_Object_Functions(&Object_Table[0]);
|
||||||
Device_Init();
|
Device_Init();
|
||||||
/* we need to handle who-is
|
/* we need to handle who-is
|
||||||
to support dynamic device binding to us */
|
to support dynamic device binding to us */
|
||||||
|
|||||||
@@ -182,6 +182,8 @@ extern "C" {
|
|||||||
|
|
||||||
void Device_Init(
|
void Device_Init(
|
||||||
void);
|
void);
|
||||||
|
void Device_Initialize_Object_Functions(
|
||||||
|
object_functions_t *object_table);
|
||||||
|
|
||||||
bool Device_Reinitialize(
|
bool Device_Reinitialize(
|
||||||
BACNET_REINITIALIZE_DEVICE_DATA * rd_data);
|
BACNET_REINITIALIZE_DEVICE_DATA * rd_data);
|
||||||
|
|||||||
Reference in New Issue
Block a user