From 90d830da6f64fb54511153c9384593b66d55f60f Mon Sep 17 00:00:00 2001 From: acidburns Date: Mon, 2 Feb 2026 22:17:09 +0100 Subject: [PATCH] Keep receiver LoRa in continuous RX - Add lora_receive_continuous() helper and use it after init and TX (ACK/time sync) - Ensure receiver returns to RX immediately after lora_send - Document continuous RX behavior in README --- README.md | 2 ++ include/lora_transport.h | 1 + src/lora_transport.cpp | 4 ++++ src/main.cpp | 2 ++ src/time_manager.cpp | 6 +++++- 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 66a9303..aef7a7e 100644 --- a/README.md +++ b/README.md @@ -133,6 +133,8 @@ void receiver_loop() { } ``` +Receiver keeps the SX1276 in continuous RX, re-entering RX after any transmit (ACK or time sync). + **Key receiver functions**: ```cpp bool lora_receive(LoraPacket &pkt, uint32_t timeout_ms); diff --git a/include/lora_transport.h b/include/lora_transport.h index ad3e932..c8c2646 100644 --- a/include/lora_transport.h +++ b/include/lora_transport.h @@ -21,5 +21,6 @@ bool lora_send(const LoraPacket &pkt); bool lora_receive(LoraPacket &pkt, uint32_t timeout_ms); void lora_idle(); void lora_sleep(); +void lora_receive_continuous(); bool lora_receive_window(LoraPacket &pkt, uint32_t timeout_ms); uint32_t lora_airtime_ms(size_t packet_len); diff --git a/src/lora_transport.cpp b/src/lora_transport.cpp index e19cb09..aa15d73 100644 --- a/src/lora_transport.cpp +++ b/src/lora_transport.cpp @@ -118,6 +118,10 @@ void lora_sleep() { LoRa.sleep(); } +void lora_receive_continuous() { + LoRa.receive(); +} + bool lora_receive_window(LoraPacket &pkt, uint32_t timeout_ms) { if (timeout_ms == 0) { return false; diff --git a/src/main.cpp b/src/main.cpp index ad44f86..736c11f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -431,6 +431,7 @@ static void send_batch_ack(uint16_t batch_id, uint16_t sender_id) { write_u16_le(&ack.payload[2], sender_id); write_u16_le(&ack.payload[4], g_short_id); lora_send(ack); + lora_receive_continuous(); } static bool prepare_inflight_from_queue() { @@ -651,6 +652,7 @@ void setup() { update_battery_cache(); } else { power_receiver_init(); + lora_receive_continuous(); pinMode(PIN_ROLE, INPUT); // release pulldown before SD uses GPIO14 as SCK sd_logger_init(); wifi_manager_init(); diff --git a/src/time_manager.cpp b/src/time_manager.cpp index 9d46f0b..f7bf88c 100644 --- a/src/time_manager.cpp +++ b/src/time_manager.cpp @@ -83,7 +83,11 @@ bool time_send_timesync(uint16_t device_id_short) { pkt.payload_type = PayloadType::TimeSync; pkt.payload_len = compressed_len; memcpy(pkt.payload, compressed, compressed_len); - return lora_send(pkt); + bool ok = lora_send(pkt); + if (ok) { + lora_receive_continuous(); + } + return ok; } bool time_handle_timesync_payload(const uint8_t *payload, size_t len) {