1 /**
2  ****************************************************************************************
3  *
4  * @file rwble_hl_error.h
5  *
6  * @brief File that contains all error codes.
7  *
8  * Copyright (C) RivieraWaves 2009-2016
9  *
10  *
11  ****************************************************************************************
12  */
13 
14 #ifndef RWBLE_HL_ERROR_H_
15 #define RWBLE_HL_ERROR_H_
16 
17 
18 /**
19  ****************************************************************************************
20  * @addtogroup ROOT
21  * @brief High layer error codes
22  *
23  * This module contains the primitives that allow an application accessing and running the
24  * BLE protocol stack
25  *
26  * @{
27  ****************************************************************************************
28  */
29 
30 
31 
32 /// Error code from HCI TO HL Range - from 0x90 to 0xD0
33 #define RW_ERR_HCI_TO_HL(err)     (((err) != 0) ? ((err) + 0x90) : (0))
34 
35 
36 /// Error code from HL TO HCI Range - from 0x90 to 0xD0
37 #define RW_ERR_HL_TO_HCI(err)     (((err) > 0x90) ? ((err) - 0x90) : (0))
38 
39 /**
40  * List all HL error codes
41  */
42 enum hl_err
43 {
44     /// No error
45     GAP_ERR_NO_ERROR                                                               = 0x00,
46 
47     // ----------------------------------------------------------------------------------
48     // -------------------------  ATT Specific Error ------------------------------------
49     // ----------------------------------------------------------------------------------
50     /// No error
51     ATT_ERR_NO_ERROR                                                               = 0x00,
52     /// 0x01: Handle is invalid
53     ATT_ERR_INVALID_HANDLE                                                         = 0x01,
54     /// 0x02: Read permission disabled
55     ATT_ERR_READ_NOT_PERMITTED                                                     = 0x02,
56     /// 0x03: Write permission disabled
57     ATT_ERR_WRITE_NOT_PERMITTED                                                    = 0x03,
58     /// 0x04: Incorrect PDU
59     ATT_ERR_INVALID_PDU                                                            = 0x04,
60     /// 0x05: Authentication privilege not enough
61     ATT_ERR_INSUFF_AUTHEN                                                          = 0x05,
62     /// 0x06: Request not supported or not understood
63     ATT_ERR_REQUEST_NOT_SUPPORTED                                                  = 0x06,
64     /// 0x07: Incorrect offset value
65     ATT_ERR_INVALID_OFFSET                                                         = 0x07,
66     /// 0x08: Authorization privilege not enough
67     ATT_ERR_INSUFF_AUTHOR                                                          = 0x08,
68     /// 0x09: Capacity queue for reliable write reached
69     ATT_ERR_PREPARE_QUEUE_FULL                                                     = 0x09,
70     /// 0x0A: Attribute requested not existing
71     ATT_ERR_ATTRIBUTE_NOT_FOUND                                                    = 0x0A,
72     /// 0x0B: Attribute requested not long
73     ATT_ERR_ATTRIBUTE_NOT_LONG                                                     = 0x0B,
74     /// 0x0C: Encryption size not sufficient
75     ATT_ERR_INSUFF_ENC_KEY_SIZE                                                    = 0x0C,
76     /// 0x0D: Invalid length of the attribute value
77     ATT_ERR_INVALID_ATTRIBUTE_VAL_LEN                                              = 0x0D,
78     /// 0x0E: Operation not fit to condition
79     ATT_ERR_UNLIKELY_ERR                                                           = 0x0E,
80     /// 0x0F: Attribute requires encryption before operation
81     ATT_ERR_INSUFF_ENC                                                             = 0x0F,
82     /// 0x10: Attribute grouping not supported
83     ATT_ERR_UNSUPP_GRP_TYPE                                                        = 0x10,
84     /// 0x11: Resources not sufficient to complete the request
85     ATT_ERR_INSUFF_RESOURCE                                                        = 0x11,
86     /// 0x80: Application error (also used in PRF Errors)
87     ATT_ERR_APP_ERROR                                                              = 0x80,
88 
89     // ----------------------------------------------------------------------------------
90     // -------------------------- L2C Specific Error ------------------------------------
91     // ----------------------------------------------------------------------------------
92     /// Message cannot be sent because connection lost. (disconnected)
93     L2C_ERR_CONNECTION_LOST                                                        = 0x30,
94     /// Invalid PDU length exceed MTU
95     L2C_ERR_INVALID_MTU_EXCEED                                                     = 0x31,
96     /// Invalid PDU length exceed MPS
97     L2C_ERR_INVALID_MPS_EXCEED                                                     = 0x32,
98     /// Invalid Channel ID
99     L2C_ERR_INVALID_CID                                                            = 0x33,
100     /// Invalid PDU
101     L2C_ERR_INVALID_PDU                                                            = 0x34,
102     /// Connection refused - no resources available
103     L2C_ERR_NO_RES_AVAIL                                                           = 0x35,
104     /// Connection refused - insufficient authentication
105     L2C_ERR_INSUFF_AUTHEN                                                          = 0x36,
106     /// Connection refused - insufficient authorization
107     L2C_ERR_INSUFF_AUTHOR                                                          = 0x37,
108     /// Connection refused - insufficient encryption key size
109     L2C_ERR_INSUFF_ENC_KEY_SIZE                                                    = 0x38,
110     /// Connection Refused - insufficient encryption
111     L2C_ERR_INSUFF_ENC                                                             = 0x39,
112     /// Connection refused - LE_PSM not supported
113     L2C_ERR_LEPSM_NOT_SUPP                                                         = 0x3A,
114     /// No more credit
115     L2C_ERR_INSUFF_CREDIT                                                          = 0x3B,
116     /// Command not understood by peer device
117     L2C_ERR_NOT_UNDERSTOOD                                                         = 0x3C,
118     /// Credit error, invalid number of credit received
119     L2C_ERR_CREDIT_ERROR                                                           = 0x3D,
120     /// Channel identifier already allocated
121     L2C_ERR_CID_ALREADY_ALLOC                                                      = 0x3E,
122 
123 
124     // ----------------------------------------------------------------------------------
125     // -------------------------- GAP Specific Error ------------------------------------
126     // ----------------------------------------------------------------------------------
127     /// Invalid parameters set
128     GAP_ERR_INVALID_PARAM                                                          = 0x40,
129     /// Problem with protocol exchange, get unexpected response
130     GAP_ERR_PROTOCOL_PROBLEM                                                       = 0x41,
131     /// Request not supported by software configuration
132     GAP_ERR_NOT_SUPPORTED                                                          = 0x42,
133     /// Request not allowed in current state.
134     GAP_ERR_COMMAND_DISALLOWED                                                     = 0x43,
135     /// Requested operation canceled.
136     GAP_ERR_CANCELED                                                               = 0x44,
137     /// Requested operation timeout.
138     GAP_ERR_TIMEOUT                                                                = 0x45,
139     /// Link connection lost during operation.
140     GAP_ERR_DISCONNECTED                                                           = 0x46,
141     /// Search algorithm finished, but no result found
142     GAP_ERR_NOT_FOUND                                                              = 0x47,
143     /// Request rejected by peer device
144     GAP_ERR_REJECTED                                                               = 0x48,
145     /// Problem with privacy configuration
146     GAP_ERR_PRIVACY_CFG_PB                                                         = 0x49,
147     /// Duplicate or invalid advertising data
148     GAP_ERR_ADV_DATA_INVALID                                                       = 0x4A,
149     /// Insufficient resources
150     GAP_ERR_INSUFF_RESOURCES                                                       = 0x4B,
151     /// Unexpected Error
152     GAP_ERR_UNEXPECTED                                                             = 0x4C,
153     /// Feature mismatch
154     GAP_ERR_MISMATCH                                                               = 0x4D,
155 
156 
157     // ----------------------------------------------------------------------------------
158     // ------------------------- GATT Specific Error ------------------------------------
159     // ----------------------------------------------------------------------------------
160     /// Problem with ATTC protocol response
161     GATT_ERR_INVALID_ATT_LEN                                                       = 0x50,
162     /// Error in service search
163     GATT_ERR_INVALID_TYPE_IN_SVC_SEARCH                                            = 0x51,
164     /// Invalid write data
165     GATT_ERR_WRITE                                                                 = 0x52,
166     /// Signed write error
167     GATT_ERR_SIGNED_WRITE                                                          = 0x53,
168     /// No attribute client defined
169     GATT_ERR_ATTRIBUTE_CLIENT_MISSING                                              = 0x54,
170     /// No attribute server defined
171     GATT_ERR_ATTRIBUTE_SERVER_MISSING                                              = 0x55,
172     /// Permission set in service/attribute are invalid
173     GATT_ERR_INVALID_PERM                                                          = 0x56,
174 
175     // ----------------------------------------------------------------------------------
176     // ------------------------- SMP Specific Error -------------------------------------
177     // ----------------------------------------------------------------------------------
178     // SMP Protocol Errors detected on local device
179     /// The user input of pass key failed, for example, the user canceled the operation.
180     SMP_ERROR_LOC_PASSKEY_ENTRY_FAILED                                             = 0x61,
181     /// The OOB Data is not available.
182     SMP_ERROR_LOC_OOB_NOT_AVAILABLE                                                = 0x62,
183     /// The pairing procedure cannot be performed as authentication requirements cannot be met
184     /// due to IO capabilities of one or both devices.
185     SMP_ERROR_LOC_AUTH_REQ                                                         = 0x63,
186     /// The confirm value does not match the calculated confirm value.
187     SMP_ERROR_LOC_CONF_VAL_FAILED                                                  = 0x64,
188     /// Pairing is not supported by the device.
189     SMP_ERROR_LOC_PAIRING_NOT_SUPP                                                 = 0x65,
190     /// The resultant encryption key size is insufficient for the security requirements of
191     /// this device.
192     SMP_ERROR_LOC_ENC_KEY_SIZE                                                     = 0x66,
193     /// The SMP command received is not supported on this device.
194     SMP_ERROR_LOC_CMD_NOT_SUPPORTED                                                = 0x67,
195     /// Pairing failed due to an unspecified reason.
196     SMP_ERROR_LOC_UNSPECIFIED_REASON                                               = 0x68,
197     /// Pairing or Authentication procedure is disallowed because too little time has elapsed
198     /// since last pairing request or security request.
199     SMP_ERROR_LOC_REPEATED_ATTEMPTS                                                = 0x69,
200     /// The command length is invalid or a parameter is outside of the specified range.
201     SMP_ERROR_LOC_INVALID_PARAM                                                    = 0x6A,
202     /// Indicates to the remote device that the DHKey Check value received doesn't
203     /// match the one calculated by the local device.
204     SMP_ERROR_LOC_DHKEY_CHECK_FAILED                                               = 0x6B,
205     /// Indicates that the confirm values in the numeric comparison protocol do not match.
206     SMP_ERROR_LOC_NUMERIC_COMPARISON_FAILED                                        = 0x6C,
207     /// Indicates that the pairing over the LE transport failed due to a Pairing Request sent
208     /// over the BR/EDR transport in process.
209     SMP_ERROR_LOC_BREDR_PAIRING_IN_PROGRESS                                        = 0x6D,
210     /// Indicates that the BR/EDR Link Key generated on the BR/EDR transport cannot be
211     /// used to derive and distribute keys for the LE transport.
212     SMP_ERROR_LOC_CROSS_TRANSPORT_KEY_GENERATION_NOT_ALLOWED                       = 0x6E,
213     // SMP Protocol Errors detected by remote device
214     /// The user input of passkey failed, for example, the user canceled the operation.
215     SMP_ERROR_REM_PASSKEY_ENTRY_FAILED                                             = 0x71,
216     /// The OOB Data is not available.
217     SMP_ERROR_REM_OOB_NOT_AVAILABLE                                                = 0x72,
218     /// The pairing procedure cannot be performed as authentication requirements cannot be
219     /// met due to IO capabilities of one or both devices.
220     SMP_ERROR_REM_AUTH_REQ                                                         = 0x73,
221     /// The confirm value does not match the calculated confirm value.
222     SMP_ERROR_REM_CONF_VAL_FAILED                                                  = 0x74,
223     /// Pairing is not supported by the device.
224     SMP_ERROR_REM_PAIRING_NOT_SUPP                                                 = 0x75,
225     /// The resultant encryption key size is insufficient for the security requirements of
226     /// this device.
227     SMP_ERROR_REM_ENC_KEY_SIZE                                                     = 0x76,
228     /// The SMP command received is not supported on this device.
229     SMP_ERROR_REM_CMD_NOT_SUPPORTED                                                = 0x77,
230     /// Pairing failed due to an unspecified reason.
231     SMP_ERROR_REM_UNSPECIFIED_REASON                                               = 0x78,
232     /// Pairing or Authentication procedure is disallowed because too little time has elapsed
233     /// since last pairing request or security request.
234     SMP_ERROR_REM_REPEATED_ATTEMPTS                                                = 0x79,
235     /// The command length is invalid or a parameter is outside of the specified range.
236     SMP_ERROR_REM_INVALID_PARAM                                                    = 0x7A,
237     /// Indicates to the remote device that the DHKey Check value received doesn't
238     /// match the one calculated by the local device.
239     SMP_ERROR_REM_DHKEY_CHECK_FAILED                                               = 0x7B,
240     /// Indicates that the confirm values in the numeric comparison protocol do not match.
241     SMP_ERROR_REM_NUMERIC_COMPARISON_FAILED                                        = 0x7C,
242     /// Indicates that the pairing over the LE transport failed due to a Pairing Request sent
243     /// over the BR/EDR transport in process.
244     SMP_ERROR_REM_BREDR_PAIRING_IN_PROGRESS                                        = 0x7D,
245     /// Indicates that the BR/EDR Link Key generated on the BR/EDR transport cannot be
246     /// used to derive and distribute keys for the LE transport.
247     SMP_ERROR_REM_CROSS_TRANSPORT_KEY_GENERATION_NOT_ALLOWED                       = 0x7E,
248     // SMP Errors triggered by local device
249     /// The provided resolvable address has not been resolved.
250     SMP_ERROR_ADDR_RESOLV_FAIL                                                     = 0xD0,
251     /// The Signature Verification Failed
252     SMP_ERROR_SIGN_VERIF_FAIL                                                      = 0xD1,
253     /// The encryption procedure failed because the slave device didn't find the LTK
254     /// needed to start an encryption session.
255     SMP_ERROR_ENC_KEY_MISSING                                                      = 0xD2,
256     /// The encryption procedure failed because the slave device doesn't support the
257     /// encryption feature.
258     SMP_ERROR_ENC_NOT_SUPPORTED                                                    = 0xD3,
259     /// A timeout has occurred during the start encryption session.
260     SMP_ERROR_ENC_TIMEOUT                                                          = 0xD4,
261 
262     // ----------------------------------------------------------------------------------
263     //------------------------ Profiles specific error codes ----------------------------
264     // ----------------------------------------------------------------------------------
265     /// Application Error
266     PRF_APP_ERROR                                                                  = 0x80,
267     /// Invalid parameter in request
268     PRF_ERR_INVALID_PARAM                                                          = 0x81,
269     /// Inexistent handle for sending a read/write characteristic request
270     PRF_ERR_INEXISTENT_HDL                                                         = 0x82,
271     /// Discovery stopped due to missing attribute according to specification
272     PRF_ERR_STOP_DISC_CHAR_MISSING                                                 = 0x83,
273     /// Too many SVC instances found -> protocol violation
274     PRF_ERR_MULTIPLE_SVC                                                           = 0x84,
275     /// Discovery stopped due to found attribute with incorrect properties
276     PRF_ERR_STOP_DISC_WRONG_CHAR_PROP                                              = 0x85,
277     /// Too many Char. instances found-> protocol violation
278     PRF_ERR_MULTIPLE_CHAR                                                          = 0x86,
279     /// Attribute write not allowed
280     PRF_ERR_NOT_WRITABLE                                                           = 0x87,
281     /// Attribute read not allowed
282     PRF_ERR_NOT_READABLE                                                           = 0x88,
283     /// Request not allowed
284     PRF_ERR_REQ_DISALLOWED                                                         = 0x89,
285     /// Notification Not Enabled
286     PRF_ERR_NTF_DISABLED                                                           = 0x8A,
287     /// Indication Not Enabled
288     PRF_ERR_IND_DISABLED                                                           = 0x8B,
289     /// Feature not supported by profile
290     PRF_ERR_FEATURE_NOT_SUPPORTED                                                  = 0x8C,
291     /// Read value has an unexpected length
292     PRF_ERR_UNEXPECTED_LEN                                                         = 0x8D,
293     /// Disconnection occurs
294     PRF_ERR_DISCONNECTED                                                           = 0x8E,
295     /// Procedure Timeout
296     PRF_ERR_PROC_TIMEOUT                                                           = 0x8F,
297     /// Client characteristic configuration improperly configured
298     PRF_CCCD_IMPR_CONFIGURED                                                       = 0xFD,
299     /// Procedure already in progress
300     PRF_PROC_IN_PROGRESS                                                           = 0xFE,
301     /// Out of Range
302     PRF_OUT_OF_RANGE                                                               = 0xFF,
303 
304     // ----------------------------------------------------------------------------------
305     //-------------------- LL Error codes conveyed to upper layer -----------------------
306     // ----------------------------------------------------------------------------------
307     /// Unknown HCI Command
308     LL_ERR_UNKNOWN_HCI_COMMAND                                                     = 0x91,
309     /// Unknown Connection Identifier
310     LL_ERR_UNKNOWN_CONNECTION_ID                                                   = 0x92,
311     /// Hardware Failure
312     LL_ERR_HARDWARE_FAILURE                                                        = 0x93,
313     /// BT Page Timeout
314     LL_ERR_PAGE_TIMEOUT                                                            = 0x94,
315     /// Authentication failure
316     LL_ERR_AUTH_FAILURE                                                            = 0x95,
317     /// Pin code missing
318     LL_ERR_PIN_MISSING                                                             = 0x96,
319     /// Memory capacity exceed
320     LL_ERR_MEMORY_CAPA_EXCEED                                                      = 0x97,
321     /// Connection Timeout
322     LL_ERR_CON_TIMEOUT                                                             = 0x98,
323     /// Connection limit Exceed
324     LL_ERR_CON_LIMIT_EXCEED                                                        = 0x99,
325     /// Synchronous Connection limit exceed
326     LL_ERR_SYNC_CON_LIMIT_DEV_EXCEED                                               = 0x9A,
327     /// ACL Connection exits
328     LL_ERR_ACL_CON_EXISTS                                                          = 0x9B,
329     /// Command Disallowed
330     LL_ERR_COMMAND_DISALLOWED                                                      = 0x9C,
331     /// Connection rejected due to limited resources
332     LL_ERR_CONN_REJ_LIMITED_RESOURCES                                              = 0x9D,
333     /// Connection rejected due to security reason
334     LL_ERR_CONN_REJ_SECURITY_REASONS                                               = 0x9E,
335     /// Connection rejected due to unacceptable BD Addr
336     LL_ERR_CONN_REJ_UNACCEPTABLE_BDADDR                                            = 0x9F,
337     /// Connection rejected due to Accept connection timeout
338     LL_ERR_CONN_ACCEPT_TIMEOUT_EXCEED                                              = 0xA0,
339     /// Not Supported
340     LL_ERR_UNSUPPORTED                                                             = 0xA1,
341     /// invalid parameters
342     LL_ERR_INVALID_HCI_PARAM                                                       = 0xA2,
343     /// Remote user terminate connection
344     LL_ERR_REMOTE_USER_TERM_CON                                                    = 0xA3,
345     /// Remote device terminate connection due to low resources
346     LL_ERR_REMOTE_DEV_TERM_LOW_RESOURCES                                           = 0xA4,
347     /// Remote device terminate connection due to power off
348     LL_ERR_REMOTE_DEV_POWER_OFF                                                    = 0xA5,
349     /// Connection terminated by local host
350     LL_ERR_CON_TERM_BY_LOCAL_HOST                                                  = 0xA6,
351     /// Repeated attempts
352     LL_ERR_REPEATED_ATTEMPTS                                                       = 0xA7,
353     /// Pairing not Allowed
354     LL_ERR_PAIRING_NOT_ALLOWED                                                     = 0xA8,
355     /// Unknown PDU Error
356     LL_ERR_UNKNOWN_LMP_PDU                                                         = 0xA9,
357     /// Unsupported remote feature
358     LL_ERR_UNSUPPORTED_REMOTE_FEATURE                                              = 0xAA,
359     /// Sco Offset rejected
360     LL_ERR_SCO_OFFSET_REJECTED                                                     = 0xAB,
361     /// SCO Interval Rejected
362     LL_ERR_SCO_INTERVAL_REJECTED                                                   = 0xAC,
363     /// SCO air mode Rejected
364     LL_ERR_SCO_AIR_MODE_REJECTED                                                   = 0xAD,
365     /// Invalid LMP parameters
366     LL_ERR_INVALID_LMP_PARAM                                                       = 0xAE,
367     /// Unspecified error
368     LL_ERR_UNSPECIFIED_ERROR                                                       = 0xAF,
369     /// Unsupported LMP Parameter value
370     LL_ERR_UNSUPPORTED_LMP_PARAM_VALUE                                             = 0xB0,
371     /// Role Change Not allowed
372     LL_ERR_ROLE_CHANGE_NOT_ALLOWED                                                 = 0xB1,
373     /// LMP Response timeout
374     LL_ERR_LMP_RSP_TIMEOUT                                                         = 0xB2,
375     /// LMP Collision
376     LL_ERR_LMP_COLLISION                                                           = 0xB3,
377     /// LMP Pdu not allowed
378     LL_ERR_LMP_PDU_NOT_ALLOWED                                                     = 0xB4,
379     /// Encryption mode not accepted
380     LL_ERR_ENC_MODE_NOT_ACCEPT                                                     = 0xB5,
381     /// Link Key Cannot be changed
382     LL_ERR_LINK_KEY_CANT_CHANGE                                                    = 0xB6,
383     /// Quality of Service not supported
384     LL_ERR_QOS_NOT_SUPPORTED                                                       = 0xB7,
385     /// Error, instant passed
386     LL_ERR_INSTANT_PASSED                                                          = 0xB8,
387     /// Pairing with unit key not supported
388     LL_ERR_PAIRING_WITH_UNIT_KEY_NOT_SUP                                           = 0xB9,
389     /// Transaction collision
390     LL_ERR_DIFF_TRANSACTION_COLLISION                                              = 0xBA,
391     /// Unacceptable parameters
392     LL_ERR_QOS_UNACCEPTABLE_PARAM                                                  = 0xBC,
393     /// Quality of Service rejected
394     LL_ERR_QOS_REJECTED                                                            = 0xBD,
395     /// Channel class not supported
396     LL_ERR_CHANNEL_CLASS_NOT_SUP                                                   = 0xBE,
397     /// Insufficient security
398     LL_ERR_INSUFFICIENT_SECURITY                                                   = 0xBF,
399     /// Parameters out of mandatory range
400     LL_ERR_PARAM_OUT_OF_MAND_RANGE                                                 = 0xC0,
401     /// Role switch pending
402     LL_ERR_ROLE_SWITCH_PEND                                                        = 0xC2,
403     /// Reserved slot violation
404     LL_ERR_RESERVED_SLOT_VIOLATION                                                 = 0xC4,
405     /// Role Switch fail
406     LL_ERR_ROLE_SWITCH_FAIL                                                        = 0xC5,
407     /// Error, EIR too large
408     LL_ERR_EIR_TOO_LARGE                                                           = 0xC6,
409     /// Simple pairing not supported by host
410     LL_ERR_SP_NOT_SUPPORTED_HOST                                                   = 0xC7,
411     /// Host pairing is busy
412     LL_ERR_HOST_BUSY_PAIRING                                                       = 0xC8,
413     /// Controller is busy
414     LL_ERR_CONTROLLER_BUSY                                                         = 0xCA,
415     /// Unacceptable connection initialization
416     LL_ERR_UNACCEPTABLE_CONN_INT                                                   = 0xCB,
417     /// Direct Advertising Timeout
418     LL_ERR_DIRECT_ADV_TO                                                           = 0xCC,
419     /// Connection Terminated due to a MIC failure
420     LL_ERR_TERMINATED_MIC_FAILURE                                                  = 0xCD,
421     /// Connection failed to be established
422     LL_ERR_CONN_FAILED_TO_BE_EST                                                   = 0xCE,
423 };
424 
425 /// @} RWBLE_HL_ERROR_H
426 
427 #endif // RWBLE_HL_ERROR_H_
428