Repeat batch ACKs to cover RX latency

- Add ACK_REPEAT_COUNT/ACK_REPEAT_DELAY_MS and repeat ACK sends
- Update README with repeat-ACK behavior
This commit is contained in:
2026-02-04 00:53:06 +01:00
parent 5a86d1bd30
commit 0e7214d606
3 changed files with 14 additions and 4 deletions

View File

@@ -497,10 +497,17 @@ static void send_batch_ack(uint16_t batch_id, uint16_t sender_id) {
write_u16_le(&ack.payload[0], batch_id);
write_u16_le(&ack.payload[2], sender_id);
write_u16_le(&ack.payload[4], g_short_id);
if (SERIAL_DEBUG_MODE) {
serial_debug_printf("ack: tx batch_id=%u to sender=%04X", batch_id, sender_id);
uint8_t repeats = ACK_REPEAT_COUNT == 0 ? 1 : ACK_REPEAT_COUNT;
for (uint8_t i = 0; i < repeats; ++i) {
if (SERIAL_DEBUG_MODE) {
serial_debug_printf("ack: tx repeat %u/%u batch_id=%u", static_cast<unsigned>(i + 1),
static_cast<unsigned>(repeats), batch_id);
}
lora_send(ack);
if (i + 1 < repeats && ACK_REPEAT_DELAY_MS > 0) {
delay(ACK_REPEAT_DELAY_MS);
}
}
lora_send(ack);
lora_receive_continuous();
}
@@ -852,7 +859,7 @@ static void sender_loop() {
if (ack_sender == g_short_id && ack_receiver == ack_pkt.device_id_short &&
g_batch_ack_pending && ack_id == g_last_sent_batch_id) {
g_last_acked_batch_id = ack_id;
serial_debug_printf("ack: ok batch_id=%u", ack_id);
serial_debug_printf("ack: rx ok batch_id=%u", ack_id);
finish_inflight_batch();
} else if (SERIAL_DEBUG_MODE) {
serial_debug_printf("ack: reject batch_id=%u sender=%u receiver=%u exp_batch=%u exp_sender=%u",