Files
smart-oil-heating-control-s…/main/sntp.c
localhorst 260b26023c bugfix/static-code-analysis (#28)
The claude.ai LLM performed a static code analysis.

Reviewed-on: #28
Co-authored-by: localhorst <localhorst@mosad.xyz>
Co-committed-by: localhorst <localhorst@mosad.xyz>
2026-02-14 16:21:32 +01:00

31 lines
717 B
C

#include <time.h>
#include <sys/time.h>
#include <esp_sntp.h>
#include "esp_log.h"
#include "sntp.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;
}