agc reset fix

This commit is contained in:
liquidraver
2026-03-15 13:49:13 +01:00
parent d794b57e31
commit 3bec5fedb9
2 changed files with 16 additions and 7 deletions
@@ -403,7 +403,7 @@ index 7b0b67f89d5..7154eb074ce 100644
/* Start transmission with 10 second timeout */
ret = sx126x_set_tx(dev, 10000);
if (ret < 0) {
@@ -1038,6 +1260,121 @@ static int sx126x_lora_test_cw(const struct device *dev, uint32_t frequency,
@@ -1038,6 +1260,126 @@ static int sx126x_lora_test_cw(const struct device *dev, uint32_t frequency,
return 0;
}
@@ -519,6 +519,11 @@ index 7b0b67f89d5..7154eb074ce 100644
+ sx126x_set_rx_gain(dev, true);
+ }
+
+ /* Chip is now in STANDBY. Update state so lora_recv_async() can
+ * transition back to RX — without this, the CAS(REST→RX) fails
+ * because state was still SX126X_STATE_RX from before the reset. */
+ atomic_set(&data->state, SX126X_STATE_IDLE);
+
+ k_mutex_unlock(&data->lock);
+}
+
+10 -6
View File
@@ -133,15 +133,19 @@ void Dispatcher::maintenanceLoop()
/* Noise floor calibration — one EMA tick per housekeeping cycle */
_radio->triggerNoiseFloorCalibrate(getInterferenceThreshold());
/* RX mode watchdog — detect if radio is stuck outside RX */
bool is_recv = _radio->isInRecvMode();
if (is_recv != prev_isrecv_mode) {
prev_isrecv_mode = is_recv;
if (!is_recv) {
/* RX mode watchdog — detect if radio is stuck in neither RX nor TX.
* Count TX time as "active" so rapid consecutive relays on a busy
* repeater don't falsely trigger the flag: the housekeeping timer
* (5 s) can miss brief RX windows between TXes, leaving
* radio_nonrx_start stale and firing the watchdog spuriously. */
bool is_active = _radio->isInRecvMode() || !_radio->isSendComplete();
if (is_active != prev_isrecv_mode) {
prev_isrecv_mode = is_active;
if (!is_active) {
radio_nonrx_start = (uint32_t)_ms->getMillis();
}
}
if (!is_recv && (uint32_t)_ms->getMillis() - radio_nonrx_start > 8000) {
if (!is_active && (uint32_t)_ms->getMillis() - radio_nonrx_start > 8000) {
_err_flags |= ERR_EVENT_STARTRX_TIMEOUT;
}