mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-07 03:56:57 +03:00
Rolling 2020-12-02
This commit is contained in:
@@ -48,18 +48,7 @@ std::string gettimestring(const char * frm)
|
||||
time_t now;
|
||||
struct tm timeinfo;
|
||||
time(&now);
|
||||
localtime_r(&now, &timeinfo);
|
||||
// Is time set? If not, tm_year will be (1970 - 1900).
|
||||
if (timeinfo.tm_year < (2016 - 1900)) {
|
||||
ESP_LOGI(TAG, "Reboot - Connecting to WiFi and getting time over NTP.");
|
||||
obtain_time();
|
||||
// update 'now' variable with current time
|
||||
time(&now);
|
||||
}
|
||||
char strftime_buf[64];
|
||||
|
||||
// setenv("TZ", "UTC-2", 1);
|
||||
// tzset();
|
||||
localtime_r(&now, &timeinfo);
|
||||
strftime(strftime_buf, sizeof(strftime_buf), frm, &timeinfo);
|
||||
|
||||
@@ -119,6 +108,8 @@ static void obtain_time(void)
|
||||
struct tm timeinfo = {};
|
||||
int retry = 0;
|
||||
const int retry_count = 10;
|
||||
time(&now);
|
||||
localtime_r(&now, &timeinfo);
|
||||
while (sntp_get_sync_status() == SNTP_SYNC_STATUS_RESET && ++retry < retry_count) {
|
||||
ESP_LOGI(TAG, "Waiting for system time to be set... (%d/%d)", retry, retry_count);
|
||||
vTaskDelay(2000 / portTICK_PERIOD_MS);
|
||||
|
||||
Reference in New Issue
Block a user