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:
@@ -88,6 +88,8 @@
|
||||
#include "bacnet/wp.h"
|
||||
#include "bacnet/basic/services.h"
|
||||
#include "bacnet/basic/sys/keylist.h"
|
||||
/* BACnet Stack Objects */
|
||||
#include "bacnet/basic/object/device.h"
|
||||
/* me! */
|
||||
#include "auditlog.h"
|
||||
|
||||
@@ -106,7 +108,12 @@ struct object_data {
|
||||
void *Context;
|
||||
};
|
||||
/* Key List for storing the object data sorted by instance number */
|
||||
static OS_Keylist Object_List;
|
||||
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
|
||||
|
||||
static const int32_t Properties_Required[] = {
|
||||
/* required properties that are supported for this object */
|
||||
@@ -1519,18 +1526,31 @@ bool Audit_Log_Delete(uint32_t object_instance)
|
||||
void Audit_Log_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) {
|
||||
Audit_Log_Records_Cleanup(pObject->Records);
|
||||
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) {
|
||||
Audit_Log_Records_Cleanup(pObject->Records);
|
||||
free(pObject);
|
||||
}
|
||||
} while (pObject);
|
||||
Keylist_Delete(Object_List);
|
||||
Object_List = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef BAC_ROUTING
|
||||
Set_Routed_Device_Object_Index(current_dev_id);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1538,7 +1558,21 @@ void Audit_Log_Cleanup(void)
|
||||
*/
|
||||
void Audit_Log_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