64 lines
1.3 KiB
C
64 lines
1.3 KiB
C
#pragma once
|
|
|
|
#include <stdbool.h>
|
|
#include <time.h>
|
|
#include "esp_err.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/**
|
|
* @brief Inicializa o serviço de hora.
|
|
*
|
|
* Responsabilidades do módulo:
|
|
* - definir a timezone local do equipamento
|
|
* - registar handlers dos eventos de rede
|
|
* - arrancar SNTP quando a STA obtém IP
|
|
* - expor o estado atual da sincronização
|
|
*/
|
|
void time_service_init(void);
|
|
|
|
/**
|
|
* @brief Indica se já houve pelo menos uma sincronização SNTP com sucesso.
|
|
*/
|
|
bool time_service_is_synced(void);
|
|
|
|
/**
|
|
* @brief Indica se existe uma tentativa de sincronização em curso.
|
|
*/
|
|
bool time_service_is_sync_in_progress(void);
|
|
|
|
/**
|
|
* @brief Retorna true se a hora atual parece válida.
|
|
*
|
|
* Critério simples: ano >= 2024.
|
|
*/
|
|
bool time_service_has_valid_time(void);
|
|
|
|
/**
|
|
* @brief Força uma nova espera pela sincronização atual.
|
|
*
|
|
* Não reinicializa o SNTP. Apenas lança uma task curta que aguarda pela sync.
|
|
*/
|
|
esp_err_t time_service_force_resync(void);
|
|
|
|
/**
|
|
* @brief Nome IANA da timezone alvo do produto.
|
|
*/
|
|
const char *time_service_get_tz_name(void);
|
|
|
|
/**
|
|
* @brief String POSIX usada por setenv("TZ", ...).
|
|
*/
|
|
const char *time_service_get_tz_posix(void);
|
|
|
|
/**
|
|
* @brief Obtém o epoch atual.
|
|
*/
|
|
time_t time_service_get_epoch(void);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|