Skip to content

Commit 2691b83

Browse files
author
Hasnain Virk
committed
Fixing premature RX2 abort
A bug while setting up RX start timers would result in premature closusre of RX2 window. The 'ack_Timeout_timer' would be invoked prematurely and at that time RX2 window may be being demodulating. This resulted in massive instability with any test that relied on Confirmed traffic or lower data rates. To fix the issue, we must know the length of the RX window in milliseconds and for this purpose we have extended the 'get_rx_window_params(...)' API. The length of the time the window may remain open must be accounted for while setting up 'ack_timeout_timer'.
1 parent 2618813 commit 2691b83

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed

features/lorawan/lorastack/mac/LoRaMac.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -667,13 +667,14 @@ void LoRaMac::on_radio_tx_done(lorawan_time_t timestamp)
667667
if (get_device_class() == CLASS_C) {
668668
_lora_time.start(_rx2_closure_timer_for_class_c,
669669
(_params.rx_window2_delay - time_diff) +
670-
_params.rx_window2_config.window_timeout);
670+
_params.rx_window2_config.window_timeout_ms);
671671
}
672672

673673
// start timer after which ack wait will timeout (for Confirmed messages)
674674
if (_params.is_node_ack_requested) {
675675
_lora_time.start(_params.timers.ack_timeout_timer,
676676
(_params.rx_window2_delay - time_diff) +
677+
_params.rx_window2_config.window_timeout_ms +
677678
_lora_phy->get_ack_timeout());
678679
}
679680
} else {
@@ -1097,6 +1098,8 @@ lorawan_status_t LoRaMac::schedule_tx()
10971098
{
10981099
channel_selection_params_t next_channel;
10991100
lorawan_time_t backoff_time = 0;
1101+
lorawan_time_t aggregated_timeoff = 0;
1102+
uint8_t channel = 0;
11001103
uint8_t fopts_len = 0;
11011104

11021105
if (_params.sys_params.max_duty_cycle == 255) {
@@ -1122,9 +1125,12 @@ lorawan_status_t LoRaMac::schedule_tx()
11221125
next_channel.last_aggregate_tx_time = _params.timers.aggregated_last_tx_time;
11231126

11241127
lorawan_status_t status = _lora_phy->set_next_channel(&next_channel,
1125-
&_params.channel,
1128+
&channel,
11261129
&backoff_time,
1127-
&_params.timers.aggregated_timeoff);
1130+
&aggregated_timeoff);
1131+
1132+
_params.channel = channel;
1133+
_params.timers.aggregated_timeoff = aggregated_timeoff;
11281134

11291135
switch (status) {
11301136
case LORAWAN_STATUS_NO_CHANNEL_FOUND:

features/lorawan/lorastack/phy/LoRaPHY.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,8 @@ float LoRaPHY::compute_symb_timeout_fsk(uint8_t phy_dr)
406406

407407
void LoRaPHY::get_rx_window_params(float t_symb, uint8_t min_rx_symb,
408408
float error_fudge, float wakeup_time,
409-
uint32_t *window_length, int32_t *window_offset,
409+
uint32_t *window_length, uint32_t *window_length_ms,
410+
int32_t *window_offset,
410411
uint8_t phy_dr)
411412
{
412413
float target_rx_window_offset;
@@ -442,6 +443,7 @@ void LoRaPHY::get_rx_window_params(float t_symb, uint8_t min_rx_symb,
442443
// Setting the window_length in terms of 'symbols' for LoRa modulation or
443444
// in terms of 'bytes' for FSK
444445
*window_length = (uint32_t) ceil(window_len_in_ms / t_symb);
446+
*window_length_ms = window_len_in_ms;
445447
}
446448

447449
int8_t LoRaPHY::compute_tx_power(int8_t tx_power_idx, float max_eirp,
@@ -848,7 +850,8 @@ void LoRaPHY::compute_rx_win_params(int8_t datarate, uint8_t min_rx_symbols,
848850
}
849851

850852
get_rx_window_params(t_symbol, min_rx_symbols, (float) rx_error, MBED_CONF_LORA_WAKEUP_TIME,
851-
&rx_conf_params->window_timeout, &rx_conf_params->window_offset,
853+
&rx_conf_params->window_timeout, &rx_conf_params->window_timeout_ms,
854+
&rx_conf_params->window_offset,
852855
rx_conf_params->datarate);
853856
}
854857

features/lorawan/lorastack/phy/LoRaPHY.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,8 @@ class LoRaPHY : private mbed::NonCopyable<LoRaPHY> {
626626
*/
627627
void get_rx_window_params(float t_symbol, uint8_t min_rx_symbols,
628628
float rx_error, float wakeup_time,
629-
uint32_t *window_length, int32_t *window_offset,
629+
uint32_t *window_length, uint32_t *window_length_ms,
630+
int32_t *window_offset,
630631
uint8_t phy_dr);
631632

632633
/**

features/lorawan/system/lorawan_data_structures.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,9 +1007,13 @@ typedef struct {
10071007
*/
10081008
uint32_t frequency;
10091009
/*!
1010-
* The RX window timeout
1010+
* The RX window timeout - Symbols
10111011
*/
10121012
uint32_t window_timeout;
1013+
/*!
1014+
* The RX window timeout - Milliseconds
1015+
*/
1016+
uint32_t window_timeout_ms;
10131017
/*!
10141018
* The RX window offset
10151019
*/

0 commit comments

Comments
 (0)