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:
15
src/main.cpp
15
src/main.cpp
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user