Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

radiolink: add log variables for statistics #1341

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion src/hal/src/radiolink.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ static int radiolinkReceiveCRTPPacket(CRTPPacket *p);
static uint8_t rssi;
static bool isConnected;
static uint32_t lastPacketTick;
static uint16_t count_rx_broadcast;
static uint16_t count_rx_unicast;

static volatile P2PCallback p2p_callback;

Expand Down Expand Up @@ -162,6 +164,7 @@ void radiolinkSyslinkDispatch(SyslinkPacket *slp)
slp->length--; // Decrease to get CRTP size.
// Assert that we are not dropping any packets
ASSERT(xQueueSend(crtpPacketDelivery, &slp->length, 0) == pdPASS);
++count_rx_unicast;
ledseqRun(&seq_linkUp);
// If a radio packet is received, one can be sent
if (xQueueReceive(txQueue, &txPacket, 0) == pdTRUE)
Expand All @@ -173,7 +176,11 @@ void radiolinkSyslinkDispatch(SyslinkPacket *slp)
{
slp->length--; // Decrease to get CRTP size.
// broadcasts are best effort, so no need to handle the case where the queue is full
xQueueSend(crtpPacketDelivery, &slp->length, 0);
BaseType_t result = xQueueSend(crtpPacketDelivery, &slp->length, 0);
// only increment the received counter, if we were able to put it in the queue
if (result == pdPASS) {
++count_rx_broadcast;
}
ledseqRun(&seq_linkUp);
// no ack for broadcasts
} else if (slp->type == SYSLINK_RADIO_RSSI)
Expand Down Expand Up @@ -259,7 +266,28 @@ static int radiolinkSetEnable(bool enable)
return 0;
}

/**
* Radio link log variables.
*/
LOG_GROUP_START(radio)
/**
* @brief Radio Signal Strength Indicator [dBm]
*/
LOG_ADD_CORE(LOG_UINT8, rssi, &rssi)
/**
* @brief Indicator if a packet was received from the radio within the last RADIO_ACTIVITY_TIMEOUT_MS.
*/
LOG_ADD_CORE(LOG_UINT8, isConnected, &isConnected)
/**
* @brief Number of broadcast packets received.
*
* Note that this is only 16 bits and overflows. Use overflow correction on the client side.
*/
LOG_ADD_CORE(LOG_UINT16, numRxBc, &count_rx_broadcast)
/**
* @brief Number of unicast packets received.
*
* Note that this is only 16 bits and overflows. Use overflow correction on the client side.
*/
LOG_ADD_CORE(LOG_UINT16, numRxUc, &count_rx_unicast)
LOG_GROUP_STOP(radio)