mqtt: publish messages for recv stats.
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include "aqhome/msg/msg_node.h"
|
||||
#include "aqhome/msg/msg_value2.h"
|
||||
#include "aqhome/msg/msg_sendstats.h"
|
||||
#include "aqhome/msg/msg_recvstats.h"
|
||||
|
||||
#include <gwenhywfar/endpoint_tcpc.h>
|
||||
#include <gwenhywfar/debug.h>
|
||||
@@ -40,6 +41,7 @@ static void _checkForConnAckMsg(GWEN_MSG_ENDPOINT *ep);
|
||||
static void _processOutMessage(GWEN_MSG_ENDPOINT *ep, GWEN_MSG *nodeMsg);
|
||||
static void _processValue2Message(GWEN_MSG_ENDPOINT *ep, GWEN_MSG *nodeMsg);
|
||||
static void _processSendStatsMessage(GWEN_MSG_ENDPOINT *ep, GWEN_MSG *nodeMsg);
|
||||
static void _processRecvStatsMessage(GWEN_MSG_ENDPOINT *ep, GWEN_MSG *nodeMsg);
|
||||
static void _publishDouble(GWEN_MSG_ENDPOINT *ep, uint32_t uid, int valueId, const char *valuePath, double v);
|
||||
static void _publishInt(GWEN_MSG_ENDPOINT *ep, uint32_t uid, int valueId, const char *valuePath, int v);
|
||||
static void _publishString(GWEN_MSG_ENDPOINT *ep, uint32_t uid, int valueId, const char *valuePath, const char *v);
|
||||
@@ -273,6 +275,9 @@ void _processOutMessage(GWEN_MSG_ENDPOINT *ep, GWEN_MSG *nodeMsg)
|
||||
case AQH_MSG_TYPE_COMSENDSTATS:
|
||||
_processSendStatsMessage(ep, nodeMsg);
|
||||
break;
|
||||
case AQH_MSG_TYPE_COMRECVSTATS:
|
||||
_processRecvStatsMessage(ep, nodeMsg);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -321,6 +326,34 @@ void _processSendStatsMessage(GWEN_MSG_ENDPOINT *ep, GWEN_MSG *nodeMsg)
|
||||
|
||||
|
||||
|
||||
void _processRecvStatsMessage(GWEN_MSG_ENDPOINT *ep, GWEN_MSG *nodeMsg)
|
||||
{
|
||||
uint16_t packetsInInt;
|
||||
|
||||
packetsInInt=AQH_RecvStatsMsg_GetPacketsIn(nodeMsg);
|
||||
if (packetsInInt) {
|
||||
double packetsIn;
|
||||
double errors;
|
||||
double handled;
|
||||
double errorsPercentage=0.0;
|
||||
double handledPercentage=0.0;
|
||||
|
||||
packetsIn=(double) packetsInInt;
|
||||
errors=(double)AQH_RecvStatsMsg_GetErrors(nodeMsg);
|
||||
handled=(double)AQH_RecvStatsMsg_GetHandled(nodeMsg);
|
||||
|
||||
errorsPercentage=errors*100.0/packetsIn;
|
||||
handledPercentage=handled*100.0/packetsIn;
|
||||
|
||||
_publishInt(ep, AQH_RecvStatsMsg_GetUid(nodeMsg), 0, "net/packetsIn", packetsInInt);
|
||||
_publishInt(ep, AQH_RecvStatsMsg_GetUid(nodeMsg), 0, "net/errors", (int) AQH_RecvStatsMsg_GetErrors(nodeMsg));
|
||||
_publishDouble(ep, AQH_RecvStatsMsg_GetUid(nodeMsg), 0, "net/errorsPercent", errorsPercentage);
|
||||
_publishDouble(ep, AQH_RecvStatsMsg_GetUid(nodeMsg), 0, "net/handledPercent", handledPercentage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void _publishDouble(GWEN_MSG_ENDPOINT *ep, uint32_t uid, int valueId, const char *valuePath, double v)
|
||||
{
|
||||
char numBuf[16];
|
||||
|
||||
Reference in New Issue
Block a user