[telemetry] add API for TREL telemetry (#9710)

Create OT API to support trel telemetry which is supported through
platform API and also add cli support to get/reset trel counters.

Metrics we are adding are:
- trel_frames_tx
- trel_bytes_tx
- trel_frames_rx
- trel_bytes_rx
- trel_frames_tx_failed
- num_trel_peers

Metrics already supported through API:
- trel_enabled
This commit is contained in:
Yang Liu
2024-01-05 22:10:27 -08:00
committed by GitHub
parent 09d07a7c6a
commit d81c6fab98
14 changed files with 261 additions and 11 deletions
+19 -4
View File
@@ -73,10 +73,11 @@ static uint16_t sPortOffset = 0;
static bool sEnabled = false;
static uint16_t sUdpPort;
static bool sServiceRegistered = false;
static uint16_t sServicePort;
static uint8_t sServiceTxtLength;
static char sServiceTxtData[TREL_MAX_SERVICE_TXT_DATA_LEN];
static bool sServiceRegistered = false;
static uint16_t sServicePort;
static uint8_t sServiceTxtLength;
static char sServiceTxtData[TREL_MAX_SERVICE_TXT_DATA_LEN];
static otPlatTrelCounters sCounters;
#if DEBUG_LOG
static void dumpBuffer(const void *aBuffer, uint16_t aLength)
@@ -388,6 +389,8 @@ void otPlatTrelSend(otInstance *aInstance,
#if DEBUG_LOG
fprintf(stderr, "\r\n[trel-sim] otPlatTrelSend(len:%u, port:%u)\r\n", aUdpPayloadLen, aDestSockAddr->mPort);
#endif
++sCounters.mTxPackets;
sCounters.mTxBytes += aUdpPayloadLen;
}
//---------------------------------------------------------------------------------------------------------------------
@@ -473,6 +476,18 @@ void platformTrelProcess(otInstance *aInstance, const fd_set *aReadFdSet, const
}
}
const otPlatTrelCounters *otPlatTrelGetCounters(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
return &sCounters;
}
void otPlatTrelResetCounters(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
memset(&sCounters, 0, sizeof(sCounters));
}
//---------------------------------------------------------------------------------------------------------------------
// This is added for RCP build to be built ok