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