ntp_posix_demo.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. /*
  2. * 这个例程适用于`RTOS`这类支持Task的POSIX设备, 它演示了用SDK配置MQTT参数并建立连接, 之后创建2个任务
  3. *
  4. * + 一个线程用于保活长连接
  5. * + 一个线程用于接收消息, 并在有消息到达时进入默认的数据回调, 在连接状态变化时进入事件回调
  6. *
  7. * 接着在MQTT连接上发送NTP查询请求, 如果云平台的回应报文到达, 从接收线程会调用NTP消息处理的回调函数, 把对时后的本地时间打印出来
  8. *
  9. * 需要用户关注或修改的部分, 已经用 TODO 在注释中标明
  10. *
  11. */
  12. #include <stdio.h>
  13. #include <string.h>
  14. #include "aiot_state_api.h"
  15. #include "aiot_sysdep_api.h"
  16. #include "aiot_mqtt_api.h"
  17. #include "aiot_ntp_api.h"
  18. #include "ali_demo.h"
  19. #include "ql_api_osi.h"
  20. #include "ql_api_nw.h"
  21. #include "ali_demo.h"
  22. #include "ql_log.h"
  23. #include "ql_api_datacall.h"
  24. #include "sockets.h"
  25. #include "lwip/ip_addr.h"
  26. #include "lwip/ip6_addr.h"
  27. #include "lwip/netdb.h"
  28. #include "lwip/netif.h"
  29. #include "lwip/inet.h"
  30. #include "lwip/tcp.h"
  31. #define QL_SOCKET_LOG_LEVEL QL_LOG_LEVEL_INFO
  32. #define uart_printf(msg, ...) QL_LOG(QL_SOCKET_LOG_LEVEL, "linkSDK ", msg, ##__VA_ARGS__)
  33. #define mqtt_profile_idx 1
  34. /* 位于portfiles/aiot_port文件夹下的系统适配函数集合 */
  35. extern aiot_sysdep_portfile_t g_aiot_sysdep_portfile;
  36. /* 位于external/ali_ca_cert.c中的服务器证书 */
  37. extern const char *ali_ca_cert;
  38. ql_task_t ql_alisdk_ntp_task_ref;
  39. ql_task_t ql_alisdk_mqtt_process_task_ref;
  40. ql_task_t ql_alisdk_mqtt_recv_task_ref;
  41. static uint8_t g_mqtt_process_task_running = 0;
  42. static uint8_t g_mqtt_recv_task_running = 0;
  43. static int datacall_satrt(void)
  44. {
  45. int ret = 0;
  46. int i = 0;
  47. ql_data_call_info_s info;
  48. char ip4_addr_str[16] = {0};
  49. uint8_t nSim = 0;
  50. ql_rtos_task_sleep_s(10);
  51. uart_printf("========== socket demo start ==========");
  52. uart_printf("wait for network register done");
  53. while ((ret = ql_network_register_wait(nSim, 120)) != 0 && i < 10)
  54. {
  55. i++;
  56. ql_rtos_task_sleep_s(1);
  57. }
  58. if (ret == 0)
  59. {
  60. i = 0;
  61. uart_printf("====network registered!!!!====");
  62. }
  63. else
  64. {
  65. uart_printf("====network register failure!!!!!====");
  66. goto exit;
  67. }
  68. ql_set_data_call_asyn_mode(nSim, mqtt_profile_idx, 0);
  69. uart_printf("===start data call====");
  70. ret = ql_start_data_call(nSim, mqtt_profile_idx, QL_PDP_TYPE_IP, "uninet", NULL, NULL, 0);
  71. uart_printf("===data call result:%d", ret);
  72. if (ret != 0)
  73. {
  74. uart_printf("====data call failure!!!!=====");
  75. }
  76. memset(&info, 0x00, sizeof(ql_data_call_info_s));
  77. ret = ql_get_data_call_info(nSim, mqtt_profile_idx, &info);
  78. if (ret != 0)
  79. {
  80. uart_printf("ql_get_data_call_info ret: %d", ret);
  81. ql_stop_data_call(nSim, mqtt_profile_idx);
  82. goto exit;
  83. }
  84. uart_printf("info->mqtt_profile_idx: %d", info.profile_idx);
  85. uart_printf("info->ip_version: %d", info.ip_version);
  86. uart_printf("info->v4.state: %d", info.v4.state);
  87. inet_ntop(AF_INET, &info.v4.addr.ip, ip4_addr_str, sizeof(ip4_addr_str));
  88. uart_printf("info.v4.addr.ip: %s\r\n", ip4_addr_str);
  89. inet_ntop(AF_INET, &info.v4.addr.pri_dns, ip4_addr_str, sizeof(ip4_addr_str));
  90. uart_printf("info.v4.addr.pri_dns: %s\r\n", ip4_addr_str);
  91. inet_ntop(AF_INET, &info.v4.addr.sec_dns, ip4_addr_str, sizeof(ip4_addr_str));
  92. uart_printf("info.v4.addr.sec_dns: %s\r\n", ip4_addr_str);
  93. return 0;
  94. exit:
  95. return -1;
  96. }
  97. /* TODO: 如果要关闭日志, 就把这个函数实现为空, 如果要减少日志, 可根据code选择不打印
  98. *
  99. * 例如: [1581501698.455][LK-0309] pub: /ext/ntp/a13FN5TplKq/ntp_basic_demo/request
  100. *
  101. * 上面这条日志的code就是0309(十六进制), code值的定义见core/aiot_state_api.h
  102. *
  103. */
  104. /* 日志回调函数, SDK的日志会从这里输出 */
  105. static int32_t demo_state_logcb(int32_t code, char *message)
  106. {
  107. uart_printf("%s", message);
  108. return 0;
  109. }
  110. /* MQTT事件回调函数, 当网络连接/重连/断开时被触发, 事件定义见core/aiot_mqtt_api.h */
  111. static void demo_mqtt_event_handler(void *handle, const aiot_mqtt_event_t *event, void *userdata)
  112. {
  113. switch (event->type) {
  114. /* SDK因为用户调用了aiot_mqtt_connect()接口, 与mqtt服务器建立连接已成功 */
  115. case AIOT_MQTTEVT_CONNECT: {
  116. uart_printf("AIOT_MQTTEVT_CONNECT\n");
  117. }
  118. break;
  119. /* SDK因为网络状况被动断连后, 自动发起重连已成功 */
  120. case AIOT_MQTTEVT_RECONNECT: {
  121. uart_printf("AIOT_MQTTEVT_RECONNECT\n");
  122. }
  123. break;
  124. /* SDK因为网络的状况而被动断开了连接, network是底层读写失败, heartbeat是没有按预期得到服务端心跳应答 */
  125. case AIOT_MQTTEVT_DISCONNECT: {
  126. char *cause = (event->data.disconnect == AIOT_MQTTDISCONNEVT_NETWORK_DISCONNECT) ? ("network disconnect") :
  127. ("heartbeat disconnect");
  128. uart_printf("AIOT_MQTTEVT_DISCONNECT: %s\n", cause);
  129. }
  130. break;
  131. default: {
  132. }
  133. }
  134. }
  135. /* MQTT默认消息处理回调, 当SDK从服务器收到MQTT消息时, 且无对应用户回调处理时被调用 */
  136. static void demo_mqtt_default_recv_handler(void *handle, const aiot_mqtt_recv_t *packet, void *userdata)
  137. {
  138. switch (packet->type) {
  139. case AIOT_MQTTRECV_HEARTBEAT_RESPONSE: {
  140. uart_printf("heartbeat response\n");
  141. }
  142. break;
  143. case AIOT_MQTTRECV_SUB_ACK: {
  144. uart_printf("suback, res: -0x%04X, packet id: %d, max qos: %d\n",
  145. -packet->data.sub_ack.res, packet->data.sub_ack.packet_id, packet->data.sub_ack.max_qos);
  146. }
  147. break;
  148. case AIOT_MQTTRECV_PUB: {
  149. uart_printf("pub, qos: %d, topic: %d %s\n", packet->data.pub.qos, packet->data.pub.topic_len, packet->data.pub.topic);
  150. uart_printf("pub, payload: %d %s\n", packet->data.pub.payload_len, packet->data.pub.payload);
  151. }
  152. break;
  153. case AIOT_MQTTRECV_PUB_ACK: {
  154. uart_printf("puback, packet id: %d\n", packet->data.pub_ack.packet_id);
  155. }
  156. break;
  157. default: {
  158. }
  159. }
  160. }
  161. /* 执行aiot_mqtt_process的线程, 包含心跳发送和QoS1消息重发 */
  162. static void demo_mqtt_process_thread(void *args)
  163. {
  164. int32_t res = STATE_SUCCESS;
  165. while (g_mqtt_process_task_running) {
  166. res = aiot_mqtt_process(args);
  167. if (res == STATE_USER_INPUT_EXEC_DISABLED) {
  168. break;
  169. }
  170. ql_rtos_task_sleep_s(1);
  171. }
  172. return ;
  173. }
  174. /* 执行aiot_mqtt_recv的线程, 包含网络自动重连和从服务器收取MQTT消息 */
  175. static void demo_mqtt_recv_thread(void *args)
  176. {
  177. int32_t res = STATE_SUCCESS;
  178. while (g_mqtt_recv_task_running) {
  179. res = aiot_mqtt_recv(args);
  180. if (res < STATE_SUCCESS) {
  181. if (res == STATE_USER_INPUT_EXEC_DISABLED) {
  182. break;
  183. }
  184. ql_rtos_task_sleep_s(1);
  185. }
  186. }
  187. return ;
  188. }
  189. static int32_t demo_mqtt_start(void **handle)
  190. {
  191. int32_t res = STATE_SUCCESS;
  192. void *mqtt_handle = NULL;
  193. char *url = "iot-as-mqtt.cn-shanghai.aliyuncs.com"; /* 阿里云平台上海站点的域名后缀 */
  194. char host[100] = {0}; /* 用这个数组拼接设备连接的云平台站点全地址, 规则是 ${productKey}.iot-as-mqtt.cn-shanghai.aliyuncs.com */
  195. uint16_t port = 443; /* 无论设备是否使用TLS连接阿里云平台, 目的端口都是443 */
  196. aiot_sysdep_network_cred_t cred; /* 安全凭据结构体, 如果要用TLS, 这个结构体中配置CA证书等参数 */
  197. /* TODO: 替换为自己设备的三元组 */
  198. char *product_key = "a1TSu2F29co";
  199. char *device_name = "000001";
  200. char *device_secret = "bd220c3a9c6a5b3f5921485d091497e1";
  201. /*执行拨号操作,设备联网*/
  202. if(datacall_satrt()!=0)
  203. return -1;
  204. /* 配置SDK的底层依赖 */
  205. aiot_sysdep_set_portfile(&g_aiot_sysdep_portfile);
  206. /* 配置SDK的日志输出 */
  207. aiot_state_set_logcb(demo_state_logcb);
  208. /* 创建SDK的安全凭据, 用于建立TLS连接 */
  209. memset(&cred, 0, sizeof(aiot_sysdep_network_cred_t));
  210. cred.option = AIOT_SYSDEP_NETWORK_CRED_SVRCERT_CA; /* 使用RSA证书校验MQTT服务端 */
  211. cred.max_tls_fragment = 16384; /* 最大的分片长度为16K, 其它可选值还有4K, 2K, 1K, 0.5K */
  212. cred.sni_enabled = 1; /* TLS建连时, 支持Server Name Indicator */
  213. cred.x509_server_cert = ali_ca_cert; /* 用来验证MQTT服务端的RSA根证书 */
  214. cred.x509_server_cert_len = strlen(ali_ca_cert); /* 用来验证MQTT服务端的RSA根证书长度 */
  215. /* 创建1个MQTT客户端实例并内部初始化默认参数 */
  216. mqtt_handle = aiot_mqtt_init();
  217. if (mqtt_handle == NULL) {
  218. uart_printf("aiot_mqtt_init failed\n");
  219. return -1;
  220. }
  221. /* TODO: 如果以下代码不被注释, 则例程会用TCP而不是TLS连接云平台 */
  222. /*
  223. {
  224. memset(&cred, 0, sizeof(aiot_sysdep_network_cred_t));
  225. cred.option = AIOT_SYSDEP_NETWORK_CRED_NONE;
  226. }
  227. */
  228. snprintf(host, 100, "%s.%s", product_key, url);
  229. /* 配置MQTT服务器地址 */
  230. aiot_mqtt_setopt(mqtt_handle, AIOT_MQTTOPT_HOST, (void *)host);
  231. /* 配置MQTT服务器端口 */
  232. aiot_mqtt_setopt(mqtt_handle, AIOT_MQTTOPT_PORT, (void *)&port);
  233. /* 配置拨号profile_idx信息(quectel平台必须执行此操作)*/
  234. uint16_t pdp = mqtt_profile_idx;
  235. aiot_mqtt_setopt(mqtt_handle, AIOT_MQTTOPT_PROFILE_IDX, (void *)&pdp);
  236. /* 配置设备productKey */
  237. aiot_mqtt_setopt(mqtt_handle, AIOT_MQTTOPT_PRODUCT_KEY, (void *)product_key);
  238. /* 配置设备deviceName */
  239. aiot_mqtt_setopt(mqtt_handle, AIOT_MQTTOPT_DEVICE_NAME, (void *)device_name);
  240. /* 配置设备deviceSecret */
  241. aiot_mqtt_setopt(mqtt_handle, AIOT_MQTTOPT_DEVICE_SECRET, (void *)device_secret);
  242. /* 配置网络连接的安全凭据, 上面已经创建好了 */
  243. aiot_mqtt_setopt(mqtt_handle, AIOT_MQTTOPT_NETWORK_CRED, (void *)&cred);
  244. /* 配置MQTT默认消息接收回调函数 */
  245. aiot_mqtt_setopt(mqtt_handle, AIOT_MQTTOPT_RECV_HANDLER, (void *)demo_mqtt_default_recv_handler);
  246. /* 配置MQTT事件回调函数 */
  247. aiot_mqtt_setopt(mqtt_handle, AIOT_MQTTOPT_EVENT_HANDLER, (void *)demo_mqtt_event_handler);
  248. /* 配置MQTT连接超时时间 */
  249. int time_delay_ms = 5000;
  250. aiot_mqtt_setopt(mqtt_handle, AIOT_MQTTOPT_CONNECT_TIMEOUT_MS, (void *)&time_delay_ms);
  251. /* 与服务器建立MQTT连接 */
  252. res = aiot_mqtt_connect(mqtt_handle);
  253. if (res < STATE_SUCCESS) {
  254. /* 尝试建立连接失败, 销毁MQTT实例, 回收资源 */
  255. aiot_mqtt_deinit(&mqtt_handle);
  256. uart_printf("aiot_mqtt_connect failed: -0x%04X\n", -res);
  257. return -1;
  258. }
  259. /* 创建一个单独的线程, 专用于执行aiot_mqtt_process, 它会自动发送心跳保活, 以及重发QoS1的未应答报文 */
  260. g_mqtt_process_task_running = 1;
  261. res = ql_rtos_task_create(&ql_alisdk_mqtt_process_task_ref, 24000, 24, "client_test", demo_mqtt_process_thread, mqtt_handle, 5);
  262. if (res < 0) {
  263. uart_printf("pthread_create demo_mqtt_process_thread failed: %d\n", res);
  264. return -1;
  265. }
  266. /* 创建一个单独的线程用于执行aiot_mqtt_recv, 它会循环收取服务器下发的MQTT消息, 并在断线时自动重连 */
  267. g_mqtt_recv_task_running = 1;
  268. res = ql_rtos_task_create(&ql_alisdk_mqtt_recv_task_ref, 24000, 25, "recv_test", demo_mqtt_recv_thread, mqtt_handle, 5);
  269. if (res < 0) {
  270. uart_printf("pthread_create demo_mqtt_recv_thread failed: %d\n", res);
  271. return -1;
  272. }
  273. *handle = mqtt_handle;
  274. return 0;
  275. }
  276. static int32_t demo_mqtt_stop(void **handle)
  277. {
  278. int32_t res = STATE_SUCCESS;
  279. void *mqtt_handle = NULL;
  280. mqtt_handle = *handle;
  281. g_mqtt_process_task_running = 0;
  282. g_mqtt_recv_task_running = 0;
  283. // pthread_join(g_mqtt_process_thread, NULL);
  284. // pthread_join(g_mqtt_recv_thread, NULL);
  285. ql_rtos_task_delete(ql_alisdk_mqtt_process_task_ref);
  286. ql_rtos_task_delete(ql_alisdk_mqtt_recv_task_ref);
  287. /* 断开MQTT连接 */
  288. res = aiot_mqtt_disconnect(mqtt_handle);
  289. if (res < STATE_SUCCESS) {
  290. aiot_mqtt_deinit(&mqtt_handle);
  291. uart_printf("aiot_mqtt_disconnect failed: -0x%04X\n", -res);
  292. return -1;
  293. }
  294. /* 销毁MQTT实例 */
  295. res = aiot_mqtt_deinit(&mqtt_handle);
  296. if (res < STATE_SUCCESS) {
  297. uart_printf("aiot_mqtt_deinit failed: -0x%04X\n", -res);
  298. return -1;
  299. }
  300. return 0;
  301. }
  302. /* 事件处理回调, */
  303. static void demo_ntp_event_handler(void *handle, const aiot_ntp_event_t *event, void *userdata)
  304. {
  305. switch (event->type) {
  306. case AIOT_NTPEVT_INVALID_RESPONSE: {
  307. uart_printf("AIOT_NTPEVT_INVALID_RESPONSE\n");
  308. }
  309. break;
  310. case AIOT_NTPEVT_INVALID_TIME_FORMAT: {
  311. uart_printf("AIOT_NTPEVT_INVALID_TIME_FORMAT\n");
  312. }
  313. break;
  314. default: {
  315. }
  316. }
  317. }
  318. /* TODO: 数据处理回调, 当SDK从网络上收到ntp消息时被调用 */
  319. static void demo_ntp_recv_handler(void *handle, const aiot_ntp_recv_t *packet, void *userdata)
  320. {
  321. switch (packet->type) {
  322. /* TODO: 结构体 aiot_ntp_recv_t{} 中包含当前时区下, 年月日时分秒的数值, 可在这里把它们解析储存起来 */
  323. case AIOT_NTPRECV_LOCAL_TIME: {
  324. uart_printf("local time: %llu, %02d/%02d/%02d-%02d:%02d:%02d:%d\n",
  325. (long long unsigned int)packet->data.local_time.timestamp,
  326. packet->data.local_time.year,
  327. packet->data.local_time.mon, packet->data.local_time.day, packet->data.local_time.hour, packet->data.local_time.min,
  328. packet->data.local_time.sec, packet->data.local_time.msec);
  329. }
  330. break;
  331. default: {
  332. }
  333. }
  334. }
  335. static void ali_ntp_test(void *arg)
  336. {
  337. int32_t res = STATE_SUCCESS;
  338. /*
  339. * 这里用中国所在的东8区演示功能, 因此例程运行时打印的是北京时间
  340. *
  341. * TODO: 若是其它时区, 可做相应调整, 如西3区则把8改为-3, time_zone的合理取值是-12到+12的整数
  342. *
  343. */
  344. int8_t time_zone = 8;
  345. void *mqtt_handle = NULL, *ntp_handle = NULL;
  346. /* 建立MQTT连接, 并开启保活线程和接收线程 */
  347. res = demo_mqtt_start(&mqtt_handle);
  348. if (res < 0) {
  349. uart_printf("demo_mqtt_start failed\n");
  350. goto exit;
  351. }
  352. /* 创建1个ntp客户端实例并内部初始化默认参数 */
  353. ntp_handle = aiot_ntp_init();
  354. if (ntp_handle == NULL) {
  355. demo_mqtt_stop(&mqtt_handle);
  356. uart_printf("aiot_ntp_init failed\n");
  357. goto exit;
  358. }
  359. res = aiot_ntp_setopt(ntp_handle, AIOT_NTPOPT_MQTT_HANDLE, mqtt_handle);
  360. if (res < STATE_SUCCESS) {
  361. uart_printf("aiot_ntp_setopt AIOT_NTPOPT_MQTT_HANDLE failed, res: -0x%04X\n", -res);
  362. aiot_ntp_deinit(&ntp_handle);
  363. demo_mqtt_stop(&mqtt_handle);
  364. goto exit;
  365. }
  366. res = aiot_ntp_setopt(ntp_handle, AIOT_NTPOPT_TIME_ZONE, (int8_t *)&time_zone);
  367. if (res < STATE_SUCCESS) {
  368. uart_printf("aiot_ntp_setopt AIOT_NTPOPT_TIME_ZONE failed, res: -0x%04X\n", -res);
  369. aiot_ntp_deinit(&ntp_handle);
  370. demo_mqtt_stop(&mqtt_handle);
  371. goto exit;
  372. }
  373. /* TODO: NTP消息回应从云端到达设备时, 会进入此处设置的回调函数 */
  374. res = aiot_ntp_setopt(ntp_handle, AIOT_NTPOPT_RECV_HANDLER, (void *)demo_ntp_recv_handler);
  375. if (res < STATE_SUCCESS) {
  376. uart_printf("aiot_ntp_setopt AIOT_NTPOPT_RECV_HANDLER failed, res: -0x%04X\n", -res);
  377. aiot_ntp_deinit(&ntp_handle);
  378. demo_mqtt_stop(&mqtt_handle);
  379. goto exit;
  380. }
  381. res = aiot_ntp_setopt(ntp_handle, AIOT_NTPOPT_EVENT_HANDLER, (void *)demo_ntp_event_handler);
  382. if (res < STATE_SUCCESS) {
  383. uart_printf("aiot_ntp_setopt AIOT_NTPOPT_EVENT_HANDLER failed, res: -0x%04X\n", -res);
  384. aiot_ntp_deinit(&ntp_handle);
  385. demo_mqtt_stop(&mqtt_handle);
  386. goto exit;
  387. }
  388. /* 发送NTP查询请求给云平台 */
  389. res = aiot_ntp_send_request(ntp_handle);
  390. if (res < STATE_SUCCESS) {
  391. aiot_ntp_deinit(&ntp_handle);
  392. demo_mqtt_stop(&mqtt_handle);
  393. goto exit;
  394. }
  395. /* 主线程进入休眠, 等云平台的NTP回应到达时, 接收线程会调用 demo_ntp_recv_handler() */
  396. while (1) {
  397. ql_rtos_task_sleep_s(1);
  398. }
  399. /* 销毁NTP实例, 一般不会运行到这里 */
  400. res = aiot_ntp_deinit(&ntp_handle);
  401. if (res < STATE_SUCCESS) {
  402. demo_mqtt_stop(&mqtt_handle);
  403. uart_printf("aiot_ntp_deinit failed: -0x%04X\n", -res);
  404. goto exit;
  405. }
  406. /* 销毁MQTT实例, 退出线程, 一般不会运行到这里 */
  407. res = demo_mqtt_stop(&mqtt_handle);
  408. if (res < 0) {
  409. uart_printf("demo_start_stop failed\n");
  410. goto exit;
  411. }
  412. return;
  413. exit:
  414. ql_rtos_task_delete(NULL);
  415. }
  416. #define QL_ALI_TASK_STACK_SIZE 10240
  417. #define QL_ALI_TASK_PRIO APP_PRIORITY_NORMAL
  418. #define QL_ALI_TASK_EVENT_CNT 5
  419. int ql_ali_sdk_ntp_test_init(void)
  420. {
  421. QlOSStatus status;
  422. int count = 0;
  423. /* 主循环进入休眠 */
  424. while (count < 10)
  425. {
  426. count++;
  427. ql_rtos_task_sleep_s(1);
  428. uart_printf("ql_ali_sdk_mqtt_client_test_init -0x%04X\n", count);
  429. }
  430. status =ql_rtos_task_create(&ql_alisdk_ntp_task_ref, QL_ALI_TASK_STACK_SIZE, APP_PRIORITY_NORMAL, "ntp_test", ali_ntp_test, NULL, QL_ALI_TASK_EVENT_CNT);
  431. if(status < 0)
  432. return -1;
  433. return 0;
  434. }