diff --git a/include/lorawan.h b/include/lorawan.h index f5790623..6acdb24c 100644 --- a/include/lorawan.h +++ b/include/lorawan.h @@ -22,8 +22,6 @@ #endif extern TaskHandle_t lmicTask, lorasendTask; -extern RTC_NOINIT_ATTR u4_t RTCnetid, RTCdevaddr; -extern RTC_NOINIT_ATTR u1_t RTCnwkKey[16], RTCartKey[16]; // table of LORAWAN MAC commands typedef struct { diff --git a/src/lorawan.cpp b/src/lorawan.cpp index 6bbe0b3e..fe8ffae5 100644 --- a/src/lorawan.cpp +++ b/src/lorawan.cpp @@ -108,6 +108,8 @@ void lora_setupForNetwork(bool preJoin) { getSfName(updr2rps(LMIC.datarate)), getBwName(updr2rps(LMIC.datarate)), getCrName(updr2rps(LMIC.datarate))); + // store LMIC keys and counters in RTC memory + LMIC_getSessionKeys(&RTCnetid, &RTCdevaddr, RTCnwkKey, RTCartKey); } } diff --git a/src/reset.cpp b/src/reset.cpp index 464a514b..0fa965d3 100644 --- a/src/reset.cpp +++ b/src/reset.cpp @@ -11,9 +11,6 @@ RTC_NOINIT_ATTR runmode_t RTC_runmode; void do_reset(bool warmstart) { if (warmstart) { // store LMIC keys and counters in RTC memory -#if (HAS_LORA) - LMIC_getSessionKeys(&RTCnetid, &RTCdevaddr, RTCnwkKey, RTCartKey); -#endif ESP_LOGI(TAG, "restarting device (warmstart), keeping runmode %d", RTC_runmode); } else { @@ -84,11 +81,6 @@ void enter_deepsleep(const int wakeup_sec, const gpio_num_t wakeup_gpio) { esp_sleep_enable_ext1_wakeup(1ULL << wakeup_gpio, ESP_EXT1_WAKEUP_ALL_LOW); } -// store LMIC keys and counters in RTC memory -#if (HAS_LORA) - LMIC_getSessionKeys(&RTCnetid, &RTCdevaddr, RTCnwkKey, RTCartKey); -#endif - // halt interrupts accessing i2c bus mask_user_IRQ();