Skip to content

Commit 5bfa7c0

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 76814d4 commit 5bfa7c0

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
@@ -692,7 +692,8 @@ void LoRaWANStack::process_reception(const uint8_t *const payload, uint16_t size
692692
state_machine_run_to_completion();
693693
}
694694

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

0 commit comments

Comments
 (0)