Files
new_kbd/inc/time_manager.h

70 lines
1.9 KiB
C
Raw Permalink Normal View History

#ifndef TIME_MANAGER_H__
#define TIME_MANAGER_H__
#include <stdbool.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
*
* - BLE/USB/
* -
*/
enum time_sync_source {
TIME_SYNC_SOURCE_NONE = 0,
TIME_SYNC_SOURCE_BLE,
TIME_SYNC_SOURCE_USB,
TIME_SYNC_SOURCE_MANUAL,
TIME_SYNC_SOURCE_HID,
};
/*
*
* - utc_ms 使 UTC
* - timezone_min DST
* - accuracy_ms 0
*/
struct time_sync_update {
uint64_t utc_ms;
int16_t timezone_min;
uint32_t accuracy_ms;
enum time_sync_source source;
};
/*
* USB/
* - synchronized=true
* - has_persisted_time=true flash
* - ready=false time_manager settings_loader
*/
struct time_manager_snapshot {
uint64_t utc_ms;
int16_t timezone_min;
uint32_t accuracy_ms;
enum time_sync_source source;
bool ready;
bool synchronized;
bool has_persisted_time;
};
/* 返回当前模块是否已经完成初始化,供同步入口快速拒绝“过早写入”。 */
bool time_manager_is_ready(void);
/*
*
* - 0snapshot
* - -EINVAL
* - -EAGAIN ready
* - -ENODATA
*/
int time_manager_get_snapshot(struct time_manager_snapshot *snapshot);
#ifdef __cplusplus
}
#endif
#endif /* TIME_MANAGER_H__ */