69 lines
2.0 KiB
C
69 lines
2.0 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>
|
|
|
|
|
|
|
|
uint32_t AQH_ClaimAddrMsg_GetUid(const GWEN_MSG *msg)
|
|
{
|
|
if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_CLAIM_ADDRESS) &&
|
|
(GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_CLAIMADDR_MINSIZE)) {
|
|
const uint8_t *ptr;
|
|
|
|
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_CLAIMADDR_UID;
|
|
return (uint32_t)(ptr[0])+(ptr[1]<<8)+(ptr[2]<<16)+(ptr[3]<<24);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
|
|
|
|
uint8_t AQH_ClaimAddrMsg_GetAddress(const GWEN_MSG *msg)
|
|
{
|
|
if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_CLAIM_ADDRESS) &&
|
|
(GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_CLAIMADDR_MINSIZE)) {
|
|
const uint8_t *ptr;
|
|
|
|
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_CLAIMADDR_ADDR;
|
|
return ptr[0];
|
|
}
|
|
return 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));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|