Files
aqhomecontrol/aqhome/msg/msg_claimaddr.c
Martin Preuss d53b061aed aqhome: implemented IPC client, fixed some bugs.
sending a PING request and retrieving the PONG response works now.
2023-04-16 23:22:03 +02:00

61 lines
1.7 KiB
C

/****************************************************************************
* 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/msg/msg_claimaddr.h"
#include <gwenhywfar/misc.h>
#include <gwenhywfar/list.h>
#include <gwenhywfar/error.h>
#include <gwenhywfar/debug.h>
#define AQH_MSG_OFFS_CLAIMADDR_UID 0
#define AQH_MSG_OFFS_CLAIMADDR_ADDR 4
#define AQH_MSG_CLAIMADDR_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_CLAIMADDR_ADDR+1)
uint32_t AQH_ClaimAddrMsg_GetUid(const GWEN_MSG *msg)
{
return GWEN_Msg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_CLAIMADDR_UID, 0);
}
uint8_t AQH_ClaimAddrMsg_GetAddress(const GWEN_MSG *msg)
{
return GWEN_Msg_GetUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_CLAIMADDR_ADDR, 0);
}
void AQH_ClaimAddrMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
{
if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_CLAIM_ADDRESS) &&
(GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_CLAIMADDR_MINSIZE)) {
GWEN_Buffer_AppendArgs(dbuf,
"0x%02x->0x%02x: CLAIM_ADDRESS %s (uid=0x%08x, address=0x%02x)\n",
AQH_NodeMsg_GetSourceAddress(msg),
AQH_NodeMsg_GetDestAddress(msg),
sText,
(unsigned int) AQH_ClaimAddrMsg_GetUid(msg),
AQH_ClaimAddrMsg_GetAddress(msg));
}
}