Prepared introduction of multiple ipc protocols.
This commit is contained in:
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user