From 01a88ac4f77ea59d59d59fb93be11e85f0a79f83 Mon Sep 17 00:00:00 2001 From: Teijo Kinnunen Date: Fri, 16 Aug 2019 12:56:58 +0300 Subject: [PATCH] LoRaWAN: Terminate RX when receiving uplink messages This prevents RX2 window to be enabled at the same time when repeating transmission, when QoS repeated TX is in effect. Failure to do so seems to place the LoRaWAN stack in a state where send() always fails with WOULD_BLOCK error. --- features/lorawan/lorastack/mac/LoRaMac.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/features/lorawan/lorastack/mac/LoRaMac.cpp b/features/lorawan/lorastack/mac/LoRaMac.cpp index b94ebe3596..f7fce18ebc 100644 --- a/features/lorawan/lorastack/mac/LoRaMac.cpp +++ b/features/lorawan/lorastack/mac/LoRaMac.cpp @@ -738,6 +738,15 @@ void LoRaMac::on_radio_rx_done(const uint8_t *const payload, uint16_t size, break; default: + // This can happen e.g. if we happen to receive uplink of another device + // during the receive window. Block RX2 window since it can overlap with + // QOS TX and cause a mess. + tr_debug("RX unexpected mtype %u", mac_hdr.bits.mtype); + if (get_current_slot() == RX_SLOT_WIN_1) { + _lora_time.stop(_params.timers.rx_window2_timer); + } + _mcps_indication.status = LORAMAC_EVENT_INFO_STATUS_ADDRESS_FAIL; + _mcps_indication.pending = false; break; } }