* Radio:: getLastSNR(), getLastRSSI()

* MESH_PACKET_LOGGING
This commit is contained in:
Scott Powell
2025-01-15 17:02:49 +11:00
parent cc5f21ab09
commit 20cd756c88
6 changed files with 26 additions and 13 deletions

View File

@@ -41,9 +41,9 @@
#error "need to provide a 'board' object"
#endif
#define FLOOD_SEND_TIMEOUT_MILLIS 6000
#define DIRECT_TIMEOUT_BASE 1000
#define DIRECT_TIMEOUT_FACTOR 400 // per hop millis
#define FLOOD_SEND_TIMEOUT_MILLIS 8000
#define DIRECT_TIMEOUT_BASE 1500
#define DIRECT_TIMEOUT_FACTOR 800 // per hop millis
/* -------------------------------------------------------------------------------------- */

View File

@@ -1,5 +1,9 @@
#include "Dispatcher.h"
#if MESH_PACKET_LOGGING
#include <Arduino.h>
#endif
namespace mesh {
void Dispatcher::begin() {
@@ -25,7 +29,6 @@ void Dispatcher::loop() {
outbound = NULL;
} else if (millisHasNowPassed(outbound_expiry)) {
MESH_DEBUG_PRINTLN("Dispatcher::loop(): WARNING: outbound packed send timed out!");
//Serial.println(" timed out");
_radio->onSendFinished();
releasePacket(outbound); // return to pool
@@ -62,7 +65,6 @@ void Dispatcher::checkRecv() {
return;
}
#endif
//Serial.print("LoRa recv: len="); Serial.println(len);
pkt->header = raw[i++];
pkt->path_len = raw[i++];
@@ -83,6 +85,11 @@ void Dispatcher::checkRecv() {
}
}
if (pkt) {
#if MESH_PACKET_LOGGING
Serial.printf("PACKET: recv, len=%d (type=%d, route=%s, payload_len=%d) SNR=%d RSSI=%d\n",
2 + pkt->path_len + pkt->payload_len, pkt->getPayloadType(), pkt->isRouteDirect() ? "D" : "F", pkt->payload_len,
(int)_radio->getLastSNR(), (int)_radio->getLastRSSI());
#endif
DispatcherAction action = onRecvPacket(pkt);
if (action == ACTION_RELEASE) {
_mgr->free(pkt);
@@ -126,7 +133,10 @@ void Dispatcher::checkSend() {
_radio->startSendRaw(raw, len);
outbound_expiry = futureMillis(max_airtime);
//Serial.print("LoRa send: len="); Serial.print(len);
#if MESH_PACKET_LOGGING
Serial.printf("PACKET: send, len=%d (type=%d, route=%s, payload_len=%d)\n",
len, outbound->getPayloadType(), outbound->isRouteDirect() ? "D" : "F", outbound->payload_len);
#endif
}
}
}

View File

@@ -57,6 +57,9 @@ public:
* \returns true if the radio is currently mid-receive of a packet.
*/
virtual bool isReceiving() { return false; }
virtual float getLastRSSI() const { return 0; }
virtual float getLastSNR() const { return 0; }
};
/**

View File

@@ -21,8 +21,8 @@
#if MESH_DEBUG && ARDUINO
#include <Arduino.h>
#define MESH_DEBUG_PRINT(...) Serial.printf(__VA_ARGS__)
#define MESH_DEBUG_PRINTLN(F, ...) Serial.printf(F "\n", ##__VA_ARGS__)
#define MESH_DEBUG_PRINT(F, ...) Serial.printf("DEBUG: " F, ##__VA_ARGS__)
#define MESH_DEBUG_PRINTLN(F, ...) Serial.printf("DEBUG: " F "\n", ##__VA_ARGS__)
#else
#define MESH_DEBUG_PRINT(...) {}
#define MESH_DEBUG_PRINTLN(...) {}

View File

@@ -37,7 +37,7 @@ int RadioLibWrapper::recvRaw(uint8_t* bytes, int sz) {
if (len > sz) { len = sz; }
int err = _radio->readData(bytes, len);
if (err != RADIOLIB_ERR_NONE) {
MESH_DEBUG_PRINTLN("RadioLibWrapper: error: readData()");
MESH_DEBUG_PRINTLN("RadioLibWrapper: error: readData(%d)", err);
} else {
// Serial.print(" readData() -> "); Serial.println(len);
}
@@ -50,7 +50,7 @@ int RadioLibWrapper::recvRaw(uint8_t* bytes, int sz) {
if (state != STATE_RX) {
int err = _radio->startReceive();
if (err != RADIOLIB_ERR_NONE) {
MESH_DEBUG_PRINTLN("RadioLibWrapper: error: startReceive()");
MESH_DEBUG_PRINTLN("RadioLibWrapper: error: startReceive(%d)", err);
}
state = STATE_RX;
}
@@ -66,7 +66,7 @@ void RadioLibWrapper::startSendRaw(const uint8_t* bytes, int len) {
_board->onBeforeTransmit();
int err = _radio->startTransmit((uint8_t *) bytes, len);
if (err != RADIOLIB_ERR_NONE) {
MESH_DEBUG_PRINTLN("RadioLibWrapper: error: startTransmit()");
MESH_DEBUG_PRINTLN("RadioLibWrapper: error: startTransmit(%d)", err);
}
}

View File

@@ -21,8 +21,8 @@ public:
uint32_t getPacketsRecv() const { return n_recv; }
uint32_t getPacketsSent() const { return n_sent; }
virtual float getLastRSSI() const;
virtual float getLastSNR() const;
float getLastRSSI() const override;
float getLastSNR() const override;
};
/**