More work on IPC code, added aqhomed daemon.

This commit is contained in:
Martin Preuss
2023-03-18 23:25:21 +01:00
parent c26119d34c
commit d1c21322b8
23 changed files with 1127 additions and 61 deletions

View File

@@ -39,12 +39,12 @@
</setVar>
<headers dist="false" install="$(pkgincludedir)/nodes" >
<headers dist="false" install="$(pkgincludedir)/msg" >
$(local/built_headers_pub)
</headers>
<headers dist="true" install="$(pkgincludedir)/nodes" >
<headers dist="true" install="$(pkgincludedir)/msg" >
endpointmgr.h
endpoint_node.h
endpoint_log.h

View File

@@ -39,18 +39,25 @@ static void GWENHYWFAR_CB _freeData(void *bp, void *p);
GWEN_MSG_ENDPOINT *AQH_NodeEndpoint_new(const char *name, int groupId)
{
GWEN_MSG_ENDPOINT *ep;
AQH_MSG_ENDPOINT_NODE *xep;
int fd;
ep=GWEN_MsgEndpoint_new(name?name:AQH_MSG_ENDPOINT_NODE_NAME, groupId);
GWEN_NEW_OBJECT(AQH_MSG_ENDPOINT_NODE, xep);
GWEN_INHERIT_SETDATA(GWEN_MSG_ENDPOINT, AQH_MSG_ENDPOINT_NODE, ep, xep, _freeData);
AQH_NodeEndpoint_Extend(ep);
return ep;
}
void AQH_NodeEndpoint_Extend(GWEN_MSG_ENDPOINT *ep)
{
AQH_MSG_ENDPOINT_NODE *xep;
GWEN_NEW_OBJECT(AQH_MSG_ENDPOINT_NODE, xep);
GWEN_INHERIT_SETDATA(GWEN_MSG_ENDPOINT, AQH_MSG_ENDPOINT_NODE, ep, xep, _freeData);
}
void _freeData(void *bp, void *p)
{
AQH_MSG_ENDPOINT_NODE *xep;

View File

@@ -20,6 +20,7 @@
AQHOME_API GWEN_MSG_ENDPOINT *AQH_NodeEndpoint_new(const char *name, int groupId);
AQHOME_API void AQH_NodeEndpoint_Extend(GWEN_MSG_ENDPOINT *ep);
AQHOME_API uint32_t AQH_NodeEndpoint_GetAcceptedMsgGroups(const GWEN_MSG_ENDPOINT *ep);
AQHOME_API void AQH_NodeEndpoint_SetAcceptedMsgGroups(GWEN_MSG_ENDPOINT *ep, uint32_t f);

View File

@@ -27,10 +27,8 @@ GWEN_INHERIT(GWEN_MSG_ENDPOINT_MGR, AQH_MSG_ENDPOINT_MGR);
static void GWENHYWFAR_CB _freeData(void *bp, void *p);
static void _msgLoopOnce(GWEN_MSG_ENDPOINT_MGR *emgr);
static void _handleEndpoint(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *ep);
static void _handleNodeEndpoint(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *ep);
static void _handleIpcEndpoint(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *ep);
static void _distributeMsgFromNodeEndpoint(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *srcEp, const GWEN_MSG *msg);
@@ -64,19 +62,19 @@ void _freeData(void *bp, void *p)
int AQH_MsgEndpointMgr_LoopOnce(GWEN_MSG_ENDPOINT_MGR *emgr)
int AQH_MsgEndpointMgr_LoopOnce(GWEN_MSG_ENDPOINT_MGR *emgr, int groupId)
{
int rv;
rv=GWEN_MsgEndpointMgr_IoLoopOnce(emgr);
_msgLoopOnce(emgr);
AQH_MsgEndpointMgr_LoopOnceOverNodeEndpoints(emgr, groupId);
GWEN_MsgEndpointMgr_RunAllEndpoints(emgr);
return rv;
}
void _msgLoopOnce(GWEN_MSG_ENDPOINT_MGR *emgr)
void AQH_MsgEndpointMgr_LoopOnceOverNodeEndpoints(GWEN_MSG_ENDPOINT_MGR *emgr, int groupId)
{
GWEN_MSG_ENDPOINT_LIST *endpointList;
@@ -88,7 +86,8 @@ void _msgLoopOnce(GWEN_MSG_ENDPOINT_MGR *emgr)
ep=GWEN_MsgEndpoint_List_First(endpointList);
while(ep) {
DBG_DEBUG(AQH_LOGDOMAIN, "- endpoint(%s)", GWEN_MsgEndpoint_GetName(ep));
_handleEndpoint(emgr, ep);
if (GWEN_MsgEndpoint_GetGroupId(ep)==groupId)
_handleNodeEndpoint(emgr, ep);
ep=GWEN_MsgEndpoint_List_Next(ep);
}
}
@@ -96,17 +95,6 @@ void _msgLoopOnce(GWEN_MSG_ENDPOINT_MGR *emgr)
void _handleEndpoint(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *ep)
{
switch(GWEN_MsgEndpoint_GetGroupId(ep)) {
case AQH_MSG_ENDPOINTGROUP_NODE: _handleNodeEndpoint(emgr, ep); break;
case AQH_MSG_ENDPOINTGROUP_IPC: _handleIpcEndpoint(emgr, ep); break;
default: break;
}
}
void _handleNodeEndpoint(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *ep)
{
GWEN_MSG *msg;
@@ -122,13 +110,6 @@ void _handleNodeEndpoint(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *ep)
void _handleIpcEndpoint(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *ep)
{
/* TODO: handle IPC messages */
}
void _distributeMsgFromNodeEndpoint(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *srcEp, const GWEN_MSG *msg)
{
GWEN_MSG_ENDPOINT_LIST *endpointList;
@@ -159,7 +140,7 @@ void _distributeMsgFromNodeEndpoint(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOI
) {
/* endpoint accepts this message */
DBG_DEBUG(AQH_LOGDOMAIN, " - endpoint %s accepts message", GWEN_MsgEndpoint_GetName(ep));
GWEN_MsgEndpoint_AddSendMessage(ep, GWEN_Msg_dup(msg));
GWEN_MsgEndpoint_ProcessOutMessage(ep, GWEN_Msg_dup(msg));
}
else {
DBG_DEBUG(AQH_LOGDOMAIN, " - endpoint %s does not accept message", GWEN_MsgEndpoint_GetName(ep));

View File

@@ -16,13 +16,10 @@
#define AQH_MSG_ENDPOINTGROUP_NODE 1
#define AQH_MSG_ENDPOINTGROUP_IPC 2
AQHOME_API GWEN_MSG_ENDPOINT_MGR *AQH_MsgEndpointMgr_new(uint8_t busAddr);
AQHOME_API int AQH_MsgEndpointMgr_LoopOnce(GWEN_MSG_ENDPOINT_MGR *emgr);
AQHOME_API int AQH_MsgEndpointMgr_LoopOnce(GWEN_MSG_ENDPOINT_MGR *emgr, int groupId);
AQHOME_API void AQH_MsgEndpointMgr_LoopOnceOverNodeEndpoints(GWEN_MSG_ENDPOINT_MGR *emgr, int groupId);