Mistake on this page?
Report an issue in GitHub or email us
att_defs.h
Go to the documentation of this file.
1 /*************************************************************************************************/
2 /*!
3  * \file
4  *
5  * \brief Attribute protocol constants and definitions from the Bluetooth specification.
6  *
7  * Copyright (c) 2009-2019 Arm Ltd. All Rights Reserved.
8  *
9  * Copyright (c) 2019-2020 Packetcraft, Inc.
10  *
11  * Licensed under the Apache License, Version 2.0 (the "License");
12  * you may not use this file except in compliance with the License.
13  * You may obtain a copy of the License at
14  *
15  * http://www.apache.org/licenses/LICENSE-2.0
16  *
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  */
23 /*************************************************************************************************/
24 #ifndef ATT_DEFS_H
25 #define ATT_DEFS_H
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 /*! \addtogroup STACK_ATT_API
32  * \{ */
33 
34 /**************************************************************************************************
35  Macros
36 **************************************************************************************************/
37 
38 /** \name ATT PDU Format
39  * ATT PDU defaults and constants
40  */
41 /**@{*/
42 #define ATT_HDR_LEN 1 /*!< \brief Attribute PDU header length */
43 #define ATT_AUTH_SIG_LEN 12 /*!< \brief Authentication signature length */
44 #define ATT_DEFAULT_MTU 23 /*!< \brief Default value of ATT_MTU */
45 #define ATT_MAX_MTU 517 /*!< \brief Maximum value of ATT_MTU */
46 #define ATT_DEFAULT_PAYLOAD_LEN 20 /*!< \brief Default maximum payload length for most PDUs */
47 /**@}*/
48 
49 /** \name ATT Maximum Value Parameters
50  * maximum values for ATT attribute length and offset
51  */
52 /**@{*/
53 #define ATT_VALUE_MAX_LEN 512 /*!< \brief Maximum attribute value length */
54 #define ATT_VALUE_MAX_OFFSET 511 /*!< \brief Maximum attribute value offset */
55 /**@}*/
56 
57 /** \name ATT Transaction Timeout
58  * Maximum time allowed between transaction request and response.
59  */
60 /**@{*/
61 #define ATT_MAX_TRANS_TIMEOUT 30 /*!< \brief Maximum transaction timeout in seconds */
62 /**@}*/
63 
64 /** \name ATT Error Codes
65  * ATT Protocol operation status codes found in PDUs
66  */
67 /**@{*/
68 #define ATT_SUCCESS 0x00 /*!< \brief Operation successful */
69 #define ATT_ERR_HANDLE 0x01 /*!< \brief Invalid handle */
70 #define ATT_ERR_READ 0x02 /*!< \brief Read not permitted */
71 #define ATT_ERR_WRITE 0x03 /*!< \brief Write not permitted */
72 #define ATT_ERR_INVALID_PDU 0x04 /*!< \brief Invalid pdu */
73 #define ATT_ERR_AUTH 0x05 /*!< \brief Insufficient authentication */
74 #define ATT_ERR_NOT_SUP 0x06 /*!< \brief Request not supported */
75 #define ATT_ERR_OFFSET 0x07 /*!< \brief Invalid offset */
76 #define ATT_ERR_AUTHOR 0x08 /*!< \brief Insufficient authorization */
77 #define ATT_ERR_QUEUE_FULL 0x09 /*!< \brief Prepare queue full */
78 #define ATT_ERR_NOT_FOUND 0x0A /*!< \brief Attribute not found */
79 #define ATT_ERR_NOT_LONG 0x0B /*!< \brief Attribute not long */
80 #define ATT_ERR_KEY_SIZE 0x0C /*!< \brief Insufficient encryption key size */
81 #define ATT_ERR_LENGTH 0x0D /*!< \brief Invalid attribute value length */
82 #define ATT_ERR_UNLIKELY 0x0E /*!< \brief Other unlikely error */
83 #define ATT_ERR_ENC 0x0F /*!< \brief Insufficient encryption */
84 #define ATT_ERR_GROUP_TYPE 0x10 /*!< \brief Unsupported group type */
85 #define ATT_ERR_RESOURCES 0x11 /*!< \brief Insufficient resources */
86 #define ATT_ERR_DATABASE_OUT_OF_SYNC 0x12 /*!< \brief Client out of synch with database */
87 #define ATT_ERR_VALUE_NOT_ALLOWED 0x13 /*!< \brief Value not allowed */
88 #define ATT_ERR_WRITE_REJ 0xFC /*!< \brief Write request rejected */
89 #define ATT_ERR_CCCD 0xFD /*!< \brief CCCD improperly configured */
90 #define ATT_ERR_IN_PROGRESS 0xFE /*!< \brief Procedure already in progress */
91 #define ATT_ERR_RANGE 0xFF /*!< \brief Value out of range */
92 /**@}*/
93 
94 /** \name Proprietary Internal Error Codes
95  * These codes may be sent to application but are not present in any ATT PDU.
96  */
97 /**@{*/
98 #define ATT_ERR_MEMORY 0x70 /*!< \brief Out of memory */
99 #define ATT_ERR_TIMEOUT 0x71 /*!< \brief Transaction timeout */
100 #define ATT_ERR_OVERFLOW 0x72 /*!< \brief Transaction overflow */
101 #define ATT_ERR_INVALID_RSP 0x73 /*!< \brief Invalid response PDU */
102 #define ATT_ERR_CANCELLED 0x74 /*!< \brief Request cancelled */
103 #define ATT_ERR_UNDEFINED 0x75 /*!< \brief Other undefined error */
104 #define ATT_ERR_REQ_NOT_FOUND 0x76 /*!< \brief Required characteristic not found */
105 #define ATT_ERR_MTU_EXCEEDED 0x77 /*!< \brief Attribute PDU length exceeded MTU size */
106 #define ATT_ERR_NO_CHANNEL 0x78 /*!< \brief No enhanced channel available */
107 #define ATT_CONTINUING 0x79 /*!< \brief Procedure continuing */
108 #define ATT_RSP_PENDING 0x7A /*!< \brief Response delayed pending higher layer */
109 /**@}*/
110 
111 /** \name ATT Application Error Codes
112  * These codes may be sent to application but are not present in any ATT PDU.
113  */
114 /**@{*/
115 #define ATT_ERR_VALUE_RANGE 0x80 /*!< \brief Value out of range */
116 #define ATT_ERR_INVALID_CHANGE_CTR 0x80 /*!< \brief Invalid change counter */
117 #define ATT_ERR_OPCODE_NOT_SUPPORTED 0x81 /*!< \brief Opcode out of range */
118 #define ATT_ERR_MUTE_DISABLE 0x82 /*!< \brief Mute disable */
119 #define ATT_ERR_VALUE_RANGE_x83 0x83 /*!< \brief Value out of range 0x83 */
120 /**@}*/
121 
122 /** \name ATT HCI Error Status
123  *
124  */
125 /**@{*/
126 /*! \brief Base value for HCI error status values passed through ATT.
127  * Since the values of HCI and ATT error codes overlap, the constant
128  * \ref ATT_HCI_ERR_BASE is added to HCI error codes before being passed through ATT.
129  * See \ref HCI_SUCCESS for HCI error code values.
130  */
131 #define ATT_HCI_ERR_BASE 0x20
132 /**@}*/
133 
134 /** \name ATT PDU Types
135  * PDU Types for all possible over-the-air ATT operations.
136  */
137 /**@{*/
138 #define ATT_PDU_ERR_RSP 0x01 /*!< \brief Error response */
139 #define ATT_PDU_MTU_REQ 0x02 /*!< \brief Exchange mtu request */
140 #define ATT_PDU_MTU_RSP 0x03 /*!< \brief Exchange mtu response */
141 #define ATT_PDU_FIND_INFO_REQ 0x04 /*!< \brief Find information request */
142 #define ATT_PDU_FIND_INFO_RSP 0x05 /*!< \brief Find information response */
143 #define ATT_PDU_FIND_TYPE_REQ 0x06 /*!< \brief Find by type value request */
144 #define ATT_PDU_FIND_TYPE_RSP 0x07 /*!< \brief Find by type value response */
145 #define ATT_PDU_READ_TYPE_REQ 0x08 /*!< \brief Read by type request */
146 #define ATT_PDU_READ_TYPE_RSP 0x09 /*!< \brief Read by type response */
147 #define ATT_PDU_READ_REQ 0x0A /*!< \brief Read request */
148 #define ATT_PDU_READ_RSP 0x0B /*!< \brief Read response */
149 #define ATT_PDU_READ_BLOB_REQ 0x0C /*!< \brief Read blob request */
150 #define ATT_PDU_READ_BLOB_RSP 0x0D /*!< \brief Read blob response */
151 #define ATT_PDU_READ_MULT_REQ 0x0E /*!< \brief Read multiple request */
152 #define ATT_PDU_READ_MULT_RSP 0x0F /*!< \brief Read multiple response */
153 #define ATT_PDU_READ_GROUP_TYPE_REQ 0x10 /*!< \brief Read by group type request */
154 #define ATT_PDU_READ_GROUP_TYPE_RSP 0x11 /*!< \brief Read by group type response */
155 #define ATT_PDU_WRITE_REQ 0x12 /*!< \brief Write request */
156 #define ATT_PDU_WRITE_RSP 0x13 /*!< \brief Write response */
157 #define ATT_PDU_WRITE_CMD 0x52 /*!< \brief Write command */
158 #define ATT_PDU_SIGNED_WRITE_CMD 0xD2 /*!< \brief Signed write command */
159 #define ATT_PDU_PREP_WRITE_REQ 0x16 /*!< \brief Prepare write request */
160 #define ATT_PDU_PREP_WRITE_RSP 0x17 /*!< \brief Prepare write response */
161 #define ATT_PDU_EXEC_WRITE_REQ 0x18 /*!< \brief Execute write request */
162 #define ATT_PDU_EXEC_WRITE_RSP 0x19 /*!< \brief Execute write response */
163 #define ATT_PDU_VALUE_NTF 0x1B /*!< \brief Handle value notification */
164 #define ATT_PDU_VALUE_IND 0x1D /*!< \brief Handle value indication */
165 #define ATT_PDU_VALUE_CNF 0x1E /*!< \brief Handle value confirmation */
166 #define ATT_PDU_READ_MULT_VAR_REQ 0x20 /*!< \brief Read multiple variable length request */
167 #define ATT_PDU_READ_MULT_VAR_RSP 0x21 /*!< \brief Read multiple variable length response */
168 #define ATT_PDU_MULT_VALUE_NTF 0x23 /*!< \brief Handle value multiple notification */
169 /**@}*/
170 
171 /** \name ATT PDU Length Fields
172  * Length constants of PDU fixed length fields
173  */
174 /**@{*/
175 #define ATT_ERR_RSP_LEN 5 /*!< \brief Error response length. */
176 #define ATT_MTU_REQ_LEN 3 /*!< \brief MTU request length. */
177 #define ATT_MTU_RSP_LEN 3 /*!< \brief MTU response length. */
178 #define ATT_FIND_INFO_REQ_LEN 5 /*!< \brief Find information request length. */
179 #define ATT_FIND_INFO_RSP_LEN 2 /*!< \brief Find information response length. */
180 #define ATT_FIND_TYPE_REQ_LEN 7 /*!< \brief Find type request length. */
181 #define ATT_FIND_TYPE_RSP_LEN 1 /*!< \brief Find type response length. */
182 #define ATT_READ_TYPE_REQ_LEN 5 /*!< \brief Read type request length. */
183 #define ATT_READ_TYPE_RSP_LEN 2 /*!< \brief Read type response length. */
184 #define ATT_READ_REQ_LEN 3 /*!< \brief Read request length. */
185 #define ATT_READ_RSP_LEN 1 /*!< \brief Read response length. */
186 #define ATT_READ_BLOB_REQ_LEN 5 /*!< \brief Read blob request legnth. */
187 #define ATT_READ_BLOB_RSP_LEN 1 /*!< \brief Read blob response length. */
188 #define ATT_READ_MULT_REQ_LEN 1 /*!< \brief Read multiple request length. */
189 #define ATT_READ_MULT_RSP_LEN 1 /*!< \brief Read multiple response length. */
190 #define ATT_READ_GROUP_TYPE_REQ_LEN 5 /*!< \brief Read group type request length. */
191 #define ATT_READ_GROUP_TYPE_RSP_LEN 2 /*!< \brief Read group type response length. */
192 #define ATT_WRITE_REQ_LEN 3 /*!< \brief Write request length. */
193 #define ATT_WRITE_RSP_LEN 1 /*!< \brief Write response length. */
194 #define ATT_WRITE_CMD_LEN 3 /*!< \brief Write command length. */
195 #define ATT_SIGNED_WRITE_CMD_LEN (ATT_WRITE_CMD_LEN + ATT_AUTH_SIG_LEN) /*!< \brief Signed write command length. */
196 #define ATT_PREP_WRITE_REQ_LEN 5 /*!< \brief Prepared write command length. */
197 #define ATT_PREP_WRITE_RSP_LEN 5 /*!< \brief Prepared write response length. */
198 #define ATT_EXEC_WRITE_REQ_LEN 2 /*!< \brief Execute write request length. */
199 #define ATT_EXEC_WRITE_RSP_LEN 1 /*!< \brief Execute write response length. */
200 #define ATT_VALUE_NTF_LEN 3 /*!< \brief Value notification length. */
201 #define ATT_VALUE_IND_LEN 3 /*!< \brief Value indication length. */
202 #define ATT_VALUE_CNF_LEN 1 /*!< \brief Value confirmation length. */
203 #define ATT_READ_MULT_VAR_REQ_LEN 1 /*!< \brief Base read multiple variable request length. */
204 #define ATT_READ_MULT_VAR_RSP_LEN 1 /*!< \brief Base read multiple variable response length. */
205 #define ATT_PDU_MULT_VALUE_NTF_LEN 1 /*!< \brief Base multiple variable notification length. */
206 /**@}*/
207 
208 /** \name ATT Find Information Response Format
209  *
210  */
211 /**@{*/
212 #define ATT_FIND_HANDLE_16_UUID 0x01 /*!< \brief Handle and 16 bit UUID */
213 #define ATT_FIND_HANDLE_128_UUID 0x02 /*!< \brief Handle and 128 bit UUID */
214 /**@}*/
215 
216 /** \name ATT Execute Write Request Flags
217  *
218  */
219 /**@{*/
220 #define ATT_EXEC_WRITE_CANCEL 0x00 /*!< \brief Cancel all prepared writes */
221 #define ATT_EXEC_WRITE_ALL 0x01 /*!< \brief Write all pending prepared writes */
222 /**@}*/
223 
224 /** \name ATT PDU Masks
225  *
226  */
227 /**@{*/
228 #define ATT_PDU_MASK_SERVER 0x01 /*!< \brief Server bit mask */
229 #define ATT_PDU_MASK_COMMAND 0x40 /*!< \brief Command bit mask */
230 #define ATT_PDU_MASK_SIGNED 0x80 /*!< \brief Auth signature bit mask */
231 /**@}*/
232 
233 /** \name ATT Handle Constants
234  * Invalid, minimum and maximum handle values.
235  */
236 /**@{*/
237 #define ATT_HANDLE_NONE 0x0000 /*!< \brief Handle none. */
238 #define ATT_HANDLE_START 0x0001 /*!< \brief Handle start. */
239 #define ATT_HANDLE_MAX 0xFFFF /*!< \brief Handle max. */
240 /**@}*/
241 
242 /** \name ATT UUID Lengths
243  *
244  */
245 /**@{*/
246 #define ATT_NO_UUID_LEN 0 /*!< \brief Length when no UUID is present ;-) */
247 #define ATT_16_UUID_LEN 2 /*!< \brief Length in bytes of a 16 bit UUID */
248 #define ATT_128_UUID_LEN 16 /*!< \brief Length in bytes of a 128 bit UUID */
249 /**@}*/
250 
251 /** \name GATT Characteristic Properties
252  * Properties for how a characteristic may be interacted with through the ATT Protocol.
253  */
254 /**@{*/
255 #define ATT_PROP_BROADCAST 0x01 /*!< \brief Permit broadcasts */
256 #define ATT_PROP_READ 0x02 /*!< \brief Permit reads */
257 #define ATT_PROP_WRITE_NO_RSP 0x04 /*!< \brief Permit writes without response */
258 #define ATT_PROP_WRITE 0x08 /*!< \brief Permit writes with response */
259 #define ATT_PROP_NOTIFY 0x10 /*!< \brief Permit notifications */
260 #define ATT_PROP_INDICATE 0x20 /*!< \brief Permit indications */
261 #define ATT_PROP_AUTHENTICATED 0x40 /*!< \brief Permit signed writes */
262 #define ATT_PROP_EXTENDED 0x80 /*!< \brief More properties defined in extended properties */
263 /**@}*/
264 
265 /** \name GATT Characteristic Extended Properties
266  *
267  */
268 /**@{*/
269 #define ATT_EXT_PROP_RELIABLE_WRITE 0x0001 /*!< \brief Permit reliable writes */
270 #define ATT_EXT_PROP_WRITEABLE_AUX 0x0002 /*!< \brief Permit write to characteristic descriptor */
271 /**@}*/
272 
273 /** \name GATT Client Charactertic Configuration
274  * Configures a characteristic to send notifications or indications, if applicable.
275  */
276 /**@{*/
277 #define ATT_CLIENT_CFG_NOTIFY 0x0001 /*!< \brief Notify the value */
278 #define ATT_CLIENT_CFG_INDICATE 0x0002 /*!< \brief Indicate the value */
279 /**@}*/
280 
281 /** \name GATT Server Characteristic Configuration
282  *
283  */
284 /**@{*/
285 #define ATT_SERVER_CFG_BROADCAST 0x0001 /*!< \brief Broadcast the value */
286 /**@}*/
287 
288 /** \name GATT Characteristic Format
289  * GATT Format descriptor values
290  */
291 /**@{*/
292 #define ATT_FORMAT_BOOLEAN 0x01 /*!< \brief Boolean */
293 #define ATT_FORMAT_2BIT 0x02 /*!< \brief Unsigned 2 bit integer */
294 #define ATT_FORMAT_NIBBLE 0x03 /*!< \brief Unsigned 4 bit integer */
295 #define ATT_FORMAT_UINT8 0x04 /*!< \brief Unsigned 8 bit integer */
296 #define ATT_FORMAT_UINT12 0x05 /*!< \brief Unsigned 12 bit integer */
297 #define ATT_FORMAT_UINT16 0x06 /*!< \brief Unsigned 16 bit integer */
298 #define ATT_FORMAT_UINT24 0x07 /*!< \brief Unsigned 24 bit integer */
299 #define ATT_FORMAT_UINT32 0x08 /*!< \brief Unsigned 32 bit integer */
300 #define ATT_FORMAT_UINT48 0x09 /*!< \brief Unsigned 48 bit integer */
301 #define ATT_FORMAT_UINT64 0x0A /*!< \brief Unsigned 64 bit integer */
302 #define ATT_FORMAT_UINT128 0x0B /*!< \brief Unsigned 128 bit integer */
303 #define ATT_FORMAT_SINT8 0x0C /*!< \brief Signed 8 bit integer */
304 #define ATT_FORMAT_SINT12 0x0D /*!< \brief Signed 12 bit integer */
305 #define ATT_FORMAT_SINT16 0x0E /*!< \brief Signed 16 bit integer */
306 #define ATT_FORMAT_SINT24 0x0F /*!< \brief Signed 24 bit integer */
307 #define ATT_FORMAT_SINT32 0x10 /*!< \brief Signed 32 bit integer */
308 #define ATT_FORMAT_SINT48 0x11 /*!< \brief Signed 48 bit integer */
309 #define ATT_FORMAT_SINT64 0x12 /*!< \brief Signed 64 bit integer */
310 #define ATT_FORMAT_SINT128 0x13 /*!< \brief Signed 128 bit integer */
311 #define ATT_FORMAT_FLOAT32 0x14 /*!< \brief IEEE-754 32 bit floating point */
312 #define ATT_FORMAT_FLOAT64 0x15 /*!< \brief IEEE-754 64 bit floating point */
313 #define ATT_FORMAT_SFLOAT 0x16 /*!< \brief IEEE-11073 16 bit SFLOAT */
314 #define ATT_FORMAT_FLOAT 0x17 /*!< \brief IEEE-11073 32 bit FLOAT */
315 #define ATT_FORMAT_DUINT16 0x18 /*!< \brief IEEE-20601 format */
316 #define ATT_FORMAT_UTF8 0x19 /*!< \brief UTF-8 string */
317 #define ATT_FORMAT_UTF16 0x1A /*!< \brief UTF-16 string */
318 #define ATT_FORMAT_STRUCT 0x1B /*!< \brief Opaque structure */
319 /**@}*/
320 
321 /** \name GATT Database Hash
322 * GATT database hash values
323 */
324 /**@{*/
325 #define ATT_DATABASE_HASH_LEN 16 /*!< \brief Database hash length. */
326 /**@}*/
327 
328 /** \name GATT Client Supported Features
329 * Flags of features supported by the GATT Client
330 */
331 /**@{*/
332 #define ATTS_CSF_ROBUST_CACHING (1<<0) /*!< \brief Robust caching. */
333 #define ATTS_CSF_EATT_BEARER (1<<1) /*!< \brief Enhanced ATT Bearer. */
334 #define ATTS_CSF_MULTI_VAL_NTF (1<<2) /*!< \brief Multiple Handle Value Notifications. */
335 
336 #define ATTS_CSF_ALL_FEATURES (0x7) /*!< \brief Mask of all client supported features. */
337 
338 #define ATT_CSF_LEN 1 /*!< \brief Length of client supported features array. */
339 /**@}*/
340 
341 /** \name GATT Server Supported Features
342 * Flags of features supported by the GATT Server
343 */
344 /**@{*/
345 #define ATTS_SSF_EATT (1<<0) /*!< \brief Enhanced ATT supported. */
346 /**@}*/
347 
348 /*! \} */ /* STACK_ATT_API */
349 
350 #ifdef __cplusplus
351 };
352 #endif
353 
354 #endif /* ATT_DEFS_H */
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.