Skip to content

Commit b0b0261

Browse files
author
Hasnain Virk
committed
[IOTCELL-1181] Using higher data rates to connect
The stack was trying to connect with default data rates which happened to be the lowest data rates in a specific region. In the beginning device and NS do not have agreed upon tx rx parameters and there can be synchronization issues. When we use lower datarates, we may end up having a minute and a half long transmissions that hnot only blocks the channel for a long time but also reduce the chance of proper synch between device and NS. That's why we have decided to begin with higher data rates and gradually decrease datarate if we do not hear from the network server.
1 parent 36a4c55 commit b0b0261

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

features/lorawan/lorastack/mac/LoRaMac.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,9 +1755,7 @@ lorawan_status_t LoRaMac::initialize(EventQueue *queue)
17551755
_params.timers.mac_init_time = _lora_time.get_current_time();
17561756

17571757
_params.sys_params.adr_on = MBED_CONF_LORA_ADR_ON;
1758-
1759-
_params.is_nwk_public = MBED_CONF_LORA_PUBLIC_NETWORK;
1760-
_lora_phy->setup_public_network_mode(MBED_CONF_LORA_PUBLIC_NETWORK);
1758+
_params.sys_params.channel_data_rate = _lora_phy->get_default_max_tx_datarate();
17611759

17621760
return LORAWAN_STATUS_OK;
17631761
}

features/lorawan/lorastack/phy/LoRaPHY.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,13 +514,16 @@ void LoRaPHY::reset_to_default_values(loramac_protocol_params *params, bool init
514514

515515
params->sys_params.channel_tx_power = get_default_tx_power();
516516

517-
params->sys_params.channel_data_rate = get_default_tx_datarate();
517+
// We shall always start with highest achievable data rate.
518+
// Subsequent decrease in data rate will mean increase in range henceforth.
519+
params->sys_params.channel_data_rate = get_default_max_tx_datarate();
518520

519521
params->sys_params.rx1_dr_offset = phy_params.default_rx1_dr_offset;
520522

521523
params->sys_params.rx2_channel.frequency = get_default_rx2_frequency();
522524

523-
params->sys_params.rx2_channel.datarate = get_default_rx2_datarate();
525+
// RX2 data rate should also start from the maximum
526+
params->sys_params.rx2_channel.datarate = get_default_max_tx_datarate();
524527

525528
params->sys_params.uplink_dwell_time = phy_params.ul_dwell_time_setting;
526529

@@ -560,6 +563,11 @@ uint8_t LoRaPHY::get_default_tx_datarate()
560563
return phy_params.default_datarate;
561564
}
562565

566+
uint8_t LoRaPHY::get_default_max_tx_datarate()
567+
{
568+
return phy_params.default_max_datarate;
569+
}
570+
563571
uint8_t LoRaPHY::get_default_tx_power()
564572
{
565573
return phy_params.default_tx_power;

features/lorawan/lorastack/phy/LoRaPHY.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,14 @@ class LoRaPHY : private mbed::NonCopyable<LoRaPHY> {
423423
*/
424424
uint8_t get_default_tx_datarate();
425425

426+
/**
427+
* @brief get_default_max_tx_datarate Gets the maximum achievable data rate for
428+
* LoRa modulation. This will always be the highest data rate achievable with
429+
* LoRa as defined in the regional specifications.
430+
* @return Maximum achievable data rate with LoRa modulation.
431+
*/
432+
uint8_t get_default_max_tx_datarate();
433+
426434
/**
427435
* @brief get_default_tx_power Gets the default TX power
428436
* @return Default TX power

0 commit comments

Comments
 (0)