/**************************************************************************** * 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 #endif #include #include #include #include #include #include #include #include #include #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)); } }