From a9e10765729f75eeeee2d6d4ded0a7ab55330355 Mon Sep 17 00:00:00 2001 From: Kimmo Vaisanen Date: Mon, 19 Feb 2018 08:42:43 +0200 Subject: [PATCH] Bug fix in RX timeout and RX error handling for class c nodes. 1. Do not stop the 2nd window timer, as it is not running. 2. Wait for the OnAckTimeout event, before setting MacDone 3. Process for class c also the 2nd window timeout part, as we do not have a 2nd window timer. --- features/lorawan/lorastack/mac/LoRaMac.cpp | 29 +++++++++++++++------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/features/lorawan/lorastack/mac/LoRaMac.cpp b/features/lorawan/lorastack/mac/LoRaMac.cpp index 6b6741c593..e8eda9000a 100644 --- a/features/lorawan/lorastack/mac/LoRaMac.cpp +++ b/features/lorawan/lorastack/mac/LoRaMac.cpp @@ -733,12 +733,17 @@ void LoRaMac::on_radio_rx_error( void ) mlme.get_confirmation().status = LORAMAC_EVENT_INFO_STATUS_RX1_ERROR; - if (_lora_time.get_elapsed_time(_params.timers.aggregated_last_tx_time) >= _params.rx_window2_delay) { - _lora_time.stop(_params.timers.rx_window2_timer); - _params.flags.bits.mac_done = 1; + if (_params.dev_class != CLASS_C) { + if (_lora_time.get_elapsed_time(_params.timers.aggregated_last_tx_time) >= _params.rx_window2_delay) { + _lora_time.stop(_params.timers.rx_window2_timer); + _params.flags.bits.mac_done = 1; + } } - - } else { + } + if ((rx_slot == RX_SLOT_WIN_2) || (_params.dev_class == CLASS_C)) { + // We need to process this case if the MAC is in class A or B for the 2nd RX window timeout. + // If the MAC is in class C, we need to process this part also for the 1st RX window timeout, + // as the 2nd window timer is not running. if (_params.is_node_ack_requested == true) { mcps.get_confirmation().status = LORAMAC_EVENT_INFO_STATUS_RX2_ERROR; @@ -768,12 +773,18 @@ void LoRaMac::on_radio_rx_timeout(void) } mlme.get_confirmation().status = LORAMAC_EVENT_INFO_STATUS_RX1_TIMEOUT; - if (_lora_time.get_elapsed_time(_params.timers.aggregated_last_tx_time ) >= _params.rx_window2_delay) { - _lora_time.stop(_params.timers.rx_window2_timer); - _params.flags.bits.mac_done = 1; + if (_params.dev_class != CLASS_C) { + if (_lora_time.get_elapsed_time(_params.timers.aggregated_last_tx_time ) >= _params.rx_window2_delay) { + _lora_time.stop(_params.timers.rx_window2_timer); + _params.flags.bits.mac_done = 1; + } } + } - } else { + if ((rx_slot == RX_SLOT_WIN_2) || (_params.dev_class == CLASS_C)) { + // We need to process this case if the MAC is in class A or B for the 2nd RX window timeout. + // If the MAC is in class C, we need to process this part also for the 1st RX window timeout, + // as the 2nd window timer is not running. if (_params.is_node_ack_requested == true) { mcps.get_confirmation().status = LORAMAC_EVENT_INFO_STATUS_RX2_TIMEOUT;