1 /* 2 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 * Description: HiLink SDK 软件适配层defines(此文件为DEMO,需集成方适配修改) 15 */ 16 #ifndef HILINK_SAL_DEFINES_H 17 #define HILINK_SAL_DEFINES_H 18 19 #ifdef HILINK_SDK_BUILD_IN 20 #include "hilink_log.h" 21 22 #define HILINK_SAL_DEBUG(...) hilink_debug(__VA_ARGS__) 23 #define HILINK_SAL_INFO(...) hilink_info(__VA_ARGS__) 24 #define HILINK_SAL_NOTICE(...) hilink_notice(__VA_ARGS__) 25 #define HILINK_SAL_WARN(...) hilink_warning(__VA_ARGS__) 26 #define HILINK_SAL_ERROR(...) hilink_error(__VA_ARGS__) 27 #define HILINK_SAL_CRIT(...) hilink_critical(__VA_ARGS__) 28 #define HILINK_SAL_DEBUG_LIMITED(...) HILINK_DEBUG_LIMITED(__VA_ARGS__) 29 #define HILINK_SAL_ERROR_LIMITED(...) HILINK_ERROR_LIMITED(__VA_ARGS__) 30 31 #else 32 33 /* hilink TLS适配层使用的mbedtls版本,可设为2或3 */ 34 #define MBEDTLS_MAJOR_VERSION 3 35 #define HILINK_MBEDTLS_CCM_SUPPORT 0 36 37 #if (MBEDTLS_MAJOR_VERSION == 3) 38 #define MBEDTLS_VERSION_3 39 #endif 40 41 #define HILINK_SAL_LOG_LVL_MIN 0 42 #define HILINK_SAL_LOG_LVL_DEBUG 1 43 #define HILINK_SAL_LOG_LVL_INFO 2 44 #define HILINK_SAL_LOG_LVL_NOTICE 3 45 #define HILINK_SAL_LOG_LVL_WARN 4 46 #define HILINK_SAL_LOG_LVL_ERROR 5 47 #define HILINK_SAL_LOG_LVL_CRIT 6 48 49 #ifndef HILINK_SAL_LOG_BUILD_LVL 50 #define HILINK_SAL_LOG_BUILD_LVL HILINK_SAL_LOG_LVL_MIN 51 #endif 52 53 #ifdef __cplusplus 54 extern "C" { 55 #endif 56 57 extern int HILINK_Printf(const char *format, ...); 58 59 #ifdef __cplusplus 60 } 61 #endif 62 63 #if HILINK_SAL_LOG_BUILD_LVL <= HILINK_SAL_LOG_LVL_DEBUG 64 #define HILINK_SAL_DEBUG(...) \ 65 do { \ 66 HILINK_Printf("[HSD]%s():%u, ", __FUNCTION__, __LINE__); \ 67 HILINK_Printf(__VA_ARGS__); \ 68 } while (0) 69 #else 70 #define HILINK_SAL_DEBUG(...) 71 #endif 72 73 #if HILINK_SAL_LOG_BUILD_LVL <= HILINK_SAL_LOG_LVL_INFO 74 #define HILINK_SAL_INFO(...) \ 75 do { \ 76 HILINK_Printf("[HSI]%s():%u, ", __FUNCTION__, __LINE__); \ 77 HILINK_Printf(__VA_ARGS__); \ 78 } while (0) 79 #else 80 #define HILINK_SAL_INFO(...) 81 #endif 82 83 #if HILINK_SAL_LOG_BUILD_LVL <= HILINK_SAL_LOG_LVL_NOTICE 84 #define HILINK_SAL_NOTICE(...) \ 85 do { \ 86 HILINK_Printf("[HSN]%s():%u, ", __FUNCTION__, __LINE__); \ 87 HILINK_Printf(__VA_ARGS__); \ 88 } while (0) 89 #else 90 #define HILINK_SAL_NOTICE(...) 91 #endif 92 93 #if HILINK_SAL_LOG_BUILD_LVL <= HILINK_SAL_LOG_LVL_WARN 94 #define HILINK_SAL_WARN(...) \ 95 do { \ 96 HILINK_Printf("[HSW]%s():%u, ", __FUNCTION__, __LINE__); \ 97 HILINK_Printf(__VA_ARGS__); \ 98 } while (0) 99 #else 100 #define HILINK_SAL_WARN(...) 101 #endif 102 103 #if HILINK_SAL_LOG_BUILD_LVL <= HILINK_SAL_LOG_LVL_ERROR 104 #define HILINK_SAL_ERROR(...) \ 105 do { \ 106 HILINK_Printf("[HSE]%s():%u, ", __FUNCTION__, __LINE__); \ 107 HILINK_Printf(__VA_ARGS__); \ 108 } while (0) 109 #else 110 #define HILINK_SAL_ERROR(...) 111 #endif 112 113 #if HILINK_SAL_LOG_BUILD_LVL <= HILINK_SAL_LOG_LVL_CRIT 114 #define HILINK_SAL_CRIT(...) \ 115 do { \ 116 HILINK_Printf("[HSC]%s():%u, ", __FUNCTION__, __LINE__); \ 117 HILINK_Printf(__VA_ARGS__); \ 118 } while (0) 119 #endif 120 121 #define HILINK_SAL_DEBUG_LIMITED(...) 122 #define HILINK_SAL_ERROR_LIMITED(...) 123 #endif /* HILINK_SDK_BUILD_IN */ 124 125 #ifndef ENUM_INT_REVERSED 126 #define ENUM_INT_REVERSED (0x7FFFFFFFU) 127 #endif 128 129 enum HiLinkSalErrorCode { 130 HILINK_SAL_KV_INTI_ERR = -600, 131 HILINK_SAL_KV_SET_ITEM_ERR, 132 HILINK_SAL_KV_GET_ITEM_ERR, 133 HILINK_SAL_KV_DELETE_ITEM_ERR, 134 135 HILINK_SAL_GET_IP_ERR = -500, 136 HILINK_SAL_GET_MAC_ERR, 137 HILINK_SAL_GET_SSID_ERR, 138 HILINK_SAL_SET_WIFI_ERR, 139 HILINK_SAL_GET_WIFI_INFO_ERR, 140 HILINK_SAL_SCAN_WIFI_ERR, 141 HILINK_SAL_ADD_WIFI_ERR, 142 HILINK_SAL_REMOVE_WIFI_ERR, 143 HILINK_SAL_CONENCT_WIFI_ERR, 144 HILINK_SAL_SET_SOFTAP_ERR, 145 146 HILINK_SAL_THREAD_ERR = -400, 147 HILINK_SAL_MUTEX_ERR, 148 HILINK_SAL_SEM_ERR, 149 HILINK_SAL_SLEEP_ERR, 150 HILINK_SAL_TIME_ERR, 151 HILINK_SAL_MALLOC_ERR, 152 153 HILINK_SAL_DNS_ERR = -300, 154 HILINK_SAL_FCNTL_ERR, 155 HILINK_SAL_SET_SOCK_OPT_ERR, 156 HILINK_SAL_GET_SOCK_OPT_ERR, 157 158 HILINK_SAL_MEMCPY_ERR = -200, 159 HILINK_SAL_STRCPY_ERR, 160 HILINK_SAL_STRNCPY_ERR, 161 HILINK_SAL_SPRINTF_ERR, 162 HILINK_SAL_MEMSET_ERR, 163 164 HILINK_SAL_PARAM_INVALID = -100, 165 HILINK_SAL_TIMEOUT, 166 HILINK_SAL_NOT_SUPPORT, 167 HILINK_SAL_NOT_INIT, 168 HILINK_SAL_FD_INVALID, 169 170 HILINK_SAL_NOK = -1, 171 HILINK_SAL_OK = 0, 172 }; 173 174 #endif /* HILINK_SAL_DEFINES_H */