Add multi-device support for BACnet gateway routing (#1279)
* Expanded Object_List to Object_List[MAX_NUM_DEVICES] array to support per-device objects for virtual remote devices * Added multi-device iteration for COV handler, device timer, and intrinsic reporting * Added apps/gateway2 demo application * When MAX_NUM_DEVICES == 1, behavior is identical to the original implementation * Conditional compilation with macros ensures no impact on non-gateway applications --------- Signed-off-by: Hyeongjun Kim <hjun1.kim@samsung.com> Co-authored-by: haemeok-kang <haemeok.kang@samsung.com>
This commit is contained in:
@@ -30,7 +30,12 @@
|
||||
#include "bacnet/basic/object/program.h"
|
||||
|
||||
/* Key List for storing the object data sorted by instance number */
|
||||
static OS_Keylist Object_List = NULL;
|
||||
static OS_Keylist Object_Lists[MAX_NUM_DEVICES];
|
||||
#ifdef BAC_ROUTING
|
||||
#define Object_List (Object_Lists[Routed_Device_Object_Index()])
|
||||
#else
|
||||
#define Object_List (Object_Lists[0])
|
||||
#endif
|
||||
/* common object type */
|
||||
static const BACNET_OBJECT_TYPE Object_Type = OBJECT_PROGRAM;
|
||||
|
||||
@@ -1426,18 +1431,30 @@ bool Program_Delete(uint32_t object_instance)
|
||||
void Program_Cleanup(void)
|
||||
{
|
||||
struct object_data *pObject;
|
||||
uint16_t dev_id;
|
||||
#ifdef BAC_ROUTING
|
||||
uint16_t current_dev_id = Routed_Device_Object_Index();
|
||||
#endif
|
||||
|
||||
if (Object_List) {
|
||||
do {
|
||||
pObject = Keylist_Data_Pop(Object_List);
|
||||
if (pObject) {
|
||||
free(pObject);
|
||||
}
|
||||
} while (pObject);
|
||||
|
||||
Keylist_Delete(Object_List);
|
||||
Object_List = NULL;
|
||||
for (dev_id = 0; dev_id < MAX_NUM_DEVICES; dev_id++) {
|
||||
#ifdef BAC_ROUTING
|
||||
Set_Routed_Device_Object_Index(dev_id);
|
||||
#endif
|
||||
if (Object_List) {
|
||||
do {
|
||||
pObject = Keylist_Data_Pop(Object_List);
|
||||
if (pObject) {
|
||||
free(pObject);
|
||||
}
|
||||
} while (pObject);
|
||||
Keylist_Delete(Object_List);
|
||||
Object_List = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef BAC_ROUTING
|
||||
Set_Routed_Device_Object_Index(current_dev_id);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1445,7 +1462,21 @@ void Program_Cleanup(void)
|
||||
*/
|
||||
void Program_Init(void)
|
||||
{
|
||||
if (!Object_List) {
|
||||
Object_List = Keylist_Create();
|
||||
uint16_t dev_id;
|
||||
#ifdef BAC_ROUTING
|
||||
uint16_t current_dev_id = Routed_Device_Object_Index();
|
||||
#endif
|
||||
|
||||
for (dev_id = 0; dev_id < MAX_NUM_DEVICES; dev_id++) {
|
||||
#ifdef BAC_ROUTING
|
||||
Set_Routed_Device_Object_Index(dev_id);
|
||||
#endif
|
||||
if (!Object_List) {
|
||||
Object_List = Keylist_Create();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef BAC_ROUTING
|
||||
Set_Routed_Device_Object_Index(current_dev_id);
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user