diff --git a/src/ledmatrixdisplay.cpp b/src/ledmatrixdisplay.cpp index ad484e34..3e273731 100644 --- a/src/ledmatrixdisplay.cpp +++ b/src/ledmatrixdisplay.cpp @@ -206,7 +206,7 @@ uint8_t GetCharWidth(char cChar) { } void ScrollMatrixLeft(uint8_t *buf, const uint16_t cols, const uint16_t rows) { - uint32_t i, k, idx; + uint32_t i, k, idx = 0; const uint32_t x = cols / 8; for (k = 0; k < rows; k++) { diff --git a/src/lmic_config.h b/src/lmic_config.h index 4a48283e..9a955dc1 100644 --- a/src/lmic_config.h +++ b/src/lmic_config.h @@ -22,6 +22,12 @@ #define LMIC_USE_INTERRUPTS 1 #endif +// avoid lmic warning if we don't configure radio because we don't have one +#define CFG_sx1276_radio 1 +#if ! (defined(CFG_sx1272_radio) || defined(CFG_sx1276_radio)) +#define CFG_sx1276_radio 1 +#endif + // time sync via LoRaWAN network, note: not supported by TTNv2 #define LMIC_ENABLE_DeviceTimeReq 1 diff --git a/src/lorawan.cpp b/src/lorawan.cpp index 040e9805..6178580d 100644 --- a/src/lorawan.cpp +++ b/src/lorawan.cpp @@ -136,9 +136,9 @@ void RevBytes(unsigned char *b, size_t c) { } // LMIC callback functions -void os_getDevKey(u1_t *buf) { +void os_getDevKey(u1_t *buf) { #ifndef LORA_ABP - memcpy(buf, APPKEY, 16); + memcpy(buf, APPKEY, 16); #endif } @@ -306,30 +306,30 @@ esp_err_t lora_stack_init(bool do_join) { &lmicTask, // task handle 1); // CPU core - #ifdef LORA_ABP - // Pass ABP parameters to LMIC_setSession +#ifdef LORA_ABP + // Pass ABP parameters to LMIC_setSession + LMIC_reset(); + uint8_t appskey[sizeof(APPSKEY)]; + uint8_t nwkskey[sizeof(NWKSKEY)]; + memcpy_P(appskey, APPSKEY, sizeof(APPSKEY)); + memcpy_P(nwkskey, NWKSKEY, sizeof(NWKSKEY)); + LMIC_setSession(NETID, DEVADDR, nwkskey, appskey); + // These parameters are defined as macro in loraconf.h + setABPParamaters(); +#else + // Start join procedure if not already joined, + // lora_setupForNetwork(true) is called by eventhandler when joined + // else continue current session + if (do_join) { + if (!LMIC_startJoining()) + ESP_LOGI(TAG, "Already joined"); + } else { LMIC_reset(); - uint8_t appskey[sizeof(APPSKEY)]; - uint8_t nwkskey[sizeof(NWKSKEY)]; - memcpy_P(appskey, APPSKEY, sizeof(APPSKEY)); - memcpy_P(nwkskey, NWKSKEY, sizeof(NWKSKEY)); - LMIC_setSession (NETID, DEVADDR, nwkskey, appskey); - // These parameters are defined as macro in loraconf.h - setABPParamaters(); - #else - // Start join procedure if not already joined, - // lora_setupForNetwork(true) is called by eventhandler when joined - // else continue current session - if (do_join) { - if (!LMIC_startJoining()) - ESP_LOGI(TAG, "Already joined"); - } else { - LMIC_reset(); - LMIC_setSession(RTCnetid, RTCdevaddr, RTCnwkKey, RTCartKey); - LMIC.seqnoUp = RTCseqnoUp; - LMIC.seqnoDn = RTCseqnoDn; - } - #endif + LMIC_setSession(RTCnetid, RTCdevaddr, RTCnwkKey, RTCartKey); + LMIC.seqnoUp = RTCseqnoUp; + LMIC.seqnoDn = RTCseqnoDn; + } +#endif // start lmic send task xTaskCreatePinnedToCore(lora_send, // task function "lorasendtask", // name of task diff --git a/src/timesync.cpp b/src/timesync.cpp index a44ab138..d0bc4c5d 100644 --- a/src/timesync.cpp +++ b/src/timesync.cpp @@ -170,6 +170,8 @@ void timesync_store(uint32_t timestamp, timesync_t timestamp_type) { // callback function to receive time answer from network or answer void IRAM_ATTR timesync_serverAnswer(void *pUserData, int flag) { +#if (TIME_SYNC_LORASERVER) || (TIME_SYNC_LORAWAN) + // if no timesync handshake is pending then exit if (!timeSyncPending) return; @@ -269,4 +271,6 @@ Exit: // inform processing task xTaskNotify(timeSyncProcTask, (rc ? rcv_seqNo : TIME_SYNC_END_FLAG), eSetBits); + +#endif // (TIME_SYNC_LORASERVER) || (TIME_SYNC_LORAWAN) } \ No newline at end of file