1 /* 2 * Copyright (C) 2015-2018 Alibaba Group Holding Limited 3 */ 4 5 #ifndef __ALCS_ADAPTER_H__ 6 #define __ALCS_ADAPTER_H__ 7 #if defined(__cplusplus) 8 extern "C" { 9 #endif 10 11 #include "alcs_internal.h" 12 #include "linkkit/mqtt_api.h" 13 #include "CoAPExport.h" 14 #include "alcs_mqtt.h" 15 #include "iotx_alcs.h" 16 17 typedef struct iotx_alcs_send_msg_st { 18 uint8_t token_len; 19 uint8_t *token; 20 char *uri; 21 struct list_head linked_list; 22 } iotx_alcs_send_msg_t, *iotx_alcs_send_msg_pt; 23 24 typedef enum { 25 IOTX_ALCS_SUBDEV_DISCONNCET_CLOUD, 26 IOTX_ALCS_SUBDEV_CONNECT_CLOUD 27 } iotx_alcs_subdev_stage_t; 28 29 #define IOTX_ALCS_SUBDEV_RETRY_INTERVAL_MS (10000) 30 31 typedef struct iotx_alcs_subdev_item_st { 32 char product_key[IOTX_PRODUCT_KEY_LEN + 1]; 33 char device_name[IOTX_DEVICE_NAME_LEN + 1]; 34 char prefix[ALCS_MQTT_PREFIX_MAX_LEN]; 35 char secret[ALCS_MQTT_SECRET_MAX_LEN]; 36 uint8_t stage; 37 uint64_t retry_ms; 38 struct list_head linked_list; 39 } iotx_alcs_subdev_item_t, *iotx_alcs_subdev_item_pt; 40 41 typedef void (*iotx_alcs_auth_timer_fnuc_t)(CoAPContext *); 42 43 typedef struct iotx_alcs_adapter_st { 44 void *mutex; 45 int local_cloud_inited; 46 CoAPContext *coap_ctx; 47 uint8_t role; 48 iotx_alcs_auth_timer_fnuc_t alcs_client_auth_timer_func; 49 iotx_alcs_auth_timer_fnuc_t alcs_server_auth_timer_func; 50 iotx_alcs_event_handle_t *alcs_event_handle; 51 struct list_head alcs_send_list; 52 struct list_head alcs_subdev_list; 53 char local_ip[NETWORK_ADDR_LEN]; 54 uint16_t local_port; 55 } iotx_alcs_adapter_t, *iotx_alcs_adapter_pt; 56 57 int iotx_alcs_subdev_insert(iotx_alcs_subdev_item_t *item); 58 int iotx_alcs_subdev_remove(const char *pk, const char *dn); 59 int iotx_alcs_subdev_search(const char *pk, const char *dn, 60 iotx_alcs_subdev_item_t **item); 61 int iotx_alcs_subdev_update_stage(iotx_alcs_subdev_item_t *item); 62 void iotx_alcs_send_list_handle(void *list_node, va_list *params); 63 int iotx_alcs_adapter_list_init(iotx_alcs_adapter_t *adapter); 64 65 #if defined(__cplusplus) 66 } 67 #endif 68 #endif 69