added SetSystemTime() function

This commit is contained in:
Bogdan Pilyugin 2024-04-24 12:45:37 +02:00
parent 3a7bf2a635
commit 78dbc8e917
2 changed files with 9 additions and 0 deletions

View File

@ -117,6 +117,7 @@ void GotEthIF(void);
void GetRFC3339Time(char *t);
void GetISO8601Time(char *t);
void StartTimeGet(void);
void SetSystemTime(struct tm *time, const char* source);
esp_err_t StartOTA(bool isManual);
char* GetAvailVersion();

View File

@ -134,6 +134,14 @@ void StartSystemTimer(void)
ESP_ERROR_CHECK(esp_timer_start_periodic(system_seconds_timer, 1000000));
}
void SetSystemTime(struct tm *time, const char* source)
{
time_t t = mktime(time);
ESP_LOGI("SNTP","Setting time: %s from thq source %s", asctime(time), source);
struct timeval now = { .tv_sec = t };
settimeofday(&now, NULL);
}
void SecondTickSystem(void *param)
{
++UpTime;