adapted to latest changes in gwen.
This commit is contained in:
@@ -170,11 +170,17 @@ GWEN_MSG_ENDPOINT_MGR *_setupService(GWEN_DB_NODE *dbArgs)
|
|||||||
{
|
{
|
||||||
GWEN_MSG_ENDPOINT_MGR *emgr;
|
GWEN_MSG_ENDPOINT_MGR *emgr;
|
||||||
int nodeAddress;
|
int nodeAddress;
|
||||||
|
const char *dbfile;
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
nodeAddress=GWEN_DB_GetIntValue(dbArgs, "nodeAddress", 0, 240);
|
nodeAddress=GWEN_DB_GetIntValue(dbArgs, "nodeAddress", 0, 240);
|
||||||
|
dbfile=GWEN_DB_GetCharValue(dbArgs, "dbfile", 0, "aqhome.db");
|
||||||
|
|
||||||
emgr=AQH_MsgManager_new(nodeAddress & 0xff);
|
emgr=AQH_MsgManager_new(nodeAddress & 0xff);
|
||||||
|
|
||||||
|
if (dbfile && *dbfile)
|
||||||
|
AQH_MsgManager_SetDbFilename(emgr, dbfile);
|
||||||
|
|
||||||
rv=_setupTty(emgr, dbArgs);
|
rv=_setupTty(emgr, dbArgs);
|
||||||
if (rv<0) {
|
if (rv<0) {
|
||||||
DBG_INFO(NULL, "here (%d)", rv);
|
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");
|
DBG_ERROR(NULL, "Error creating endpoint TTY");
|
||||||
return GWEN_ERROR_GENERIC;
|
return GWEN_ERROR_GENERIC;
|
||||||
}
|
}
|
||||||
|
GWEN_MsgEndpoint_SetAcceptedGroupIds(epTty, AQH_MSGMGR_ENDPOINTGROUP_NODE);
|
||||||
GWEN_MsgEndpointMgr_AddEndpoint(emgr, epTty);
|
GWEN_MsgEndpointMgr_AddEndpoint(emgr, epTty);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -246,6 +253,7 @@ int _setupLog(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_DB_NODE *dbArgs)
|
|||||||
DBG_ERROR(AQH_LOGDOMAIN, "Error creating endpoint LOG");
|
DBG_ERROR(AQH_LOGDOMAIN, "Error creating endpoint LOG");
|
||||||
return GWEN_ERROR_GENERIC;
|
return GWEN_ERROR_GENERIC;
|
||||||
}
|
}
|
||||||
|
GWEN_MsgEndpoint_SetAcceptedGroupIds(epLog, AQH_MSGMGR_ENDPOINTGROUP_NODE);
|
||||||
GWEN_MsgEndpointMgr_AddEndpoint(emgr, epLog);
|
GWEN_MsgEndpointMgr_AddEndpoint(emgr, epLog);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -264,11 +272,12 @@ int _setupIpc(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_DB_NODE *dbArgs)
|
|||||||
if (tcpAddress && *tcpAddress && tcpPort) {
|
if (tcpAddress && *tcpAddress && tcpPort) {
|
||||||
GWEN_MSG_ENDPOINT *epTcp;
|
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) {
|
if (epTcp==NULL) {
|
||||||
DBG_ERROR(AQH_LOGDOMAIN, "Error creating endpoint TCP");
|
DBG_ERROR(AQH_LOGDOMAIN, "Error creating endpoint TCP");
|
||||||
return GWEN_ERROR_GENERIC;
|
return GWEN_ERROR_GENERIC;
|
||||||
}
|
}
|
||||||
|
GWEN_MsgEndpoint_SetAcceptedGroupIds(epTcp, AQH_MSGMGR_ENDPOINTGROUP_NODE | AQH_MSGMGR_ENDPOINTGROUP_IPC);
|
||||||
GWEN_MsgEndpointMgr_AddEndpoint(emgr, epTcp);
|
GWEN_MsgEndpointMgr_AddEndpoint(emgr, epTcp);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -293,11 +302,12 @@ int _setupMqtt(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_DB_NODE *dbArgs)
|
|||||||
if (mqttAddress && *mqttAddress && mqttPort) {
|
if (mqttAddress && *mqttAddress && mqttPort) {
|
||||||
GWEN_MSG_ENDPOINT *epMqtt;
|
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) {
|
if (epMqtt==NULL) {
|
||||||
DBG_ERROR(AQH_LOGDOMAIN, "Error creating endpoint TCP");
|
DBG_ERROR(AQH_LOGDOMAIN, "Error creating endpoint TCP");
|
||||||
return GWEN_ERROR_GENERIC;
|
return GWEN_ERROR_GENERIC;
|
||||||
}
|
}
|
||||||
|
GWEN_MsgEndpoint_SetAcceptedGroupIds(epMqtt, AQH_MSGMGR_ENDPOINTGROUP_NODE | AQH_MSGMGR_ENDPOINTGROUP_MQTT);
|
||||||
if (mqttClientId && *mqttClientId)
|
if (mqttClientId && *mqttClientId)
|
||||||
AQH_MqttClientEndpoint_SetClientId(epMqtt, mqttClientId);
|
AQH_MqttClientEndpoint_SetClientId(epMqtt, mqttClientId);
|
||||||
if (mqttTopicPrefix && *mqttTopicPrefix)
|
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)"),
|
||||||
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_ARGS_FLAGS_HAS_ARGUMENT, /* flags */
|
||||||
GWEN_ArgsType_Char, /* type */
|
GWEN_ArgsType_Char, /* type */
|
||||||
|
|||||||
@@ -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);
|
ep=GWEN_MsgEndpoint_new(name?name:AQH_MSG_ENDPOINT_NODE_NAME, groupId);
|
||||||
AQH_NodeEndpoint_Extend(ep);
|
AQH_NodeEndpoint_Extend(ep);
|
||||||
|
|
||||||
return ep;
|
return ep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ GWEN_MSG_ENDPOINT_MGR *AQH_MsgEndpointMgr_new(uint8_t busAddr)
|
|||||||
mgr=GWEN_MsgEndpointMgr_new();
|
mgr=GWEN_MsgEndpointMgr_new();
|
||||||
GWEN_NEW_OBJECT(AQH_MSG_ENDPOINT_MGR, xmgr);
|
GWEN_NEW_OBJECT(AQH_MSG_ENDPOINT_MGR, xmgr);
|
||||||
GWEN_INHERIT_SETDATA(GWEN_MSG_ENDPOINT_MGR, AQH_MSG_ENDPOINT_MGR, mgr, xmgr, _freeData);
|
GWEN_INHERIT_SETDATA(GWEN_MSG_ENDPOINT_MGR, AQH_MSG_ENDPOINT_MGR, mgr, xmgr, _freeData);
|
||||||
|
|
||||||
xmgr->busAddr=busAddr;
|
xmgr->busAddr=busAddr;
|
||||||
|
|
||||||
return mgr;
|
return mgr;
|
||||||
@@ -67,16 +66,16 @@ void AQH_MsgEndpointMgr_DistributeMsgFromNodeEndpoint(GWEN_MSG_ENDPOINT_MGR *emg
|
|||||||
endpointList=GWEN_MsgEndpointMgr_GetEndpointList(emgr);
|
endpointList=GWEN_MsgEndpointMgr_GetEndpointList(emgr);
|
||||||
if (endpointList) {
|
if (endpointList) {
|
||||||
GWEN_MSG_ENDPOINT *ep;
|
GWEN_MSG_ENDPOINT *ep;
|
||||||
int srcGroupId;
|
int acceptedGroupIds;
|
||||||
uint32_t msgGroup;
|
uint32_t msgGroup;
|
||||||
|
|
||||||
msgGroup=AQH_NodeMsg_GetMsgGroup(AQH_NodeMsg_GetMsgType(msg));
|
msgGroup=AQH_NodeMsg_GetMsgGroup(AQH_NodeMsg_GetMsgType(msg));
|
||||||
srcGroupId=GWEN_MsgEndpoint_GetGroupId(srcEp);
|
acceptedGroupIds=GWEN_MsgEndpoint_GetAcceptedGroupIds(srcEp);
|
||||||
|
|
||||||
ep=GWEN_MsgEndpoint_List_First(endpointList);
|
ep=GWEN_MsgEndpoint_List_First(endpointList);
|
||||||
while(ep) {
|
while(ep) {
|
||||||
if (ep!=srcEp) {
|
if (ep!=srcEp) {
|
||||||
if (srcGroupId & groupId) {
|
if (acceptedGroupIds & groupId) {
|
||||||
uint32_t acceptedMsgGroups;
|
uint32_t acceptedMsgGroups;
|
||||||
|
|
||||||
acceptedMsgGroups=AQH_NodeEndpoint_GetAcceptedMsgGroups(ep);
|
acceptedMsgGroups=AQH_NodeEndpoint_GetAcceptedMsgGroups(ep);
|
||||||
|
|||||||
Reference in New Issue
Block a user