aqhome: Prepared reorganizing IPC and nodes code around built-in event2 api.
This commit is contained in:
@@ -70,10 +70,12 @@
|
||||
|
||||
<useTargets>
|
||||
aqhmsg_ipcd
|
||||
aqhmsg_ipcn
|
||||
</useTargets>
|
||||
|
||||
<subdirs>
|
||||
data
|
||||
nodes
|
||||
</subdirs>
|
||||
|
||||
|
||||
|
||||
@@ -54,3 +54,5 @@ const char *AQH_IpcdMessage_MsgTypeToChar(uint16_t i)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
#include <aqhome/api.h>
|
||||
#include <aqhome/ipc2/message.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
|
||||
#define AQH_IPC_PROTOCOL_DATA_ID 2
|
||||
#define AQH_IPC_PROTOCOL_DATA_VERSION 1
|
||||
|
||||
@@ -59,6 +59,30 @@ AQH_MESSAGE *AQH_IpcdMessageDevices_new(uint16_t code, uint32_t msgId, uint32_t
|
||||
|
||||
|
||||
|
||||
AQH_MESSAGE *AQH_IpcdMessageDevices_newForOneDevice(uint16_t code, uint32_t msgId, uint32_t refMsgId,
|
||||
uint32_t flags, const AQH_DEVICE *device)
|
||||
{
|
||||
AQH_MESSAGE *msg;
|
||||
GWEN_BUFFER *buf;
|
||||
int rv;
|
||||
|
||||
buf=GWEN_Buffer_new(0, 256, 0, 1);
|
||||
GWEN_Tag16_WriteUint32TagToBuffer(AQH_MSGDATA_DEVICES_TAGS_FLAGS, flags, buf);
|
||||
rv=AQH_Tag16_WriteDeviceAsTagToBuffer(AQH_MSGDATA_DEVICES_TAGS_DEVICE, device, buf);
|
||||
if (rv<0) {
|
||||
DBG_INFO(AQH_LOGDOMAIN, "here (%d)", rv);
|
||||
GWEN_Buffer_free(buf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
msg=AQH_IpcMessage_new(AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, code, msgId, refMsgId,
|
||||
GWEN_Buffer_GetUsedBytes(buf), (const uint8_t*) GWEN_Buffer_GetStart(buf));
|
||||
GWEN_Buffer_free(buf);
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
AQH_DEVICE_LIST *AQH_IpcdMessageDevices_ReadDeviceList(const GWEN_TAG16_LIST *tagList)
|
||||
{
|
||||
if (tagList) {
|
||||
|
||||
@@ -29,6 +29,9 @@
|
||||
|
||||
AQHOME_API AQH_MESSAGE *AQH_IpcdMessageDevices_new(uint16_t code, uint32_t msgId, uint32_t refMsgId,
|
||||
uint32_t flags, const AQH_DEVICE_LIST *deviceList);
|
||||
AQHOME_API AQH_MESSAGE *AQH_IpcdMessageDevices_newForOneDevice(uint16_t code, uint32_t msgId, uint32_t refMsgId,
|
||||
uint32_t flags, const AQH_DEVICE *device);
|
||||
|
||||
AQHOME_API AQH_DEVICE_LIST *AQH_IpcdMessageDevices_ReadDeviceList(const GWEN_TAG16_LIST *tagList);
|
||||
AQHOME_API AQH_DEVICE *AQH_IpcdMessageDevices_ReadFirstDevice(const GWEN_TAG16_LIST *tagList);
|
||||
AQHOME_API uint32_t AQH_IpcdMessageDevices_GetFlags(const GWEN_TAG16_LIST *tagList);
|
||||
|
||||
@@ -132,6 +132,17 @@ uint8_t *AQH_IpcMessage_GetPayloadPointer(const AQH_MESSAGE *msg)
|
||||
|
||||
|
||||
|
||||
void AQH_IpcMessage_DumpToBuffer(const AQH_MESSAGE *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
GWEN_Buffer_AppendArgs(dbuf, "IPC message %s (code=%d, protocol=%d, protocol version=%d)\n",
|
||||
sText?sText:"",
|
||||
AQH_IpcMessage_GetCode(msg),
|
||||
AQH_IpcMessage_GetProtoId(msg),
|
||||
AQH_IpcMessage_GetProtoVersion(msg));
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char *AQH_IpcMessage_MsgTypeToChar(uint16_t i)
|
||||
{
|
||||
switch(i) {
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include <aqhome/api.h>
|
||||
#include <aqhome/ipc2/message.h>
|
||||
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
|
||||
#define AQH_IPCMSG_OFFS_SIZE 0 /* 4 bytes: number of all bytes including size, protoid, protover and code */
|
||||
#define AQH_IPCMSG_OFFS_PROTOID 4 /* 1 byte: protocol id (free to use) */
|
||||
@@ -75,6 +77,8 @@ AQHOME_API uint32_t AQH_IpcMessage_GetRefMsgId(const AQH_MESSAGE *msg);
|
||||
AQHOME_API uint32_t AQH_IpcMessage_GetPayloadLength(const AQH_MESSAGE *msg);
|
||||
AQHOME_API uint8_t *AQH_IpcMessage_GetPayloadPointer(const AQH_MESSAGE *msg);
|
||||
|
||||
AQHOME_API void AQH_IpcMessage_DumpToBuffer(const AQH_MESSAGE *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
|
||||
AQHOME_API const char *AQH_IpcMessage_MsgTypeToChar(uint16_t i);
|
||||
|
||||
|
||||
@@ -49,6 +49,20 @@
|
||||
#define AQH_IPCDATA_DEVICE_TAGS_MANUFACTURER 0x0a
|
||||
#define AQH_IPCDATA_DEVICE_TAGS_TIMEOFCREATION 0x0b
|
||||
|
||||
#define AQH_IPCDATA_NODE_TAGS_BUSADDR 0x01 /* uint8_t */
|
||||
#define AQH_IPCDATA_NODE_TAGS_UID 0x02 /* uint32_t */
|
||||
#define AQH_IPCDATA_NODE_TAGS_MANUFACTURER 0x03 /* uint32_t */
|
||||
#define AQH_IPCDATA_NODE_TAGS_DEVICETYPE 0x04 /* uint16_t */
|
||||
#define AQH_IPCDATA_NODE_TAGS_DEVICEVERSION 0x05 /* uint16_t */
|
||||
#define AQH_IPCDATA_NODE_TAGS_FIRMWAREVERSION 0x06 /* uint32_t */
|
||||
#define AQH_IPCDATA_NODE_TAGS_LASTCHANGE 0x07 /* uint64_t */
|
||||
#define AQH_IPCDATA_NODE_TAGS_STATSPACKETSOUT 0x08 /* uint16_t */
|
||||
#define AQH_IPCDATA_NODE_TAGS_STATSPACKETSIN 0x09 /* uint16_t */
|
||||
#define AQH_IPCDATA_NODE_TAGS_STATSCOLLISIONS 0x0a /* uint16_t */
|
||||
#define AQH_IPCDATA_NODE_TAGS_STATSBUSY 0x0b /* uint16_t */
|
||||
#define AQH_IPCDATA_NODE_TAGS_STATSCRCERRORS 0x0c /* uint16_t */
|
||||
#define AQH_IPCDATA_NODE_TAGS_STATSIOERRORS 0x0d /* uint16_t */
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
@@ -60,6 +74,8 @@ static void _writeValueFieldsAsTagsToBuffer(const AQH_VALUE *value, GWEN_BUFFER
|
||||
static AQH_VALUE *_readValueFromTag(const uint8_t *ptr, uint32_t len);
|
||||
static void _writeDeviceFieldsAsTagsToBuffer(const AQH_DEVICE *device, GWEN_BUFFER *buf);
|
||||
static AQH_DEVICE *_readDeviceFromTag(const uint8_t *ptr, uint32_t len);
|
||||
static void _writeNodeInfoFieldsAsTagsToBuffer(const AQH_NODE_INFO *ni, GWEN_BUFFER *buf);
|
||||
static AQH_NODE_INFO *_readNodeInfoFromTag(const uint8_t *ptr, uint32_t len);
|
||||
|
||||
|
||||
|
||||
@@ -578,5 +594,201 @@ AQH_DEVICE *_readDeviceFromTag(const uint8_t *ptr, uint32_t len)
|
||||
|
||||
|
||||
|
||||
int AQH_Tag16_WriteNodeInfoListAsTagsToBuffer(unsigned int tagType, const AQH_NODE_INFO_LIST *nodeInfoList, GWEN_BUFFER *buf)
|
||||
{
|
||||
if (nodeInfoList) {
|
||||
const AQH_NODE_INFO *nodeInfo;
|
||||
|
||||
nodeInfo=AQH_NodeInfo_List_First(nodeInfoList);
|
||||
while(nodeInfo) {
|
||||
int rv;
|
||||
|
||||
rv=AQH_Tag16_WriteNodeInfoAsTagToBuffer(tagType, nodeInfo, buf);
|
||||
if (rv<0) {
|
||||
DBG_INFO(AQH_LOGDOMAIN, "here (%d)", rv);
|
||||
GWEN_Buffer_free(buf);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nodeInfo=AQH_NodeInfo_List_Next(nodeInfo);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int AQH_Tag16_WriteNodeInfoAsTagToBuffer(unsigned int tagType, const AQH_NODE_INFO *ni, GWEN_BUFFER *buf)
|
||||
{
|
||||
int startPos;
|
||||
int rv;
|
||||
|
||||
startPos=GWEN_Tag16_StartTagInBuffer(tagType, buf);
|
||||
if (startPos<0) {
|
||||
DBG_INFO(AQH_LOGDOMAIN, "here (%d)", startPos);
|
||||
return startPos;
|
||||
}
|
||||
|
||||
_writeNodeInfoFieldsAsTagsToBuffer(ni, buf);
|
||||
|
||||
rv=GWEN_Tag16_EndTagInBuffer(startPos, buf);
|
||||
if (rv<0) {
|
||||
DBG_INFO(AQH_LOGDOMAIN, "here (%d)", rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void _writeNodeInfoFieldsAsTagsToBuffer(const AQH_NODE_INFO *ni, GWEN_BUFFER *buf)
|
||||
{
|
||||
const GWEN_TIMESTAMP *t;
|
||||
|
||||
GWEN_Tag16_WriteUint8TagToBuffer(AQH_IPCDATA_NODE_TAGS_BUSADDR, AQH_NodeInfo_GetBusAddress(ni), buf);
|
||||
GWEN_Tag16_WriteUint32TagToBuffer(AQH_IPCDATA_NODE_TAGS_UID, AQH_NodeInfo_GetUid(ni), buf);
|
||||
GWEN_Tag16_WriteUint32TagToBuffer(AQH_IPCDATA_NODE_TAGS_MANUFACTURER, AQH_NodeInfo_GetManufacturer(ni), buf);
|
||||
GWEN_Tag16_WriteUint16TagToBuffer(AQH_IPCDATA_NODE_TAGS_DEVICETYPE, AQH_NodeInfo_GetDeviceType(ni), buf);
|
||||
GWEN_Tag16_WriteUint16TagToBuffer(AQH_IPCDATA_NODE_TAGS_DEVICEVERSION, AQH_NodeInfo_GetDeviceVersion(ni), buf);
|
||||
GWEN_Tag16_WriteUint32TagToBuffer(AQH_IPCDATA_NODE_TAGS_FIRMWAREVERSION, AQH_NodeInfo_GetFirmwareVersion(ni), buf);
|
||||
t=AQH_NodeInfo_GetTimestampLastChange(ni);
|
||||
GWEN_Tag16_WriteUint64TagToBuffer(AQH_IPCDATA_NODE_TAGS_LASTCHANGE, t?((uint64_t)GWEN_Timestamp_toInt64(t)):0L, buf);
|
||||
|
||||
GWEN_Tag16_WriteUint16TagToBuffer(AQH_IPCDATA_NODE_TAGS_STATSPACKETSOUT, AQH_NodeInfo_GetStatsPacketsOut(ni), buf);
|
||||
GWEN_Tag16_WriteUint16TagToBuffer(AQH_IPCDATA_NODE_TAGS_STATSPACKETSIN, AQH_NodeInfo_GetStatsPacketsIn(ni), buf);
|
||||
GWEN_Tag16_WriteUint16TagToBuffer(AQH_IPCDATA_NODE_TAGS_STATSCOLLISIONS, AQH_NodeInfo_GetStatsCollisions(ni), buf);
|
||||
GWEN_Tag16_WriteUint16TagToBuffer(AQH_IPCDATA_NODE_TAGS_STATSBUSY, AQH_NodeInfo_GetStatsBusy(ni), buf);
|
||||
GWEN_Tag16_WriteUint16TagToBuffer(AQH_IPCDATA_NODE_TAGS_STATSCRCERRORS, AQH_NodeInfo_GetStatsCrcErrors(ni), buf);
|
||||
GWEN_Tag16_WriteUint16TagToBuffer(AQH_IPCDATA_NODE_TAGS_STATSIOERRORS, AQH_NodeInfo_GetStatsIoErrors(ni), buf);
|
||||
}
|
||||
|
||||
|
||||
|
||||
AQH_NODE_INFO_LIST *AQH_Tag16_ReadNodeInfosFromTagList(const GWEN_TAG16_LIST *tagList, unsigned int wantedTagType)
|
||||
{
|
||||
AQH_NODE_INFO_LIST *nodeInfoList;
|
||||
const GWEN_TAG16 *tag;
|
||||
|
||||
nodeInfoList=AQH_NodeInfo_List_new();
|
||||
tag=GWEN_Tag16_List_First(tagList);
|
||||
while(tag) {
|
||||
unsigned int tagType;
|
||||
|
||||
tagType=GWEN_Tag16_GetTagType(tag);
|
||||
if (tagType==wantedTagType) {
|
||||
AQH_NODE_INFO *nodeInfo;
|
||||
|
||||
nodeInfo=_readNodeInfoFromTag((const uint8_t*) GWEN_Tag16_GetTagData(tag), (uint32_t) GWEN_Tag16_GetTagLength(tag));
|
||||
if (nodeInfo)
|
||||
AQH_NodeInfo_List_Add(nodeInfo, nodeInfoList);
|
||||
}
|
||||
|
||||
tag=GWEN_Tag16_List_Next(tag);
|
||||
}
|
||||
|
||||
if (AQH_NodeInfo_List_GetCount(nodeInfoList)<1) {
|
||||
AQH_NodeInfo_List_free(nodeInfoList);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return nodeInfoList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
AQH_NODE_INFO *AQH_Tag16_ReadNodeInfoFromTagList(const GWEN_TAG16_LIST *tagList, unsigned int wantedTagType)
|
||||
{
|
||||
if (tagList) {
|
||||
const GWEN_TAG16 *tag;
|
||||
|
||||
tag=GWEN_Tag16_List_FindFirstByTagType(tagList, wantedTagType);
|
||||
return tag?_readNodeInfoFromTag((const uint8_t*) GWEN_Tag16_GetTagData(tag), (uint32_t) GWEN_Tag16_GetTagLength(tag)):NULL;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
AQH_NODE_INFO *_readNodeInfoFromTag(const uint8_t *ptr, uint32_t len)
|
||||
{
|
||||
GWEN_TAG16_LIST *tagList;
|
||||
|
||||
tagList=GWEN_Tag16_List_fromBuffer(ptr, len, 0);
|
||||
if (tagList) {
|
||||
GWEN_TAG16 *tag;
|
||||
AQH_NODE_INFO *ni;
|
||||
|
||||
ni=AQH_NodeInfo_new();
|
||||
tag=GWEN_Tag16_List_First(tagList);
|
||||
while(tag) {
|
||||
unsigned int tagType;
|
||||
uint64_t u64;
|
||||
|
||||
tagType=GWEN_Tag16_GetTagType(tag);
|
||||
switch(tagType) {
|
||||
case AQH_IPCDATA_NODE_TAGS_BUSADDR:
|
||||
AQH_NodeInfo_SetBusAddress(ni, GWEN_Tag16_GetTagDataAsUint8(tag, 0));
|
||||
break;
|
||||
case AQH_IPCDATA_NODE_TAGS_UID:
|
||||
AQH_NodeInfo_SetUid(ni, GWEN_Tag16_GetTagDataAsUint32(tag, 0));
|
||||
break;
|
||||
case AQH_IPCDATA_NODE_TAGS_MANUFACTURER:
|
||||
AQH_NodeInfo_SetManufacturer(ni, GWEN_Tag16_GetTagDataAsUint32(tag, 0));
|
||||
break;
|
||||
case AQH_IPCDATA_NODE_TAGS_DEVICETYPE:
|
||||
AQH_NodeInfo_SetDeviceType(ni, GWEN_Tag16_GetTagDataAsUint16(tag, 0));
|
||||
break;
|
||||
case AQH_IPCDATA_NODE_TAGS_DEVICEVERSION:
|
||||
AQH_NodeInfo_SetDeviceVersion(ni, GWEN_Tag16_GetTagDataAsUint16(tag, 0));
|
||||
break;
|
||||
case AQH_IPCDATA_NODE_TAGS_FIRMWAREVERSION:
|
||||
AQH_NodeInfo_SetFirmwareVersion(ni, GWEN_Tag16_GetTagDataAsUint32(tag, 0));
|
||||
break;
|
||||
case AQH_IPCDATA_NODE_TAGS_LASTCHANGE:
|
||||
u64=GWEN_Tag16_GetTagDataAsUint64(tag, 0);
|
||||
if (u64>0) {
|
||||
GWEN_TIMESTAMP *t;
|
||||
|
||||
t=GWEN_Timestamp_fromInt64((int64_t) u64);
|
||||
if (t) {
|
||||
AQH_NodeInfo_SetTimestampLastChange(ni, t);
|
||||
GWEN_Timestamp_free(t);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case AQH_IPCDATA_NODE_TAGS_STATSPACKETSOUT:
|
||||
AQH_NodeInfo_SetStatsPacketsOut(ni, GWEN_Tag16_GetTagDataAsUint16(tag, 0));
|
||||
break;
|
||||
case AQH_IPCDATA_NODE_TAGS_STATSPACKETSIN:
|
||||
AQH_NodeInfo_SetStatsPacketsIn(ni, GWEN_Tag16_GetTagDataAsUint16(tag, 0));
|
||||
break;
|
||||
case AQH_IPCDATA_NODE_TAGS_STATSCOLLISIONS:
|
||||
AQH_NodeInfo_SetStatsCollisions(ni, GWEN_Tag16_GetTagDataAsUint16(tag, 0));
|
||||
break;
|
||||
case AQH_IPCDATA_NODE_TAGS_STATSBUSY:
|
||||
AQH_NodeInfo_SetStatsBusy(ni, GWEN_Tag16_GetTagDataAsUint16(tag, 0));
|
||||
break;
|
||||
case AQH_IPCDATA_NODE_TAGS_STATSCRCERRORS:
|
||||
AQH_NodeInfo_SetStatsCrcErrors(ni, GWEN_Tag16_GetTagDataAsUint16(tag, 0));
|
||||
break;
|
||||
case AQH_IPCDATA_NODE_TAGS_STATSIOERRORS:
|
||||
AQH_NodeInfo_SetStatsIoErrors(ni, GWEN_Tag16_GetTagDataAsUint16(tag, 0));
|
||||
break;
|
||||
default:
|
||||
DBG_INFO(AQH_LOGDOMAIN, "Unhandled tag typ %d (%02x)", tagType, tagType);
|
||||
break;
|
||||
}
|
||||
tag=GWEN_Tag16_List_Next(tag);
|
||||
}
|
||||
GWEN_Tag16_List_free(tagList);
|
||||
return ni;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <aqhome/ipc2/message.h>
|
||||
#include <aqhome/data/value.h>
|
||||
#include <aqhome/data/device.h>
|
||||
#include <aqhome/nodes/nodeinfo.h>
|
||||
|
||||
#include <gwenhywfar/tag16.h>
|
||||
|
||||
@@ -38,6 +39,12 @@ AQHOME_API int AQH_Tag16_WriteDeviceAsTagToBuffer(unsigned int tagType, const AQ
|
||||
AQHOME_API AQH_DEVICE_LIST *AQH_Tag16_ReadDevicesFromTagList(const GWEN_TAG16_LIST *tagList, unsigned int wantedTagType);
|
||||
AQHOME_API AQH_DEVICE *AQH_Tag16_ReadDeviceFromTagList(const GWEN_TAG16_LIST *tagList, unsigned int wantedTagType);
|
||||
|
||||
AQHOME_API int AQH_Tag16_WriteNodeInfoListAsTagsToBuffer(unsigned int tagType, const AQH_NODE_INFO_LIST *nodeInfoList, GWEN_BUFFER *buf);
|
||||
AQHOME_API int AQH_Tag16_WriteNodeInfoAsTagToBuffer(unsigned int tagType, const AQH_NODE_INFO *ni, GWEN_BUFFER *buf);
|
||||
|
||||
AQHOME_API AQH_NODE_INFO_LIST *AQH_Tag16_ReadNodeInfosFromTagList(const GWEN_TAG16_LIST *tagList, unsigned int wantedTagType);
|
||||
AQHOME_API AQH_NODE_INFO *AQH_Tag16_ReadNodeInfoFromTagList(const GWEN_TAG16_LIST *tagList, unsigned int wantedTagType);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
84
aqhome/msg/ipc/nodes/0BUILD
Normal file
84
aqhome/msg/ipc/nodes/0BUILD
Normal 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>
|
||||
46
aqhome/msg/ipc/nodes/m_ipcn.c
Normal file
46
aqhome/msg/ipc/nodes/m_ipcn.c
Normal 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)";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
43
aqhome/msg/ipc/nodes/m_ipcn.h
Normal file
43
aqhome/msg/ipc/nodes/m_ipcn.h
Normal 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
|
||||
|
||||
|
||||
|
||||
80
aqhome/msg/ipc/nodes/m_ipcn_forward.c
Normal file
80
aqhome/msg/ipc/nodes/m_ipcn_forward.c
Normal 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');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
37
aqhome/msg/ipc/nodes/m_ipcn_forward.h
Normal file
37
aqhome/msg/ipc/nodes/m_ipcn_forward.h
Normal 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
|
||||
57
aqhome/msg/ipc/nodes/m_ipcn_getdevices_req.c
Normal file
57
aqhome/msg/ipc/nodes/m_ipcn_getdevices_req.c
Normal 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));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
30
aqhome/msg/ipc/nodes/m_ipcn_getdevices_req.h
Normal file
30
aqhome/msg/ipc/nodes/m_ipcn_getdevices_req.h
Normal 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
|
||||
100
aqhome/msg/ipc/nodes/m_ipcn_getdevices_rsp.c
Normal file
100
aqhome/msg/ipc/nodes/m_ipcn_getdevices_rsp.c
Normal 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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
40
aqhome/msg/ipc/nodes/m_ipcn_getdevices_rsp.h
Normal file
40
aqhome/msg/ipc/nodes/m_ipcn_getdevices_rsp.h
Normal 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
|
||||
Reference in New Issue
Block a user