diff --git a/apps/aqhomed/main.c b/apps/aqhomed/main.c index bdfda83..24456a3 100644 --- a/apps/aqhomed/main.c +++ b/apps/aqhomed/main.c @@ -170,11 +170,17 @@ GWEN_MSG_ENDPOINT_MGR *_setupService(GWEN_DB_NODE *dbArgs) { GWEN_MSG_ENDPOINT_MGR *emgr; int nodeAddress; + const char *dbfile; int rv; nodeAddress=GWEN_DB_GetIntValue(dbArgs, "nodeAddress", 0, 240); + dbfile=GWEN_DB_GetCharValue(dbArgs, "dbfile", 0, "aqhome.db"); emgr=AQH_MsgManager_new(nodeAddress & 0xff); + + if (dbfile && *dbfile) + AQH_MsgManager_SetDbFilename(emgr, dbfile); + rv=_setupTty(emgr, dbArgs); if (rv<0) { DBG_INFO(NULL, "here (%d)", rv); @@ -221,6 +227,7 @@ int _setupTty(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_DB_NODE *dbArgs) DBG_ERROR(NULL, "Error creating endpoint TTY"); return GWEN_ERROR_GENERIC; } + GWEN_MsgEndpoint_SetAcceptedGroupIds(epTty, AQH_MSGMGR_ENDPOINTGROUP_NODE); GWEN_MsgEndpointMgr_AddEndpoint(emgr, epTty); } else { @@ -246,6 +253,7 @@ int _setupLog(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_DB_NODE *dbArgs) DBG_ERROR(AQH_LOGDOMAIN, "Error creating endpoint LOG"); return GWEN_ERROR_GENERIC; } + GWEN_MsgEndpoint_SetAcceptedGroupIds(epLog, AQH_MSGMGR_ENDPOINTGROUP_NODE); GWEN_MsgEndpointMgr_AddEndpoint(emgr, epLog); } return 0; @@ -264,11 +272,12 @@ int _setupIpc(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_DB_NODE *dbArgs) if (tcpAddress && *tcpAddress && tcpPort) { GWEN_MSG_ENDPOINT *epTcp; - epTcp=AQH_TcpdIpcNodeEndpoint_new(tcpAddress, tcpPort, NULL, AQH_MSGMGR_ENDPOINTGROUP_IPC); + epTcp=AQH_TcpdIpcNodeEndpoint_new(tcpAddress, tcpPort, NULL, AQH_MSGMGR_ENDPOINTGROUP_NODE|AQH_MSGMGR_ENDPOINTGROUP_IPC); if (epTcp==NULL) { DBG_ERROR(AQH_LOGDOMAIN, "Error creating endpoint TCP"); return GWEN_ERROR_GENERIC; } + GWEN_MsgEndpoint_SetAcceptedGroupIds(epTcp, AQH_MSGMGR_ENDPOINTGROUP_NODE | AQH_MSGMGR_ENDPOINTGROUP_IPC); GWEN_MsgEndpointMgr_AddEndpoint(emgr, epTcp); } return 0; @@ -293,11 +302,12 @@ int _setupMqtt(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_DB_NODE *dbArgs) if (mqttAddress && *mqttAddress && mqttPort) { GWEN_MSG_ENDPOINT *epMqtt; - epMqtt=AQH_MqttClientEndpoint_new(mqttAddress, mqttPort, NULL, AQH_MSGMGR_ENDPOINTGROUP_NODE|AQH_MSGMGR_ENDPOINTGROUP_MQTT); + epMqtt=AQH_MqttClientEndpoint_new(mqttAddress, mqttPort, NULL, AQH_MSGMGR_ENDPOINTGROUP_MQTT); if (epMqtt==NULL) { DBG_ERROR(AQH_LOGDOMAIN, "Error creating endpoint TCP"); return GWEN_ERROR_GENERIC; } + GWEN_MsgEndpoint_SetAcceptedGroupIds(epMqtt, AQH_MSGMGR_ENDPOINTGROUP_NODE | AQH_MSGMGR_ENDPOINTGROUP_MQTT); if (mqttClientId && *mqttClientId) AQH_MqttClientEndpoint_SetClientId(epMqtt, mqttClientId); if (mqttTopicPrefix && *mqttTopicPrefix) @@ -447,6 +457,17 @@ int _readArgs(int argc, char **argv, GWEN_DB_NODE *dbArgs) I18S("Specify keepalive time in seconds (defaults: 600)"), I18S("Specify keepalive time in seconds (defaults: 600)") }, + { + GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ + GWEN_ArgsType_Char, /* type */ + "dbfile", /* name */ + 0, /* minnum */ + 1, /* maxnum */ + "db", /* short option */ + "dbfile", /* long option */ + I18S("Specify DB file to read/write node database"), + I18S("Specify DB file to read/write node database") + }, { GWEN_ARGS_FLAGS_HAS_ARGUMENT, /* flags */ GWEN_ArgsType_Char, /* type */ diff --git a/aqhome/msg/endpoint_node.c b/aqhome/msg/endpoint_node.c index 0384f15..581fecd 100644 --- a/aqhome/msg/endpoint_node.c +++ b/aqhome/msg/endpoint_node.c @@ -42,7 +42,6 @@ GWEN_MSG_ENDPOINT *AQH_NodeEndpoint_new(const char *name, int groupId) ep=GWEN_MsgEndpoint_new(name?name:AQH_MSG_ENDPOINT_NODE_NAME, groupId); AQH_NodeEndpoint_Extend(ep); - return ep; } diff --git a/aqhome/msg/endpointmgr.c b/aqhome/msg/endpointmgr.c index f7bdb08..5d59a9f 100644 --- a/aqhome/msg/endpointmgr.c +++ b/aqhome/msg/endpointmgr.c @@ -39,7 +39,6 @@ GWEN_MSG_ENDPOINT_MGR *AQH_MsgEndpointMgr_new(uint8_t busAddr) mgr=GWEN_MsgEndpointMgr_new(); GWEN_NEW_OBJECT(AQH_MSG_ENDPOINT_MGR, xmgr); GWEN_INHERIT_SETDATA(GWEN_MSG_ENDPOINT_MGR, AQH_MSG_ENDPOINT_MGR, mgr, xmgr, _freeData); - xmgr->busAddr=busAddr; return mgr; @@ -67,16 +66,16 @@ void AQH_MsgEndpointMgr_DistributeMsgFromNodeEndpoint(GWEN_MSG_ENDPOINT_MGR *emg endpointList=GWEN_MsgEndpointMgr_GetEndpointList(emgr); if (endpointList) { GWEN_MSG_ENDPOINT *ep; - int srcGroupId; + int acceptedGroupIds; uint32_t msgGroup; msgGroup=AQH_NodeMsg_GetMsgGroup(AQH_NodeMsg_GetMsgType(msg)); - srcGroupId=GWEN_MsgEndpoint_GetGroupId(srcEp); + acceptedGroupIds=GWEN_MsgEndpoint_GetAcceptedGroupIds(srcEp); ep=GWEN_MsgEndpoint_List_First(endpointList); while(ep) { if (ep!=srcEp) { - if (srcGroupId & groupId) { + if (acceptedGroupIds & groupId) { uint32_t acceptedMsgGroups; acceptedMsgGroups=AQH_NodeEndpoint_GetAcceptedMsgGroups(ep);