xref: /btstack/src/bluetooth.h (revision df8843a08cb99c922622d19b3b7faaf02ab33b92)
147f4e325SMatthias Ringwald /*
247f4e325SMatthias Ringwald  * Copyright (C) 2015 BlueKitchen GmbH
347f4e325SMatthias Ringwald  *
447f4e325SMatthias Ringwald  * Redistribution and use in source and binary forms, with or without
547f4e325SMatthias Ringwald  * modification, are permitted provided that the following conditions
647f4e325SMatthias Ringwald  * are met:
747f4e325SMatthias Ringwald  *
847f4e325SMatthias Ringwald  * 1. Redistributions of source code must retain the above copyright
947f4e325SMatthias Ringwald  *    notice, this list of conditions and the following disclaimer.
1047f4e325SMatthias Ringwald  * 2. Redistributions in binary form must reproduce the above copyright
1147f4e325SMatthias Ringwald  *    notice, this list of conditions and the following disclaimer in the
1247f4e325SMatthias Ringwald  *    documentation and/or other materials provided with the distribution.
1347f4e325SMatthias Ringwald  * 3. Neither the name of the copyright holders nor the names of
1447f4e325SMatthias Ringwald  *    contributors may be used to endorse or promote products derived
1547f4e325SMatthias Ringwald  *    from this software without specific prior written permission.
1647f4e325SMatthias Ringwald  * 4. Any redistribution, use, or modification is done solely for
1747f4e325SMatthias Ringwald  *    personal benefit and not for any commercial purpose or for
1847f4e325SMatthias Ringwald  *    monetary gain.
1947f4e325SMatthias Ringwald  *
2047f4e325SMatthias Ringwald  * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
2147f4e325SMatthias Ringwald  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2247f4e325SMatthias Ringwald  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
232fca4dadSMilanka Ringwald  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN
242fca4dadSMilanka Ringwald  * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
2547f4e325SMatthias Ringwald  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
2647f4e325SMatthias Ringwald  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
2747f4e325SMatthias Ringwald  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
2847f4e325SMatthias Ringwald  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2947f4e325SMatthias Ringwald  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
3047f4e325SMatthias Ringwald  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3147f4e325SMatthias Ringwald  * SUCH DAMAGE.
3247f4e325SMatthias Ringwald  *
3347f4e325SMatthias Ringwald  * Please inquire about commercial licensing options at
3447f4e325SMatthias Ringwald  * [email protected]
3547f4e325SMatthias Ringwald  *
3647f4e325SMatthias Ringwald  */
3747f4e325SMatthias Ringwald 
3847f4e325SMatthias Ringwald /*
3947f4e325SMatthias Ringwald  * bluetooth.h
4047f4e325SMatthias Ringwald  *
4147f4e325SMatthias Ringwald  * Numbers defined or derived from the official Bluetooth specification
4247f4e325SMatthias Ringwald  */
4347f4e325SMatthias Ringwald 
4480e33422SMatthias Ringwald #ifndef BLUETOOTH_H
4580e33422SMatthias Ringwald #define BLUETOOTH_H
4647f4e325SMatthias Ringwald 
4747f4e325SMatthias Ringwald #include <stdint.h>
4847f4e325SMatthias Ringwald 
4947f4e325SMatthias Ringwald /**
508974fcd6SMatthias Ringwald  * @brief hci connection handle type
518974fcd6SMatthias Ringwald  */
528974fcd6SMatthias Ringwald typedef uint16_t hci_con_handle_t;
538974fcd6SMatthias Ringwald 
548974fcd6SMatthias Ringwald /**
558974fcd6SMatthias Ringwald  * @brief Length of a bluetooth device address.
568974fcd6SMatthias Ringwald  */
578974fcd6SMatthias Ringwald #define BD_ADDR_LEN 6
588974fcd6SMatthias Ringwald 
598974fcd6SMatthias Ringwald /**
608974fcd6SMatthias Ringwald  * @brief Bluetooth address
618974fcd6SMatthias Ringwald  */
628974fcd6SMatthias Ringwald typedef uint8_t bd_addr_t[BD_ADDR_LEN];
638974fcd6SMatthias Ringwald 
648974fcd6SMatthias Ringwald /**
658974fcd6SMatthias Ringwald  * Address types
668974fcd6SMatthias Ringwald  */
678974fcd6SMatthias Ringwald  typedef enum {
683739bc96SMatthias Ringwald     // Public Device Address
698974fcd6SMatthias Ringwald     BD_ADDR_TYPE_LE_PUBLIC = 0,
703739bc96SMatthias Ringwald     // Random Device Address
718974fcd6SMatthias Ringwald     BD_ADDR_TYPE_LE_RANDOM = 1,
723739bc96SMatthias Ringwald     // Public Identity Address (Corresponds to Resolved Private Address)
733739bc96SMatthias Ringwald     BD_ADDR_TYPE_LE_PUBLIC_IDENTITY = 2,
743739bc96SMatthias Ringwald     // Random (static) Identity Address (Corresponds to Resolved Private Address)
753739bc96SMatthias Ringwald     BD_ADDR_TYPE_LE_RANDOM_IDENTITY = 3,
763739bc96SMatthias Ringwald     // internal BTstack addr types for Classic connections
7712fd3a99SMatthias Ringwald     BD_ADDR_TYPE_SCO       = 0xfc,
7812fd3a99SMatthias Ringwald     BD_ADDR_TYPE_ACL       = 0xfd,
7912fd3a99SMatthias Ringwald     BD_ADDR_TYPE_UNKNOWN   = 0xfe,  // also used as 'invalid'
808974fcd6SMatthias Ringwald } bd_addr_type_t;
818974fcd6SMatthias Ringwald 
82c26f2c7bSMatthias Ringwald  /**
83c26f2c7bSMatthias Ringwald   * Pin Codde
84c26f2c7bSMatthias Ringwald   */
85c26f2c7bSMatthias Ringwald #define PIN_CODE_LEN 16
86c26f2c7bSMatthias Ringwald 
875e91d96cSMatthias Ringwald /**
885e91d96cSMatthias Ringwald  * Link types for BR/EDR Connections
895e91d96cSMatthias Ringwald  */
905e91d96cSMatthias Ringwald typedef enum {
915e91d96cSMatthias Ringwald     HCI_LINK_TYPE_SCO  = 0,
925e91d96cSMatthias Ringwald     HCI_LINK_TYPE_ACL  = 1,
935e91d96cSMatthias Ringwald     HCI_LINK_TYPE_ESCO = 2,
945e91d96cSMatthias Ringwald } hci_link_type_t;
95b95a5a35SMatthias Ringwald 
96b95a5a35SMatthias Ringwald 
978974fcd6SMatthias Ringwald /**
988974fcd6SMatthias Ringwald  * @brief link key
998974fcd6SMatthias Ringwald  */
1008974fcd6SMatthias Ringwald #define LINK_KEY_LEN 16
1018974fcd6SMatthias Ringwald #define LINK_KEY_STR_LEN (LINK_KEY_LEN*2)
1028974fcd6SMatthias Ringwald typedef uint8_t link_key_t[LINK_KEY_LEN];
1038974fcd6SMatthias Ringwald 
1048974fcd6SMatthias Ringwald /**
1058974fcd6SMatthias Ringwald  * @brief link key type
1068974fcd6SMatthias Ringwald  */
1078974fcd6SMatthias Ringwald typedef enum {
108e9f98c4aSMatthias Ringwald   INVALID_LINK_KEY = 0xffff,
1098974fcd6SMatthias Ringwald   COMBINATION_KEY = 0,  // standard pairing
1108974fcd6SMatthias Ringwald   LOCAL_UNIT_KEY,     // ?
1118974fcd6SMatthias Ringwald   REMOTE_UNIT_KEY,    // ?
1128974fcd6SMatthias Ringwald   DEBUG_COMBINATION_KEY,  // SSP with debug
1138974fcd6SMatthias Ringwald   UNAUTHENTICATED_COMBINATION_KEY_GENERATED_FROM_P192, // SSP Simple Pairing
1148974fcd6SMatthias Ringwald   AUTHENTICATED_COMBINATION_KEY_GENERATED_FROM_P192,   // SSP Passkey, Number confirm, OOB
1158974fcd6SMatthias Ringwald   CHANGED_COMBINATION_KEY,               // Link key changed using Change Connection Lnk Key
1168974fcd6SMatthias Ringwald   UNAUTHENTICATED_COMBINATION_KEY_GENERATED_FROM_P256, // SSP Simpe Pairing
1178974fcd6SMatthias Ringwald   AUTHENTICATED_COMBINATION_KEY_GENERATED_FROM_P256,   // SSP Passkey, Number confirm, OOB
1188974fcd6SMatthias Ringwald } link_key_type_t;
1198974fcd6SMatthias Ringwald 
1208974fcd6SMatthias Ringwald /**
1217115cf4eSMatthias Ringwald  * LE Privacy 1.2
1227115cf4eSMatthias Ringwald  */
1237115cf4eSMatthias Ringwald typedef enum {
1247115cf4eSMatthias Ringwald     LE_PRIVACY_MODE_NETWORK = 0,
1257115cf4eSMatthias Ringwald     LE_PRIVACY_MODE_DEVICE = 1,
1267115cf4eSMatthias Ringwald } le_privacy_mode_t;
1277115cf4eSMatthias Ringwald 
1287115cf4eSMatthias Ringwald /**
129a8c4e5adSMatthias Ringwald  * @brief Extended Inquiry Response
130a8c4e5adSMatthias Ringwald  */
131a8c4e5adSMatthias Ringwald #define EXTENDED_INQUIRY_RESPONSE_DATA_LEN 240
132a8c4e5adSMatthias Ringwald 
133a8c4e5adSMatthias Ringwald /**
134f6858d14SMatthias Ringwald  * @brief Inquiry modes
135f6858d14SMatthias Ringwald  */
136f6858d14SMatthias Ringwald typedef enum {
137f6858d14SMatthias Ringwald   INQUIRY_MODE_STANDARD = 0,
138f6858d14SMatthias Ringwald   INQUIRY_MODE_RSSI,
139f6858d14SMatthias Ringwald   INQUIRY_MODE_RSSI_AND_EIR,
140f6858d14SMatthias Ringwald } inquiry_mode_t;
141f6858d14SMatthias Ringwald 
142a29d7266SMatthias Ringwald /**
143a29d7266SMatthias Ringwald  * @brief Page Scan Types
144a29d7266SMatthias Ringwald  */
145a29d7266SMatthias Ringwald typedef enum {
146a29d7266SMatthias Ringwald     PAGE_SCAN_MODE_STANDARD = 0,
147a29d7266SMatthias Ringwald     PAGE_SCAN_MODE_INTERLACED,
148a29d7266SMatthias Ringwald } page_scan_type_t;
149a29d7266SMatthias Ringwald 
150a29d7266SMatthias Ringwald /**
151a29d7266SMatthias Ringwald  * @brief Inquiry Scan Types
152a29d7266SMatthias Ringwald  */
153a29d7266SMatthias Ringwald typedef enum {
154a29d7266SMatthias Ringwald     INQUIRY_SCAN_MODE_STANDARD = 0,
155a29d7266SMatthias Ringwald     INQUIRY_SCAN_MODE_INTERLACED,
156a29d7266SMatthias Ringwald } inquiry_scan_type_t;
15785ddcd84SMatthias Ringwald 
158671fb338SMatthias Ringwald /**
159d821984bSMatthias Ringwald  * Link Supervision Timeout Default, 0x7d00 * 0.625ms = 20s
160d821984bSMatthias Ringwald  */
161d821984bSMatthias Ringwald #define HCI_LINK_SUPERVISION_TIMEOUT_DEFAULT 0x7D00
162d821984bSMatthias Ringwald 
163d821984bSMatthias Ringwald /**
164278ff8a9SMatthias Ringwald  * Service Type used for QoS Setup and Flow Specification
165278ff8a9SMatthias Ringwald  */
166278ff8a9SMatthias Ringwald typedef enum {
167278ff8a9SMatthias Ringwald     HCI_SERVICE_TYPE_NO_TRAFFIC = 0,
168278ff8a9SMatthias Ringwald     HCI_SERVICE_TYPE_BEST_EFFORT,
169278ff8a9SMatthias Ringwald     HCI_SERVICE_TYPE_GUARANTEED,
170965a4ccfSMatthias Ringwald     HCI_SERVICE_TYPE_INVALID,
171278ff8a9SMatthias Ringwald } hci_service_type_t;
172278ff8a9SMatthias Ringwald 
173278ff8a9SMatthias Ringwald /**
17447f4e325SMatthias Ringwald  * HCI Transport
17547f4e325SMatthias Ringwald  */
17647f4e325SMatthias Ringwald 
17747f4e325SMatthias Ringwald /**
17847f4e325SMatthias Ringwald  * packet types - used in BTstack and over the H4 UART interface
17947f4e325SMatthias Ringwald  */
18047f4e325SMatthias Ringwald #define HCI_COMMAND_DATA_PACKET 0x01
18147f4e325SMatthias Ringwald #define HCI_ACL_DATA_PACKET     0x02
18247f4e325SMatthias Ringwald #define HCI_SCO_DATA_PACKET     0x03
18347f4e325SMatthias Ringwald #define HCI_EVENT_PACKET        0x04
1840d5b1bafSMatthias Ringwald #define HCI_ISO_DATA_PACKET     0x05
18547f4e325SMatthias Ringwald 
18647f4e325SMatthias Ringwald /**
18799617827SMatthias Ringwald  * Other assigned numbers, Assigned_Numbers_Host Controller Interface.pdf
18899617827SMatthias Ringwald  */
18999617827SMatthias Ringwald 
19099617827SMatthias Ringwald typedef enum {
19199617827SMatthias Ringwald     HCI_AUDIO_CODING_FORMAT_U_LAW_LOG = 0x00,
19299617827SMatthias Ringwald     HCI_AUDIO_CODING_FORMAT_A_LAW_LOG,
19399617827SMatthias Ringwald     HCI_AUDIO_CODING_FORMAT_CVSD,
19499617827SMatthias Ringwald     HCI_AUDIO_CODING_FORMAT_TRANSPARENT, // Indicates that the controller does not do any transcoding or resampling. This is also used for test mode.
19599617827SMatthias Ringwald     HCI_AUDIO_CODING_FORMAT_LINEAR_PCM,
19699617827SMatthias Ringwald     HCI_AUDIO_CODING_FORMAT_MSBC,
19799617827SMatthias Ringwald     HCI_AUDIO_CODING_FORMAT_LC3,
19899617827SMatthias Ringwald     HCI_AUDIO_CODING_FORMAT_G_729A,
19999617827SMatthias Ringwald     HCI_AUDIO_CODING_FORMAT_RFU,
20099617827SMatthias Ringwald     HCI_AUDIO_CODING_FORMAT_VENDOR_SPECIFIC = 0xFF
20199617827SMatthias Ringwald } hci_audio_coding_format_t;
20299617827SMatthias Ringwald 
20399617827SMatthias Ringwald /**
20447f4e325SMatthias Ringwald  * HCI Layer
20547f4e325SMatthias Ringwald  */
20647f4e325SMatthias Ringwald 
20747f4e325SMatthias Ringwald //
208f193890fSMatthias Ringwald // Error Codes rfom Bluetooth Core Specification
20947f4e325SMatthias Ringwald //
21047f4e325SMatthias Ringwald 
211f193890fSMatthias Ringwald /* ENUM_START: BLUETOOTH_ERROR_CODE */
212*df8843a0SMatthias Ringwald #define ERROR_CODE_SUCCESS                                            0x00u
213*df8843a0SMatthias Ringwald #define ERROR_CODE_UNKNOWN_HCI_COMMAND                                0x01u
214*df8843a0SMatthias Ringwald #define ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER                      0x02u
215*df8843a0SMatthias Ringwald #define ERROR_CODE_HARDWARE_FAILURE                                   0x03u
216*df8843a0SMatthias Ringwald #define ERROR_CODE_PAGE_TIMEOUT                                       0x04u
217*df8843a0SMatthias Ringwald #define ERROR_CODE_AUTHENTICATION_FAILURE                             0x05u
218*df8843a0SMatthias Ringwald #define ERROR_CODE_PIN_OR_KEY_MISSING                                 0x06u
219*df8843a0SMatthias Ringwald #define ERROR_CODE_MEMORY_CAPACITY_EXCEEDED                           0x07u
220*df8843a0SMatthias Ringwald #define ERROR_CODE_CONNECTION_TIMEOUT                                 0x08u
221*df8843a0SMatthias Ringwald #define ERROR_CODE_CONNECTION_LIMIT_EXCEEDED                          0x09u
222*df8843a0SMatthias Ringwald #define ERROR_CODE_SYNCHRONOUS_CONNECTION_LIMIT_TO_A_DEVICE_EXCEEDED  0x0Au
223*df8843a0SMatthias Ringwald #define ERROR_CODE_ACL_CONNECTION_ALREADY_EXISTS                      0x0Bu
224*df8843a0SMatthias Ringwald #define ERROR_CODE_COMMAND_DISALLOWED                                 0x0Cu
225*df8843a0SMatthias Ringwald #define ERROR_CODE_CONNECTION_REJECTED_DUE_TO_LIMITED_RESOURCES       0x0Du
226*df8843a0SMatthias Ringwald #define ERROR_CODE_CONNECTION_REJECTED_DUE_TO_SECURITY_REASONS        0x0Eu
227*df8843a0SMatthias Ringwald #define ERROR_CODE_CONNECTION_REJECTED_DUE_TO_UNACCEPTABLE_BD_ADDR    0x0Fu
228*df8843a0SMatthias Ringwald #define ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE             0x11u
229*df8843a0SMatthias Ringwald #define ERROR_CODE_INVALID_HCI_COMMAND_PARAMETERS                     0x12u
230*df8843a0SMatthias Ringwald #define ERROR_CODE_REMOTE_USER_TERMINATED_CONNECTION                  0x13u
231*df8843a0SMatthias Ringwald #define ERROR_CODE_CONNECTION_ACCEPT_TIMEOUT_EXCEEDED                 0x10u
232*df8843a0SMatthias Ringwald #define ERROR_CODE_REMOTE_DEVICE_TERMINATED_CONNECTION_DUE_TO_LOW_RESOURCES 0x14u
233*df8843a0SMatthias Ringwald #define ERROR_CODE_REMOTE_DEVICE_TERMINATED_CONNECTION_DUE_TO_POWER_OFF     0x15u
234*df8843a0SMatthias Ringwald #define ERROR_CODE_CONNECTION_TERMINATED_BY_LOCAL_HOST                0x16u
235*df8843a0SMatthias Ringwald #define ERROR_CODE_REPEATED_ATTEMPTS                                  0x17u
236*df8843a0SMatthias Ringwald #define ERROR_CODE_PAIRING_NOT_ALLOWED                                0x18u
237*df8843a0SMatthias Ringwald #define ERROR_CODE_UNKNOWN_LMP_PDU                                    0x19u
238*df8843a0SMatthias Ringwald #define ERROR_CODE_UNSUPPORTED_REMOTE_FEATURE_UNSUPPORTED_LMP_FEATURE 0x1Au
239*df8843a0SMatthias Ringwald #define ERROR_CODE_SCO_OFFSET_REJECTED                                0x1Bu
240*df8843a0SMatthias Ringwald #define ERROR_CODE_SCO_INTERVAL_REJECTED                              0x1Cu
241*df8843a0SMatthias Ringwald #define ERROR_CODE_SCO_AIR_MODE_REJECTED                              0x1Du
242*df8843a0SMatthias Ringwald #define ERROR_CODE_INVALID_LMP_PARAMETERS_INVALID_LL_PARAMETERS       0x1Eu
243*df8843a0SMatthias Ringwald #define ERROR_CODE_UNSPECIFIED_ERROR                                  0x1Fu
244*df8843a0SMatthias Ringwald #define ERROR_CODE_UNSUPPORTED_LMP_PARAMETER_VALUE_UNSUPPORTED_LL_PARAMETER_VALUE 0x20u
245*df8843a0SMatthias Ringwald #define ERROR_CODE_ROLE_CHANGE_NOT_ALLOWED                            0x21u
246*df8843a0SMatthias Ringwald #define ERROR_CODE_LMP_RESPONSE_TIMEOUT_LL_RESPONSE_TIMEOUT           0x22u
247*df8843a0SMatthias Ringwald #define ERROR_CODE_LMP_ERROR_TRANSACTION_COLLISION                    0x23u
248*df8843a0SMatthias Ringwald #define ERROR_CODE_LMP_PDU_NOT_ALLOWED                                0x24u
249*df8843a0SMatthias Ringwald #define ERROR_CODE_ENCRYPTION_MODE_NOT_ACCEPTABLE                     0x25u
250*df8843a0SMatthias Ringwald #define ERROR_CODE_LINK_KEY_CANNOT_BE_CHANGED                         0x26u
251*df8843a0SMatthias Ringwald #define ERROR_CODE_REQUESTED_QOS_NOT_SUPPORTED                        0x27u
252*df8843a0SMatthias Ringwald #define ERROR_CODE_INSTANT_PASSED                                     0x28u
253*df8843a0SMatthias Ringwald #define ERROR_CODE_PAIRING_WITH_UNIT_KEY_NOT_SUPPORTED                0x29u
254*df8843a0SMatthias Ringwald #define ERROR_CODE_DIFFERENT_TRANSACTION_COLLISION                    0x2Au
255*df8843a0SMatthias Ringwald #define ERROR_CODE_RESERVED                                           0x2Bu
256*df8843a0SMatthias Ringwald #define ERROR_CODE_QOS_UNACCEPTABLE_PARAMETER                         0x2Cu
257*df8843a0SMatthias Ringwald #define ERROR_CODE_QOS_REJECTED                                       0x2Du
258*df8843a0SMatthias Ringwald #define ERROR_CODE_CHANNEL_CLASSIFICATION_NOT_SUPPORTED               0x2Eu
259*df8843a0SMatthias Ringwald #define ERROR_CODE_INSUFFICIENT_SECURITY                              0x2Fu
260*df8843a0SMatthias Ringwald #define ERROR_CODE_PARAMETER_OUT_OF_MANDATORY_RANGE                   0x30u
26147f4e325SMatthias Ringwald // #define ERROR_CODE_RESERVED
262*df8843a0SMatthias Ringwald #define ERROR_CODE_ROLE_SWITCH_PENDING                                0x32u
26347f4e325SMatthias Ringwald // #define ERROR_CODE_RESERVED
264*df8843a0SMatthias Ringwald #define ERROR_CODE_RESERVED_SLOT_VIOLATION                            0x34u
265*df8843a0SMatthias Ringwald #define ERROR_CODE_ROLE_SWITCH_FAILED                                 0x35u
266*df8843a0SMatthias Ringwald #define ERROR_CODE_EXTENDED_INQUIRY_RESPONSE_TOO_LARGE                0x36u
267*df8843a0SMatthias Ringwald #define ERROR_CODE_SECURE_SIMPLE_PAIRING_NOT_SUPPORTED_BY_HOST        0x37u
268*df8843a0SMatthias Ringwald #define ERROR_CODE_HOST_BUSY_PAIRING                                  0x38u
269*df8843a0SMatthias Ringwald #define ERROR_CODE_CONNECTION_REJECTED_DUE_TO_NO_SUITABLE_CHANNEL_FOUND 0x39u
270*df8843a0SMatthias Ringwald #define ERROR_CODE_CONTROLLER_BUSY                                    0x3Au
271*df8843a0SMatthias Ringwald #define ERROR_CODE_UNACCEPTABLE_CONNECTION_PARAMETERS                 0x3Bu
272*df8843a0SMatthias Ringwald #define ERROR_CODE_DIRECTED_ADVERTISING_TIMEOUT                       0x3Cu
273*df8843a0SMatthias Ringwald #define ERROR_CODE_CONNECTION_TERMINATED_DUE_TO_MIC_FAILURE           0x3Du
274*df8843a0SMatthias Ringwald #define ERROR_CODE_CONNECTION_FAILED_TO_BE_ESTABLISHED                0x3Eu
275*df8843a0SMatthias Ringwald #define ERROR_CODE_MAC_CONNECTION_FAILED                              0x3Fu
276*df8843a0SMatthias Ringwald #define ERROR_CODE_COARSE_CLOCK_ADJUSTMENT_REJECTED_BUT_WILL_TRY_TO_ADJUST_USING_CLOCK_DRAGGING 0x40u
27796c69d4aSMilanka Ringwald 
27896c69d4aSMilanka Ringwald // BTstack defined ERRORS, mapped into BLuetooth status code range
27996c69d4aSMilanka Ringwald 
28096c69d4aSMilanka Ringwald #define BTSTACK_CONNECTION_TO_BTDAEMON_FAILED              0x50
28196c69d4aSMilanka Ringwald #define BTSTACK_ACTIVATION_FAILED_SYSTEM_BLUETOOTH         0x51
28296c69d4aSMilanka Ringwald #define BTSTACK_ACTIVATION_POWERON_FAILED                  0x52
28396c69d4aSMilanka Ringwald #define BTSTACK_ACTIVATION_FAILED_UNKNOWN                  0x53
28496c69d4aSMilanka Ringwald #define BTSTACK_NOT_ACTIVATED                              0x54
28596c69d4aSMilanka Ringwald #define BTSTACK_BUSY                                       0x55
28696c69d4aSMilanka Ringwald #define BTSTACK_MEMORY_ALLOC_FAILED                        0x56
28796c69d4aSMilanka Ringwald #define BTSTACK_ACL_BUFFERS_FULL                           0x57
28896c69d4aSMilanka Ringwald 
28996c69d4aSMilanka Ringwald // l2cap errors - enumeration by the command that created them
29096c69d4aSMilanka Ringwald #define L2CAP_COMMAND_REJECT_REASON_COMMAND_NOT_UNDERSTOOD 0x60
29196c69d4aSMilanka Ringwald #define L2CAP_COMMAND_REJECT_REASON_SIGNALING_MTU_EXCEEDED 0x61
29296c69d4aSMilanka Ringwald #define L2CAP_COMMAND_REJECT_REASON_INVALID_CID_IN_REQUEST 0x62
29396c69d4aSMilanka Ringwald 
29496c69d4aSMilanka Ringwald #define L2CAP_CONNECTION_RESPONSE_RESULT_SUCCESSFUL        0x63
29596c69d4aSMilanka Ringwald #define L2CAP_CONNECTION_RESPONSE_RESULT_PENDING           0x64
29696c69d4aSMilanka Ringwald #define L2CAP_CONNECTION_RESPONSE_RESULT_REFUSED_PSM       0x65
29796c69d4aSMilanka Ringwald #define L2CAP_CONNECTION_RESPONSE_RESULT_REFUSED_SECURITY  0x66
29896c69d4aSMilanka Ringwald #define L2CAP_CONNECTION_RESPONSE_RESULT_REFUSED_RESOURCES 0x67
29996c69d4aSMilanka Ringwald #define L2CAP_CONNECTION_RESPONSE_RESULT_ERTM_NOT_SUPPORTED 0x68
30096c69d4aSMilanka Ringwald 
30196c69d4aSMilanka Ringwald // should be L2CAP_CONNECTION_RTX_TIMEOUT
30296c69d4aSMilanka Ringwald #define L2CAP_CONNECTION_RESPONSE_RESULT_RTX_TIMEOUT       0x69
30396c69d4aSMilanka Ringwald #define L2CAP_CONNECTION_BASEBAND_DISCONNECT               0x6A
30496c69d4aSMilanka Ringwald #define L2CAP_SERVICE_ALREADY_REGISTERED                   0x6B
30596c69d4aSMilanka Ringwald #define L2CAP_DATA_LEN_EXCEEDS_REMOTE_MTU                  0x6C
30696c69d4aSMilanka Ringwald #define L2CAP_SERVICE_DOES_NOT_EXIST                       0x6D
30796c69d4aSMilanka Ringwald #define L2CAP_LOCAL_CID_DOES_NOT_EXIST                     0x6E
308198ba16fSMatthias Ringwald #define L2CAP_CONNECTION_RESPONSE_UNKNOWN_ERROR            0x6F
30996c69d4aSMilanka Ringwald 
31096c69d4aSMilanka Ringwald #define RFCOMM_MULTIPLEXER_STOPPED                         0x70
31196c69d4aSMilanka Ringwald #define RFCOMM_CHANNEL_ALREADY_REGISTERED                  0x71
31296c69d4aSMilanka Ringwald #define RFCOMM_NO_OUTGOING_CREDITS                         0x72
31396c69d4aSMilanka Ringwald #define RFCOMM_AGGREGATE_FLOW_OFF                          0x73
31496c69d4aSMilanka Ringwald #define RFCOMM_DATA_LEN_EXCEEDS_MTU                        0x74
31596c69d4aSMilanka Ringwald 
316c06a442eSMilanka Ringwald #define HFP_REMOTE_REJECTS_AUDIO_CONNECTION                0x7F
317c06a442eSMilanka Ringwald 
31896c69d4aSMilanka Ringwald #define SDP_HANDLE_ALREADY_REGISTERED                      0x80
31996c69d4aSMilanka Ringwald #define SDP_QUERY_INCOMPLETE                               0x81
32096c69d4aSMilanka Ringwald #define SDP_SERVICE_NOT_FOUND                              0x82
32196c69d4aSMilanka Ringwald #define SDP_HANDLE_INVALID                                 0x83
32296c69d4aSMilanka Ringwald #define SDP_QUERY_BUSY                                     0x84
32396c69d4aSMilanka Ringwald 
32496c69d4aSMilanka Ringwald #define ATT_HANDLE_VALUE_INDICATION_IN_PROGRESS            0x90
32596c69d4aSMilanka Ringwald #define ATT_HANDLE_VALUE_INDICATION_TIMEOUT                0x91
32696c69d4aSMilanka Ringwald #define ATT_HANDLE_VALUE_INDICATION_DISCONNECT             0x92
32796c69d4aSMilanka Ringwald 
32896c69d4aSMilanka Ringwald #define GATT_CLIENT_NOT_CONNECTED                          0x93
32996c69d4aSMilanka Ringwald #define GATT_CLIENT_BUSY                                   0x94
33096c69d4aSMilanka Ringwald #define GATT_CLIENT_IN_WRONG_STATE                         0x95
33196c69d4aSMilanka Ringwald #define GATT_CLIENT_DIFFERENT_CONTEXT_FOR_ADDRESS_ALREADY_EXISTS 0x96
33296c69d4aSMilanka Ringwald #define GATT_CLIENT_VALUE_TOO_LONG                         0x97
33396c69d4aSMilanka Ringwald #define GATT_CLIENT_CHARACTERISTIC_NOTIFICATION_NOT_SUPPORTED 0x98
33496c69d4aSMilanka Ringwald #define GATT_CLIENT_CHARACTERISTIC_INDICATION_NOT_SUPPORTED   0x99
33596c69d4aSMilanka Ringwald 
33696c69d4aSMilanka Ringwald #define BNEP_SERVICE_ALREADY_REGISTERED                    0xA0
33796c69d4aSMilanka Ringwald #define BNEP_CHANNEL_NOT_CONNECTED                         0xA1
33896c69d4aSMilanka Ringwald #define BNEP_DATA_LEN_EXCEEDS_MTU                          0xA2
339b14ca7e1SMatthias Ringwald #define BNEP_SETUP_CONNECTION_ERROR                        0xA3
34096c69d4aSMilanka Ringwald 
34196c69d4aSMilanka Ringwald // OBEX ERRORS
34296c69d4aSMilanka Ringwald #define OBEX_UNKNOWN_ERROR                                 0xB0
34396c69d4aSMilanka Ringwald #define OBEX_CONNECT_FAILED                                0xB1
34496c69d4aSMilanka Ringwald #define OBEX_DISCONNECTED                                  0xB2
34596c69d4aSMilanka Ringwald #define OBEX_NOT_FOUND                                     0xB3
34696c69d4aSMilanka Ringwald #define OBEX_NOT_ACCEPTABLE                                0xB4
347fe7c8426SMatthias Ringwald #define OBEX_ABORTED                                       0xB5
34896c69d4aSMilanka Ringwald 
34996c69d4aSMilanka Ringwald #define MESH_ERROR_APPKEY_INDEX_INVALID                    0xD0
350f193890fSMatthias Ringwald /* ENUM_END */
35147f4e325SMatthias Ringwald 
35232272f12SMilanka Ringwald 
353954cc391SMilanka Ringwald /* ENUM_START: AVRCP_BROWSING_ERROR_CODE */
354954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_INVALID_COMMAND                     0x00  // Sent if TG received a PDU that it did not understand. Valid for All.
355954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_INVALID_PARAMETER                   0x01  // Sent if the TG received a PDU with a parameter ID that it did not understand. Sent if there is only one parameter ID in the PDU. Valid for All.
356954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_SPECIFIED_PARAMETER_NOT_FOUND       0x02  // Sent if the parameter ID is understood, but content is wrong or corrupted. Valid for All.
357954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_INTERNAL_ERROR                      0x03  // Sent if there are error conditions not covered by a more specific error code. Valid for All.
358954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_SUCCESS                             0x04  // This is the status that should be returned if the operation was successful. Valid for All except where the response CType is AV/C REJECTED.
359954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_UID_CHANGED                         0x05  // The UIDs on the device have changed. Valid for All.
360954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_RESERVED_06                         0x06  // Valid for All.
361954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_INVALID_DIRECTION                   0x07  // The Direction parameter is invalid. Valid for Change Path.
362954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_NOT_A_DIRECTORY                     0x08  // The UID provided does not refer to a folder item. Valid for Change Path.
363954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_DOES_NOT_EXIST                      0x09  // The UID provided does not refer to any currently valid. Valid for Change Path, PlayItem, AddToNowPlaying, GetItemAttributes.
364954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_INVALID_SCOPE                       0x0a  // The scope parameter is invalid. Valid for GetFolderItems, PlayItem, AddToNowPlayer, GetItemAttributes,.
365954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_RANGE_OUT_OF_BOUNDS                 0x0b  // The start of range provided is not valid. Valid for GetFolderItems.
366954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_UID_IS_A_DIRECTORY                  0x0c  // The UID provided refers to a directory, which cannot be handled by this media player. Valid for PlayItem, AddToNowPlaying.
367954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_MEDIA_IN_USES                       0x0d  // The media is not able to be used for this operation at this time. Valid for PlayItem, AddToNowPlaying.
368954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_NOW_PLAYING_LIST_FULL               0x0e  // No more items can be added to the Now Playing List. Valid for AddToNowPlaying.
369954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_SEARCH_NOT_SUPPORTED                0x0f  // The Browsed Media Player does not support search. Valid for Search.
370954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_SEARCH_IN_PROGRESS                  0x10  // A search operation is already in progress. Valid for Search.
371954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_INVALID_PLAYER_ID                   0x11  // The specified Player Id does not refer to a valid player. Valid for SetAddressedPlayer, SetBrowsedPlayer.
372954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_PLAYER_NOT_BROWSABLE                0x12  // The Player Id supplied refers to a Media Player which does not support browsing. Valid for SetBrowsedPlayer.
373954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_PLAYER_NOT_ADDRESSED                0x13  // The Player Id supplied refers to a player which is not currently addressed, and the command is not able to be performed if the player is not set as addressed. Valid for Search SetBrowsedPlayer.
374954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_NO_VALID_SEARCH_RESULTS             0x14  // The Search result list does not contain valid entries, e.g. after being invalidated due to change of browsed player. Valid for GetFolderItems.
375954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_NO_AVAILABLE_PLAYERS                0x15  // Valid for All.
376954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_ADDRESSED_PLAYER_CHANGED            0x16  // Valid for Register Notification.
377954cc391SMilanka Ringwald // 0x17-0xff Reserved
378954cc391SMilanka Ringwald /* ENUM_END */
379954cc391SMilanka Ringwald 
3808799c043SMatthias Ringwald // HCI roles
3812dceb1d6SMatthias Ringwald typedef enum {
3822dceb1d6SMatthias Ringwald     HCI_ROLE_MASTER = 0,
3832dceb1d6SMatthias Ringwald     HCI_ROLE_SLAVE  = 1,
3842dceb1d6SMatthias Ringwald     HCI_ROLE_INVALID = 0xff,
3852dceb1d6SMatthias Ringwald } hci_role_t;
3868799c043SMatthias Ringwald 
3878799c043SMatthias Ringwald // packet sizes (max payload)
3888799c043SMatthias Ringwald #define HCI_ACL_DM1_SIZE            17
3898799c043SMatthias Ringwald #define HCI_ACL_DH1_SIZE            27
3908799c043SMatthias Ringwald #define HCI_ACL_2DH1_SIZE           54
3918799c043SMatthias Ringwald #define HCI_ACL_3DH1_SIZE           83
3928799c043SMatthias Ringwald #define HCI_ACL_DM3_SIZE           121
3938799c043SMatthias Ringwald #define HCI_ACL_DH3_SIZE           183
3948799c043SMatthias Ringwald #define HCI_ACL_DM5_SIZE           224
3958799c043SMatthias Ringwald #define HCI_ACL_DH5_SIZE           339
3968799c043SMatthias Ringwald #define HCI_ACL_2DH3_SIZE          367
3978799c043SMatthias Ringwald #define HCI_ACL_3DH3_SIZE          552
3988799c043SMatthias Ringwald #define HCI_ACL_2DH5_SIZE          679
3998799c043SMatthias Ringwald #define HCI_ACL_3DH5_SIZE         1021
400b8e9d0d5SMatthias Ringwald #define HCI_SCO_HV1_SIZE            10
401b8e9d0d5SMatthias Ringwald #define HCI_SCO_HV2_SIZE            20
402b8e9d0d5SMatthias Ringwald #define HCI_SCO_HV3_SIZE            30
403b8e9d0d5SMatthias Ringwald #define HCI_SCO_EV3_SIZE            30
404b8e9d0d5SMatthias Ringwald #define HCI_SCO_EV4_SIZE           120
405b8e9d0d5SMatthias Ringwald #define HCI_SCO_EV5_SIZE           180
406b8e9d0d5SMatthias Ringwald #define HCI_SCO_2EV3_SIZE           60
407b8e9d0d5SMatthias Ringwald #define HCI_SCO_2EV5_SIZE          360
408b8e9d0d5SMatthias Ringwald #define HCI_SCO_3EV3_SIZE           90
409b8e9d0d5SMatthias Ringwald #define HCI_SCO_3EV5_SIZE          540
4108799c043SMatthias Ringwald 
4118799c043SMatthias Ringwald #define LE_ADVERTISING_DATA_SIZE    31
41243ce0351SMatthias Ringwald #define LE_EXTENDED_ADVERTISING_DATA_SIZE    229
4132d0c7965SMatthias Ringwald #define LE_EXTENDED_ADVERTISING_LEGACY_HANDLE 0
414d565a84bSMatthias Ringwald #define LE_EXTENDED_ADVERTISING_MAX_HANDLE 0xEFu
415d565a84bSMatthias Ringwald #define LE_EXTENDED_ADVERTISING_MAX_CHUNK_LEN 251
416d565a84bSMatthias Ringwald 
417d565a84bSMatthias Ringwald // advertising event properties for extended advertising
418d565a84bSMatthias Ringwald #define LE_ADVERTISING_PROPERTIES_CONNECTABLE      (1u<<0)
419d565a84bSMatthias Ringwald #define LE_ADVERTISING_PROPERTIES_SCANNABLE        (1u<<1)
420d565a84bSMatthias Ringwald #define LE_ADVERTISING_PROPERTIES_DIRECTED         (1u<<2)
421d565a84bSMatthias Ringwald #define LE_ADVERTISING_PROPERTIES_HIGH_DUTY_CYCLE  (1u<<3)
422d565a84bSMatthias Ringwald #define LE_ADVERTISING_PROPERTIES_LEGACY           (1u<<4)
423d565a84bSMatthias Ringwald #define LE_ADVERTISING_PROPERTIES_ANONYMOUS        (1u<<5)
424d565a84bSMatthias Ringwald #define LE_ADVERTISING_PROPERTIES_INCLUDE_TX_POWER (1u<<6)
425d565a84bSMatthias Ringwald 
42667955da4SMatthias Ringwald // ACL Packet Types
42767955da4SMatthias Ringwald #define ACL_PACKET_TYPES_NONE       0x0000
42867955da4SMatthias Ringwald #define ACL_PACKET_TYPES_2DH1       0x0002
42967955da4SMatthias Ringwald #define ACL_PACKET_TYPES_3DH1       0x0004
43067955da4SMatthias Ringwald #define ACL_PACKET_TYPES_DM1        0x0008
43167955da4SMatthias Ringwald #define ACL_PACKET_TYPES_DH1        0x0010
43267955da4SMatthias Ringwald #define ACL_PACKET_TYPES_2DH3       0x0100
43367955da4SMatthias Ringwald #define ACL_PACKET_TYPES_3DH3       0x0200
43467955da4SMatthias Ringwald #define ACL_PACKET_TYPES_DM3        0x0400
43567955da4SMatthias Ringwald #define ACL_PACKET_TYPES_DH3        0x0800
43667955da4SMatthias Ringwald #define ACL_PACKET_TYPES_2DH5       0x1000
43767955da4SMatthias Ringwald #define ACL_PACKET_TYPES_3DH5       0x2000
43867955da4SMatthias Ringwald #define ACL_PACKET_TYPES_DM5        0x4000
43967955da4SMatthias Ringwald #define ACL_PACKET_TYPES_DH5        0x8000
44067955da4SMatthias Ringwald #define ACL_PACKET_TYPES_BR         (ACL_PACKET_TYPES_DM1  | ACL_PACKET_TYPES_DH1  | ACL_PACKET_TYPES_DM3  | ACL_PACKET_TYPES_DH3 | ACL_PACKET_TYPES_DM5 | ACL_PACKET_TYPES_DH5)
44167955da4SMatthias Ringwald #define ACL_PACKET_TYPES_EDR2       (ACL_PACKET_TYPES_2DH1 | ACL_PACKET_TYPES_2DH3 | ACL_PACKET_TYPES_2DH5)
44267955da4SMatthias Ringwald #define ACL_PACKET_TYPES_EDR3       (ACL_PACKET_TYPES_3DH1 | ACL_PACKET_TYPES_3DH3 | ACL_PACKET_TYPES_3DH5)
44367955da4SMatthias Ringwald #define ACL_PACKET_TYPES_SLOTS1     (ACL_PACKET_TYPES_DM1  | ACL_PACKET_TYPES_DH1  | ACL_PACKET_TYPES_2DH1 | ACL_PACKET_TYPES_3DH1)
44467955da4SMatthias Ringwald #define ACL_PACKET_TYPES_SLOTS3     (ACL_PACKET_TYPES_DM3  | ACL_PACKET_TYPES_DH3  | ACL_PACKET_TYPES_2DH3 | ACL_PACKET_TYPES_3DH3)
44567955da4SMatthias Ringwald #define ACL_PACKET_TYPES_SLOTS5     (ACL_PACKET_TYPES_DM5  | ACL_PACKET_TYPES_DH5  | ACL_PACKET_TYPES_2DH5 | ACL_PACKET_TYPES_3DH5)
44667955da4SMatthias Ringwald #define ACL_PACKET_TYPES_ALL        (ACL_PACKET_TYPES_BR   | ACL_PACKET_TYPES_EDR2 | ACL_PACKET_TYPES_EDR3)
44747f4e325SMatthias Ringwald 
4483962dc20SMatthias Ringwald // SCO Packet Types
4493962dc20SMatthias Ringwald #define SCO_PACKET_TYPES_NONE  0x0000
4503962dc20SMatthias Ringwald #define SCO_PACKET_TYPES_HV1   0x0001
451b8e9d0d5SMatthias Ringwald #define SCO_PACKET_TYPES_HV2   0x0002
4523962dc20SMatthias Ringwald #define SCO_PACKET_TYPES_HV3   0x0004
4533962dc20SMatthias Ringwald #define SCO_PACKET_TYPES_EV3   0x0008
454b8e9d0d5SMatthias Ringwald #define SCO_PACKET_TYPES_EV4   0x0010
455b8e9d0d5SMatthias Ringwald #define SCO_PACKET_TYPES_EV5   0x0020
4563962dc20SMatthias Ringwald #define SCO_PACKET_TYPES_2EV3  0x0040
457b8e9d0d5SMatthias Ringwald #define SCO_PACKET_TYPES_3EV3  0x0080
458b8e9d0d5SMatthias Ringwald #define SCO_PACKET_TYPES_2EV5  0x0100
459b8e9d0d5SMatthias Ringwald #define SCO_PACKET_TYPES_3EV5  0x0200
4603962dc20SMatthias Ringwald #define SCO_PACKET_TYPES_ALL   0x03FF
4619c47355dSMatthias Ringwald #define SCO_PACKET_TYPES_SCO   0x0007
4629c47355dSMatthias Ringwald #define SCO_PACKET_TYPES_ESCO  0x03F8
4633962dc20SMatthias Ringwald 
464c33e56d3SMatthias Ringwald // Link Policy Settings
465c33e56d3SMatthias Ringwald #define LM_LINK_POLICY_DISABLE_ALL_LM_MODES  0
466c33e56d3SMatthias Ringwald #define LM_LINK_POLICY_ENABLE_ROLE_SWITCH    1
467c33e56d3SMatthias Ringwald #define LM_LINK_POLICY_ENABLE_HOLD_MODE      2
46864a93fb5SMatthias Ringwald #define LM_LINK_POLICY_ENABLE_SNIFF_MODE     4
469c33e56d3SMatthias Ringwald 
47051fd61e9SMatthias Ringwald // ACL Connection Modes
47151fd61e9SMatthias Ringwald #define ACL_CONNECTION_MODE_ACTIVE 0
47251fd61e9SMatthias Ringwald #define ACL_CONNECTION_MODE_HOLD   1
47351fd61e9SMatthias Ringwald #define ACL_CONNECTION_MODE_SNIFF  2
47451fd61e9SMatthias Ringwald 
47547f4e325SMatthias Ringwald /**
47647f4e325SMatthias Ringwald  * Default INQ Mode
47747f4e325SMatthias Ringwald  */
4788aee7be2SMilanka Ringwald #define GAP_IAC_GENERAL_INQUIRY 0x9E8B33L // General/Unlimited Inquiry Access Code (GIAC)
4798aee7be2SMilanka Ringwald #define GAP_IAC_LIMITED_INQUIRY 0x9E8B00L // Limited Dedicated Inquiry Access Code (LIAC)
48047f4e325SMatthias Ringwald 
48147f4e325SMatthias Ringwald /**
48247f4e325SMatthias Ringwald  * SSP IO Capabilities
48347f4e325SMatthias Ringwald  */
48447f4e325SMatthias Ringwald #define SSP_IO_CAPABILITY_DISPLAY_ONLY   0
48547f4e325SMatthias Ringwald #define SSP_IO_CAPABILITY_DISPLAY_YES_NO 1
48647f4e325SMatthias Ringwald #define SSP_IO_CAPABILITY_KEYBOARD_ONLY  2
48747f4e325SMatthias Ringwald #define SSP_IO_CAPABILITY_NO_INPUT_NO_OUTPUT 3
48847f4e325SMatthias Ringwald #define SSP_IO_CAPABILITY_UNKNOWN 0xff
48947f4e325SMatthias Ringwald 
49047f4e325SMatthias Ringwald 
49147f4e325SMatthias Ringwald /**
49247f4e325SMatthias Ringwald  * SSP Authentication Requirements, see IO Capability Request Reply Commmand
49347f4e325SMatthias Ringwald  */
49447f4e325SMatthias Ringwald 
49547f4e325SMatthias Ringwald // Numeric comparison with automatic accept allowed.
49647f4e325SMatthias Ringwald #define SSP_IO_AUTHREQ_MITM_PROTECTION_NOT_REQUIRED_NO_BONDING 0x00
49747f4e325SMatthias Ringwald 
49847f4e325SMatthias Ringwald // Use IO Capabilities to deter- mine authentication procedure
49947f4e325SMatthias Ringwald #define SSP_IO_AUTHREQ_MITM_PROTECTION_REQUIRED_NO_BONDING 0x01
50047f4e325SMatthias Ringwald 
50147f4e325SMatthias Ringwald // Numeric compar- ison with automatic accept allowed.
50247f4e325SMatthias Ringwald #define SSP_IO_AUTHREQ_MITM_PROTECTION_NOT_REQUIRED_DEDICATED_BONDING 0x02
50347f4e325SMatthias Ringwald 
50447f4e325SMatthias Ringwald // Use IO Capabilities to determine authentication procedure
50547f4e325SMatthias Ringwald #define SSP_IO_AUTHREQ_MITM_PROTECTION_REQUIRED_DEDICATED_BONDING 0x03
50647f4e325SMatthias Ringwald 
50747f4e325SMatthias Ringwald // Numeric Compari- son with automatic accept allowed.
50847f4e325SMatthias Ringwald #define SSP_IO_AUTHREQ_MITM_PROTECTION_NOT_REQUIRED_GENERAL_BONDING 0x04
50947f4e325SMatthias Ringwald 
5108799c043SMatthias Ringwald // Use IO capabilities to determine authentication procedure.
51147f4e325SMatthias Ringwald #define SSP_IO_AUTHREQ_MITM_PROTECTION_REQUIRED_GENERAL_BONDING 0x05
51247f4e325SMatthias Ringwald 
51347f4e325SMatthias Ringwald 
5148799c043SMatthias Ringwald // OGFs
5158799c043SMatthias Ringwald #define OGF_LINK_CONTROL          0x01
5168799c043SMatthias Ringwald #define OGF_LINK_POLICY           0x02
5178799c043SMatthias Ringwald #define OGF_CONTROLLER_BASEBAND   0x03
5188799c043SMatthias Ringwald #define OGF_INFORMATIONAL_PARAMETERS 0x04
5198799c043SMatthias Ringwald #define OGF_STATUS_PARAMETERS     0x05
5208799c043SMatthias Ringwald #define OGF_TESTING               0x06
5218799c043SMatthias Ringwald #define OGF_LE_CONTROLLER 0x08
5228799c043SMatthias Ringwald #define OGF_VENDOR  0x3f
5238799c043SMatthias Ringwald 
5248799c043SMatthias Ringwald 
52547f4e325SMatthias Ringwald 
52647f4e325SMatthias Ringwald 
52747f4e325SMatthias Ringwald /**
52847f4e325SMatthias Ringwald  * L2CAP Layer
52947f4e325SMatthias Ringwald  */
53047f4e325SMatthias Ringwald 
531a8373a41SMatthias Ringwald #define L2CAP_HEADER_SIZE 4
532a8373a41SMatthias Ringwald 
533a8373a41SMatthias Ringwald // minimum signaling MTU
534a8373a41SMatthias Ringwald #define L2CAP_MINIMAL_MTU 48
535a8373a41SMatthias Ringwald #define L2CAP_DEFAULT_MTU 672
536a8373a41SMatthias Ringwald 
537a8373a41SMatthias Ringwald // Minimum/default MTU
538a8373a41SMatthias Ringwald #define L2CAP_LE_DEFAULT_MTU  23
539a8373a41SMatthias Ringwald 
540a8373a41SMatthias Ringwald // L2CAP Fixed Channel IDs
541a8373a41SMatthias Ringwald #define L2CAP_CID_SIGNALING                        0x0001
542a8373a41SMatthias Ringwald #define L2CAP_CID_CONNECTIONLESS_CHANNEL           0x0002
543a8373a41SMatthias Ringwald #define L2CAP_CID_ATTRIBUTE_PROTOCOL               0x0004
544a8373a41SMatthias Ringwald #define L2CAP_CID_SIGNALING_LE                     0x0005
545a8373a41SMatthias Ringwald #define L2CAP_CID_SECURITY_MANAGER_PROTOCOL        0x0006
5464e65ea07SMatthias Ringwald #define L2CAP_CID_BR_EDR_SECURITY_MANAGER          0x0007
547198ba16fSMatthias Ringwald 
548d8c69877SMatthias Ringwald // L2CAP Channels in Basic and Enhanced Retransmission Mode
5498dc9980fSMatthias Ringwald 
5508dc9980fSMatthias Ringwald // connection response result
5518dc9980fSMatthias Ringwald #define L2CAP_CONNECTION_RESULT_SUCCESS                         0x0000
5528dc9980fSMatthias Ringwald #define L2CAP_CONNECTION_RESULT_PENDING                         0x0001
5538dc9980fSMatthias Ringwald #define L2CAP_CONNECTION_RESULT_PSM_NOT_SUPPORTED               0x0002
5548dc9980fSMatthias Ringwald #define L2CAP_CONNECTION_RESULT_SECURITY_BLOCK                  0x0003
5558dc9980fSMatthias Ringwald #define L2CAP_CONNECTION_RESULT_NO_RESOURCES_AVAILABLE          0x0004
5568dc9980fSMatthias Ringwald #define L2CAP_CONNECTION_RESULT_INVALID_SOURCE_CID              0x0006
5578dc9980fSMatthias Ringwald #define L2CAP_CONNECTION_RESULT_SOURCE_CID_ALREADY_ALLOCATED    0x0007
5588dc9980fSMatthias Ringwald 
5598dc9980fSMatthias Ringwald // L2CAP Channels in LE Credit-Based Flow-Control Mode
5608dc9980fSMatthias Ringwald 
5618dc9980fSMatthias Ringwald // connection response result
5628dc9980fSMatthias Ringwald #define L2CAP_CBM_CONNECTION_RESULT_SUCCESS                         0x0000
5638dc9980fSMatthias Ringwald #define L2CAP_CBM_CONNECTION_RESULT_SPSM_NOT_SUPPORTED              0x0002
5648dc9980fSMatthias Ringwald #define L2CAP_CBM_CONNECTION_RESULT_NO_RESOURCES_AVAILABLE          0x0004
5658dc9980fSMatthias Ringwald #define L2CAP_CBM_CONNECTION_RESULT_INSUFFICIENT_AUTHENTICATION     0x0005
5668dc9980fSMatthias Ringwald #define L2CAP_CBM_CONNECTION_RESULT_INSUFFICIENT_AUTHORIZATION      0x0006
5678dc9980fSMatthias Ringwald #define L2CAP_CBM_CONNECTION_RESULT_ENCYRPTION_KEY_SIZE_TOO_SHORT   0x0007
5688dc9980fSMatthias Ringwald #define L2CAP_CBM_CONNECTION_RESULT_INSUFFICIENT_ENCRYPTION         0x0008
5698dc9980fSMatthias Ringwald #define L2CAP_CBM_CONNECTION_RESULT_INVALID_SOURCE_CID              0x0009
5708dc9980fSMatthias Ringwald #define L2CAP_CBM_CONNECTION_RESULT_SOURCE_CID_ALREADY_ALLOCATED    0x000A
5718dc9980fSMatthias Ringwald #define L2CAP_CBM_CONNECTION_RESULT_UNACCEPTABLE_PARAMETERS         0x000B
5728dc9980fSMatthias Ringwald 
5738dc9980fSMatthias Ringwald 
5748dc9980fSMatthias Ringwald // L2CAP Channels in Enhanced Credit-Based Flow-Control Mode
575198ba16fSMatthias Ringwald 
576198ba16fSMatthias Ringwald // number of CIDs in single connection+reconfiguration request/response
577bbb517b6SMatthias Ringwald #define L2CAP_ECBM_MAX_CID_ARRAY_SIZE        5
578198ba16fSMatthias Ringwald 
5798dc9980fSMatthias Ringwald // connection response result
5808dc9980fSMatthias Ringwald #define L2CAP_ECBM_CONNECTION_RESULT_ALL_SUCCESS                                    0x0000
5818dc9980fSMatthias Ringwald #define L2CAP_ECBM_CONNECTION_RESULT_ALL_REFUSED_SPSM_NOT_SUPPORTED                 0x0002
5828dc9980fSMatthias Ringwald #define L2CAP_ECBM_CONNECTION_RESULT_SOME_REFUSED_INSUFFICIENT_RESOURCES_AVAILABLE  0x0004
5838dc9980fSMatthias Ringwald #define L2CAP_ECBM_CONNECTION_RESULT_ALL_REFUSED_INSUFFICIENT_AUTHENTICATION        0x0005
5848dc9980fSMatthias Ringwald #define L2CAP_ECBM_CONNECTION_RESULT_ALL_REFUSED_INSUFFICIENT_AUTHORIZATION         0x0006
5858dc9980fSMatthias Ringwald #define L2CAP_ECBM_CONNECTION_RESULT_ALL_REFUSED_ENCYRPTION_KEY_SIZE_TOO_SHORT      0x0007
5868dc9980fSMatthias Ringwald #define L2CAP_ECBM_CONNECTION_RESULT_ALL_REFUSED_INSUFFICIENT_ENCRYPTION            0x0008
5878dc9980fSMatthias Ringwald #define L2CAP_ECBM_CONNECTION_RESULT_SOME_REFUSED_INVALID_SOURCE_CID                0x0009
5888dc9980fSMatthias Ringwald #define L2CAP_ECBM_CONNECTION_RESULT_SOME_REFUSED_SOURCE_CID_ALREADY_ALOCATED       0x000A
5898dc9980fSMatthias Ringwald #define L2CAP_ECBM_CONNECTION_RESULT_ALL_REFUSED_UNACCEPTABLE_PARAMETERS            0x000B
5908dc9980fSMatthias Ringwald #define L2CAP_ECBM_CONNECTION_RESULT_ALL_REFUSED_INVALID_PARAMETERS                 0x000C
5918dc9980fSMatthias Ringwald #define L2CAP_ECBM_CONNECTION_RESULT_ALL_PENDING_NO_FURTHER_INFORMATION             0x000D
5928dc9980fSMatthias Ringwald #define L2CAP_ECBM_CONNECTION_RESULT_ALL_PENDING_AUTHENTICATION                     0x000E
5938dc9980fSMatthias Ringwald #define L2CAP_ECBM_CONNECTION_RESULT_ALL_PENDING_AUTHORIZATION                      0x000F
5948dc9980fSMatthias Ringwald 
5958dc9980fSMatthias Ringwald 
596198ba16fSMatthias Ringwald // Result for Reconfigure Request
5978dc9980fSMatthias Ringwald #define L2CAP_ECBM_RECONFIGURE_SUCCESS                                 0
5988dc9980fSMatthias Ringwald #define L2CAP_ECBM_RECONFIGURE_FAILED_MTU_REDUCTION_NOT_ALLOWED        1
5998dc9980fSMatthias Ringwald #define L2CAP_ECBM_RECONFIGURE_FAILED_MPS_REDUCTION_MULTIPLE_CHANNELS  2
6008dc9980fSMatthias Ringwald #define L2CAP_ECBM_RECONFIGURE_FAILED_DESTINATION_CID_INVALID          3
6018dc9980fSMatthias Ringwald #define L2CAP_ECBM_RECONFIGURE_FAILED_UNACCEPTABLE_PARAMETERS          4
602198ba16fSMatthias Ringwald 
60366b1fcb3SMatthias Ringwald /**
604235946f1SMatthias Ringwald  * SDP Protocol
605ef907034SMatthias Ringwald  */
606ef907034SMatthias Ringwald 
607c4b3290dSMatthias Ringwald // Device Vendor ID Sources
608c4b3290dSMatthias Ringwald #define DEVICE_ID_VENDOR_ID_SOURCE_BLUETOOTH 0x0001
609c4b3290dSMatthias Ringwald #define DEVICE_ID_VENDOR_ID_SOURCE_USB       0x0002
610c4b3290dSMatthias Ringwald 
611ef907034SMatthias Ringwald // OBEX
612ef907034SMatthias Ringwald #define SDP_vCard_2_1       0x01
613ef907034SMatthias Ringwald #define SDP_vCard_3_0       0x02
614ef907034SMatthias Ringwald #define SDP_vCal_1_0        0x03
615ef907034SMatthias Ringwald #define SDP_iCal_2_0        0x04
616ef907034SMatthias Ringwald #define SDP_vNote           0x05
617ef907034SMatthias Ringwald #define SDP_vMessage        0x06
618ef907034SMatthias Ringwald #define SDP_OBEXFileTypeAny 0xFF
619ef907034SMatthias Ringwald 
620ef907034SMatthias Ringwald /**
621e2577bd7SMatthias Ringwald  * RFCOMM Protocol
622e2577bd7SMatthias Ringwald  */
623e2577bd7SMatthias Ringwald 
624e2577bd7SMatthias Ringwald // Line Status
625e2577bd7SMatthias Ringwald #define LINE_STATUS_NO_ERROR       0x00
626e2577bd7SMatthias Ringwald #define LINE_STATUS_OVERRUN_ERROR  0x03
627e2577bd7SMatthias Ringwald #define LINE_STATUS_PARITY_ERORR   0x05
628e2577bd7SMatthias Ringwald #define LINE_STATUS_FRAMING_ERROR  0x09
629e2577bd7SMatthias Ringwald 
630e2577bd7SMatthias Ringwald // Modem Status Flags
631e2577bd7SMatthias Ringwald #define MODEM_STATUS_FC   0x02
632e2577bd7SMatthias Ringwald #define MODEM_STATUS_RTC  0x04
633e2577bd7SMatthias Ringwald #define MODEM_STATUS_RTR  0x08
634e2577bd7SMatthias Ringwald #define MODEM_STATUS_IC   0x40
635e2577bd7SMatthias Ringwald #define MODEM_STATUS_DV   0x80
636e2577bd7SMatthias Ringwald 
637e2577bd7SMatthias Ringwald typedef enum rpn_baud {
638e2577bd7SMatthias Ringwald     RPN_BAUD_2400 = 0,
639e2577bd7SMatthias Ringwald     RPN_BAUD_4800,
640e2577bd7SMatthias Ringwald     RPN_BAUD_7200,
641e2577bd7SMatthias Ringwald     RPN_BAUD_9600,
642e2577bd7SMatthias Ringwald     RPN_BAUD_19200,
643e2577bd7SMatthias Ringwald     RPN_BAUD_38400,
644e2577bd7SMatthias Ringwald     RPN_BAUD_57600,
645e2577bd7SMatthias Ringwald     RPN_BAUD_115200,
646e2577bd7SMatthias Ringwald     RPN_BAUD_230400
647e2577bd7SMatthias Ringwald } rpn_baud_t;
648e2577bd7SMatthias Ringwald 
649e2577bd7SMatthias Ringwald typedef enum rpn_data_bits {
650e2577bd7SMatthias Ringwald     RPN_DATA_BITS_5 = 0,
651e2577bd7SMatthias Ringwald     RPN_DATA_BITS_6 = 0,
652e2577bd7SMatthias Ringwald     RPN_DATA_BITS_7 = 0,
653e2577bd7SMatthias Ringwald     RPN_DATA_BITS_8 = 0
654e2577bd7SMatthias Ringwald } rpn_data_bits_t;
655e2577bd7SMatthias Ringwald 
656e2577bd7SMatthias Ringwald typedef enum rpn_stop_bits {
657e2577bd7SMatthias Ringwald     RPN_STOP_BITS_1_0 = 0,
658e2577bd7SMatthias Ringwald     RPN_STOP_BITS_1_5
659e2577bd7SMatthias Ringwald } rpn_stop_bits_t;
660e2577bd7SMatthias Ringwald 
661e2577bd7SMatthias Ringwald typedef enum rpn_parity {
662e2577bd7SMatthias Ringwald     RPN_PARITY_NONE  = 0,
663e2577bd7SMatthias Ringwald     RPN_PARITY_ODD   = 1,
664e2577bd7SMatthias Ringwald     RPN_PARITY_EVEN  = 3,
665e2577bd7SMatthias Ringwald     RPN_PARITY_MARK  = 5,
666e2577bd7SMatthias Ringwald     RPN_PARITY_SPACE = 7,
667e2577bd7SMatthias Ringwald } rpn_parity_t;
668e2577bd7SMatthias Ringwald 
669874776bfSMatthias Ringwald #define RPN_FLOW_CONTROL_XONXOFF_ON_INPUT  0x01
670874776bfSMatthias Ringwald #define RPN_FLOW_CONTROL_XONXOFF_ON_OUTPUT 0x02
671874776bfSMatthias Ringwald #define RPN_FLOW_CONTROL_RTR_ON_INPUT      0x04
672874776bfSMatthias Ringwald #define RPN_FLOW_CONTROL_RTR_ON_OUTPUT     0x08
673874776bfSMatthias Ringwald #define RPN_FLOW_CONTROL_RTC_ON_INPUT      0x10
674874776bfSMatthias Ringwald #define RPN_FLOW_CONTROL_RTC_ON_OUTPUT     0x20
675e2577bd7SMatthias Ringwald 
676e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_BAUD             0x01
677e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_DATA_BITS        0x02
678e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_STOP_BITS        0x04
679e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_PARITY           0x08
680e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_PARITY_TYPE      0x10
681e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_XON_CHAR         0x20
682e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_XOFF_CHAR        0x40
683e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_RESERVED         0x80
684e2577bd7SMatthias Ringwald 
685e2577bd7SMatthias Ringwald // @note: values are identical to rpn_flow_control_t
686e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_XONOFF_ON_INPUT  0x01
687e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_XONOFF_ON_OUTPUT 0x02
688e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RTR_ON_INPUT     0x04
689e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RTR_ON_OUTPUT    0x08
690e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RTC_ON_INPUT     0x10
691e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RTC_ON_OUTPUT    0x20
692e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RESERVED_0       0x40
693e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RESERVED_1       0x80
694e2577bd7SMatthias Ringwald 
695e2577bd7SMatthias Ringwald /**
69666b1fcb3SMatthias Ringwald  * BNEP Protocol
69766b1fcb3SMatthias Ringwald  */
69847f4e325SMatthias Ringwald 
69966b1fcb3SMatthias Ringwald #ifndef ETHER_ADDR_LEN
7009a73f75dSMatthias Ringwald #define ETHER_ADDR_LEN 6
70166b1fcb3SMatthias Ringwald #endif
70247f4e325SMatthias Ringwald 
70366b1fcb3SMatthias Ringwald #ifndef ETHERTYPE_VLAN
70466b1fcb3SMatthias Ringwald #define ETHERTYPE_VLAN                                  0x8100 /* IEEE 802.1Q VLAN tag */
70566b1fcb3SMatthias Ringwald #endif
70666b1fcb3SMatthias Ringwald 
70766b1fcb3SMatthias Ringwald #define BNEP_MTU_MIN                                    1691
70866b1fcb3SMatthias Ringwald 
70966b1fcb3SMatthias Ringwald 
71066b1fcb3SMatthias Ringwald /**
71166b1fcb3SMatthias Ringwald  * PAN Profile
71266b1fcb3SMatthias Ringwald  */
71366b1fcb3SMatthias Ringwald 
71466b1fcb3SMatthias Ringwald typedef enum {
71566b1fcb3SMatthias Ringwald     BNEP_SECURITY_NONE = 0x0000,
71666b1fcb3SMatthias Ringwald     BNEP_SECURITY_SERVICE_LEVEL_ENFORCED,
71766b1fcb3SMatthias Ringwald     BNEP_SECURITY_802_1X
71866b1fcb3SMatthias Ringwald } security_description_t;
71966b1fcb3SMatthias Ringwald 
72066b1fcb3SMatthias Ringwald typedef enum {
72166b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_PSTN = 0x0000,
72266b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_ISDN,
72366b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_DSL,
72466b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_CABLE_MODEM,
72566b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_10MB_ETHERNET,
72666b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_100MB_ETHERNET,
72766b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_4MB_TOKEN_RING,
72866b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_16MB_TOKEN_RING,
72966b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_100MB_TOKEN_RING,
73066b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_FDDI,
73166b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_GSM,
73266b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_CDMA,
73366b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_GPRS,
73466b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_3G,
73566b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_CELULAR,
73666b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_OTHER = 0xFFFE,
73766b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_NONE
73866b1fcb3SMatthias Ringwald } net_access_type_t;
73947f4e325SMatthias Ringwald 
7404c1900e6SMatthias Ringwald /**
7414c1900e6SMatthias Ringwald  * ATT
7424c1900e6SMatthias Ringwald  */
7434c1900e6SMatthias Ringwald 
7444c1900e6SMatthias Ringwald // Minimum/default MTU
7454c1900e6SMatthias Ringwald #define ATT_DEFAULT_MTU               23
7464c1900e6SMatthias Ringwald 
7474c1900e6SMatthias Ringwald // MARK: ATT Error Codes
748*df8843a0SMatthias Ringwald #define ATT_ERROR_SUCCESS                          0x00u
749*df8843a0SMatthias Ringwald #define ATT_ERROR_INVALID_HANDLE                   0x01u
750*df8843a0SMatthias Ringwald #define ATT_ERROR_READ_NOT_PERMITTED               0x02u
751*df8843a0SMatthias Ringwald #define ATT_ERROR_WRITE_NOT_PERMITTED              0x03u
752*df8843a0SMatthias Ringwald #define ATT_ERROR_INVALID_PDU                      0x04u
753*df8843a0SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_AUTHENTICATION      0x05u
754*df8843a0SMatthias Ringwald #define ATT_ERROR_REQUEST_NOT_SUPPORTED            0x06u
755*df8843a0SMatthias Ringwald #define ATT_ERROR_INVALID_OFFSET                   0x07u
756*df8843a0SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_AUTHORIZATION       0x08u
757*df8843a0SMatthias Ringwald #define ATT_ERROR_PREPARE_QUEUE_FULL               0x09u
758*df8843a0SMatthias Ringwald #define ATT_ERROR_ATTRIBUTE_NOT_FOUND              0x0au
759*df8843a0SMatthias Ringwald #define ATT_ERROR_ATTRIBUTE_NOT_LONG               0x0bu
760*df8843a0SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_ENCRYPTION_KEY_SIZE 0x0cu
761*df8843a0SMatthias Ringwald #define ATT_ERROR_INVALID_ATTRIBUTE_VALUE_LENGTH   0x0du
762*df8843a0SMatthias Ringwald #define ATT_ERROR_UNLIKELY_ERROR                   0x0eu
763*df8843a0SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_ENCRYPTION          0x0fu
764*df8843a0SMatthias Ringwald #define ATT_ERROR_UNSUPPORTED_GROUP_TYPE           0x10u
765*df8843a0SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_RESOURCES           0x11u
766*df8843a0SMatthias Ringwald #define ATT_ERROR_VALUE_NOT_ALLOWED                0x13u
767204991f3SMilanka Ringwald 
7682cc32601SMatthias Ringwald // MARK: ATT Error Codes defined by BTstack
769*df8843a0SMatthias Ringwald #define ATT_ERROR_HCI_DISCONNECT_RECEIVED          0x1fu
770*df8843a0SMatthias Ringwald #define ATT_ERROR_BONDING_INFORMATION_MISSING      0x70u
771*df8843a0SMatthias Ringwald #define ATT_ERROR_DATA_MISMATCH                    0x7eu
772*df8843a0SMatthias Ringwald #define ATT_ERROR_TIMEOUT                          0x7Fu
773*df8843a0SMatthias Ringwald #define ATT_ERROR_WRITE_RESPONSE_PENDING           0x100u
7742865193aSMilanka Ringwald 
775aae1cdcdSMilanka Ringwald // MARK: ATT Error Codes from Bluetooth Core Specification Supplement, Version 9 or later
776*df8843a0SMatthias Ringwald #define ATT_ERROR_WRITE_REQUEST_REJECTED                                                      0xFCu
777*df8843a0SMatthias Ringwald #define ATT_ERROR_CLIENT_CHARACTERISTIC_CONFIGURATION_DESCRIPTOR_IMPROPERLY_CONFIGURED        0xFDu
778*df8843a0SMatthias Ringwald #define ATT_ERROR_PROCEDURE_ALREADY_IN_PROGRESS                                               0xFEu
779*df8843a0SMatthias Ringwald #define ATT_ERROR_OUT_OF_RANGE                                                                0xFFu
780aae1cdcdSMilanka Ringwald 
781204991f3SMilanka Ringwald // MARK: ATT Error Codes from Cycling Power Service spec
782*df8843a0SMatthias Ringwald #define CYCLING_POWER_ERROR_CODE_INAPPROPRIATE_CONNECTION_PARAMETERS                          0x80u
783*df8843a0SMatthias Ringwald #define CYCLING_POWER_ERROR_CODE_PROCEDURE_ALREADY_IN_PROGRESS                                0xFEu
784*df8843a0SMatthias Ringwald #define CYCLING_POWER_ERROR_CODE_CCC_DESCRIPTOR_IMPROPERLY_CONFIGURED                         0xFDu
785204991f3SMilanka Ringwald 
786204991f3SMilanka Ringwald // MARK: ATT Error Codes from Cycling Speed and Cadence Service spec
787*df8843a0SMatthias Ringwald #define CYCLING_SPEED_AND_CADENCE_ERROR_CODE_PROCEDURE_ALREADY_IN_PROGRESS                    0x80u
788*df8843a0SMatthias Ringwald #define CYCLING_SPEED_AND_CADENCE_ERROR_CODE_CCC_DESCRIPTOR_IMPROPERLY_CONFIGURED             0x81u
789204991f3SMilanka Ringwald 
7904c1900e6SMatthias Ringwald 
7914c1900e6SMatthias Ringwald // MARK: Attribute Property Flags
7924c1900e6SMatthias Ringwald #define ATT_PROPERTY_BROADCAST           0x01
7934c1900e6SMatthias Ringwald #define ATT_PROPERTY_READ                0x02
7944c1900e6SMatthias Ringwald #define ATT_PROPERTY_WRITE_WITHOUT_RESPONSE 0x04
7954c1900e6SMatthias Ringwald #define ATT_PROPERTY_WRITE               0x08
7964c1900e6SMatthias Ringwald #define ATT_PROPERTY_NOTIFY              0x10
7974c1900e6SMatthias Ringwald #define ATT_PROPERTY_INDICATE            0x20
7984c1900e6SMatthias Ringwald #define ATT_PROPERTY_AUTHENTICATED_SIGNED_WRITE 0x40
7994c1900e6SMatthias Ringwald #define ATT_PROPERTY_EXTENDED_PROPERTIES 0x80
8004c1900e6SMatthias Ringwald 
8014c1900e6SMatthias Ringwald // MARK: Attribute Property Flag, BTstack extension
8024c1900e6SMatthias Ringwald // value is asked from client
8034c1900e6SMatthias Ringwald #define ATT_PROPERTY_DYNAMIC             0x100
804ff04bac7SMatthias Ringwald 
805ff04bac7SMatthias Ringwald // Security levels
806ff04bac7SMatthias Ringwald #define ATT_SECURITY_NONE 0
807ff04bac7SMatthias Ringwald #define ATT_SECURITY_ENCRYPTED 1
808ff04bac7SMatthias Ringwald #define ATT_SECURITY_AUTHENTICATED 2
809ff04bac7SMatthias Ringwald #define ATT_SECURITY_AUTHORIZED 3
810bb96f9f8SMatthias Ringwald #define ATT_SECURITY_AUTHENTICATED_SC 4
811ff04bac7SMatthias Ringwald 
8129b31df63SMatthias Ringwald // ATT Transaction Timeout of 30 seconds for Command/Response or Indication/Confirmation
8134c1900e6SMatthias Ringwald #define ATT_TRANSACTION_TIMEOUT_MS     30000
8144c1900e6SMatthias Ringwald 
8154c1900e6SMatthias Ringwald #define ATT_TRANSACTION_MODE_NONE      0x0
8164c1900e6SMatthias Ringwald #define ATT_TRANSACTION_MODE_ACTIVE    0x1
8174c1900e6SMatthias Ringwald #define ATT_TRANSACTION_MODE_EXECUTE   0x2
8184c1900e6SMatthias Ringwald #define ATT_TRANSACTION_MODE_CANCEL    0x3
8199b31df63SMatthias Ringwald #define ATT_TRANSACTION_MODE_VALIDATE  0x4
8204c1900e6SMatthias Ringwald 
8214c1900e6SMatthias Ringwald // MARK: GATT UUIDs
8224c1900e6SMatthias Ringwald #define GATT_PRIMARY_SERVICE_UUID                   0x2800
8234c1900e6SMatthias Ringwald #define GATT_SECONDARY_SERVICE_UUID                 0x2801
8244c1900e6SMatthias Ringwald #define GATT_INCLUDE_SERVICE_UUID                   0x2802
8254c1900e6SMatthias Ringwald #define GATT_CHARACTERISTICS_UUID                   0x2803
8264c1900e6SMatthias Ringwald #define GATT_CHARACTERISTIC_EXTENDED_PROPERTIES     0x2900
8274c1900e6SMatthias Ringwald #define GATT_CHARACTERISTIC_USER_DESCRIPTION        0x2901
8284c1900e6SMatthias Ringwald #define GATT_CLIENT_CHARACTERISTICS_CONFIGURATION   0x2902
8294c1900e6SMatthias Ringwald #define GATT_SERVER_CHARACTERISTICS_CONFIGURATION   0x2903
8304c1900e6SMatthias Ringwald #define GATT_CHARACTERISTIC_PRESENTATION_FORMAT     0x2904
8314c1900e6SMatthias Ringwald #define GATT_CHARACTERISTIC_AGGREGATE_FORMAT        0x2905
83262ef30efSMatthias Ringwald #define GATT_CLIENT_SUPPORTED_FEATURES              0x2B29
83362ef30efSMatthias Ringwald #define GATT_SERVER_SUPPORTED_FEATURES              0x2B3A
8344c1900e6SMatthias Ringwald 
8354c1900e6SMatthias Ringwald #define GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NONE          0
8364c1900e6SMatthias Ringwald #define GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NOTIFICATION  1
8374c1900e6SMatthias Ringwald #define GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_INDICATION    2
8384c1900e6SMatthias Ringwald 
839b3f03c84SMatthias Ringwald #define GATT_CLIENT_ANY_CONNECTION      0xffff
840b3f03c84SMatthias Ringwald #define GATT_CLIENT_ANY_VALUE_HANDLE    0x0000
841b3f03c84SMatthias Ringwald 
8424c1900e6SMatthias Ringwald // GAP Service and Characteristics
8434c1900e6SMatthias Ringwald #define GAP_SERVICE_UUID               0x1800
8444c1900e6SMatthias Ringwald #define GAP_DEVICE_NAME_UUID           0x2a00
8454c1900e6SMatthias Ringwald #define GAP_APPEARANCE_UUID            0x2a01
8464c1900e6SMatthias Ringwald #define GAP_PERIPHERAL_PRIVACY_FLAG    0x2a02
8474c1900e6SMatthias Ringwald #define GAP_RECONNECTION_ADDRESS_UUID  0x2a03
8484c1900e6SMatthias Ringwald #define GAP_PERIPHERAL_PREFERRED_CONNECTION_PARAMETERS_UUID 0x2a04
84917fe8172SMatthias Ringwald #define GAP_SERVICE_CHANGED            0x2a05
8504c1900e6SMatthias Ringwald 
851bb7f3677SMilanka Ringwald // Bluetooth GATT types
852bb7f3677SMilanka Ringwald 
853bb7f3677SMilanka Ringwald typedef struct {
854bb7f3677SMilanka Ringwald     uint16_t year;      // 0 - year  is not known; or [1582,9999]
855bb7f3677SMilanka Ringwald     uint8_t  month;     // 0 - month is not known; or [1,12]
856bb7f3677SMilanka Ringwald     uint8_t  day;       // 0 - day   is not known; or [1,31]
857bb7f3677SMilanka Ringwald     uint8_t  hours;     // [0,23]
858bb7f3677SMilanka Ringwald     uint8_t  minutes;   // [0,59]
859bb7f3677SMilanka Ringwald     uint8_t  seconds;   // [0,59]
860bb7f3677SMilanka Ringwald } gatt_date_time_t;
861bb7f3677SMilanka Ringwald 
862f229ad0aSMilanka Ringwald typedef enum {
863f229ad0aSMilanka Ringwald     GATT_MICROPHONE_CONTROL_MUTE_OFF = 0x00,
864f229ad0aSMilanka Ringwald     GATT_MICROPHONE_CONTROL_MUTE_ON,
865f229ad0aSMilanka Ringwald     GATT_MICROPHONE_CONTROL_MUTE_DISABLED
866f229ad0aSMilanka Ringwald } gatt_microphone_control_mute_t;
867f229ad0aSMilanka Ringwald 
8684c1900e6SMatthias Ringwald /**
8694c1900e6SMatthias Ringwald  * SM - LE Security Manager
8704c1900e6SMatthias Ringwald  */
8714c1900e6SMatthias Ringwald // Bluetooth Spec definitions
8724c1900e6SMatthias Ringwald typedef enum {
8734c1900e6SMatthias Ringwald     SM_CODE_PAIRING_REQUEST = 0X01,
8744c1900e6SMatthias Ringwald     SM_CODE_PAIRING_RESPONSE,
8754c1900e6SMatthias Ringwald     SM_CODE_PAIRING_CONFIRM,
8764c1900e6SMatthias Ringwald     SM_CODE_PAIRING_RANDOM,
8774c1900e6SMatthias Ringwald     SM_CODE_PAIRING_FAILED,
8784c1900e6SMatthias Ringwald     SM_CODE_ENCRYPTION_INFORMATION,
8794c1900e6SMatthias Ringwald     SM_CODE_MASTER_IDENTIFICATION,
8804c1900e6SMatthias Ringwald     SM_CODE_IDENTITY_INFORMATION,
8814c1900e6SMatthias Ringwald     SM_CODE_IDENTITY_ADDRESS_INFORMATION,
8824c1900e6SMatthias Ringwald     SM_CODE_SIGNING_INFORMATION,
88374a9b3d5SMatthias Ringwald     SM_CODE_SECURITY_REQUEST,
88474a9b3d5SMatthias Ringwald     SM_CODE_PAIRING_PUBLIC_KEY,
88574a9b3d5SMatthias Ringwald     SM_CODE_PAIRING_DHKEY_CHECK,
88644e8d9acSMatthias Ringwald     SM_CODE_KEYPRESS_NOTIFICATION,
8874c1900e6SMatthias Ringwald } SECURITY_MANAGER_COMMANDS;
8884c1900e6SMatthias Ringwald 
8894c1900e6SMatthias Ringwald // IO Capability Values
8904c1900e6SMatthias Ringwald typedef enum {
8914c1900e6SMatthias Ringwald     IO_CAPABILITY_DISPLAY_ONLY = 0,
8924c1900e6SMatthias Ringwald     IO_CAPABILITY_DISPLAY_YES_NO,
8934c1900e6SMatthias Ringwald     IO_CAPABILITY_KEYBOARD_ONLY,
8944c1900e6SMatthias Ringwald     IO_CAPABILITY_NO_INPUT_NO_OUTPUT,
8954c1900e6SMatthias Ringwald     IO_CAPABILITY_KEYBOARD_DISPLAY, // not used by secure simple pairing
8964c1900e6SMatthias Ringwald } io_capability_t;
8974c1900e6SMatthias Ringwald 
8984c1900e6SMatthias Ringwald // Authentication requirement flags
8994c1900e6SMatthias Ringwald #define SM_AUTHREQ_NO_BONDING        0x00
9004c1900e6SMatthias Ringwald #define SM_AUTHREQ_BONDING           0x01
9014c1900e6SMatthias Ringwald #define SM_AUTHREQ_MITM_PROTECTION   0x04
90274a9b3d5SMatthias Ringwald #define SM_AUTHREQ_SECURE_CONNECTION 0x08
90374a9b3d5SMatthias Ringwald #define SM_AUTHREQ_KEYPRESS          0x10
90457132f12SMatthias Ringwald #define SM_AUTHREQ_CT2               0x20
9054c1900e6SMatthias Ringwald 
9064c1900e6SMatthias Ringwald // Key distribution flags used by spec
90752f9cf63SMatthias Ringwald #define SM_KEYDIST_ENC_KEY  0x01
9084c1900e6SMatthias Ringwald #define SM_KEYDIST_ID_KEY   0x02
9094c1900e6SMatthias Ringwald #define SM_KEYDIST_SIGN     0x04
91052f9cf63SMatthias Ringwald #define SM_KEYDIST_LINK_KEY 0x08
9114c1900e6SMatthias Ringwald 
9124c1900e6SMatthias Ringwald // Key distribution flags used internally
9134c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_ENCRYPTION_INFORMATION       0x01
9144c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_MASTER_IDENTIFICATION        0x02
9154c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_IDENTITY_INFORMATION         0x04
9164c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_IDENTITY_ADDRESS_INFORMATION 0x08
9174c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_SIGNING_IDENTIFICATION       0x10
9184c1900e6SMatthias Ringwald 
9194c1900e6SMatthias Ringwald // STK Generation Methods
9204c1900e6SMatthias Ringwald #define SM_STK_GENERATION_METHOD_JUST_WORKS          0x01
9214c1900e6SMatthias Ringwald #define SM_STK_GENERATION_METHOD_OOB                 0x02
9224c1900e6SMatthias Ringwald #define SM_STK_GENERATION_METHOD_PASSKEY             0x04
923b4343428SMatthias Ringwald #define SM_STK_GENERATION_METHOD_NUMERIC_COMPARISON  0x08
9244c1900e6SMatthias Ringwald 
9254c1900e6SMatthias Ringwald // Pairing Failed Reasons
9264c1900e6SMatthias Ringwald #define SM_REASON_RESERVED                     0x00
92716a1a3e5SMatthias Ringwald #define SM_REASON_PASSKEY_ENTRY_FAILED         0x01
9284c1900e6SMatthias Ringwald #define SM_REASON_OOB_NOT_AVAILABLE            0x02
9294c1900e6SMatthias Ringwald #define SM_REASON_AUTHENTHICATION_REQUIREMENTS 0x03
9304c1900e6SMatthias Ringwald #define SM_REASON_CONFIRM_VALUE_FAILED         0x04
9314c1900e6SMatthias Ringwald #define SM_REASON_PAIRING_NOT_SUPPORTED        0x05
9324c1900e6SMatthias Ringwald #define SM_REASON_ENCRYPTION_KEY_SIZE          0x06
9334c1900e6SMatthias Ringwald #define SM_REASON_COMMAND_NOT_SUPPORTED        0x07
9344c1900e6SMatthias Ringwald #define SM_REASON_UNSPECIFIED_REASON           0x08
9354c1900e6SMatthias Ringwald #define SM_REASON_REPEATED_ATTEMPTS            0x09
936a9f29768SMatthias Ringwald #define SM_REASON_INVALID_PARAMETERS           0x0a
937a9f29768SMatthias Ringwald #define SM_REASON_DHKEY_CHECK_FAILED           0x0b
938a9f29768SMatthias Ringwald #define SM_REASON_NUMERIC_COMPARISON_FAILED    0x0c
9394e65ea07SMatthias Ringwald #define SM_REASON_BR_EDR_PAIRING_IN_PROGRESS   0x0d
9404e65ea07SMatthias Ringwald #define SM_REASON_CROSS_TRANSPORT_KEY_DERIVATION_NOT_ALLOWED 0x0e
9414e65ea07SMatthias Ringwald #define SM_REASON_KEY_REJECTED                 0x0f
942a9f29768SMatthias Ringwald 
9434c1900e6SMatthias Ringwald // also, invalid parameters
9444c1900e6SMatthias Ringwald // and reserved
9454c1900e6SMatthias Ringwald 
94644e8d9acSMatthias Ringwald // Keypress Notifications
94744e8d9acSMatthias Ringwald #define SM_KEYPRESS_PASSKEY_ENTRY_STARTED      0x00
94844e8d9acSMatthias Ringwald #define SM_KEYPRESS_PASSKEY_DIGIT_ENTERED      0x01
94944e8d9acSMatthias Ringwald #define SM_KEYPRESS_PASSKEY_DIGIT_ERASED       0x02
95044e8d9acSMatthias Ringwald #define SM_KEYPRESS_PASSKEY_CLEARED            0x03
95144e8d9acSMatthias Ringwald #define SM_KEYPRESS_PASSKEY_ENTRY_COMPLETED    0x04
95244e8d9acSMatthias Ringwald 
95344e8d9acSMatthias Ringwald 
95447f4e325SMatthias Ringwald #endif
955