Read config file for fallback when no command line arguments are given.

This commit is contained in:
Martin Preuss
2023-10-03 16:51:15 +02:00
parent 0740378ad8
commit 831c94f898
24 changed files with 324 additions and 34 deletions

View File

@@ -14,6 +14,7 @@
#include "./init.h"
#include "./aqhome_data_p.h"
#include "aqhome/aqhome.h"
#include "aqhome/ipc/endpoint_ipc.h"
#include <gwenhywfar/gwenhywfar.h>
@@ -83,6 +84,8 @@ int AqHomeData_Init(AQHOME_DATA *aqh, int argc, char **argv)
DBG_ERROR(NULL, "Error reading args (%d)", rv);
return rv;
}
AQH_MergeConfigFileIntoConfig(dbArgs, "ConfigFile");
aqh->dbArgs=dbArgs;
aqh->timeout=GWEN_DB_GetIntValue(dbArgs, "timeout", 0, 0);
@@ -145,9 +148,14 @@ void _setupIpc(AQHOME_DATA *aqh, GWEN_DB_NODE *dbArgs)
int tcpPort;
tcpAddress=GWEN_DB_GetCharValue(dbArgs, "tcpAddress", 0, NULL);
tcpPort=GWEN_DB_GetIntValue(dbArgs, "tcpPort", 0, AQHOME_DATA_DEFAULT_IPC_PORT);
if (!(tcpAddress && *tcpAddress))
tcpAddress=GWEN_DB_GetCharValue(dbArgs, "ConfigFile/brokerAddress", 0, NULL);
if (tcpAddress && *tcpAddress && tcpPort) {
tcpPort=GWEN_DB_GetIntValue(dbArgs, "tcpPort", 0, -1);
if (tcpPort<0)
tcpPort=GWEN_DB_GetIntValue(dbArgs, "ConfigFile/brokerPort", 0, AQHOME_DATA_DEFAULT_IPC_PORT);
if (tcpAddress && *tcpAddress && tcpPort>0) {
GWEN_MSG_ENDPOINT *ep;
DBG_INFO(NULL, "Starting TCP service on \"%s\":%d", tcpAddress, tcpPort);