diff --git a/include/display.h b/include/display.h index 931b201c..8fb8120f 100644 --- a/include/display.h +++ b/include/display.h @@ -4,6 +4,10 @@ #include "cyclic.h" #include "qrcode.h" +#if (COUNT_ENS) +#include "corona.h" +#endif + #if (HAS_DISPLAY) == 1 #include #elif (HAS_DISPLAY) == 2 diff --git a/include/globals.h b/include/globals.h index 2e4320d5..42c3257e 100644 --- a/include/globals.h +++ b/include/globals.h @@ -60,6 +60,11 @@ ; \ } +// emulate millis to avoid rollovers +#define _millis() esp_timer_get_time() / 1000 +#define _micros() esp_timer_get_time() +#define _seconds() _millis() / 1000.0 + enum sendprio_t { prio_low, prio_normal, prio_high }; enum timesource_t { _gps, _rtc, _lora, _unsynced }; diff --git a/include/macsniff.h b/include/macsniff.h index e216af62..e119d9a3 100644 --- a/include/macsniff.h +++ b/include/macsniff.h @@ -10,6 +10,10 @@ #include "cyclic.h" #include "led.h" +#if (COUNT_ENS) +#include "corona.h" +#endif + #define MAC_SNIFF_WIFI 0 #define MAC_SNIFF_BLE 1 #define MAC_SNIFF_BLE_CWA 2 diff --git a/include/senddata.h b/include/senddata.h index 42686688..dcebb809 100644 --- a/include/senddata.h +++ b/include/senddata.h @@ -8,7 +8,10 @@ #include "lorawan.h" #include "display.h" #include "sdcard.h" + +#if (COUNT_ENS) #include "corona.h" +#endif extern Ticker sendTimer; diff --git a/include/sensor.h b/include/sensor.h index 6e6b837b..322c78a7 100644 --- a/include/sensor.h +++ b/include/sensor.h @@ -1,8 +1,10 @@ #ifndef _SENSOR_H #define _SENSOR_H +#define HAS_SENSORS (HAS_SENSOR_1 || HAS_SENSOR_2 || HAS_SENSOR_3) + uint8_t sensor_mask(uint8_t sensor_no); -uint8_t * sensor_read(uint8_t sensor); +uint8_t *sensor_read(uint8_t sensor); void sensor_init(void); #endif \ No newline at end of file diff --git a/src/bmesensor.cpp b/src/bmesensor.cpp index 4a365d90..7d747c6d 100644 --- a/src/bmesensor.cpp +++ b/src/bmesensor.cpp @@ -228,7 +228,7 @@ void updateState(void) { } else { /* Update every STATE_SAVE_PERIOD minutes */ - if ((stateUpdateCounter * STATE_SAVE_PERIOD) < millis()) { + if ((stateUpdateCounter * STATE_SAVE_PERIOD) < _millis()) { update = true; stateUpdateCounter++; } diff --git a/src/corona.cpp b/src/corona.cpp index 632bff1e..caa4d412 100644 --- a/src/corona.cpp +++ b/src/corona.cpp @@ -49,7 +49,7 @@ bool cwa_init(void) { } void cwa_mac_add(uint16_t hashedmac) { - cwaSeenNotifiers[hashedmac] = millis(); // hash last seen at .... + cwaSeenNotifiers[hashedmac] = _millis(); // hash last seen at .... } #endif diff --git a/src/cyclic.cpp b/src/cyclic.cpp index c57a0863..55cb4497 100644 --- a/src/cyclic.cpp +++ b/src/cyclic.cpp @@ -33,7 +33,10 @@ void doHousekeeping() { } } - // task storage debugging // + // heap and task storage debugging + ESP_LOGD(TAG, "Heap: Free:%d, Min:%d, Size:%d, Alloc:%d, StackHWM:%d", + ESP.getFreeHeap(), ESP.getMinFreeHeap(), ESP.getHeapSize(), + ESP.getMaxAllocHeap(), uxTaskGetStackHighWaterMark(NULL)); ESP_LOGD(TAG, "IRQhandler %d bytes left | Taskstate = %d", uxTaskGetStackHighWaterMark(irqHandlerTask), eTaskGetState(irqHandlerTask)); @@ -130,15 +133,7 @@ void doHousekeeping() { } // doHousekeeping() -// uptime counter 64bit to prevent millis() rollover after 49 days -uint64_t uptime() { - static uint32_t low32, high32; - uint32_t new_low32 = millis(); - if (new_low32 < low32) - high32++; - low32 = new_low32; - return (uint64_t)high32 << 32 | low32; -} +uint64_t uptime() { return _millis(); } uint32_t getFreeRAM() { #ifndef BOARD_HAS_PSRAM diff --git a/src/display.cpp b/src/display.cpp index a29cd974..537f7169 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -67,7 +67,7 @@ void dp_setup(int contrast) { MY_DISPLAY_INVERT, USE_HW_I2C, MY_DISPLAY_SDA, MY_DISPLAY_SCL, MY_DISPLAY_RST, OLED_FREQUENCY); // use standard I2C bus at 400Khz - _ASSERT (rc != OLED_NOT_FOUND); + _ASSERT(rc != OLED_NOT_FOUND); // set display buffer obdSetBackBuffer(&ssoled, displaybuf); @@ -94,7 +94,7 @@ void dp_init(bool verbose) { #if (HAS_DISPLAY) == 1 // i2c // block i2c bus access if (!I2C_MUTEX_LOCK()) - ESP_LOGV(TAG, "[%0.3f] i2c mutex lock failed", millis() / 1000.0); + ESP_LOGV(TAG, "[%0.3f] i2c mutex lock failed", _seconds()); else { #endif @@ -190,7 +190,7 @@ void dp_refresh(bool nextPage) { // block i2c bus access if (!I2C_MUTEX_LOCK()) - ESP_LOGV(TAG, "[%0.3f] i2c mutex lock failed", millis() / 1000.0); + ESP_LOGV(TAG, "[%0.3f] i2c mutex lock failed", _seconds()); else { // set display on/off according to current device configuration if (DisplayIsOn != cfg.screenon) { @@ -265,10 +265,12 @@ void dp_drawPage(time_t t, bool nextpage) { else dp_printf("WIFI:off"); if (cfg.blescan) - if (!cfg.enscount) - dp_printf("BLTH:%-5d", macs_ble); - else +#if (COUNT_ENS) + if (cfg.enscount) dp_printf(" CWA:%-5d", cwa_report()); + else +#endif + dp_printf("BLTH:%-5d", macs_ble); else dp_printf(" BLTH:off"); #elif ((WIFICOUNTER) && (!BLECOUNTER)) @@ -277,11 +279,13 @@ void dp_drawPage(time_t t, bool nextpage) { else dp_printf("WIFI:off"); #elif ((!WIFICOUNTER) && (BLECOUNTER)) - if (cfg.blescan) { + if (cfg.blescan) dp_printf("BLTH:%-5d", macs_ble); - if (cfg.enscount) - dp_printf("(CWA:%d)", cwa_report()); - } else +#if (COUNT_ENS) + if (cfg.enscount) + dp_printf("(CWA:%d)", cwa_report()); + else +#endif dp_printf("BLTH:off"); #else dp_printf("Sniffer disabled"); @@ -596,7 +600,7 @@ void dp_shutdown(void) { #if (HAS_DISPLAY) == 1 // block i2c bus access if (!I2C_MUTEX_LOCK()) - ESP_LOGV(TAG, "[%0.3f] i2c mutex lock failed", millis() / 1000.0); + ESP_LOGV(TAG, "[%0.3f] i2c mutex lock failed", _seconds()); else { cfg.screenon = 0; obdPower(&ssoled, false); diff --git a/src/hal/ecopower.h b/src/hal/ecopower.h index 69a595d3..4b7f7a6f 100644 --- a/src/hal/ecopower.h +++ b/src/hal/ecopower.h @@ -38,7 +38,7 @@ #define RTC_INT GPIO_NUM_0 // // Settings for IF482 interface -#define HAS_IF482 9600, SERIAL_7E1, GPIO_NUM_3, GPIO_NUM_1 // RX, TX +//#define HAS_IF482 9600, SERIAL_7E1, GPIO_NUM_3, GPIO_NUM_1 // RX, TX // Settings for DCF77 interface //#define HAS_DCF77 GPIO_NUM_14 // JP8 #13 diff --git a/src/hal/generic.h b/src/hal/generic.h index 0010f69d..10db27e9 100644 --- a/src/hal/generic.h +++ b/src/hal/generic.h @@ -55,8 +55,10 @@ #define SDS_TX 19 // connect to RX on the SDS011 #define SDS_RX 23 // connect to TX on the SDS011 -// user defined sensors -#define HAS_SENSORS 1 // comment out if device has user defined sensors +// up to three user defined sensors (if connected) +//#define HAS_SENSOR_1 1 // comment out if device has user defined sensor #1 +//#define HAS_SENSOR_2 1 // comment out if device has user defined sensor #2 +//#define HAS_SENSOR_3 1 // comment out if device has user defined sensor #3 #define CFG_sx1276_radio 1 // select LoRa chip //#define CFG_sx1272_radio 1 // select LoRa chip diff --git a/src/hal/lopy4.h b/src/hal/lopy4.h index 4e625dfa..8072dfd0 100644 --- a/src/hal/lopy4.h +++ b/src/hal/lopy4.h @@ -31,18 +31,18 @@ #define HAS_ANTENNA_SWITCH (21) // pin for switching wifi antenna (P12) #define WIFI_ANTENNA 0 // 0 = internal, 1 = external -// uncomment this only if your LoPy runs on a PYTRACK BOARD +// uncomment defines in this section ONLY if your LoPy lives on a PYTRACK BOARD //#define HAS_GPS 1 //#define GPS_I2C GPIO_NUM_25, GPIO_NUM_26 // SDA (P22), SCL (P21) //#define GPS_ADDR 0x10 -// uncomment this only if your LoPy runs on a EXPANSION BOARD -#define HAS_LED (12) // use if LoPy is on Expansion Board, this has a user LED -#define LED_ACTIVE_LOW 1 // use if LoPy is on Expansion Board, this has a user LED -#define HAS_BUTTON (13) // user button on expansion board -#define BUTTON_PULLUP 1 // Button need pullup instead of default pulldown -#define BAT_MEASURE_ADC ADC1_GPIO39_CHANNEL // battery probe GPIO pin -> ADC1_CHANNEL_7 -#define BAT_VOLTAGE_DIVIDER 2 // voltage divider 1MOhm/1MOhm -> expansion board 3.0 +// uncomment defines in this section ONLY if your LoPy lives on a EXPANSION BOARD +//#define HAS_LED (12) // use if LoPy is on Expansion Board, this has a user LED +//#define LED_ACTIVE_LOW 1 // use if LoPy is on Expansion Board, this has a user LED +//#define HAS_BUTTON (13) // user button on expansion board +//#define BUTTON_PULLUP 1 // Button need pullup instead of default pulldown +//#define BAT_MEASURE_ADC ADC1_GPIO39_CHANNEL // battery probe GPIO pin -> ADC1_CHANNEL_7 +//#define BAT_VOLTAGE_DIVIDER 2 // voltage divider 1MOhm/1MOhm -> expansion board 3.0 //#define BAT_VOLTAGE_DIVIDER 4 // voltage divider 115kOhm/56kOhm -> expansion board 2.0 #endif \ No newline at end of file diff --git a/src/hal/m5core.h b/src/hal/m5core.h index 17dc7f22..7a65e40a 100644 --- a/src/hal/m5core.h +++ b/src/hal/m5core.h @@ -25,9 +25,6 @@ #define SDCARD_MISO MISO #define SDCARD_SCLK SCK -// user defined sensors -//#define HAS_SENSORS 1 // comment out if device has user defined sensors - #define CFG_sx1276_radio 1 // select LoRa chip #define DISABLE_BROWNOUT 1 // comment out if you want to keep brownout feature diff --git a/src/hal/m5fire.h b/src/hal/m5fire.h index a35bbb93..8cf4e097 100644 --- a/src/hal/m5fire.h +++ b/src/hal/m5fire.h @@ -28,9 +28,6 @@ #define SDCARD_MISO MISO #define SDCARD_SCLK SCK -// user defined sensors -//#define HAS_SENSORS 1 // comment out if device has user defined sensors - #define CFG_sx1276_radio 1 // select LoRa chip #define BOARD_HAS_PSRAM // use if board has external PSRAM #define DISABLE_BROWNOUT 1 // comment out if you want to keep brownout feature diff --git a/src/hal/octopus32.h b/src/hal/octopus32.h index b040b71f..b7de8b12 100644 --- a/src/hal/octopus32.h +++ b/src/hal/octopus32.h @@ -20,9 +20,6 @@ #define HAS_BME680 GPIO_NUM_23, GPIO_NUM_22 // SDA, SCL #define BME680_ADDR BME680_I2C_ADDR_PRIMARY // connect SDIO of BME680 to GND -// user defined sensors -//#define HAS_SENSORS 1 // comment out if device has user defined sensors - #define HAS_LED 13 // ESP32 GPIO12 (pin22) On Board LED //#define LED_ACTIVE_LOW 1 // Onboard LED is active when pin is LOW //#define HAS_RGB_LED SmartLed rgb_led(LED_WS2812, 1, GPIO_NUM_13) // ESP32 GPIO13 (pin13) On Board Shield WS2812B RGB LED diff --git a/src/hal/ttgobeam.h b/src/hal/ttgobeam.h index 61547adc..76e6ae51 100644 --- a/src/hal/ttgobeam.h +++ b/src/hal/ttgobeam.h @@ -39,9 +39,6 @@ #define MY_DISPLAY_RST NOT_A_PIN //#define MY_DISPLAY_FLIP 1 // use if display is rotated -// user defined sensors (if connected) -//#define HAS_SENSORS 1 // comment out if device has user defined sensors - //#define DISABLE_BROWNOUT 1 // comment out if you want to keep brownout feature #endif diff --git a/src/hal/ttgobeam10.h b/src/hal/ttgobeam10.h index 96238c71..f7cae001 100644 --- a/src/hal/ttgobeam10.h +++ b/src/hal/ttgobeam10.h @@ -52,9 +52,6 @@ Reset -> reset device //#define HAS_BME680 SDA, SCL //#define BME680_ADDR BME680_I2C_ADDR_PRIMARY // !! connect SDIO of BME680 to GND !! -// user defined sensors (if connected) -//#define HAS_SENSORS 1 // comment out if device has user defined sensors - //#define DISABLE_BROWNOUT 1 // comment out if you want to keep brownout feature #endif diff --git a/src/i2c.cpp b/src/i2c.cpp index 69effd3d..dcecc797 100644 --- a/src/i2c.cpp +++ b/src/i2c.cpp @@ -109,7 +109,7 @@ uint8_t i2c_readBytes(uint8_t addr, uint8_t reg, uint8_t *data, uint8_t len) { I2C_MUTEX_UNLOCK(); // release i2c bus access return ret; } else { - ESP_LOGW(TAG, "[%0.3f] i2c mutex lock failed", millis() / 1000.0); + ESP_LOGW(TAG, "[%0.3f] i2c mutex lock failed", _seconds()); return 0xFF; } } @@ -128,7 +128,7 @@ uint8_t i2c_writeBytes(uint8_t addr, uint8_t reg, uint8_t *data, uint8_t len) { I2C_MUTEX_UNLOCK(); // release i2c bus access return ret ? ret : 0xFF; } else { - ESP_LOGW(TAG, "[%0.3f] i2c mutex lock failed", millis() / 1000.0); + ESP_LOGW(TAG, "[%0.3f] i2c mutex lock failed", _seconds()); return 0xFF; } } diff --git a/src/led.cpp b/src/led.cpp index e74e92c6..a0708558 100644 --- a/src/led.cpp +++ b/src/led.cpp @@ -9,7 +9,7 @@ led_states previousLEDState = TaskHandle_t ledLoopTask; uint16_t LEDColor = COLOR_NONE, LEDBlinkDuration = 0; // state machine variables -unsigned long LEDBlinkStarted = 0; // When (in millis() led blink started) +unsigned long LEDBlinkStarted = 0; // When (in _millis() led blink started) #ifdef HAS_RGB_LED @@ -133,7 +133,7 @@ void blink_LED(uint16_t set_color, uint16_t set_blinkduration) { #if (HAS_LED != NOT_A_PIN) || defined(HAS_RGB_LED) LEDColor = set_color; // set color for RGB LED LEDBlinkDuration = set_blinkduration; // duration - LEDBlinkStarted = millis(); // Time Start here + LEDBlinkStarted = _millis(); // Time Start here LEDState = LED_ON; // Let main set LED on #endif } @@ -145,8 +145,8 @@ void ledLoop(void *parameter) { // Custom blink running always have priority other LoRaWAN led // management if (LEDBlinkStarted && LEDBlinkDuration) { - // Custom blink is finished, let this order, avoid millis() overflow - if ((millis() - LEDBlinkStarted) >= LEDBlinkDuration) { + // Custom blink is finished, let this order, avoid _millis() overflow + if ((_millis() - LEDBlinkStarted) >= LEDBlinkDuration) { // Led becomes off, and stop blink LEDState = LED_OFF; LEDBlinkStarted = 0; @@ -165,7 +165,7 @@ void ledLoop(void *parameter) { LEDColor = COLOR_YELLOW; // quick blink 20ms on each 1/5 second LEDState = - ((millis() % 200) < 20) ? LED_ON : LED_OFF; // TX data pending + ((_millis() % 200) < 20) ? LED_ON : LED_OFF; // TX data pending } else if (LMIC.opmode & (OP_TXDATA | OP_TXRXPEND)) { // select color to blink by message port switch (LMIC.pendTxPort) { @@ -180,13 +180,13 @@ void ledLoop(void *parameter) { break; } // small blink 10ms on each 1/2sec (not when joining) - LEDState = ((millis() % 500) < 10) ? LED_ON : LED_OFF; + LEDState = ((_millis() % 500) < 10) ? LED_ON : LED_OFF; // This should not happen so indicate a problem } else if (LMIC.opmode & ((OP_TXDATA | OP_TXRXPEND | OP_JOINING | OP_REJOIN) == 0)) { LEDColor = COLOR_RED; // heartbeat long blink 200ms on each 2 seconds - LEDState = ((millis() % 2000) < 200) ? LED_ON : LED_OFF; + LEDState = ((_millis() % 2000) < 200) ? LED_ON : LED_OFF; } else #endif // HAS_LORA { diff --git a/src/lorawan.cpp b/src/lorawan.cpp index d7567d50..00f92194 100644 --- a/src/lorawan.cpp +++ b/src/lorawan.cpp @@ -540,23 +540,6 @@ void myRxCallback(void *pUserData, uint8_t port, const uint8_t *pMsg, } // switch } -/* -// event EV_TXCOMPLETE message handler -void myTxCallback(void *pUserData, int fSuccess) { - - uint8_t *const pMsg = (uint8_t *)pUserData; - - // LMIC did successful transmit data - if (fSuccess) { - RTCseqnoUp = LMIC.seqnoUp; - RTCseqnoDn = LMIC.seqnoDn; - } else { - // LMIC could not transmit data - // -> error handling yet to come - } -} -*/ - const char *getSfName(rps_t rps) { const char *const t[] = {"FSK", "SF7", "SF8", "SF9", "SF10", "SF11", "SF12", "SF?"}; diff --git a/src/mqttclient.cpp b/src/mqttclient.cpp index 25d7ee04..511f02b5 100644 --- a/src/mqttclient.cpp +++ b/src/mqttclient.cpp @@ -124,7 +124,7 @@ void mqtt_client_task(void *param) { if (mqttClient.connected()) { char buffer[PAYLOAD_BUFFER_SIZE + 3]; - snprintf(buffer, msg.MessageSize + 3, "%s/%u", msg.MessagePort, + snprintf(buffer, msg.MessageSize + 3, "%u/%s", msg.MessagePort, msg.Message); if (mqttClient.publish(MQTT_OUTTOPIC, buffer)) { @@ -174,7 +174,7 @@ void mqtt_enqueuedata(MessageBuffer_t *message) { void mqtt_callback(MQTTClient *client, char topic[], char payload[], int length) { - if (topic == MQTT_INTOPIC) + if (strcmp(topic, MQTT_INTOPIC) == 0) rcommand((const uint8_t *)payload, (const uint8_t)length); } diff --git a/src/ota.cpp b/src/ota.cpp index c256559e..70dea1a0 100644 --- a/src/ota.cpp +++ b/src/ota.cpp @@ -178,9 +178,9 @@ int do_ota_update() { client.print("Cache-Control: no-cache\r\n"); client.print("Connection: close\r\n\r\n"); - unsigned long timeout = millis(); + unsigned long timeout = _millis(); while (client.available() == 0) { - if ((millis() - timeout) > (RESPONSE_TIMEOUT_MS)) { + if ((_millis() - timeout) > (RESPONSE_TIMEOUT_MS)) { ESP_LOGI(TAG, "Client timeout"); ota_display(3, " E", "client timeout"); goto abort; diff --git a/src/sensor.cpp b/src/sensor.cpp index bb34030e..b3f56440 100644 --- a/src/sensor.cpp +++ b/src/sensor.cpp @@ -6,7 +6,6 @@ #include "payload.h" #include "corona.h" #include "macsniff.h" - extern PayloadConvert payload; #endif diff --git a/src/timekeeper.cpp b/src/timekeeper.cpp index 3354b45d..1d4663ab 100644 --- a/src/timekeeper.cpp +++ b/src/timekeeper.cpp @@ -26,7 +26,7 @@ Ticker timesyncer; void setTimeSyncIRQ() { xTaskNotify(irqHandlerTask, TIMESYNC_IRQ, eSetBits); } void calibrateTime(void) { - ESP_LOGD(TAG, "[%0.3f] calibrateTime, timeSource == %d", millis() / 1000.0, + ESP_LOGD(TAG, "[%0.3f] calibrateTime, timeSource == %d", _millis() / 1000.0, timeSource); time_t t = 0; uint16_t t_msec = 0; @@ -85,7 +85,7 @@ void IRAM_ATTR setMyTime(uint32_t t_sec, uint16_t t_msec, vTaskDelay(pdMS_TO_TICKS(1000 - t_msec % 1000)); } - ESP_LOGI(TAG, "[%0.3f] UTC time: %d.%03d sec", millis() / 1000.0, + ESP_LOGI(TAG, "[%0.3f] UTC time: %d.%03d sec", _seconds(), time_to_set, t_msec % 1000); // if we have got an external timesource, set RTC time and shift RTC_INT pulse @@ -106,11 +106,11 @@ void IRAM_ATTR setMyTime(uint32_t t_sec, uint16_t t_msec, timeSource = mytimesource; // set global variable timesyncer.attach(TIME_SYNC_INTERVAL * 60, setTimeSyncIRQ); ESP_LOGD(TAG, "[%0.3f] Timesync finished, time was set | source: %c", - millis() / 1000.0, timeSetSymbols[mytimesource]); + _seconds(), timeSetSymbols[mytimesource]); } else { timesyncer.attach(TIME_SYNC_INTERVAL_RETRY * 60, setTimeSyncIRQ); ESP_LOGD(TAG, "[%0.3f] Timesync failed, invalid time fetched | source: %c", - millis() / 1000.0, timeSetSymbols[mytimesource]); + _seconds(), timeSetSymbols[mytimesource]); } } diff --git a/src/timesync.cpp b/src/timesync.cpp index 4e9e2d1b..bdeea67b 100644 --- a/src/timesync.cpp +++ b/src/timesync.cpp @@ -47,7 +47,7 @@ void timesync_request(void) { // start timesync handshake else { ESP_LOGI(TAG, "[%0.3f] Timeserver sync request started, seqNo#%d", - millis() / 1000.0, time_sync_seqNo); + _seconds(), time_sync_seqNo); xTaskNotifyGive(timeSyncProcTask); // unblock timesync task } } @@ -98,14 +98,14 @@ void IRAM_ATTR timesync_processReq(void *taskparameter) { if (xTaskNotifyWait(0x00, ULONG_MAX, &rcv_seqNo, pdMS_TO_TICKS(TIME_SYNC_TIMEOUT * 1000)) == pdFALSE) { ESP_LOGW(TAG, "[d%0.3f] Timesync aborted: timed out", - millis() / 1000.0); + _seconds()); goto Fail; // no timestamp received before timeout } // check if we are in handshake with server if (rcv_seqNo != time_sync_seqNo) { ESP_LOGW(TAG, "[%0.3f] Timesync aborted: handshake out of sync", - millis() / 1000.0); + _seconds()); goto Fail; } @@ -166,7 +166,7 @@ void IRAM_ATTR timesync_processReq(void *taskparameter) { // store incoming timestamps void timesync_store(uint32_t timestamp, timesync_t timestamp_type) { - ESP_LOGD(TAG, "[%0.3f] seq#%d[%d]: t%d=%d", millis() / 1000.0, + ESP_LOGD(TAG, "[%0.3f] seq#%d[%d]: t%d=%d", _seconds(), time_sync_seqNo, sample_idx, timestamp_type, timestamp); timesync_timestamp[sample_idx][timestamp_type] = timestamp; } @@ -214,10 +214,10 @@ void IRAM_ATTR timesync_serverAnswer(void *pUserData, int flag) { if (flag != TIME_SYNC_FRAME_LENGTH) { if (rcv_seqNo == TIME_SYNC_END_FLAG) ESP_LOGI(TAG, "[%0.3f] Timeserver error: no confident time available", - millis() / 1000.0); + _seconds()); else ESP_LOGW(TAG, "[%0.3f] Timeserver error: spurious data received", - millis() / 1000.0); + _seconds()); goto Exit; // failure } @@ -233,13 +233,13 @@ void IRAM_ATTR timesync_serverAnswer(void *pUserData, int flag) { if (flag != 1) { ESP_LOGW(TAG, "[%0.3f] Network did not answer time request", - millis() / 1000.0); + _seconds()); goto Exit; } // Populate lmic_time_reference if ((LMIC_getNetworkTimeReference(&lmicTime)) != 1) { - ESP_LOGW(TAG, "[%0.3f] Network time request failed", millis() / 1000.0); + ESP_LOGW(TAG, "[%0.3f] Network time request failed", _seconds()); goto Exit; } @@ -267,7 +267,7 @@ Finish: rc = 1; } else { ESP_LOGW(TAG, "[%0.3f] Timeserver error: outdated time received", - millis() / 1000.0); + _seconds()); } Exit: