xref: /btstack/src/bluetooth.h (revision f193890f132676f0519b3a74a92f6ba3533cf17c)
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,
71b95a5a35SMatthias Ringwald     BD_ADDR_TYPE_LE_PRIVAT_FALLBACK_PUBLIC = 2,
72b95a5a35SMatthias Ringwald     BD_ADDR_TYPE_LE_PRIVAT_FALLBACK_RANDOM = 3,
738974fcd6SMatthias Ringwald     BD_ADDR_TYPE_SCO       = 0xfe,
748974fcd6SMatthias Ringwald     BD_ADDR_TYPE_CLASSIC   = 0xff,
758974fcd6SMatthias Ringwald     BD_ADDR_TYPE_UNKNOWN   = 0xfe
768974fcd6SMatthias Ringwald } bd_addr_type_t;
778974fcd6SMatthias Ringwald 
78b95a5a35SMatthias Ringwald 
79b95a5a35SMatthias Ringwald 
808974fcd6SMatthias Ringwald /**
818974fcd6SMatthias Ringwald  * @brief link key
828974fcd6SMatthias Ringwald  */
838974fcd6SMatthias Ringwald #define LINK_KEY_LEN 16
848974fcd6SMatthias Ringwald #define LINK_KEY_STR_LEN (LINK_KEY_LEN*2)
858974fcd6SMatthias Ringwald typedef uint8_t link_key_t[LINK_KEY_LEN];
868974fcd6SMatthias Ringwald 
878974fcd6SMatthias Ringwald /**
888974fcd6SMatthias Ringwald  * @brief link key type
898974fcd6SMatthias Ringwald  */
908974fcd6SMatthias Ringwald typedef enum {
918974fcd6SMatthias Ringwald   COMBINATION_KEY = 0,  // standard pairing
928974fcd6SMatthias Ringwald   LOCAL_UNIT_KEY,     // ?
938974fcd6SMatthias Ringwald   REMOTE_UNIT_KEY,    // ?
948974fcd6SMatthias Ringwald   DEBUG_COMBINATION_KEY,  // SSP with debug
958974fcd6SMatthias Ringwald   UNAUTHENTICATED_COMBINATION_KEY_GENERATED_FROM_P192, // SSP Simple Pairing
968974fcd6SMatthias Ringwald   AUTHENTICATED_COMBINATION_KEY_GENERATED_FROM_P192,   // SSP Passkey, Number confirm, OOB
978974fcd6SMatthias Ringwald   CHANGED_COMBINATION_KEY,               // Link key changed using Change Connection Lnk Key
988974fcd6SMatthias Ringwald   UNAUTHENTICATED_COMBINATION_KEY_GENERATED_FROM_P256, // SSP Simpe Pairing
998974fcd6SMatthias Ringwald   AUTHENTICATED_COMBINATION_KEY_GENERATED_FROM_P256,   // SSP Passkey, Number confirm, OOB
1008974fcd6SMatthias Ringwald } link_key_type_t;
1018974fcd6SMatthias Ringwald 
1028974fcd6SMatthias Ringwald /**
103f6858d14SMatthias Ringwald  * @brief Inquiry modes
104f6858d14SMatthias Ringwald  */
105f6858d14SMatthias Ringwald typedef enum {
106f6858d14SMatthias Ringwald   INQUIRY_MODE_STANDARD = 0,
107f6858d14SMatthias Ringwald   INQUIRY_MODE_RSSI,
108f6858d14SMatthias Ringwald   INQUIRY_MODE_RSSI_AND_EIR,
109f6858d14SMatthias Ringwald } inquiry_mode_t;
110f6858d14SMatthias Ringwald 
111f6858d14SMatthias Ringwald /**
11247f4e325SMatthias Ringwald  * HCI Transport
11347f4e325SMatthias Ringwald  */
11447f4e325SMatthias Ringwald 
11547f4e325SMatthias Ringwald /**
11647f4e325SMatthias Ringwald  * packet types - used in BTstack and over the H4 UART interface
11747f4e325SMatthias Ringwald  */
11847f4e325SMatthias Ringwald #define HCI_COMMAND_DATA_PACKET 0x01
11947f4e325SMatthias Ringwald #define HCI_ACL_DATA_PACKET     0x02
12047f4e325SMatthias Ringwald #define HCI_SCO_DATA_PACKET     0x03
12147f4e325SMatthias Ringwald #define HCI_EVENT_PACKET        0x04
12247f4e325SMatthias Ringwald 
1238799c043SMatthias Ringwald // packet header sizes
1248799c043SMatthias Ringwald #define HCI_CMD_HEADER_SIZE          3
1258799c043SMatthias Ringwald #define HCI_ACL_HEADER_SIZE          4
1268799c043SMatthias Ringwald #define HCI_SCO_HEADER_SIZE          3
1278799c043SMatthias Ringwald #define HCI_EVENT_HEADER_SIZE        2
1288799c043SMatthias Ringwald 
12947f4e325SMatthias Ringwald /**
13047f4e325SMatthias Ringwald  * HCI Layer
13147f4e325SMatthias Ringwald  */
13247f4e325SMatthias Ringwald 
13347f4e325SMatthias Ringwald //
134*f193890fSMatthias Ringwald // Error Codes rfom Bluetooth Core Specification
13547f4e325SMatthias Ringwald //
13647f4e325SMatthias Ringwald 
137*f193890fSMatthias Ringwald /* ENUM_START: BLUETOOTH_ERROR_CODE */
138616edd56SMatthias Ringwald #define ERROR_CODE_SUCCESS                                 0x00
13947f4e325SMatthias Ringwald #define ERROR_CODE_UNKNOWN_HCI_COMMAND                     0x01
14047f4e325SMatthias Ringwald #define ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER           0x02
14147f4e325SMatthias Ringwald #define ERROR_CODE_HARDWARE_FAILURE                        0x03
14247f4e325SMatthias Ringwald #define ERROR_CODE_PAGE_TIMEOUT                            0x04
14347f4e325SMatthias Ringwald #define ERROR_CODE_AUTHENTICATION_FAILURE                  0x05
14447f4e325SMatthias Ringwald #define ERROR_CODE_PIN_OR_KEY_MISSING                      0x06
14547f4e325SMatthias Ringwald #define ERROR_CODE_MEMORY_CAPACITY_EXCEEDED                0x07
14647f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_TIMEOUT                      0x08
14747f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_LIMIT_EXCEEDED               0x09
14847f4e325SMatthias Ringwald #define ERROR_CODE_SYNCHRONOUS_CONNECTION_LIMIT_TO_A_DEVICE_EXCEEDED  0x0A
14947f4e325SMatthias Ringwald #define ERROR_CODE_ACL_CONNECTION_ALREADY_EXISTS           0x0B
15047f4e325SMatthias Ringwald #define ERROR_CODE_COMMAND_DISALLOWED                      0x0C
15147f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_REJECTED_DUE_TO_LIMITED_RESOURCES 0x0D
15247f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_REJECTED_DUE_TO_SECURITY_REASONS  0x0E
15347f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_REJECTED_DUE_TO_UNACCEPTABLE_BD_ADDR 0x0F
15447f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_ACCEPT_TIMEOUT_EXCEEDED      0x10
15547f4e325SMatthias Ringwald #define ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE  0x11
15647f4e325SMatthias Ringwald #define ERROR_CODE_INVALID_HCI_COMMAND_PARAMETERS          0x12
15747f4e325SMatthias Ringwald #define ERROR_CODE_REMOTE_USER_TERMINATED_CONNECTION       0x13
15847f4e325SMatthias Ringwald #define ERROR_CODE_REMOTE_DEVICE_TERMINATED_CONNECTION_DUE_TO_LOW_RESOURCES 0x14
15947f4e325SMatthias Ringwald #define ERROR_CODE_REMOTE_DEVICE_TERMINATED_CONNECTION_DUE_TO_POWER_OFF     0x15
16047f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_TERMINATED_BY_LOCAL_HOST     0x16
16147f4e325SMatthias Ringwald #define ERROR_CODE_REPEATED_ATTEMPTS                       0x17
16247f4e325SMatthias Ringwald #define ERROR_CODE_PAIRING_NOT_ALLOWED                     0x18
16347f4e325SMatthias Ringwald #define ERROR_CODE_UNKNOWN_LMP_PDU                         0x19
16447f4e325SMatthias Ringwald #define ERROR_CODE_UNSUPPORTED_REMOTE_FEATURE_UNSUPPORTED_LMP_FEATURE 0x1A
16547f4e325SMatthias Ringwald #define ERROR_CODE_SCO_OFFSET_REJECTED                     0x1B
16647f4e325SMatthias Ringwald #define ERROR_CODE_SCO_INTERVAL_REJECTED                   0x1C
16747f4e325SMatthias Ringwald #define ERROR_CODE_SCO_AIR_MODE_REJECTED                   0x1D
16847f4e325SMatthias Ringwald #define ERROR_CODE_INVALID_LMP_PARAMETERS_INVALID_LL_PARAMETERS 0x1E
16947f4e325SMatthias Ringwald #define ERROR_CODE_UNSPECIFIED_ERROR                       0x1F
17047f4e325SMatthias Ringwald #define ERROR_CODE_UNSUPPORTED_LMP_PARAMETER_VALUE_UNSUPPORTED_LL_PARAMETER_VALUE 0x20
17147f4e325SMatthias Ringwald #define ERROR_CODE_ROLE_CHANGE_NOT_ALLOWED                 0x21
17247f4e325SMatthias Ringwald #define ERROR_CODE_LMP_RESPONSE_TIMEOUT_LL_RESPONSE_TIMEOUT 0x22
17347f4e325SMatthias Ringwald #define ERROR_CODE_LMP_ERROR_TRANSACTION_COLLISION         0x23
17447f4e325SMatthias Ringwald #define ERROR_CODE_LMP_PDU_NOT_ALLOWED                     0x24
17547f4e325SMatthias Ringwald #define ERROR_CODE_ENCRYPTION_MODE_NOT_ACCEPTABLE          0x25
17647f4e325SMatthias Ringwald #define ERROR_CODE_LINK_KEY_CANNOT_BE_CHANGED              0x26
17747f4e325SMatthias Ringwald #define ERROR_CODE_REQUESTED_QOS_NOT_SUPPORTED             0x27
17847f4e325SMatthias Ringwald #define ERROR_CODE_INSTANT_PASSED                          0x28
17947f4e325SMatthias Ringwald #define ERROR_CODE_PAIRING_WITH_UNIT_KEY_NOT_SUPPORTED     0x29
18047f4e325SMatthias Ringwald #define ERROR_CODE_DIFFERENT_TRANSACTION_COLLISION         0x2A
18147f4e325SMatthias Ringwald #define ERROR_CODE_RESERVED                                0x2B
18247f4e325SMatthias Ringwald #define ERROR_CODE_QOS_UNACCEPTABLE_PARAMETER              0x2C
18347f4e325SMatthias Ringwald #define ERROR_CODE_QOS_REJECTED                            0x2D
18447f4e325SMatthias Ringwald #define ERROR_CODE_CHANNEL_CLASSIFICATION_NOT_SUPPORTED    0x2E
18547f4e325SMatthias Ringwald #define ERROR_CODE_INSUFFICIENT_SECURITY                   0x2F
18647f4e325SMatthias Ringwald #define ERROR_CODE_PARAMETER_OUT_OF_MANDATORY_RANGE        0x30
18747f4e325SMatthias Ringwald // #define ERROR_CODE_RESERVED
18847f4e325SMatthias Ringwald #define ERROR_CODE_ROLE_SWITCH_PENDING                     0x32
18947f4e325SMatthias Ringwald // #define ERROR_CODE_RESERVED
19047f4e325SMatthias Ringwald #define ERROR_CODE_RESERVED_SLOT_VIOLATION                 0x34
19147f4e325SMatthias Ringwald #define ERROR_CODE_ROLE_SWITCH_FAILED                      0x35
19247f4e325SMatthias Ringwald #define ERROR_CODE_EXTENDED_INQUIRY_RESPONSE_TOO_LARGE     0x36
19347f4e325SMatthias Ringwald #define ERROR_CODE_SECURE_SIMPLE_PAIRING_NOT_SUPPORTED_BY_HOST 0x37
19447f4e325SMatthias Ringwald #define ERROR_CODE_HOST_BUSY_PAIRING                       0x38
19547f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_REJECTED_DUE_TO_NO_SUITABLE_CHANNEL_FOUND 0x39
19647f4e325SMatthias Ringwald #define ERROR_CODE_CONTROLLER_BUSY                         0x3A
19747f4e325SMatthias Ringwald #define ERROR_CODE_UNACCEPTABLE_CONNECTION_PARAMETERS      0x3B
19847f4e325SMatthias Ringwald #define ERROR_CODE_DIRECTED_ADVERTISING_TIMEOUT            0x3C
19947f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_TERMINATED_DUE_TO_MIC_FAILURE 0x3D
20047f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_FAILED_TO_BE_ESTABLISHED     0x3E
20147f4e325SMatthias Ringwald #define ERROR_CODE_MAC_CONNECTION_FAILED                   0x3F
20247f4e325SMatthias Ringwald #define ERROR_CODE_COARSE_CLOCK_ADJUSTMENT_REJECTED_BUT_WILL_TRY_TO_ADJUST_USING_CLOCK_DRAGGING 0x40
203*f193890fSMatthias Ringwald /* ENUM_END */
20447f4e325SMatthias Ringwald 
2058799c043SMatthias Ringwald // HCI roles
2068799c043SMatthias Ringwald #define HCI_ROLE_MASTER 0
2078799c043SMatthias Ringwald #define HCI_ROLE_SLAVE  1
2088799c043SMatthias Ringwald 
2098799c043SMatthias Ringwald // packet sizes (max payload)
2108799c043SMatthias Ringwald #define HCI_ACL_DM1_SIZE            17
2118799c043SMatthias Ringwald #define HCI_ACL_DH1_SIZE            27
2128799c043SMatthias Ringwald #define HCI_ACL_2DH1_SIZE           54
2138799c043SMatthias Ringwald #define HCI_ACL_3DH1_SIZE           83
2148799c043SMatthias Ringwald #define HCI_ACL_DM3_SIZE           121
2158799c043SMatthias Ringwald #define HCI_ACL_DH3_SIZE           183
2168799c043SMatthias Ringwald #define HCI_ACL_DM5_SIZE           224
2178799c043SMatthias Ringwald #define HCI_ACL_DH5_SIZE           339
2188799c043SMatthias Ringwald #define HCI_ACL_2DH3_SIZE          367
2198799c043SMatthias Ringwald #define HCI_ACL_3DH3_SIZE          552
2208799c043SMatthias Ringwald #define HCI_ACL_2DH5_SIZE          679
2218799c043SMatthias Ringwald #define HCI_ACL_3DH5_SIZE         1021
2228799c043SMatthias Ringwald 
2238799c043SMatthias Ringwald #define HCI_EVENT_PAYLOAD_SIZE     255
2248799c043SMatthias Ringwald #define HCI_CMD_PAYLOAD_SIZE       255
2258799c043SMatthias Ringwald 
2268799c043SMatthias Ringwald #define LE_ADVERTISING_DATA_SIZE    31
22747f4e325SMatthias Ringwald 
22847f4e325SMatthias Ringwald /**
22947f4e325SMatthias Ringwald  * Default INQ Mode
23047f4e325SMatthias Ringwald  */
23147f4e325SMatthias Ringwald #define HCI_INQUIRY_LAP 0x9E8B33L  // 0x9E8B33: General/Unlimited Inquiry Access Code (GIAC)
23247f4e325SMatthias Ringwald 
23347f4e325SMatthias Ringwald /**
23447f4e325SMatthias Ringwald  * SSP IO Capabilities
23547f4e325SMatthias Ringwald  */
23647f4e325SMatthias Ringwald #define SSP_IO_CAPABILITY_DISPLAY_ONLY   0
23747f4e325SMatthias Ringwald #define SSP_IO_CAPABILITY_DISPLAY_YES_NO 1
23847f4e325SMatthias Ringwald #define SSP_IO_CAPABILITY_KEYBOARD_ONLY  2
23947f4e325SMatthias Ringwald #define SSP_IO_CAPABILITY_NO_INPUT_NO_OUTPUT 3
24047f4e325SMatthias Ringwald #define SSP_IO_CAPABILITY_UNKNOWN 0xff
24147f4e325SMatthias Ringwald 
24247f4e325SMatthias Ringwald 
24347f4e325SMatthias Ringwald /**
24447f4e325SMatthias Ringwald  * SSP Authentication Requirements, see IO Capability Request Reply Commmand
24547f4e325SMatthias Ringwald  */
24647f4e325SMatthias Ringwald 
24747f4e325SMatthias Ringwald // Numeric comparison with automatic accept allowed.
24847f4e325SMatthias Ringwald #define SSP_IO_AUTHREQ_MITM_PROTECTION_NOT_REQUIRED_NO_BONDING 0x00
24947f4e325SMatthias Ringwald 
25047f4e325SMatthias Ringwald // Use IO Capabilities to deter- mine authentication procedure
25147f4e325SMatthias Ringwald #define SSP_IO_AUTHREQ_MITM_PROTECTION_REQUIRED_NO_BONDING 0x01
25247f4e325SMatthias Ringwald 
25347f4e325SMatthias Ringwald // Numeric compar- ison with automatic accept allowed.
25447f4e325SMatthias Ringwald #define SSP_IO_AUTHREQ_MITM_PROTECTION_NOT_REQUIRED_DEDICATED_BONDING 0x02
25547f4e325SMatthias Ringwald 
25647f4e325SMatthias Ringwald // Use IO Capabilities to determine authentication procedure
25747f4e325SMatthias Ringwald #define SSP_IO_AUTHREQ_MITM_PROTECTION_REQUIRED_DEDICATED_BONDING 0x03
25847f4e325SMatthias Ringwald 
25947f4e325SMatthias Ringwald // Numeric Compari- son with automatic accept allowed.
26047f4e325SMatthias Ringwald #define SSP_IO_AUTHREQ_MITM_PROTECTION_NOT_REQUIRED_GENERAL_BONDING 0x04
26147f4e325SMatthias Ringwald 
2628799c043SMatthias Ringwald // Use IO capabilities to determine authentication procedure.
26347f4e325SMatthias Ringwald #define SSP_IO_AUTHREQ_MITM_PROTECTION_REQUIRED_GENERAL_BONDING 0x05
26447f4e325SMatthias Ringwald 
26547f4e325SMatthias Ringwald 
2668799c043SMatthias Ringwald // OGFs
2678799c043SMatthias Ringwald #define OGF_LINK_CONTROL          0x01
2688799c043SMatthias Ringwald #define OGF_LINK_POLICY           0x02
2698799c043SMatthias Ringwald #define OGF_CONTROLLER_BASEBAND   0x03
2708799c043SMatthias Ringwald #define OGF_INFORMATIONAL_PARAMETERS 0x04
2718799c043SMatthias Ringwald #define OGF_STATUS_PARAMETERS     0x05
2728799c043SMatthias Ringwald #define OGF_TESTING               0x06
2738799c043SMatthias Ringwald #define OGF_LE_CONTROLLER 0x08
2748799c043SMatthias Ringwald #define OGF_VENDOR  0x3f
2758799c043SMatthias Ringwald 
2768799c043SMatthias Ringwald 
27747f4e325SMatthias Ringwald // Events from host controller to host
27847f4e325SMatthias Ringwald 
27947f4e325SMatthias Ringwald /**
28047f4e325SMatthias Ringwald  * @format 1
28147f4e325SMatthias Ringwald  * @param status
28247f4e325SMatthias Ringwald  */
28347f4e325SMatthias Ringwald #define HCI_EVENT_INQUIRY_COMPLETE                         0x01
28447f4e325SMatthias Ringwald 
28547f4e325SMatthias Ringwald /**
28647f4e325SMatthias Ringwald  * @format 1B11132
28747f4e325SMatthias Ringwald  * @param num_responses
28847f4e325SMatthias Ringwald  * @param bd_addr
28947f4e325SMatthias Ringwald  * @param page_scan_repetition_mode
29047f4e325SMatthias Ringwald  * @param reserved1
29147f4e325SMatthias Ringwald  * @param reserved2
29247f4e325SMatthias Ringwald  * @param class_of_device
29347f4e325SMatthias Ringwald  * @param clock_offset
29447f4e325SMatthias Ringwald  */
29547f4e325SMatthias Ringwald #define HCI_EVENT_INQUIRY_RESULT                           0x02
29647f4e325SMatthias Ringwald 
29747f4e325SMatthias Ringwald /**
29847f4e325SMatthias Ringwald  * @format 12B11
29947f4e325SMatthias Ringwald  * @param status
30047f4e325SMatthias Ringwald  * @param connection_handle
30147f4e325SMatthias Ringwald  * @param bd_addr
30247f4e325SMatthias Ringwald  * @param link_type
30347f4e325SMatthias Ringwald  * @param encryption_enabled
30447f4e325SMatthias Ringwald  */
30547f4e325SMatthias Ringwald #define HCI_EVENT_CONNECTION_COMPLETE                      0x03
30647f4e325SMatthias Ringwald /**
30747f4e325SMatthias Ringwald  * @format B31
30847f4e325SMatthias Ringwald  * @param bd_addr
30947f4e325SMatthias Ringwald  * @param class_of_device
31047f4e325SMatthias Ringwald  * @param link_type
31147f4e325SMatthias Ringwald  */
31247f4e325SMatthias Ringwald #define HCI_EVENT_CONNECTION_REQUEST                       0x04
31347f4e325SMatthias Ringwald /**
31447f4e325SMatthias Ringwald  * @format 121
31547f4e325SMatthias Ringwald  * @param status
31647f4e325SMatthias Ringwald  * @param connection_handle
31747f4e325SMatthias Ringwald  * @param reason
31847f4e325SMatthias Ringwald  */
31947f4e325SMatthias Ringwald #define HCI_EVENT_DISCONNECTION_COMPLETE                   0x05
32047f4e325SMatthias Ringwald /**
32147f4e325SMatthias Ringwald  * @format 12
32247f4e325SMatthias Ringwald  * @param status
32347f4e325SMatthias Ringwald  * @param connection_handle
32447f4e325SMatthias Ringwald  */
32547f4e325SMatthias Ringwald #define HCI_EVENT_AUTHENTICATION_COMPLETE_EVENT            0x06
32647f4e325SMatthias Ringwald /**
32747f4e325SMatthias Ringwald  * @format 1BN
32847f4e325SMatthias Ringwald  * @param status
32947f4e325SMatthias Ringwald  * @param bd_addr
33047f4e325SMatthias Ringwald  * @param remote_name
33147f4e325SMatthias Ringwald  */
33247f4e325SMatthias Ringwald #define HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE             0x07
33347f4e325SMatthias Ringwald /**
33447f4e325SMatthias Ringwald  * @format 121
33547f4e325SMatthias Ringwald  * @param status
33647f4e325SMatthias Ringwald  * @param connection_handle
33747f4e325SMatthias Ringwald  * @param encryption_enabled
33847f4e325SMatthias Ringwald  */
33947f4e325SMatthias Ringwald #define HCI_EVENT_ENCRYPTION_CHANGE                        0x08
34047f4e325SMatthias Ringwald /**
34147f4e325SMatthias Ringwald  * @format 12
34247f4e325SMatthias Ringwald  * @param status
34347f4e325SMatthias Ringwald  * @param connection_handle
34447f4e325SMatthias Ringwald  */
34547f4e325SMatthias Ringwald #define HCI_EVENT_CHANGE_CONNECTION_LINK_KEY_COMPLETE      0x09
34647f4e325SMatthias Ringwald /**
34747f4e325SMatthias Ringwald  * @format 121
34847f4e325SMatthias Ringwald  * @param status
34947f4e325SMatthias Ringwald  * @param connection_handle
35047f4e325SMatthias Ringwald  * @param key_flag
35147f4e325SMatthias Ringwald  */
35247f4e325SMatthias Ringwald #define HCI_EVENT_MASTER_LINK_KEY_COMPLETE                 0x0A
353ad71fb17SMatthias Ringwald 
35447f4e325SMatthias Ringwald #define HCI_EVENT_READ_REMOTE_SUPPORTED_FEATURES_COMPLETE  0x0B
355ad71fb17SMatthias Ringwald 
35647f4e325SMatthias Ringwald #define HCI_EVENT_READ_REMOTE_VERSION_INFORMATION_COMPLETE 0x0C
357ad71fb17SMatthias Ringwald 
35847f4e325SMatthias Ringwald #define HCI_EVENT_QOS_SETUP_COMPLETE                       0x0D
35947f4e325SMatthias Ringwald 
36047f4e325SMatthias Ringwald /**
36147f4e325SMatthias Ringwald  * @format 12R
36247f4e325SMatthias Ringwald  * @param num_hci_command_packets
36347f4e325SMatthias Ringwald  * @param command_opcode
36447f4e325SMatthias Ringwald  * @param return_parameters
36547f4e325SMatthias Ringwald  */
36647f4e325SMatthias Ringwald #define HCI_EVENT_COMMAND_COMPLETE                         0x0E
36747f4e325SMatthias Ringwald /**
36847f4e325SMatthias Ringwald  * @format 112
36947f4e325SMatthias Ringwald  * @param status
37047f4e325SMatthias Ringwald  * @param num_hci_command_packets
37147f4e325SMatthias Ringwald  * @param command_opcode
37247f4e325SMatthias Ringwald  */
37347f4e325SMatthias Ringwald #define HCI_EVENT_COMMAND_STATUS                           0x0F
37447f4e325SMatthias Ringwald 
37547f4e325SMatthias Ringwald /**
3762c737695SMatthias Ringwald  * @format 1
37747f4e325SMatthias Ringwald  * @param hardware_code
37847f4e325SMatthias Ringwald  */
37947f4e325SMatthias Ringwald #define HCI_EVENT_HARDWARE_ERROR                           0x10
38047f4e325SMatthias Ringwald 
381ad71fb17SMatthias Ringwald #define HCI_EVENT_FLUSH_OCCURRED                           0x11
38247f4e325SMatthias Ringwald 
38347f4e325SMatthias Ringwald /**
38447f4e325SMatthias Ringwald  * @format 1B1
38547f4e325SMatthias Ringwald  * @param status
38647f4e325SMatthias Ringwald  * @param bd_addr
38747f4e325SMatthias Ringwald  * @param role
38847f4e325SMatthias Ringwald  */
38947f4e325SMatthias Ringwald #define HCI_EVENT_ROLE_CHANGE                              0x12
39047f4e325SMatthias Ringwald 
39110093bf5SMilanka Ringwald // TODO: number_of_handles 1, connection_handle[H*i], hc_num_of_completed_packets[2*i]
39247f4e325SMatthias Ringwald #define HCI_EVENT_NUMBER_OF_COMPLETED_PACKETS              0x13
39310093bf5SMilanka Ringwald 
39410093bf5SMilanka Ringwald /**
39510093bf5SMilanka Ringwald  * @format 1H12
39610093bf5SMilanka Ringwald  * @param status
39710093bf5SMilanka Ringwald  * @param handle
39810093bf5SMilanka Ringwald  * @param mode
39910093bf5SMilanka Ringwald  * @param interval
40010093bf5SMilanka Ringwald  */
40147f4e325SMatthias Ringwald #define HCI_EVENT_MODE_CHANGE_EVENT                        0x14
40210093bf5SMilanka Ringwald 
40310093bf5SMilanka Ringwald // TODO: num_keys, bd_addr[B*i], link_key[16 octets * i]
40447f4e325SMatthias Ringwald #define HCI_EVENT_RETURN_LINK_KEYS                         0x15
40510093bf5SMilanka Ringwald 
40610093bf5SMilanka Ringwald /**
40710093bf5SMilanka Ringwald  * @format B
40810093bf5SMilanka Ringwald  * @param bd_addr
40910093bf5SMilanka Ringwald  */
41047f4e325SMatthias Ringwald #define HCI_EVENT_PIN_CODE_REQUEST                         0x16
41110093bf5SMilanka Ringwald 
41210093bf5SMilanka Ringwald /**
41310093bf5SMilanka Ringwald  * @format B
41410093bf5SMilanka Ringwald  * @param bd_addr
41510093bf5SMilanka Ringwald  */
41647f4e325SMatthias Ringwald #define HCI_EVENT_LINK_KEY_REQUEST                         0x17
41710093bf5SMilanka Ringwald 
41810093bf5SMilanka Ringwald // TODO: bd_addr B, link_key 16octets, key_type 1
41947f4e325SMatthias Ringwald #define HCI_EVENT_LINK_KEY_NOTIFICATION                    0x18
42010093bf5SMilanka Ringwald 
42110093bf5SMilanka Ringwald /**
42210093bf5SMilanka Ringwald  * @format 1
42310093bf5SMilanka Ringwald  * @param link_type
42410093bf5SMilanka Ringwald  */
42547f4e325SMatthias Ringwald #define HCI_EVENT_DATA_BUFFER_OVERFLOW                     0x1A
42610093bf5SMilanka Ringwald 
42710093bf5SMilanka Ringwald /**
42810093bf5SMilanka Ringwald  * @format H1
42910093bf5SMilanka Ringwald  * @param handle
43010093bf5SMilanka Ringwald  * @param lmp_max_slots
43110093bf5SMilanka Ringwald  */
43247f4e325SMatthias Ringwald #define HCI_EVENT_MAX_SLOTS_CHANGED                        0x1B
43310093bf5SMilanka Ringwald 
43410093bf5SMilanka Ringwald /**
43510093bf5SMilanka Ringwald  * @format 1H2
43610093bf5SMilanka Ringwald  * @param status
43710093bf5SMilanka Ringwald  * @param handle
43810093bf5SMilanka Ringwald  * @param clock_offset
43910093bf5SMilanka Ringwald  */
44047f4e325SMatthias Ringwald #define HCI_EVENT_READ_CLOCK_OFFSET_COMPLETE               0x1C
44110093bf5SMilanka Ringwald 
44210093bf5SMilanka Ringwald /**
44310093bf5SMilanka Ringwald  * @format 1H2
44410093bf5SMilanka Ringwald  * @param status
44510093bf5SMilanka Ringwald  * @param handle
446fea5a680SMatthias Ringwald  * @param packet_types
447fea5a680SMatthias Ringwald  * @pnote packet_type is in plural to avoid clash with Java binding Packet.getPacketType()
44810093bf5SMilanka Ringwald  */
449fea5a680SMatthias Ringwald #define HCI_EVENT_CONNECTION_PACKET_TYPE_CHANGED           0x1D
45047f4e325SMatthias Ringwald 
45147f4e325SMatthias Ringwald /**
45247f4e325SMatthias Ringwald  * @format 1B11321
45347f4e325SMatthias Ringwald  * @param num_responses
45447f4e325SMatthias Ringwald  * @param bd_addr
45547f4e325SMatthias Ringwald  * @param page_scan_repetition_mode
45647f4e325SMatthias Ringwald  * @param reserved
45747f4e325SMatthias Ringwald  * @param class_of_device
45847f4e325SMatthias Ringwald  * @param clock_offset
45947f4e325SMatthias Ringwald  * @param rssi
46047f4e325SMatthias Ringwald  */
46147f4e325SMatthias Ringwald #define HCI_EVENT_INQUIRY_RESULT_WITH_RSSI                 0x22
46247f4e325SMatthias Ringwald 
46347f4e325SMatthias Ringwald /**
46447f4e325SMatthias Ringwald  * @format 1HB111221
46547f4e325SMatthias Ringwald  * @param status
46647f4e325SMatthias Ringwald  * @param handle
46747f4e325SMatthias Ringwald  * @param bd_addr
46847f4e325SMatthias Ringwald  * @param link_type
46947f4e325SMatthias Ringwald  * @param transmission_interval
47047f4e325SMatthias Ringwald  * @param retransmission_interval
47147f4e325SMatthias Ringwald  * @param rx_packet_length
47247f4e325SMatthias Ringwald  * @param tx_packet_length
47347f4e325SMatthias Ringwald  * @param air_mode
47447f4e325SMatthias Ringwald  */
47547f4e325SMatthias Ringwald #define HCI_EVENT_SYNCHRONOUS_CONNECTION_COMPLETE          0x2C
47647f4e325SMatthias Ringwald 
47747f4e325SMatthias Ringwald // TODO: serialize extended_inquiry_response and provide parser
47847f4e325SMatthias Ringwald /**
47947f4e325SMatthias Ringwald  * @format 1B11321
48047f4e325SMatthias Ringwald  * @param num_responses
48147f4e325SMatthias Ringwald  * @param bd_addr
48247f4e325SMatthias Ringwald  * @param page_scan_repetition_mode
48347f4e325SMatthias Ringwald  * @param reserved
48447f4e325SMatthias Ringwald  * @param class_of_device
48547f4e325SMatthias Ringwald  * @param clock_offset
48647f4e325SMatthias Ringwald  * @param rssi
48747f4e325SMatthias Ringwald  */
48847f4e325SMatthias Ringwald #define HCI_EVENT_EXTENDED_INQUIRY_RESPONSE                0x2F
48947f4e325SMatthias Ringwald 
49047f4e325SMatthias Ringwald  /**
49147f4e325SMatthias Ringwald   * @format 1H
49247f4e325SMatthias Ringwald   * @param status
49347f4e325SMatthias Ringwald   * @param handle
49447f4e325SMatthias Ringwald   */
49547f4e325SMatthias Ringwald #define HCI_EVENT_ENCRYPTION_KEY_REFRESH_COMPLETE          0x30
49647f4e325SMatthias Ringwald 
49747f4e325SMatthias Ringwald #define HCI_EVENT_IO_CAPABILITY_REQUEST                    0x31
49847f4e325SMatthias Ringwald #define HCI_EVENT_IO_CAPABILITY_RESPONSE                   0x32
499ad71fb17SMatthias Ringwald 
500ad71fb17SMatthias Ringwald /**
501ad71fb17SMatthias Ringwald  * @format B4
502ad71fb17SMatthias Ringwald  * @param bd_addr
503ad71fb17SMatthias Ringwald  * @param numeric_value
504ad71fb17SMatthias Ringwald  */
50547f4e325SMatthias Ringwald #define HCI_EVENT_USER_CONFIRMATION_REQUEST                0x33
506ad71fb17SMatthias Ringwald 
507ad71fb17SMatthias Ringwald /**
508ad71fb17SMatthias Ringwald  * @format B
509ad71fb17SMatthias Ringwald  * @param bd_addr
510ad71fb17SMatthias Ringwald  */
51147f4e325SMatthias Ringwald #define HCI_EVENT_USER_PASSKEY_REQUEST                     0x34
512ad71fb17SMatthias Ringwald 
513ad71fb17SMatthias Ringwald /**
514ad71fb17SMatthias Ringwald  * @format B
515ad71fb17SMatthias Ringwald  * @param bd_addr
516ad71fb17SMatthias Ringwald  */
51747f4e325SMatthias Ringwald #define HCI_EVENT_REMOTE_OOB_DATA_REQUEST                  0x35
518ad71fb17SMatthias Ringwald 
519ad71fb17SMatthias Ringwald /**
520ad71fb17SMatthias Ringwald  * @format 1B
521ad71fb17SMatthias Ringwald  * @param status
522ad71fb17SMatthias Ringwald  * @param bd_addr
523ad71fb17SMatthias Ringwald  */
52447f4e325SMatthias Ringwald #define HCI_EVENT_SIMPLE_PAIRING_COMPLETE                  0x36
52547f4e325SMatthias Ringwald 
52647f4e325SMatthias Ringwald #define HCI_EVENT_LE_META                                  0x3E
52747f4e325SMatthias Ringwald 
52882180fcaSMatthias Ringwald // last used HCI_EVENT in 2.1 is 0x3d
52982180fcaSMatthias Ringwald // last used HCI_EVENT in 4.1 is 0x57
53082180fcaSMatthias Ringwald 
531941b3855SMatthias Ringwald #define HCI_EVENT_VENDOR_SPECIFIC                          0xFF
532941b3855SMatthias Ringwald 
53347f4e325SMatthias Ringwald /**
534ca0d73deSMatthias Ringwald  * @format 11H11B2221
53547f4e325SMatthias Ringwald  * @param subevent_code
53647f4e325SMatthias Ringwald  * @param status
53747f4e325SMatthias Ringwald  * @param connection_handle
53847f4e325SMatthias Ringwald  * @param role
53947f4e325SMatthias Ringwald  * @param peer_address_type
54047f4e325SMatthias Ringwald  * @param peer_address
54147f4e325SMatthias Ringwald  * @param conn_interval
54247f4e325SMatthias Ringwald  * @param conn_latency
54347f4e325SMatthias Ringwald  * @param supervision_timeout
54447f4e325SMatthias Ringwald  * @param master_clock_accuracy
54547f4e325SMatthias Ringwald  */
54647f4e325SMatthias Ringwald #define HCI_SUBEVENT_LE_CONNECTION_COMPLETE                0x01
54782180fcaSMatthias Ringwald 
54882180fcaSMatthias Ringwald // array of advertisements, not handled by event accessor generator
54947f4e325SMatthias Ringwald #define HCI_SUBEVENT_LE_ADVERTISING_REPORT                 0x02
55082180fcaSMatthias Ringwald 
55182180fcaSMatthias Ringwald /**
55282180fcaSMatthias Ringwald  * @format 11H222
55382180fcaSMatthias Ringwald  * @param subevent_code
55482180fcaSMatthias Ringwald  * @param status
55582180fcaSMatthias Ringwald  * @param connection_handle
55682180fcaSMatthias Ringwald  * @param conn_interval
55782180fcaSMatthias Ringwald  * @param conn_latency
5582c737695SMatthias Ringwald  * @param supervision_timeout
55982180fcaSMatthias Ringwald  */
56047f4e325SMatthias Ringwald  #define HCI_SUBEVENT_LE_CONNECTION_UPDATE_COMPLETE         0x03
56182180fcaSMatthias Ringwald 
56282180fcaSMatthias Ringwald /**
56382180fcaSMatthias Ringwald  * @format 1HD2
56482180fcaSMatthias Ringwald  * @param subevent_code
56582180fcaSMatthias Ringwald  * @param connection_handle
56682180fcaSMatthias Ringwald  * @param random_number
56782180fcaSMatthias Ringwald  * @param encryption_diversifier
56882180fcaSMatthias Ringwald  */
56947f4e325SMatthias Ringwald #define HCI_SUBEVENT_LE_READ_REMOTE_USED_FEATURES_COMPLETE 0x04
57082180fcaSMatthias Ringwald 
57182180fcaSMatthias Ringwald /**
57282180fcaSMatthias Ringwald  * @format 1HD2
57382180fcaSMatthias Ringwald  * @param subevent_code
57482180fcaSMatthias Ringwald  * @param connection_handle
57582180fcaSMatthias Ringwald  * @param random_number
57682180fcaSMatthias Ringwald  * @param encryption_diversifier
57782180fcaSMatthias Ringwald  */
57847f4e325SMatthias Ringwald #define HCI_SUBEVENT_LE_LONG_TERM_KEY_REQUEST              0x05
57947f4e325SMatthias Ringwald 
58082180fcaSMatthias Ringwald /**
58182180fcaSMatthias Ringwald  * @format 1H2222
58282180fcaSMatthias Ringwald  * @param subevent_code
58382180fcaSMatthias Ringwald  * @param connection_handle
58482180fcaSMatthias Ringwald  * @param interval_min
58582180fcaSMatthias Ringwald  * @param interval_max
58682180fcaSMatthias Ringwald  * @param latency
58782180fcaSMatthias Ringwald  * @param timeout
58882180fcaSMatthias Ringwald  */
58982180fcaSMatthias Ringwald #define HCI_SUBEVENT_LE_REMOTE_CONNECTION_PARAMETER_REQUEST 0x06
59082180fcaSMatthias Ringwald 
59182180fcaSMatthias Ringwald /**
59282180fcaSMatthias Ringwald  * @format 1H2222
59382180fcaSMatthias Ringwald  * @param subevent_code
59482180fcaSMatthias Ringwald  * @param connection_handle
59582180fcaSMatthias Ringwald  * @param max_tx_octets
59682180fcaSMatthias Ringwald  * @param max_tx_time
59782180fcaSMatthias Ringwald  * @param max_rx_octets
59882180fcaSMatthias Ringwald  * @param max_rx_time
59982180fcaSMatthias Ringwald  */
60082180fcaSMatthias Ringwald #define HCI_SUBEVENT_LE_DATA_LENGTH_CHANGE 0x07
60182180fcaSMatthias Ringwald 
60282180fcaSMatthias Ringwald /**
60382180fcaSMatthias Ringwald  * @format 11QQ
60482180fcaSMatthias Ringwald  * @param subevent_code
60582180fcaSMatthias Ringwald  * @param status
60682180fcaSMatthias Ringwald  * @param dhkey_x x coordinate of P256 public key
60782180fcaSMatthias Ringwald  * @param dhkey_y y coordinate of P256 public key
60882180fcaSMatthias Ringwald  */
60982180fcaSMatthias Ringwald #define HCI_SUBEVENT_LE_READ_LOCAL_P256_PUBLIC_KEY_COMPLETE 0x08
61082180fcaSMatthias Ringwald  /**
61182180fcaSMatthias Ringwald  * @format 11QQ
61282180fcaSMatthias Ringwald  * @param subevent_code
61382180fcaSMatthias Ringwald  * @param status
61482180fcaSMatthias Ringwald  * @param dhkey_x x coordinate of Diffie-Hellman key
61582180fcaSMatthias Ringwald  * @param dhkey_y y coordinate of Diffie-Hellman key
61682180fcaSMatthias Ringwald  */
61782180fcaSMatthias Ringwald #define HCI_SUBEVENT_LE_GENERATE_DHKEY_COMPLETE            0x09
61882180fcaSMatthias Ringwald 
61982180fcaSMatthias Ringwald /**
62082180fcaSMatthias Ringwald  * @format 11H11BBB2221
62182180fcaSMatthias Ringwald  * @param subevent_code
62282180fcaSMatthias Ringwald  * @param status
62382180fcaSMatthias Ringwald  * @param connection_handle
62482180fcaSMatthias Ringwald  * @param role
62582180fcaSMatthias Ringwald  * @param peer_address_type
62682180fcaSMatthias Ringwald  * @param perr_addresss
62782180fcaSMatthias Ringwald  * @param local_resolvable_private_addres
62882180fcaSMatthias Ringwald  * @param peer_resolvable_private_addres
62982180fcaSMatthias Ringwald  * @param conn_interval
63082180fcaSMatthias Ringwald  * @param conn_latency
63182180fcaSMatthias Ringwald  * @param supervision_timeout
63282180fcaSMatthias Ringwald  * @param master_clock_accuracy
63382180fcaSMatthias Ringwald  */
63482180fcaSMatthias Ringwald #define HCI_SUBEVENT_LE_ENHANCED_CONNECTION_COMPLETE       0x0A
63582180fcaSMatthias Ringwald 
63682180fcaSMatthias Ringwald // array of advertisements, not handled by event accessor generator
63782180fcaSMatthias Ringwald #define HCI_SUBEVENT_LE_DIRECT_ADVERTISING_REPORT          0x0B
63847f4e325SMatthias Ringwald 
63947f4e325SMatthias Ringwald /**
64047f4e325SMatthias Ringwald  * L2CAP Layer
64147f4e325SMatthias Ringwald  */
64247f4e325SMatthias Ringwald 
643a8373a41SMatthias Ringwald #define L2CAP_HEADER_SIZE 4
644a8373a41SMatthias Ringwald 
645a8373a41SMatthias Ringwald #define L2CAP_SIG_ID_INVALID 0
646a8373a41SMatthias Ringwald 
647a8373a41SMatthias Ringwald // size of HCI ACL + L2CAP Header for regular data packets (8)
648a8373a41SMatthias Ringwald #define COMPLETE_L2CAP_HEADER (HCI_ACL_HEADER_SIZE + L2CAP_HEADER_SIZE)
649a8373a41SMatthias Ringwald 
650a8373a41SMatthias Ringwald // minimum signaling MTU
651a8373a41SMatthias Ringwald #define L2CAP_MINIMAL_MTU 48
652a8373a41SMatthias Ringwald #define L2CAP_DEFAULT_MTU 672
653a8373a41SMatthias Ringwald 
654a8373a41SMatthias Ringwald // Minimum/default MTU
655a8373a41SMatthias Ringwald #define L2CAP_LE_DEFAULT_MTU  23
656a8373a41SMatthias Ringwald 
657a8373a41SMatthias Ringwald // L2CAP Fixed Channel IDs
658a8373a41SMatthias Ringwald #define L2CAP_CID_SIGNALING                 0x0001
659a8373a41SMatthias Ringwald #define L2CAP_CID_CONNECTIONLESS_CHANNEL    0x0002
660a8373a41SMatthias Ringwald #define L2CAP_CID_ATTRIBUTE_PROTOCOL        0x0004
661a8373a41SMatthias Ringwald #define L2CAP_CID_SIGNALING_LE              0x0005
662a8373a41SMatthias Ringwald #define L2CAP_CID_SECURITY_MANAGER_PROTOCOL 0x0006
663a8373a41SMatthias Ringwald 
664a8373a41SMatthias Ringwald // L2CAP Configuration Result Codes
665a8373a41SMatthias Ringwald #define L2CAP_CONF_RESULT_UNKNOWN_OPTIONS   0x0003
666a8373a41SMatthias Ringwald 
667a8373a41SMatthias Ringwald // L2CAP Reject Result Codes
668a8373a41SMatthias Ringwald #define L2CAP_REJ_CMD_UNKNOWN               0x0000
669a8373a41SMatthias Ringwald 
670a8373a41SMatthias Ringwald // Response Timeout eXpired
671a8373a41SMatthias Ringwald #define L2CAP_RTX_TIMEOUT_MS   10000
672a8373a41SMatthias Ringwald 
673a8373a41SMatthias Ringwald // Extended Response Timeout eXpired
674a8373a41SMatthias Ringwald #define L2CAP_ERTX_TIMEOUT_MS 120000
675a8373a41SMatthias Ringwald 
676dfbc0b0dSMatthias Ringwald //
677dfbc0b0dSMatthias Ringwald // Fixed PSM numbers from https://www.bluetooth.com/specifications/assigned-numbers/logical-link-control
678dfbc0b0dSMatthias Ringwald //
679dfbc0b0dSMatthias Ringwald // @TODO: replace with BLUETOOTH_PROTOCOL_xxx in rest of code
680235946f1SMatthias Ringwald #define PSM_SDP           BLUETOOTH_PROTOCOL_SDP
681235946f1SMatthias Ringwald #define PSM_RFCOMM        BLUETOOTH_PROTOCOL_RFCOMM
682235946f1SMatthias Ringwald #define PSM_BNEP          BLUETOOTH_PROTOCOL_BNEP
683dfbc0b0dSMatthias Ringwald // @TODO: scrape PSMs Bluetooth SIG site and put in bluetooth_psm.h or bluetooth_l2cap.h
68447f4e325SMatthias Ringwald #define PSM_HID_CONTROL   0x11
68547f4e325SMatthias Ringwald #define PSM_HID_INTERRUPT 0x13
686dfbc0b0dSMatthias Ringwald #define PSM_IPSP          0x23
68747f4e325SMatthias Ringwald 
68866b1fcb3SMatthias Ringwald /**
689235946f1SMatthias Ringwald  * SDP Protocol
690ef907034SMatthias Ringwald  */
691ef907034SMatthias Ringwald 
692ef907034SMatthias Ringwald  // PDU Types
693ef907034SMatthias Ringwald typedef enum {
694ef907034SMatthias Ringwald     SDP_Invalid = 0,
695ef907034SMatthias Ringwald     SDP_ErrorResponse = 1,
696ef907034SMatthias Ringwald     SDP_ServiceSearchRequest,
697ef907034SMatthias Ringwald     SDP_ServiceSearchResponse,
698ef907034SMatthias Ringwald     SDP_ServiceAttributeRequest,
699ef907034SMatthias Ringwald     SDP_ServiceAttributeResponse,
700ef907034SMatthias Ringwald     SDP_ServiceSearchAttributeRequest,
701ef907034SMatthias Ringwald     SDP_ServiceSearchAttributeResponse
702ef907034SMatthias Ringwald } SDP_PDU_ID_t;
703ef907034SMatthias Ringwald 
704235946f1SMatthias Ringwald /* Please use assigned numbers from bluetooth_sdp.h instead for thsese ...*/
705235946f1SMatthias Ringwald 
706ef907034SMatthias Ringwald // UNIVERSAL ATTRIBUTE DEFINITIONS
707235946f1SMatthias Ringwald #define SDP_ServiceRecordHandle               BLUETOOTH_ATTRIBUTE_SERVICE_RECORD_HANDLE
708235946f1SMatthias Ringwald #define SDP_ServiceClassIDList                BLUETOOTH_ATTRIBUTE_SERVICE_CLASS_ID_LIST
709235946f1SMatthias Ringwald #define SDP_ServiceRecordState                BLUETOOTH_ATTRIBUTE_SERVICE_RECORD_STATE
710235946f1SMatthias Ringwald #define SDP_ServiceID                         BLUETOOTH_ATTRIBUTE_SERVICE_ID
711235946f1SMatthias Ringwald #define SDP_ProtocolDescriptorList            BLUETOOTH_ATTRIBUTE_PROTOCOL_DESCRIPTOR_LIST
712235946f1SMatthias Ringwald #define SDP_BrowseGroupList                   BLUETOOTH_ATTRIBUTE_BROWSE_GROUP_LIST
713235946f1SMatthias Ringwald #define SDP_LanguageBaseAttributeIDList       BLUETOOTH_ATTRIBUTE_LANGUAGE_BASE_ATTRIBUTE_ID_LIST
714235946f1SMatthias Ringwald #define SDP_ServiceInfoTimeToLive             BLUETOOTH_ATTRIBUTE_SERVICE_INFO_TIME_TO_LIVE
715235946f1SMatthias Ringwald #define SDP_ServiceAvailability               BLUETOOTH_ATTRIBUTE_SERVICE_AVAILABILITY
716235946f1SMatthias Ringwald #define SDP_BluetoothProfileDescriptorList    BLUETOOTH_ATTRIBUTE_BLUETOOTH_PROFILE_DESCRIPTOR_LIST
717235946f1SMatthias Ringwald #define SDP_DocumentationURL                  BLUETOOTH_ATTRIBUTE_DOCUMENTATION_URL
718235946f1SMatthias Ringwald #define SDP_ClientExecutableURL               BLUETOOTH_ATTRIBUTE_CLIENT_EXECUTABLE_URL
719235946f1SMatthias Ringwald #define SDP_IconURL                           BLUETOOTH_ATTRIBUTE_ICON_URL
720235946f1SMatthias Ringwald #define SDP_AdditionalProtocolDescriptorList  BLUETOOTH_ATTRIBUTE_ADDITIONAL_PROTOCOL_DESCRIPTOR_LISTS
721235946f1SMatthias Ringwald #define SDP_SupportedFormatsList              BLUETOOTH_ATTRIBUTE_SUPPORTED_FORMATS_LIST
722ef907034SMatthias Ringwald 
723ef907034SMatthias Ringwald // SERVICE CLASSES
724235946f1SMatthias Ringwald #define SDP_OBEXObjectPush                    BLUETOOTH_SERVICE_CLASS_OBEX_OBJECT_PUSH
725235946f1SMatthias Ringwald #define SDP_OBEXFileTransfer                  BLUETOOTH_SERVICE_CLASS_OBEX_FILE_TRANSFER
726235946f1SMatthias Ringwald #define SDP_PublicBrowseGroup                 BLUETOOTH_ATTRIBUTE_PUBLIC_BROWSE_ROOT
727235946f1SMatthias Ringwald #define SDP_HSP                               BLUETOOTH_SERVICE_CLASS_HEADSET
728235946f1SMatthias Ringwald #define SDP_Headset_AG                        BLUETOOTH_SERVICE_CLASS_HEADSET_AUDIO_GATEWAY_AG
729235946f1SMatthias Ringwald #define SDP_PANU                              BLUETOOTH_SERVICE_CLASS_PANU
730235946f1SMatthias Ringwald #define SDP_NAP                               BLUETOOTH_SERVICE_CLASS_NAP
731235946f1SMatthias Ringwald #define SDP_GN                                BLUETOOTH_SERVICE_CLASS_GN
732235946f1SMatthias Ringwald #define SDP_Handsfree                         BLUETOOTH_SERVICE_CLASS_HANDSFREE
733235946f1SMatthias Ringwald #define SDP_HandsfreeAudioGateway             BLUETOOTH_SERVICE_CLASS_HANDSFREE_AUDIO_GATEWAY
734235946f1SMatthias Ringwald #define SDP_Headset_HS                        BLUETOOTH_SERVICE_CLASS_HEADSET_HS
735235946f1SMatthias Ringwald #define SDP_GenericAudio                      BLUETOOTH_SERVICE_CLASS_GENERIC_AUDIO
736ef907034SMatthias Ringwald 
737ef907034SMatthias Ringwald // PROTOCOLS
738235946f1SMatthias Ringwald #define SDP_SDPProtocol                       BLUETOOTH_PROTOCOL_SDP
739235946f1SMatthias Ringwald #define SDP_UDPProtocol                       BLUETOOTH_PROTOCOL_UDP
740235946f1SMatthias Ringwald #define SDP_RFCOMMProtocol                    BLUETOOTH_PROTOCOL_RFCOMM
741235946f1SMatthias Ringwald #define SDP_OBEXProtocol                      BLUETOOTH_PROTOCOL_OBEX
742235946f1SMatthias Ringwald #define SDP_L2CAPProtocol                     BLUETOOTH_PROTOCOL_L2CAP
743235946f1SMatthias Ringwald #define SDP_BNEPProtocol                      BLUETOOTH_PROTOCOL_BNEP
744235946f1SMatthias Ringwald #define SDP_AVDTPProtocol                     BLUETOOTH_PROTOCOL_AVDTP
745235946f1SMatthias Ringwald 
746235946f1SMatthias Ringwald /** .. until here ..*/
747ef907034SMatthias Ringwald 
748ef907034SMatthias Ringwald // OFFSETS FOR LOCALIZED ATTRIBUTES - SDP_LanguageBaseAttributeIDList
749ef907034SMatthias Ringwald #define SDP_Offest_ServiceName      0x0000
750ef907034SMatthias Ringwald #define SDP_Offest_ServiceDescription 0x0001
751ef907034SMatthias Ringwald #define SDP_Offest_ProviderName     0x0002
752ef907034SMatthias Ringwald 
753c4b3290dSMatthias Ringwald // Device Vendor ID Sources
754c4b3290dSMatthias Ringwald #define DEVICE_ID_VENDOR_ID_SOURCE_BLUETOOTH 0x0001
755c4b3290dSMatthias Ringwald #define DEVICE_ID_VENDOR_ID_SOURCE_USB       0x0002
756c4b3290dSMatthias Ringwald 
757ef907034SMatthias Ringwald // OBEX
758ef907034SMatthias Ringwald #define SDP_vCard_2_1       0x01
759ef907034SMatthias Ringwald #define SDP_vCard_3_0       0x02
760ef907034SMatthias Ringwald #define SDP_vCal_1_0        0x03
761ef907034SMatthias Ringwald #define SDP_iCal_2_0        0x04
762ef907034SMatthias Ringwald #define SDP_vNote           0x05
763ef907034SMatthias Ringwald #define SDP_vMessage        0x06
764ef907034SMatthias Ringwald #define SDP_OBEXFileTypeAny 0xFF
765ef907034SMatthias Ringwald 
766ef907034SMatthias Ringwald /**
767e2577bd7SMatthias Ringwald  * RFCOMM Protocol
768e2577bd7SMatthias Ringwald  */
769e2577bd7SMatthias Ringwald 
770e2577bd7SMatthias Ringwald // Control field values      bit no.       1 2 3 4 PF 6 7 8
771e2577bd7SMatthias Ringwald #define BT_RFCOMM_SABM       0x3F       // 1 1 1 1  1 1 0 0
772e2577bd7SMatthias Ringwald #define BT_RFCOMM_UA         0x73       // 1 1 0 0  1 1 1 0
773e2577bd7SMatthias Ringwald #define BT_RFCOMM_DM         0x0F       // 1 1 1 1  0 0 0 0
774e2577bd7SMatthias Ringwald #define BT_RFCOMM_DM_PF      0x1F       // 1 1 1 1  1 0 0 0
775e2577bd7SMatthias Ringwald #define BT_RFCOMM_DISC       0x53       // 1 1 0 0  1 0 1 0
776e2577bd7SMatthias Ringwald #define BT_RFCOMM_UIH        0xEF       // 1 1 1 1  0 1 1 1
777e2577bd7SMatthias Ringwald #define BT_RFCOMM_UIH_PF     0xFF       // 1 1 1 1  0 1 1 1
778e2577bd7SMatthias Ringwald 
779e2577bd7SMatthias Ringwald // Multiplexer message types
780e2577bd7SMatthias Ringwald #define BT_RFCOMM_CLD_CMD    0xC3
781e2577bd7SMatthias Ringwald #define BT_RFCOMM_FCON_CMD   0xA3
782e2577bd7SMatthias Ringwald #define BT_RFCOMM_FCON_RSP   0xA1
783e2577bd7SMatthias Ringwald #define BT_RFCOMM_FCOFF_CMD  0x63
784e2577bd7SMatthias Ringwald #define BT_RFCOMM_FCOFF_RSP  0x61
785e2577bd7SMatthias Ringwald #define BT_RFCOMM_MSC_CMD    0xE3
786e2577bd7SMatthias Ringwald #define BT_RFCOMM_MSC_RSP    0xE1
787e2577bd7SMatthias Ringwald #define BT_RFCOMM_NSC_RSP    0x11
788e2577bd7SMatthias Ringwald #define BT_RFCOMM_PN_CMD     0x83
789e2577bd7SMatthias Ringwald #define BT_RFCOMM_PN_RSP     0x81
790e2577bd7SMatthias Ringwald #define BT_RFCOMM_RLS_CMD    0x53
791e2577bd7SMatthias Ringwald #define BT_RFCOMM_RLS_RSP    0x51
792e2577bd7SMatthias Ringwald #define BT_RFCOMM_RPN_CMD    0x93
793e2577bd7SMatthias Ringwald #define BT_RFCOMM_RPN_RSP    0x91
794e2577bd7SMatthias Ringwald #define BT_RFCOMM_TEST_CMD   0x23
795e2577bd7SMatthias Ringwald #define BT_RFCOMM_TEST_RSP   0x21
796e2577bd7SMatthias Ringwald 
797e2577bd7SMatthias Ringwald // Line Status
798e2577bd7SMatthias Ringwald #define LINE_STATUS_NO_ERROR       0x00
799e2577bd7SMatthias Ringwald #define LINE_STATUS_OVERRUN_ERROR  0x03
800e2577bd7SMatthias Ringwald #define LINE_STATUS_PARITY_ERORR   0x05
801e2577bd7SMatthias Ringwald #define LINE_STATUS_FRAMING_ERROR  0x09
802e2577bd7SMatthias Ringwald 
803e2577bd7SMatthias Ringwald // Modem Status Flags
804e2577bd7SMatthias Ringwald #define MODEM_STATUS_FC   0x02
805e2577bd7SMatthias Ringwald #define MODEM_STATUS_RTC  0x04
806e2577bd7SMatthias Ringwald #define MODEM_STATUS_RTR  0x08
807e2577bd7SMatthias Ringwald #define MODEM_STATUS_IC   0x40
808e2577bd7SMatthias Ringwald #define MODEM_STATUS_DV   0x80
809e2577bd7SMatthias Ringwald 
810e2577bd7SMatthias Ringwald typedef enum rpn_baud {
811e2577bd7SMatthias Ringwald     RPN_BAUD_2400 = 0,
812e2577bd7SMatthias Ringwald     RPN_BAUD_4800,
813e2577bd7SMatthias Ringwald     RPN_BAUD_7200,
814e2577bd7SMatthias Ringwald     RPN_BAUD_9600,
815e2577bd7SMatthias Ringwald     RPN_BAUD_19200,
816e2577bd7SMatthias Ringwald     RPN_BAUD_38400,
817e2577bd7SMatthias Ringwald     RPN_BAUD_57600,
818e2577bd7SMatthias Ringwald     RPN_BAUD_115200,
819e2577bd7SMatthias Ringwald     RPN_BAUD_230400
820e2577bd7SMatthias Ringwald } rpn_baud_t;
821e2577bd7SMatthias Ringwald 
822e2577bd7SMatthias Ringwald typedef enum rpn_data_bits {
823e2577bd7SMatthias Ringwald     RPN_DATA_BITS_5 = 0,
824e2577bd7SMatthias Ringwald     RPN_DATA_BITS_6 = 0,
825e2577bd7SMatthias Ringwald     RPN_DATA_BITS_7 = 0,
826e2577bd7SMatthias Ringwald     RPN_DATA_BITS_8 = 0
827e2577bd7SMatthias Ringwald } rpn_data_bits_t;
828e2577bd7SMatthias Ringwald 
829e2577bd7SMatthias Ringwald typedef enum rpn_stop_bits {
830e2577bd7SMatthias Ringwald     RPN_STOP_BITS_1_0 = 0,
831e2577bd7SMatthias Ringwald     RPN_STOP_BITS_1_5
832e2577bd7SMatthias Ringwald } rpn_stop_bits_t;
833e2577bd7SMatthias Ringwald 
834e2577bd7SMatthias Ringwald typedef enum rpn_parity {
835e2577bd7SMatthias Ringwald     RPN_PARITY_NONE  = 0,
836e2577bd7SMatthias Ringwald     RPN_PARITY_ODD   = 1,
837e2577bd7SMatthias Ringwald     RPN_PARITY_EVEN  = 3,
838e2577bd7SMatthias Ringwald     RPN_PARITY_MARK  = 5,
839e2577bd7SMatthias Ringwald     RPN_PARITY_SPACE = 7,
840e2577bd7SMatthias Ringwald } rpn_parity_t;
841e2577bd7SMatthias Ringwald 
842e2577bd7SMatthias Ringwald typedef enum rpn_flow_control {
843e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_XONXOFF_ON_INPUT  = 1 << 0,
844e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_XONXOFF_ON_OUTPUT = 1 << 1,
845e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_RTR_ON_INPUT  = 1 << 2,
846e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_RTR_ON_OUTPUT = 1 << 3,
847e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_RTC_ON_INPUT  = 1 << 4,
848e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_RTC_ON_OUTPUT = 1 << 5,
849e2577bd7SMatthias Ringwald } rpn_flow_control_t;
850e2577bd7SMatthias Ringwald 
851e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_BAUD             0x01
852e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_DATA_BITS        0x02
853e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_STOP_BITS        0x04
854e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_PARITY           0x08
855e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_PARITY_TYPE      0x10
856e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_XON_CHAR         0x20
857e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_XOFF_CHAR        0x40
858e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_RESERVED         0x80
859e2577bd7SMatthias Ringwald 
860e2577bd7SMatthias Ringwald // @note: values are identical to rpn_flow_control_t
861e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_XONOFF_ON_INPUT  0x01
862e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_XONOFF_ON_OUTPUT 0x02
863e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RTR_ON_INPUT     0x04
864e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RTR_ON_OUTPUT    0x08
865e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RTC_ON_INPUT     0x10
866e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RTC_ON_OUTPUT    0x20
867e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RESERVED_0       0x40
868e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RESERVED_1       0x80
869e2577bd7SMatthias Ringwald 
870e2577bd7SMatthias Ringwald /**
87166b1fcb3SMatthias Ringwald  * BNEP Protocol
87266b1fcb3SMatthias Ringwald  */
87347f4e325SMatthias Ringwald 
87466b1fcb3SMatthias Ringwald #ifndef ETHER_ADDR_LEN
8759a73f75dSMatthias Ringwald #define ETHER_ADDR_LEN 6
87666b1fcb3SMatthias Ringwald #endif
87747f4e325SMatthias Ringwald 
87866b1fcb3SMatthias Ringwald #ifndef ETHERTYPE_VLAN
87966b1fcb3SMatthias Ringwald #define ETHERTYPE_VLAN                                  0x8100 /* IEEE 802.1Q VLAN tag */
88066b1fcb3SMatthias Ringwald #endif
88166b1fcb3SMatthias Ringwald 
88266b1fcb3SMatthias Ringwald #define BNEP_MTU_MIN                                    1691
88366b1fcb3SMatthias Ringwald 
88466b1fcb3SMatthias Ringwald #define BNEP_EXT_FLAG                                   0x80
88566b1fcb3SMatthias Ringwald #define BNEP_TYPE_MASK                                  0x7F
88666b1fcb3SMatthias Ringwald #define BNEP_TYPE(header)                               ((header) & BNEP_TYPE_MASK)
88766b1fcb3SMatthias Ringwald #define BNEP_HEADER_HAS_EXT(x)                          (((x) & BNEP_EXT_FLAG) == BNEP_EXT_FLAG)
88866b1fcb3SMatthias Ringwald 
88966b1fcb3SMatthias Ringwald /* BNEP packet types */
89066b1fcb3SMatthias Ringwald #define BNEP_PKT_TYPE_GENERAL_ETHERNET                  0x00
89166b1fcb3SMatthias Ringwald #define BNEP_PKT_TYPE_CONTROL                           0x01
89266b1fcb3SMatthias Ringwald #define BNEP_PKT_TYPE_COMPRESSED_ETHERNET               0x02
89366b1fcb3SMatthias Ringwald #define BNEP_PKT_TYPE_COMPRESSED_ETHERNET_SOURCE_ONLY   0x03
89466b1fcb3SMatthias Ringwald #define BNEP_PKT_TYPE_COMPRESSED_ETHERNET_DEST_ONLY     0x04
89566b1fcb3SMatthias Ringwald 
89666b1fcb3SMatthias Ringwald /* BNEP control types */
89766b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_COMMAND_NOT_UNDERSTOOD        0x00
89866b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_SETUP_CONNECTION_REQUEST      0x01
89966b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_SETUP_CONNECTION_RESPONSE     0x02
90066b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_FILTER_NET_TYPE_SET           0x03
90166b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_FILTER_NET_TYPE_RESPONSE      0x04
90266b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_FILTER_MULTI_ADDR_SET         0x05
90366b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_FILTER_MULTI_ADDR_RESPONSE    0x06
90466b1fcb3SMatthias Ringwald 
90566b1fcb3SMatthias Ringwald /* BNEP extension header types */
90666b1fcb3SMatthias Ringwald #define BNEP_EXT_HEADER_TYPE_EXTENSION_CONTROL          0x00
90766b1fcb3SMatthias Ringwald 
90866b1fcb3SMatthias Ringwald /* BNEP setup response codes */
90966b1fcb3SMatthias Ringwald #define BNEP_RESP_SETUP_SUCCESS                         0x0000
91066b1fcb3SMatthias Ringwald #define BNEP_RESP_SETUP_INVALID_DEST_UUID               0x0001
91166b1fcb3SMatthias Ringwald #define BNEP_RESP_SETUP_INVALID_SOURCE_UUID             0x0002
91266b1fcb3SMatthias Ringwald #define BNEP_RESP_SETUP_INVALID_SERVICE_UUID_SIZE       0x0003
91366b1fcb3SMatthias Ringwald #define BNEP_RESP_SETUP_CONNECTION_NOT_ALLOWED          0x0004
91466b1fcb3SMatthias Ringwald 
91566b1fcb3SMatthias Ringwald /* BNEP filter response codes */
91666b1fcb3SMatthias Ringwald #define BNEP_RESP_FILTER_SUCCESS                        0x0000
91766b1fcb3SMatthias Ringwald #define BNEP_RESP_FILTER_UNSUPPORTED_REQUEST            0x0001
91866b1fcb3SMatthias Ringwald #define BNEP_RESP_FILTER_ERR_INVALID_RANGE              0x0002
91966b1fcb3SMatthias Ringwald #define BNEP_RESP_FILTER_ERR_TOO_MANY_FILTERS           0x0003
92066b1fcb3SMatthias Ringwald #define BNEP_RESP_FILTER_ERR_SECURITY                   0x0004
92166b1fcb3SMatthias Ringwald 
92266b1fcb3SMatthias Ringwald /**
92366b1fcb3SMatthias Ringwald  * PAN Profile
92466b1fcb3SMatthias Ringwald  */
92566b1fcb3SMatthias Ringwald 
92666b1fcb3SMatthias Ringwald typedef enum {
92766b1fcb3SMatthias Ringwald     BNEP_SECURITY_NONE = 0x0000,
92866b1fcb3SMatthias Ringwald     BNEP_SECURITY_SERVICE_LEVEL_ENFORCED,
92966b1fcb3SMatthias Ringwald     BNEP_SECURITY_802_1X
93066b1fcb3SMatthias Ringwald } security_description_t;
93166b1fcb3SMatthias Ringwald 
93266b1fcb3SMatthias Ringwald typedef enum {
93366b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_PSTN = 0x0000,
93466b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_ISDN,
93566b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_DSL,
93666b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_CABLE_MODEM,
93766b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_10MB_ETHERNET,
93866b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_100MB_ETHERNET,
93966b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_4MB_TOKEN_RING,
94066b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_16MB_TOKEN_RING,
94166b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_100MB_TOKEN_RING,
94266b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_FDDI,
94366b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_GSM,
94466b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_CDMA,
94566b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_GPRS,
94666b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_3G,
94766b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_CELULAR,
94866b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_OTHER = 0xFFFE,
94966b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_NONE
95066b1fcb3SMatthias Ringwald } net_access_type_t;
95147f4e325SMatthias Ringwald 
9524c1900e6SMatthias Ringwald /**
9534c1900e6SMatthias Ringwald  * ATT
9544c1900e6SMatthias Ringwald  */
9554c1900e6SMatthias Ringwald 
9564c1900e6SMatthias Ringwald // Minimum/default MTU
9574c1900e6SMatthias Ringwald #define ATT_DEFAULT_MTU               23
9584c1900e6SMatthias Ringwald 
9594c1900e6SMatthias Ringwald // MARK: Attribute PDU Opcodes
9604c1900e6SMatthias Ringwald #define ATT_ERROR_RESPONSE              0x01
9614c1900e6SMatthias Ringwald 
9624c1900e6SMatthias Ringwald #define ATT_EXCHANGE_MTU_REQUEST        0x02
9634c1900e6SMatthias Ringwald #define ATT_EXCHANGE_MTU_RESPONSE       0x03
9644c1900e6SMatthias Ringwald 
9654c1900e6SMatthias Ringwald #define ATT_FIND_INFORMATION_REQUEST    0x04
9664c1900e6SMatthias Ringwald #define ATT_FIND_INFORMATION_REPLY      0x05
9674c1900e6SMatthias Ringwald #define ATT_FIND_BY_TYPE_VALUE_REQUEST  0x06
9684c1900e6SMatthias Ringwald #define ATT_FIND_BY_TYPE_VALUE_RESPONSE 0x07
9694c1900e6SMatthias Ringwald 
9704c1900e6SMatthias Ringwald #define ATT_READ_BY_TYPE_REQUEST        0x08
9714c1900e6SMatthias Ringwald #define ATT_READ_BY_TYPE_RESPONSE       0x09
9724c1900e6SMatthias Ringwald #define ATT_READ_REQUEST                0x0a
9734c1900e6SMatthias Ringwald #define ATT_READ_RESPONSE               0x0b
9744c1900e6SMatthias Ringwald #define ATT_READ_BLOB_REQUEST           0x0c
9754c1900e6SMatthias Ringwald #define ATT_READ_BLOB_RESPONSE          0x0d
9764c1900e6SMatthias Ringwald #define ATT_READ_MULTIPLE_REQUEST       0x0e
9774c1900e6SMatthias Ringwald #define ATT_READ_MULTIPLE_RESPONSE      0x0f
9784c1900e6SMatthias Ringwald #define ATT_READ_BY_GROUP_TYPE_REQUEST  0x10
9794c1900e6SMatthias Ringwald #define ATT_READ_BY_GROUP_TYPE_RESPONSE 0x11
9804c1900e6SMatthias Ringwald 
9814c1900e6SMatthias Ringwald #define ATT_WRITE_REQUEST               0x12
9824c1900e6SMatthias Ringwald #define ATT_WRITE_RESPONSE              0x13
9834c1900e6SMatthias Ringwald 
9844c1900e6SMatthias Ringwald #define ATT_PREPARE_WRITE_REQUEST       0x16
9854c1900e6SMatthias Ringwald #define ATT_PREPARE_WRITE_RESPONSE      0x17
9864c1900e6SMatthias Ringwald #define ATT_EXECUTE_WRITE_REQUEST       0x18
9874c1900e6SMatthias Ringwald #define ATT_EXECUTE_WRITE_RESPONSE      0x19
9884c1900e6SMatthias Ringwald 
9894c1900e6SMatthias Ringwald #define ATT_HANDLE_VALUE_NOTIFICATION   0x1b
9904c1900e6SMatthias Ringwald #define ATT_HANDLE_VALUE_INDICATION     0x1d
9914c1900e6SMatthias Ringwald #define ATT_HANDLE_VALUE_CONFIRMATION   0x1e
9924c1900e6SMatthias Ringwald 
9934c1900e6SMatthias Ringwald 
9944c1900e6SMatthias Ringwald #define ATT_WRITE_COMMAND                0x52
9954c1900e6SMatthias Ringwald #define ATT_SIGNED_WRITE_COMMAND         0xD2
9964c1900e6SMatthias Ringwald 
9974c1900e6SMatthias Ringwald // MARK: ATT Error Codes
9984c1900e6SMatthias Ringwald #define ATT_ERROR_INVALID_HANDLE                   0x01
9994c1900e6SMatthias Ringwald #define ATT_ERROR_READ_NOT_PERMITTED               0x02
10004c1900e6SMatthias Ringwald #define ATT_ERROR_WRITE_NOT_PERMITTED              0x03
10014c1900e6SMatthias Ringwald #define ATT_ERROR_INVALID_PDU                      0x04
10024c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_AUTHENTICATION      0x05
10034c1900e6SMatthias Ringwald #define ATT_ERROR_REQUEST_NOT_SUPPORTED            0x06
10044c1900e6SMatthias Ringwald #define ATT_ERROR_INVALID_OFFSET                   0x07
10054c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_AUTHORIZATION       0x08
10064c1900e6SMatthias Ringwald #define ATT_ERROR_PREPARE_QUEUE_FULL               0x09
10074c1900e6SMatthias Ringwald #define ATT_ERROR_ATTRIBUTE_NOT_FOUND              0x0a
10084c1900e6SMatthias Ringwald #define ATT_ERROR_ATTRIBUTE_NOT_LONG               0x0b
10094c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_ENCRYPTION_KEY_SIZE 0x0c
10104c1900e6SMatthias Ringwald #define ATT_ERROR_INVALID_ATTRIBUTE_VALUE_LENGTH   0x0d
10114c1900e6SMatthias Ringwald #define ATT_ERROR_UNLIKELY_ERROR                   0x0e
10124c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_ENCRYPTION          0x0f
10134c1900e6SMatthias Ringwald #define ATT_ERROR_UNSUPPORTED_GROUP_TYPE           0x10
10144c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_RESOURCES           0x11
10154c1900e6SMatthias Ringwald 
10164c1900e6SMatthias Ringwald // MARK: Attribute Property Flags
10174c1900e6SMatthias Ringwald #define ATT_PROPERTY_BROADCAST           0x01
10184c1900e6SMatthias Ringwald #define ATT_PROPERTY_READ                0x02
10194c1900e6SMatthias Ringwald #define ATT_PROPERTY_WRITE_WITHOUT_RESPONSE 0x04
10204c1900e6SMatthias Ringwald #define ATT_PROPERTY_WRITE               0x08
10214c1900e6SMatthias Ringwald #define ATT_PROPERTY_NOTIFY              0x10
10224c1900e6SMatthias Ringwald #define ATT_PROPERTY_INDICATE            0x20
10234c1900e6SMatthias Ringwald #define ATT_PROPERTY_AUTHENTICATED_SIGNED_WRITE 0x40
10244c1900e6SMatthias Ringwald #define ATT_PROPERTY_EXTENDED_PROPERTIES 0x80
10254c1900e6SMatthias Ringwald 
10264c1900e6SMatthias Ringwald // MARK: Attribute Property Flag, BTstack extension
10274c1900e6SMatthias Ringwald // value is asked from client
10284c1900e6SMatthias Ringwald #define ATT_PROPERTY_DYNAMIC             0x100
10294c1900e6SMatthias Ringwald // 128 bit UUID used
10304c1900e6SMatthias Ringwald #define ATT_PROPERTY_UUID128             0x200
10314c1900e6SMatthias Ringwald // Authentication required
10324c1900e6SMatthias Ringwald #define ATT_PROPERTY_AUTHENTICATION_REQUIRED 0x400
10334c1900e6SMatthias Ringwald // Authorization from user required
10344c1900e6SMatthias Ringwald #define ATT_PROPERTY_AUTHORIZATION_REQUIRED  0x800
10354c1900e6SMatthias Ringwald // Encryption key size stored in upper 4 bits, 0 == no encryption, encryption key size - 1 otherwise
10364c1900e6SMatthias Ringwald 
10374c1900e6SMatthias Ringwald // ATT Transaction Timeout of 30 seconds for Command/Response or Incidationc/Confirmation
10384c1900e6SMatthias Ringwald #define ATT_TRANSACTION_TIMEOUT_MS     30000
10394c1900e6SMatthias Ringwald 
10404c1900e6SMatthias Ringwald #define ATT_TRANSACTION_MODE_NONE      0x0
10414c1900e6SMatthias Ringwald #define ATT_TRANSACTION_MODE_ACTIVE    0x1
10424c1900e6SMatthias Ringwald #define ATT_TRANSACTION_MODE_EXECUTE   0x2
10434c1900e6SMatthias Ringwald #define ATT_TRANSACTION_MODE_CANCEL    0x3
10444c1900e6SMatthias Ringwald 
10454c1900e6SMatthias Ringwald // MARK: GATT UUIDs
10464c1900e6SMatthias Ringwald #define GATT_PRIMARY_SERVICE_UUID                   0x2800
10474c1900e6SMatthias Ringwald #define GATT_SECONDARY_SERVICE_UUID                 0x2801
10484c1900e6SMatthias Ringwald #define GATT_INCLUDE_SERVICE_UUID                   0x2802
10494c1900e6SMatthias Ringwald #define GATT_CHARACTERISTICS_UUID                   0x2803
10504c1900e6SMatthias Ringwald #define GATT_CHARACTERISTIC_EXTENDED_PROPERTIES     0x2900
10514c1900e6SMatthias Ringwald #define GATT_CHARACTERISTIC_USER_DESCRIPTION        0x2901
10524c1900e6SMatthias Ringwald #define GATT_CLIENT_CHARACTERISTICS_CONFIGURATION   0x2902
10534c1900e6SMatthias Ringwald #define GATT_SERVER_CHARACTERISTICS_CONFIGURATION   0x2903
10544c1900e6SMatthias Ringwald #define GATT_CHARACTERISTIC_PRESENTATION_FORMAT     0x2904
10554c1900e6SMatthias Ringwald #define GATT_CHARACTERISTIC_AGGREGATE_FORMAT        0x2905
10564c1900e6SMatthias Ringwald 
10574c1900e6SMatthias Ringwald #define GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NONE          0
10584c1900e6SMatthias Ringwald #define GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NOTIFICATION  1
10594c1900e6SMatthias Ringwald #define GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_INDICATION    2
10604c1900e6SMatthias Ringwald 
10614c1900e6SMatthias Ringwald // GAP Service and Characteristics
10624c1900e6SMatthias Ringwald #define GAP_SERVICE_UUID               0x1800
10634c1900e6SMatthias Ringwald #define GAP_DEVICE_NAME_UUID           0x2a00
10644c1900e6SMatthias Ringwald #define GAP_APPEARANCE_UUID            0x2a01
10654c1900e6SMatthias Ringwald #define GAP_PERIPHERAL_PRIVACY_FLAG    0x2a02
10664c1900e6SMatthias Ringwald #define GAP_RECONNECTION_ADDRESS_UUID  0x2a03
10674c1900e6SMatthias Ringwald #define GAP_PERIPHERAL_PREFERRED_CONNECTION_PARAMETERS_UUID 0x2a04
106817fe8172SMatthias Ringwald #define GAP_SERVICE_CHANGED            0x2a05
10694c1900e6SMatthias Ringwald 
10704c1900e6SMatthias Ringwald /**
10714c1900e6SMatthias Ringwald  * SM - LE Security Manager
10724c1900e6SMatthias Ringwald  */
10734c1900e6SMatthias Ringwald // Bluetooth Spec definitions
10744c1900e6SMatthias Ringwald typedef enum {
10754c1900e6SMatthias Ringwald     SM_CODE_PAIRING_REQUEST = 0X01,
10764c1900e6SMatthias Ringwald     SM_CODE_PAIRING_RESPONSE,
10774c1900e6SMatthias Ringwald     SM_CODE_PAIRING_CONFIRM,
10784c1900e6SMatthias Ringwald     SM_CODE_PAIRING_RANDOM,
10794c1900e6SMatthias Ringwald     SM_CODE_PAIRING_FAILED,
10804c1900e6SMatthias Ringwald     SM_CODE_ENCRYPTION_INFORMATION,
10814c1900e6SMatthias Ringwald     SM_CODE_MASTER_IDENTIFICATION,
10824c1900e6SMatthias Ringwald     SM_CODE_IDENTITY_INFORMATION,
10834c1900e6SMatthias Ringwald     SM_CODE_IDENTITY_ADDRESS_INFORMATION,
10844c1900e6SMatthias Ringwald     SM_CODE_SIGNING_INFORMATION,
108574a9b3d5SMatthias Ringwald     SM_CODE_SECURITY_REQUEST,
108674a9b3d5SMatthias Ringwald     SM_CODE_PAIRING_PUBLIC_KEY,
108774a9b3d5SMatthias Ringwald     SM_CODE_PAIRING_DHKEY_CHECK,
108844e8d9acSMatthias Ringwald     SM_CODE_KEYPRESS_NOTIFICATION,
10894c1900e6SMatthias Ringwald } SECURITY_MANAGER_COMMANDS;
10904c1900e6SMatthias Ringwald 
10914c1900e6SMatthias Ringwald // IO Capability Values
10924c1900e6SMatthias Ringwald typedef enum {
10934c1900e6SMatthias Ringwald     IO_CAPABILITY_DISPLAY_ONLY = 0,
10944c1900e6SMatthias Ringwald     IO_CAPABILITY_DISPLAY_YES_NO,
10954c1900e6SMatthias Ringwald     IO_CAPABILITY_KEYBOARD_ONLY,
10964c1900e6SMatthias Ringwald     IO_CAPABILITY_NO_INPUT_NO_OUTPUT,
10974c1900e6SMatthias Ringwald     IO_CAPABILITY_KEYBOARD_DISPLAY, // not used by secure simple pairing
10984c1900e6SMatthias Ringwald } io_capability_t;
10994c1900e6SMatthias Ringwald 
11004c1900e6SMatthias Ringwald // Authentication requirement flags
11014c1900e6SMatthias Ringwald #define SM_AUTHREQ_NO_BONDING        0x00
11024c1900e6SMatthias Ringwald #define SM_AUTHREQ_BONDING           0x01
11034c1900e6SMatthias Ringwald #define SM_AUTHREQ_MITM_PROTECTION   0x04
110474a9b3d5SMatthias Ringwald #define SM_AUTHREQ_SECURE_CONNECTION 0x08
110574a9b3d5SMatthias Ringwald #define SM_AUTHREQ_KEYPRESS          0x10
11064c1900e6SMatthias Ringwald 
11074c1900e6SMatthias Ringwald // Key distribution flags used by spec
110852f9cf63SMatthias Ringwald #define SM_KEYDIST_ENC_KEY  0x01
11094c1900e6SMatthias Ringwald #define SM_KEYDIST_ID_KEY   0x02
11104c1900e6SMatthias Ringwald #define SM_KEYDIST_SIGN     0x04
111152f9cf63SMatthias Ringwald #define SM_KEYDIST_LINK_KEY 0x08
11124c1900e6SMatthias Ringwald 
11134c1900e6SMatthias Ringwald // Key distribution flags used internally
11144c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_ENCRYPTION_INFORMATION       0x01
11154c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_MASTER_IDENTIFICATION        0x02
11164c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_IDENTITY_INFORMATION         0x04
11174c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_IDENTITY_ADDRESS_INFORMATION 0x08
11184c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_SIGNING_IDENTIFICATION       0x10
11194c1900e6SMatthias Ringwald 
11204c1900e6SMatthias Ringwald // STK Generation Methods
11214c1900e6SMatthias Ringwald #define SM_STK_GENERATION_METHOD_JUST_WORKS          0x01
11224c1900e6SMatthias Ringwald #define SM_STK_GENERATION_METHOD_OOB                 0x02
11234c1900e6SMatthias Ringwald #define SM_STK_GENERATION_METHOD_PASSKEY             0x04
1124b4343428SMatthias Ringwald #define SM_STK_GENERATION_METHOD_NUMERIC_COMPARISON  0x08
11254c1900e6SMatthias Ringwald 
11264c1900e6SMatthias Ringwald // Pairing Failed Reasons
11274c1900e6SMatthias Ringwald #define SM_REASON_RESERVED                     0x00
11284c1900e6SMatthias Ringwald #define SM_REASON_PASSKEYT_ENTRY_FAILED        0x01
11294c1900e6SMatthias Ringwald #define SM_REASON_OOB_NOT_AVAILABLE            0x02
11304c1900e6SMatthias Ringwald #define SM_REASON_AUTHENTHICATION_REQUIREMENTS 0x03
11314c1900e6SMatthias Ringwald #define SM_REASON_CONFIRM_VALUE_FAILED         0x04
11324c1900e6SMatthias Ringwald #define SM_REASON_PAIRING_NOT_SUPPORTED        0x05
11334c1900e6SMatthias Ringwald #define SM_REASON_ENCRYPTION_KEY_SIZE          0x06
11344c1900e6SMatthias Ringwald #define SM_REASON_COMMAND_NOT_SUPPORTED        0x07
11354c1900e6SMatthias Ringwald #define SM_REASON_UNSPECIFIED_REASON           0x08
11364c1900e6SMatthias Ringwald #define SM_REASON_REPEATED_ATTEMPTS            0x09
1137a9f29768SMatthias Ringwald #define SM_REASON_INVALID_PARAMETERS           0x0a
1138a9f29768SMatthias Ringwald #define SM_REASON_DHKEY_CHECK_FAILED           0x0b
1139a9f29768SMatthias Ringwald #define SM_REASON_NUMERIC_COMPARISON_FAILED    0x0c
1140a9f29768SMatthias Ringwald 
11414c1900e6SMatthias Ringwald // also, invalid parameters
11424c1900e6SMatthias Ringwald // and reserved
11434c1900e6SMatthias Ringwald 
114444e8d9acSMatthias Ringwald // Keypress Notifications
114544e8d9acSMatthias Ringwald #define SM_KEYPRESS_PASSKEY_ENTRY_STARTED      0x00
114644e8d9acSMatthias Ringwald #define SM_KEYPRESS_PASSKEY_DIGIT_ENTERED      0x01
114744e8d9acSMatthias Ringwald #define SM_KEYPRESS_PASSKEY_DIGIT_ERASED       0x02
114844e8d9acSMatthias Ringwald #define SM_KEYPRESS_PASSKEY_CLEARED            0x03
114944e8d9acSMatthias Ringwald #define SM_KEYPRESS_PASSKEY_ENTRY_COMPLETED    0x04
115044e8d9acSMatthias Ringwald 
115144e8d9acSMatthias Ringwald 
115247f4e325SMatthias Ringwald #endif