/**************************************************************************** * 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 "aqhome/msg_pong.h" #include #include #include #include uint32_t AQH_MsgPong_GetTimestamp(const AQH_MSG *msg) { if ((AQH_Msg_GetMsgType(msg)==AQH_MSG_TYPE_PONG) && (AQH_Msg_GetBytesInBuffer(msg)>=AQH_MSG_PONG_MINSIZE)) { const uint8_t *ptr; ptr=AQH_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_PONG_TIMESTAMP; return (uint32_t)(ptr[0])+(ptr[1]<<8)+(ptr[2]<<16)+(ptr[3]<<24); } return 0; } void AQH_MsgPong_DumpToBuffer(const AQH_MSG *msg, GWEN_BUFFER *dbuf, const char *sText) { if ((AQH_Msg_GetMsgType(msg)==AQH_MSG_TYPE_PONG) && (AQH_Msg_GetBytesInBuffer(msg)>=AQH_MSG_PONG_MINSIZE)) { GWEN_Buffer_AppendArgs(dbuf, "0x%02x->0x%02x: PONG %s (timestamp=0x%08x)\n", AQH_Msg_GetSourceAddress(msg), AQH_Msg_GetDestAddress(msg), sText, (unsigned int) AQH_MsgPong_GetTimestamp(msg)); } }