Skip to content

Commit d76f6c0

Browse files
author
Hasnain Virk
committed
Making recv timing error and preamble length configurable
We had a bug especially in the reception path. Our recv window opening delays were being calculated on the premise that the radio has to capture 5 preamble symbols out of 8 transmitted by the base station. However, in PHY layer while setting radio rc settings, we were setting preamble length to be 8. Preamble length register needs to be configured differently for Uplink and Downlink. For uplink, we wish to transmit 8 preamble symbols whereas in the reception path we need to receive 5 preamble symbols at least out of 8. Alongwith that the maximum range of timing error may vary from platform to platform as it is based upon the crystal in the chip. We have now made these parameters configurable and have loaded them with the most optimal defaults.
1 parent 24c5c58 commit d76f6c0

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

features/lorawan/lorastack/mac/LoRaMac.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,13 +1080,13 @@ lorawan_status_t LoRaMac::schedule_tx()
10801080
uint8_t dr_offset = _lora_phy->apply_DR_offset(_params.sys_params.channel_data_rate,
10811081
_params.sys_params.rx1_dr_offset);
10821082

1083-
_lora_phy->compute_rx_win_params(dr_offset, _params.sys_params.min_rx_symb,
1084-
_params.sys_params.max_sys_rx_error,
1083+
_lora_phy->compute_rx_win_params(dr_offset, MBED_CONF_LORA_DOWNLINK_PREAMBLE_LENGTH,
1084+
MBED_CONF_LORA_MAX_SYS_RX_ERROR,
10851085
&_params.rx_window1_config);
10861086

10871087
_lora_phy->compute_rx_win_params(_params.sys_params.rx2_channel.datarate,
1088-
_params.sys_params.min_rx_symb,
1089-
_params.sys_params.max_sys_rx_error,
1088+
MBED_CONF_LORA_DOWNLINK_PREAMBLE_LENGTH,
1089+
MBED_CONF_LORA_MAX_SYS_RX_ERROR,
10901090
&_params.rx_window2_config);
10911091

10921092
if (!_is_nwk_joined) {
@@ -1355,8 +1355,8 @@ void LoRaMac::set_device_class(const device_class_t &device_class,
13551355
_params.is_node_ack_requested = false;
13561356
_lora_phy->put_radio_to_sleep();
13571357
_lora_phy->compute_rx_win_params(_params.sys_params.rx2_channel.datarate,
1358-
_params.sys_params.min_rx_symb,
1359-
_params.sys_params.max_sys_rx_error,
1358+
MBED_CONF_LORA_DOWNLINK_PREAMBLE_LENGTH,
1359+
MBED_CONF_LORA_MAX_SYS_RX_ERROR,
13601360
&_params.rx_window2_config);
13611361
}
13621362

@@ -1732,9 +1732,6 @@ lorawan_status_t LoRaMac::initialize(EventQueue *queue)
17321732
_params.timers.aggregated_timeoff = 0;
17331733

17341734
_lora_phy->reset_to_default_values(&_params, true);
1735-
1736-
_params.sys_params.max_sys_rx_error = 10;
1737-
_params.sys_params.min_rx_symb = 6;
17381735
_params.sys_params.retry_num = 1;
17391736

17401737
reset_mac_parameters();

features/lorawan/lorastack/phy/LoRaPHY.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,8 @@ bool LoRaPHY::rx_config(rx_config_params_t *rx_conf)
853853
false, rx_conf->is_rx_continuous);
854854
} else {
855855
modem = MODEM_LORA;
856-
_radio->set_rx_config(modem, rx_conf->bandwidth, phy_dr, 1, 0, 8,
856+
_radio->set_rx_config(modem, rx_conf->bandwidth, phy_dr, 1, 0,
857+
MBED_CONF_LORA_DOWNLINK_PREAMBLE_LENGTH,
857858
rx_conf->window_timeout, false, 0, false, 0, 0,
858859
true, rx_conf->is_rx_continuous);
859860
}
@@ -903,7 +904,8 @@ bool LoRaPHY::tx_config(tx_config_params_t *tx_conf, int8_t *tx_power,
903904
3000);
904905
} else {
905906
modem = MODEM_LORA;
906-
_radio->set_tx_config(modem, phy_tx_power, 0, bandwidth, phy_dr, 1, 8,
907+
_radio->set_tx_config(modem, phy_tx_power, 0, bandwidth, phy_dr, 1,
908+
MBED_CONF_LORA_UPLINK_PREAMBLE_LENGTH,
907909
false, true, 0, 0, false, 3000);
908910
}
909911

features/lorawan/mbed_lib.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,18 @@
6464
"automatic-uplink-message": {
6565
"help": "Stack will automatically send an uplink message when lora server requires immediate response",
6666
"value": true
67+
},
68+
"max-sys-rx-error": {
69+
"help": "Maximum timing error of the receiver in ms. The receiver will turn on in [-RxError : + RxError]",
70+
"value": 10
71+
},
72+
"downlink-preamble-length": {
73+
"help": "Number of preamble symbols need to be captured (out of 8) for successful demodulation",
74+
"value": 5
75+
},
76+
"uplink-preamble-length": {
77+
"help": "Number of preamble symbols to transmit. Must be <= 8",
78+
"value": 8
6779
}
6880
}
6981
}

features/lorawan/system/lorawan_data_structures.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -166,17 +166,6 @@ typedef struct {
166166
* The data rate in channels.
167167
*/
168168
int8_t channel_data_rate;
169-
/*!
170-
* The system overall timing error in milliseconds.
171-
* [-SystemMaxRxError : +SystemMaxRxError]
172-
* Default: +/-10 ms
173-
*/
174-
uint32_t max_sys_rx_error;
175-
/*!
176-
* The minimum number of symbols required to detect an RX frame.
177-
* Default: 6 symbols
178-
*/
179-
uint8_t min_rx_symb;
180169
/*!
181170
* LoRaMac maximum time a reception window stays open.
182171
*/

0 commit comments

Comments
 (0)