From 72727b2911719771edeeec7b5e52515528ef7940 Mon Sep 17 00:00:00 2001 From: Pawel Jalocha Date: Fri, 9 Oct 2020 17:17:44 +0100 Subject: [PATCH] Reset WAN when new key in the parameters --- main/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main/main.cpp b/main/main.cpp index bc09427..a83e6c9 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -66,9 +66,9 @@ void app_main(void) WANdev.Reset(getUniqueID(), Parameters.AppKey); // set default LoRaWAN config. if(WANdev.ReadFromNVS()!=ESP_OK) // if can't read the LoRaWAN setup from NVS { WANdev.WriteToNVS(); } // then store the default - // if(memcmp(WANdev.AppKey, Parameters.AppKey, 16)) // if LoRaWAN key different from the one in Parameters - // { WANdev.Reset(getUniqueID(), Parameters.AppKey); // then reset LoRaWAN to this key - // WANdev.WriteToNVS(); } // and save LoRaWAN config. to NVS + if(WANdev.State<2 && memcmp(WANdev.AppKey, Parameters.AppKey, 16)) // if LoRaWAN key different from the one in Parameters + { WANdev.Reset(getUniqueID(), Parameters.AppKey); // then reset LoRaWAN to this key + WANdev.WriteToNVS(); } // and save LoRaWAN config. to NVS #endif CONS_UART_SetBaudrate(Parameters.CONbaud);