Added UCI support for the BACnet demo server. UCI is a replacement for nvram. The source is GPL and has a lua lib.

http://wiki.openwrt.org/doc/uci
http://nbd.name/gitweb.cgi?p=uci.git;a=summary
Thank you, Patrick <patrick@lunatiki.de>.
This commit is contained in:
skarg
2013-04-15 20:22:24 +00:00
parent 0c963ecc30
commit 15cb616b4a
8 changed files with 279 additions and 7 deletions
+6 -1
View File
@@ -21,7 +21,12 @@ BACNET_LIB_TARGET = $(BACNET_LIB_DIR)/lib$(BACNET_LIB_NAME).a
INCLUDE1 = -I$(BACNET_PORT_DIR) -I$(BACNET_OBJECT) -I$(BACNET_HANDLER)
INCLUDE2 = -I$(BACNET_INCLUDE)
INCLUDES = $(INCLUDE1) $(INCLUDE2)
BACNET_LIB=-L$(BACNET_LIB_DIR),-l$(BACNET_LIB_NAME)
BACNET_LIB := -L$(BACNET_LIB_DIR),-l$(BACNET_LIB_NAME)
# build for UCI
ifneq (,$(findstring -DBAC_UCI,$(BACNET_DEFINES)))
BACNET_LIB = $(BACNET_LIB),-L$(UCI_LIB_DIR),-luci
endif
# OS specific builds
ifeq (${BACNET_PORT},linux)
PFLAGS = -pthread
TARGET_EXT =
+20 -1
View File
@@ -67,6 +67,9 @@
#if defined(BACFILE)
#include "bacfile.h"
#endif /* defined(BACFILE) */
#if defined(BAC_UCI)
#include "ucix.h"
#endif /* defined(BAC_UCI) */
#if defined(__BORLANDC__)
@@ -1810,8 +1813,24 @@ void Device_Init(
object_functions_t * object_table)
{
struct object_functions *pObject = NULL;
#if defined(BAC_UCI)
const char *uciname;
struct uci_context *ctx;
fprintf(stderr, "Device_Init\n");
ctx = ucix_init("bacnet_dev");
if(!ctx)
fprintf(stderr, "Failed to load config file bacnet_dev\n");
uciname = ucix_get_option(ctx, "bacnet_dev", "0", "Name");
if (uciname != 0) {
characterstring_init_ansi(&My_Object_Name, uciname);
} else {
#endif /* defined(BAC_UCI) */
characterstring_init_ansi(&My_Object_Name, "SimpleServer");
#if defined(BAC_UCI)
}
ucix_cleanup(ctx);
#endif /* defined(BAC_UCI) */
characterstring_init_ansi(&My_Object_Name, "SimpleServer");
if (object_table) {
Object_Table = object_table;
} else {
+23 -3
View File
@@ -59,6 +59,9 @@
#if defined(BACFILE)
#include "bacfile.h"
#endif /* defined(BACFILE) */
#if defined(BAC_UCI)
#include "ucix.h"
#endif /* defined(BAC_UCI) */
/** @file server/main.c Example server application using the BACnet Stack. */
@@ -158,10 +161,27 @@ int main(
uint32_t elapsed_milliseconds = 0;
uint32_t address_binding_tmr = 0;
uint32_t recipient_scan_tmr = 0;
#if defined(BAC_UCI)
int uciId = 0;
struct uci_context *ctx;
ctx = ucix_init("bacnet_dev");
if(!ctx)
fprintf(stderr, "Failed to load config file bacnet_dev\n");
uciId = ucix_get_option_int(ctx, "bacnet_dev", "0", "Id", 0);
printf("ID: %i", uciId);
if (uciId != 0) {
Device_Set_Object_Instance_Number(uciId);
} else {
#endif /* defined(BAC_UCI) */
/* allow the device ID to be set */
if (argc > 1)
Device_Set_Object_Instance_Number(strtol(argv[1], NULL, 0));
#if defined(BAC_UCI)
}
ucix_cleanup(ctx);
#endif /* defined(BAC_UCI) */
/* allow the device ID to be set */
if (argc > 1)
Device_Set_Object_Instance_Number(strtol(argv[1], NULL, 0));
printf("BACnet Server Demo\n" "BACnet Stack Version %s\n"
"BACnet Device ID: %u\n" "Max APDU: %d\n", BACnet_Version,
Device_Object_Instance_Number(), MAX_APDU);