Skip to content

Commit 782e470

Browse files
author
Kimmo Vaisanen
committed
Lora: Fix ADRAckReq
This commit fixes two bugs related to ADRAckReq: - adr_ack_counter must be incremented for all uplink messages (not just confirmed) - When ADR_ACK_LIMIT + ADR_ACK_DELAY has been reached, stack decreased used datarate twice.
1 parent 920db63 commit 782e470

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

features/lorawan/lorastack/mac/LoRaMac.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ void LoRaMac::post_process_mcps_req()
163163
_mcps_indication.is_ack_recvd = false;
164164
if (_params.is_ul_frame_counter_fixed == false) {
165165
_params.ul_frame_counter++;
166+
_params.adr_ack_counter++;
166167
}
167168
} else {
168169
_mcps_confirmation.status = LORAMAC_EVENT_INFO_STATUS_ERROR;
@@ -171,6 +172,7 @@ void LoRaMac::post_process_mcps_req()
171172
//UNCONFIRMED or PROPRIETARY
172173
if (_params.is_ul_frame_counter_fixed == false) {
173174
_params.ul_frame_counter++;
175+
_params.adr_ack_counter++;
174176
}
175177
}
176178
}
@@ -269,6 +271,7 @@ void LoRaMac::handle_join_accept_frame(const uint8_t *payload, uint16_t size)
269271
// Node joined successfully
270272
_params.ul_frame_counter = 0;
271273
_params.ul_nb_rep_counter = 0;
274+
_params.adr_ack_counter = 0;
272275

273276
} else {
274277
_mlme_confirmation.status = LORAMAC_EVENT_INFO_STATUS_JOIN_FAIL;
@@ -779,7 +782,6 @@ bool LoRaMac::continue_sending_process()
779782
{
780783
if (_params.ack_timeout_retry_counter > _params.max_ack_timeout_retries) {
781784
_mac_commands.clear_command_buffer();
782-
_params.adr_ack_counter++;
783785
_lora_time.stop(_params.timers.ack_timeout_timer);
784786
return false;
785787
}
@@ -1821,13 +1823,17 @@ uint8_t LoRaMac::get_max_possible_tx_size(uint8_t fopts_len)
18211823
uint8_t max_possible_payload_size = 0;
18221824
uint8_t allowed_frm_payload_size = 0;
18231825

1826+
int8_t datarate = _params.sys_params.channel_data_rate;
1827+
int8_t tx_power = _params.sys_params.channel_tx_power;
1828+
uint32_t adr_ack_counter = _params.adr_ack_counter;
1829+
18241830
if (_params.sys_params.adr_on) {
1825-
_lora_phy->get_next_ADR(false, _params.sys_params.channel_data_rate,
1826-
_params.sys_params.channel_tx_power,
1827-
_params.adr_ack_counter);
1831+
// Just query the information. We do not want to apply them into use
1832+
// at this point.
1833+
_lora_phy->get_next_ADR(false, datarate, tx_power, adr_ack_counter);
18281834
}
18291835

1830-
allowed_frm_payload_size = _lora_phy->get_max_payload(_params.sys_params.channel_data_rate,
1836+
allowed_frm_payload_size = _lora_phy->get_max_payload(datarate,
18311837
_params.is_repeater_supported);
18321838

18331839
if (allowed_frm_payload_size >= fopts_len) {

0 commit comments

Comments
 (0)