mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #7601 from hasnainvirk/abp_auto_fix
LoRaWAN: Reduced priority for automatic uplinks & higher data rate usage for connection establishmentpull/7727/head
commit
40ff622711
|
@ -605,17 +605,14 @@ void LoRaWANStack::process_transmission(void)
|
|||
_ctrl_flags &= ~TX_DONE_FLAG;
|
||||
tr_debug("Awaiting ACK");
|
||||
_device_current_state = DEVICE_STATE_AWAITING_ACK;
|
||||
return;
|
||||
}
|
||||
|
||||
} else if (_loramac.get_device_class() == CLASS_A) {
|
||||
// Class A unconfirmed message sent, TX_DONE event will be sent to
|
||||
// application when RX2 windows is elapsed, i.e., in process_reception_timeout()
|
||||
_ctrl_flags &= ~TX_ONGOING_FLAG;
|
||||
_ctrl_flags |= TX_DONE_FLAG;
|
||||
|
||||
} else if (_loramac.get_device_class() == CLASS_C) {
|
||||
// In Class C, reception timeout never happens, so we handle the state
|
||||
// progression for TX_DONE in UNCONFIRMED case here
|
||||
if (_loramac.get_device_class() == CLASS_C) {
|
||||
_loramac.post_process_mcps_req();
|
||||
state_controller(DEVICE_STATE_STATUS_CHECK);
|
||||
state_machine_run_to_completion();
|
||||
|
@ -678,9 +675,10 @@ void LoRaWANStack::process_reception(const uint8_t *const payload, uint16_t size
|
|||
state_controller(DEVICE_STATE_STATUS_CHECK);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else if (_loramac.get_device_class() == CLASS_A) {
|
||||
// handle UNCONFIRMED case here, RX slots were turned off due to
|
||||
// valid packet reception
|
||||
// valid packet reception. For Class C, an outgoing UNCONFIRMED message
|
||||
// gets its handling in process_transmission.
|
||||
_loramac.post_process_mcps_req();
|
||||
_ctrl_flags |= TX_DONE_FLAG;
|
||||
state_controller(DEVICE_STATE_STATUS_CHECK);
|
||||
|
@ -814,8 +812,12 @@ void LoRaWANStack::send_event_to_application(const lorawan_event_t event) const
|
|||
|
||||
void LoRaWANStack::send_automatic_uplink_message(const uint8_t port)
|
||||
{
|
||||
// we will silently ignore the automatic uplink event if the user is already
|
||||
// sending something
|
||||
const int16_t ret = handle_tx(port, NULL, 0, MSG_CONFIRMED_FLAG, true, true);
|
||||
if (ret < 0) {
|
||||
if (ret == LORAWAN_STATUS_WOULD_BLOCK) {
|
||||
_automatic_uplink_ongoing = false;
|
||||
} else if (ret < 0) {
|
||||
tr_debug("Failed to generate AUTOMATIC UPLINK, error code = %d", ret);
|
||||
send_event_to_application(AUTOMATIC_UPLINK_ERROR);
|
||||
}
|
||||
|
|
|
@ -164,6 +164,8 @@ void LoRaMac::post_process_mcps_req()
|
|||
if (_params.is_ul_frame_counter_fixed == false) {
|
||||
_params.ul_frame_counter++;
|
||||
}
|
||||
} else {
|
||||
_mcps_confirmation.status = LORAMAC_EVENT_INFO_STATUS_ERROR;
|
||||
}
|
||||
} else {
|
||||
//UNCONFIRMED or PROPRIETARY
|
||||
|
@ -665,7 +667,7 @@ void LoRaMac::on_radio_rx_done(const uint8_t *const payload, uint16_t size,
|
|||
{
|
||||
if (_device_class == CLASS_C && !_continuous_rx2_window_open) {
|
||||
open_rx2_window();
|
||||
} else {
|
||||
} else if (_device_class != CLASS_C){
|
||||
_lora_time.stop(_params.timers.rx_window1_timer);
|
||||
_lora_phy->put_radio_to_sleep();
|
||||
}
|
||||
|
@ -1101,13 +1103,13 @@ lorawan_status_t LoRaMac::schedule_tx()
|
|||
uint8_t dr_offset = _lora_phy->apply_DR_offset(_params.sys_params.channel_data_rate,
|
||||
_params.sys_params.rx1_dr_offset);
|
||||
|
||||
_lora_phy->compute_rx_win_params(dr_offset, _params.sys_params.min_rx_symb,
|
||||
_params.sys_params.max_sys_rx_error,
|
||||
_lora_phy->compute_rx_win_params(dr_offset, MBED_CONF_LORA_DOWNLINK_PREAMBLE_LENGTH,
|
||||
MBED_CONF_LORA_MAX_SYS_RX_ERROR,
|
||||
&_params.rx_window1_config);
|
||||
|
||||
_lora_phy->compute_rx_win_params(_params.sys_params.rx2_channel.datarate,
|
||||
_params.sys_params.min_rx_symb,
|
||||
_params.sys_params.max_sys_rx_error,
|
||||
MBED_CONF_LORA_DOWNLINK_PREAMBLE_LENGTH,
|
||||
MBED_CONF_LORA_MAX_SYS_RX_ERROR,
|
||||
&_params.rx_window2_config);
|
||||
|
||||
if (!_is_nwk_joined) {
|
||||
|
@ -1376,8 +1378,8 @@ void LoRaMac::set_device_class(const device_class_t &device_class,
|
|||
_params.is_node_ack_requested = false;
|
||||
_lora_phy->put_radio_to_sleep();
|
||||
_lora_phy->compute_rx_win_params(_params.sys_params.rx2_channel.datarate,
|
||||
_params.sys_params.min_rx_symb,
|
||||
_params.sys_params.max_sys_rx_error,
|
||||
MBED_CONF_LORA_DOWNLINK_PREAMBLE_LENGTH,
|
||||
MBED_CONF_LORA_MAX_SYS_RX_ERROR,
|
||||
&_params.rx_window2_config);
|
||||
}
|
||||
|
||||
|
@ -1755,9 +1757,6 @@ lorawan_status_t LoRaMac::initialize(EventQueue *queue,
|
|||
_params.timers.aggregated_timeoff = 0;
|
||||
|
||||
_lora_phy->reset_to_default_values(&_params, true);
|
||||
|
||||
_params.sys_params.max_sys_rx_error = 10;
|
||||
_params.sys_params.min_rx_symb = 6;
|
||||
_params.sys_params.retry_num = 1;
|
||||
|
||||
reset_mac_parameters();
|
||||
|
@ -1780,9 +1779,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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -845,7 +853,8 @@ bool LoRaPHY::rx_config(rx_config_params_t *rx_conf)
|
|||
false, rx_conf->is_rx_continuous);
|
||||
} else {
|
||||
modem = MODEM_LORA;
|
||||
_radio->set_rx_config(modem, rx_conf->bandwidth, phy_dr, 1, 0, 8,
|
||||
_radio->set_rx_config(modem, rx_conf->bandwidth, phy_dr, 1, 0,
|
||||
MBED_CONF_LORA_DOWNLINK_PREAMBLE_LENGTH,
|
||||
rx_conf->window_timeout, false, 0, false, 0, 0,
|
||||
true, rx_conf->is_rx_continuous);
|
||||
}
|
||||
|
@ -895,7 +904,8 @@ bool LoRaPHY::tx_config(tx_config_params_t *tx_conf, int8_t *tx_power,
|
|||
3000);
|
||||
} else {
|
||||
modem = MODEM_LORA;
|
||||
_radio->set_tx_config(modem, phy_tx_power, 0, bandwidth, phy_dr, 1, 8,
|
||||
_radio->set_tx_config(modem, phy_tx_power, 0, bandwidth, phy_dr, 1,
|
||||
MBED_CONF_LORA_UPLINK_PREAMBLE_LENGTH,
|
||||
false, true, 0, 0, false, 3000);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
*/
|
||||
#define AS923_DEFAULT_DATARATE DR_2
|
||||
|
||||
#define AS923_DEFAULT_MAX_DATARATE DR_7
|
||||
#define AS923_DEFAULT_MAX_DATARATE DR_5
|
||||
|
||||
/*!
|
||||
* The minimum datarate which is used when the
|
||||
|
|
|
@ -64,6 +64,18 @@
|
|||
"automatic-uplink-message": {
|
||||
"help": "Stack will automatically send an uplink message when lora server requires immediate response",
|
||||
"value": true
|
||||
},
|
||||
"max-sys-rx-error": {
|
||||
"help": "Maximum timing error of the receiver in ms. The receiver will turn on in [-RxError : + RxError]",
|
||||
"value": 10
|
||||
},
|
||||
"downlink-preamble-length": {
|
||||
"help": "Number of preamble symbols need to be captured (out of 8) for successful demodulation",
|
||||
"value": 5
|
||||
},
|
||||
"uplink-preamble-length": {
|
||||
"help": "Number of preamble symbols to transmit. Must be <= 8",
|
||||
"value": 8
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -166,17 +166,6 @@ typedef struct {
|
|||
* The data rate in channels.
|
||||
*/
|
||||
int8_t channel_data_rate;
|
||||
/*!
|
||||
* The system overall timing error in milliseconds.
|
||||
* [-SystemMaxRxError : +SystemMaxRxError]
|
||||
* Default: +/-10 ms
|
||||
*/
|
||||
uint32_t max_sys_rx_error;
|
||||
/*!
|
||||
* The minimum number of symbols required to detect an RX frame.
|
||||
* Default: 6 symbols
|
||||
*/
|
||||
uint8_t min_rx_symb;
|
||||
/*!
|
||||
* LoRaMac maximum time a reception window stays open.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue