From dcd0b1a4a155be17960f9a08f731562cf61b6948 Mon Sep 17 00:00:00 2001 From: Thomas Kolb Date: Wed, 1 Jan 2025 14:58:31 +0100 Subject: [PATCH] connection: ensure that tx_request is set on the last packet in a burst --- impl/src/layer2/connection.c | 7 ++++++- impl/test/layer2_over_udp/l2udptest_digipeater.c | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/impl/src/layer2/connection.c b/impl/src/layer2/connection.c index 7915e31..a9879c7 100644 --- a/impl/src/layer2/connection.c +++ b/impl/src/layer2/connection.c @@ -490,8 +490,13 @@ size_t connection_encode_next_packet(connection_ctx_t *ctx, uint8_t *buf, size_t layer2_packet_header_t header = entry->header; header.rx_seq_nr = ctx->next_expected_seq; + header.tx_request = (ctx->next_packet_index == (packet_queue_get_used_space(&ctx->packet_queue) - 1)); + // encode the header - LOG(LVL_DEBUG, "Encoding packet with rx_seq_nr %u, tx_seq_nr %u.", header.rx_seq_nr, header.tx_seq_nr); + LOG(LVL_DEBUG, "Encoding packet with rx_seq_nr %u, tx_seq_nr %u, tx_request = (%u == %u -> %d).", header.rx_seq_nr, header.tx_seq_nr, + ctx->next_packet_index, + packet_queue_get_used_space(&ctx->packet_queue) - 1, + header.tx_request); size_t packet_size = layer2_encode_packet(&header, entry->data, entry->data_len, buf, buf_len); if(packet_size == 0) { diff --git a/impl/test/layer2_over_udp/l2udptest_digipeater.c b/impl/test/layer2_over_udp/l2udptest_digipeater.c index 20e5307..eaa3113 100644 --- a/impl/test/layer2_over_udp/l2udptest_digipeater.c +++ b/impl/test/layer2_over_udp/l2udptest_digipeater.c @@ -233,7 +233,7 @@ int main(void) if(packet_size == 0) { // no more packets available - LOG(LVL_DEBUG, "Ending burst due to empty packet queue."); + LOG(LVL_WARN, "Ending burst without TX Request!"); break; }