aqhome: implemented IPC client, fixed some bugs.

sending a PING request and retrieving the PONG response works now.
This commit is contained in:
Martin Preuss
2023-04-16 23:22:03 +02:00
parent c00b90bf28
commit d53b061aed
34 changed files with 549 additions and 158 deletions

View File

@@ -21,10 +21,15 @@
#include "aqhome/msg/msg_claimaddr.h"
#include "aqhome/msg/msg_haveaddr.h"
#include "aqhome/msg/msg_device.h"
#include "aqhome/msg/msg_ping.h"
#include "aqhome/msg/endpoint_tty.h"
#include "aqhome/mqtt/endpoint_mqttc.h"
#include "aqhome/ipc/msg_ipc.h"
#include "aqhome/ipc/msg_ipc_ping.h"
#include <gwenhywfar/endpoint_tcpc.h>
#include <gwenhywfar/endpoint_connectable.h>
#include <gwenhywfar/msg_ipc.h>
#include <gwenhywfar/misc.h>
#include <gwenhywfar/debug.h>
@@ -46,6 +51,9 @@ static void _handleMsgHaveAddress(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT
static void _handleMsgComSendStat(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg);
static void _handleMsgComRecvStat(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg);
static void _handleMsgDevice(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg);
static void _handleIpcMsgPing(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg);
static AQH_NODE_INFO *_getOrCreateNodeAndUpdateUidAddr(GWEN_MSG_ENDPOINT_MGR *emgr, const GWEN_MSG *msg, uint32_t uid);
@@ -200,7 +208,7 @@ void _handleNodeMsg(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *ep, const GW
AQH_NodeMsg_GetMsgType(msg), AQH_NodeMsg_GetSourceAddress(msg), AQH_NodeMsg_GetDestAddress(msg));
AQH_MsgEndpointMgr_DistributeMsgFromNodeEndpoint(emgr, ep, msg, AQH_MSGMGR_ENDPOINTGROUP_NODE);
AQH_MsgEndpointMgr_DistributeMsgFromNodeEndpoint(emgr, ep, msg, AQH_MSGMGR_ENDPOINTGROUP_NODE, NULL);
msgIsValid=(AQH_NodeMsg_IsChecksumValid(msg) && AQH_NodeMsg_IsMsgComplete(msg));
msgType=AQH_NodeMsg_GetMsgType(msg);
@@ -223,7 +231,15 @@ void _handleNodeMsg(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *ep, const GW
void _handleIpcMsg(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg)
{
uint16_t code;
/* exec IPC message */
code=GWEN_IpcMsg_GetCode(msg);
DBG_ERROR(AQH_LOGDOMAIN, "Received IPC packet");
switch(code) {
case AQH_MSGTYPE_IPC_PING: _handleIpcMsgPing(emgr, ep, msg); break;
default: break;
}
}
@@ -235,6 +251,20 @@ void _handleMqttMsg(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *ep, const GW
void _handleIpcMsgPing(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg)
{
GWEN_MSG *msgOut;
DBG_ERROR(AQH_LOGDOMAIN, "Received IPC PING message");
msgOut=AQH_PingMsg_new(AQH_MsgEndpointMgr_GetBusAddr(emgr),
AQH_PingIpcMsg_GetDestAddr(msg),
AQH_MSG_TYPE_PING);
AQH_MsgEndpointMgr_DistributeMsgFromNodeEndpoint(emgr, ep, msgOut, AQH_MSGMGR_ENDPOINTGROUP_NODE, AQH_MSG_ENDPOINT_TTY_NAME);
GWEN_Msg_free(msgOut);
}
void _handleMsgValue2(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg)
{
AQH_MSG_MANAGER *xmgr;