From 9363478d6fd174bb22a75dc74f022e0cb4a6d337 Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Wed, 18 Jun 2025 01:27:53 +1000 Subject: [PATCH] * noise floor can now be queried even when int.thresh = 0 --- src/helpers/RadioLibWrappers.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/helpers/RadioLibWrappers.cpp b/src/helpers/RadioLibWrappers.cpp index 0593451a..96fb7aab 100644 --- a/src/helpers/RadioLibWrappers.cpp +++ b/src/helpers/RadioLibWrappers.cpp @@ -9,6 +9,7 @@ #define STATE_INT_READY 16 #define NUM_NOISE_FLOOR_SAMPLES 64 +#define SAMPLING_THRESHOLD 14 static volatile uint8_t state = STATE_IDLE; @@ -46,7 +47,7 @@ void RadioLibWrapper::idle() { void RadioLibWrapper::triggerNoiseFloorCalibrate(int threshold) { _threshold = threshold; - if (threshold > 0 && _num_floor_samples >= NUM_NOISE_FLOOR_SAMPLES) { // ignore trigger if currently sampling + if (_num_floor_samples >= NUM_NOISE_FLOOR_SAMPLES) { // ignore trigger if currently sampling _num_floor_samples = 0; _floor_sample_sum = 0; } @@ -65,7 +66,7 @@ void RadioLibWrapper::loop() { if (state == STATE_RX && _num_floor_samples < NUM_NOISE_FLOOR_SAMPLES) { if (!isReceivingPacket()) { int rssi = getCurrentRSSI(); - if (rssi < _noise_floor + _threshold) { // only consider samples below current floor+THRESHOLD + if (rssi < _noise_floor + SAMPLING_THRESHOLD) { // only consider samples below current floor + sampling THRESHOLD _num_floor_samples++; _floor_sample_sum += rssi; }