|
Link Kit C-SDK
4.0.0
|
ntp模块的API接口实现, 提供获取utc时间的能力 更多...
#include "ntp_private.h"#include "core_string.h"#include "core_log.h"#include "core_global.h"#include "core_mqtt.h"
函数 | |
| static void | _core_ntp_exec_inc (ntp_handle_t *ntp_handle) |
| static void | _core_ntp_exec_dec (ntp_handle_t *ntp_handle) |
| static void | _ntp_recv_handler (void *handle, const aiot_mqtt_recv_t *packet, void *userdata) |
| static int32_t | _ntp_operate_topic_map (ntp_handle_t *ntp_handle, aiot_mqtt_option_t option) |
| static void | _ntp_core_mqtt_process_handler (void *context, aiot_mqtt_event_t *event, core_mqtt_event_t *core_event) |
| static int32_t | _ntp_core_mqtt_operate_process_handler (ntp_handle_t *ntp_handle, core_mqtt_option_t option) |
| void * | aiot_ntp_init (void) |
| 创建ntp会话实例, 并以默认值配置会话参数 更多... | |
| int32_t | aiot_ntp_setopt (void *handle, aiot_ntp_option_t option, void *data) |
| 配置ntp会话 更多... | |
| int32_t | aiot_ntp_deinit (void **handle) |
| 结束ntp会话, 销毁实例并回收资源 更多... | |
| int32_t | aiot_ntp_send_request (void *handle) |
| 向ntp服务器发送ntp消息请求 更多... | |
ntp模块的API接口实现, 提供获取utc时间的能力
|
static |
|
static |
|
static |
|
static |

|
static |
|
static |

| void* aiot_ntp_init | ( | void | ) |
创建ntp会话实例, 并以默认值配置会话参数
| 非NULL | ntp实例的句柄 |
| NULL | 初始化失败, 一般是内存分配失败导致 |

| int32_t aiot_ntp_setopt | ( | void * | handle, |
| aiot_ntp_option_t | option, | ||
| void * | data | ||
| ) |
配置ntp会话
常见的配置项如下
AIOT_NTPOPT_MQTT_HANDLE: 已建立连接的MQTT会话句柄AIOT_NTPOPT_TIME_ZONE: 时区设置, SDK会将收到的UTC时间按配置的时区进行转换AIOT_NTPOPT_RECV_HANDLER: 时间数据接收回调函数, SDK将UTC时间转换完成后, 通过此回调函数输出| [in] | handle | ntp会话句柄 |
| [in] | option | 配置选项, 更多信息请参考aiot_ntp_option_t |
| [in] | data | 配置选项数据, 更多信息请参考aiot_ntp_option_t |
| <STATE_SUCCESS | 参数配置失败 |
| >=STATE_SUCCESS | 参数配置成功 |

| int32_t aiot_ntp_deinit | ( | void ** | handle | ) |
结束ntp会话, 销毁实例并回收资源
| [in] | handle | 指向ntp会话句柄的指针 |
| <STATE_SUCCESS | 执行失败 |
| >=STATE_SUCCESS | 执行成功 |

| int32_t aiot_ntp_send_request | ( | void * | handle | ) |
向ntp服务器发送ntp消息请求
发送NTP请求, 然后SDK会调用通过 aiot_ntp_setopt 配置的 AIOT_NTPOPT_RECV_HANDLER 回调函数, 通知用户当前的时间
| handle | ntp会话句柄 |
| <STATE_SUCCESS | 请求发送失败 |
| >=STATE_SUCCESS | 请求发送成功 |

1.8.11