Scale ACK RX window to LoRa airtime

- Compute ACK receive window from airtime with bounds and margin
- Retry once if initial window misses
- Document ACK window sizing
This commit is contained in:
2026-02-04 01:21:42 +01:00
parent 1024aa3dd0
commit 7e5e23e56c
2 changed files with 18 additions and 1 deletions

View File

@@ -862,8 +862,24 @@ static void sender_loop() {
if (g_batch_ack_pending) {
LoraPacket ack_pkt = {};
const uint32_t ack_len = 5 + 6 + 2;
uint32_t ack_air_ms = lora_airtime_ms(ack_len);
uint32_t ack_window_ms = ack_air_ms + 300;
if (ack_window_ms < 1200) {
ack_window_ms = 1200;
}
if (ack_window_ms > 4000) {
ack_window_ms = 4000;
}
if (SERIAL_DEBUG_MODE) {
serial_debug_printf("ack: rx window=%lu airtime=%lu", static_cast<unsigned long>(ack_window_ms),
static_cast<unsigned long>(ack_air_ms));
}
uint32_t rx_start = millis();
bool got_ack = lora_receive_window(ack_pkt, 400);
bool got_ack = lora_receive_window(ack_pkt, ack_window_ms);
if (!got_ack) {
got_ack = lora_receive_window(ack_pkt, ack_window_ms / 2);
}
uint32_t rx_elapsed = millis() - rx_start;
if (SERIAL_DEBUG_MODE) {
g_sender_rx_window_ms += rx_elapsed;