feat: implement system time synchronization, web server handlers, and clock application components
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
#ifndef SYS_TIME_H
|
||||
#define SYS_TIME_H
|
||||
|
||||
#include <time.h>
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Default Timezone: UK (GMT / BST with Daylight Saving) */
|
||||
#define SYS_TIME_DEFAULT_TZ "GMT0BST,M3.5.0/1,M10.5.0"
|
||||
|
||||
/**
|
||||
* @brief Initialize system time service and load timezone from NVS.
|
||||
*/
|
||||
esp_err_t sys_time_init(void);
|
||||
|
||||
/**
|
||||
* @brief Start SNTP background synchronization over active network.
|
||||
*/
|
||||
void sys_time_start_sntp(void);
|
||||
|
||||
/**
|
||||
* @brief Check whether real-world wall clock has been synchronized.
|
||||
*/
|
||||
bool sys_time_is_synced(void);
|
||||
|
||||
/**
|
||||
* @brief Get current UTC epoch seconds.
|
||||
*/
|
||||
time_t sys_time_get_epoch(void);
|
||||
|
||||
/**
|
||||
* @brief Get breakdown of current local time.
|
||||
* @param[out] out_tm Struct tm filled with current local time.
|
||||
* @return true if time is synchronized, false otherwise.
|
||||
*/
|
||||
bool sys_time_get_local(struct tm *out_tm);
|
||||
|
||||
/**
|
||||
* @brief Set epoch time manually.
|
||||
*/
|
||||
esp_err_t sys_time_set_epoch(time_t epoch_sec);
|
||||
|
||||
/**
|
||||
* @brief Set and persist active timezone string in POSIX format.
|
||||
*/
|
||||
esp_err_t sys_time_set_timezone(const char *tz);
|
||||
|
||||
/**
|
||||
* @brief Get active timezone string.
|
||||
*/
|
||||
const char *sys_time_get_timezone(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // SYS_TIME_H
|
||||
Reference in New Issue
Block a user