Skip to content

Commit dc702c2

Browse files
author
Hasnain Virk
committed
Adding check for ongoing automatic-uplink
Before going after an automatic uplink, we should check if there was an automatic uplink already ongoing, i.e., the ack for the previous automatic uplink cycle has not been received. If there is we shouldn't queue the new automatic uplink and wait for the previous Ack cycle to complete.
1 parent 1fa2589 commit dc702c2

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

features/lorawan/LoRaWANStack.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,8 @@ void LoRaWANStack::process_reception(const uint8_t *const payload, uint16_t size
691691
state_machine_run_to_completion();
692692
}
693693

694-
if (_loramac.get_mlme_indication()->pending) {
694+
// suppress auto uplink if another auto-uplink is in AWAITING_ACK state
695+
if (_loramac.get_mlme_indication()->pending && !_automatic_uplink_ongoing) {
695696
tr_debug("MLME Indication pending");
696697
_loramac.post_process_mlme_ind();
697698
tr_debug("Immediate Uplink requested");
@@ -1027,11 +1028,15 @@ void LoRaWANStack::mcps_indication_handler()
10271028
|| (_loramac.get_device_class() == CLASS_C
10281029
&& mcps_indication->type == MCPS_CONFIRMED)) {
10291030
#if (MBED_CONF_LORA_AUTOMATIC_UPLINK_MESSAGE)
1030-
tr_debug("Sending empty uplink message...");
1031-
_automatic_uplink_ongoing = true;
1032-
const int ret = _queue->call(this, &LoRaWANStack::send_automatic_uplink_message, mcps_indication->port);
1033-
MBED_ASSERT(ret != 0);
1034-
(void)ret;
1031+
// Do not queue an automatic uplink of there is one already outgoing
1032+
// This means we have not received an ack for the previous automatic uplink
1033+
if (!_automatic_uplink_ongoing) {
1034+
tr_debug("Sending empty uplink message...");
1035+
_automatic_uplink_ongoing = true;
1036+
const int ret = _queue->call(this, &LoRaWANStack::send_automatic_uplink_message, mcps_indication->port);
1037+
MBED_ASSERT(ret != 0);
1038+
(void)ret;
1039+
}
10351040
#else
10361041
send_event_to_application(UPLINK_REQUIRED);
10371042
#endif

0 commit comments

Comments
 (0)