Read config file for fallback when no command line arguments are given.
This commit is contained in:
48
0BUILD
48
0BUILD
@@ -50,6 +50,23 @@
|
||||
<setVar name="pkgincludedir">$(includedir)/aqhome/$(package)</setVar>
|
||||
<setVar name="pkgdatadir">$(datadir)/$(package)</setVar>
|
||||
|
||||
<option id="enable_testcode" type="string">
|
||||
<default>TRUE</default>
|
||||
<choices>TRUE FALSE</choices>
|
||||
</option>
|
||||
<ifVarMatches name="option_enable_testcode" value="TRUE" >
|
||||
<define name="AQHOME_ENABLE_TESTCODE" value="1" />
|
||||
</ifVarMatches>
|
||||
|
||||
|
||||
<option id="local_install" type="string">
|
||||
<default>FALSE</default>
|
||||
<choices>TRUE FALSE</choices>
|
||||
</option>
|
||||
<ifVarMatches name="option_local_install" value="TRUE" >
|
||||
<define name="ENABLE_LOCAL_INSTALL" value="1" />
|
||||
</ifVarMatches>
|
||||
|
||||
|
||||
<option id="debug" type="string">
|
||||
<default>TRUE</default>
|
||||
@@ -61,6 +78,37 @@
|
||||
</ifVarMatches>
|
||||
|
||||
|
||||
|
||||
<!-- paths -->
|
||||
<ifVarMatches name="GWBUILD_SYSTEM" value="windows" > <!-- long version of IF statement with THEN and ELSE -->
|
||||
<then>
|
||||
<define name="OS_WIN32" value="1" />
|
||||
<setVar name="aqhome_sys_is_windows">1</setVar>
|
||||
<setVar name="aqhome_cfg_searchdir">etc</setVar>
|
||||
<setVar name="aqhome_locale_searchdir">share/locale</setVar>
|
||||
<setVar name="aqhome_data_searchdir">share"</setVar>
|
||||
</then>
|
||||
<else>
|
||||
<define name="OS_POSIX" value="1" />
|
||||
<setVar name="aqhome_sys_is_windows">0</setVar>
|
||||
<ifVarMatches name="option_local_install" value="TRUE" >
|
||||
<then>
|
||||
<setVar name="aqhome_cfg_searchdir">etc</setVar>
|
||||
<setVar name="aqhome_locale_searchdir">share/locale</setVar>
|
||||
<setVar name="aqhome_data_searchdir">share</setVar>
|
||||
</then>
|
||||
<else>
|
||||
<setVar name="aqhome_cfg_searchdir">$(sysconfdir)</setVar>
|
||||
<setVar name="aqhome_locale_searchdir">$(datadir)/locale</setVar>
|
||||
<setVar name="aqhome_data_searchdir">$(datadir)</setVar>
|
||||
</else>
|
||||
</ifVarMatches>
|
||||
</else>
|
||||
</ifVarMatches>
|
||||
<define name="AQHOME_SYS_IS_WINDOWS" value="$(aqhome_sys_is_windows)" />
|
||||
|
||||
|
||||
|
||||
<!-- use "-Owith_avr=TRUE" or "FALSE" to enable or disable assembling AVR code -->
|
||||
<option id="with_avr" type="string">
|
||||
<default>TRUE</default>
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "./aqhomed_p.h"
|
||||
#include "./tty_log.h"
|
||||
|
||||
#include "aqhome/aqhome.h"
|
||||
#include "aqhome/msg/endpoint_tty.h"
|
||||
#include "aqhome/ipc/endpoint_ipc.h"
|
||||
#include "aqhome/ipc/endpoint_ipcclient.h"
|
||||
@@ -87,6 +88,7 @@ int AqHomed_Init(AQHOMED *aqh, int argc, char **argv)
|
||||
DBG_ERROR(NULL, "Error reading args (%d)", rv);
|
||||
return rv;
|
||||
}
|
||||
AQH_MergeConfigFileIntoConfig(dbArgs, "ConfigFile");
|
||||
aqh->dbArgs=dbArgs;
|
||||
|
||||
s=GWEN_DB_GetCharValue(dbArgs, "pidfile", 0, AQHOMED_DEFAULT_PIDFILE);
|
||||
@@ -150,7 +152,12 @@ void _setupIpcd(AQHOMED *aqh, GWEN_DB_NODE *dbArgs)
|
||||
int tcpPort;
|
||||
|
||||
tcpAddress=GWEN_DB_GetCharValue(dbArgs, "tcpAddress", 0, NULL);
|
||||
tcpPort=GWEN_DB_GetIntValue(dbArgs, "tcpPort", 0, AQHOMED_DEFAULT_IPC_PORT);
|
||||
if (!(tcpAddress && *tcpAddress))
|
||||
tcpAddress=GWEN_DB_GetCharValue(dbArgs, "ConfigFile/nodesAddress", 0, NULL);
|
||||
|
||||
tcpPort=GWEN_DB_GetIntValue(dbArgs, "tcpPort", 0, -1);
|
||||
if (tcpPort<0)
|
||||
tcpPort=GWEN_DB_GetIntValue(dbArgs, "ConfigFile/nodesPort", 0, AQHOMED_DEFAULT_IPC_PORT);
|
||||
|
||||
if (tcpAddress && *tcpAddress && tcpPort) {
|
||||
GWEN_MSG_ENDPOINT *ep;
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "./adddata.h"
|
||||
#include "../utils.h"
|
||||
|
||||
#include "aqhome/aqhome.h"
|
||||
#include "aqhome/msg/msg_node.h"
|
||||
#include "aqhome/ipc/msg_ipc_result.h"
|
||||
#include "aqhome/ipc/data/msg_data_multidata.h"
|
||||
@@ -188,6 +189,8 @@ int AQH_Tool_AddDataPoint(GWEN_DB_NODE *dbGlobalArgs, int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
AQH_MergeConfigFileIntoConfig(dbLocalArgs, "ConfigFile");
|
||||
|
||||
return _doAddData(dbLocalArgs);
|
||||
}
|
||||
|
||||
@@ -242,7 +245,7 @@ int _doAddData(GWEN_DB_NODE *dbArgs)
|
||||
/*fprintf(stdout, "Sending AddData request\n");*/
|
||||
|
||||
|
||||
epTcp=Utils_OpenConnection(dbArgs, 0, timeoutInSeconds);
|
||||
epTcp=Utils_OpenBrokerConnection(dbArgs, 0, timeoutInSeconds);
|
||||
if (epTcp==NULL) {
|
||||
DBG_ERROR(NULL, "ERROR creating TCP connection");
|
||||
return 2;
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "./getdatapoints.h"
|
||||
#include "../utils.h"
|
||||
|
||||
#include "aqhome/aqhome.h"
|
||||
#include "aqhome/msg/msg_node.h"
|
||||
#include "aqhome/ipc/msg_ipc_result.h"
|
||||
#include "aqhome/ipc/data/msg_data_datapoints.h"
|
||||
@@ -190,6 +191,8 @@ int AQH_Tool_GetDataPoints(GWEN_DB_NODE *dbGlobalArgs, int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
AQH_MergeConfigFileIntoConfig(dbLocalArgs, "ConfigFile");
|
||||
|
||||
return _doGetDataPoints(dbLocalArgs);
|
||||
}
|
||||
|
||||
@@ -220,7 +223,7 @@ int _doGetDataPoints(GWEN_DB_NODE *dbArgs)
|
||||
return 2;
|
||||
}
|
||||
|
||||
epTcp=Utils_OpenConnection(dbArgs, 0, timeoutInSeconds);
|
||||
epTcp=Utils_OpenBrokerConnection(dbArgs, 0, timeoutInSeconds);
|
||||
if (epTcp==NULL) {
|
||||
DBG_ERROR(NULL, "ERROR creating TCP connection");
|
||||
return 2;
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "./getdevices.h"
|
||||
#include "../utils.h"
|
||||
|
||||
#include "aqhome/aqhome.h"
|
||||
#include "aqhome/msg/msg_node.h"
|
||||
#include "aqhome/ipc/msg_ipc_result.h"
|
||||
#include "aqhome/ipc/data/msg_data_devices.h"
|
||||
@@ -154,6 +155,8 @@ int AQH_Tool_GetDevices(GWEN_DB_NODE *dbGlobalArgs, int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
AQH_MergeConfigFileIntoConfig(dbLocalArgs, "ConfigFile");
|
||||
|
||||
return _doGetDevices(dbLocalArgs);
|
||||
}
|
||||
|
||||
@@ -169,7 +172,7 @@ int _doGetDevices(GWEN_DB_NODE *dbArgs)
|
||||
timeoutInSeconds=GWEN_DB_GetIntValue(dbArgs, "timeout", 0, 5);
|
||||
printHeader=GWEN_DB_GetIntValue(dbArgs, "printHeader", 0, 0);
|
||||
|
||||
epTcp=Utils_OpenConnection(dbArgs, 0, timeoutInSeconds);
|
||||
epTcp=Utils_OpenBrokerConnection(dbArgs, 0, timeoutInSeconds);
|
||||
if (epTcp==NULL) {
|
||||
DBG_ERROR(NULL, "ERROR creating TCP connection");
|
||||
return 2;
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "./getlastdatapoint.h"
|
||||
#include "../utils.h"
|
||||
|
||||
#include "aqhome/aqhome.h"
|
||||
#include "aqhome/msg/msg_node.h"
|
||||
#include "aqhome/ipc/msg_ipc_result.h"
|
||||
#include "aqhome/ipc/data/msg_data_getdata.h"
|
||||
@@ -167,6 +168,8 @@ int AQH_Tool_GetLastDataPoint(GWEN_DB_NODE *dbGlobalArgs, int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
AQH_MergeConfigFileIntoConfig(dbLocalArgs, "ConfigFile");
|
||||
|
||||
return _doGetLastDataPoint(dbLocalArgs);
|
||||
}
|
||||
|
||||
@@ -182,7 +185,7 @@ int _doGetLastDataPoint(GWEN_DB_NODE *dbArgs)
|
||||
timeoutInSeconds=GWEN_DB_GetIntValue(dbArgs, "timeout", 0, 5);
|
||||
valueName=GWEN_DB_GetCharValue(dbArgs, "valueName", 0, NULL);
|
||||
|
||||
epTcp=Utils_OpenConnection(dbArgs, 0, timeoutInSeconds);
|
||||
epTcp=Utils_OpenBrokerConnection(dbArgs, 0, timeoutInSeconds);
|
||||
if (epTcp==NULL) {
|
||||
DBG_ERROR(NULL, "ERROR creating TCP connection");
|
||||
return 2;
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "./getvalues.h"
|
||||
#include "../utils.h"
|
||||
|
||||
#include "aqhome/aqhome.h"
|
||||
#include "aqhome/msg/msg_node.h"
|
||||
#include "aqhome/ipc/msg_ipc_result.h"
|
||||
#include "aqhome/ipc/data/msg_data_values.h"
|
||||
@@ -143,6 +144,8 @@ int AQH_Tool_GetValues(GWEN_DB_NODE *dbGlobalArgs, int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
AQH_MergeConfigFileIntoConfig(dbLocalArgs, "ConfigFile");
|
||||
|
||||
return _doGetValues(dbLocalArgs);
|
||||
}
|
||||
|
||||
@@ -156,7 +159,7 @@ int _doGetValues(GWEN_DB_NODE *dbArgs)
|
||||
|
||||
timeoutInSeconds=GWEN_DB_GetIntValue(dbArgs, "timeout", 0, 5);
|
||||
|
||||
epTcp=Utils_OpenConnection(dbArgs, 0, timeoutInSeconds);
|
||||
epTcp=Utils_OpenBrokerConnection(dbArgs, 0, timeoutInSeconds);
|
||||
if (epTcp==NULL) {
|
||||
DBG_ERROR(NULL, "ERROR creating TCP connection");
|
||||
return 2;
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "./moddevice.h"
|
||||
#include "../utils.h"
|
||||
|
||||
#include "aqhome/aqhome.h"
|
||||
#include "aqhome/msg/msg_node.h"
|
||||
#include "aqhome/ipc/msg_ipc_result.h"
|
||||
#include "aqhome/ipc/data/msg_data_devices.h"
|
||||
@@ -198,6 +199,8 @@ int AQH_Tool_ModDevice(GWEN_DB_NODE *dbGlobalArgs, int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
AQH_MergeConfigFileIntoConfig(dbLocalArgs, "ConfigFile");
|
||||
|
||||
return _doModDevice(dbLocalArgs);
|
||||
}
|
||||
|
||||
@@ -213,7 +216,7 @@ int _doModDevice(GWEN_DB_NODE *dbArgs)
|
||||
timeoutInSeconds=GWEN_DB_GetIntValue(dbArgs, "timeout", 0, 5);
|
||||
device=Utils_DeviceFromArgs(dbArgs);
|
||||
|
||||
epTcp=Utils_OpenConnection(dbArgs, 0, timeoutInSeconds);
|
||||
epTcp=Utils_OpenBrokerConnection(dbArgs, 0, timeoutInSeconds);
|
||||
if (epTcp==NULL) {
|
||||
DBG_ERROR(NULL, "ERROR creating TCP connection");
|
||||
return 2;
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "./setdata.h"
|
||||
#include "../utils.h"
|
||||
|
||||
#include "aqhome/aqhome.h"
|
||||
#include "aqhome/msg/msg_node.h"
|
||||
#include "aqhome/ipc/msg_ipc_result.h"
|
||||
#include "aqhome/ipc/data/msg_data_multidata.h"
|
||||
@@ -176,6 +177,8 @@ int AQH_Tool_SetData(GWEN_DB_NODE *dbGlobalArgs, int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
AQH_MergeConfigFileIntoConfig(dbLocalArgs, "ConfigFile");
|
||||
|
||||
return _doSetData(dbLocalArgs);
|
||||
}
|
||||
|
||||
@@ -215,7 +218,7 @@ int _doSetData(GWEN_DB_NODE *dbArgs)
|
||||
/*fprintf(stdout, "Sending SetData request\n");*/
|
||||
|
||||
|
||||
epTcp=Utils_OpenConnection(dbArgs, 0, timeoutInSeconds);
|
||||
epTcp=Utils_OpenBrokerConnection(dbArgs, 0, timeoutInSeconds);
|
||||
if (epTcp==NULL) {
|
||||
DBG_ERROR(NULL, "ERROR creating TCP connection");
|
||||
return 2;
|
||||
|
||||
@@ -140,6 +140,8 @@ int main(int argc, char **argv)
|
||||
argv+=rv-1;
|
||||
}
|
||||
|
||||
AQH_MergeConfigFileIntoConfig(dbArgs, "ConfigFile");
|
||||
|
||||
s=GWEN_DB_GetCharValue(dbArgs, "charset", 0, NULL);
|
||||
if (s && *s)
|
||||
GWEN_Gui_SetCharSet(gui, s);
|
||||
@@ -169,3 +171,4 @@ int main(int argc, char **argv)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -212,7 +212,7 @@ int _doFlash(GWEN_DB_NODE *dbArgs)
|
||||
}
|
||||
|
||||
/* setup client connection */
|
||||
epTcp=Utils_SetupIpcEndpoint(dbArgs);
|
||||
epTcp=Utils_SetupNodesClientEndpoint(dbArgs);
|
||||
if (epTcp==NULL) {
|
||||
DBG_ERROR(NULL, "ERROR creating TCP connection");
|
||||
return 3;
|
||||
|
||||
@@ -122,7 +122,7 @@ int _doGetNodes(GWEN_DB_NODE *dbArgs)
|
||||
int rv;
|
||||
int timeoutInSeconds;
|
||||
|
||||
epTcp=Utils_SetupIpcEndpoint(dbArgs);
|
||||
epTcp=Utils_SetupNodesClientEndpoint(dbArgs);
|
||||
if (epTcp==NULL) {
|
||||
DBG_ERROR(NULL, "ERROR creating TCP connection");
|
||||
return 2;
|
||||
|
||||
@@ -135,7 +135,7 @@ int _doPing(GWEN_DB_NODE *dbArgs)
|
||||
int timeoutInSeconds;
|
||||
GWEN_MSG *msg;
|
||||
|
||||
epTcp=Utils_SetupIpcEndpoint(dbArgs);
|
||||
epTcp=Utils_SetupNodesClientEndpoint(dbArgs);
|
||||
if (epTcp==NULL) {
|
||||
DBG_ERROR(NULL, "ERROR creating TCP connection");
|
||||
return 2;
|
||||
|
||||
@@ -32,15 +32,39 @@
|
||||
|
||||
|
||||
|
||||
GWEN_MSG_ENDPOINT *Utils_SetupIpcEndpoint(GWEN_DB_NODE *dbArgs)
|
||||
GWEN_MSG_ENDPOINT *Utils_SetupBrokerClientEndpoint(GWEN_DB_NODE *dbArgs)
|
||||
{
|
||||
return Utils_SetupIpcEndpoint(dbArgs, "tcpAddress", "tcpPort", "ConfigFile/brokerAddress", "ConfigFile/brokerPort", 1899);
|
||||
}
|
||||
|
||||
|
||||
|
||||
GWEN_MSG_ENDPOINT *Utils_SetupNodesClientEndpoint(GWEN_DB_NODE *dbArgs)
|
||||
{
|
||||
return Utils_SetupIpcEndpoint(dbArgs, "tcpAddress", "tcpPort", "ConfigFile/nodesAddress", "ConfigFile/nodesPort", 45454);
|
||||
}
|
||||
|
||||
|
||||
|
||||
GWEN_MSG_ENDPOINT *Utils_SetupIpcEndpoint(GWEN_DB_NODE *dbArgs,
|
||||
const char *varNameAddr,
|
||||
const char *varNamePort,
|
||||
const char *fileVarNameAddr,
|
||||
const char *fileVarNamePort,
|
||||
int defaultPort)
|
||||
{
|
||||
GWEN_MSG_ENDPOINT *epTcp;
|
||||
const char *tcpAddress;
|
||||
int tcpPort;
|
||||
int rv;
|
||||
|
||||
tcpAddress=GWEN_DB_GetCharValue(dbArgs, "tcpAddress", 0, "127.0.0.1");
|
||||
tcpPort=GWEN_DB_GetIntValue(dbArgs, "tcpPort", 0, 45454);
|
||||
tcpAddress=GWEN_DB_GetCharValue(dbArgs, varNameAddr, 0, NULL);
|
||||
if (!(tcpAddress && *tcpAddress))
|
||||
tcpAddress=GWEN_DB_GetCharValue(dbArgs, fileVarNameAddr, 0, "127.0.0.1");
|
||||
|
||||
tcpPort=GWEN_DB_GetIntValue(dbArgs, varNamePort, 0, -1);
|
||||
if (tcpPort<0)
|
||||
tcpPort=GWEN_DB_GetIntValue(dbArgs, fileVarNamePort, 0, defaultPort);
|
||||
|
||||
DBG_INFO(NULL, "Setup tcp client endpoint to %s:%d", tcpAddress, tcpPort);
|
||||
epTcp=AQH_IpcEndpoint_CreateIpcTcpClient(tcpAddress, tcpPort, "aqhome-tool-IPC", 0);
|
||||
@@ -190,7 +214,7 @@ int Utils_SendAcceptedMsgGroups(GWEN_MSG_ENDPOINT *epTcp, uint32_t groups)
|
||||
|
||||
|
||||
|
||||
GWEN_MSG_ENDPOINT *Utils_OpenConnection(GWEN_DB_NODE *dbArgs, uint32_t flags, int timeoutInSeconds)
|
||||
GWEN_MSG_ENDPOINT *Utils_OpenBrokerConnection(GWEN_DB_NODE *dbArgs, uint32_t flags, int timeoutInSeconds)
|
||||
{
|
||||
GWEN_MSG_ENDPOINT *epTcp;
|
||||
GWEN_MSG *msgOut;
|
||||
@@ -204,7 +228,7 @@ GWEN_MSG_ENDPOINT *Utils_OpenConnection(GWEN_DB_NODE *dbArgs, uint32_t flags, in
|
||||
userId=GWEN_DB_GetCharValue(dbArgs, "userId", 0, NULL);
|
||||
password=GWEN_DB_GetCharValue(dbArgs, "password", 0, NULL);
|
||||
|
||||
epTcp=Utils_SetupIpcEndpoint(dbArgs);
|
||||
epTcp=Utils_SetupBrokerClientEndpoint(dbArgs);
|
||||
if (epTcp==NULL) {
|
||||
DBG_ERROR(NULL, "ERROR creating TCP connection");
|
||||
return NULL;
|
||||
|
||||
@@ -18,7 +18,14 @@
|
||||
|
||||
|
||||
|
||||
GWEN_MSG_ENDPOINT *Utils_SetupIpcEndpoint(GWEN_DB_NODE *dbArgs);
|
||||
GWEN_MSG_ENDPOINT *Utils_SetupIpcEndpoint(GWEN_DB_NODE *dbArgs,
|
||||
const char *varNameAddr,
|
||||
const char *varNamePort,
|
||||
const char *fileVarNameAddr,
|
||||
const char *fileVarNamePort,
|
||||
int defaultPort);
|
||||
GWEN_MSG_ENDPOINT *Utils_SetupBrokerClientEndpoint(GWEN_DB_NODE *dbArgs);
|
||||
GWEN_MSG_ENDPOINT *Utils_SetupNodesClientEndpoint(GWEN_DB_NODE *dbArgs);
|
||||
|
||||
GWEN_MSG *Utils_WaitForSpecificNodeMessage(GWEN_MSG_ENDPOINT *epTcp, int msgCode, int nodeAddr, int timeoutInSeconds);
|
||||
|
||||
@@ -28,7 +35,7 @@ int Utils_FlushOutMessageQueue(GWEN_MSG_ENDPOINT *epTcp, int timeoutInSeconds);
|
||||
|
||||
int Utils_SendAcceptedMsgGroups(GWEN_MSG_ENDPOINT *epTcp, uint32_t groups);
|
||||
|
||||
GWEN_MSG_ENDPOINT *Utils_OpenConnection(GWEN_DB_NODE *dbArgs, uint32_t flags, int timeoutInSeconds);
|
||||
GWEN_MSG_ENDPOINT *Utils_OpenBrokerConnection(GWEN_DB_NODE *dbArgs, uint32_t flags, int timeoutInSeconds);
|
||||
|
||||
void Utils_PrintDataPoints(const uint64_t *dataPoints, uint32_t numValues, const char *valueUnits);
|
||||
void Utils_PrintSingleDataPoint(uint64_t timestamp, double data, const char *valueUnits);
|
||||
|
||||
@@ -9,4 +9,4 @@ export LD_LIBRARY_PATH="0-build/aqhome/:$LD_LIBRARY_PATH"
|
||||
--datafolder=apps/aqhome-data/test/data \
|
||||
-t 127.0.0.1 -P 1899 \
|
||||
-p ./aqhome-data.pid \
|
||||
$*
|
||||
"$@"
|
||||
|
||||
@@ -10,4 +10,4 @@ export LD_LIBRARY_PATH="0-build/aqhome/:$LD_LIBRARY_PATH"
|
||||
# 0-build/apps/aqhomed/aqhomed -l aqhome.log -db aqhome.db -ma 192.168.117.192 -mp 1883 -t 127.0.0.1 -p aqhomed.pid
|
||||
|
||||
# 0-build/apps/aqhomed/aqhomed -l aqhome.log -db aqhome.db -p aqhomed.pid -W /tmp/aqhome/aqhomed -ma 192.168.117.192 -mp 1883 -t 127.0.0.1 --mqttclientid=AQHOMEMQTTLOGTEST1
|
||||
0-build/apps/aqhome-nodes/aqhome-nodes -l aqhome-nodes.log -db aqhome-nodes.db -p aqhome-nodes.pid -t 127.0.0.1 -ba 127.0.0.1
|
||||
0-build/apps/aqhome-nodes/aqhome-nodes -l aqhome-nodes.log -db aqhome-nodes.db -p aqhome-nodes.pid -t 127.0.0.1 -ba 127.0.0.1 "$@"
|
||||
|
||||
@@ -13,4 +13,4 @@ export LD_LIBRARY_PATH="0-build/aqhome/:$LD_LIBRARY_PATH"
|
||||
-ma 192.168.117.192 -mp 1883 --mqttclientid=AQHOMESTORAGETEST \
|
||||
-ha 127.0.0.1 -hp 1884 \
|
||||
-p ./aqhome-storage.pid \
|
||||
$*
|
||||
"$@"
|
||||
|
||||
@@ -4,5 +4,5 @@
|
||||
export LD_LIBRARY_PATH="0-build/aqhome/:$LD_LIBRARY_PATH"
|
||||
|
||||
# 0-build/apps/aqhome-tool/aqhome-tool ping -n 2 -T 5
|
||||
0-build/apps/aqhome-tool/aqhome-tool $*
|
||||
0-build/apps/aqhome-tool/aqhome-tool "$@"
|
||||
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
|
||||
|
||||
<define name="BUILDING_AQHOME" />
|
||||
<define name="AQHOME_SYSCONF_DIR" value="$(aqhome_cfg_searchdir)" quoted="TRUE" />
|
||||
<define name="AQHOME_LOCALEF_DIR" value="$(aqhome_locale_searchdir)" quoted="TRUE" />
|
||||
<define name="AQHOME_DATA_DIR" value="$(aqhome_data_searchdir)" quoted="TRUE" />
|
||||
|
||||
<setVar name="local/cflags">$(visibility_cflags)</setVar>
|
||||
|
||||
|
||||
173
aqhome/aqhome.c
173
aqhome/aqhome.c
@@ -14,23 +14,125 @@
|
||||
|
||||
#include <gwenhywfar/gwenhywfar.h>
|
||||
#include <gwenhywfar/logger.h>
|
||||
#include <gwenhywfar/pathmanager.h>
|
||||
#include <gwenhywfar/debug.h>
|
||||
#include <gwenhywfar/i18n.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
|
||||
#define AQHOME_PM_LIBNAME "aqhome"
|
||||
#define AQHOME_PM_SYSCONFDIR "sysconfdir"
|
||||
#define AQHOME_PM_DATADIR "datadir"
|
||||
#define AQHOME_PM_LOCALEDIR "localedir"
|
||||
|
||||
int AQH_Init()
|
||||
#define AQHOME_SYSCONFIG_FILE "aqhome.conf"
|
||||
|
||||
|
||||
|
||||
static void _initLogging(void);
|
||||
static void _finiLogging(void);
|
||||
static void _initPathManager(void);
|
||||
static void _finiPathManager(void);
|
||||
static void _initI18n(void);
|
||||
static void _definePath(const char *pathName, const char *pathValue);
|
||||
|
||||
|
||||
|
||||
int AQH_Init(void)
|
||||
{
|
||||
int rv;
|
||||
const char *s;
|
||||
|
||||
rv=GWEN_Init();
|
||||
if (rv) {
|
||||
DBG_ERROR_ERR(AQH_LOGDOMAIN, rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
_initLogging();
|
||||
_initPathManager();
|
||||
_initI18n();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_Fini(void)
|
||||
{
|
||||
_finiPathManager();
|
||||
_finiLogging();
|
||||
|
||||
GWEN_Fini();
|
||||
}
|
||||
|
||||
|
||||
|
||||
GWEN_STRINGLIST *AQH_GetGlobalDataDirs(void)
|
||||
{
|
||||
return GWEN_PathManager_GetPaths(AQHOME_PM_LIBNAME, AQHOME_PM_DATADIR);
|
||||
}
|
||||
|
||||
|
||||
|
||||
GWEN_STRINGLIST *AQH_GetGlobalSysconfDirs(void)
|
||||
{
|
||||
return GWEN_PathManager_GetPaths(AQHOME_PM_LIBNAME, AQHOME_PM_SYSCONFDIR);
|
||||
}
|
||||
|
||||
|
||||
|
||||
GWEN_DB_NODE *AQH_LoadConfigFile(void)
|
||||
{
|
||||
GWEN_BUFFER *fbuf;
|
||||
int rv;
|
||||
|
||||
fbuf=GWEN_Buffer_new(0, 256, 0, 1);
|
||||
rv=GWEN_PathManager_FindFile(AQHOME_PM_LIBNAME, AQHOME_PM_SYSCONFDIR, AQHOME_SYSCONFIG_FILE, fbuf);
|
||||
if (rv<0) {
|
||||
DBG_INFO(AQH_LOGDOMAIN, "Config file \"%s\" not found (%d)", AQHOME_SYSCONFIG_FILE, rv);
|
||||
GWEN_Buffer_free(fbuf);
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
GWEN_DB_NODE *db;
|
||||
|
||||
db=GWEN_DB_Group_new("aqhome-config");
|
||||
rv=GWEN_DB_ReadFile(db, GWEN_Buffer_GetStart(fbuf), GWEN_DB_FLAGS_DEFAULT);
|
||||
if (rv<0) {
|
||||
DBG_INFO(AQH_LOGDOMAIN, "Error reading config file \"%s\" (%d)", AQHOME_SYSCONFIG_FILE, rv);
|
||||
GWEN_Buffer_free(fbuf);
|
||||
GWEN_DB_Group_free(db);
|
||||
return NULL;
|
||||
}
|
||||
GWEN_Buffer_free(fbuf);
|
||||
return db;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_MergeConfigFileIntoConfig(GWEN_DB_NODE *dbArgs, const char *destDbGroupName)
|
||||
{
|
||||
GWEN_DB_NODE *dbConfig;
|
||||
|
||||
dbConfig=AQH_LoadConfigFile();
|
||||
if (dbConfig) {
|
||||
GWEN_DB_GroupRename(dbConfig, destDbGroupName);
|
||||
GWEN_DB_AddGroup(dbArgs, dbConfig);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void _initLogging(void)
|
||||
{
|
||||
const char *s;
|
||||
|
||||
if (!GWEN_Logger_IsOpen(AQH_LOGDOMAIN))
|
||||
GWEN_Logger_Open(AQH_LOGDOMAIN, "aqhome", 0, GWEN_LoggerType_Console, GWEN_LoggerFacility_User);
|
||||
|
||||
@@ -43,19 +145,76 @@ int AQH_Init()
|
||||
}
|
||||
else
|
||||
GWEN_Logger_SetLevel(AQH_LOGDOMAIN, GWEN_LoggerLevel_Notice);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int AQH_Fini()
|
||||
void _finiLogging(void)
|
||||
{
|
||||
GWEN_Logger_Close(AQH_LOGDOMAIN);
|
||||
GWEN_Fini();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void _initPathManager(void)
|
||||
{
|
||||
_definePath(AQHOME_PM_SYSCONFDIR, AQHOME_SYSCONF_DIR);
|
||||
_definePath(AQHOME_PM_LOCALEDIR, AQHOME_SYSCONF_DIR);
|
||||
_definePath(AQHOME_PM_DATADIR, AQHOME_DATA_DIR);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void _finiPathManager(void)
|
||||
{
|
||||
GWEN_PathManager_UndefinePath(AQHOME_PM_LIBNAME, AQHOME_PM_LOCALEDIR);
|
||||
GWEN_PathManager_UndefinePath(AQHOME_PM_LIBNAME, AQHOME_PM_DATADIR);
|
||||
GWEN_PathManager_UndefinePath(AQHOME_PM_LIBNAME, AQHOME_PM_SYSCONFDIR);
|
||||
GWEN_PathManager_RemovePaths(AQHOME_PM_LIBNAME);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void _initI18n(void)
|
||||
{
|
||||
GWEN_STRINGLIST *sl;
|
||||
|
||||
sl=GWEN_PathManager_GetPaths(AQHOME_PM_LIBNAME, AQHOME_PM_LOCALEDIR);
|
||||
if (sl) {
|
||||
const char *localedir;
|
||||
int rv;
|
||||
|
||||
localedir=GWEN_StringList_FirstString(sl);
|
||||
|
||||
rv=GWEN_I18N_BindTextDomain_Dir(PACKAGE, localedir);
|
||||
if (rv) {
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "Could not bind textdomain (%d)", rv);
|
||||
}
|
||||
else {
|
||||
rv=GWEN_I18N_BindTextDomain_Codeset(PACKAGE, "UTF-8");
|
||||
if (rv) {
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "Could not set codeset (%d)", rv);
|
||||
}
|
||||
}
|
||||
|
||||
GWEN_StringList_free(sl);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void _definePath(const char *pathName, const char *pathValue)
|
||||
{
|
||||
/* define sysconf paths */
|
||||
GWEN_PathManager_DefinePath(AQHOME_PM_LIBNAME, pathName);
|
||||
#if defined(OS_WIN32) || defined(ENABLE_LOCAL_INSTALL)
|
||||
/* add folder relative to EXE */
|
||||
GWEN_PathManager_AddRelPath(AQHOME_PM_LIBNAME, AQHOME_PM_LIBNAME, pathName, pathValue, GWEN_PathManager_RelModeExe);
|
||||
#else
|
||||
/* add absolute folder */
|
||||
GWEN_PathManager_AddPath(AQHOME_PM_LIBNAME, AQHOME_PM_LIBNAME, pathName, pathValue);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -12,9 +12,19 @@
|
||||
|
||||
#include <aqhome/api.h>
|
||||
|
||||
#include <gwenhywfar/stringlist.h>
|
||||
#include <gwenhywfar/db.h>
|
||||
|
||||
AQHOME_API int AQH_Init();
|
||||
AQHOME_API int AQH_Fini();
|
||||
|
||||
|
||||
AQHOME_API int AQH_Init(void);
|
||||
AQHOME_API void AQH_Fini(void);
|
||||
|
||||
AQHOME_API GWEN_DB_NODE *AQH_LoadConfigFile(void);
|
||||
AQHOME_API void AQH_MergeConfigFileIntoConfig(GWEN_DB_NODE *dbArgs, const char *destDbGroupName);
|
||||
|
||||
AQHOME_API GWEN_STRINGLIST *AQH_GetGlobalDataDirs(void);
|
||||
AQHOME_API GWEN_STRINGLIST *AQH_GetGlobalSysconfDirs(void);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -10,4 +10,4 @@ export LD_LIBRARY_PATH="0-build/aqhome/:$LD_LIBRARY_PATH"
|
||||
# 0-build/apps/aqhomed/aqhomed -l aqhome.log -db aqhome.db -ma 192.168.117.192 -mp 1883 -t 127.0.0.1 -p aqhomed.pid
|
||||
|
||||
# 0-build/apps/aqhomed/aqhomed -l aqhome.log -db aqhome.db -p aqhomed.pid -W /tmp/aqhome/aqhomed -ma 192.168.117.192 -mp 1883 -t 127.0.0.1 --mqttclientid=AQHOMEMQTTLOGTEST1
|
||||
0-build/apps/aqhomed/aqhomed -l aqhome.log -db aqhome.db -p aqhomed.pid -t 127.0.0.1
|
||||
0-build/apps/aqhomed/aqhomed -l aqhome.log -db aqhome.db -p aqhomed.pid -t 127.0.0.1 "$@"
|
||||
|
||||
Reference in New Issue
Block a user