0x97 allows for detection of all 1-3 bit errors in a message of up to 119 bytes (see https://www.faa.gov/aircraft/air_cert/design_approvals/air_software/media/TC-14-49.pdf)
52 lines
1.4 KiB
C
52 lines
1.4 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_pong.h"
|
|
|
|
#include <gwenhywfar/misc.h>
|
|
#include <gwenhywfar/list.h>
|
|
#include <gwenhywfar/error.h>
|
|
#include <gwenhywfar/debug.h>
|
|
|
|
|
|
#define AQH_MSG_OFFS_PONG_TIMESTAMP 0
|
|
|
|
#define AQH_MSG_PONG_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_PONG_TIMESTAMP+4)
|
|
|
|
|
|
|
|
uint32_t AQH_PongMsg_GetTimestamp(const GWEN_MSG *msg)
|
|
{
|
|
return AQH_NodeMsg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_PONG_TIMESTAMP, 0);
|
|
}
|
|
|
|
|
|
|
|
void AQH_PongMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
|
|
{
|
|
if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_PONG) &&
|
|
(GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_PONG_MINSIZE)) {
|
|
GWEN_Buffer_AppendArgs(dbuf,
|
|
"0x%02x->0x%02x: PONG %s (timestamp=0x%08x)\n",
|
|
AQH_NodeMsg_GetSourceAddress(msg),
|
|
AQH_NodeMsg_GetDestAddress(msg),
|
|
sText,
|
|
(unsigned int) AQH_PongMsg_GetTimestamp(msg));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|