aqhome: Prepared reorganizing IPC and nodes code around built-in event2 api.

This commit is contained in:
Martin Preuss
2025-02-26 00:49:33 +01:00
parent cf8edbbd5f
commit f63079af11
54 changed files with 2390 additions and 202 deletions

View File

@@ -0,0 +1,84 @@
<?xml?>
<gwbuild>
<target type="ConvenienceLibrary" name="aqhmsg_ipcn" >
<includes type="c" >
$(gwenhywfar_cflags)
-I$(topsrcdir)
-I$(topbuilddir)
</includes>
<includes type="tm2" >
--include=$(builddir)
--include=$(srcdir)
</includes>
<define name="BUILDING_AQHOME" />
<setVar name="local/cflags">$(visibility_cflags)</setVar>
<setVar name="tm2flags" >
--api=AQHOME_API
</setVar>
<setVar name="local/typefiles" >
</setVar>
<setVar name="local/built_sources" >
</setVar>
<setVar name="local/built_headers_pub">
</setVar>
<setVar name="local/built_headers_priv" >
</setVar>
<headers dist="false" install="$(pkgincludedir)/msg" >
$(local/built_headers_pub)
</headers>
<headers dist="true" install="$(pkgincludedir)/msg" >
m_ipcn.h
m_ipcn_forward.h
m_ipcn_getdevices_req.h
m_ipcn_getdevices_rsp.h
</headers>
<headers dist="true" >
</headers>
<sources>
$(local/typefiles)
m_ipcn.c
m_ipcn_forward.c
m_ipcn_getdevices_req.c
m_ipcn_getdevices_rsp.c
</sources>
<extradist>
</extradist>
<useTargets>
</useTargets>
<subdirs>
</subdirs>
</target>
</gwbuild>

View File

@@ -0,0 +1,46 @@
/****************************************************************************
* This file is part of the project AqHome.
* AqHome (c) by 2025 Martin Preuss, all rights reserved.
*
* The license for this file can be found in the file COPYING which you
* should have received along with this file.
****************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "aqhome/msg/ipc/nodes/m_ipcn.h"
#include "aqhome/msg/ipc/m_ipc.h"
#include <gwenhywfar/text.h>
/* ------------------------------------------------------------------------------------------------
* forward declarations
* ------------------------------------------------------------------------------------------------
*/
/* ------------------------------------------------------------------------------------------------
* implementation
* ------------------------------------------------------------------------------------------------
*/
const char *AQH_IpcnMessage_MsgTypeToChar(uint16_t i)
{
switch(i) {
case AQH_MSGTYPE_IPC_NODES_RESULT: return "Result";
case AQH_MSGTYPE_IPC_NODES_FORWARD: return "Forward";
case AQH_MSGTYPE_IPC_NODES_VALUE: return "Value";
case AQH_MSGTYPE_IPC_NODES_PING: return "Ping";
case AQH_MSGTYPE_IPC_NODES_SETACCMSGGRPS: return "SetAccMsgGroups";
case AQH_MSGTYPE_IPC_NODES_GETDEVICES_REQ: return "GetDevices(Req)";
case AQH_MSGTYPE_IPC_NODES_GETDEVICES_RSP: return "GetDevices(Rsp)";
default: return "(unknown)";
}
}

View File

@@ -0,0 +1,43 @@
/****************************************************************************
* This file is part of the project AqHome.
* AqHome (c) by 2025 Martin Preuss, all rights reserved.
*
* The license for this file can be found in the file COPYING which you
* should have received along with this file.
****************************************************************************/
#ifndef AQH_MSG_IPC_NODES_M_IPCN_H
#define AQH_MSG_IPC_NODES_M_IPCN_H
#include <aqhome/api.h>
#include <gwenhywfar/msg_ipc.h>
#include <gwenhywfar/buffer.h>
#include <stdint.h>
#define AQH_IPC_PROTOCOL_NODES_ID 1
#define AQH_IPC_PROTOCOL_NODES_VERSION 1
#define AQH_MSGTYPE_IPC_NODES_RESULT 0xf001
#define AQH_MSGTYPE_IPC_NODES_FORWARD 0xf100
#define AQH_MSGTYPE_IPC_NODES_VALUE 0xf200
#define AQH_MSGTYPE_IPC_NODES_PING 0xf300
#define AQH_MSGTYPE_IPC_NODES_SETACCMSGGRPS 0xf400
#define AQH_MSGTYPE_IPC_NODES_GETDEVICES_REQ 0xf500
#define AQH_MSGTYPE_IPC_NODES_GETDEVICES_RSP 0xf600
AQHOME_API const char *AQH_IpcnMessage_MsgTypeToChar(uint16_t i);
#endif

View File

@@ -0,0 +1,80 @@
/****************************************************************************
* This file is part of the project AqHome.
* AqHome (c) by 2025 Martin Preuss, all rights reserved.
*
* The license for this file can be found in the file COPYING which you
* should have received along with this file.
****************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "aqhome/msg/ipc/nodes/m_ipcn_forward.h"
#include "aqhome/msg/ipc/m_ipc_tag16.h"
#include "aqhome/msg/ipc/nodes/m_ipcn.h"
#include "aqhome/msg/ipc/m_ipc.h"
#include <gwenhywfar/text.h>
#include <gwenhywfar/tag16.h>
#include <gwenhywfar/buffer.h>
/* ------------------------------------------------------------------------------------------------
* forward declarations
* ------------------------------------------------------------------------------------------------
*/
/* ------------------------------------------------------------------------------------------------
* implementation
* ------------------------------------------------------------------------------------------------
*/
AQH_MESSAGE *AQH_IpcnMessageForward_new(uint16_t code, uint32_t msgId, uint32_t refMsgId,
const uint8_t *ptr, uint32_t len)
{
AQH_MESSAGE *msg;
GWEN_BUFFER *buf;
buf=GWEN_Buffer_new(0, 256, 0, 1);
GWEN_Tag16_WriteTagToBuffer(AQH_MSGNODE_FORWARD_TAGS_MSG, ptr, len, buf);
msg=AQH_IpcMessage_new(AQH_IPC_PROTOCOL_NODES_ID, AQH_IPC_PROTOCOL_NODES_VERSION, code, msgId, refMsgId,
GWEN_Buffer_GetUsedBytes(buf), (const uint8_t*) GWEN_Buffer_GetStart(buf));
GWEN_Buffer_free(buf);
return msg;
}
void AQH_IpcnMessageForward_DumpToBuffer(const AQH_MESSAGE *msg, const GWEN_TAG16_LIST *tagList, GWEN_BUFFER *dbuf, const char *sText)
{
const GWEN_TAG16 *tag;
const uint8_t *ptr;
uint32_t len;
tag=tagList?GWEN_Tag16_List_FindFirstByTagType(tagList, AQH_MSGNODE_FORWARD_TAGS_MSG):NULL;
ptr=tag?GWEN_Tag16_GetTagData(tag):NULL;
len=tag?GWEN_Tag16_GetTagLength(tag):0;
GWEN_Buffer_AppendArgs(dbuf, "FORWARD(%s) %s (code=%d, protocol=%d, protocol version=%d)\n",
AQH_IpcnMessage_MsgTypeToChar(AQH_IpcMessage_GetCode(msg)),
sText?sText:"",
AQH_IpcMessage_GetCode(msg),
AQH_IpcMessage_GetProtoId(msg),
AQH_IpcMessage_GetProtoVersion(msg));
if (ptr && len) {
GWEN_Text_DumpString2Buffer((const char*)ptr, len, dbuf, 2);
GWEN_Buffer_AppendByte(dbuf, '\n');
}
}

View File

@@ -0,0 +1,37 @@
/****************************************************************************
* This file is part of the project AqHome.
* AqHome (c) by 2025 Martin Preuss, all rights reserved.
*
* The license for this file can be found in the file COPYING which you
* should have received along with this file.
****************************************************************************/
#ifndef AQH_M_IPCN_M_FORWARD_H
#define AQH_M_IPCN_M_FORWARD_H
#include <aqhome/api.h>
#include <aqhome/ipc2/message.h>
#include <aqhome/data/value.h>
#include <gwenhywfar/tag16.h>
#include <gwenhywfar/buffer.h>
#define AQH_MSGNODE_FORWARD_TAGS_MSG 0x01
AQHOME_API AQH_MESSAGE *AQH_IpcnMessageForward_new(uint16_t code, uint32_t msgId, uint32_t refMsgId,
const uint8_t *ptr, uint32_t len);
AQHOME_API void AQH_IpcnMessageForward_DumpToBuffer(const AQH_MESSAGE *msg, const GWEN_TAG16_LIST *tagList,
GWEN_BUFFER *dbuf, const char *sText);
#endif

View File

@@ -0,0 +1,57 @@
/****************************************************************************
* This file is part of the project AqHome.
* AqHome (c) by 2025 Martin Preuss, all rights reserved.
*
* The license for this file can be found in the file COPYING which you
* should have received along with this file.
****************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "aqhome/msg/ipc/nodes/m_ipcn_getdevices_req.h"
#include "aqhome/msg/ipc/m_ipc_tag16.h"
#include "aqhome/msg/ipc/nodes/m_ipcn.h"
#include "aqhome/msg/ipc/m_ipc.h"
#include <gwenhywfar/text.h>
#include <gwenhywfar/tag16.h>
#include <gwenhywfar/buffer.h>
/* ------------------------------------------------------------------------------------------------
* forward declarations
* ------------------------------------------------------------------------------------------------
*/
/* ------------------------------------------------------------------------------------------------
* implementation
* ------------------------------------------------------------------------------------------------
*/
AQH_MESSAGE *AQH_IpcnMessageGetDevicesReq_new(uint16_t code, uint32_t msgId, uint32_t refMsgId)
{
return AQH_IpcMessage_new(AQH_IPC_PROTOCOL_NODES_ID, AQH_IPC_PROTOCOL_NODES_VERSION, code, msgId, refMsgId, 0, NULL);
}
void AQH_IpcnMessageGetDevicesReq_DumpToBuffer(const AQH_MESSAGE *msg, GWEN_BUFFER *dbuf, const char *sText)
{
GWEN_Buffer_AppendArgs(dbuf, "GETDEVICESREQ(%s) %s (code=%d, protocol=%d, protocol version=%d)\n",
AQH_IpcnMessage_MsgTypeToChar(AQH_IpcMessage_GetCode(msg)),
sText?sText:"",
AQH_IpcMessage_GetCode(msg),
AQH_IpcMessage_GetProtoId(msg),
AQH_IpcMessage_GetProtoVersion(msg));
}

View File

@@ -0,0 +1,30 @@
/****************************************************************************
* This file is part of the project AqHome.
* AqHome (c) by 2025 Martin Preuss, all rights reserved.
*
* The license for this file can be found in the file COPYING which you
* should have received along with this file.
****************************************************************************/
#ifndef AQH_M_IPCN_M_GETDEVICES_REQ_H
#define AQH_M_IPCN_M_GETDEVICES_REQ_H
#include <aqhome/api.h>
#include <aqhome/ipc2/message.h>
#include <aqhome/data/value.h>
#include <gwenhywfar/tag16.h>
#include <gwenhywfar/buffer.h>
AQHOME_API AQH_MESSAGE *AQH_IpcnMessageGetDevicesReq_new(uint16_t code, uint32_t msgId, uint32_t refMsgId);
AQHOME_API void AQH_IpcnMessageGetDevicesReq_DumpToBuffer(const AQH_MESSAGE *msg, GWEN_BUFFER *dbuf, const char *sText);
#endif

View File

@@ -0,0 +1,100 @@
/****************************************************************************
* This file is part of the project AqHome.
* AqHome (c) by 2025 Martin Preuss, all rights reserved.
*
* The license for this file can be found in the file COPYING which you
* should have received along with this file.
****************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "aqhome/msg/ipc/nodes/m_ipcn_getdevices_rsp.h"
#include "aqhome/msg/ipc/m_ipc_tag16.h"
#include "aqhome/msg/ipc/nodes/m_ipcn.h"
#include "aqhome/msg/ipc/m_ipc.h"
#include <gwenhywfar/text.h>
#include <gwenhywfar/tag16.h>
#include <gwenhywfar/buffer.h>
#include <gwenhywfar/debug.h>
/* ------------------------------------------------------------------------------------------------
* forward declarations
* ------------------------------------------------------------------------------------------------
*/
/* ------------------------------------------------------------------------------------------------
* implementation
* ------------------------------------------------------------------------------------------------
*/
AQH_MESSAGE *AQH_IpcnMessageGetDevicesRsp_new(uint16_t code, uint32_t msgId, uint32_t refMsgId, uint32_t flags, const AQH_NODE_INFO *ni)
{
AQH_MESSAGE *msg;
GWEN_BUFFER *buf;
buf=GWEN_Buffer_new(0, 256, 0, 1);
GWEN_Tag16_WriteUint32TagToBuffer(AQH_MSGNODE_GETDEVICES_RSP_TAGS_FLAGS, flags, buf);
AQH_Tag16_WriteNodeInfoAsTagToBuffer(AQH_MSGNODE_GETDEVICES_RSP_TAGS_NODEINFO, ni, buf);
msg=AQH_IpcMessage_new(AQH_IPC_PROTOCOL_NODES_ID, AQH_IPC_PROTOCOL_NODES_VERSION, code, msgId, refMsgId,
GWEN_Buffer_GetUsedBytes(buf), (const uint8_t*) GWEN_Buffer_GetStart(buf));
GWEN_Buffer_free(buf);
return msg;
}
AQH_NODE_INFO *AQH_IpcnMessageGetDevicesRsp_ReadNodeInfo(const GWEN_TAG16_LIST *tagList)
{
if (tagList) {
AQH_NODE_INFO *ni;
ni=AQH_Tag16_ReadNodeInfoFromTagList(tagList, AQH_MSGNODE_GETDEVICES_RSP_TAGS_NODEINFO);
if (ni==NULL) {
DBG_INFO(AQH_LOGDOMAIN, "No node info received");
}
return ni;
}
return NULL;
}
void AQH_IpcnMessageGetDevicesRsp_DumpToBuffer(const AQH_MESSAGE *msg, const GWEN_TAG16_LIST *tagList,
GWEN_BUFFER *dbuf, const char *sText)
{
AQH_NODE_INFO *ni;
uint8_t busAddr;
uint32_t uid;
uint32_t flags;
ni=tagList?AQH_IpcnMessageGetDevicesRsp_ReadNodeInfo(tagList):NULL;
busAddr=ni?AQH_NodeInfo_GetBusAddress(ni):0;
uid=ni?AQH_NodeInfo_GetUid(ni):0;
flags=tagList?AQH_Tag16_GetTagDataAsUint32(tagList, AQH_MSGNODE_GETDEVICES_RSP_TAGS_FLAGS, 0):0;
GWEN_Buffer_AppendArgs(dbuf, "GETDEVICESRSP(%s) %s (code=%d, protocol=%d/%d, flags=%04x, addr=%d, uid=%08x)\n",
AQH_IpcnMessage_MsgTypeToChar(AQH_IpcMessage_GetCode(msg)),
sText?sText:"",
AQH_IpcMessage_GetCode(msg),
AQH_IpcMessage_GetProtoId(msg),
AQH_IpcMessage_GetProtoVersion(msg),
flags,
busAddr,
uid);
AQH_NodeInfo_free(ni);
}

View File

@@ -0,0 +1,40 @@
/****************************************************************************
* This file is part of the project AqHome.
* AqHome (c) by 2025 Martin Preuss, all rights reserved.
*
* The license for this file can be found in the file COPYING which you
* should have received along with this file.
****************************************************************************/
#ifndef AQH_M_IPCN_M_GETDEVICES_RSP_H
#define AQH_M_IPCN_M_GETDEVICES_RSP_H
#include <aqhome/api.h>
#include <aqhome/ipc2/message.h>
#include <aqhome/data/value.h>
#include <aqhome/nodes/nodeinfo.h>
#include <gwenhywfar/tag16.h>
#include <gwenhywfar/buffer.h>
#define AQH_MSGNODE_GETDEVICES_RSP_TAGS_FLAGS 0x01
#define AQH_MSGNODE_GETDEVICES_RSP_TAGS_NODEINFO 0xc2
AQHOME_API AQH_MESSAGE *AQH_IpcnMessageGetDevicesRsp_new(uint16_t code, uint32_t msgId, uint32_t refMsgId,
uint32_t flags, const AQH_NODE_INFO *ni);
AQHOME_API AQH_NODE_INFO *AQH_IpcnMessageGetDevicesRsp_ReadNodeInfo(const GWEN_TAG16_LIST *tagList);
AQHOME_API void AQH_IpcnMessageGetDevicesRsp_DumpToBuffer(const AQH_MESSAGE *msg, const GWEN_TAG16_LIST *tagList,
GWEN_BUFFER *dbuf, const char *sText);
#endif