From 1f322d23ebb8fbc7fb61664669a3c2142e50df7c Mon Sep 17 00:00:00 2001 From: Hasnain Virk Date: Fri, 22 Mar 2019 15:12:37 +0200 Subject: [PATCH] Ack timeout must be at least 2 seconds While calculating ack timeout, we were ending up getting a random value which may become less than 2 seconds. This is not allowed as per v1.0.2 specification. To fix the issue we now take the random number from 0 to 2000 ms and then add that to the fixed 2000 ms ack timeout value, guaranteeing a value at least equal to 2000 ms. --- features/lorawan/lorastack/phy/LoRaPHY.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/features/lorawan/lorastack/phy/LoRaPHY.cpp b/features/lorawan/lorastack/phy/LoRaPHY.cpp index eb13ed6949..c13f07d18a 100644 --- a/features/lorawan/lorastack/phy/LoRaPHY.cpp +++ b/features/lorawan/lorastack/phy/LoRaPHY.cpp @@ -630,8 +630,7 @@ uint16_t LoRaPHY::get_maximum_frame_counter_gap() uint32_t LoRaPHY::get_ack_timeout() { uint16_t ack_timeout_rnd = phy_params.ack_timeout_rnd; - return (phy_params.ack_timeout - + get_random(-ack_timeout_rnd, ack_timeout_rnd)); + return (phy_params.ack_timeout + get_random(0, ack_timeout_rnd)); } uint32_t LoRaPHY::get_default_rx2_frequency()