Skip to content

Commit b0ce443

Browse files
author
Hasnain Virk
committed
Doing away with rx_abort()
rx_abort() was sort of dead code as it was doing essentially nothing. It might have actually meddled with the state machine if it was hit by invoking on_ack_timeout_timer_event(). State machine and corresponding processors now take care of the ack timeout, retries and all other bits, so we don't need abort_rx().
1 parent 375e1b7 commit b0ce443

File tree

3 files changed

+13
-23
lines changed

3 files changed

+13
-23
lines changed

features/lorawan/LoRaWANStack.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,8 +540,8 @@ void LoRaWANStack::process_transmission_timeout()
540540

541541
void LoRaWANStack::process_transmission(void)
542542
{
543-
_loramac.on_radio_tx_done();
544543
tr_debug("Transmission completed");
544+
_loramac.on_radio_tx_done();
545545

546546
make_tx_metadata_available();
547547

features/lorawan/lorastack/mac/LoRaMac.cpp

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -223,15 +223,6 @@ void LoRaMac::on_radio_tx_done(void)
223223
_params.timers.aggregated_last_tx_time = cur_time;
224224
}
225225

226-
void LoRaMac::abort_rx(void)
227-
{
228-
if (_params.is_node_ack_requested) {
229-
const int ret = _ev_queue->call(this, &LoRaMac::on_ack_timeout_timer_event);
230-
MBED_ASSERT(ret != 0);
231-
(void)ret;
232-
}
233-
}
234-
235226
/**
236227
* This part handles incoming frames in response to Radio RX Interrupt
237228
*/
@@ -526,7 +517,6 @@ void LoRaMac::handle_data_frame(const uint8_t* const payload,
526517
if (!is_multicast) {
527518
// We are not the destination of this frame.
528519
_mcps_indication.status = LORAMAC_EVENT_INFO_STATUS_ADDRESS_FAIL;
529-
abort_rx();
530520
return;
531521
}
532522
} else {
@@ -543,13 +533,14 @@ void LoRaMac::handle_data_frame(const uint8_t* const payload,
543533
if (!message_integrity_check(payload, size, &ptr_pos, address,
544534
&downlink_counter, nwk_skey)) {
545535
tr_error("MIC failed");
546-
abort_rx();
547536
return;
548537
}
549538

550539
// message is intended for us and MIC have passed, stop RX2 Window
551540
// Spec: 3.3.4 Receiver Activity during the receive windows
552-
_lora_time.stop(_params.timers.rx_window2_timer);
541+
if (_params.rx_slot == RX_SLOT_WIN_2) {
542+
_lora_time.stop(_params.timers.rx_window2_timer);
543+
}
553544

554545
_mcps_confirmation.ack_received = false;
555546
_mcps_indication.is_ack_recvd = false;
@@ -578,7 +569,6 @@ void LoRaMac::handle_data_frame(const uint8_t* const payload,
578569
_mcps_indication.status = LORAMAC_EVENT_INFO_STATUS_DOWNLINK_REPEATED;
579570
_mcps_indication.dl_frame_counter = downlink_counter;
580571
_mcps_indication.pending = false;
581-
abort_rx();
582572

583573
return;
584574
}
@@ -610,7 +600,7 @@ void LoRaMac::handle_data_frame(const uint8_t* const payload,
610600
tr_debug("Discarding duplicate frame");
611601
_mcps_indication.pending = false;
612602
_mcps_indication.status = LORAMAC_EVENT_INFO_STATUS_DOWNLINK_REPEATED;
613-
abort_rx();
603+
614604
return;
615605
}
616606
}
@@ -663,8 +653,14 @@ void LoRaMac::set_batterylevel_callback(mbed::Callback<uint8_t(void)> battery_le
663653
void LoRaMac::on_radio_rx_done(const uint8_t* const payload, uint16_t size,
664654
int16_t rssi, int8_t snr)
665655
{
666-
// on reception turn off queued timers
667-
_lora_time.stop(_params.timers.rx_window1_timer);
656+
// stop the RX1 timer here if its the first RX slot.
657+
// If the MIC will pass we will stop RX2 timer as well later.
658+
// If its RX2, stop RX2 timer.
659+
if (_params.rx_slot == RX_SLOT_WIN_1) {
660+
_lora_time.stop(_params.timers.rx_window1_timer);
661+
} else if (_params.rx_slot == RX_SLOT_WIN_2) {
662+
_lora_time.stop(_params.timers.rx_window2_timer);
663+
}
668664

669665
if (_device_class == CLASS_C) {
670666
open_rx2_window();
@@ -681,7 +677,6 @@ void LoRaMac::on_radio_rx_done(const uint8_t* const payload, uint16_t size,
681677
case FRAME_TYPE_JOIN_ACCEPT:
682678

683679
if (nwk_joined()) {
684-
abort_rx();
685680
_mlme_confirmation.pending = false;
686681
return;
687682
} else {

features/lorawan/lorastack/mac/LoRaMac.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -471,11 +471,6 @@ class LoRaMac {
471471
rtos::Mutex _mutex;
472472
#endif
473473

474-
/**
475-
* Aborts reception
476-
*/
477-
void abort_rx(void);
478-
479474
/**
480475
* Handles a Join Accept frame
481476
*/

0 commit comments

Comments
 (0)