Prepared introduction of multiple ipc protocols.
This commit is contained in:
93
aqhome/ipc/nodes/0BUILD
Normal file
93
aqhome/ipc/nodes/0BUILD
Normal file
@@ -0,0 +1,93 @@
|
||||
<?xml?>
|
||||
|
||||
<gwbuild>
|
||||
|
||||
<target type="ConvenienceLibrary" name="aqhipcnodes" >
|
||||
|
||||
<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)/ipc" >
|
||||
$(local/built_headers_pub)
|
||||
</headers>
|
||||
|
||||
|
||||
<headers dist="true" install="$(pkgincludedir)/ipc" >
|
||||
ipc_nodes.h
|
||||
msg_ipc_forward.h
|
||||
msg_ipc_value.h
|
||||
msg_ipc_ping.h
|
||||
msg_ipc_error.h
|
||||
msg_ipc_setaccmsggrps.h
|
||||
msg_ipc_getdevices_req.h
|
||||
msg_ipc_getdevices_rsp.h
|
||||
</headers>
|
||||
|
||||
|
||||
<headers dist="true" >
|
||||
endpoint_ipc_p.h
|
||||
</headers>
|
||||
|
||||
|
||||
<sources>
|
||||
$(local/typefiles)
|
||||
|
||||
ipc_nodes.c
|
||||
msg_ipc_forward.c
|
||||
msg_ipc_value.c
|
||||
msg_ipc_ping.c
|
||||
msg_ipc_error.c
|
||||
msg_ipc_setaccmsggrps.c
|
||||
msg_ipc_getdevices_req.c
|
||||
msg_ipc_getdevices_rsp.c
|
||||
</sources>
|
||||
|
||||
|
||||
<extradist>
|
||||
</extradist>
|
||||
|
||||
|
||||
<useTargets>
|
||||
</useTargets>
|
||||
|
||||
<subdirs>
|
||||
</subdirs>
|
||||
|
||||
|
||||
|
||||
|
||||
</target>
|
||||
|
||||
</gwbuild>
|
||||
16
aqhome/ipc/nodes/ipc_nodes.c
Normal file
16
aqhome/ipc/nodes/ipc_nodes.c
Normal file
@@ -0,0 +1,16 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 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/ipc/nodes/ipc_nodes.h>
|
||||
|
||||
|
||||
37
aqhome/ipc/nodes/ipc_nodes.h
Normal file
37
aqhome/ipc/nodes/ipc_nodes.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 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_H
|
||||
#define AQH_MSG_IPC_NODES_H
|
||||
|
||||
|
||||
#include <aqhome/api.h>
|
||||
|
||||
#include <gwenhywfar/msg_ipc.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
|
||||
#define AQH_IPC_PROTOCOL_NODES_ID 1
|
||||
#define AQH_IPC_PROTOCOL_NODES_VERSION 1
|
||||
|
||||
|
||||
#define AQH_MSGTYPE_IPC_NODES_FORWARD 0x100
|
||||
#define AQH_MSGTYPE_IPC_NODES_VALUE 0x200
|
||||
#define AQH_MSGTYPE_IPC_NODES_PING 0x300
|
||||
#define AQH_MSGTYPE_IPC_NODES_SETACCMSGGRPS 0x400
|
||||
#define AQH_MSGTYPE_IPC_NODES_GETDEVICES_REQ 0x500
|
||||
#define AQH_MSGTYPE_IPC_NODES_GETDEVICES_RSP 0x600
|
||||
#define AQH_MSGTYPE_IPC_NODES_ERROR 0x700
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
74
aqhome/ipc/nodes/msg_ipc_error.c
Normal file
74
aqhome/ipc/nodes/msg_ipc_error.c
Normal file
@@ -0,0 +1,74 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 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/ipc/nodes/msg_ipc_error.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
#include <gwenhywfar/misc.h>
|
||||
#include <gwenhywfar/list.h>
|
||||
#include <gwenhywfar/error.h>
|
||||
#include <gwenhywfar/debug.h>
|
||||
#include <gwenhywfar/text.h>
|
||||
#include <gwenhywfar/msg_ipc.h>
|
||||
|
||||
|
||||
#define AQH_MSGIPC_ERROR_OFFS_ERRORCODE 0 /* 2 bytes */
|
||||
|
||||
#define AQH_MSGIPC_ERROR_MINSIZE (GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_ERROR_OFFS_ERRORCODE+2)
|
||||
|
||||
|
||||
|
||||
|
||||
GWEN_MSG *AQH_ErrorIpcMsg_new(uint16_t code, uint16_t errorCode)
|
||||
{
|
||||
GWEN_MSG *msg;
|
||||
uint8_t *ptr;
|
||||
|
||||
msg=GWEN_IpcMsg_new(AQH_IPC_PROTOCOL_NODES_ID, AQH_IPC_PROTOCOL_NODES_VERSION, code, AQH_MSGIPC_ERROR_MINSIZE, NULL);
|
||||
ptr=GWEN_Msg_GetBuffer(msg);
|
||||
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_ERROR_OFFS_ERRORCODE+0]=errorCode & 0xff;
|
||||
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_ERROR_OFFS_ERRORCODE+1]=errorCode & 0xff;
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_ErrorIpcMsg_GetErrorCode(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint16At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_ERROR_OFFS_ERRORCODE, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void AQH_ErrorIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSGIPC_ERROR_MINSIZE) {
|
||||
GWEN_Buffer_AppendArgs(dbuf,
|
||||
"ERROR (code=%d, proto=%d, proto version=%d, error=%d)\n",
|
||||
GWEN_IpcMsg_GetCode(msg),
|
||||
GWEN_IpcMsg_GetProtoId(msg),
|
||||
GWEN_IpcMsg_GetProtoVersion(msg),
|
||||
AQH_ErrorIpcMsg_GetErrorCode(msg));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
33
aqhome/ipc/nodes/msg_ipc_error.h
Normal file
33
aqhome/ipc/nodes/msg_ipc_error.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 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_ERROR_H
|
||||
#define AQH_MSG_IPC_ERROR_H
|
||||
|
||||
|
||||
#include <aqhome/api.h>
|
||||
#include <aqhome/ipc/nodes/ipc_nodes.h>
|
||||
#include <aqhome/msg/msg_node.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
|
||||
#define AQH_MSG_IPC_ERROR_OK 0
|
||||
#define AQH_MSG_IPC_ERROR_NODATA 1
|
||||
|
||||
|
||||
AQHOME_API GWEN_MSG *AQH_ErrorIpcMsg_new(uint16_t code, uint16_t errorCode);
|
||||
AQHOME_API uint16_t AQH_ErrorIpcMsg_GetErrorCode(const GWEN_MSG *msg);
|
||||
AQHOME_API void AQH_ErrorIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
93
aqhome/ipc/nodes/msg_ipc_forward.c
Normal file
93
aqhome/ipc/nodes/msg_ipc_forward.c
Normal file
@@ -0,0 +1,93 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 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/ipc/nodes/msg_ipc_forward.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
#include <gwenhywfar/misc.h>
|
||||
#include <gwenhywfar/list.h>
|
||||
#include <gwenhywfar/error.h>
|
||||
#include <gwenhywfar/debug.h>
|
||||
#include <gwenhywfar/text.h>
|
||||
#include <gwenhywfar/msg_ipc.h>
|
||||
|
||||
|
||||
|
||||
#define AQH_MSG_OFFS_FORWARD_MSG (GWEN_MSGIPC_OFFS_PAYLOAD+0)
|
||||
|
||||
#define AQH_MSG_FORWARD_MINSIZE (AQH_MSG_OFFS_FORWARD_MSG+AQH_MSG_OFFS_ALL_DATA_BEGIN)
|
||||
|
||||
|
||||
|
||||
GWEN_MSG *AQH_ForwardIpcMsg_new(uint16_t code, const uint8_t *ptr, uint32_t len)
|
||||
{
|
||||
return GWEN_IpcMsg_new(AQH_IPC_PROTOCOL_NODES_ID, AQH_IPC_PROTOCOL_NODES_VERSION, code, len, ptr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
const uint8_t *AQH_ForwardIpcMsg_GetMsgPtr(const GWEN_MSG *msg)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_FORWARD_MINSIZE)
|
||||
return GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_FORWARD_MSG;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint32_t AQH_ForwardIpcMsg_GetMsgLen(const GWEN_MSG *msg)
|
||||
{
|
||||
uint32_t len;
|
||||
|
||||
len=GWEN_Msg_GetBytesInBuffer(msg);
|
||||
if (len>AQH_MSG_FORWARD_MINSIZE) {
|
||||
return len-AQH_MSG_OFFS_FORWARD_MSG;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
GWEN_MSG *AQH_ForwardIpcMsg_GetCopyOfNodeMsg(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_fromBytes(AQH_ForwardIpcMsg_GetMsgPtr(msg), AQH_ForwardIpcMsg_GetMsgLen(msg));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_ForwardIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_FORWARD_MINSIZE) {
|
||||
const uint8_t *ptr;
|
||||
uint32_t len;
|
||||
|
||||
ptr=AQH_ForwardIpcMsg_GetMsgPtr(msg);
|
||||
len=AQH_ForwardIpcMsg_GetMsgLen(msg);
|
||||
|
||||
GWEN_Buffer_AppendArgs(dbuf, "FORWARD (code=%d, protocol=%d, protocol version=%d)\n",
|
||||
GWEN_IpcMsg_GetCode(msg),
|
||||
GWEN_IpcMsg_GetProtoId(msg),
|
||||
GWEN_IpcMsg_GetProtoVersion(msg));
|
||||
if (ptr && len) {
|
||||
GWEN_Text_DumpString2Buffer((const char*)ptr, len, dbuf, 2);
|
||||
GWEN_Buffer_AppendByte(dbuf, '\n');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
32
aqhome/ipc/nodes/msg_ipc_forward.h
Normal file
32
aqhome/ipc/nodes/msg_ipc_forward.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 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_FORWARD_H
|
||||
#define AQH_MSG_IPC_FORWARD_H
|
||||
|
||||
|
||||
#include <aqhome/api.h>
|
||||
#include <aqhome/ipc/nodes/ipc_nodes.h>
|
||||
#include <aqhome/msg/msg_node.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
|
||||
|
||||
AQHOME_API GWEN_MSG *AQH_ForwardIpcMsg_new(uint16_t code, const uint8_t *ptr, uint32_t len);
|
||||
AQHOME_API const uint8_t *AQH_ForwardIpcMsg_GetMsgPtr(const GWEN_MSG *msg);
|
||||
AQHOME_API uint32_t AQH_ForwardIpcMsg_GetMsgLen(const GWEN_MSG *msg);
|
||||
AQHOME_API GWEN_MSG *AQH_ForwardIpcMsg_GetCopyOfNodeMsg(const GWEN_MSG *msg);
|
||||
AQHOME_API void AQH_ForwardIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
52
aqhome/ipc/nodes/msg_ipc_getdevices_req.c
Normal file
52
aqhome/ipc/nodes/msg_ipc_getdevices_req.c
Normal file
@@ -0,0 +1,52 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 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/ipc/nodes/msg_ipc_getdevices_req.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
#include <gwenhywfar/misc.h>
|
||||
#include <gwenhywfar/list.h>
|
||||
#include <gwenhywfar/error.h>
|
||||
#include <gwenhywfar/debug.h>
|
||||
#include <gwenhywfar/text.h>
|
||||
#include <gwenhywfar/msg_ipc.h>
|
||||
|
||||
|
||||
#define AQH_MSGIPC_GETDEVICES_REQ_MINSIZE (GWEN_MSGIPC_OFFS_PAYLOAD)
|
||||
|
||||
|
||||
|
||||
|
||||
GWEN_MSG *AQH_GetDevicesRequestIpcMsg_new(uint16_t code)
|
||||
{
|
||||
return GWEN_IpcMsg_new(AQH_IPC_PROTOCOL_NODES_ID, AQH_IPC_PROTOCOL_NODES_VERSION, code, AQH_MSGIPC_GETDEVICES_REQ_MINSIZE, NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_GetDevicesRequestIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSGIPC_GETDEVICES_REQ_MINSIZE) {
|
||||
GWEN_Buffer_AppendArgs(dbuf,
|
||||
"GET_DEVICES REQ (code=%d, proto=%d, proto version=%d)\n",
|
||||
GWEN_IpcMsg_GetCode(msg),
|
||||
GWEN_IpcMsg_GetProtoId(msg),
|
||||
GWEN_IpcMsg_GetProtoVersion(msg));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
27
aqhome/ipc/nodes/msg_ipc_getdevices_req.h
Normal file
27
aqhome/ipc/nodes/msg_ipc_getdevices_req.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 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_MSGIPC_GETDEVICES_REQ_H
|
||||
#define AQH_MSGIPC_GETDEVICES_REQ_H
|
||||
|
||||
|
||||
#include <aqhome/api.h>
|
||||
#include <aqhome/ipc/nodes/ipc_nodes.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
|
||||
AQHOME_API GWEN_MSG *AQH_GetDevicesRequestIpcMsg_new(uint16_t code);
|
||||
|
||||
AQHOME_API void AQH_GetDevicesRequestIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
234
aqhome/ipc/nodes/msg_ipc_getdevices_rsp.c
Normal file
234
aqhome/ipc/nodes/msg_ipc_getdevices_rsp.c
Normal file
@@ -0,0 +1,234 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 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/ipc/nodes/msg_ipc_getdevices_rsp.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
#include <gwenhywfar/misc.h>
|
||||
#include <gwenhywfar/list.h>
|
||||
#include <gwenhywfar/error.h>
|
||||
#include <gwenhywfar/debug.h>
|
||||
#include <gwenhywfar/text.h>
|
||||
#include <gwenhywfar/msg_ipc.h>
|
||||
|
||||
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_FLAGS 0 /* 1 bytes */
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_BUSADDR 1 /* 1 bytes */
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_UID 2 /* 4 bytes */
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_FWTYPE 6 /* 2 bytes */
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_FWVER 8 /* 2 bytes */
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_MODULES 10 /* 2 bytes */
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_LASTCHG 12 /* 8 bytes */
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_PKGOUT 20 /* 2 bytes */
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_PKGIN 22 /* 2 bytes */
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_COLLISIONS 24 /* 2 bytes */
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_BUSY 26 /* 2 bytes */
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_CRC 28 /* 2 bytes */
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_IO 30 /* 2 bytes */
|
||||
|
||||
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_MINSIZE (GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_GETDEVICES_RSP_OFFS_LASTCHG+8)
|
||||
|
||||
|
||||
|
||||
|
||||
GWEN_MSG *AQH_GetDevicesResponseIpcMsg_new(uint16_t code, uint8_t flags, const AQH_NODE_INFO *ni)
|
||||
{
|
||||
GWEN_MSG *msg;
|
||||
uint8_t *ptr;
|
||||
uint32_t u32;
|
||||
uint64_t u64=0;
|
||||
const GWEN_TIMESTAMP *t;
|
||||
|
||||
msg=GWEN_IpcMsg_new(AQH_IPC_PROTOCOL_NODES_ID, AQH_IPC_PROTOCOL_NODES_VERSION, code, AQH_MSGIPC_GETDEVICES_RSP_MINSIZE, NULL);
|
||||
ptr=GWEN_Msg_GetBuffer(msg)+GWEN_MSGIPC_OFFS_PAYLOAD;
|
||||
|
||||
*(ptr++)=flags & 0xff;
|
||||
|
||||
*(ptr++)=AQH_NodeInfo_GetBusAddress(ni);
|
||||
|
||||
u32=AQH_NodeInfo_GetUid(ni);
|
||||
*(ptr++)=u32 & 0xff;
|
||||
*(ptr++)=(u32>>8) & 0xff;
|
||||
*(ptr++)=(u32>>16) & 0xff;
|
||||
*(ptr++)=(u32>>24) & 0xff;
|
||||
|
||||
u32=AQH_NodeInfo_GetFirmwareType(ni);
|
||||
*(ptr++)=u32 & 0xff;
|
||||
*(ptr++)=(u32>>8) & 0xff;
|
||||
|
||||
u32=AQH_NodeInfo_GetFirmwareVersion(ni);
|
||||
*(ptr++)=u32 & 0xff;
|
||||
*(ptr++)=(u32>>8) & 0xff;
|
||||
|
||||
u32=AQH_NodeInfo_GetModules(ni);
|
||||
*(ptr++)=u32 & 0xff;
|
||||
*(ptr++)=(u32>>8) & 0xff;
|
||||
|
||||
t=AQH_NodeInfo_GetTimestampLastChange(ni);
|
||||
if (t)
|
||||
u64=(uint64_t)GWEN_Timestamp_toInt64(t);
|
||||
*(ptr++)=u64 & 0xff;
|
||||
*(ptr++)=(u64>>8) & 0xff;
|
||||
*(ptr++)=(u64>>16) & 0xff;
|
||||
*(ptr++)=(u64>>24) & 0xff;
|
||||
*(ptr++)=(u64>>32) & 0xff;
|
||||
*(ptr++)=(u64>>40) & 0xff;
|
||||
*(ptr++)=(u64>>48) & 0xff;
|
||||
*(ptr++)=(u64>>56) & 0xff;
|
||||
|
||||
u32=AQH_NodeInfo_GetStatsPacketsOut(ni);
|
||||
*(ptr++)=u32 & 0xff;
|
||||
*(ptr++)=(u32>>8) & 0xff;
|
||||
|
||||
u32=AQH_NodeInfo_GetStatsPacketsIn(ni);
|
||||
*(ptr++)=u32 & 0xff;
|
||||
*(ptr++)=(u32>>8) & 0xff;
|
||||
|
||||
u32=AQH_NodeInfo_GetStatsCollisions(ni);
|
||||
*(ptr++)=u32 & 0xff;
|
||||
*(ptr++)=(u32>>8) & 0xff;
|
||||
|
||||
u32=AQH_NodeInfo_GetStatsBusy(ni);
|
||||
*(ptr++)=u32 & 0xff;
|
||||
*(ptr++)=(u32>>8) & 0xff;
|
||||
|
||||
u32=AQH_NodeInfo_GetStatsCrcErrors(ni);
|
||||
*(ptr++)=u32 & 0xff;
|
||||
*(ptr++)=(u32>>8) & 0xff;
|
||||
|
||||
u32=AQH_NodeInfo_GetStatsIoErrors(ni);
|
||||
*(ptr++)=u32 & 0xff;
|
||||
*(ptr++)=(u32>>8) & 0xff;
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_GetDevicesResponseIpcMsg_GetFlags(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint8At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_GETDEVICES_RSP_OFFS_FLAGS, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_GetDevicesResponseIpcMsg_GetBusAddress(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint16At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_GETDEVICES_RSP_OFFS_BUSADDR, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint32_t AQH_GetDevicesResponseIpcMsg_GetUid(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint32At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_GETDEVICES_RSP_OFFS_UID, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_GetDevicesResponseIpcMsg_GetFirmwareType(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint16At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_GETDEVICES_RSP_OFFS_FWTYPE, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_GetDevicesResponseIpcMsg_GetFirmwareVersion(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint16At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_GETDEVICES_RSP_OFFS_FWVER, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_GetDevicesResponseIpcMsg_GetModules(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint16At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_GETDEVICES_RSP_OFFS_MODULES, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int64_t AQH_GetDevicesResponseIpcMsg_GetTimestamp(const GWEN_MSG *msg)
|
||||
{
|
||||
uint64_t v;
|
||||
|
||||
v=(uint64_t) GWEN_Msg_GetUint32At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_GETDEVICES_RSP_OFFS_LASTCHG, 0);
|
||||
v|=((uint64_t)GWEN_Msg_GetUint32At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_GETDEVICES_RSP_OFFS_LASTCHG+4, 0))<<32;
|
||||
return (int64_t) v;
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_GetDevicesResponseIpcMsg_GetPkgOut(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint16At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_GETDEVICES_RSP_OFFS_PKGOUT, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_GetDevicesResponseIpcMsg_GetPkgIn(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint16At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_GETDEVICES_RSP_OFFS_PKGIN, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_GetDevicesResponseIpcMsg_GetCollisions(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint16At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_GETDEVICES_RSP_OFFS_COLLISIONS, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_GetDevicesResponseIpcMsg_GetBusy(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint16At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_GETDEVICES_RSP_OFFS_BUSY, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_GetDevicesResponseIpcMsg_GetCrcErrors(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint16At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_GETDEVICES_RSP_OFFS_CRC, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_GetDevicesResponseIpcMsg_GetIoErrors(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint16At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_GETDEVICES_RSP_OFFS_IO, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_GetDevicesResponseIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSGIPC_GETDEVICES_RSP_MINSIZE) {
|
||||
GWEN_Buffer_AppendArgs(dbuf,
|
||||
"GET_DEVICES_RSP (code=%d, proto=%d, proto version=%d, uid=0x%08x, bus addr=0x%02x, flags=0x%02x)\n",
|
||||
GWEN_IpcMsg_GetCode(msg),
|
||||
GWEN_IpcMsg_GetProtoId(msg),
|
||||
GWEN_IpcMsg_GetProtoVersion(msg),
|
||||
(unsigned int) AQH_GetDevicesResponseIpcMsg_GetUid(msg),
|
||||
AQH_GetDevicesResponseIpcMsg_GetBusAddress(msg),
|
||||
AQH_GetDevicesResponseIpcMsg_GetFlags(msg));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
48
aqhome/ipc/nodes/msg_ipc_getdevices_rsp.h
Normal file
48
aqhome/ipc/nodes/msg_ipc_getdevices_rsp.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 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_MSGIPC_GETDEVICES_RSP_H
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_H
|
||||
|
||||
|
||||
#include <aqhome/api.h>
|
||||
#include <aqhome/ipc/nodes/ipc_nodes.h>
|
||||
#include <aqhome/nodes/nodeinfo.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
|
||||
#define AQH_MSGIPC_GETDEVICES_RSP_FLAGS_LAST 0x01
|
||||
|
||||
|
||||
AQHOME_API GWEN_MSG *AQH_GetDevicesResponseIpcMsg_new(uint16_t code, uint8_t flags, const AQH_NODE_INFO *ni);
|
||||
|
||||
AQHOME_API uint8_t AQH_GetDevicesResponseIpcMsg_GetFlags(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_GetDevicesResponseIpcMsg_GetBusAddress(const GWEN_MSG *msg);
|
||||
|
||||
AQHOME_API uint32_t AQH_GetDevicesResponseIpcMsg_GetUid(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_GetDevicesResponseIpcMsg_GetFirmwareType(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_GetDevicesResponseIpcMsg_GetFirmwareVersion(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_GetDevicesResponseIpcMsg_GetModules(const GWEN_MSG *msg);
|
||||
AQHOME_API int64_t AQH_GetDevicesResponseIpcMsg_GetTimestamp(const GWEN_MSG *msg);
|
||||
|
||||
AQHOME_API uint16_t AQH_GetDevicesResponseIpcMsg_GetPkgOut(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_GetDevicesResponseIpcMsg_GetPkgIn(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_GetDevicesResponseIpcMsg_GetCollisions(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_GetDevicesResponseIpcMsg_GetBusy(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_GetDevicesResponseIpcMsg_GetCrcErrors(const GWEN_MSG *msg);
|
||||
AQHOME_API uint16_t AQH_GetDevicesResponseIpcMsg_GetIoErrors(const GWEN_MSG *msg);
|
||||
|
||||
|
||||
AQHOME_API void AQH_GetDevicesResponseIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
69
aqhome/ipc/nodes/msg_ipc_ping.c
Normal file
69
aqhome/ipc/nodes/msg_ipc_ping.c
Normal file
@@ -0,0 +1,69 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 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/ipc/nodes/msg_ipc_ping.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
#include <gwenhywfar/misc.h>
|
||||
#include <gwenhywfar/list.h>
|
||||
#include <gwenhywfar/error.h>
|
||||
#include <gwenhywfar/debug.h>
|
||||
#include <gwenhywfar/text.h>
|
||||
#include <gwenhywfar/msg_ipc.h>
|
||||
|
||||
|
||||
#define AQH_MSGIPC_PING_OFFS_DESTADDR 0 /* 1 bytes */
|
||||
|
||||
#define AQH_MSGIPC_PING_MINSIZE (GWEN_MSGIPC_OFFS_PAYLOAD+1)
|
||||
|
||||
|
||||
|
||||
|
||||
GWEN_MSG *AQH_PingIpcMsg_new(uint16_t code, uint8_t destAddr)
|
||||
{
|
||||
GWEN_MSG *msg;
|
||||
uint8_t *ptr;
|
||||
|
||||
msg=GWEN_IpcMsg_new(AQH_IPC_PROTOCOL_NODES_ID, AQH_IPC_PROTOCOL_NODES_VERSION, code, AQH_MSGIPC_PING_MINSIZE, NULL);
|
||||
ptr=GWEN_Msg_GetBuffer(msg);
|
||||
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_PING_OFFS_DESTADDR]=destAddr & 0xff;
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_PingIpcMsg_GetDestAddr(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint8At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_PING_OFFS_DESTADDR, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_PingIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSGIPC_PING_MINSIZE) {
|
||||
GWEN_Buffer_AppendArgs(dbuf,
|
||||
"PING (code=%d, proto=%d, proto version=%d, dest addr=%02x)\n",
|
||||
GWEN_IpcMsg_GetCode(msg),
|
||||
GWEN_IpcMsg_GetProtoId(msg),
|
||||
GWEN_IpcMsg_GetProtoVersion(msg),
|
||||
AQH_PingIpcMsg_GetDestAddr(msg));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
29
aqhome/ipc/nodes/msg_ipc_ping.h
Normal file
29
aqhome/ipc/nodes/msg_ipc_ping.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 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_PING_H
|
||||
#define AQH_MSG_IPC_PING_H
|
||||
|
||||
|
||||
#include <aqhome/api.h>
|
||||
#include <aqhome/ipc/nodes/ipc_nodes.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
|
||||
AQHOME_API GWEN_MSG *AQH_PingIpcMsg_new(uint16_t code, uint8_t destAddr);
|
||||
|
||||
AQHOME_API uint8_t AQH_PingIpcMsg_GetDestAddr(const GWEN_MSG *msg);
|
||||
|
||||
AQHOME_API void AQH_PingIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
72
aqhome/ipc/nodes/msg_ipc_setaccmsggrps.c
Normal file
72
aqhome/ipc/nodes/msg_ipc_setaccmsggrps.c
Normal file
@@ -0,0 +1,72 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 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/ipc/nodes/msg_ipc_setaccmsggrps.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
#include <gwenhywfar/misc.h>
|
||||
#include <gwenhywfar/list.h>
|
||||
#include <gwenhywfar/error.h>
|
||||
#include <gwenhywfar/debug.h>
|
||||
#include <gwenhywfar/text.h>
|
||||
#include <gwenhywfar/msg_ipc.h>
|
||||
|
||||
|
||||
#define AQH_MSGIPC_SETACCEPTEDMSGGRPS_OFFS_GROUPS 0 /* 4 bytes */
|
||||
|
||||
#define AQH_MSGIPC_SETACCEPTEDMSGGRPS_MINSIZE (GWEN_MSGIPC_OFFS_PAYLOAD+4)
|
||||
|
||||
|
||||
|
||||
|
||||
GWEN_MSG *AQH_SetAcceptedMsgGroupsIpcMsg_new(uint16_t code, uint32_t groups)
|
||||
{
|
||||
GWEN_MSG *msg;
|
||||
uint8_t *ptr;
|
||||
|
||||
msg=GWEN_IpcMsg_new(AQH_IPC_PROTOCOL_NODES_ID, AQH_IPC_PROTOCOL_NODES_VERSION, code, AQH_MSGIPC_SETACCEPTEDMSGGRPS_MINSIZE, NULL);
|
||||
ptr=GWEN_Msg_GetBuffer(msg);
|
||||
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_SETACCEPTEDMSGGRPS_OFFS_GROUPS+0]=groups & 0xff;
|
||||
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_SETACCEPTEDMSGGRPS_OFFS_GROUPS+1]=(groups>>8) & 0xff;
|
||||
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_SETACCEPTEDMSGGRPS_OFFS_GROUPS+2]=(groups>>16) & 0xff;
|
||||
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_SETACCEPTEDMSGGRPS_OFFS_GROUPS+3]=(groups>>24) & 0xff;
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint32_t AQH_SetAcceptedMsgGroupsIpcMsg_GetMsgGroups(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint32At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_SETACCEPTEDMSGGRPS_OFFS_GROUPS, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_SetAcceptedMsgGroupsIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSGIPC_SETACCEPTEDMSGGRPS_MINSIZE) {
|
||||
GWEN_Buffer_AppendArgs(dbuf,
|
||||
"SET_ACCEPTED_MSG_GROUPS (code=%d, proto=%d, proto version=%d, groups=%08x)\n",
|
||||
GWEN_IpcMsg_GetCode(msg),
|
||||
GWEN_IpcMsg_GetProtoId(msg),
|
||||
GWEN_IpcMsg_GetProtoVersion(msg),
|
||||
AQH_SetAcceptedMsgGroupsIpcMsg_GetMsgGroups(msg));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
29
aqhome/ipc/nodes/msg_ipc_setaccmsggrps.h
Normal file
29
aqhome/ipc/nodes/msg_ipc_setaccmsggrps.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 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_MSGIPC_SETACCEPTEDMSGGRPS_H
|
||||
#define AQH_MSGIPC_SETACCEPTEDMSGGRPS_H
|
||||
|
||||
|
||||
#include <aqhome/api.h>
|
||||
#include <aqhome/ipc/nodes/ipc_nodes.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
|
||||
AQHOME_API GWEN_MSG *AQH_SetAcceptedMsgGroupsIpcMsg_new(uint16_t code, uint32_t groups);
|
||||
|
||||
AQHOME_API uint32_t AQH_SetAcceptedMsgGroupsIpcMsg_GetMsgGroups(const GWEN_MSG *msg);
|
||||
|
||||
AQHOME_API void AQH_SetAcceptedMsgGroupsIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
143
aqhome/ipc/nodes/msg_ipc_value.c
Normal file
143
aqhome/ipc/nodes/msg_ipc_value.c
Normal file
@@ -0,0 +1,143 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 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/ipc/nodes/msg_ipc_value.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
#include <gwenhywfar/misc.h>
|
||||
#include <gwenhywfar/list.h>
|
||||
#include <gwenhywfar/error.h>
|
||||
#include <gwenhywfar/debug.h>
|
||||
#include <gwenhywfar/text.h>
|
||||
#include <gwenhywfar/msg_ipc.h>
|
||||
|
||||
|
||||
#define AQH_MSGIPC_VALUE_OFFS_UID 0 /* 4 bytes */
|
||||
#define AQH_MSGIPC_VALUE_OFFS_VALUEID 4 /* 1 byte */
|
||||
#define AQH_MSGIPC_VALUE_OFFS_VALUETYPE 5 /* 1 byte */
|
||||
#define AQH_MSGIPC_VALUE_OFFS_VALUE_NOM 6 /* 2 bytes */
|
||||
#define AQH_MSGIPC_VALUE_OFFS_VALUE_DENOM 8 /* 2 bytes */
|
||||
|
||||
#define AQH_MSGIPC_VALUE_MINSIZE (GWEN_MSGIPC_OFFS_PAYLOAD+10)
|
||||
|
||||
|
||||
|
||||
|
||||
GWEN_MSG *AQH_ValueIpcMsg_new(uint16_t code,
|
||||
uint32_t uid,
|
||||
uint8_t valueId,
|
||||
uint8_t valueType,
|
||||
int16_t valueNom,
|
||||
int16_t valueDenom)
|
||||
{
|
||||
GWEN_MSG *msg;
|
||||
uint8_t *ptr;
|
||||
|
||||
msg=GWEN_IpcMsg_new(AQH_IPC_PROTOCOL_NODES_ID, AQH_IPC_PROTOCOL_NODES_VERSION, code, AQH_MSGIPC_VALUE_MINSIZE, NULL);
|
||||
ptr=GWEN_Msg_GetBuffer(msg);
|
||||
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_VALUE_OFFS_UID+0]=uid & 0xff;
|
||||
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_VALUE_OFFS_UID+1]=(uid>>8) & 0xff;
|
||||
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_VALUE_OFFS_UID+2]=(uid>>16) & 0xff;
|
||||
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_VALUE_OFFS_UID+3]=(uid>>24) & 0xff;
|
||||
|
||||
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_VALUE_OFFS_VALUEID]=valueId;
|
||||
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_VALUE_OFFS_VALUETYPE]=valueType;
|
||||
|
||||
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_VALUE_OFFS_VALUE_NOM+0]=valueNom & 0xff;
|
||||
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_VALUE_OFFS_VALUE_NOM+1]=(valueNom>>8) & 0xff;
|
||||
|
||||
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_VALUE_OFFS_VALUE_DENOM+0]=valueDenom & 0xff;
|
||||
ptr[GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_VALUE_OFFS_VALUE_DENOM+1]=(valueDenom>>8) & 0xff;
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint32_t AQH_ValueIpcMsg_GetUid(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint32At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_VALUE_OFFS_UID, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_ValueIpcMsg_GetValueId(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint8At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_VALUE_OFFS_VALUEID, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t AQH_ValueIpcMsg_GetValueType(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint8At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_VALUE_OFFS_VALUETYPE, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int16_t AQH_ValueIpcMsg_GetValueNom(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint16At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_VALUE_OFFS_VALUE_NOM, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int16_t AQH_ValueIpcMsg_GetValueDenom(const GWEN_MSG *msg)
|
||||
{
|
||||
return GWEN_Msg_GetUint16At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_VALUE_OFFS_VALUE_DENOM, 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
double AQH_ValueIpcMsg_GetValueAsDouble(const GWEN_MSG *msg)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSGIPC_VALUE_MINSIZE) {
|
||||
double nom;
|
||||
int16_t rawDenom;
|
||||
double denom;
|
||||
|
||||
nom=(double) AQH_ValueIpcMsg_GetValueNom(msg);
|
||||
rawDenom=AQH_ValueIpcMsg_GetValueDenom(msg);
|
||||
if (rawDenom==0)
|
||||
denom=1.0;
|
||||
else
|
||||
denom=(double) rawDenom;
|
||||
return (double)(nom/denom);
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_ValueIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSGIPC_VALUE_MINSIZE) {
|
||||
GWEN_Buffer_AppendArgs(dbuf,
|
||||
"VALUE (code=%d, proto=%d, proto version=%d, uid=0x%08x, value_id=0x%02x, type=0x%02x, value=%f)\n",
|
||||
GWEN_IpcMsg_GetCode(msg),
|
||||
GWEN_IpcMsg_GetProtoId(msg),
|
||||
GWEN_IpcMsg_GetProtoVersion(msg),
|
||||
(unsigned int) AQH_ValueIpcMsg_GetUid(msg),
|
||||
AQH_ValueIpcMsg_GetValueId(msg),
|
||||
AQH_ValueIpcMsg_GetValueType(msg),
|
||||
AQH_ValueIpcMsg_GetValueAsDouble(msg));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
41
aqhome/ipc/nodes/msg_ipc_value.h
Normal file
41
aqhome/ipc/nodes/msg_ipc_value.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project AqHome.
|
||||
* AqHome (c) by 2023 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_VALUE_H
|
||||
#define AQH_MSG_IPC_VALUE_H
|
||||
|
||||
|
||||
#include <aqhome/api.h>
|
||||
#include <aqhome/ipc/nodes/ipc_nodes.h>
|
||||
#include <aqhome/msg/msg_node.h>
|
||||
|
||||
#include <gwenhywfar/msg.h>
|
||||
#include <gwenhywfar/buffer.h>
|
||||
|
||||
|
||||
|
||||
AQHOME_API GWEN_MSG *AQH_ValueIpcMsg_new(uint16_t code,
|
||||
uint32_t uid,
|
||||
uint8_t valueId,
|
||||
uint8_t valueType,
|
||||
int16_t valueNom,
|
||||
int16_t valueDenom);
|
||||
AQHOME_API uint32_t AQH_ValueIpcMsg_GetUid(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_ValueIpcMsg_GetValueId(const GWEN_MSG *msg);
|
||||
AQHOME_API uint8_t AQH_ValueIpcMsg_GetValueType(const GWEN_MSG *msg);
|
||||
AQHOME_API int16_t AQH_ValueIpcMsg_GetValueNom(const GWEN_MSG *msg);
|
||||
AQHOME_API int16_t AQH_ValueIpcMsg_GetValueDenom(const GWEN_MSG *msg);
|
||||
AQHOME_API double AQH_ValueIpcMsg_GetValueAsDouble(const GWEN_MSG *msg);
|
||||
|
||||
AQHOME_API void AQH_ValueIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user