From 76d01f5c7192943eb40da8596a4211d289ddb669 Mon Sep 17 00:00:00 2001 From: Kimmo Vaisanen Date: Mon, 13 Aug 2018 12:41:01 +0300 Subject: [PATCH] LoRa: Fix MAC initialization for connection with parameters LoRaMAC was not initialized properly if application called connect(const lorawan_connect_t &connect); This causes problems for example in case where application first disconnects and then reconnects as counter values are not initialized. --- features/lorawan/lorastack/mac/LoRaMac.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/features/lorawan/lorastack/mac/LoRaMac.cpp b/features/lorawan/lorastack/mac/LoRaMac.cpp index 833f7ccc72..dc3159ddc9 100644 --- a/features/lorawan/lorastack/mac/LoRaMac.cpp +++ b/features/lorawan/lorastack/mac/LoRaMac.cpp @@ -1419,6 +1419,11 @@ lorawan_status_t LoRaMac::prepare_join(const lorawan_connect_t *params, bool is_ } // Reset variable JoinRequestTrials _params.join_request_trial_counter = 0; + + reset_mac_parameters(); + + _params.sys_params.channel_data_rate = + _lora_phy->get_alternate_DR(_params.join_request_trial_counter + 1); } else { if ((params->connection_u.abp.dev_addr == 0) || (params->connection_u.abp.nwk_id == 0)