Integration of upstrem PR #1727

This commit is contained in:
Matthias Wientapper
2026-04-05 17:29:08 +02:00
6 changed files with 19 additions and 8 deletions

View File

@@ -255,7 +255,7 @@ float MyMesh::getAirtimeBudgetFactor() const {
} }
int MyMesh::getInterferenceThreshold() const { int MyMesh::getInterferenceThreshold() const {
return 0; // disabled for now, until currentRSSI() problem is resolved return 1; // non-zero enables hardware CAD (Channel Activity Detection) before TX
} }
int MyMesh::calcRxDelay(float score, uint32_t air_time) const { int MyMesh::calcRxDelay(float score, uint32_t air_time) const {

View File

@@ -881,7 +881,7 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc
_prefs.flood_advert_interval = 12; // 12 hours _prefs.flood_advert_interval = 12; // 12 hours
_prefs.flood_advert_base = 0.308f; _prefs.flood_advert_base = 0.308f;
_prefs.flood_max = 64; _prefs.flood_max = 64;
_prefs.interference_threshold = 0; // disabled _prefs.interference_threshold = 1; // non-zero enables hardware CAD before TX
// bridge defaults // bridge defaults
_prefs.bridge_enabled = 1; // enabled _prefs.bridge_enabled = 1; // enabled

View File

@@ -633,7 +633,7 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc
_prefs.flood_advert_interval = 12; // 12 hours _prefs.flood_advert_interval = 12; // 12 hours
_prefs.flood_advert_base = 0.308f; _prefs.flood_advert_base = 0.308f;
_prefs.flood_max = 64; _prefs.flood_max = 64;
_prefs.interference_threshold = 0; // disabled _prefs.interference_threshold = 1; // non-zero enables hardware CAD before TX
#ifdef ROOM_PASSWORD #ifdef ROOM_PASSWORD
StrHelper::strncpy(_prefs.guest_password, ROOM_PASSWORD, sizeof(_prefs.guest_password)); StrHelper::strncpy(_prefs.guest_password, ROOM_PASSWORD, sizeof(_prefs.guest_password));
#endif #endif

View File

@@ -723,7 +723,7 @@ SensorMesh::SensorMesh(mesh::MainBoard& board, mesh::Radio& radio, mesh::Millise
_prefs.flood_advert_interval = 0; // disabled _prefs.flood_advert_interval = 0; // disabled
_prefs.disable_fwd = true; _prefs.disable_fwd = true;
_prefs.flood_max = 64; _prefs.flood_max = 64;
_prefs.interference_threshold = 0; // disabled _prefs.interference_threshold = 1; // non-zero enables hardware CAD before TX
// GPS defaults // GPS defaults
_prefs.gps_enabled = 0; _prefs.gps_enabled = 0;

View File

@@ -168,10 +168,20 @@ void RadioLibWrapper::onSendFinished() {
state = STATE_IDLE; state = STATE_IDLE;
} }
int16_t RadioLibWrapper::performChannelScan() {
return _radio->scanChannel();
}
bool RadioLibWrapper::isChannelActive() { bool RadioLibWrapper::isChannelActive() {
return _threshold == 0 if (_threshold == 0) return false; // interference check is disabled
? false // interference check is disabled
: getCurrentRSSI() > _noise_floor + _threshold; int16_t result = performChannelScan();
// scanChannel() triggers DIO interrupt (CAD done) which sets STATE_INT_READY
// via setFlag() ISR. Clear it before restarting RX so recvRaw() doesn't
// try to read a non-existent packet and count a spurious recv error.
state = STATE_IDLE;
startRecv();
return result != RADIOLIB_CHANNEL_FREE;
} }
float RadioLibWrapper::getLastRSSI() const { float RadioLibWrapper::getLastRSSI() const {

View File

@@ -31,13 +31,14 @@ public:
bool isInRecvMode() const override; bool isInRecvMode() const override;
bool isChannelActive(); bool isChannelActive();
bool isReceiving() override { bool isReceiving() override {
if (isReceivingPacket()) return true; if (isReceivingPacket()) return true;
return isChannelActive(); return isChannelActive();
} }
virtual float getCurrentRSSI() =0; virtual float getCurrentRSSI() =0;
virtual int16_t performChannelScan();
int getNoiseFloor() const override { return _noise_floor; } int getNoiseFloor() const override { return _noise_floor; }
void triggerNoiseFloorCalibrate(int threshold) override; void triggerNoiseFloorCalibrate(int threshold) override;