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. * Description: BT PUBLIC API module. 14 */ 15 16 /** 17 * @defgroup bluetooth_bts_def PUBLIC API 18 * @ingroup bluetooth 19 * @{ 20 */ 21 22 #ifndef BTS_DEF_H 23 #define BTS_DEF_H 24 25 #include "stdint.h" 26 27 #ifdef __cplusplus 28 extern "C" { 29 #endif 30 31 /** 32 * @if Eng 33 * @brief Length of bluetooth device address. 34 * @else 35 * @brief 蓝牙设备的地址长度。 36 * @endif 37 */ 38 #define BD_ADDR_LEN 6 39 40 /** 41 * @if Eng 42 * @brief Max length of bluetooth uuid in octets. 43 * @else 44 * @brief 蓝牙UUID的最大长度,单位字节。 45 * @endif 46 */ 47 #define BT_UUID_MAX_LEN 16 48 49 /** 50 * @if Eng 51 * @brief Max length of bluetooth device name. 52 * @else 53 * @brief 蓝牙设备名称的最大长度,单位字节。 54 * @endif 55 */ 56 #define BT_DEVICE_NAME_MAX_LEN 32 57 58 /** 59 * @if Eng 60 * @brief Min value of ble error code. 61 * @else 62 * @brief 蓝牙错误状态类型最小值。 63 * @endif 64 */ 65 #define ERRCODE_BT_COMMON_BASE 0x80006000 66 /** 67 * @if Eng 68 * @brief Min value of ble error code. 69 * @else 70 * @brief 蓝牙错误状态类型最大值。 71 * @endif 72 */ 73 #define ERRCODE_BT_COMMON_END 0x800067FF 74 75 /** 76 * @if Eng 77 * @brief Enum of uuid type. 78 * @else 79 * @brief 定义UUID的类型。 80 * @endif 81 */ 82 typedef enum { 83 UUID_TYPE_NULL = 0x00, /*!< @if Eng null uuid. @else 空uuid。 @endif */ 84 UUID_TYPE_16_BIT, /*!< @if Eng uuid type of 16 bit. @else 16bit长度的uuid。 @endif */ 85 UUID_TYPE_32_BIT, /*!< @if Eng uuid type of 32 bit. @else 32bit长度的uuid。 @endif */ 86 UUID_TYPE_128_BIT, /*!< @if Eng uuid type of 128 bit. @else 128bit长度的uuid。 @endif */ 87 } uuid_type_t; 88 89 /** 90 * @if Eng 91 * @brief Enum of bt status error code. 92 * @else 93 * @brief 定义蓝牙错误状态类型。 94 * @endif 95 */ 96 typedef enum { 97 ERRCODE_BT_SUCCESS = 0x00, /*!< @if Eng error code of success 98 @else 执行成功错误码 @endif */ 99 ERRCODE_BT_FAIL = ERRCODE_BT_COMMON_BASE, /*!< @if Eng error code of failure 100 @else 执行失败错误码 @endif */ 101 ERRCODE_BT_NOT_READY, /*!< @if Eng error code of not ready 102 @else 执行状态未就绪错误码 @endif */ 103 ERRCODE_BT_MALLOC_FAIL, /*!< @if Eng error code of memmery not enough 104 @else 内存不足错误码 @endif */ 105 ERRCODE_BT_MEMCPY_FAIL, /*!< @if Eng error code of memcpy fail 106 @else 内存拷贝错误错误码 @endif */ 107 ERRCODE_BT_BUSY, /*!< @if Eng error code of system is busy 108 @else 繁忙无法响应错误码 @endif */ 109 ERRCODE_BT_DONE, /*!< @if Eng error code of complete 110 @else 执行完成错误码 @endif */ 111 ERRCODE_BT_UNSUPPORTED, /*!< @if Eng error code of not support 112 @else 不支持错误码 @endif */ 113 ERRCODE_BT_PARAM_ERR, /*!< @if Eng error code of invalid param 114 @else 无效参数错误码 @endif */ 115 ERRCODE_BT_STATE_ERR, /*!< @if Eng error code of state error 116 @else 状态错误 @endif */ 117 ERRCODE_BT_UNHANDLED, /*!< @if Eng error code of unhandle 118 @else 未处理错误码 @endif */ 119 ERRCODE_BT_AUTH_FAIL, /*!< @if Eng error code of auth failure 120 @else 鉴权失败错误码 @endif */ 121 ERRCODE_BT_RMT_DEV_DOWN, /*!< @if Eng error code of remote device down 122 @else 远端设备关闭错误码 @endif */ 123 ERRCODE_BT_AUTH_REJECTED, /*!< @if Eng error code of auth rejected 124 @else 鉴权被拒错误码 @endif */ 125 ERRCODE_BT_MAX = ERRCODE_BT_COMMON_END /*!< @if Eng the max of bt error code 126 @else 蓝牙错误码最大值 @endif */ 127 } errcode_bt_t; 128 129 /** 130 * @if Eng 131 * @brief Enum of bluetooth device address type. 132 * @else 133 * @brief 定义设备的蓝牙地址类型。 134 * @endif 135 */ 136 typedef enum { 137 BT_ADDRESS_TYPE_PUBLIC_DEVICE_ADDRESS = 0x00, /*!< @if Eng bluetooth public address. 138 @else 蓝牙公有地址。 @endif */ 139 BT_ADDRESS_TYPE_RANDOM_DEVICE_ADDRESS = 0x01, /*!< @if Eng bluetooth random address. 140 @else 蓝牙随机地址。 @endif */ 141 } bt_addr_type; 142 143 /** 144 * @if Eng 145 * @brief Struct of bluetooth device address. 146 * @else 147 * @brief 定义设备的蓝牙地址。 148 * @endif 149 */ 150 typedef struct { 151 uint8_t addr[BD_ADDR_LEN]; /*!< @if Eng bluetooth device address. 152 @else 蓝牙地址。 @endif */ 153 uint8_t type; /*!< @if Eng bluetooth device address type, See { @ref bt_addr_type }. 154 @else 蓝牙地址类型,参考 { @ref bt_addr_type }。 @endif */ 155 } bd_addr_t; 156 157 /** 158 * @if Eng 159 * @brief Struct of UUID. 160 * @else 161 * @brief 定义UUID结构。 162 * @endif 163 */ 164 typedef struct { 165 uint8_t uuid_len; /*!< @if Eng length of uuid. 166 @else UUID长度。 @endif */ 167 uint8_t uuid[BT_UUID_MAX_LEN]; /*!< @if Eng uuid. 168 @else UUID字段。 @endif */ 169 } bt_uuid_t; 170 171 /** 172 * @} 173 */ 174 175 #ifdef __cplusplus 176 } 177 #endif 178 #endif /* end of bts_def.h */ 179 180