1 /**
2  * @file ntp_private.h
3  * @brief ntp模块内部的宏定义和数据结构声明, 不面向其它模块, 更不面向用户
4  *
5  * @copyright Copyright (C) 2015-2020 Alibaba Group Holding Limited
6  *
7  */
8 #ifndef __NTP_PRIVATE_H__
9 #define __NTP_PRIVATE_H__
10 
11 #if defined(__cplusplus)
12 extern "C" {
13 #endif
14 
15 /* 用这种方式包含标准C库的头文件 */
16 #include "core_stdinc.h"
17 
18 /* TODO: 这一段列出需要包含SDK其它模块头文件, 与上一段落以1个空行隔开 */
19 #include "aiot_state_api.h"
20 #include "aiot_sysdep_api.h"
21 #include "aiot_ntp_api.h"      /* 内部头文件是用户可见头文件的超集 */
22 
23 /* TODO: 定义ntp模块内部的会话句柄结构体, SDK用户不可见, 只能得到void *handle类型的指针 */
24 typedef struct {
25     aiot_sysdep_portfile_t     *sysdep;             /* 底层依赖回调合集的引用指针 */
26     void *mqtt_handle;
27 
28     int8_t time_zone;
29     uint32_t deinit_timeout_ms;
30 
31     aiot_ntp_recv_handler_t    recv_handler;       /* 组件从协议栈读到内容时, 通知用户的回调 */
32     aiot_ntp_event_handler_t   event_handler;
33     void *userdata;                                 /* 组件调用以上2个 ntp_handler 时的入参之一 */
34 
35     /*---- 以上都是用户在API可配 ----*/
36     void *data_mutex;
37 
38     uint8_t exec_enabled;
39     uint32_t exec_count;
40 
41 } ntp_handle_t;
42 
43 #define NTP_MODULE_NAME                      "ntp"  /* 用于内存统计的模块名字符串 */
44 
45 #define NTP_DEFAULT_DEINIT_TIMEOUT_MS        (2 * 1000)
46 #define NTP_DEFAULT_TIME_ZONE                (0)
47 
48 #define NTP_REQUEST_TOPIC_FMT                "/ext/ntp/%s/%s/request"
49 #define NTP_REQUEST_PAYLOAD_FMT              "{\"deviceSendTime\":\"%s\"}"
50 #define NTP_RESPONSE_TOPIC_FMT               "/ext/ntp/%s/%s/response"
51 
52 #define NTP_DEINIT_INTERVAL_MS               (100)
53 
54 #if defined(__cplusplus)
55 }
56 #endif
57 #endif  /* __NTP_PRIVATE_H__ */
58 
59