Managing Confirmed traffic based on NbTrans

In 1.1, NbTrans governs both unconfirmed and confirmed traffic.
We cannot set number of retries ourselves. Based upon NbTrans received
in linkADRReq command, we will retry. If NbTrans is 1, we will send only
one message and if ack is not received we will generate TX error event.
Its the NS now which controls how many retransmission a device can do
without incrementing Frame counter. When we fail with TX error after not
receiving an ack, we increment the frame counter. This is necessary as
the NS will drop anything with the  previous counter and it can happen
that the NS may have sent an ack but we didn't receive it.
feature-lorawan-1-1
Hasnain Virk 2018-10-21 20:59:00 +03:00 committed by Antti Kauppila
parent 749b3d459c
commit 341b5e1566
1 changed files with 13 additions and 6 deletions

View File

@ -155,6 +155,10 @@ void LoRaMac::post_process_mcps_req()
_mcps_confirmation.ack_received = false;
_mcps_indication.is_ack_recvd = false;
} else {
if (_params.server_type == LW1_1) {
// because network server will not accept un-incremented fcnt
_params.ul_frame_counter++;
}
_mcps_confirmation.status = LORAMAC_EVENT_INFO_STATUS_ERROR;
}
@ -567,7 +571,7 @@ void LoRaMac::handle_data_frame(const uint8_t *const payload,
multicast_params_t *cur_multicast_params;
uint32_t address = 0;
uint32_t downlink_counter = 0;
seq_counter_type_t cnt_type;
seq_counter_type_t cnt_type = NFCNT_DOWN;
uint8_t *nwk_skey = _params.keys.nwk_skey;
uint8_t *mic_key = _params.keys.nwk_skey;
uint8_t *app_skey = _params.keys.app_skey;
@ -954,7 +958,7 @@ bool LoRaMac::continue_joining_process()
bool LoRaMac::continue_sending_process()
{
if (_params.ack_timeout_retry_counter > _params.max_ack_timeout_retries) {
if (_params.ack_timeout_retry_counter >= _params.max_ack_timeout_retries) {
_lora_time.stop(_params.timers.ack_timeout_timer);
return false;
}
@ -1323,7 +1327,6 @@ lorawan_status_t LoRaMac::schedule_tx()
tr_debug("TX: Channel=%d, TX DR=%d, RX1 DR=%d",
_params.channel, _params.sys_params.channel_data_rate, rx1_dr);
_lora_phy->compute_rx_win_params(rx1_dr, MBED_CONF_LORA_DOWNLINK_PREAMBLE_LENGTH,
MBED_CONF_LORA_MAX_SYS_RX_ERROR,
&_params.rx_window1_config);
@ -1517,7 +1520,7 @@ int16_t LoRaMac::prepare_ongoing_tx(const uint8_t port,
if (flags & MSG_PROPRIETARY_FLAG) {
_ongoing_tx_msg.type = MCPS_PROPRIETARY;
_ongoing_tx_msg.fport = port;
_ongoing_tx_msg.nb_trials = _params.sys_params.nb_trans;
_ongoing_tx_msg.nb_trials = _params.sys_params.nb_trans > 0 ? _params.sys_params.nb_trans : 1;
// a proprietary frame only includes an MHDR field which contains MTYPE field.
// Everything else is at the discretion of the implementer
fopts_len = 0;
@ -1572,7 +1575,11 @@ lorawan_status_t LoRaMac::send_ongoing_tx()
machdr.bits.mtype = FRAME_TYPE_DATA_UNCONFIRMED_UP;
} else if (_ongoing_tx_msg.type == MCPS_CONFIRMED) {
machdr.bits.mtype = FRAME_TYPE_DATA_CONFIRMED_UP;
if (_params.server_type == LW1_1) {
_params.max_ack_timeout_retries = _params.sys_params.nb_trans;
} else {
_params.max_ack_timeout_retries = _ongoing_tx_msg.nb_trials;
}
} else if (_ongoing_tx_msg.type == MCPS_PROPRIETARY) {
machdr.bits.mtype = FRAME_TYPE_PROPRIETARY;
} else {
@ -2332,7 +2339,7 @@ lorawan_status_t LoRaMac::calculate_userdata_mic()
if (_params.is_srv_ack_requested) {
args = _params.counterForAck;
}
args |= _params.sys_params.channel_data_rate << 16;
args |= ((uint8_t) _params.sys_params.channel_data_rate) << 16;
args |= _params.channel << 24;
if (0 != _lora_crypto.compute_mic(_params.tx_buffer, _params.tx_buffer_len,