1 /* 2 * Copyright (C) 2015-2018 Alibaba Group Holding Limited 3 */ 4 5 #ifndef __AWSS_CMP_H__ 6 #define __AWSS_CMP_H__ 7 8 #ifdef __cplusplus 9 extern "C" { 10 #endif 11 12 #include <stdint.h> 13 /** 14 * @brief this is a network address structure, including host(ip or host name) 15 * and port. 16 */ 17 typedef struct { 18 char host[16]; /**< host ip(dotted-decimal notation) or host name(string) */ 19 uint16_t port; /**< udp port or tcp port */ 20 } platform_netaddr_t; 21 22 enum { 23 AWSS_LC_INIT_ROUTER = 0x01, 24 AWSS_LC_INIT_PAP = 0x02, 25 AWSS_LC_INIT_DEV_AP = 0x04, 26 AWSS_LC_INIT_SUC = 0x08, 27 AWSS_LC_INIT_BIND = 0x100, 28 }; 29 30 struct awss_cmp_couple { 31 int init_stage; 32 char *topic; 33 void *cb; 34 }; 35 36 struct coap_session_ctx_t { 37 void *request; 38 void *remote; 39 char is_mcast; 40 }; 41 42 int awss_cmp_local_init(int init_stage); 43 int awss_cmp_local_deinit(int force); 44 int awss_cmp_online_init(); 45 int awss_cmp_online_deinit(); 46 int awss_token_remain_time(); 47 int awss_token_timeout(); 48 int awss_update_token(); 49 int awss_report_token(); 50 int awss_stop_report_token(); 51 52 int awss_cmp_coap_cancel_packet(uint16_t msgid); 53 int awss_cmp_coap_register_cb(char *topic, void *cb); 54 int awss_cmp_coap_send(void *buf, uint32_t len, void *sa, const char *uri, 55 void *cb, uint16_t *msgid); 56 int awss_cmp_coap_send_resp(void *buf, uint32_t len, void *sa, const char *uri, 57 void *req, void *cb, uint16_t *msgid, char qos); 58 int awss_cmp_coap_ob_send(void *buf, uint32_t len, void *sa, const char *uri, 59 void *cb); 60 int awss_cmp_coap_deinit(); 61 62 int awss_cmp_mqtt_register_cb(char *topic, void *cb); 63 int awss_cmp_mqtt_unregister_cb(char *topic); 64 int awss_cmp_mqtt_send(char *topic, void *pkt, int pkt_len, int qos); 65 66 int awss_release_coap_ctx(void *session); 67 void *awss_cpy_coap_ctx(void *request, void *remote, char mcast); 68 69 char *awss_cmp_get_coap_payload(void *request, int *payload_len); 70 uint8_t awss_cmp_get_coap_code(void *request); 71 72 int online_dev_bind_monitor(void *ctx, void *resource, void *remote, 73 void *request); 74 75 void awss_enrollee_checkin(void *pcontext, void *pclient, void *msg); 76 void awss_online_switchap(void *pcontext, void *pclient, void *msg); 77 void awss_report_enrollee_reply(void *pcontext, void *pclient, void *msg); 78 void awss_get_cipher_reply(void *pcontext, void *pclient, void *msg); 79 void awss_report_token_reply(void *pcontext, void *pclient, void *msg); 80 int awss_cmp_mqtt_get_payload(void *mesg, char **payload, 81 uint32_t *playload_len); 82 83 #ifdef __cplusplus 84 } 85 #endif 86 87 #endif 88