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); }