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
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user