From 4e2003d8ea16d2696ca464f6f102560b3e310603 Mon Sep 17 00:00:00 2001 From: Shawn Nock Date: Fri, 2 Aug 2019 15:41:42 -0400 Subject: [PATCH] Fixes a bug where last_seen_seq was taken from unreliable packets --- src/main.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main.c b/src/main.c index 0dbfad5..19b7077 100644 --- a/src/main.c +++ b/src/main.c @@ -588,15 +588,14 @@ static void unproc_thread(void) { goto next; } - u8_t expected_seq = next_seq(h5.last_seen_seq_from_host); - if (hdr.is_reliable && hdr.seq != expected_seq) { - LOG_ERR("Seq expected %u got %u. Drop packet", expected_seq, hdr.seq); - net_buf_unref(rx_buf); - goto next; - } - h5.last_seen_seq_from_host = hdr.seq; - - if (hdr.is_reliable) { + if (hdr.is_reliable) { + u8_t expected_seq = next_seq(h5.last_seen_seq_from_host); + if (hdr.seq != expected_seq) { + LOG_ERR("Seq expected %u got %u. Drop packet", expected_seq, hdr.seq); + net_buf_unref(rx_buf); + goto next; + } + h5.last_seen_seq_from_host = hdr.seq; /* Submit delayed work to ack the packet */ k_delayed_work_submit(&ack_work, H5_RX_ACK_TIMEOUT); }