T-Box Basic dev
Loading...
Searching...
No Matches
sys_time.h
Go to the documentation of this file.
1
10#ifndef SYS_TIME_H
11#define SYS_TIME_H
12
13#ifdef __cplusplus
14extern "C"
15{
16#endif
17
18#include "tbox/time.h"
19
20/* NTP 服务器配置 */
21#define SYS_TIME_NTP_SERVER_KEY1 "ro.time.ntp1"
22#define SYS_TIME_NTP_SERVER_KEY2 "ro.time.ntp2"
23#define SYS_TIME_NTP_SERVER_KEY3 "ro.time.ntp3"
24#define SYS_TIME_NTP_SERVER_DFT_VAL1 "ntp.shu.edu.cn"
25#define SYS_TIME_NTP_SERVER_DFT_VAL2 "ntp1.aliyun.com"
26#define SYS_TIME_NTP_SERVER_DFT_VAL3 "ntp2.aliyun.com"
27#define SYS_TIME_NTP_SERVER_ID_1 "ntp1"
28#define SYS_TIME_NTP_SERVER_ID_2 "ntp2"
29#define SYS_TIME_NTP_SERVER_ID_3 "ntp3"
30#define SYS_TIME_ZONE_KEY "ro.time.timezone"
31#define SYS_TIME_ZONE_DEFAULT "+08:00" /* 默认时区:东八区 */
32#define SYS_TIME_ZONE_LEN 16 /* 时区字符串长度,如 "+08:00" */
33
34/* 时间校准来源 */
35typedef enum
36{
37 SYS_TIME_TYPE_MCU_CALC,
38 SYS_TIME_TYPE_GPS_CALC,
39 SYS_TIME_TYPE_NTP_CALC,
40 SYS_TIME_TYPE_TSP_CALC,
41} sys_time_calc_type_t;
42
43/* NTP 服务器信息 */
44typedef struct
45{
46 char domain[50];
47 char* id;
49
50/* 时间配置信息 */
51typedef struct
52{
53 char zone_time[SYS_TIME_ZONE_LEN];
54 sys_ntp_server_t ntp_server[3];
56
57// 校准时间回调
58typedef void (*sys_time_cb_t)(tbox_time_info_t* time_info_t, sys_time_calc_type_t type);
64void sys_time_mcu_rtc(const uint8_t* data, uint32_t len);
65
74void sys_time_set_by_tsp(time_t ts);
75
76#ifdef __cplusplus
77}
78#endif
79
80#endif /* SYS_TIME_H */
Definition sys_time.h:45
Definition sys_time.h:52
Definition time.h:29
void sys_time_create_oneshot(void)
创建一次性校时任务
void sys_time_mcu_rtc(const uint8_t *data, uint32_t len)
处理MCU RTC时间回调
void sys_time_set_by_tsp(time_t ts)
TSP 时间源设置系统时间
T-Box 时间工具接口