added timestamp in ISO-8601 format

This commit is contained in:
Bogdan Pilyugin 2024-01-23 14:22:31 +02:00
parent f48de3aa15
commit b1311d8494
2 changed files with 16 additions and 0 deletions

View File

@ -113,6 +113,7 @@ void PrintNetifs(void);
void GotEthIF(void);
void GetRFC3339Time(char *t);
void GetISO8601Time(char *t);
void StartTimeGet(void);
esp_err_t StartOTA(bool isManual);

View File

@ -113,6 +113,21 @@ void GetRFC3339Time(char *t)
timeinfo.tm_sec);
}
void GetISO8601Time(char *t)
{
struct tm timeinfo;
struct timeval tp;
gettimeofday(&tp, NULL);
localtime_r(&tp.tv_sec, &timeinfo);
sprintf(t, "%04d-%02d-%02dT%02d:%02d:%02d.%luZ",
(timeinfo.tm_year) + YEAR_BASE,
(timeinfo.tm_mon) + 1,
timeinfo.tm_mday,
timeinfo.tm_hour,
timeinfo.tm_min,
timeinfo.tm_sec, (unsigned long)tp.tv_usec);
}
void StartSystemTimer(void)
{
ESP_ERROR_CHECK(esp_timer_create(&system_seconds_timer_args, &system_seconds_timer));