1 /* 2 * Copyright (C) 2015-2018 Alibaba Group Holding Limited 3 */ 4 5 #ifndef _IOTX_DM_INTERNAL_H_ 6 #define _IOTX_DM_INTERNAL_H_ 7 8 #include <stdio.h> 9 #include <string.h> 10 #include <stdlib.h> 11 12 #include "linkkit/infra/infra_compat.h" 13 #include "linkkit/infra/infra_config.h" 14 #include "linkkit/infra/infra_types.h" 15 #include "linkkit/infra/infra_defs.h" 16 #include "linkkit/infra/infra_list.h" 17 #include "linkkit/infra/infra_cjson.h" 18 #include "linkkit/infra/infra_report.h" 19 #include "linkkit/infra/infra_string.h" 20 21 #if defined(DEVICE_MODEL_GATEWAY) 22 #include "linkkit/infra/infra_sha256.h" 23 #endif 24 25 #ifndef _IN_ 26 #define _IN_ 27 #endif 28 29 #ifndef _OU_ 30 #define _OU_ 31 #endif 32 33 #ifndef DM_READ_ONLY 34 #define DM_READ_ONLY 35 #endif 36 37 #include <stdlib.h> 38 39 #if defined(OTA_ENABLED) && !defined(BUILD_AOS) 40 #include "iotx_ota.h" 41 #include "ota_api.h" 42 #endif 43 44 /* CM Header File */ 45 #include "iotx_cm.h" 46 47 /* ALCS Header File */ 48 #ifdef ALCS_ENABLED 49 #include "CoAPExport.h" 50 #include "iotx_alcs.h" 51 #include "dm_server_adapter.h" 52 #include "dm_server.h" 53 #endif 54 55 /* DM Header File */ 56 #include "linkkit/wrappers/wrappers.h" 57 #include "iotx_dm_config.h" 58 #include "iotx_dm.h" 59 #include "dm_utils.h" 60 #include "dm_shadow.h" 61 #include "dm_tsl_alink.h" 62 #include "dm_message_cache.h" 63 #include "dm_opt.h" 64 #include "dm_ota.h" 65 #include "dm_cota.h" 66 #include "dm_fota.h" 67 #include "dm_ipc.h" 68 #include "dm_message.h" 69 #include "dm_msg_process.h" 70 #include "dm_manager.h" 71 #include "dm_client_adapter.h" 72 #include "dm_client.h" 73 #include "dm_intf.h" 74 75 #ifdef INFRA_MEM_STATS 76 #include "linkkit/infra/infra_mem_stats.h" 77 #define DM_malloc(size) LITE_malloc(size, MEM_MAGIC, "dm") 78 #define DM_free(ptr) LITE_free(ptr) 79 #else 80 #define DM_malloc(size) HAL_Malloc(size) 81 #define DM_free(ptr) \ 82 { \ 83 HAL_Free((void *)ptr); \ 84 ptr = NULL; \ 85 } 86 #endif 87 88 #if defined(COAP_COMM_ENABLED) && !defined(MQTT_COMM_ENABLED) 89 #define DM_URI_OFFSET 1 90 #else 91 #define DM_URI_OFFSET 0 92 #endif 93 94 #ifdef INFRA_LOG 95 #include "linkkit/infra/infra_log.h" 96 #define dm_log_emerg(...) log_emerg("DM", __VA_ARGS__) 97 #define dm_log_crit(...) log_crit("DM", __VA_ARGS__) 98 #define dm_log_err(...) log_err("DM", __VA_ARGS__) 99 #define dm_log_warning(...) log_warning("DM", __VA_ARGS__) 100 #define dm_log_info(...) log_info("DM", __VA_ARGS__) 101 #define dm_log_debug(...) log_debug("DM", __VA_ARGS__) 102 #else 103 #define dm_log_emerg(...) \ 104 do { \ 105 HAL_Printf(__VA_ARGS__); \ 106 HAL_Printf("\r\n"); \ 107 } while (0) 108 #define dm_log_crit(...) \ 109 do { \ 110 HAL_Printf(__VA_ARGS__); \ 111 HAL_Printf("\r\n"); \ 112 } while (0) 113 #define dm_log_err(...) \ 114 do { \ 115 HAL_Printf(__VA_ARGS__); \ 116 HAL_Printf("\r\n"); \ 117 } while (0) 118 #define dm_log_warning(...) \ 119 do { \ 120 HAL_Printf(__VA_ARGS__); \ 121 HAL_Printf("\r\n"); \ 122 } while (0) 123 #define dm_log_info(...) \ 124 do { \ 125 HAL_Printf(__VA_ARGS__); \ 126 HAL_Printf("\r\n"); \ 127 } while (0) 128 #define dm_log_debug(...) \ 129 do { \ 130 HAL_Printf(__VA_ARGS__); \ 131 HAL_Printf("\r\n"); \ 132 } while (0) 133 #define HEXDUMP_INFO(...) \ 134 do { \ 135 HAL_Printf(__VA_ARGS__); \ 136 HAL_Printf("\r\n"); \ 137 } while (0) 138 #define HEXDUMP_DEBUG(...) \ 139 do { \ 140 HAL_Printf(__VA_ARGS__); \ 141 HAL_Printf("\r\n"); \ 142 } while (0) 143 #endif 144 145 #ifdef LOG_REPORT_TO_CLOUD 146 #define LOG_POLL_SIZE (CONFIG_MQTT_TX_MAXLEN - 174) 147 #define REPORT_LEN (LOG_POLL_SIZE - 110) 148 #define OVERFLOW_LEN (LOG_POLL_SIZE - 10) 149 150 typedef enum { 151 READY, 152 RUNNING, 153 DONE 154 } REPORT_STATE; 155 unsigned int add_tail(); 156 int reset_log_poll(); 157 int remove_log_poll(); 158 unsigned int push_log(const char *perform_data, int perform_data_size); 159 #endif 160 161 #if !defined(DEVICE_MODEL_RAWDATA_SOLO) 162 void iotx_linkkit_service_list_overtime_handle(void); 163 #endif 164 165 #endif 166