diff --git a/features/lorawan/lorastack/mac/LoRaMac.cpp b/features/lorawan/lorastack/mac/LoRaMac.cpp index 6d7ed946bd..de3d45bf3c 100644 --- a/features/lorawan/lorastack/mac/LoRaMac.cpp +++ b/features/lorawan/lorastack/mac/LoRaMac.cpp @@ -1755,9 +1755,7 @@ lorawan_status_t LoRaMac::initialize(EventQueue *queue) _params.timers.mac_init_time = _lora_time.get_current_time(); _params.sys_params.adr_on = MBED_CONF_LORA_ADR_ON; - - _params.is_nwk_public = MBED_CONF_LORA_PUBLIC_NETWORK; - _lora_phy->setup_public_network_mode(MBED_CONF_LORA_PUBLIC_NETWORK); + _params.sys_params.channel_data_rate = _lora_phy->get_default_max_tx_datarate(); return LORAWAN_STATUS_OK; } diff --git a/features/lorawan/lorastack/phy/LoRaPHY.cpp b/features/lorawan/lorastack/phy/LoRaPHY.cpp index f889a09161..5c288c9eb3 100644 --- a/features/lorawan/lorastack/phy/LoRaPHY.cpp +++ b/features/lorawan/lorastack/phy/LoRaPHY.cpp @@ -514,13 +514,16 @@ void LoRaPHY::reset_to_default_values(loramac_protocol_params *params, bool init params->sys_params.channel_tx_power = get_default_tx_power(); - params->sys_params.channel_data_rate = get_default_tx_datarate(); + // We shall always start with highest achievable data rate. + // Subsequent decrease in data rate will mean increase in range henceforth. + params->sys_params.channel_data_rate = get_default_max_tx_datarate(); params->sys_params.rx1_dr_offset = phy_params.default_rx1_dr_offset; params->sys_params.rx2_channel.frequency = get_default_rx2_frequency(); - params->sys_params.rx2_channel.datarate = get_default_rx2_datarate(); + // RX2 data rate should also start from the maximum + params->sys_params.rx2_channel.datarate = get_default_max_tx_datarate(); params->sys_params.uplink_dwell_time = phy_params.ul_dwell_time_setting; @@ -560,6 +563,11 @@ uint8_t LoRaPHY::get_default_tx_datarate() return phy_params.default_datarate; } +uint8_t LoRaPHY::get_default_max_tx_datarate() +{ + return phy_params.default_max_datarate; +} + uint8_t LoRaPHY::get_default_tx_power() { return phy_params.default_tx_power; diff --git a/features/lorawan/lorastack/phy/LoRaPHY.h b/features/lorawan/lorastack/phy/LoRaPHY.h index 2302064b8c..317c616297 100644 --- a/features/lorawan/lorastack/phy/LoRaPHY.h +++ b/features/lorawan/lorastack/phy/LoRaPHY.h @@ -423,6 +423,14 @@ public: */ uint8_t get_default_tx_datarate(); + /** + * @brief get_default_max_tx_datarate Gets the maximum achievable data rate for + * LoRa modulation. This will always be the highest data rate achievable with + * LoRa as defined in the regional specifications. + * @return Maximum achievable data rate with LoRa modulation. + */ + uint8_t get_default_max_tx_datarate(); + /** * @brief get_default_tx_power Gets the default TX power * @return Default TX power