Files
smart-oil-heating-control-s…/main/sntp.c
T
localhorst 085f5b4acb Relocate the configuration values (#29)
closes #24

Reviewed-on: #29
Co-authored-by: localhorst <localhorst@mosad.xyz>
Co-committed-by: localhorst <localhorst@mosad.xyz>
2026-05-10 11:12:18 +02:00

32 lines
718 B
C

#include "sntp.h"
#include "esp_sntp.h"
#include "esp_log.h"
#include <time.h>
#include <sys/time.h>
static const char *TAG = "smart-oil-heater-control-system-sntp";
static volatile eSntpState sntpState = SYNC_NOT_STARTED;
void time_sync_notification_cb(struct timeval *tv);
void initSntp(void)
{
esp_sntp_setoperatingmode(SNTP_OPMODE_POLL);
esp_sntp_setservername(0, CONFIG_SNTP_SERVER_IP_ADDR);
sntp_set_time_sync_notification_cb(time_sync_notification_cb);
esp_sntp_init();
}
eSntpState getSntpState(void)
{
return sntpState;
}
void time_sync_notification_cb(struct timeval *tv)
{
ESP_LOGI(TAG, "SNTP synchronization! Unix Time: %lld", tv->tv_sec);
sntpState = SYNC_SUCCESSFUL;
}