Code: Select all
if(bits & WIFI_CONNECTED_BIT){
sntp_setoperatingmode(SNTP_OPMODE_POLL);
sntp_setservername(0, "pool.ntp.org");
sntp_set_sync_mode(SNTP_SYNC_MODE_IMMED);
sntp_init();
time_t now = 0;
struct tm timeinfo = { 0 };
int retry = 0;
const int retry_count = 10;
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);
}
time(&now);
setenv("TZ", "CET-1CEST-2,M3.5.0/02:00:00,M10.5.0/03:00:00", 1); //TZ environment variable
tzset();
localtime_r(&now, &timeinfo);
wpisz_do_ds3231(0,(uint8_t)timeinfo.tm_sec);
wpisz_do_ds3231(1,(uint8_t)timeinfo.tm_min);
wpisz_do_ds3231(2,(uint8_t)timeinfo.tm_hour);
wpisz_do_ds3231(4,(uint8_t)timeinfo.tm_mday);
wpisz_do_ds3231(5,(uint8_t)timeinfo.tm_mon+1);
wpisz_do_ds3231(6,(uint8_t)timeinfo.tm_year-100);
}
I want to have it at the level of miliseconds.
How to achieve this?