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: BTS GATT STRU module. 15 */ 16 17 /** 18 * @defgroup bluetooth_bts_gatt_stru BTS GATT STRU API 19 * @ingroup bluetooth 20 * @{ 21 */ 22 23 #ifndef BTS_GATT_STRU_H 24 #define BTS_GATT_STRU_H 25 26 #include <stdint.h> 27 #include "errcode.h" 28 #include "bts_def.h" 29 #include "bts_gatt_stru.h" 30 31 #ifdef __cplusplus 32 extern "C" { 33 #endif 34 35 /** 36 * @if Eng 37 * @brief Struct of gatt characteristic Properties bit field. 38 * @else 39 * @brief gatt特征特性比特位属性定义。 40 * @endif 41 */ 42 typedef enum { 43 GATT_CHARACTER_PROPERTY_BIT_BROADCAST = 0x01, /*!< @if Eng Broadcast characteristic value 44 @else 广播特征值 @endif */ 45 GATT_CHARACTER_PROPERTY_BIT_READ = 0x02, /*!< @if Eng Read characteristic value 46 @else 读特征值 @endif */ 47 GATT_CHARACTER_PROPERTY_BIT_WRITE_NO_RSP = 0x04, /*!< @if Eng Write characteristic value with no response 48 @else 写特征值并且不需要响应 @endif */ 49 GATT_CHARACTER_PROPERTY_BIT_WRITE = 0x08, /*!< @if Eng Write characteristic value 50 @else 写特征值 @endif */ 51 GATT_CHARACTER_PROPERTY_BIT_NOTIFY = 0x10, /*!< @if Eng Notify client characteristic value 52 @else 通知特征值 @endif */ 53 GATT_CHARACTER_PROPERTY_BIT_INDICATE = 0x20, /*!< @if Eng Indicate characteristic value 54 @else 指示特征值 @endif */ 55 GATT_CHARACTER_PROPERTY_BIT_SIGNED_WRITE = 0x40, /*!< @if Eng Signed write characteristic value 56 @else 签名写特征值 @endif */ 57 GATT_CHARACTER_PROPERTY_BIT_EXTENDED_PROPERTY = 0x80, /*!< @if Eng Define extern characteristic properties in 58 Characteristic Extended Properties Descriptor 59 @else 在特征扩展特性描述符中定义了附加的特征特性 60 @endif */ 61 } gatt_characteristic_property_t; 62 63 /** 64 * @if Eng 65 * @brief Enum of gatt attribute permission. 66 * @else 67 * @brief 定义了当前Attribute的操作权限。 68 * @endif 69 */ 70 typedef enum { 71 GATT_ATTRIBUTE_PERMISSION_READ = 0x01, /*!< @if Eng readable 72 @else 可读 @endif */ 73 GATT_ATTRIBUTE_PERMISSION_WRITE = 0x02, /*!< @if Eng writable 74 @else 可写 @endif */ 75 GATT_ATTRIBUTE_PERMISSION_ENCRYPTION_NEED = 0x04, /*!< @if Eng need encryption 76 @else 需要加密 @endif */ 77 GATT_ATTRIBUTE_PERMISSION_AUTHENTICATION_NEED = 0x08, /*!< @if Eng need authentication 78 @else 需要认证 @endif */ 79 GATT_ATTRIBUTE_PERMISSION_AUTHORIZATION_NEED = 0x10, /*!< @if Eng need authorization 80 @else 需要授权 @endif */ 81 GATT_ATTRIBUTE_PERMISSION_MITM_NEED = 0x20, /*!< @if Eng need MITM protection 82 @else 需要MITM保护 @endif */ 83 } gatt_attribute_permission_t; 84 85 /** 86 * @if Eng 87 * @brief Enum of gatt operation error code. 88 * @else 89 * @brief 定义gatt操作错误码。 90 * @endif 91 */ 92 typedef enum { 93 GATT_STATUS_SUCCESS = 0x00, /*!< @if Eng operation error code of success 94 @else 执行成功错误码 @endif */ 95 GATT_STATUS_INVALID_HANDLE = 0x01, /*!< @if Eng operation error code of invalid handle 96 @else 无效handle错误码 @endif */ 97 GATT_STATUS_READ_NOT_PERMITTED = 0x02, /*!< @if Eng operation error code of read not permitted 98 @else 不可读错误码 @endif */ 99 GATT_STATUS_WRITE_NOT_PERMITTED = 0x03, /*!< @if Eng operation error code of write not permitted 100 @else 不可写错误码 @endif */ 101 GATT_STATUS_INVALID_PDU = 0x04, /*!< @if Eng operation error code of invalid PDU 102 @else 无效PDU错误码 @endif */ 103 GATT_STATUS_INSUFFICIENT_AUTHENTICATION = 0x05, /*!< @if Eng operation error code of insufficient authorization 104 @else 未认证的读写错误码 @endif */ 105 GATT_STATUS_REQUEST_NOT_SUPPORTED = 0x06, /*!< @if Eng operation error code of not support the request 106 by the client 107 @else 不支持client发送的请求 @endif */ 108 GATT_STATUS_INVALID_OFFSET = 0x07, /*!< @if Eng operation error code of invalid offset 109 @else 无效偏移的读写错误码 @endif */ 110 GATT_STATUS_INSUFFICIENT_AUTHORIZATION = 0x08, /*!< @if Eng operation error code of insufficient 111 authentication 112 @else 未授权错误码 @endif */ 113 GATT_STATUS_PREPARE_QUEUE_FULL = 0x09, /*!< @if Eng operation error code of prepare queue full 114 @else 排队的prepare writes太多,队列已满错误码 @endif */ 115 GATT_STATUS_ATTRIBUTE_NOT_FOUND = 0x0A, /*!< @if Eng operation error code of prepare queue full 116 @else 排队的prepare writes太多,队列已满错误码 @endif */ 117 GATT_STATUS_ATTRIBUTE_NOT_LONG = 0x0B, /*!< @if Eng operation error code of can not use 118 ATT_READ_BLOB_REQ PDU by not long attribute 119 @else 该attribute不是long attribute, 不能使用 120 ATT_READ_BLOB_REQ PDU @endif */ 121 GATT_STATUS_INSUFFICIENT_ENCRYPTION_KEY_SIZE = 0x0C, /*!< @if Eng operation error code of the encryption key size is 122 insufficient 123 @else 用于加密此连接的加密密钥大小不足@endif */ 124 GATT_STATUS_INVALID_ATTRIBUTE_VALUE_LENGTH = 0x0D, /*!< @if Eng operation error code of the encryption key size is 125 insufficient 126 @else 用于加密此连接的加密密钥大小不足@endif */ 127 GATT_STATUS_UNLIKELY_ERROR = 0x0E, /*!< @if Eng operation error code unlikely 128 @else 不可能的错误码@endif */ 129 GATT_STATUS_INSUFFICIENT_ENCRYPTION = 0x0F, /*!< @if Eng operation error code of insufficient encryption 130 @else 加密不足错误码@endif */ 131 GATT_STATUS_UNSUPPORTED_GROUP_TYPE = 0x10, /*!< @if Eng operation error code of unsupport grouping 132 attribute type 133 @else 不支持的 grouping attribute错误码@endif */ 134 GATT_STATUS_INSUFFICIENT_RESOURCES = 0x11, /*!< @if Eng operation error code of insufficient resource 135 @else 资源不足错误码@endif */ 136 GATT_STATUS_DATABASE_OUT_OF_SYNC = 0x12, /*!< @if Eng operation error code of database out of sync 137 @else 服务端与客户端未同步数据库错误码@endif */ 138 GATT_STATUS_VALUE_NOT_ALLOWED = 0x13, /*!< @if Eng operation error code of not allowed value 139 @else 非法的参数值错误码@endif */ 140 } gatt_status_t; 141 142 /** 143 * @if Eng 144 * @brief Max value of ble MTU. 145 * @else 146 * @brief 协议规定的BLE MTU最大值。 147 * @endif 148 */ 149 #define SDK_BLE_MTU_MAX 517 150 151 /** 152 * @if Eng 153 * @brief Min value of ble MTU. 154 * @else 155 * @brief 用户可配置的BLE MTU最小值。 156 * @endif 157 */ 158 #define SDK_BLE_MTU_MIN 23 159 160 #ifdef __cplusplus 161 } 162 #endif 163 #endif 164 /** @} */ 165 166