xref: /btstack/src/bluetooth.h (revision ad71fb174251b39286e4e47aa7f379dd9ee510b6)
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 /**
99f6858d14SMatthias Ringwald  * @brief Inquiry modes
100f6858d14SMatthias Ringwald  */
101f6858d14SMatthias Ringwald typedef enum {
102f6858d14SMatthias Ringwald   INQUIRY_MODE_STANDARD = 0,
103f6858d14SMatthias Ringwald   INQUIRY_MODE_RSSI,
104f6858d14SMatthias Ringwald   INQUIRY_MODE_RSSI_AND_EIR,
105f6858d14SMatthias Ringwald } inquiry_mode_t;
106f6858d14SMatthias Ringwald 
107f6858d14SMatthias 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 
28047f4e325SMatthias Ringwald /**
28147f4e325SMatthias Ringwald  * @format 1B11132
28247f4e325SMatthias Ringwald  * @param num_responses
28347f4e325SMatthias Ringwald  * @param bd_addr
28447f4e325SMatthias Ringwald  * @param page_scan_repetition_mode
28547f4e325SMatthias Ringwald  * @param reserved1
28647f4e325SMatthias Ringwald  * @param reserved2
28747f4e325SMatthias Ringwald  * @param class_of_device
28847f4e325SMatthias Ringwald  * @param clock_offset
28947f4e325SMatthias Ringwald  */
29047f4e325SMatthias Ringwald #define HCI_EVENT_INQUIRY_RESULT                           0x02
29147f4e325SMatthias Ringwald 
29247f4e325SMatthias Ringwald /**
29347f4e325SMatthias Ringwald  * @format 12B11
29447f4e325SMatthias Ringwald  * @param status
29547f4e325SMatthias Ringwald  * @param connection_handle
29647f4e325SMatthias Ringwald  * @param bd_addr
29747f4e325SMatthias Ringwald  * @param link_type
29847f4e325SMatthias Ringwald  * @param encryption_enabled
29947f4e325SMatthias Ringwald  */
30047f4e325SMatthias Ringwald #define HCI_EVENT_CONNECTION_COMPLETE                      0x03
30147f4e325SMatthias Ringwald /**
30247f4e325SMatthias Ringwald  * @format B31
30347f4e325SMatthias Ringwald  * @param bd_addr
30447f4e325SMatthias Ringwald  * @param class_of_device
30547f4e325SMatthias Ringwald  * @param link_type
30647f4e325SMatthias Ringwald  */
30747f4e325SMatthias Ringwald #define HCI_EVENT_CONNECTION_REQUEST                       0x04
30847f4e325SMatthias Ringwald /**
30947f4e325SMatthias Ringwald  * @format 121
31047f4e325SMatthias Ringwald  * @param status
31147f4e325SMatthias Ringwald  * @param connection_handle
31247f4e325SMatthias Ringwald  * @param reason
31347f4e325SMatthias Ringwald  */
31447f4e325SMatthias Ringwald #define HCI_EVENT_DISCONNECTION_COMPLETE                   0x05
31547f4e325SMatthias Ringwald /**
31647f4e325SMatthias Ringwald  * @format 12
31747f4e325SMatthias Ringwald  * @param status
31847f4e325SMatthias Ringwald  * @param connection_handle
31947f4e325SMatthias Ringwald  */
32047f4e325SMatthias Ringwald #define HCI_EVENT_AUTHENTICATION_COMPLETE_EVENT            0x06
32147f4e325SMatthias Ringwald /**
32247f4e325SMatthias Ringwald  * @format 1BN
32347f4e325SMatthias Ringwald  * @param status
32447f4e325SMatthias Ringwald  * @param bd_addr
32547f4e325SMatthias Ringwald  * @param remote_name
32647f4e325SMatthias Ringwald  */
32747f4e325SMatthias Ringwald #define HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE             0x07
32847f4e325SMatthias Ringwald /**
32947f4e325SMatthias Ringwald  * @format 121
33047f4e325SMatthias Ringwald  * @param status
33147f4e325SMatthias Ringwald  * @param connection_handle
33247f4e325SMatthias Ringwald  * @param encryption_enabled
33347f4e325SMatthias Ringwald  */
33447f4e325SMatthias Ringwald #define HCI_EVENT_ENCRYPTION_CHANGE                        0x08
33547f4e325SMatthias Ringwald /**
33647f4e325SMatthias Ringwald  * @format 12
33747f4e325SMatthias Ringwald  * @param status
33847f4e325SMatthias Ringwald  * @param connection_handle
33947f4e325SMatthias Ringwald  */
34047f4e325SMatthias Ringwald #define HCI_EVENT_CHANGE_CONNECTION_LINK_KEY_COMPLETE      0x09
34147f4e325SMatthias Ringwald /**
34247f4e325SMatthias Ringwald  * @format 121
34347f4e325SMatthias Ringwald  * @param status
34447f4e325SMatthias Ringwald  * @param connection_handle
34547f4e325SMatthias Ringwald  * @param key_flag
34647f4e325SMatthias Ringwald  */
34747f4e325SMatthias Ringwald #define HCI_EVENT_MASTER_LINK_KEY_COMPLETE                 0x0A
348*ad71fb17SMatthias Ringwald 
34947f4e325SMatthias Ringwald #define HCI_EVENT_READ_REMOTE_SUPPORTED_FEATURES_COMPLETE  0x0B
350*ad71fb17SMatthias Ringwald 
35147f4e325SMatthias Ringwald #define HCI_EVENT_READ_REMOTE_VERSION_INFORMATION_COMPLETE 0x0C
352*ad71fb17SMatthias Ringwald 
35347f4e325SMatthias Ringwald #define HCI_EVENT_QOS_SETUP_COMPLETE                       0x0D
35447f4e325SMatthias Ringwald 
35547f4e325SMatthias Ringwald /**
35647f4e325SMatthias Ringwald  * @format 12R
35747f4e325SMatthias Ringwald  * @param num_hci_command_packets
35847f4e325SMatthias Ringwald  * @param command_opcode
35947f4e325SMatthias Ringwald  * @param return_parameters
36047f4e325SMatthias Ringwald  */
36147f4e325SMatthias Ringwald #define HCI_EVENT_COMMAND_COMPLETE                         0x0E
36247f4e325SMatthias Ringwald /**
36347f4e325SMatthias Ringwald  * @format 112
36447f4e325SMatthias Ringwald  * @param status
36547f4e325SMatthias Ringwald  * @param num_hci_command_packets
36647f4e325SMatthias Ringwald  * @param command_opcode
36747f4e325SMatthias Ringwald  */
36847f4e325SMatthias Ringwald #define HCI_EVENT_COMMAND_STATUS                           0x0F
36947f4e325SMatthias Ringwald 
37047f4e325SMatthias Ringwald /**
37147f4e325SMatthias Ringwald  * @format 121
37247f4e325SMatthias Ringwald  * @param hardware_code
37347f4e325SMatthias Ringwald  */
37447f4e325SMatthias Ringwald #define HCI_EVENT_HARDWARE_ERROR                           0x10
37547f4e325SMatthias Ringwald 
376*ad71fb17SMatthias Ringwald #define HCI_EVENT_FLUSH_OCCURRED                           0x11
37747f4e325SMatthias Ringwald 
37847f4e325SMatthias Ringwald /**
37947f4e325SMatthias Ringwald  * @format 1B1
38047f4e325SMatthias Ringwald  * @param status
38147f4e325SMatthias Ringwald  * @param bd_addr
38247f4e325SMatthias Ringwald  * @param role
38347f4e325SMatthias Ringwald  */
38447f4e325SMatthias Ringwald #define HCI_EVENT_ROLE_CHANGE                              0x12
38547f4e325SMatthias Ringwald 
38610093bf5SMilanka Ringwald // TODO: number_of_handles 1, connection_handle[H*i], hc_num_of_completed_packets[2*i]
38747f4e325SMatthias Ringwald #define HCI_EVENT_NUMBER_OF_COMPLETED_PACKETS              0x13
38810093bf5SMilanka Ringwald 
38910093bf5SMilanka Ringwald /**
39010093bf5SMilanka Ringwald  * @format 1H12
39110093bf5SMilanka Ringwald  * @param status
39210093bf5SMilanka Ringwald  * @param handle
39310093bf5SMilanka Ringwald  * @param mode
39410093bf5SMilanka Ringwald  * @param interval
39510093bf5SMilanka Ringwald  */
39647f4e325SMatthias Ringwald #define HCI_EVENT_MODE_CHANGE_EVENT                        0x14
39710093bf5SMilanka Ringwald 
39810093bf5SMilanka Ringwald // TODO: num_keys, bd_addr[B*i], link_key[16 octets * i]
39947f4e325SMatthias Ringwald #define HCI_EVENT_RETURN_LINK_KEYS                         0x15
40010093bf5SMilanka Ringwald 
40110093bf5SMilanka Ringwald /**
40210093bf5SMilanka Ringwald  * @format B
40310093bf5SMilanka Ringwald  * @param bd_addr
40410093bf5SMilanka Ringwald  */
40547f4e325SMatthias Ringwald #define HCI_EVENT_PIN_CODE_REQUEST                         0x16
40610093bf5SMilanka Ringwald 
40710093bf5SMilanka Ringwald /**
40810093bf5SMilanka Ringwald  * @format B
40910093bf5SMilanka Ringwald  * @param bd_addr
41010093bf5SMilanka Ringwald  */
41147f4e325SMatthias Ringwald #define HCI_EVENT_LINK_KEY_REQUEST                         0x17
41210093bf5SMilanka Ringwald 
41310093bf5SMilanka Ringwald // TODO: bd_addr B, link_key 16octets, key_type 1
41447f4e325SMatthias Ringwald #define HCI_EVENT_LINK_KEY_NOTIFICATION                    0x18
41510093bf5SMilanka Ringwald 
41610093bf5SMilanka Ringwald /**
41710093bf5SMilanka Ringwald  * @format 1
41810093bf5SMilanka Ringwald  * @param link_type
41910093bf5SMilanka Ringwald  */
42047f4e325SMatthias Ringwald #define HCI_EVENT_DATA_BUFFER_OVERFLOW                     0x1A
42110093bf5SMilanka Ringwald 
42210093bf5SMilanka Ringwald /**
42310093bf5SMilanka Ringwald  * @format H1
42410093bf5SMilanka Ringwald  * @param handle
42510093bf5SMilanka Ringwald  * @param lmp_max_slots
42610093bf5SMilanka Ringwald  */
42747f4e325SMatthias Ringwald #define HCI_EVENT_MAX_SLOTS_CHANGED                        0x1B
42810093bf5SMilanka Ringwald 
42910093bf5SMilanka Ringwald /**
43010093bf5SMilanka Ringwald  * @format 1H2
43110093bf5SMilanka Ringwald  * @param status
43210093bf5SMilanka Ringwald  * @param handle
43310093bf5SMilanka Ringwald  * @param clock_offset
43410093bf5SMilanka Ringwald  */
43547f4e325SMatthias Ringwald #define HCI_EVENT_READ_CLOCK_OFFSET_COMPLETE               0x1C
43610093bf5SMilanka Ringwald 
43710093bf5SMilanka Ringwald /**
43810093bf5SMilanka Ringwald  * @format 1H2
43910093bf5SMilanka Ringwald  * @param status
44010093bf5SMilanka Ringwald  * @param handle
441fea5a680SMatthias Ringwald  * @param packet_types
442fea5a680SMatthias Ringwald  * @pnote packet_type is in plural to avoid clash with Java binding Packet.getPacketType()
44310093bf5SMilanka Ringwald  */
444fea5a680SMatthias Ringwald #define HCI_EVENT_CONNECTION_PACKET_TYPE_CHANGED           0x1D
44547f4e325SMatthias Ringwald 
44647f4e325SMatthias Ringwald /**
44747f4e325SMatthias Ringwald  * @format 1B11321
44847f4e325SMatthias Ringwald  * @param num_responses
44947f4e325SMatthias Ringwald  * @param bd_addr
45047f4e325SMatthias Ringwald  * @param page_scan_repetition_mode
45147f4e325SMatthias Ringwald  * @param reserved
45247f4e325SMatthias Ringwald  * @param class_of_device
45347f4e325SMatthias Ringwald  * @param clock_offset
45447f4e325SMatthias Ringwald  * @param rssi
45547f4e325SMatthias Ringwald  */
45647f4e325SMatthias Ringwald #define HCI_EVENT_INQUIRY_RESULT_WITH_RSSI                 0x22
45747f4e325SMatthias Ringwald 
45847f4e325SMatthias Ringwald /**
45947f4e325SMatthias Ringwald  * @format 1HB111221
46047f4e325SMatthias Ringwald  * @param status
46147f4e325SMatthias Ringwald  * @param handle
46247f4e325SMatthias Ringwald  * @param bd_addr
46347f4e325SMatthias Ringwald  * @param link_type
46447f4e325SMatthias Ringwald  * @param transmission_interval
46547f4e325SMatthias Ringwald  * @param retransmission_interval
46647f4e325SMatthias Ringwald  * @param rx_packet_length
46747f4e325SMatthias Ringwald  * @param tx_packet_length
46847f4e325SMatthias Ringwald  * @param air_mode
46947f4e325SMatthias Ringwald  */
47047f4e325SMatthias Ringwald #define HCI_EVENT_SYNCHRONOUS_CONNECTION_COMPLETE          0x2C
47147f4e325SMatthias Ringwald 
47247f4e325SMatthias Ringwald // TODO: serialize extended_inquiry_response and provide parser
47347f4e325SMatthias Ringwald /**
47447f4e325SMatthias Ringwald  * @format 1B11321
47547f4e325SMatthias Ringwald  * @param num_responses
47647f4e325SMatthias Ringwald  * @param bd_addr
47747f4e325SMatthias Ringwald  * @param page_scan_repetition_mode
47847f4e325SMatthias Ringwald  * @param reserved
47947f4e325SMatthias Ringwald  * @param class_of_device
48047f4e325SMatthias Ringwald  * @param clock_offset
48147f4e325SMatthias Ringwald  * @param rssi
48247f4e325SMatthias Ringwald  */
48347f4e325SMatthias Ringwald #define HCI_EVENT_EXTENDED_INQUIRY_RESPONSE                0x2F
48447f4e325SMatthias Ringwald 
48547f4e325SMatthias Ringwald  /**
48647f4e325SMatthias Ringwald   * @format 1H
48747f4e325SMatthias Ringwald   * @param status
48847f4e325SMatthias Ringwald   * @param handle
48947f4e325SMatthias Ringwald   */
49047f4e325SMatthias Ringwald #define HCI_EVENT_ENCRYPTION_KEY_REFRESH_COMPLETE          0x30
49147f4e325SMatthias Ringwald 
49247f4e325SMatthias Ringwald #define HCI_EVENT_IO_CAPABILITY_REQUEST                    0x31
49347f4e325SMatthias Ringwald #define HCI_EVENT_IO_CAPABILITY_RESPONSE                   0x32
494*ad71fb17SMatthias Ringwald 
495*ad71fb17SMatthias Ringwald /**
496*ad71fb17SMatthias Ringwald  * @format B4
497*ad71fb17SMatthias Ringwald  * @param bd_addr
498*ad71fb17SMatthias Ringwald  * @param numeric_value
499*ad71fb17SMatthias Ringwald  */
50047f4e325SMatthias Ringwald #define HCI_EVENT_USER_CONFIRMATION_REQUEST                0x33
501*ad71fb17SMatthias Ringwald 
502*ad71fb17SMatthias Ringwald /**
503*ad71fb17SMatthias Ringwald  * @format B
504*ad71fb17SMatthias Ringwald  * @param bd_addr
505*ad71fb17SMatthias Ringwald  */
50647f4e325SMatthias Ringwald #define HCI_EVENT_USER_PASSKEY_REQUEST                     0x34
507*ad71fb17SMatthias Ringwald 
508*ad71fb17SMatthias Ringwald /**
509*ad71fb17SMatthias Ringwald  * @format B
510*ad71fb17SMatthias Ringwald  * @param bd_addr
511*ad71fb17SMatthias Ringwald  */
51247f4e325SMatthias Ringwald #define HCI_EVENT_REMOTE_OOB_DATA_REQUEST                  0x35
513*ad71fb17SMatthias Ringwald 
514*ad71fb17SMatthias Ringwald /**
515*ad71fb17SMatthias Ringwald  * @format 1B
516*ad71fb17SMatthias Ringwald  * @param status
517*ad71fb17SMatthias Ringwald  * @param bd_addr
518*ad71fb17SMatthias Ringwald  */
51947f4e325SMatthias Ringwald #define HCI_EVENT_SIMPLE_PAIRING_COMPLETE                  0x36
52047f4e325SMatthias Ringwald 
52147f4e325SMatthias Ringwald #define HCI_EVENT_LE_META                                  0x3E
52247f4e325SMatthias Ringwald 
523941b3855SMatthias Ringwald #define HCI_EVENT_VENDOR_SPECIFIC                          0xFF
524941b3855SMatthias Ringwald 
52547f4e325SMatthias Ringwald /**
526ca0d73deSMatthias Ringwald  * @format 11H11B2221
52747f4e325SMatthias Ringwald  * @param subevent_code
52847f4e325SMatthias Ringwald  * @param status
52947f4e325SMatthias Ringwald  * @param connection_handle
53047f4e325SMatthias Ringwald  * @param role
53147f4e325SMatthias Ringwald  * @param peer_address_type
53247f4e325SMatthias Ringwald  * @param peer_address
53347f4e325SMatthias Ringwald  * @param conn_interval
53447f4e325SMatthias Ringwald  * @param conn_latency
53547f4e325SMatthias Ringwald  * @param supervision_timeout
53647f4e325SMatthias Ringwald  * @param master_clock_accuracy
53747f4e325SMatthias Ringwald  */
53847f4e325SMatthias Ringwald #define HCI_SUBEVENT_LE_CONNECTION_COMPLETE                0x01
53947f4e325SMatthias Ringwald #define HCI_SUBEVENT_LE_ADVERTISING_REPORT                 0x02
54047f4e325SMatthias Ringwald #define HCI_SUBEVENT_LE_CONNECTION_UPDATE_COMPLETE         0x03
54147f4e325SMatthias Ringwald #define HCI_SUBEVENT_LE_READ_REMOTE_USED_FEATURES_COMPLETE 0x04
54247f4e325SMatthias Ringwald #define HCI_SUBEVENT_LE_LONG_TERM_KEY_REQUEST              0x05
54347f4e325SMatthias Ringwald 
54447f4e325SMatthias Ringwald // last used HCI_EVENT in 2.1 is 0x3d
54547f4e325SMatthias Ringwald // last used HCI_EVENT in 4.1 is 0x57
54647f4e325SMatthias Ringwald 
54747f4e325SMatthias Ringwald /**
54847f4e325SMatthias Ringwald  * L2CAP Layer
54947f4e325SMatthias Ringwald  */
55047f4e325SMatthias Ringwald 
551a8373a41SMatthias Ringwald #define L2CAP_HEADER_SIZE 4
552a8373a41SMatthias Ringwald 
553a8373a41SMatthias Ringwald #define L2CAP_SIG_ID_INVALID 0
554a8373a41SMatthias Ringwald 
555a8373a41SMatthias Ringwald // size of HCI ACL + L2CAP Header for regular data packets (8)
556a8373a41SMatthias Ringwald #define COMPLETE_L2CAP_HEADER (HCI_ACL_HEADER_SIZE + L2CAP_HEADER_SIZE)
557a8373a41SMatthias Ringwald 
558a8373a41SMatthias Ringwald // minimum signaling MTU
559a8373a41SMatthias Ringwald #define L2CAP_MINIMAL_MTU 48
560a8373a41SMatthias Ringwald #define L2CAP_DEFAULT_MTU 672
561a8373a41SMatthias Ringwald 
562a8373a41SMatthias Ringwald // Minimum/default MTU
563a8373a41SMatthias Ringwald #define L2CAP_LE_DEFAULT_MTU  23
564a8373a41SMatthias Ringwald 
565a8373a41SMatthias Ringwald // L2CAP Fixed Channel IDs
566a8373a41SMatthias Ringwald #define L2CAP_CID_SIGNALING                 0x0001
567a8373a41SMatthias Ringwald #define L2CAP_CID_CONNECTIONLESS_CHANNEL    0x0002
568a8373a41SMatthias Ringwald #define L2CAP_CID_ATTRIBUTE_PROTOCOL        0x0004
569a8373a41SMatthias Ringwald #define L2CAP_CID_SIGNALING_LE              0x0005
570a8373a41SMatthias Ringwald #define L2CAP_CID_SECURITY_MANAGER_PROTOCOL 0x0006
571a8373a41SMatthias Ringwald 
572a8373a41SMatthias Ringwald // L2CAP Configuration Result Codes
573a8373a41SMatthias Ringwald #define L2CAP_CONF_RESULT_UNKNOWN_OPTIONS   0x0003
574a8373a41SMatthias Ringwald 
575a8373a41SMatthias Ringwald // L2CAP Reject Result Codes
576a8373a41SMatthias Ringwald #define L2CAP_REJ_CMD_UNKNOWN               0x0000
577a8373a41SMatthias Ringwald 
578a8373a41SMatthias Ringwald // Response Timeout eXpired
579a8373a41SMatthias Ringwald #define L2CAP_RTX_TIMEOUT_MS   10000
580a8373a41SMatthias Ringwald 
581a8373a41SMatthias Ringwald // Extended Response Timeout eXpired
582a8373a41SMatthias Ringwald #define L2CAP_ERTX_TIMEOUT_MS 120000
583a8373a41SMatthias Ringwald 
58447f4e325SMatthias Ringwald // Fixed PSM numbers
58547f4e325SMatthias Ringwald #define PSM_SDP           0x01
58647f4e325SMatthias Ringwald #define PSM_RFCOMM        0x03
58747f4e325SMatthias Ringwald #define PSM_BNEP          0x0F
58847f4e325SMatthias Ringwald #define PSM_HID_CONTROL   0x11
58947f4e325SMatthias Ringwald #define PSM_HID_INTERRUPT 0x13
59047f4e325SMatthias Ringwald 
59166b1fcb3SMatthias Ringwald /**
592ef907034SMatthias Ringwald  * SDP Protocl
593ef907034SMatthias Ringwald  */
594ef907034SMatthias Ringwald 
595ef907034SMatthias Ringwald  // PDU Types
596ef907034SMatthias Ringwald typedef enum {
597ef907034SMatthias Ringwald     SDP_Invalid = 0,
598ef907034SMatthias Ringwald     SDP_ErrorResponse = 1,
599ef907034SMatthias Ringwald     SDP_ServiceSearchRequest,
600ef907034SMatthias Ringwald     SDP_ServiceSearchResponse,
601ef907034SMatthias Ringwald     SDP_ServiceAttributeRequest,
602ef907034SMatthias Ringwald     SDP_ServiceAttributeResponse,
603ef907034SMatthias Ringwald     SDP_ServiceSearchAttributeRequest,
604ef907034SMatthias Ringwald     SDP_ServiceSearchAttributeResponse
605ef907034SMatthias Ringwald } SDP_PDU_ID_t;
606ef907034SMatthias Ringwald 
607ef907034SMatthias Ringwald // UNIVERSAL ATTRIBUTE DEFINITIONS
608ef907034SMatthias Ringwald #define SDP_ServiceRecordHandle     0x0000
609ef907034SMatthias Ringwald #define SDP_ServiceClassIDList      0x0001
610ef907034SMatthias Ringwald #define SDP_ServiceRecordState      0x0002
611ef907034SMatthias Ringwald #define SDP_ServiceID               0x0003
612ef907034SMatthias Ringwald #define SDP_ProtocolDescriptorList  0x0004
613ef907034SMatthias Ringwald #define SDP_BrowseGroupList         0x0005
614ef907034SMatthias Ringwald #define SDP_LanguageBaseAttributeIDList 0x0006
615ef907034SMatthias Ringwald #define SDP_ServiceInfoTimeToLive   0x0007
616ef907034SMatthias Ringwald #define SDP_ServiceAvailability     0x0008
617ef907034SMatthias Ringwald #define SDP_BluetoothProfileDescriptorList 0x0009
618ef907034SMatthias Ringwald #define SDP_DocumentationURL        0x000a
619ef907034SMatthias Ringwald #define SDP_ClientExecutableURL     0x000b
620ef907034SMatthias Ringwald #define SDP_IconURL                 0x000c
621ef907034SMatthias Ringwald #define SDP_AdditionalProtocolDescriptorList 0x000d
622ef907034SMatthias Ringwald #define SDP_SupportedFormatsList    0x0303
623ef907034SMatthias Ringwald 
624ef907034SMatthias Ringwald // SERVICE CLASSES
625ef907034SMatthias Ringwald #define SDP_OBEXObjectPush          0x1105
626ef907034SMatthias Ringwald #define SDP_OBEXFileTransfer        0x1106
627ef907034SMatthias Ringwald #define SDP_PublicBrowseGroup       0x1002
628ef907034SMatthias Ringwald #define SDP_HSP                     0x1108
629ef907034SMatthias Ringwald #define SDP_Headset_AG              0x1112
630ef907034SMatthias Ringwald #define SDP_PANU                    0x1115
631ef907034SMatthias Ringwald #define SDP_NAP                     0x1116
632ef907034SMatthias Ringwald #define SDP_GN                      0x1117
633ef907034SMatthias Ringwald #define SDP_Handsfree               0x111E
634ef907034SMatthias Ringwald #define SDP_HandsfreeAudioGateway   0x111F
635ef907034SMatthias Ringwald #define SDP_Headset_HS              0x1131
636ef907034SMatthias Ringwald #define SDP_GenericAudio            0x1203
637ef907034SMatthias Ringwald 
638ef907034SMatthias Ringwald 
639ef907034SMatthias Ringwald // PROTOCOLS
640ef907034SMatthias Ringwald #define SDP_SDPProtocol       0x0001
641ef907034SMatthias Ringwald #define SDP_UDPProtocol       0x0002
642ef907034SMatthias Ringwald #define SDP_RFCOMMProtocol    0x0003
643ef907034SMatthias Ringwald #define SDP_OBEXProtocol      0x0008
644ef907034SMatthias Ringwald #define SDP_L2CAPProtocol     0x0100
645ef907034SMatthias Ringwald #define SDP_BNEPProtocol      0x000F
646ef907034SMatthias Ringwald #define SDP_AVDTPProtocol     0x0019
647ef907034SMatthias Ringwald 
648ef907034SMatthias Ringwald // OFFSETS FOR LOCALIZED ATTRIBUTES - SDP_LanguageBaseAttributeIDList
649ef907034SMatthias Ringwald #define SDP_Offest_ServiceName      0x0000
650ef907034SMatthias Ringwald #define SDP_Offest_ServiceDescription 0x0001
651ef907034SMatthias Ringwald #define SDP_Offest_ProviderName     0x0002
652ef907034SMatthias Ringwald 
653ef907034SMatthias Ringwald // OBEX
654ef907034SMatthias Ringwald #define SDP_vCard_2_1       0x01
655ef907034SMatthias Ringwald #define SDP_vCard_3_0       0x02
656ef907034SMatthias Ringwald #define SDP_vCal_1_0        0x03
657ef907034SMatthias Ringwald #define SDP_iCal_2_0        0x04
658ef907034SMatthias Ringwald #define SDP_vNote           0x05
659ef907034SMatthias Ringwald #define SDP_vMessage        0x06
660ef907034SMatthias Ringwald #define SDP_OBEXFileTypeAny 0xFF
661ef907034SMatthias Ringwald 
662ef907034SMatthias Ringwald /**
663e2577bd7SMatthias Ringwald  * RFCOMM Protocol
664e2577bd7SMatthias Ringwald  */
665e2577bd7SMatthias Ringwald 
666e2577bd7SMatthias Ringwald // Control field values      bit no.       1 2 3 4 PF 6 7 8
667e2577bd7SMatthias Ringwald #define BT_RFCOMM_SABM       0x3F       // 1 1 1 1  1 1 0 0
668e2577bd7SMatthias Ringwald #define BT_RFCOMM_UA         0x73       // 1 1 0 0  1 1 1 0
669e2577bd7SMatthias Ringwald #define BT_RFCOMM_DM         0x0F       // 1 1 1 1  0 0 0 0
670e2577bd7SMatthias Ringwald #define BT_RFCOMM_DM_PF      0x1F       // 1 1 1 1  1 0 0 0
671e2577bd7SMatthias Ringwald #define BT_RFCOMM_DISC       0x53       // 1 1 0 0  1 0 1 0
672e2577bd7SMatthias Ringwald #define BT_RFCOMM_UIH        0xEF       // 1 1 1 1  0 1 1 1
673e2577bd7SMatthias Ringwald #define BT_RFCOMM_UIH_PF     0xFF       // 1 1 1 1  0 1 1 1
674e2577bd7SMatthias Ringwald 
675e2577bd7SMatthias Ringwald // Multiplexer message types
676e2577bd7SMatthias Ringwald #define BT_RFCOMM_CLD_CMD    0xC3
677e2577bd7SMatthias Ringwald #define BT_RFCOMM_FCON_CMD   0xA3
678e2577bd7SMatthias Ringwald #define BT_RFCOMM_FCON_RSP   0xA1
679e2577bd7SMatthias Ringwald #define BT_RFCOMM_FCOFF_CMD  0x63
680e2577bd7SMatthias Ringwald #define BT_RFCOMM_FCOFF_RSP  0x61
681e2577bd7SMatthias Ringwald #define BT_RFCOMM_MSC_CMD    0xE3
682e2577bd7SMatthias Ringwald #define BT_RFCOMM_MSC_RSP    0xE1
683e2577bd7SMatthias Ringwald #define BT_RFCOMM_NSC_RSP    0x11
684e2577bd7SMatthias Ringwald #define BT_RFCOMM_PN_CMD     0x83
685e2577bd7SMatthias Ringwald #define BT_RFCOMM_PN_RSP     0x81
686e2577bd7SMatthias Ringwald #define BT_RFCOMM_RLS_CMD    0x53
687e2577bd7SMatthias Ringwald #define BT_RFCOMM_RLS_RSP    0x51
688e2577bd7SMatthias Ringwald #define BT_RFCOMM_RPN_CMD    0x93
689e2577bd7SMatthias Ringwald #define BT_RFCOMM_RPN_RSP    0x91
690e2577bd7SMatthias Ringwald #define BT_RFCOMM_TEST_CMD   0x23
691e2577bd7SMatthias Ringwald #define BT_RFCOMM_TEST_RSP   0x21
692e2577bd7SMatthias Ringwald 
693e2577bd7SMatthias Ringwald // Line Status
694e2577bd7SMatthias Ringwald #define LINE_STATUS_NO_ERROR       0x00
695e2577bd7SMatthias Ringwald #define LINE_STATUS_OVERRUN_ERROR  0x03
696e2577bd7SMatthias Ringwald #define LINE_STATUS_PARITY_ERORR   0x05
697e2577bd7SMatthias Ringwald #define LINE_STATUS_FRAMING_ERROR  0x09
698e2577bd7SMatthias Ringwald 
699e2577bd7SMatthias Ringwald // Modem Status Flags
700e2577bd7SMatthias Ringwald #define MODEM_STATUS_FC   0x02
701e2577bd7SMatthias Ringwald #define MODEM_STATUS_RTC  0x04
702e2577bd7SMatthias Ringwald #define MODEM_STATUS_RTR  0x08
703e2577bd7SMatthias Ringwald #define MODEM_STATUS_IC   0x40
704e2577bd7SMatthias Ringwald #define MODEM_STATUS_DV   0x80
705e2577bd7SMatthias Ringwald 
706e2577bd7SMatthias Ringwald typedef enum rpn_baud {
707e2577bd7SMatthias Ringwald     RPN_BAUD_2400 = 0,
708e2577bd7SMatthias Ringwald     RPN_BAUD_4800,
709e2577bd7SMatthias Ringwald     RPN_BAUD_7200,
710e2577bd7SMatthias Ringwald     RPN_BAUD_9600,
711e2577bd7SMatthias Ringwald     RPN_BAUD_19200,
712e2577bd7SMatthias Ringwald     RPN_BAUD_38400,
713e2577bd7SMatthias Ringwald     RPN_BAUD_57600,
714e2577bd7SMatthias Ringwald     RPN_BAUD_115200,
715e2577bd7SMatthias Ringwald     RPN_BAUD_230400
716e2577bd7SMatthias Ringwald } rpn_baud_t;
717e2577bd7SMatthias Ringwald 
718e2577bd7SMatthias Ringwald typedef enum rpn_data_bits {
719e2577bd7SMatthias Ringwald     RPN_DATA_BITS_5 = 0,
720e2577bd7SMatthias Ringwald     RPN_DATA_BITS_6 = 0,
721e2577bd7SMatthias Ringwald     RPN_DATA_BITS_7 = 0,
722e2577bd7SMatthias Ringwald     RPN_DATA_BITS_8 = 0
723e2577bd7SMatthias Ringwald } rpn_data_bits_t;
724e2577bd7SMatthias Ringwald 
725e2577bd7SMatthias Ringwald typedef enum rpn_stop_bits {
726e2577bd7SMatthias Ringwald     RPN_STOP_BITS_1_0 = 0,
727e2577bd7SMatthias Ringwald     RPN_STOP_BITS_1_5
728e2577bd7SMatthias Ringwald } rpn_stop_bits_t;
729e2577bd7SMatthias Ringwald 
730e2577bd7SMatthias Ringwald typedef enum rpn_parity {
731e2577bd7SMatthias Ringwald     RPN_PARITY_NONE  = 0,
732e2577bd7SMatthias Ringwald     RPN_PARITY_ODD   = 1,
733e2577bd7SMatthias Ringwald     RPN_PARITY_EVEN  = 3,
734e2577bd7SMatthias Ringwald     RPN_PARITY_MARK  = 5,
735e2577bd7SMatthias Ringwald     RPN_PARITY_SPACE = 7,
736e2577bd7SMatthias Ringwald } rpn_parity_t;
737e2577bd7SMatthias Ringwald 
738e2577bd7SMatthias Ringwald typedef enum rpn_flow_control {
739e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_XONXOFF_ON_INPUT  = 1 << 0,
740e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_XONXOFF_ON_OUTPUT = 1 << 1,
741e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_RTR_ON_INPUT  = 1 << 2,
742e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_RTR_ON_OUTPUT = 1 << 3,
743e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_RTC_ON_INPUT  = 1 << 4,
744e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_RTC_ON_OUTPUT = 1 << 5,
745e2577bd7SMatthias Ringwald } rpn_flow_control_t;
746e2577bd7SMatthias Ringwald 
747e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_BAUD             0x01
748e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_DATA_BITS        0x02
749e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_STOP_BITS        0x04
750e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_PARITY           0x08
751e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_PARITY_TYPE      0x10
752e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_XON_CHAR         0x20
753e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_XOFF_CHAR        0x40
754e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_RESERVED         0x80
755e2577bd7SMatthias Ringwald 
756e2577bd7SMatthias Ringwald // @note: values are identical to rpn_flow_control_t
757e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_XONOFF_ON_INPUT  0x01
758e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_XONOFF_ON_OUTPUT 0x02
759e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RTR_ON_INPUT     0x04
760e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RTR_ON_OUTPUT    0x08
761e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RTC_ON_INPUT     0x10
762e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RTC_ON_OUTPUT    0x20
763e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RESERVED_0       0x40
764e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RESERVED_1       0x80
765e2577bd7SMatthias Ringwald 
766e2577bd7SMatthias Ringwald /**
76766b1fcb3SMatthias Ringwald  * BNEP Protocol
76866b1fcb3SMatthias Ringwald  */
76947f4e325SMatthias Ringwald 
77066b1fcb3SMatthias Ringwald #ifndef ETHER_ADDR_LEN
7719a73f75dSMatthias Ringwald #define ETHER_ADDR_LEN 6
77266b1fcb3SMatthias Ringwald #endif
77347f4e325SMatthias Ringwald 
77466b1fcb3SMatthias Ringwald #ifndef ETHERTYPE_VLAN
77566b1fcb3SMatthias Ringwald #define ETHERTYPE_VLAN                                  0x8100 /* IEEE 802.1Q VLAN tag */
77666b1fcb3SMatthias Ringwald #endif
77766b1fcb3SMatthias Ringwald 
77866b1fcb3SMatthias Ringwald #define BNEP_MTU_MIN                                    1691
77966b1fcb3SMatthias Ringwald 
78066b1fcb3SMatthias Ringwald #define BNEP_EXT_FLAG                                   0x80
78166b1fcb3SMatthias Ringwald #define BNEP_TYPE_MASK                                  0x7F
78266b1fcb3SMatthias Ringwald #define BNEP_TYPE(header)                               ((header) & BNEP_TYPE_MASK)
78366b1fcb3SMatthias Ringwald #define BNEP_HEADER_HAS_EXT(x)                          (((x) & BNEP_EXT_FLAG) == BNEP_EXT_FLAG)
78466b1fcb3SMatthias Ringwald 
78566b1fcb3SMatthias Ringwald /* BNEP packet types */
78666b1fcb3SMatthias Ringwald #define BNEP_PKT_TYPE_GENERAL_ETHERNET                  0x00
78766b1fcb3SMatthias Ringwald #define BNEP_PKT_TYPE_CONTROL                           0x01
78866b1fcb3SMatthias Ringwald #define BNEP_PKT_TYPE_COMPRESSED_ETHERNET               0x02
78966b1fcb3SMatthias Ringwald #define BNEP_PKT_TYPE_COMPRESSED_ETHERNET_SOURCE_ONLY   0x03
79066b1fcb3SMatthias Ringwald #define BNEP_PKT_TYPE_COMPRESSED_ETHERNET_DEST_ONLY     0x04
79166b1fcb3SMatthias Ringwald 
79266b1fcb3SMatthias Ringwald /* BNEP control types */
79366b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_COMMAND_NOT_UNDERSTOOD        0x00
79466b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_SETUP_CONNECTION_REQUEST      0x01
79566b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_SETUP_CONNECTION_RESPONSE     0x02
79666b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_FILTER_NET_TYPE_SET           0x03
79766b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_FILTER_NET_TYPE_RESPONSE      0x04
79866b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_FILTER_MULTI_ADDR_SET         0x05
79966b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_FILTER_MULTI_ADDR_RESPONSE    0x06
80066b1fcb3SMatthias Ringwald 
80166b1fcb3SMatthias Ringwald /* BNEP extension header types */
80266b1fcb3SMatthias Ringwald #define BNEP_EXT_HEADER_TYPE_EXTENSION_CONTROL          0x00
80366b1fcb3SMatthias Ringwald 
80466b1fcb3SMatthias Ringwald /* BNEP setup response codes */
80566b1fcb3SMatthias Ringwald #define BNEP_RESP_SETUP_SUCCESS                         0x0000
80666b1fcb3SMatthias Ringwald #define BNEP_RESP_SETUP_INVALID_DEST_UUID               0x0001
80766b1fcb3SMatthias Ringwald #define BNEP_RESP_SETUP_INVALID_SOURCE_UUID             0x0002
80866b1fcb3SMatthias Ringwald #define BNEP_RESP_SETUP_INVALID_SERVICE_UUID_SIZE       0x0003
80966b1fcb3SMatthias Ringwald #define BNEP_RESP_SETUP_CONNECTION_NOT_ALLOWED          0x0004
81066b1fcb3SMatthias Ringwald 
81166b1fcb3SMatthias Ringwald /* BNEP filter response codes */
81266b1fcb3SMatthias Ringwald #define BNEP_RESP_FILTER_SUCCESS                        0x0000
81366b1fcb3SMatthias Ringwald #define BNEP_RESP_FILTER_UNSUPPORTED_REQUEST            0x0001
81466b1fcb3SMatthias Ringwald #define BNEP_RESP_FILTER_ERR_INVALID_RANGE              0x0002
81566b1fcb3SMatthias Ringwald #define BNEP_RESP_FILTER_ERR_TOO_MANY_FILTERS           0x0003
81666b1fcb3SMatthias Ringwald #define BNEP_RESP_FILTER_ERR_SECURITY                   0x0004
81766b1fcb3SMatthias Ringwald 
81866b1fcb3SMatthias Ringwald /**
81966b1fcb3SMatthias Ringwald  * PAN Profile
82066b1fcb3SMatthias Ringwald  */
82166b1fcb3SMatthias Ringwald 
82266b1fcb3SMatthias Ringwald typedef enum {
82366b1fcb3SMatthias Ringwald     PANU_UUID = 0x1115,
82466b1fcb3SMatthias Ringwald     NAP_UUID = 0x1116,
82566b1fcb3SMatthias Ringwald     GN_UUID = 0x1117
82666b1fcb3SMatthias Ringwald } bnep_service_uuid_t;
82766b1fcb3SMatthias Ringwald 
82866b1fcb3SMatthias Ringwald typedef enum {
82966b1fcb3SMatthias Ringwald     BNEP_SECURITY_NONE = 0x0000,
83066b1fcb3SMatthias Ringwald     BNEP_SECURITY_SERVICE_LEVEL_ENFORCED,
83166b1fcb3SMatthias Ringwald     BNEP_SECURITY_802_1X
83266b1fcb3SMatthias Ringwald } security_description_t;
83366b1fcb3SMatthias Ringwald 
83466b1fcb3SMatthias Ringwald typedef enum {
83566b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_PSTN = 0x0000,
83666b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_ISDN,
83766b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_DSL,
83866b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_CABLE_MODEM,
83966b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_10MB_ETHERNET,
84066b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_100MB_ETHERNET,
84166b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_4MB_TOKEN_RING,
84266b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_16MB_TOKEN_RING,
84366b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_100MB_TOKEN_RING,
84466b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_FDDI,
84566b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_GSM,
84666b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_CDMA,
84766b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_GPRS,
84866b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_3G,
84966b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_CELULAR,
85066b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_OTHER = 0xFFFE,
85166b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_NONE
85266b1fcb3SMatthias Ringwald } net_access_type_t;
85347f4e325SMatthias Ringwald 
8544c1900e6SMatthias Ringwald /**
8554c1900e6SMatthias Ringwald  * ATT
8564c1900e6SMatthias Ringwald  */
8574c1900e6SMatthias Ringwald 
8584c1900e6SMatthias Ringwald // Minimum/default MTU
8594c1900e6SMatthias Ringwald #define ATT_DEFAULT_MTU               23
8604c1900e6SMatthias Ringwald 
8614c1900e6SMatthias Ringwald // MARK: Attribute PDU Opcodes
8624c1900e6SMatthias Ringwald #define ATT_ERROR_RESPONSE              0x01
8634c1900e6SMatthias Ringwald 
8644c1900e6SMatthias Ringwald #define ATT_EXCHANGE_MTU_REQUEST        0x02
8654c1900e6SMatthias Ringwald #define ATT_EXCHANGE_MTU_RESPONSE       0x03
8664c1900e6SMatthias Ringwald 
8674c1900e6SMatthias Ringwald #define ATT_FIND_INFORMATION_REQUEST    0x04
8684c1900e6SMatthias Ringwald #define ATT_FIND_INFORMATION_REPLY      0x05
8694c1900e6SMatthias Ringwald #define ATT_FIND_BY_TYPE_VALUE_REQUEST  0x06
8704c1900e6SMatthias Ringwald #define ATT_FIND_BY_TYPE_VALUE_RESPONSE 0x07
8714c1900e6SMatthias Ringwald 
8724c1900e6SMatthias Ringwald #define ATT_READ_BY_TYPE_REQUEST        0x08
8734c1900e6SMatthias Ringwald #define ATT_READ_BY_TYPE_RESPONSE       0x09
8744c1900e6SMatthias Ringwald #define ATT_READ_REQUEST                0x0a
8754c1900e6SMatthias Ringwald #define ATT_READ_RESPONSE               0x0b
8764c1900e6SMatthias Ringwald #define ATT_READ_BLOB_REQUEST           0x0c
8774c1900e6SMatthias Ringwald #define ATT_READ_BLOB_RESPONSE          0x0d
8784c1900e6SMatthias Ringwald #define ATT_READ_MULTIPLE_REQUEST       0x0e
8794c1900e6SMatthias Ringwald #define ATT_READ_MULTIPLE_RESPONSE      0x0f
8804c1900e6SMatthias Ringwald #define ATT_READ_BY_GROUP_TYPE_REQUEST  0x10
8814c1900e6SMatthias Ringwald #define ATT_READ_BY_GROUP_TYPE_RESPONSE 0x11
8824c1900e6SMatthias Ringwald 
8834c1900e6SMatthias Ringwald #define ATT_WRITE_REQUEST               0x12
8844c1900e6SMatthias Ringwald #define ATT_WRITE_RESPONSE              0x13
8854c1900e6SMatthias Ringwald 
8864c1900e6SMatthias Ringwald #define ATT_PREPARE_WRITE_REQUEST       0x16
8874c1900e6SMatthias Ringwald #define ATT_PREPARE_WRITE_RESPONSE      0x17
8884c1900e6SMatthias Ringwald #define ATT_EXECUTE_WRITE_REQUEST       0x18
8894c1900e6SMatthias Ringwald #define ATT_EXECUTE_WRITE_RESPONSE      0x19
8904c1900e6SMatthias Ringwald 
8914c1900e6SMatthias Ringwald #define ATT_HANDLE_VALUE_NOTIFICATION   0x1b
8924c1900e6SMatthias Ringwald #define ATT_HANDLE_VALUE_INDICATION     0x1d
8934c1900e6SMatthias Ringwald #define ATT_HANDLE_VALUE_CONFIRMATION   0x1e
8944c1900e6SMatthias Ringwald 
8954c1900e6SMatthias Ringwald 
8964c1900e6SMatthias Ringwald #define ATT_WRITE_COMMAND                0x52
8974c1900e6SMatthias Ringwald #define ATT_SIGNED_WRITE_COMMAND         0xD2
8984c1900e6SMatthias Ringwald 
8994c1900e6SMatthias Ringwald // MARK: ATT Error Codes
9004c1900e6SMatthias Ringwald #define ATT_ERROR_INVALID_HANDLE                   0x01
9014c1900e6SMatthias Ringwald #define ATT_ERROR_READ_NOT_PERMITTED               0x02
9024c1900e6SMatthias Ringwald #define ATT_ERROR_WRITE_NOT_PERMITTED              0x03
9034c1900e6SMatthias Ringwald #define ATT_ERROR_INVALID_PDU                      0x04
9044c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_AUTHENTICATION      0x05
9054c1900e6SMatthias Ringwald #define ATT_ERROR_REQUEST_NOT_SUPPORTED            0x06
9064c1900e6SMatthias Ringwald #define ATT_ERROR_INVALID_OFFSET                   0x07
9074c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_AUTHORIZATION       0x08
9084c1900e6SMatthias Ringwald #define ATT_ERROR_PREPARE_QUEUE_FULL               0x09
9094c1900e6SMatthias Ringwald #define ATT_ERROR_ATTRIBUTE_NOT_FOUND              0x0a
9104c1900e6SMatthias Ringwald #define ATT_ERROR_ATTRIBUTE_NOT_LONG               0x0b
9114c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_ENCRYPTION_KEY_SIZE 0x0c
9124c1900e6SMatthias Ringwald #define ATT_ERROR_INVALID_ATTRIBUTE_VALUE_LENGTH   0x0d
9134c1900e6SMatthias Ringwald #define ATT_ERROR_UNLIKELY_ERROR                   0x0e
9144c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_ENCRYPTION          0x0f
9154c1900e6SMatthias Ringwald #define ATT_ERROR_UNSUPPORTED_GROUP_TYPE           0x10
9164c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_RESOURCES           0x11
9174c1900e6SMatthias Ringwald 
9184c1900e6SMatthias Ringwald // MARK: Attribute Property Flags
9194c1900e6SMatthias Ringwald #define ATT_PROPERTY_BROADCAST           0x01
9204c1900e6SMatthias Ringwald #define ATT_PROPERTY_READ                0x02
9214c1900e6SMatthias Ringwald #define ATT_PROPERTY_WRITE_WITHOUT_RESPONSE 0x04
9224c1900e6SMatthias Ringwald #define ATT_PROPERTY_WRITE               0x08
9234c1900e6SMatthias Ringwald #define ATT_PROPERTY_NOTIFY              0x10
9244c1900e6SMatthias Ringwald #define ATT_PROPERTY_INDICATE            0x20
9254c1900e6SMatthias Ringwald #define ATT_PROPERTY_AUTHENTICATED_SIGNED_WRITE 0x40
9264c1900e6SMatthias Ringwald #define ATT_PROPERTY_EXTENDED_PROPERTIES 0x80
9274c1900e6SMatthias Ringwald 
9284c1900e6SMatthias Ringwald // MARK: Attribute Property Flag, BTstack extension
9294c1900e6SMatthias Ringwald // value is asked from client
9304c1900e6SMatthias Ringwald #define ATT_PROPERTY_DYNAMIC             0x100
9314c1900e6SMatthias Ringwald // 128 bit UUID used
9324c1900e6SMatthias Ringwald #define ATT_PROPERTY_UUID128             0x200
9334c1900e6SMatthias Ringwald // Authentication required
9344c1900e6SMatthias Ringwald #define ATT_PROPERTY_AUTHENTICATION_REQUIRED 0x400
9354c1900e6SMatthias Ringwald // Authorization from user required
9364c1900e6SMatthias Ringwald #define ATT_PROPERTY_AUTHORIZATION_REQUIRED  0x800
9374c1900e6SMatthias Ringwald // Encryption key size stored in upper 4 bits, 0 == no encryption, encryption key size - 1 otherwise
9384c1900e6SMatthias Ringwald 
9394c1900e6SMatthias Ringwald // ATT Transaction Timeout of 30 seconds for Command/Response or Incidationc/Confirmation
9404c1900e6SMatthias Ringwald #define ATT_TRANSACTION_TIMEOUT_MS     30000
9414c1900e6SMatthias Ringwald 
9424c1900e6SMatthias Ringwald #define ATT_TRANSACTION_MODE_NONE      0x0
9434c1900e6SMatthias Ringwald #define ATT_TRANSACTION_MODE_ACTIVE    0x1
9444c1900e6SMatthias Ringwald #define ATT_TRANSACTION_MODE_EXECUTE   0x2
9454c1900e6SMatthias Ringwald #define ATT_TRANSACTION_MODE_CANCEL    0x3
9464c1900e6SMatthias Ringwald 
9474c1900e6SMatthias Ringwald // MARK: GATT UUIDs
9484c1900e6SMatthias Ringwald #define GATT_PRIMARY_SERVICE_UUID                   0x2800
9494c1900e6SMatthias Ringwald #define GATT_SECONDARY_SERVICE_UUID                 0x2801
9504c1900e6SMatthias Ringwald #define GATT_INCLUDE_SERVICE_UUID                   0x2802
9514c1900e6SMatthias Ringwald #define GATT_CHARACTERISTICS_UUID                   0x2803
9524c1900e6SMatthias Ringwald #define GATT_CHARACTERISTIC_EXTENDED_PROPERTIES     0x2900
9534c1900e6SMatthias Ringwald #define GATT_CHARACTERISTIC_USER_DESCRIPTION        0x2901
9544c1900e6SMatthias Ringwald #define GATT_CLIENT_CHARACTERISTICS_CONFIGURATION   0x2902
9554c1900e6SMatthias Ringwald #define GATT_SERVER_CHARACTERISTICS_CONFIGURATION   0x2903
9564c1900e6SMatthias Ringwald #define GATT_CHARACTERISTIC_PRESENTATION_FORMAT     0x2904
9574c1900e6SMatthias Ringwald #define GATT_CHARACTERISTIC_AGGREGATE_FORMAT        0x2905
9584c1900e6SMatthias Ringwald 
9594c1900e6SMatthias Ringwald #define GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NONE          0
9604c1900e6SMatthias Ringwald #define GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NOTIFICATION  1
9614c1900e6SMatthias Ringwald #define GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_INDICATION    2
9624c1900e6SMatthias Ringwald 
9634c1900e6SMatthias Ringwald // GAP Service and Characteristics
9644c1900e6SMatthias Ringwald #define GAP_SERVICE_UUID               0x1800
9654c1900e6SMatthias Ringwald #define GAP_DEVICE_NAME_UUID           0x2a00
9664c1900e6SMatthias Ringwald #define GAP_APPEARANCE_UUID            0x2a01
9674c1900e6SMatthias Ringwald #define GAP_PERIPHERAL_PRIVACY_FLAG    0x2a02
9684c1900e6SMatthias Ringwald #define GAP_RECONNECTION_ADDRESS_UUID  0x2a03
9694c1900e6SMatthias Ringwald #define GAP_PERIPHERAL_PREFERRED_CONNECTION_PARAMETERS_UUID 0x2a04
97017fe8172SMatthias Ringwald #define GAP_SERVICE_CHANGED            0x2a05
9714c1900e6SMatthias Ringwald 
9724c1900e6SMatthias Ringwald /**
9734c1900e6SMatthias Ringwald  * SM - LE Security Manager
9744c1900e6SMatthias Ringwald  */
9754c1900e6SMatthias Ringwald // Bluetooth Spec definitions
9764c1900e6SMatthias Ringwald typedef enum {
9774c1900e6SMatthias Ringwald     SM_CODE_PAIRING_REQUEST = 0X01,
9784c1900e6SMatthias Ringwald     SM_CODE_PAIRING_RESPONSE,
9794c1900e6SMatthias Ringwald     SM_CODE_PAIRING_CONFIRM,
9804c1900e6SMatthias Ringwald     SM_CODE_PAIRING_RANDOM,
9814c1900e6SMatthias Ringwald     SM_CODE_PAIRING_FAILED,
9824c1900e6SMatthias Ringwald     SM_CODE_ENCRYPTION_INFORMATION,
9834c1900e6SMatthias Ringwald     SM_CODE_MASTER_IDENTIFICATION,
9844c1900e6SMatthias Ringwald     SM_CODE_IDENTITY_INFORMATION,
9854c1900e6SMatthias Ringwald     SM_CODE_IDENTITY_ADDRESS_INFORMATION,
9864c1900e6SMatthias Ringwald     SM_CODE_SIGNING_INFORMATION,
98774a9b3d5SMatthias Ringwald     SM_CODE_SECURITY_REQUEST,
98874a9b3d5SMatthias Ringwald     SM_CODE_PAIRING_PUBLIC_KEY,
98974a9b3d5SMatthias Ringwald     SM_CODE_PAIRING_DHKEY_CHECK,
99044e8d9acSMatthias Ringwald     SM_CODE_KEYPRESS_NOTIFICATION,
9914c1900e6SMatthias Ringwald } SECURITY_MANAGER_COMMANDS;
9924c1900e6SMatthias Ringwald 
9934c1900e6SMatthias Ringwald // IO Capability Values
9944c1900e6SMatthias Ringwald typedef enum {
9954c1900e6SMatthias Ringwald     IO_CAPABILITY_DISPLAY_ONLY = 0,
9964c1900e6SMatthias Ringwald     IO_CAPABILITY_DISPLAY_YES_NO,
9974c1900e6SMatthias Ringwald     IO_CAPABILITY_KEYBOARD_ONLY,
9984c1900e6SMatthias Ringwald     IO_CAPABILITY_NO_INPUT_NO_OUTPUT,
9994c1900e6SMatthias Ringwald     IO_CAPABILITY_KEYBOARD_DISPLAY, // not used by secure simple pairing
10004c1900e6SMatthias Ringwald } io_capability_t;
10014c1900e6SMatthias Ringwald 
10024c1900e6SMatthias Ringwald // Authentication requirement flags
10034c1900e6SMatthias Ringwald #define SM_AUTHREQ_NO_BONDING        0x00
10044c1900e6SMatthias Ringwald #define SM_AUTHREQ_BONDING           0x01
10054c1900e6SMatthias Ringwald #define SM_AUTHREQ_MITM_PROTECTION   0x04
100674a9b3d5SMatthias Ringwald #define SM_AUTHREQ_SECURE_CONNECTION 0x08
100774a9b3d5SMatthias Ringwald #define SM_AUTHREQ_KEYPRESS          0x10
10084c1900e6SMatthias Ringwald 
10094c1900e6SMatthias Ringwald // Key distribution flags used by spec
101052f9cf63SMatthias Ringwald #define SM_KEYDIST_ENC_KEY  0x01
10114c1900e6SMatthias Ringwald #define SM_KEYDIST_ID_KEY   0x02
10124c1900e6SMatthias Ringwald #define SM_KEYDIST_SIGN     0x04
101352f9cf63SMatthias Ringwald #define SM_KEYDIST_LINK_KEY 0x08
10144c1900e6SMatthias Ringwald 
10154c1900e6SMatthias Ringwald // Key distribution flags used internally
10164c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_ENCRYPTION_INFORMATION       0x01
10174c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_MASTER_IDENTIFICATION        0x02
10184c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_IDENTITY_INFORMATION         0x04
10194c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_IDENTITY_ADDRESS_INFORMATION 0x08
10204c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_SIGNING_IDENTIFICATION       0x10
10214c1900e6SMatthias Ringwald 
10224c1900e6SMatthias Ringwald // STK Generation Methods
10234c1900e6SMatthias Ringwald #define SM_STK_GENERATION_METHOD_JUST_WORKS          0x01
10244c1900e6SMatthias Ringwald #define SM_STK_GENERATION_METHOD_OOB                 0x02
10254c1900e6SMatthias Ringwald #define SM_STK_GENERATION_METHOD_PASSKEY             0x04
1026b4343428SMatthias Ringwald #define SM_STK_GENERATION_METHOD_NUMERIC_COMPARISON  0x08
10274c1900e6SMatthias Ringwald 
10284c1900e6SMatthias Ringwald // Pairing Failed Reasons
10294c1900e6SMatthias Ringwald #define SM_REASON_RESERVED                     0x00
10304c1900e6SMatthias Ringwald #define SM_REASON_PASSKEYT_ENTRY_FAILED        0x01
10314c1900e6SMatthias Ringwald #define SM_REASON_OOB_NOT_AVAILABLE            0x02
10324c1900e6SMatthias Ringwald #define SM_REASON_AUTHENTHICATION_REQUIREMENTS 0x03
10334c1900e6SMatthias Ringwald #define SM_REASON_CONFIRM_VALUE_FAILED         0x04
10344c1900e6SMatthias Ringwald #define SM_REASON_PAIRING_NOT_SUPPORTED        0x05
10354c1900e6SMatthias Ringwald #define SM_REASON_ENCRYPTION_KEY_SIZE          0x06
10364c1900e6SMatthias Ringwald #define SM_REASON_COMMAND_NOT_SUPPORTED        0x07
10374c1900e6SMatthias Ringwald #define SM_REASON_UNSPECIFIED_REASON           0x08
10384c1900e6SMatthias Ringwald #define SM_REASON_REPEATED_ATTEMPTS            0x09
1039a9f29768SMatthias Ringwald #define SM_REASON_INVALID_PARAMETERS           0x0a
1040a9f29768SMatthias Ringwald #define SM_REASON_DHKEY_CHECK_FAILED           0x0b
1041a9f29768SMatthias Ringwald #define SM_REASON_NUMERIC_COMPARISON_FAILED    0x0c
1042a9f29768SMatthias Ringwald 
10434c1900e6SMatthias Ringwald // also, invalid parameters
10444c1900e6SMatthias Ringwald // and reserved
10454c1900e6SMatthias Ringwald 
104644e8d9acSMatthias Ringwald // Keypress Notifications
104744e8d9acSMatthias Ringwald #define SM_KEYPRESS_PASSKEY_ENTRY_STARTED      0x00
104844e8d9acSMatthias Ringwald #define SM_KEYPRESS_PASSKEY_DIGIT_ENTERED      0x01
104944e8d9acSMatthias Ringwald #define SM_KEYPRESS_PASSKEY_DIGIT_ERASED       0x02
105044e8d9acSMatthias Ringwald #define SM_KEYPRESS_PASSKEY_CLEARED            0x03
105144e8d9acSMatthias Ringwald #define SM_KEYPRESS_PASSKEY_ENTRY_COMPLETED    0x04
105244e8d9acSMatthias Ringwald 
105344e8d9acSMatthias Ringwald 
1054c6d1dbedSMatthias Ringwald // Company identifiers / manufacturers
1055c6d1dbedSMatthias Ringwald #define COMPANY_ID_CAMBRIDGE_SILICON_RADIO     0x000A
1056c6d1dbedSMatthias Ringwald #define COMPANY_ID_TEXAS_INSTRUMENTS_INC       0x000D
1057c6d1dbedSMatthias Ringwald #define COMPANY_ID_BROADCOM_CORPORATION        0x000F
1058c6d1dbedSMatthias Ringwald #define COMPANY_ID_ST_MICROELECTRONICS         0x0030
1059c6d1dbedSMatthias Ringwald #define COMPANY_ID_EM_MICROELECTRONICS_MARIN   0x005A
1060c6d1dbedSMatthias Ringwald 
10614c1900e6SMatthias Ringwald 
106247f4e325SMatthias Ringwald #endif