From e9c551a4195139e856fa2cc259154af5657f5e9c Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Sun, 1 Feb 2026 22:20:00 -0600 Subject: [PATCH] AGC reset don't crash, don't naively call --- src/main.cpp | 2 +- src/main.h | 1 + src/mesh/RadioLibInterface.cpp | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 55134ede0..324debeb7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1169,7 +1169,7 @@ void loop() #endif power->powerCommandsCheck(); - if (last_listen + 1000 * 60 < millis() && + if (RadioLibInterface::instance != nullptr && last_listen + 1000 * 60 < millis() && !(RadioLibInterface::instance->isSending() || RadioLibInterface::instance->isActivelyReceiving())) { RadioLibInterface::instance->startReceive(); LOG_DEBUG("attempting AGC reset"); diff --git a/src/main.h b/src/main.h index 91e27951f..619eb184e 100644 --- a/src/main.h +++ b/src/main.h @@ -33,6 +33,7 @@ extern ScanI2C::DeviceAddress cardkb_found; extern uint8_t kb_model; extern bool kb_found; extern bool osk_found; +extern unsigned long last_listen; extern ScanI2C::DeviceAddress rtc_found; extern ScanI2C::DeviceAddress accelerometer_found; extern ScanI2C::FoundDevice rgb_found; diff --git a/src/mesh/RadioLibInterface.cpp b/src/mesh/RadioLibInterface.cpp index 80e51b8bc..6716109b6 100644 --- a/src/mesh/RadioLibInterface.cpp +++ b/src/mesh/RadioLibInterface.cpp @@ -514,6 +514,8 @@ void RadioLibInterface::handleReceiveInterrupt() void RadioLibInterface::startReceive() { + // Note the updated timestamp, to avoid unneeded AGC resets + last_listen = millis(); isReceiving = true; powerMon->setState(meshtastic_PowerMon_State_Lora_RXOn); }