From 36a4c557b7d663e770eedf5727822e45862eed6c Mon Sep 17 00:00:00 2001 From: Hasnain Virk Date: Thu, 26 Jul 2018 11:09:24 +0300 Subject: [PATCH] [IOTCELL-1182] User TX priority over automatic uplinks In the case when an automatic uplink was queued and the user do have something send, we should give priority to user data instead od automatic uplink message. --- features/lorawan/LoRaWANStack.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/features/lorawan/LoRaWANStack.cpp b/features/lorawan/LoRaWANStack.cpp index ece5aed9f8..fabb0895d8 100644 --- a/features/lorawan/LoRaWANStack.cpp +++ b/features/lorawan/LoRaWANStack.cpp @@ -805,8 +805,12 @@ void LoRaWANStack::send_event_to_application(const lorawan_event_t event) const void LoRaWANStack::send_automatic_uplink_message(const uint8_t port) { + // we will silently ignore the automatic uplink event if the user is already + // sending something const int16_t ret = handle_tx(port, NULL, 0, MSG_CONFIRMED_FLAG, true, true); - if (ret < 0) { + if (ret == LORAWAN_STATUS_WOULD_BLOCK) { + _automatic_uplink_ongoing = false; + } else if (ret < 0) { tr_debug("Failed to generate AUTOMATIC UPLINK, error code = %d", ret); send_event_to_application(AUTOMATIC_UPLINK_ERROR); }