aqhome: started rewriting message code, start using new event2 lib.
This commit is contained in:
70
aqhome/msg/node/m_sendstats.c
Normal file
70
aqhome/msg/node/m_sendstats.c
Normal file
@@ -0,0 +1,70 @@
|
||||
/****************************************************************************
|
||||
* 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/node/m_sendstats.h"
|
||||
#include "aqhome/msg/node/m_node.h"
|
||||
|
||||
#include <gwenhywfar/debug.h>
|
||||
|
||||
|
||||
#define AQH_MSG_OFFS_SENDSTATS_UID 0 /* 4 bytes */
|
||||
#define AQH_MSG_OFFS_SENDSTATS_PACKETSOUT 4 /* 2 bytes */
|
||||
#define AQH_MSG_OFFS_SENDSTATS_COLLISIONS 6 /* 2 bytes */
|
||||
#define AQH_MSG_OFFS_SENDSTATS_BUSY 8 /* 2 bytes */
|
||||
|
||||
|
||||
|
||||
uint32_t AQH_SendStatsMessage_GetUid(const AQH_MESSAGE *msg)
|
||||
{
|
||||
return AQH_Message_ReadUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_SENDSTATS_UID, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_SendStatsMessage_GetPacketsOut(const AQH_MESSAGE *msg)
|
||||
{
|
||||
return AQH_Message_ReadUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_SENDSTATS_PACKETSOUT, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_SendStatsMessage_GetCollisions(const AQH_MESSAGE *msg)
|
||||
{
|
||||
return AQH_Message_ReadUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_SENDSTATS_COLLISIONS, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_SendStatsMessage_GetBusyErrors(const AQH_MESSAGE *msg)
|
||||
{
|
||||
return AQH_Message_ReadUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_SENDSTATS_BUSY, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_SendStatsMessage_DumpToBuffer(const AQH_MESSAGE *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
if (msg)
|
||||
GWEN_Buffer_AppendArgs(dbuf,
|
||||
"0x%02x->0x%02x: SENDSTATS %s (uid=0x%08x, out=%d, collisions=%d, busy line=%d)\n",
|
||||
AQH_NodeMessage_GetSourceAddress(msg),
|
||||
AQH_NodeMessage_GetDestAddress(msg),
|
||||
sText,
|
||||
(unsigned int) AQH_SendStatsMessage_GetUid(msg),
|
||||
AQH_SendStatsMessage_GetPacketsOut(msg),
|
||||
AQH_SendStatsMessage_GetCollisions(msg),
|
||||
AQH_SendStatsMessage_GetBusyErrors(msg));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user