Add RX and RX_ALL analytics for #588

This commit is contained in:
Jm Casler 2020-12-27 09:29:48 -08:00
parent 3c69beef94
commit 58859848a3
3 changed files with 27 additions and 5 deletions

2
proto

@ -1 +1 @@
Subproject commit 323b814f4392ae0f9c42a0f14557c6b9333efce3 Subproject commit ce422b7c448906c6fee3eef64bbd41adfbc990f0

View File

@ -4,6 +4,24 @@
#include <Arduino.h> #include <Arduino.h>
#include <functional> #include <functional>
/*
TX_LOG - Time on air this device has transmitted
RX_LOG - Time on air used by valid and routable mesh packets, does not include
TX air time
RX_ALL_LOG - Time of all received lora packets. This includes packets that are not
for meshtastic devices. Does not include TX air time.
Example analytics:
TX_LOG + RX_LOG = Total air time for a perticular meshtastic channel.
TX_LOG + RX_LOG = Total air time for a perticular meshtastic channel, including
other lora radios.
RX_ALL_LOG - RX_LOG = Other lora radios on our frequency channel.
*/
enum reportTypes { TX_LOG, RX_LOG, RX_ALL_LOG }; enum reportTypes { TX_LOG, RX_LOG, RX_ALL_LOG };
void logAirtime(reportTypes reportType, uint32_t airtime_ms); void logAirtime(reportTypes reportType, uint32_t airtime_ms);

View File

@ -58,7 +58,6 @@ void INTERRUPT_ATTR RadioLibInterface::isrTxLevel0()
*/ */
RadioLibInterface *RadioLibInterface::instance; RadioLibInterface *RadioLibInterface::instance;
/** Could we send right now (i.e. either not actively receving or transmitting)? */ /** Could we send right now (i.e. either not actively receving or transmitting)? */
bool RadioLibInterface::canSendImmediately() bool RadioLibInterface::canSendImmediately()
{ {
@ -88,7 +87,6 @@ ErrorCode RadioLibInterface::send(MeshPacket *p)
printPacket("enqueuing for send", p); printPacket("enqueuing for send", p);
uint32_t xmitMsec = getPacketTime(p); uint32_t xmitMsec = getPacketTime(p);
DEBUG_MSG("txGood=%d,rxGood=%d,rxBad=%d\n", txGood, rxGood, rxBad); DEBUG_MSG("txGood=%d,rxGood=%d,rxBad=%d\n", txGood, rxGood, rxBad);
ErrorCode res = txQueue.enqueue(p, 0) ? ERRNO_OK : ERRNO_UNKNOWN; ErrorCode res = txQueue.enqueue(p, 0) ? ERRNO_OK : ERRNO_UNKNOWN;
@ -100,7 +98,6 @@ ErrorCode RadioLibInterface::send(MeshPacket *p)
// Count the packet toward our TX airtime utilization. // Count the packet toward our TX airtime utilization.
// We only count it if it can be added to the TX queue. // We only count it if it can be added to the TX queue.
logAirtime(TX_LOG, xmitMsec); logAirtime(TX_LOG, xmitMsec);
// We want all sending/receiving to be done by our daemon thread, We use a delay here because this packet might have been sent // We want all sending/receiving to be done by our daemon thread, We use a delay here because this packet might have been sent
// in response to a packet we just received. So we want to make sure the other side has had a chance to reconfigure its radio // in response to a packet we just received. So we want to make sure the other side has had a chance to reconfigure its radio
@ -211,12 +208,16 @@ void RadioLibInterface::completeSending()
void RadioLibInterface::handleReceiveInterrupt() void RadioLibInterface::handleReceiveInterrupt()
{ {
uint32_t xmitMsec;
assert(isReceiving); assert(isReceiving);
isReceiving = false; isReceiving = false;
// read the number of actually received bytes // read the number of actually received bytes
size_t length = iface->getPacketLength(); size_t length = iface->getPacketLength();
xmitMsec = getPacketTime(length);
logAirtime(RX_ALL_LOG, xmitMsec);
int state = iface->readData(radiobuf, length); int state = iface->readData(radiobuf, length);
if (state != ERR_NONE) { if (state != ERR_NONE) {
DEBUG_MSG("ignoring received packet due to error=%d\n", state); DEBUG_MSG("ignoring received packet due to error=%d\n", state);
@ -256,11 +257,14 @@ void RadioLibInterface::handleReceiveInterrupt()
printPacket("Lora RX", mp); printPacket("Lora RX", mp);
xmitMsec = getPacketTime(mp);
logAirtime(RX_LOG, xmitMsec);
deliverToReceiver(mp); deliverToReceiver(mp);
} }
} }
} }
/** start an immediate transmit */ /** start an immediate transmit */
void RadioLibInterface::startSend(MeshPacket *txp) void RadioLibInterface::startSend(MeshPacket *txp)
{ {