xref: /btstack/src/bluetooth.h (revision f6858d14c853904ddef6a275d83bc37b9e4f91b7)
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
2347f4e325SMatthias Ringwald  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
2447f4e325SMatthias Ringwald  * RINGWALD 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 
4447f4e325SMatthias Ringwald #ifndef __BLUETOOTH_H
4547f4e325SMatthias 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  * @note: BTstack uses a custom addr type to refer to classic ACL and SCO devices
678974fcd6SMatthias Ringwald  */
688974fcd6SMatthias Ringwald  typedef enum {
698974fcd6SMatthias Ringwald     BD_ADDR_TYPE_LE_PUBLIC = 0,
708974fcd6SMatthias Ringwald     BD_ADDR_TYPE_LE_RANDOM = 1,
718974fcd6SMatthias Ringwald     BD_ADDR_TYPE_SCO       = 0xfe,
728974fcd6SMatthias Ringwald     BD_ADDR_TYPE_CLASSIC   = 0xff,
738974fcd6SMatthias Ringwald     BD_ADDR_TYPE_UNKNOWN   = 0xfe
748974fcd6SMatthias Ringwald } bd_addr_type_t;
758974fcd6SMatthias Ringwald 
768974fcd6SMatthias Ringwald /**
778974fcd6SMatthias Ringwald  * @brief link key
788974fcd6SMatthias Ringwald  */
798974fcd6SMatthias Ringwald #define LINK_KEY_LEN 16
808974fcd6SMatthias Ringwald #define LINK_KEY_STR_LEN (LINK_KEY_LEN*2)
818974fcd6SMatthias Ringwald typedef uint8_t link_key_t[LINK_KEY_LEN];
828974fcd6SMatthias Ringwald 
838974fcd6SMatthias Ringwald /**
848974fcd6SMatthias Ringwald  * @brief link key type
858974fcd6SMatthias Ringwald  */
868974fcd6SMatthias Ringwald typedef enum {
878974fcd6SMatthias Ringwald   COMBINATION_KEY = 0,  // standard pairing
888974fcd6SMatthias Ringwald   LOCAL_UNIT_KEY,     // ?
898974fcd6SMatthias Ringwald   REMOTE_UNIT_KEY,    // ?
908974fcd6SMatthias Ringwald   DEBUG_COMBINATION_KEY,  // SSP with debug
918974fcd6SMatthias Ringwald   UNAUTHENTICATED_COMBINATION_KEY_GENERATED_FROM_P192, // SSP Simple Pairing
928974fcd6SMatthias Ringwald   AUTHENTICATED_COMBINATION_KEY_GENERATED_FROM_P192,   // SSP Passkey, Number confirm, OOB
938974fcd6SMatthias Ringwald   CHANGED_COMBINATION_KEY,               // Link key changed using Change Connection Lnk Key
948974fcd6SMatthias Ringwald   UNAUTHENTICATED_COMBINATION_KEY_GENERATED_FROM_P256, // SSP Simpe Pairing
958974fcd6SMatthias Ringwald   AUTHENTICATED_COMBINATION_KEY_GENERATED_FROM_P256,   // SSP Passkey, Number confirm, OOB
968974fcd6SMatthias Ringwald } link_key_type_t;
978974fcd6SMatthias Ringwald 
988974fcd6SMatthias Ringwald /**
99*f6858d14SMatthias Ringwald  * @brief Inquiry modes
100*f6858d14SMatthias Ringwald  */
101*f6858d14SMatthias Ringwald typedef enum {
102*f6858d14SMatthias Ringwald   INQUIRY_MODE_STANDARD = 0,
103*f6858d14SMatthias Ringwald   INQUIRY_MODE_RSSI,
104*f6858d14SMatthias Ringwald   INQUIRY_MODE_RSSI_AND_EIR,
105*f6858d14SMatthias Ringwald } inquiry_mode_t;
106*f6858d14SMatthias Ringwald 
107*f6858d14SMatthias Ringwald /**
10847f4e325SMatthias Ringwald  * HCI Transport
10947f4e325SMatthias Ringwald  */
11047f4e325SMatthias Ringwald 
11147f4e325SMatthias Ringwald /**
11247f4e325SMatthias Ringwald  * packet types - used in BTstack and over the H4 UART interface
11347f4e325SMatthias Ringwald  */
11447f4e325SMatthias Ringwald #define HCI_COMMAND_DATA_PACKET 0x01
11547f4e325SMatthias Ringwald #define HCI_ACL_DATA_PACKET     0x02
11647f4e325SMatthias Ringwald #define HCI_SCO_DATA_PACKET     0x03
11747f4e325SMatthias Ringwald #define HCI_EVENT_PACKET        0x04
11847f4e325SMatthias Ringwald 
1198799c043SMatthias Ringwald // packet header sizes
1208799c043SMatthias Ringwald #define HCI_CMD_HEADER_SIZE          3
1218799c043SMatthias Ringwald #define HCI_ACL_HEADER_SIZE          4
1228799c043SMatthias Ringwald #define HCI_SCO_HEADER_SIZE          3
1238799c043SMatthias Ringwald #define HCI_EVENT_HEADER_SIZE        2
1248799c043SMatthias Ringwald 
12547f4e325SMatthias Ringwald /**
12647f4e325SMatthias Ringwald  * HCI Layer
12747f4e325SMatthias Ringwald  */
12847f4e325SMatthias Ringwald 
12947f4e325SMatthias Ringwald //
13047f4e325SMatthias Ringwald // Error Codes
13147f4e325SMatthias Ringwald //
13247f4e325SMatthias Ringwald 
13347f4e325SMatthias Ringwald // from Bluetooth Core Specification
134616edd56SMatthias Ringwald #define ERROR_CODE_SUCCESS                                 0x00
13547f4e325SMatthias Ringwald #define ERROR_CODE_UNKNOWN_HCI_COMMAND                     0x01
13647f4e325SMatthias Ringwald #define ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER           0x02
13747f4e325SMatthias Ringwald #define ERROR_CODE_HARDWARE_FAILURE                        0x03
13847f4e325SMatthias Ringwald #define ERROR_CODE_PAGE_TIMEOUT                            0x04
13947f4e325SMatthias Ringwald #define ERROR_CODE_AUTHENTICATION_FAILURE                  0x05
14047f4e325SMatthias Ringwald #define ERROR_CODE_PIN_OR_KEY_MISSING                      0x06
14147f4e325SMatthias Ringwald #define ERROR_CODE_MEMORY_CAPACITY_EXCEEDED                0x07
14247f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_TIMEOUT                      0x08
14347f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_LIMIT_EXCEEDED               0x09
14447f4e325SMatthias Ringwald #define ERROR_CODE_SYNCHRONOUS_CONNECTION_LIMIT_TO_A_DEVICE_EXCEEDED  0x0A
14547f4e325SMatthias Ringwald #define ERROR_CODE_ACL_CONNECTION_ALREADY_EXISTS           0x0B
14647f4e325SMatthias Ringwald #define ERROR_CODE_COMMAND_DISALLOWED                      0x0C
14747f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_REJECTED_DUE_TO_LIMITED_RESOURCES 0x0D
14847f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_REJECTED_DUE_TO_SECURITY_REASONS  0x0E
14947f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_REJECTED_DUE_TO_UNACCEPTABLE_BD_ADDR 0x0F
15047f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_ACCEPT_TIMEOUT_EXCEEDED      0x10
15147f4e325SMatthias Ringwald #define ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE  0x11
15247f4e325SMatthias Ringwald #define ERROR_CODE_INVALID_HCI_COMMAND_PARAMETERS          0x12
15347f4e325SMatthias Ringwald #define ERROR_CODE_REMOTE_USER_TERMINATED_CONNECTION       0x13
15447f4e325SMatthias Ringwald #define ERROR_CODE_REMOTE_DEVICE_TERMINATED_CONNECTION_DUE_TO_LOW_RESOURCES 0x14
15547f4e325SMatthias Ringwald #define ERROR_CODE_REMOTE_DEVICE_TERMINATED_CONNECTION_DUE_TO_POWER_OFF     0x15
15647f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_TERMINATED_BY_LOCAL_HOST     0x16
15747f4e325SMatthias Ringwald #define ERROR_CODE_REPEATED_ATTEMPTS                       0x17
15847f4e325SMatthias Ringwald #define ERROR_CODE_PAIRING_NOT_ALLOWED                     0x18
15947f4e325SMatthias Ringwald #define ERROR_CODE_UNKNOWN_LMP_PDU                         0x19
16047f4e325SMatthias Ringwald #define ERROR_CODE_UNSUPPORTED_REMOTE_FEATURE_UNSUPPORTED_LMP_FEATURE 0x1A
16147f4e325SMatthias Ringwald #define ERROR_CODE_SCO_OFFSET_REJECTED                     0x1B
16247f4e325SMatthias Ringwald #define ERROR_CODE_SCO_INTERVAL_REJECTED                   0x1C
16347f4e325SMatthias Ringwald #define ERROR_CODE_SCO_AIR_MODE_REJECTED                   0x1D
16447f4e325SMatthias Ringwald #define ERROR_CODE_INVALID_LMP_PARAMETERS_INVALID_LL_PARAMETERS 0x1E
16547f4e325SMatthias Ringwald #define ERROR_CODE_UNSPECIFIED_ERROR                       0x1F
16647f4e325SMatthias Ringwald #define ERROR_CODE_UNSUPPORTED_LMP_PARAMETER_VALUE_UNSUPPORTED_LL_PARAMETER_VALUE 0x20
16747f4e325SMatthias Ringwald #define ERROR_CODE_ROLE_CHANGE_NOT_ALLOWED                 0x21
16847f4e325SMatthias Ringwald #define ERROR_CODE_LMP_RESPONSE_TIMEOUT_LL_RESPONSE_TIMEOUT 0x22
16947f4e325SMatthias Ringwald #define ERROR_CODE_LMP_ERROR_TRANSACTION_COLLISION         0x23
17047f4e325SMatthias Ringwald #define ERROR_CODE_LMP_PDU_NOT_ALLOWED                     0x24
17147f4e325SMatthias Ringwald #define ERROR_CODE_ENCRYPTION_MODE_NOT_ACCEPTABLE          0x25
17247f4e325SMatthias Ringwald #define ERROR_CODE_LINK_KEY_CANNOT_BE_CHANGED              0x26
17347f4e325SMatthias Ringwald #define ERROR_CODE_REQUESTED_QOS_NOT_SUPPORTED             0x27
17447f4e325SMatthias Ringwald #define ERROR_CODE_INSTANT_PASSED                          0x28
17547f4e325SMatthias Ringwald #define ERROR_CODE_PAIRING_WITH_UNIT_KEY_NOT_SUPPORTED     0x29
17647f4e325SMatthias Ringwald #define ERROR_CODE_DIFFERENT_TRANSACTION_COLLISION         0x2A
17747f4e325SMatthias Ringwald #define ERROR_CODE_RESERVED                                0x2B
17847f4e325SMatthias Ringwald #define ERROR_CODE_QOS_UNACCEPTABLE_PARAMETER              0x2C
17947f4e325SMatthias Ringwald #define ERROR_CODE_QOS_REJECTED                            0x2D
18047f4e325SMatthias Ringwald #define ERROR_CODE_CHANNEL_CLASSIFICATION_NOT_SUPPORTED    0x2E
18147f4e325SMatthias Ringwald #define ERROR_CODE_INSUFFICIENT_SECURITY                   0x2F
18247f4e325SMatthias Ringwald #define ERROR_CODE_PARAMETER_OUT_OF_MANDATORY_RANGE        0x30
18347f4e325SMatthias Ringwald // #define ERROR_CODE_RESERVED
18447f4e325SMatthias Ringwald #define ERROR_CODE_ROLE_SWITCH_PENDING                     0x32
18547f4e325SMatthias Ringwald // #define ERROR_CODE_RESERVED
18647f4e325SMatthias Ringwald #define ERROR_CODE_RESERVED_SLOT_VIOLATION                 0x34
18747f4e325SMatthias Ringwald #define ERROR_CODE_ROLE_SWITCH_FAILED                      0x35
18847f4e325SMatthias Ringwald #define ERROR_CODE_EXTENDED_INQUIRY_RESPONSE_TOO_LARGE     0x36
18947f4e325SMatthias Ringwald #define ERROR_CODE_SECURE_SIMPLE_PAIRING_NOT_SUPPORTED_BY_HOST 0x37
19047f4e325SMatthias Ringwald #define ERROR_CODE_HOST_BUSY_PAIRING                       0x38
19147f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_REJECTED_DUE_TO_NO_SUITABLE_CHANNEL_FOUND 0x39
19247f4e325SMatthias Ringwald #define ERROR_CODE_CONTROLLER_BUSY                         0x3A
19347f4e325SMatthias Ringwald #define ERROR_CODE_UNACCEPTABLE_CONNECTION_PARAMETERS      0x3B
19447f4e325SMatthias Ringwald #define ERROR_CODE_DIRECTED_ADVERTISING_TIMEOUT            0x3C
19547f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_TERMINATED_DUE_TO_MIC_FAILURE 0x3D
19647f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_FAILED_TO_BE_ESTABLISHED     0x3E
19747f4e325SMatthias Ringwald #define ERROR_CODE_MAC_CONNECTION_FAILED                   0x3F
19847f4e325SMatthias Ringwald #define ERROR_CODE_COARSE_CLOCK_ADJUSTMENT_REJECTED_BUT_WILL_TRY_TO_ADJUST_USING_CLOCK_DRAGGING 0x40
19947f4e325SMatthias Ringwald 
2008799c043SMatthias Ringwald // HCI roles
2018799c043SMatthias Ringwald #define HCI_ROLE_MASTER 0
2028799c043SMatthias Ringwald #define HCI_ROLE_SLAVE  1
2038799c043SMatthias Ringwald 
2048799c043SMatthias Ringwald // packet sizes (max payload)
2058799c043SMatthias Ringwald #define HCI_ACL_DM1_SIZE            17
2068799c043SMatthias Ringwald #define HCI_ACL_DH1_SIZE            27
2078799c043SMatthias Ringwald #define HCI_ACL_2DH1_SIZE           54
2088799c043SMatthias Ringwald #define HCI_ACL_3DH1_SIZE           83
2098799c043SMatthias Ringwald #define HCI_ACL_DM3_SIZE           121
2108799c043SMatthias Ringwald #define HCI_ACL_DH3_SIZE           183
2118799c043SMatthias Ringwald #define HCI_ACL_DM5_SIZE           224
2128799c043SMatthias Ringwald #define HCI_ACL_DH5_SIZE           339
2138799c043SMatthias Ringwald #define HCI_ACL_2DH3_SIZE          367
2148799c043SMatthias Ringwald #define HCI_ACL_3DH3_SIZE          552
2158799c043SMatthias Ringwald #define HCI_ACL_2DH5_SIZE          679
2168799c043SMatthias Ringwald #define HCI_ACL_3DH5_SIZE         1021
2178799c043SMatthias Ringwald 
2188799c043SMatthias Ringwald #define HCI_EVENT_PAYLOAD_SIZE     255
2198799c043SMatthias Ringwald #define HCI_CMD_PAYLOAD_SIZE       255
2208799c043SMatthias Ringwald 
2218799c043SMatthias Ringwald #define LE_ADVERTISING_DATA_SIZE    31
22247f4e325SMatthias Ringwald 
22347f4e325SMatthias Ringwald /**
22447f4e325SMatthias Ringwald  * Default INQ Mode
22547f4e325SMatthias Ringwald  */
22647f4e325SMatthias Ringwald #define HCI_INQUIRY_LAP 0x9E8B33L  // 0x9E8B33: General/Unlimited Inquiry Access Code (GIAC)
22747f4e325SMatthias Ringwald 
22847f4e325SMatthias Ringwald /**
22947f4e325SMatthias Ringwald  * SSP IO Capabilities
23047f4e325SMatthias Ringwald  */
23147f4e325SMatthias Ringwald #define SSP_IO_CAPABILITY_DISPLAY_ONLY   0
23247f4e325SMatthias Ringwald #define SSP_IO_CAPABILITY_DISPLAY_YES_NO 1
23347f4e325SMatthias Ringwald #define SSP_IO_CAPABILITY_KEYBOARD_ONLY  2
23447f4e325SMatthias Ringwald #define SSP_IO_CAPABILITY_NO_INPUT_NO_OUTPUT 3
23547f4e325SMatthias Ringwald #define SSP_IO_CAPABILITY_UNKNOWN 0xff
23647f4e325SMatthias Ringwald 
23747f4e325SMatthias Ringwald 
23847f4e325SMatthias Ringwald /**
23947f4e325SMatthias Ringwald  * SSP Authentication Requirements, see IO Capability Request Reply Commmand
24047f4e325SMatthias Ringwald  */
24147f4e325SMatthias Ringwald 
24247f4e325SMatthias Ringwald // Numeric comparison with automatic accept allowed.
24347f4e325SMatthias Ringwald #define SSP_IO_AUTHREQ_MITM_PROTECTION_NOT_REQUIRED_NO_BONDING 0x00
24447f4e325SMatthias Ringwald 
24547f4e325SMatthias Ringwald // Use IO Capabilities to deter- mine authentication procedure
24647f4e325SMatthias Ringwald #define SSP_IO_AUTHREQ_MITM_PROTECTION_REQUIRED_NO_BONDING 0x01
24747f4e325SMatthias Ringwald 
24847f4e325SMatthias Ringwald // Numeric compar- ison with automatic accept allowed.
24947f4e325SMatthias Ringwald #define SSP_IO_AUTHREQ_MITM_PROTECTION_NOT_REQUIRED_DEDICATED_BONDING 0x02
25047f4e325SMatthias Ringwald 
25147f4e325SMatthias Ringwald // Use IO Capabilities to determine authentication procedure
25247f4e325SMatthias Ringwald #define SSP_IO_AUTHREQ_MITM_PROTECTION_REQUIRED_DEDICATED_BONDING 0x03
25347f4e325SMatthias Ringwald 
25447f4e325SMatthias Ringwald // Numeric Compari- son with automatic accept allowed.
25547f4e325SMatthias Ringwald #define SSP_IO_AUTHREQ_MITM_PROTECTION_NOT_REQUIRED_GENERAL_BONDING 0x04
25647f4e325SMatthias Ringwald 
2578799c043SMatthias Ringwald // Use IO capabilities to determine authentication procedure.
25847f4e325SMatthias Ringwald #define SSP_IO_AUTHREQ_MITM_PROTECTION_REQUIRED_GENERAL_BONDING 0x05
25947f4e325SMatthias Ringwald 
26047f4e325SMatthias Ringwald 
2618799c043SMatthias Ringwald // OGFs
2628799c043SMatthias Ringwald #define OGF_LINK_CONTROL          0x01
2638799c043SMatthias Ringwald #define OGF_LINK_POLICY           0x02
2648799c043SMatthias Ringwald #define OGF_CONTROLLER_BASEBAND   0x03
2658799c043SMatthias Ringwald #define OGF_INFORMATIONAL_PARAMETERS 0x04
2668799c043SMatthias Ringwald #define OGF_STATUS_PARAMETERS     0x05
2678799c043SMatthias Ringwald #define OGF_TESTING               0x06
2688799c043SMatthias Ringwald #define OGF_LE_CONTROLLER 0x08
2698799c043SMatthias Ringwald #define OGF_VENDOR  0x3f
2708799c043SMatthias Ringwald 
2718799c043SMatthias Ringwald 
27247f4e325SMatthias Ringwald // Events from host controller to host
27347f4e325SMatthias Ringwald 
27447f4e325SMatthias Ringwald /**
27547f4e325SMatthias Ringwald  * @format 1
27647f4e325SMatthias Ringwald  * @param status
27747f4e325SMatthias Ringwald  */
27847f4e325SMatthias Ringwald #define HCI_EVENT_INQUIRY_COMPLETE                         0x01
27947f4e325SMatthias Ringwald // no format yet, can contain multiple results
28047f4e325SMatthias Ringwald 
28147f4e325SMatthias Ringwald /**
28247f4e325SMatthias Ringwald  * @format 1B11132
28347f4e325SMatthias Ringwald  * @param num_responses
28447f4e325SMatthias Ringwald  * @param bd_addr
28547f4e325SMatthias Ringwald  * @param page_scan_repetition_mode
28647f4e325SMatthias Ringwald  * @param reserved1
28747f4e325SMatthias Ringwald  * @param reserved2
28847f4e325SMatthias Ringwald  * @param class_of_device
28947f4e325SMatthias Ringwald  * @param clock_offset
29047f4e325SMatthias Ringwald  */
29147f4e325SMatthias Ringwald #define HCI_EVENT_INQUIRY_RESULT                           0x02
29247f4e325SMatthias Ringwald 
29347f4e325SMatthias Ringwald /**
29447f4e325SMatthias Ringwald  * @format 12B11
29547f4e325SMatthias Ringwald  * @param status
29647f4e325SMatthias Ringwald  * @param connection_handle
29747f4e325SMatthias Ringwald  * @param bd_addr
29847f4e325SMatthias Ringwald  * @param link_type
29947f4e325SMatthias Ringwald  * @param encryption_enabled
30047f4e325SMatthias Ringwald  */
30147f4e325SMatthias Ringwald #define HCI_EVENT_CONNECTION_COMPLETE                      0x03
30247f4e325SMatthias Ringwald /**
30347f4e325SMatthias Ringwald  * @format B31
30447f4e325SMatthias Ringwald  * @param bd_addr
30547f4e325SMatthias Ringwald  * @param class_of_device
30647f4e325SMatthias Ringwald  * @param link_type
30747f4e325SMatthias Ringwald  */
30847f4e325SMatthias Ringwald #define HCI_EVENT_CONNECTION_REQUEST                       0x04
30947f4e325SMatthias Ringwald /**
31047f4e325SMatthias Ringwald  * @format 121
31147f4e325SMatthias Ringwald  * @param status
31247f4e325SMatthias Ringwald  * @param connection_handle
31347f4e325SMatthias Ringwald  * @param reason
31447f4e325SMatthias Ringwald  */
31547f4e325SMatthias Ringwald #define HCI_EVENT_DISCONNECTION_COMPLETE                   0x05
31647f4e325SMatthias Ringwald /**
31747f4e325SMatthias Ringwald  * @format 12
31847f4e325SMatthias Ringwald  * @param status
31947f4e325SMatthias Ringwald  * @param connection_handle
32047f4e325SMatthias Ringwald  */
32147f4e325SMatthias Ringwald #define HCI_EVENT_AUTHENTICATION_COMPLETE_EVENT            0x06
32247f4e325SMatthias Ringwald /**
32347f4e325SMatthias Ringwald  * @format 1BN
32447f4e325SMatthias Ringwald  * @param status
32547f4e325SMatthias Ringwald  * @param bd_addr
32647f4e325SMatthias Ringwald  * @param remote_name
32747f4e325SMatthias Ringwald  */
32847f4e325SMatthias Ringwald #define HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE             0x07
32947f4e325SMatthias Ringwald /**
33047f4e325SMatthias Ringwald  * @format 121
33147f4e325SMatthias Ringwald  * @param status
33247f4e325SMatthias Ringwald  * @param connection_handle
33347f4e325SMatthias Ringwald  * @param encryption_enabled
33447f4e325SMatthias Ringwald  */
33547f4e325SMatthias Ringwald #define HCI_EVENT_ENCRYPTION_CHANGE                        0x08
33647f4e325SMatthias Ringwald /**
33747f4e325SMatthias Ringwald  * @format 12
33847f4e325SMatthias Ringwald  * @param status
33947f4e325SMatthias Ringwald  * @param connection_handle
34047f4e325SMatthias Ringwald  */
34147f4e325SMatthias Ringwald #define HCI_EVENT_CHANGE_CONNECTION_LINK_KEY_COMPLETE      0x09
34247f4e325SMatthias Ringwald /**
34347f4e325SMatthias Ringwald  * @format 121
34447f4e325SMatthias Ringwald  * @param status
34547f4e325SMatthias Ringwald  * @param connection_handle
34647f4e325SMatthias Ringwald  * @param key_flag
34747f4e325SMatthias Ringwald  */
34847f4e325SMatthias Ringwald #define HCI_EVENT_MASTER_LINK_KEY_COMPLETE                 0x0A
34947f4e325SMatthias Ringwald #define HCI_EVENT_READ_REMOTE_SUPPORTED_FEATURES_COMPLETE  0x0B
35047f4e325SMatthias Ringwald #define HCI_EVENT_READ_REMOTE_VERSION_INFORMATION_COMPLETE 0x0C
35147f4e325SMatthias Ringwald #define HCI_EVENT_QOS_SETUP_COMPLETE                       0x0D
35247f4e325SMatthias Ringwald 
35347f4e325SMatthias Ringwald /**
35447f4e325SMatthias Ringwald  * @format 12R
35547f4e325SMatthias Ringwald  * @param num_hci_command_packets
35647f4e325SMatthias Ringwald  * @param command_opcode
35747f4e325SMatthias Ringwald  * @param return_parameters
35847f4e325SMatthias Ringwald  */
35947f4e325SMatthias Ringwald #define HCI_EVENT_COMMAND_COMPLETE                         0x0E
36047f4e325SMatthias Ringwald /**
36147f4e325SMatthias Ringwald  * @format 112
36247f4e325SMatthias Ringwald  * @param status
36347f4e325SMatthias Ringwald  * @param num_hci_command_packets
36447f4e325SMatthias Ringwald  * @param command_opcode
36547f4e325SMatthias Ringwald  */
36647f4e325SMatthias Ringwald #define HCI_EVENT_COMMAND_STATUS                           0x0F
36747f4e325SMatthias Ringwald 
36847f4e325SMatthias Ringwald /**
36947f4e325SMatthias Ringwald  * @format 121
37047f4e325SMatthias Ringwald  * @param hardware_code
37147f4e325SMatthias Ringwald  */
37247f4e325SMatthias Ringwald #define HCI_EVENT_HARDWARE_ERROR                           0x10
37347f4e325SMatthias Ringwald 
37447f4e325SMatthias Ringwald #define HCI_EVENT_FLUSH_OCCURED                            0x11
37547f4e325SMatthias Ringwald 
37647f4e325SMatthias Ringwald /**
37747f4e325SMatthias Ringwald  * @format 1B1
37847f4e325SMatthias Ringwald  * @param status
37947f4e325SMatthias Ringwald  * @param bd_addr
38047f4e325SMatthias Ringwald  * @param role
38147f4e325SMatthias Ringwald  */
38247f4e325SMatthias Ringwald #define HCI_EVENT_ROLE_CHANGE                              0x12
38347f4e325SMatthias Ringwald 
38410093bf5SMilanka Ringwald // TODO: number_of_handles 1, connection_handle[H*i], hc_num_of_completed_packets[2*i]
38547f4e325SMatthias Ringwald #define HCI_EVENT_NUMBER_OF_COMPLETED_PACKETS              0x13
38610093bf5SMilanka Ringwald 
38710093bf5SMilanka Ringwald /**
38810093bf5SMilanka Ringwald  * @format 1H12
38910093bf5SMilanka Ringwald  * @param status
39010093bf5SMilanka Ringwald  * @param handle
39110093bf5SMilanka Ringwald  * @param mode
39210093bf5SMilanka Ringwald  * @param interval
39310093bf5SMilanka Ringwald  */
39447f4e325SMatthias Ringwald #define HCI_EVENT_MODE_CHANGE_EVENT                        0x14
39510093bf5SMilanka Ringwald 
39610093bf5SMilanka Ringwald // TODO: num_keys, bd_addr[B*i], link_key[16 octets * i]
39747f4e325SMatthias Ringwald #define HCI_EVENT_RETURN_LINK_KEYS                         0x15
39810093bf5SMilanka Ringwald 
39910093bf5SMilanka Ringwald /**
40010093bf5SMilanka Ringwald  * @format B
40110093bf5SMilanka Ringwald  * @param bd_addr
40210093bf5SMilanka Ringwald  */
40347f4e325SMatthias Ringwald #define HCI_EVENT_PIN_CODE_REQUEST                         0x16
40410093bf5SMilanka Ringwald 
40510093bf5SMilanka Ringwald /**
40610093bf5SMilanka Ringwald  * @format B
40710093bf5SMilanka Ringwald  * @param bd_addr
40810093bf5SMilanka Ringwald  */
40947f4e325SMatthias Ringwald #define HCI_EVENT_LINK_KEY_REQUEST                         0x17
41010093bf5SMilanka Ringwald 
41110093bf5SMilanka Ringwald // TODO: bd_addr B, link_key 16octets, key_type 1
41247f4e325SMatthias Ringwald #define HCI_EVENT_LINK_KEY_NOTIFICATION                    0x18
41310093bf5SMilanka Ringwald 
41410093bf5SMilanka Ringwald /**
41510093bf5SMilanka Ringwald  * @format 1
41610093bf5SMilanka Ringwald  * @param link_type
41710093bf5SMilanka Ringwald  */
41847f4e325SMatthias Ringwald #define HCI_EVENT_DATA_BUFFER_OVERFLOW                     0x1A
41910093bf5SMilanka Ringwald 
42010093bf5SMilanka Ringwald /**
42110093bf5SMilanka Ringwald  * @format H1
42210093bf5SMilanka Ringwald  * @param handle
42310093bf5SMilanka Ringwald  * @param lmp_max_slots
42410093bf5SMilanka Ringwald  */
42547f4e325SMatthias Ringwald #define HCI_EVENT_MAX_SLOTS_CHANGED                        0x1B
42610093bf5SMilanka Ringwald 
42710093bf5SMilanka Ringwald /**
42810093bf5SMilanka Ringwald  * @format 1H2
42910093bf5SMilanka Ringwald  * @param status
43010093bf5SMilanka Ringwald  * @param handle
43110093bf5SMilanka Ringwald  * @param clock_offset
43210093bf5SMilanka Ringwald  */
43347f4e325SMatthias Ringwald #define HCI_EVENT_READ_CLOCK_OFFSET_COMPLETE               0x1C
43410093bf5SMilanka Ringwald 
43510093bf5SMilanka Ringwald /**
43610093bf5SMilanka Ringwald  * @format 1H2
43710093bf5SMilanka Ringwald  * @param status
43810093bf5SMilanka Ringwald  * @param handle
439fea5a680SMatthias Ringwald  * @param packet_types
440fea5a680SMatthias Ringwald  * @pnote packet_type is in plural to avoid clash with Java binding Packet.getPacketType()
44110093bf5SMilanka Ringwald  */
442fea5a680SMatthias Ringwald #define HCI_EVENT_CONNECTION_PACKET_TYPE_CHANGED           0x1D
44347f4e325SMatthias Ringwald 
44447f4e325SMatthias Ringwald /**
44547f4e325SMatthias Ringwald  * @format 1B11321
44647f4e325SMatthias Ringwald  * @param num_responses
44747f4e325SMatthias Ringwald  * @param bd_addr
44847f4e325SMatthias Ringwald  * @param page_scan_repetition_mode
44947f4e325SMatthias Ringwald  * @param reserved
45047f4e325SMatthias Ringwald  * @param class_of_device
45147f4e325SMatthias Ringwald  * @param clock_offset
45247f4e325SMatthias Ringwald  * @param rssi
45347f4e325SMatthias Ringwald  */
45447f4e325SMatthias Ringwald #define HCI_EVENT_INQUIRY_RESULT_WITH_RSSI                 0x22
45547f4e325SMatthias Ringwald 
45647f4e325SMatthias Ringwald /**
45747f4e325SMatthias Ringwald  * @format 1HB111221
45847f4e325SMatthias Ringwald  * @param status
45947f4e325SMatthias Ringwald  * @param handle
46047f4e325SMatthias Ringwald  * @param bd_addr
46147f4e325SMatthias Ringwald  * @param link_type
46247f4e325SMatthias Ringwald  * @param transmission_interval
46347f4e325SMatthias Ringwald  * @param retransmission_interval
46447f4e325SMatthias Ringwald  * @param rx_packet_length
46547f4e325SMatthias Ringwald  * @param tx_packet_length
46647f4e325SMatthias Ringwald  * @param air_mode
46747f4e325SMatthias Ringwald  */
46847f4e325SMatthias Ringwald #define HCI_EVENT_SYNCHRONOUS_CONNECTION_COMPLETE          0x2C
46947f4e325SMatthias Ringwald 
47047f4e325SMatthias Ringwald // TODO: serialize extended_inquiry_response and provide parser
47147f4e325SMatthias Ringwald /**
47247f4e325SMatthias Ringwald  * @format 1B11321
47347f4e325SMatthias Ringwald  * @param num_responses
47447f4e325SMatthias Ringwald  * @param bd_addr
47547f4e325SMatthias Ringwald  * @param page_scan_repetition_mode
47647f4e325SMatthias Ringwald  * @param reserved
47747f4e325SMatthias Ringwald  * @param class_of_device
47847f4e325SMatthias Ringwald  * @param clock_offset
47947f4e325SMatthias Ringwald  * @param rssi
48047f4e325SMatthias Ringwald  */
48147f4e325SMatthias Ringwald #define HCI_EVENT_EXTENDED_INQUIRY_RESPONSE                0x2F
48247f4e325SMatthias Ringwald 
48347f4e325SMatthias Ringwald  /**
48447f4e325SMatthias Ringwald   * @format 1H
48547f4e325SMatthias Ringwald   * @param status
48647f4e325SMatthias Ringwald   * @param handle
48747f4e325SMatthias Ringwald   */
48847f4e325SMatthias Ringwald #define HCI_EVENT_ENCRYPTION_KEY_REFRESH_COMPLETE          0x30
48947f4e325SMatthias Ringwald 
49047f4e325SMatthias Ringwald #define HCI_EVENT_IO_CAPABILITY_REQUEST                    0x31
49147f4e325SMatthias Ringwald #define HCI_EVENT_IO_CAPABILITY_RESPONSE                   0x32
49247f4e325SMatthias Ringwald #define HCI_EVENT_USER_CONFIRMATION_REQUEST                0x33
49347f4e325SMatthias Ringwald #define HCI_EVENT_USER_PASSKEY_REQUEST                     0x34
49447f4e325SMatthias Ringwald #define HCI_EVENT_REMOTE_OOB_DATA_REQUEST                  0x35
49547f4e325SMatthias Ringwald #define HCI_EVENT_SIMPLE_PAIRING_COMPLETE                  0x36
49647f4e325SMatthias Ringwald 
49747f4e325SMatthias Ringwald #define HCI_EVENT_LE_META                                  0x3E
49847f4e325SMatthias Ringwald 
499941b3855SMatthias Ringwald #define HCI_EVENT_VENDOR_SPECIFIC                          0xFF
500941b3855SMatthias Ringwald 
50147f4e325SMatthias Ringwald /**
502ca0d73deSMatthias Ringwald  * @format 11H11B2221
50347f4e325SMatthias Ringwald  * @param subevent_code
50447f4e325SMatthias Ringwald  * @param status
50547f4e325SMatthias Ringwald  * @param connection_handle
50647f4e325SMatthias Ringwald  * @param role
50747f4e325SMatthias Ringwald  * @param peer_address_type
50847f4e325SMatthias Ringwald  * @param peer_address
50947f4e325SMatthias Ringwald  * @param conn_interval
51047f4e325SMatthias Ringwald  * @param conn_latency
51147f4e325SMatthias Ringwald  * @param supervision_timeout
51247f4e325SMatthias Ringwald  * @param master_clock_accuracy
51347f4e325SMatthias Ringwald  */
51447f4e325SMatthias Ringwald #define HCI_SUBEVENT_LE_CONNECTION_COMPLETE                0x01
51547f4e325SMatthias Ringwald #define HCI_SUBEVENT_LE_ADVERTISING_REPORT                 0x02
51647f4e325SMatthias Ringwald #define HCI_SUBEVENT_LE_CONNECTION_UPDATE_COMPLETE         0x03
51747f4e325SMatthias Ringwald #define HCI_SUBEVENT_LE_READ_REMOTE_USED_FEATURES_COMPLETE 0x04
51847f4e325SMatthias Ringwald #define HCI_SUBEVENT_LE_LONG_TERM_KEY_REQUEST              0x05
51947f4e325SMatthias Ringwald 
52047f4e325SMatthias Ringwald // last used HCI_EVENT in 2.1 is 0x3d
52147f4e325SMatthias Ringwald // last used HCI_EVENT in 4.1 is 0x57
52247f4e325SMatthias Ringwald 
52347f4e325SMatthias Ringwald /**
52447f4e325SMatthias Ringwald  * L2CAP Layer
52547f4e325SMatthias Ringwald  */
52647f4e325SMatthias Ringwald 
527a8373a41SMatthias Ringwald #define L2CAP_HEADER_SIZE 4
528a8373a41SMatthias Ringwald 
529a8373a41SMatthias Ringwald #define L2CAP_SIG_ID_INVALID 0
530a8373a41SMatthias Ringwald 
531a8373a41SMatthias Ringwald // size of HCI ACL + L2CAP Header for regular data packets (8)
532a8373a41SMatthias Ringwald #define COMPLETE_L2CAP_HEADER (HCI_ACL_HEADER_SIZE + L2CAP_HEADER_SIZE)
533a8373a41SMatthias Ringwald 
534a8373a41SMatthias Ringwald // minimum signaling MTU
535a8373a41SMatthias Ringwald #define L2CAP_MINIMAL_MTU 48
536a8373a41SMatthias Ringwald #define L2CAP_DEFAULT_MTU 672
537a8373a41SMatthias Ringwald 
538a8373a41SMatthias Ringwald // Minimum/default MTU
539a8373a41SMatthias Ringwald #define L2CAP_LE_DEFAULT_MTU  23
540a8373a41SMatthias Ringwald 
541a8373a41SMatthias Ringwald // L2CAP Fixed Channel IDs
542a8373a41SMatthias Ringwald #define L2CAP_CID_SIGNALING                 0x0001
543a8373a41SMatthias Ringwald #define L2CAP_CID_CONNECTIONLESS_CHANNEL    0x0002
544a8373a41SMatthias Ringwald #define L2CAP_CID_ATTRIBUTE_PROTOCOL        0x0004
545a8373a41SMatthias Ringwald #define L2CAP_CID_SIGNALING_LE              0x0005
546a8373a41SMatthias Ringwald #define L2CAP_CID_SECURITY_MANAGER_PROTOCOL 0x0006
547a8373a41SMatthias Ringwald 
548a8373a41SMatthias Ringwald // L2CAP Configuration Result Codes
549a8373a41SMatthias Ringwald #define L2CAP_CONF_RESULT_UNKNOWN_OPTIONS   0x0003
550a8373a41SMatthias Ringwald 
551a8373a41SMatthias Ringwald // L2CAP Reject Result Codes
552a8373a41SMatthias Ringwald #define L2CAP_REJ_CMD_UNKNOWN               0x0000
553a8373a41SMatthias Ringwald 
554a8373a41SMatthias Ringwald // Response Timeout eXpired
555a8373a41SMatthias Ringwald #define L2CAP_RTX_TIMEOUT_MS   10000
556a8373a41SMatthias Ringwald 
557a8373a41SMatthias Ringwald // Extended Response Timeout eXpired
558a8373a41SMatthias Ringwald #define L2CAP_ERTX_TIMEOUT_MS 120000
559a8373a41SMatthias Ringwald 
56047f4e325SMatthias Ringwald // Fixed PSM numbers
56147f4e325SMatthias Ringwald #define PSM_SDP           0x01
56247f4e325SMatthias Ringwald #define PSM_RFCOMM        0x03
56347f4e325SMatthias Ringwald #define PSM_BNEP          0x0F
56447f4e325SMatthias Ringwald #define PSM_HID_CONTROL   0x11
56547f4e325SMatthias Ringwald #define PSM_HID_INTERRUPT 0x13
56647f4e325SMatthias Ringwald 
56766b1fcb3SMatthias Ringwald /**
568ef907034SMatthias Ringwald  * SDP Protocl
569ef907034SMatthias Ringwald  */
570ef907034SMatthias Ringwald 
571ef907034SMatthias Ringwald  // PDU Types
572ef907034SMatthias Ringwald typedef enum {
573ef907034SMatthias Ringwald     SDP_Invalid = 0,
574ef907034SMatthias Ringwald     SDP_ErrorResponse = 1,
575ef907034SMatthias Ringwald     SDP_ServiceSearchRequest,
576ef907034SMatthias Ringwald     SDP_ServiceSearchResponse,
577ef907034SMatthias Ringwald     SDP_ServiceAttributeRequest,
578ef907034SMatthias Ringwald     SDP_ServiceAttributeResponse,
579ef907034SMatthias Ringwald     SDP_ServiceSearchAttributeRequest,
580ef907034SMatthias Ringwald     SDP_ServiceSearchAttributeResponse
581ef907034SMatthias Ringwald } SDP_PDU_ID_t;
582ef907034SMatthias Ringwald 
583ef907034SMatthias Ringwald // UNIVERSAL ATTRIBUTE DEFINITIONS
584ef907034SMatthias Ringwald #define SDP_ServiceRecordHandle     0x0000
585ef907034SMatthias Ringwald #define SDP_ServiceClassIDList      0x0001
586ef907034SMatthias Ringwald #define SDP_ServiceRecordState      0x0002
587ef907034SMatthias Ringwald #define SDP_ServiceID               0x0003
588ef907034SMatthias Ringwald #define SDP_ProtocolDescriptorList  0x0004
589ef907034SMatthias Ringwald #define SDP_BrowseGroupList         0x0005
590ef907034SMatthias Ringwald #define SDP_LanguageBaseAttributeIDList 0x0006
591ef907034SMatthias Ringwald #define SDP_ServiceInfoTimeToLive   0x0007
592ef907034SMatthias Ringwald #define SDP_ServiceAvailability     0x0008
593ef907034SMatthias Ringwald #define SDP_BluetoothProfileDescriptorList 0x0009
594ef907034SMatthias Ringwald #define SDP_DocumentationURL        0x000a
595ef907034SMatthias Ringwald #define SDP_ClientExecutableURL     0x000b
596ef907034SMatthias Ringwald #define SDP_IconURL                 0x000c
597ef907034SMatthias Ringwald #define SDP_AdditionalProtocolDescriptorList 0x000d
598ef907034SMatthias Ringwald #define SDP_SupportedFormatsList    0x0303
599ef907034SMatthias Ringwald 
600ef907034SMatthias Ringwald // SERVICE CLASSES
601ef907034SMatthias Ringwald #define SDP_OBEXObjectPush          0x1105
602ef907034SMatthias Ringwald #define SDP_OBEXFileTransfer        0x1106
603ef907034SMatthias Ringwald #define SDP_PublicBrowseGroup       0x1002
604ef907034SMatthias Ringwald #define SDP_HSP                     0x1108
605ef907034SMatthias Ringwald #define SDP_Headset_AG              0x1112
606ef907034SMatthias Ringwald #define SDP_PANU                    0x1115
607ef907034SMatthias Ringwald #define SDP_NAP                     0x1116
608ef907034SMatthias Ringwald #define SDP_GN                      0x1117
609ef907034SMatthias Ringwald #define SDP_Handsfree               0x111E
610ef907034SMatthias Ringwald #define SDP_HandsfreeAudioGateway   0x111F
611ef907034SMatthias Ringwald #define SDP_Headset_HS              0x1131
612ef907034SMatthias Ringwald #define SDP_GenericAudio            0x1203
613ef907034SMatthias Ringwald 
614ef907034SMatthias Ringwald 
615ef907034SMatthias Ringwald // PROTOCOLS
616ef907034SMatthias Ringwald #define SDP_SDPProtocol       0x0001
617ef907034SMatthias Ringwald #define SDP_UDPProtocol       0x0002
618ef907034SMatthias Ringwald #define SDP_RFCOMMProtocol    0x0003
619ef907034SMatthias Ringwald #define SDP_OBEXProtocol      0x0008
620ef907034SMatthias Ringwald #define SDP_L2CAPProtocol     0x0100
621ef907034SMatthias Ringwald #define SDP_BNEPProtocol      0x000F
622ef907034SMatthias Ringwald #define SDP_AVDTPProtocol     0x0019
623ef907034SMatthias Ringwald 
624ef907034SMatthias Ringwald // OFFSETS FOR LOCALIZED ATTRIBUTES - SDP_LanguageBaseAttributeIDList
625ef907034SMatthias Ringwald #define SDP_Offest_ServiceName      0x0000
626ef907034SMatthias Ringwald #define SDP_Offest_ServiceDescription 0x0001
627ef907034SMatthias Ringwald #define SDP_Offest_ProviderName     0x0002
628ef907034SMatthias Ringwald 
629ef907034SMatthias Ringwald // OBEX
630ef907034SMatthias Ringwald #define SDP_vCard_2_1       0x01
631ef907034SMatthias Ringwald #define SDP_vCard_3_0       0x02
632ef907034SMatthias Ringwald #define SDP_vCal_1_0        0x03
633ef907034SMatthias Ringwald #define SDP_iCal_2_0        0x04
634ef907034SMatthias Ringwald #define SDP_vNote           0x05
635ef907034SMatthias Ringwald #define SDP_vMessage        0x06
636ef907034SMatthias Ringwald #define SDP_OBEXFileTypeAny 0xFF
637ef907034SMatthias Ringwald 
638ef907034SMatthias Ringwald /**
639e2577bd7SMatthias Ringwald  * RFCOMM Protocol
640e2577bd7SMatthias Ringwald  */
641e2577bd7SMatthias Ringwald 
642e2577bd7SMatthias Ringwald // Control field values      bit no.       1 2 3 4 PF 6 7 8
643e2577bd7SMatthias Ringwald #define BT_RFCOMM_SABM       0x3F       // 1 1 1 1  1 1 0 0
644e2577bd7SMatthias Ringwald #define BT_RFCOMM_UA         0x73       // 1 1 0 0  1 1 1 0
645e2577bd7SMatthias Ringwald #define BT_RFCOMM_DM         0x0F       // 1 1 1 1  0 0 0 0
646e2577bd7SMatthias Ringwald #define BT_RFCOMM_DM_PF      0x1F       // 1 1 1 1  1 0 0 0
647e2577bd7SMatthias Ringwald #define BT_RFCOMM_DISC       0x53       // 1 1 0 0  1 0 1 0
648e2577bd7SMatthias Ringwald #define BT_RFCOMM_UIH        0xEF       // 1 1 1 1  0 1 1 1
649e2577bd7SMatthias Ringwald #define BT_RFCOMM_UIH_PF     0xFF       // 1 1 1 1  0 1 1 1
650e2577bd7SMatthias Ringwald 
651e2577bd7SMatthias Ringwald // Multiplexer message types
652e2577bd7SMatthias Ringwald #define BT_RFCOMM_CLD_CMD    0xC3
653e2577bd7SMatthias Ringwald #define BT_RFCOMM_FCON_CMD   0xA3
654e2577bd7SMatthias Ringwald #define BT_RFCOMM_FCON_RSP   0xA1
655e2577bd7SMatthias Ringwald #define BT_RFCOMM_FCOFF_CMD  0x63
656e2577bd7SMatthias Ringwald #define BT_RFCOMM_FCOFF_RSP  0x61
657e2577bd7SMatthias Ringwald #define BT_RFCOMM_MSC_CMD    0xE3
658e2577bd7SMatthias Ringwald #define BT_RFCOMM_MSC_RSP    0xE1
659e2577bd7SMatthias Ringwald #define BT_RFCOMM_NSC_RSP    0x11
660e2577bd7SMatthias Ringwald #define BT_RFCOMM_PN_CMD     0x83
661e2577bd7SMatthias Ringwald #define BT_RFCOMM_PN_RSP     0x81
662e2577bd7SMatthias Ringwald #define BT_RFCOMM_RLS_CMD    0x53
663e2577bd7SMatthias Ringwald #define BT_RFCOMM_RLS_RSP    0x51
664e2577bd7SMatthias Ringwald #define BT_RFCOMM_RPN_CMD    0x93
665e2577bd7SMatthias Ringwald #define BT_RFCOMM_RPN_RSP    0x91
666e2577bd7SMatthias Ringwald #define BT_RFCOMM_TEST_CMD   0x23
667e2577bd7SMatthias Ringwald #define BT_RFCOMM_TEST_RSP   0x21
668e2577bd7SMatthias Ringwald 
669e2577bd7SMatthias Ringwald // Line Status
670e2577bd7SMatthias Ringwald #define LINE_STATUS_NO_ERROR       0x00
671e2577bd7SMatthias Ringwald #define LINE_STATUS_OVERRUN_ERROR  0x03
672e2577bd7SMatthias Ringwald #define LINE_STATUS_PARITY_ERORR   0x05
673e2577bd7SMatthias Ringwald #define LINE_STATUS_FRAMING_ERROR  0x09
674e2577bd7SMatthias Ringwald 
675e2577bd7SMatthias Ringwald // Modem Status Flags
676e2577bd7SMatthias Ringwald #define MODEM_STATUS_FC   0x02
677e2577bd7SMatthias Ringwald #define MODEM_STATUS_RTC  0x04
678e2577bd7SMatthias Ringwald #define MODEM_STATUS_RTR  0x08
679e2577bd7SMatthias Ringwald #define MODEM_STATUS_IC   0x40
680e2577bd7SMatthias Ringwald #define MODEM_STATUS_DV   0x80
681e2577bd7SMatthias Ringwald 
682e2577bd7SMatthias Ringwald typedef enum rpn_baud {
683e2577bd7SMatthias Ringwald     RPN_BAUD_2400 = 0,
684e2577bd7SMatthias Ringwald     RPN_BAUD_4800,
685e2577bd7SMatthias Ringwald     RPN_BAUD_7200,
686e2577bd7SMatthias Ringwald     RPN_BAUD_9600,
687e2577bd7SMatthias Ringwald     RPN_BAUD_19200,
688e2577bd7SMatthias Ringwald     RPN_BAUD_38400,
689e2577bd7SMatthias Ringwald     RPN_BAUD_57600,
690e2577bd7SMatthias Ringwald     RPN_BAUD_115200,
691e2577bd7SMatthias Ringwald     RPN_BAUD_230400
692e2577bd7SMatthias Ringwald } rpn_baud_t;
693e2577bd7SMatthias Ringwald 
694e2577bd7SMatthias Ringwald typedef enum rpn_data_bits {
695e2577bd7SMatthias Ringwald     RPN_DATA_BITS_5 = 0,
696e2577bd7SMatthias Ringwald     RPN_DATA_BITS_6 = 0,
697e2577bd7SMatthias Ringwald     RPN_DATA_BITS_7 = 0,
698e2577bd7SMatthias Ringwald     RPN_DATA_BITS_8 = 0
699e2577bd7SMatthias Ringwald } rpn_data_bits_t;
700e2577bd7SMatthias Ringwald 
701e2577bd7SMatthias Ringwald typedef enum rpn_stop_bits {
702e2577bd7SMatthias Ringwald     RPN_STOP_BITS_1_0 = 0,
703e2577bd7SMatthias Ringwald     RPN_STOP_BITS_1_5
704e2577bd7SMatthias Ringwald } rpn_stop_bits_t;
705e2577bd7SMatthias Ringwald 
706e2577bd7SMatthias Ringwald typedef enum rpn_parity {
707e2577bd7SMatthias Ringwald     RPN_PARITY_NONE  = 0,
708e2577bd7SMatthias Ringwald     RPN_PARITY_ODD   = 1,
709e2577bd7SMatthias Ringwald     RPN_PARITY_EVEN  = 3,
710e2577bd7SMatthias Ringwald     RPN_PARITY_MARK  = 5,
711e2577bd7SMatthias Ringwald     RPN_PARITY_SPACE = 7,
712e2577bd7SMatthias Ringwald } rpn_parity_t;
713e2577bd7SMatthias Ringwald 
714e2577bd7SMatthias Ringwald typedef enum rpn_flow_control {
715e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_XONXOFF_ON_INPUT  = 1 << 0,
716e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_XONXOFF_ON_OUTPUT = 1 << 1,
717e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_RTR_ON_INPUT  = 1 << 2,
718e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_RTR_ON_OUTPUT = 1 << 3,
719e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_RTC_ON_INPUT  = 1 << 4,
720e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_RTC_ON_OUTPUT = 1 << 5,
721e2577bd7SMatthias Ringwald } rpn_flow_control_t;
722e2577bd7SMatthias Ringwald 
723e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_BAUD             0x01
724e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_DATA_BITS        0x02
725e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_STOP_BITS        0x04
726e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_PARITY           0x08
727e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_PARITY_TYPE      0x10
728e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_XON_CHAR         0x20
729e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_XOFF_CHAR        0x40
730e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_RESERVED         0x80
731e2577bd7SMatthias Ringwald 
732e2577bd7SMatthias Ringwald // @note: values are identical to rpn_flow_control_t
733e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_XONOFF_ON_INPUT  0x01
734e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_XONOFF_ON_OUTPUT 0x02
735e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RTR_ON_INPUT     0x04
736e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RTR_ON_OUTPUT    0x08
737e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RTC_ON_INPUT     0x10
738e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RTC_ON_OUTPUT    0x20
739e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RESERVED_0       0x40
740e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RESERVED_1       0x80
741e2577bd7SMatthias Ringwald 
742e2577bd7SMatthias Ringwald /**
74366b1fcb3SMatthias Ringwald  * BNEP Protocol
74466b1fcb3SMatthias Ringwald  */
74547f4e325SMatthias Ringwald 
74666b1fcb3SMatthias Ringwald #ifndef ETHER_ADDR_LEN
7479a73f75dSMatthias Ringwald #define ETHER_ADDR_LEN 6
74866b1fcb3SMatthias Ringwald #endif
74947f4e325SMatthias Ringwald 
75066b1fcb3SMatthias Ringwald #ifndef ETHERTYPE_VLAN
75166b1fcb3SMatthias Ringwald #define ETHERTYPE_VLAN                                  0x8100 /* IEEE 802.1Q VLAN tag */
75266b1fcb3SMatthias Ringwald #endif
75366b1fcb3SMatthias Ringwald 
75466b1fcb3SMatthias Ringwald #define BNEP_MTU_MIN                                    1691
75566b1fcb3SMatthias Ringwald 
75666b1fcb3SMatthias Ringwald #define BNEP_EXT_FLAG                                   0x80
75766b1fcb3SMatthias Ringwald #define BNEP_TYPE_MASK                                  0x7F
75866b1fcb3SMatthias Ringwald #define BNEP_TYPE(header)                               ((header) & BNEP_TYPE_MASK)
75966b1fcb3SMatthias Ringwald #define BNEP_HEADER_HAS_EXT(x)                          (((x) & BNEP_EXT_FLAG) == BNEP_EXT_FLAG)
76066b1fcb3SMatthias Ringwald 
76166b1fcb3SMatthias Ringwald /* BNEP packet types */
76266b1fcb3SMatthias Ringwald #define BNEP_PKT_TYPE_GENERAL_ETHERNET                  0x00
76366b1fcb3SMatthias Ringwald #define BNEP_PKT_TYPE_CONTROL                           0x01
76466b1fcb3SMatthias Ringwald #define BNEP_PKT_TYPE_COMPRESSED_ETHERNET               0x02
76566b1fcb3SMatthias Ringwald #define BNEP_PKT_TYPE_COMPRESSED_ETHERNET_SOURCE_ONLY   0x03
76666b1fcb3SMatthias Ringwald #define BNEP_PKT_TYPE_COMPRESSED_ETHERNET_DEST_ONLY     0x04
76766b1fcb3SMatthias Ringwald 
76866b1fcb3SMatthias Ringwald /* BNEP control types */
76966b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_COMMAND_NOT_UNDERSTOOD        0x00
77066b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_SETUP_CONNECTION_REQUEST      0x01
77166b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_SETUP_CONNECTION_RESPONSE     0x02
77266b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_FILTER_NET_TYPE_SET           0x03
77366b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_FILTER_NET_TYPE_RESPONSE      0x04
77466b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_FILTER_MULTI_ADDR_SET         0x05
77566b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_FILTER_MULTI_ADDR_RESPONSE    0x06
77666b1fcb3SMatthias Ringwald 
77766b1fcb3SMatthias Ringwald /* BNEP extension header types */
77866b1fcb3SMatthias Ringwald #define BNEP_EXT_HEADER_TYPE_EXTENSION_CONTROL          0x00
77966b1fcb3SMatthias Ringwald 
78066b1fcb3SMatthias Ringwald /* BNEP setup response codes */
78166b1fcb3SMatthias Ringwald #define BNEP_RESP_SETUP_SUCCESS                         0x0000
78266b1fcb3SMatthias Ringwald #define BNEP_RESP_SETUP_INVALID_DEST_UUID               0x0001
78366b1fcb3SMatthias Ringwald #define BNEP_RESP_SETUP_INVALID_SOURCE_UUID             0x0002
78466b1fcb3SMatthias Ringwald #define BNEP_RESP_SETUP_INVALID_SERVICE_UUID_SIZE       0x0003
78566b1fcb3SMatthias Ringwald #define BNEP_RESP_SETUP_CONNECTION_NOT_ALLOWED          0x0004
78666b1fcb3SMatthias Ringwald 
78766b1fcb3SMatthias Ringwald /* BNEP filter response codes */
78866b1fcb3SMatthias Ringwald #define BNEP_RESP_FILTER_SUCCESS                        0x0000
78966b1fcb3SMatthias Ringwald #define BNEP_RESP_FILTER_UNSUPPORTED_REQUEST            0x0001
79066b1fcb3SMatthias Ringwald #define BNEP_RESP_FILTER_ERR_INVALID_RANGE              0x0002
79166b1fcb3SMatthias Ringwald #define BNEP_RESP_FILTER_ERR_TOO_MANY_FILTERS           0x0003
79266b1fcb3SMatthias Ringwald #define BNEP_RESP_FILTER_ERR_SECURITY                   0x0004
79366b1fcb3SMatthias Ringwald 
79466b1fcb3SMatthias Ringwald /**
79566b1fcb3SMatthias Ringwald  * PAN Profile
79666b1fcb3SMatthias Ringwald  */
79766b1fcb3SMatthias Ringwald 
79866b1fcb3SMatthias Ringwald typedef enum {
79966b1fcb3SMatthias Ringwald     PANU_UUID = 0x1115,
80066b1fcb3SMatthias Ringwald     NAP_UUID = 0x1116,
80166b1fcb3SMatthias Ringwald     GN_UUID = 0x1117
80266b1fcb3SMatthias Ringwald } bnep_service_uuid_t;
80366b1fcb3SMatthias Ringwald 
80466b1fcb3SMatthias Ringwald typedef enum {
80566b1fcb3SMatthias Ringwald     BNEP_SECURITY_NONE = 0x0000,
80666b1fcb3SMatthias Ringwald     BNEP_SECURITY_SERVICE_LEVEL_ENFORCED,
80766b1fcb3SMatthias Ringwald     BNEP_SECURITY_802_1X
80866b1fcb3SMatthias Ringwald } security_description_t;
80966b1fcb3SMatthias Ringwald 
81066b1fcb3SMatthias Ringwald typedef enum {
81166b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_PSTN = 0x0000,
81266b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_ISDN,
81366b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_DSL,
81466b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_CABLE_MODEM,
81566b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_10MB_ETHERNET,
81666b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_100MB_ETHERNET,
81766b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_4MB_TOKEN_RING,
81866b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_16MB_TOKEN_RING,
81966b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_100MB_TOKEN_RING,
82066b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_FDDI,
82166b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_GSM,
82266b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_CDMA,
82366b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_GPRS,
82466b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_3G,
82566b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_CELULAR,
82666b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_OTHER = 0xFFFE,
82766b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_NONE
82866b1fcb3SMatthias Ringwald } net_access_type_t;
82947f4e325SMatthias Ringwald 
8304c1900e6SMatthias Ringwald /**
8314c1900e6SMatthias Ringwald  * ATT
8324c1900e6SMatthias Ringwald  */
8334c1900e6SMatthias Ringwald 
8344c1900e6SMatthias Ringwald // Minimum/default MTU
8354c1900e6SMatthias Ringwald #define ATT_DEFAULT_MTU               23
8364c1900e6SMatthias Ringwald 
8374c1900e6SMatthias Ringwald // MARK: Attribute PDU Opcodes
8384c1900e6SMatthias Ringwald #define ATT_ERROR_RESPONSE              0x01
8394c1900e6SMatthias Ringwald 
8404c1900e6SMatthias Ringwald #define ATT_EXCHANGE_MTU_REQUEST        0x02
8414c1900e6SMatthias Ringwald #define ATT_EXCHANGE_MTU_RESPONSE       0x03
8424c1900e6SMatthias Ringwald 
8434c1900e6SMatthias Ringwald #define ATT_FIND_INFORMATION_REQUEST    0x04
8444c1900e6SMatthias Ringwald #define ATT_FIND_INFORMATION_REPLY      0x05
8454c1900e6SMatthias Ringwald #define ATT_FIND_BY_TYPE_VALUE_REQUEST  0x06
8464c1900e6SMatthias Ringwald #define ATT_FIND_BY_TYPE_VALUE_RESPONSE 0x07
8474c1900e6SMatthias Ringwald 
8484c1900e6SMatthias Ringwald #define ATT_READ_BY_TYPE_REQUEST        0x08
8494c1900e6SMatthias Ringwald #define ATT_READ_BY_TYPE_RESPONSE       0x09
8504c1900e6SMatthias Ringwald #define ATT_READ_REQUEST                0x0a
8514c1900e6SMatthias Ringwald #define ATT_READ_RESPONSE               0x0b
8524c1900e6SMatthias Ringwald #define ATT_READ_BLOB_REQUEST           0x0c
8534c1900e6SMatthias Ringwald #define ATT_READ_BLOB_RESPONSE          0x0d
8544c1900e6SMatthias Ringwald #define ATT_READ_MULTIPLE_REQUEST       0x0e
8554c1900e6SMatthias Ringwald #define ATT_READ_MULTIPLE_RESPONSE      0x0f
8564c1900e6SMatthias Ringwald #define ATT_READ_BY_GROUP_TYPE_REQUEST  0x10
8574c1900e6SMatthias Ringwald #define ATT_READ_BY_GROUP_TYPE_RESPONSE 0x11
8584c1900e6SMatthias Ringwald 
8594c1900e6SMatthias Ringwald #define ATT_WRITE_REQUEST               0x12
8604c1900e6SMatthias Ringwald #define ATT_WRITE_RESPONSE              0x13
8614c1900e6SMatthias Ringwald 
8624c1900e6SMatthias Ringwald #define ATT_PREPARE_WRITE_REQUEST       0x16
8634c1900e6SMatthias Ringwald #define ATT_PREPARE_WRITE_RESPONSE      0x17
8644c1900e6SMatthias Ringwald #define ATT_EXECUTE_WRITE_REQUEST       0x18
8654c1900e6SMatthias Ringwald #define ATT_EXECUTE_WRITE_RESPONSE      0x19
8664c1900e6SMatthias Ringwald 
8674c1900e6SMatthias Ringwald #define ATT_HANDLE_VALUE_NOTIFICATION   0x1b
8684c1900e6SMatthias Ringwald #define ATT_HANDLE_VALUE_INDICATION     0x1d
8694c1900e6SMatthias Ringwald #define ATT_HANDLE_VALUE_CONFIRMATION   0x1e
8704c1900e6SMatthias Ringwald 
8714c1900e6SMatthias Ringwald 
8724c1900e6SMatthias Ringwald #define ATT_WRITE_COMMAND                0x52
8734c1900e6SMatthias Ringwald #define ATT_SIGNED_WRITE_COMMAND         0xD2
8744c1900e6SMatthias Ringwald 
8754c1900e6SMatthias Ringwald // MARK: ATT Error Codes
8764c1900e6SMatthias Ringwald #define ATT_ERROR_INVALID_HANDLE                   0x01
8774c1900e6SMatthias Ringwald #define ATT_ERROR_READ_NOT_PERMITTED               0x02
8784c1900e6SMatthias Ringwald #define ATT_ERROR_WRITE_NOT_PERMITTED              0x03
8794c1900e6SMatthias Ringwald #define ATT_ERROR_INVALID_PDU                      0x04
8804c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_AUTHENTICATION      0x05
8814c1900e6SMatthias Ringwald #define ATT_ERROR_REQUEST_NOT_SUPPORTED            0x06
8824c1900e6SMatthias Ringwald #define ATT_ERROR_INVALID_OFFSET                   0x07
8834c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_AUTHORIZATION       0x08
8844c1900e6SMatthias Ringwald #define ATT_ERROR_PREPARE_QUEUE_FULL               0x09
8854c1900e6SMatthias Ringwald #define ATT_ERROR_ATTRIBUTE_NOT_FOUND              0x0a
8864c1900e6SMatthias Ringwald #define ATT_ERROR_ATTRIBUTE_NOT_LONG               0x0b
8874c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_ENCRYPTION_KEY_SIZE 0x0c
8884c1900e6SMatthias Ringwald #define ATT_ERROR_INVALID_ATTRIBUTE_VALUE_LENGTH   0x0d
8894c1900e6SMatthias Ringwald #define ATT_ERROR_UNLIKELY_ERROR                   0x0e
8904c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_ENCRYPTION          0x0f
8914c1900e6SMatthias Ringwald #define ATT_ERROR_UNSUPPORTED_GROUP_TYPE           0x10
8924c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_RESOURCES           0x11
8934c1900e6SMatthias Ringwald 
8944c1900e6SMatthias Ringwald // MARK: Attribute Property Flags
8954c1900e6SMatthias Ringwald #define ATT_PROPERTY_BROADCAST           0x01
8964c1900e6SMatthias Ringwald #define ATT_PROPERTY_READ                0x02
8974c1900e6SMatthias Ringwald #define ATT_PROPERTY_WRITE_WITHOUT_RESPONSE 0x04
8984c1900e6SMatthias Ringwald #define ATT_PROPERTY_WRITE               0x08
8994c1900e6SMatthias Ringwald #define ATT_PROPERTY_NOTIFY              0x10
9004c1900e6SMatthias Ringwald #define ATT_PROPERTY_INDICATE            0x20
9014c1900e6SMatthias Ringwald #define ATT_PROPERTY_AUTHENTICATED_SIGNED_WRITE 0x40
9024c1900e6SMatthias Ringwald #define ATT_PROPERTY_EXTENDED_PROPERTIES 0x80
9034c1900e6SMatthias Ringwald 
9044c1900e6SMatthias Ringwald // MARK: Attribute Property Flag, BTstack extension
9054c1900e6SMatthias Ringwald // value is asked from client
9064c1900e6SMatthias Ringwald #define ATT_PROPERTY_DYNAMIC             0x100
9074c1900e6SMatthias Ringwald // 128 bit UUID used
9084c1900e6SMatthias Ringwald #define ATT_PROPERTY_UUID128             0x200
9094c1900e6SMatthias Ringwald // Authentication required
9104c1900e6SMatthias Ringwald #define ATT_PROPERTY_AUTHENTICATION_REQUIRED 0x400
9114c1900e6SMatthias Ringwald // Authorization from user required
9124c1900e6SMatthias Ringwald #define ATT_PROPERTY_AUTHORIZATION_REQUIRED  0x800
9134c1900e6SMatthias Ringwald // Encryption key size stored in upper 4 bits, 0 == no encryption, encryption key size - 1 otherwise
9144c1900e6SMatthias Ringwald 
9154c1900e6SMatthias Ringwald // ATT Transaction Timeout of 30 seconds for Command/Response or Incidationc/Confirmation
9164c1900e6SMatthias Ringwald #define ATT_TRANSACTION_TIMEOUT_MS     30000
9174c1900e6SMatthias Ringwald 
9184c1900e6SMatthias Ringwald #define ATT_TRANSACTION_MODE_NONE      0x0
9194c1900e6SMatthias Ringwald #define ATT_TRANSACTION_MODE_ACTIVE    0x1
9204c1900e6SMatthias Ringwald #define ATT_TRANSACTION_MODE_EXECUTE   0x2
9214c1900e6SMatthias Ringwald #define ATT_TRANSACTION_MODE_CANCEL    0x3
9224c1900e6SMatthias Ringwald 
9234c1900e6SMatthias Ringwald // MARK: GATT UUIDs
9244c1900e6SMatthias Ringwald #define GATT_PRIMARY_SERVICE_UUID                   0x2800
9254c1900e6SMatthias Ringwald #define GATT_SECONDARY_SERVICE_UUID                 0x2801
9264c1900e6SMatthias Ringwald #define GATT_INCLUDE_SERVICE_UUID                   0x2802
9274c1900e6SMatthias Ringwald #define GATT_CHARACTERISTICS_UUID                   0x2803
9284c1900e6SMatthias Ringwald #define GATT_CHARACTERISTIC_EXTENDED_PROPERTIES     0x2900
9294c1900e6SMatthias Ringwald #define GATT_CHARACTERISTIC_USER_DESCRIPTION        0x2901
9304c1900e6SMatthias Ringwald #define GATT_CLIENT_CHARACTERISTICS_CONFIGURATION   0x2902
9314c1900e6SMatthias Ringwald #define GATT_SERVER_CHARACTERISTICS_CONFIGURATION   0x2903
9324c1900e6SMatthias Ringwald #define GATT_CHARACTERISTIC_PRESENTATION_FORMAT     0x2904
9334c1900e6SMatthias Ringwald #define GATT_CHARACTERISTIC_AGGREGATE_FORMAT        0x2905
9344c1900e6SMatthias Ringwald 
9354c1900e6SMatthias Ringwald #define GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NONE          0
9364c1900e6SMatthias Ringwald #define GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NOTIFICATION  1
9374c1900e6SMatthias Ringwald #define GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_INDICATION    2
9384c1900e6SMatthias Ringwald 
9394c1900e6SMatthias Ringwald // GAP Service and Characteristics
9404c1900e6SMatthias Ringwald #define GAP_SERVICE_UUID               0x1800
9414c1900e6SMatthias Ringwald #define GAP_DEVICE_NAME_UUID           0x2a00
9424c1900e6SMatthias Ringwald #define GAP_APPEARANCE_UUID            0x2a01
9434c1900e6SMatthias Ringwald #define GAP_PERIPHERAL_PRIVACY_FLAG    0x2a02
9444c1900e6SMatthias Ringwald #define GAP_RECONNECTION_ADDRESS_UUID  0x2a03
9454c1900e6SMatthias Ringwald #define GAP_PERIPHERAL_PREFERRED_CONNECTION_PARAMETERS_UUID 0x2a04
94617fe8172SMatthias Ringwald #define GAP_SERVICE_CHANGED            0x2a05
9474c1900e6SMatthias Ringwald 
9484c1900e6SMatthias Ringwald /**
9494c1900e6SMatthias Ringwald  * SM - LE Security Manager
9504c1900e6SMatthias Ringwald  */
9514c1900e6SMatthias Ringwald // Bluetooth Spec definitions
9524c1900e6SMatthias Ringwald typedef enum {
9534c1900e6SMatthias Ringwald     SM_CODE_PAIRING_REQUEST = 0X01,
9544c1900e6SMatthias Ringwald     SM_CODE_PAIRING_RESPONSE,
9554c1900e6SMatthias Ringwald     SM_CODE_PAIRING_CONFIRM,
9564c1900e6SMatthias Ringwald     SM_CODE_PAIRING_RANDOM,
9574c1900e6SMatthias Ringwald     SM_CODE_PAIRING_FAILED,
9584c1900e6SMatthias Ringwald     SM_CODE_ENCRYPTION_INFORMATION,
9594c1900e6SMatthias Ringwald     SM_CODE_MASTER_IDENTIFICATION,
9604c1900e6SMatthias Ringwald     SM_CODE_IDENTITY_INFORMATION,
9614c1900e6SMatthias Ringwald     SM_CODE_IDENTITY_ADDRESS_INFORMATION,
9624c1900e6SMatthias Ringwald     SM_CODE_SIGNING_INFORMATION,
96374a9b3d5SMatthias Ringwald     SM_CODE_SECURITY_REQUEST,
96474a9b3d5SMatthias Ringwald     SM_CODE_PAIRING_PUBLIC_KEY,
96574a9b3d5SMatthias Ringwald     SM_CODE_PAIRING_DHKEY_CHECK,
96644e8d9acSMatthias Ringwald     SM_CODE_KEYPRESS_NOTIFICATION,
9674c1900e6SMatthias Ringwald } SECURITY_MANAGER_COMMANDS;
9684c1900e6SMatthias Ringwald 
9694c1900e6SMatthias Ringwald // IO Capability Values
9704c1900e6SMatthias Ringwald typedef enum {
9714c1900e6SMatthias Ringwald     IO_CAPABILITY_DISPLAY_ONLY = 0,
9724c1900e6SMatthias Ringwald     IO_CAPABILITY_DISPLAY_YES_NO,
9734c1900e6SMatthias Ringwald     IO_CAPABILITY_KEYBOARD_ONLY,
9744c1900e6SMatthias Ringwald     IO_CAPABILITY_NO_INPUT_NO_OUTPUT,
9754c1900e6SMatthias Ringwald     IO_CAPABILITY_KEYBOARD_DISPLAY, // not used by secure simple pairing
9764c1900e6SMatthias Ringwald } io_capability_t;
9774c1900e6SMatthias Ringwald 
9784c1900e6SMatthias Ringwald // Authentication requirement flags
9794c1900e6SMatthias Ringwald #define SM_AUTHREQ_NO_BONDING        0x00
9804c1900e6SMatthias Ringwald #define SM_AUTHREQ_BONDING           0x01
9814c1900e6SMatthias Ringwald #define SM_AUTHREQ_MITM_PROTECTION   0x04
98274a9b3d5SMatthias Ringwald #define SM_AUTHREQ_SECURE_CONNECTION 0x08
98374a9b3d5SMatthias Ringwald #define SM_AUTHREQ_KEYPRESS          0x10
9844c1900e6SMatthias Ringwald 
9854c1900e6SMatthias Ringwald // Key distribution flags used by spec
98652f9cf63SMatthias Ringwald #define SM_KEYDIST_ENC_KEY  0x01
9874c1900e6SMatthias Ringwald #define SM_KEYDIST_ID_KEY   0x02
9884c1900e6SMatthias Ringwald #define SM_KEYDIST_SIGN     0x04
98952f9cf63SMatthias Ringwald #define SM_KEYDIST_LINK_KEY 0x08
9904c1900e6SMatthias Ringwald 
9914c1900e6SMatthias Ringwald // Key distribution flags used internally
9924c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_ENCRYPTION_INFORMATION       0x01
9934c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_MASTER_IDENTIFICATION        0x02
9944c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_IDENTITY_INFORMATION         0x04
9954c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_IDENTITY_ADDRESS_INFORMATION 0x08
9964c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_SIGNING_IDENTIFICATION       0x10
9974c1900e6SMatthias Ringwald 
9984c1900e6SMatthias Ringwald // STK Generation Methods
9994c1900e6SMatthias Ringwald #define SM_STK_GENERATION_METHOD_JUST_WORKS          0x01
10004c1900e6SMatthias Ringwald #define SM_STK_GENERATION_METHOD_OOB                 0x02
10014c1900e6SMatthias Ringwald #define SM_STK_GENERATION_METHOD_PASSKEY             0x04
1002b4343428SMatthias Ringwald #define SM_STK_GENERATION_METHOD_NUMERIC_COMPARISON  0x08
10034c1900e6SMatthias Ringwald 
10044c1900e6SMatthias Ringwald // Pairing Failed Reasons
10054c1900e6SMatthias Ringwald #define SM_REASON_RESERVED                     0x00
10064c1900e6SMatthias Ringwald #define SM_REASON_PASSKEYT_ENTRY_FAILED        0x01
10074c1900e6SMatthias Ringwald #define SM_REASON_OOB_NOT_AVAILABLE            0x02
10084c1900e6SMatthias Ringwald #define SM_REASON_AUTHENTHICATION_REQUIREMENTS 0x03
10094c1900e6SMatthias Ringwald #define SM_REASON_CONFIRM_VALUE_FAILED         0x04
10104c1900e6SMatthias Ringwald #define SM_REASON_PAIRING_NOT_SUPPORTED        0x05
10114c1900e6SMatthias Ringwald #define SM_REASON_ENCRYPTION_KEY_SIZE          0x06
10124c1900e6SMatthias Ringwald #define SM_REASON_COMMAND_NOT_SUPPORTED        0x07
10134c1900e6SMatthias Ringwald #define SM_REASON_UNSPECIFIED_REASON           0x08
10144c1900e6SMatthias Ringwald #define SM_REASON_REPEATED_ATTEMPTS            0x09
1015a9f29768SMatthias Ringwald #define SM_REASON_INVALID_PARAMETERS           0x0a
1016a9f29768SMatthias Ringwald #define SM_REASON_DHKEY_CHECK_FAILED           0x0b
1017a9f29768SMatthias Ringwald #define SM_REASON_NUMERIC_COMPARISON_FAILED    0x0c
1018a9f29768SMatthias Ringwald 
10194c1900e6SMatthias Ringwald // also, invalid parameters
10204c1900e6SMatthias Ringwald // and reserved
10214c1900e6SMatthias Ringwald 
102244e8d9acSMatthias Ringwald // Keypress Notifications
102344e8d9acSMatthias Ringwald #define SM_KEYPRESS_PASSKEY_ENTRY_STARTED      0x00
102444e8d9acSMatthias Ringwald #define SM_KEYPRESS_PASSKEY_DIGIT_ENTERED      0x01
102544e8d9acSMatthias Ringwald #define SM_KEYPRESS_PASSKEY_DIGIT_ERASED       0x02
102644e8d9acSMatthias Ringwald #define SM_KEYPRESS_PASSKEY_CLEARED            0x03
102744e8d9acSMatthias Ringwald #define SM_KEYPRESS_PASSKEY_ENTRY_COMPLETED    0x04
102844e8d9acSMatthias Ringwald 
102944e8d9acSMatthias Ringwald 
1030c6d1dbedSMatthias Ringwald // Company identifiers / manufacturers
1031c6d1dbedSMatthias Ringwald #define COMPANY_ID_CAMBRIDGE_SILICON_RADIO     0x000A
1032c6d1dbedSMatthias Ringwald #define COMPANY_ID_TEXAS_INSTRUMENTS_INC       0x000D
1033c6d1dbedSMatthias Ringwald #define COMPANY_ID_BROADCOM_CORPORATION        0x000F
1034c6d1dbedSMatthias Ringwald #define COMPANY_ID_ST_MICROELECTRONICS         0x0030
1035c6d1dbedSMatthias Ringwald #define COMPANY_ID_EM_MICROELECTRONICS_MARIN   0x005A
1036c6d1dbedSMatthias Ringwald 
10374c1900e6SMatthias Ringwald 
103847f4e325SMatthias Ringwald #endif