xref: /btstack/src/bluetooth.h (revision 33373e4028711d345c0917135062dade0b367c64)
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
348ad71fb17SMatthias Ringwald 
34947f4e325SMatthias Ringwald #define HCI_EVENT_READ_REMOTE_SUPPORTED_FEATURES_COMPLETE  0x0B
350ad71fb17SMatthias Ringwald 
35147f4e325SMatthias Ringwald #define HCI_EVENT_READ_REMOTE_VERSION_INFORMATION_COMPLETE 0x0C
352ad71fb17SMatthias 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 
376ad71fb17SMatthias 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
494ad71fb17SMatthias Ringwald 
495ad71fb17SMatthias Ringwald /**
496ad71fb17SMatthias Ringwald  * @format B4
497ad71fb17SMatthias Ringwald  * @param bd_addr
498ad71fb17SMatthias Ringwald  * @param numeric_value
499ad71fb17SMatthias Ringwald  */
50047f4e325SMatthias Ringwald #define HCI_EVENT_USER_CONFIRMATION_REQUEST                0x33
501ad71fb17SMatthias Ringwald 
502ad71fb17SMatthias Ringwald /**
503ad71fb17SMatthias Ringwald  * @format B
504ad71fb17SMatthias Ringwald  * @param bd_addr
505ad71fb17SMatthias Ringwald  */
50647f4e325SMatthias Ringwald #define HCI_EVENT_USER_PASSKEY_REQUEST                     0x34
507ad71fb17SMatthias Ringwald 
508ad71fb17SMatthias Ringwald /**
509ad71fb17SMatthias Ringwald  * @format B
510ad71fb17SMatthias Ringwald  * @param bd_addr
511ad71fb17SMatthias Ringwald  */
51247f4e325SMatthias Ringwald #define HCI_EVENT_REMOTE_OOB_DATA_REQUEST                  0x35
513ad71fb17SMatthias Ringwald 
514ad71fb17SMatthias Ringwald /**
515ad71fb17SMatthias Ringwald  * @format 1B
516ad71fb17SMatthias Ringwald  * @param status
517ad71fb17SMatthias Ringwald  * @param bd_addr
518ad71fb17SMatthias Ringwald  */
51947f4e325SMatthias Ringwald #define HCI_EVENT_SIMPLE_PAIRING_COMPLETE                  0x36
52047f4e325SMatthias Ringwald 
52147f4e325SMatthias Ringwald #define HCI_EVENT_LE_META                                  0x3E
52247f4e325SMatthias Ringwald 
52382180fcaSMatthias Ringwald // last used HCI_EVENT in 2.1 is 0x3d
52482180fcaSMatthias Ringwald // last used HCI_EVENT in 4.1 is 0x57
52582180fcaSMatthias Ringwald 
526941b3855SMatthias Ringwald #define HCI_EVENT_VENDOR_SPECIFIC                          0xFF
527941b3855SMatthias Ringwald 
52847f4e325SMatthias Ringwald /**
529ca0d73deSMatthias Ringwald  * @format 11H11B2221
53047f4e325SMatthias Ringwald  * @param subevent_code
53147f4e325SMatthias Ringwald  * @param status
53247f4e325SMatthias Ringwald  * @param connection_handle
53347f4e325SMatthias Ringwald  * @param role
53447f4e325SMatthias Ringwald  * @param peer_address_type
53547f4e325SMatthias Ringwald  * @param peer_address
53647f4e325SMatthias Ringwald  * @param conn_interval
53747f4e325SMatthias Ringwald  * @param conn_latency
53847f4e325SMatthias Ringwald  * @param supervision_timeout
53947f4e325SMatthias Ringwald  * @param master_clock_accuracy
54047f4e325SMatthias Ringwald  */
54147f4e325SMatthias Ringwald #define HCI_SUBEVENT_LE_CONNECTION_COMPLETE                0x01
54282180fcaSMatthias Ringwald 
54382180fcaSMatthias Ringwald // array of advertisements, not handled by event accessor generator
54447f4e325SMatthias Ringwald #define HCI_SUBEVENT_LE_ADVERTISING_REPORT                 0x02
54582180fcaSMatthias Ringwald 
54682180fcaSMatthias Ringwald /**
54782180fcaSMatthias Ringwald  * @format 11H222
54882180fcaSMatthias Ringwald  * @param subevent_code
54982180fcaSMatthias Ringwald  * @param status
55082180fcaSMatthias Ringwald  * @param connection_handle
55182180fcaSMatthias Ringwald  * @param conn_interval
55282180fcaSMatthias Ringwald  * @param conn_latency
55382180fcaSMatthias Ringwald  */
55447f4e325SMatthias Ringwald  #define HCI_SUBEVENT_LE_CONNECTION_UPDATE_COMPLETE         0x03
55582180fcaSMatthias Ringwald 
55682180fcaSMatthias Ringwald /**
55782180fcaSMatthias Ringwald  * @format 1HD2
55882180fcaSMatthias Ringwald  * @param subevent_code
55982180fcaSMatthias Ringwald  * @param connection_handle
56082180fcaSMatthias Ringwald  * @param random_number
56182180fcaSMatthias Ringwald  * @param encryption_diversifier
56282180fcaSMatthias Ringwald  */
56347f4e325SMatthias Ringwald #define HCI_SUBEVENT_LE_READ_REMOTE_USED_FEATURES_COMPLETE 0x04
56482180fcaSMatthias Ringwald 
56582180fcaSMatthias Ringwald /**
56682180fcaSMatthias Ringwald  * @format 1HD2
56782180fcaSMatthias Ringwald  * @param subevent_code
56882180fcaSMatthias Ringwald  * @param connection_handle
56982180fcaSMatthias Ringwald  * @param random_number
57082180fcaSMatthias Ringwald  * @param encryption_diversifier
57182180fcaSMatthias Ringwald  */
57247f4e325SMatthias Ringwald #define HCI_SUBEVENT_LE_LONG_TERM_KEY_REQUEST              0x05
57347f4e325SMatthias Ringwald 
57482180fcaSMatthias Ringwald /**
57582180fcaSMatthias Ringwald  * @format 1H2222
57682180fcaSMatthias Ringwald  * @param subevent_code
57782180fcaSMatthias Ringwald  * @param connection_handle
57882180fcaSMatthias Ringwald  * @param interval_min
57982180fcaSMatthias Ringwald  * @param interval_max
58082180fcaSMatthias Ringwald  * @param latency
58182180fcaSMatthias Ringwald  * @param timeout
58282180fcaSMatthias Ringwald  */
58382180fcaSMatthias Ringwald #define HCI_SUBEVENT_LE_REMOTE_CONNECTION_PARAMETER_REQUEST 0x06
58482180fcaSMatthias Ringwald 
58582180fcaSMatthias Ringwald /**
58682180fcaSMatthias Ringwald  * @format 1H2222
58782180fcaSMatthias Ringwald  * @param subevent_code
58882180fcaSMatthias Ringwald  * @param connection_handle
58982180fcaSMatthias Ringwald  * @param max_tx_octets
59082180fcaSMatthias Ringwald  * @param max_tx_time
59182180fcaSMatthias Ringwald  * @param max_rx_octets
59282180fcaSMatthias Ringwald  * @param max_rx_time
59382180fcaSMatthias Ringwald  */
59482180fcaSMatthias Ringwald #define HCI_SUBEVENT_LE_DATA_LENGTH_CHANGE 0x07
59582180fcaSMatthias Ringwald 
59682180fcaSMatthias Ringwald /**
59782180fcaSMatthias Ringwald  * @format 11QQ
59882180fcaSMatthias Ringwald  * @param subevent_code
59982180fcaSMatthias Ringwald  * @param status
60082180fcaSMatthias Ringwald  * @param dhkey_x x coordinate of P256 public key
60182180fcaSMatthias Ringwald  * @param dhkey_y y coordinate of P256 public key
60282180fcaSMatthias Ringwald  */
60382180fcaSMatthias Ringwald #define HCI_SUBEVENT_LE_READ_LOCAL_P256_PUBLIC_KEY_COMPLETE 0x08
60482180fcaSMatthias Ringwald  /**
60582180fcaSMatthias Ringwald  * @format 11QQ
60682180fcaSMatthias Ringwald  * @param subevent_code
60782180fcaSMatthias Ringwald  * @param status
60882180fcaSMatthias Ringwald  * @param dhkey_x x coordinate of Diffie-Hellman key
60982180fcaSMatthias Ringwald  * @param dhkey_y y coordinate of Diffie-Hellman key
61082180fcaSMatthias Ringwald  */
61182180fcaSMatthias Ringwald #define HCI_SUBEVENT_LE_GENERATE_DHKEY_COMPLETE            0x09
61282180fcaSMatthias Ringwald 
61382180fcaSMatthias Ringwald /**
61482180fcaSMatthias Ringwald  * @format 11H11BBB2221
61582180fcaSMatthias Ringwald  * @param subevent_code
61682180fcaSMatthias Ringwald  * @param status
61782180fcaSMatthias Ringwald  * @param connection_handle
61882180fcaSMatthias Ringwald  * @param role
61982180fcaSMatthias Ringwald  * @param peer_address_type
62082180fcaSMatthias Ringwald  * @param perr_addresss
62182180fcaSMatthias Ringwald  * @param local_resolvable_private_addres
62282180fcaSMatthias Ringwald  * @param peer_resolvable_private_addres
62382180fcaSMatthias Ringwald  * @param conn_interval
62482180fcaSMatthias Ringwald  * @param conn_latency
62582180fcaSMatthias Ringwald  * @param supervision_timeout
62682180fcaSMatthias Ringwald  * @param master_clock_accuracy
62782180fcaSMatthias Ringwald  */
62882180fcaSMatthias Ringwald #define HCI_SUBEVENT_LE_ENHANCED_CONNECTION_COMPLETE       0x0A
62982180fcaSMatthias Ringwald 
63082180fcaSMatthias Ringwald // array of advertisements, not handled by event accessor generator
63182180fcaSMatthias Ringwald #define HCI_SUBEVENT_LE_DIRECT_ADVERTISING_REPORT          0x0B
63247f4e325SMatthias Ringwald 
63347f4e325SMatthias Ringwald /**
63447f4e325SMatthias Ringwald  * L2CAP Layer
63547f4e325SMatthias Ringwald  */
63647f4e325SMatthias Ringwald 
637a8373a41SMatthias Ringwald #define L2CAP_HEADER_SIZE 4
638a8373a41SMatthias Ringwald 
639a8373a41SMatthias Ringwald #define L2CAP_SIG_ID_INVALID 0
640a8373a41SMatthias Ringwald 
641a8373a41SMatthias Ringwald // size of HCI ACL + L2CAP Header for regular data packets (8)
642a8373a41SMatthias Ringwald #define COMPLETE_L2CAP_HEADER (HCI_ACL_HEADER_SIZE + L2CAP_HEADER_SIZE)
643a8373a41SMatthias Ringwald 
644a8373a41SMatthias Ringwald // minimum signaling MTU
645a8373a41SMatthias Ringwald #define L2CAP_MINIMAL_MTU 48
646a8373a41SMatthias Ringwald #define L2CAP_DEFAULT_MTU 672
647a8373a41SMatthias Ringwald 
648a8373a41SMatthias Ringwald // Minimum/default MTU
649a8373a41SMatthias Ringwald #define L2CAP_LE_DEFAULT_MTU  23
650a8373a41SMatthias Ringwald 
651a8373a41SMatthias Ringwald // L2CAP Fixed Channel IDs
652a8373a41SMatthias Ringwald #define L2CAP_CID_SIGNALING                 0x0001
653a8373a41SMatthias Ringwald #define L2CAP_CID_CONNECTIONLESS_CHANNEL    0x0002
654a8373a41SMatthias Ringwald #define L2CAP_CID_ATTRIBUTE_PROTOCOL        0x0004
655a8373a41SMatthias Ringwald #define L2CAP_CID_SIGNALING_LE              0x0005
656a8373a41SMatthias Ringwald #define L2CAP_CID_SECURITY_MANAGER_PROTOCOL 0x0006
657a8373a41SMatthias Ringwald 
658a8373a41SMatthias Ringwald // L2CAP Configuration Result Codes
659a8373a41SMatthias Ringwald #define L2CAP_CONF_RESULT_UNKNOWN_OPTIONS   0x0003
660a8373a41SMatthias Ringwald 
661a8373a41SMatthias Ringwald // L2CAP Reject Result Codes
662a8373a41SMatthias Ringwald #define L2CAP_REJ_CMD_UNKNOWN               0x0000
663a8373a41SMatthias Ringwald 
664a8373a41SMatthias Ringwald // Response Timeout eXpired
665a8373a41SMatthias Ringwald #define L2CAP_RTX_TIMEOUT_MS   10000
666a8373a41SMatthias Ringwald 
667a8373a41SMatthias Ringwald // Extended Response Timeout eXpired
668a8373a41SMatthias Ringwald #define L2CAP_ERTX_TIMEOUT_MS 120000
669a8373a41SMatthias Ringwald 
67047f4e325SMatthias Ringwald // Fixed PSM numbers
67147f4e325SMatthias Ringwald #define PSM_SDP           0x01
67247f4e325SMatthias Ringwald #define PSM_RFCOMM        0x03
67347f4e325SMatthias Ringwald #define PSM_BNEP          0x0F
67447f4e325SMatthias Ringwald #define PSM_HID_CONTROL   0x11
67547f4e325SMatthias Ringwald #define PSM_HID_INTERRUPT 0x13
67647f4e325SMatthias Ringwald 
67766b1fcb3SMatthias Ringwald /**
678ef907034SMatthias Ringwald  * SDP Protocl
679ef907034SMatthias Ringwald  */
680ef907034SMatthias Ringwald 
681ef907034SMatthias Ringwald  // PDU Types
682ef907034SMatthias Ringwald typedef enum {
683ef907034SMatthias Ringwald     SDP_Invalid = 0,
684ef907034SMatthias Ringwald     SDP_ErrorResponse = 1,
685ef907034SMatthias Ringwald     SDP_ServiceSearchRequest,
686ef907034SMatthias Ringwald     SDP_ServiceSearchResponse,
687ef907034SMatthias Ringwald     SDP_ServiceAttributeRequest,
688ef907034SMatthias Ringwald     SDP_ServiceAttributeResponse,
689ef907034SMatthias Ringwald     SDP_ServiceSearchAttributeRequest,
690ef907034SMatthias Ringwald     SDP_ServiceSearchAttributeResponse
691ef907034SMatthias Ringwald } SDP_PDU_ID_t;
692ef907034SMatthias Ringwald 
693ef907034SMatthias Ringwald // UNIVERSAL ATTRIBUTE DEFINITIONS
694ef907034SMatthias Ringwald #define SDP_ServiceRecordHandle     0x0000
695ef907034SMatthias Ringwald #define SDP_ServiceClassIDList      0x0001
696ef907034SMatthias Ringwald #define SDP_ServiceRecordState      0x0002
697ef907034SMatthias Ringwald #define SDP_ServiceID               0x0003
698ef907034SMatthias Ringwald #define SDP_ProtocolDescriptorList  0x0004
699ef907034SMatthias Ringwald #define SDP_BrowseGroupList         0x0005
700ef907034SMatthias Ringwald #define SDP_LanguageBaseAttributeIDList 0x0006
701ef907034SMatthias Ringwald #define SDP_ServiceInfoTimeToLive   0x0007
702ef907034SMatthias Ringwald #define SDP_ServiceAvailability     0x0008
703ef907034SMatthias Ringwald #define SDP_BluetoothProfileDescriptorList 0x0009
704ef907034SMatthias Ringwald #define SDP_DocumentationURL        0x000a
705ef907034SMatthias Ringwald #define SDP_ClientExecutableURL     0x000b
706ef907034SMatthias Ringwald #define SDP_IconURL                 0x000c
707ef907034SMatthias Ringwald #define SDP_AdditionalProtocolDescriptorList 0x000d
708ef907034SMatthias Ringwald #define SDP_SupportedFormatsList    0x0303
709ef907034SMatthias Ringwald 
710ef907034SMatthias Ringwald // SERVICE CLASSES
711ef907034SMatthias Ringwald #define SDP_OBEXObjectPush          0x1105
712ef907034SMatthias Ringwald #define SDP_OBEXFileTransfer        0x1106
713ef907034SMatthias Ringwald #define SDP_PublicBrowseGroup       0x1002
714ef907034SMatthias Ringwald #define SDP_HSP                     0x1108
715ef907034SMatthias Ringwald #define SDP_Headset_AG              0x1112
716ef907034SMatthias Ringwald #define SDP_PANU                    0x1115
717ef907034SMatthias Ringwald #define SDP_NAP                     0x1116
718ef907034SMatthias Ringwald #define SDP_GN                      0x1117
719ef907034SMatthias Ringwald #define SDP_Handsfree               0x111E
720ef907034SMatthias Ringwald #define SDP_HandsfreeAudioGateway   0x111F
721ef907034SMatthias Ringwald #define SDP_Headset_HS              0x1131
722ef907034SMatthias Ringwald #define SDP_GenericAudio            0x1203
723ef907034SMatthias Ringwald 
724ef907034SMatthias Ringwald 
725ef907034SMatthias Ringwald // PROTOCOLS
726ef907034SMatthias Ringwald #define SDP_SDPProtocol       0x0001
727ef907034SMatthias Ringwald #define SDP_UDPProtocol       0x0002
728ef907034SMatthias Ringwald #define SDP_RFCOMMProtocol    0x0003
729ef907034SMatthias Ringwald #define SDP_OBEXProtocol      0x0008
730ef907034SMatthias Ringwald #define SDP_L2CAPProtocol     0x0100
731ef907034SMatthias Ringwald #define SDP_BNEPProtocol      0x000F
732ef907034SMatthias Ringwald #define SDP_AVDTPProtocol     0x0019
733ef907034SMatthias Ringwald 
734ef907034SMatthias Ringwald // OFFSETS FOR LOCALIZED ATTRIBUTES - SDP_LanguageBaseAttributeIDList
735ef907034SMatthias Ringwald #define SDP_Offest_ServiceName      0x0000
736ef907034SMatthias Ringwald #define SDP_Offest_ServiceDescription 0x0001
737ef907034SMatthias Ringwald #define SDP_Offest_ProviderName     0x0002
738ef907034SMatthias Ringwald 
739ef907034SMatthias Ringwald // OBEX
740ef907034SMatthias Ringwald #define SDP_vCard_2_1       0x01
741ef907034SMatthias Ringwald #define SDP_vCard_3_0       0x02
742ef907034SMatthias Ringwald #define SDP_vCal_1_0        0x03
743ef907034SMatthias Ringwald #define SDP_iCal_2_0        0x04
744ef907034SMatthias Ringwald #define SDP_vNote           0x05
745ef907034SMatthias Ringwald #define SDP_vMessage        0x06
746ef907034SMatthias Ringwald #define SDP_OBEXFileTypeAny 0xFF
747ef907034SMatthias Ringwald 
748ef907034SMatthias Ringwald /**
749e2577bd7SMatthias Ringwald  * RFCOMM Protocol
750e2577bd7SMatthias Ringwald  */
751e2577bd7SMatthias Ringwald 
752e2577bd7SMatthias Ringwald // Control field values      bit no.       1 2 3 4 PF 6 7 8
753e2577bd7SMatthias Ringwald #define BT_RFCOMM_SABM       0x3F       // 1 1 1 1  1 1 0 0
754e2577bd7SMatthias Ringwald #define BT_RFCOMM_UA         0x73       // 1 1 0 0  1 1 1 0
755e2577bd7SMatthias Ringwald #define BT_RFCOMM_DM         0x0F       // 1 1 1 1  0 0 0 0
756e2577bd7SMatthias Ringwald #define BT_RFCOMM_DM_PF      0x1F       // 1 1 1 1  1 0 0 0
757e2577bd7SMatthias Ringwald #define BT_RFCOMM_DISC       0x53       // 1 1 0 0  1 0 1 0
758e2577bd7SMatthias Ringwald #define BT_RFCOMM_UIH        0xEF       // 1 1 1 1  0 1 1 1
759e2577bd7SMatthias Ringwald #define BT_RFCOMM_UIH_PF     0xFF       // 1 1 1 1  0 1 1 1
760e2577bd7SMatthias Ringwald 
761e2577bd7SMatthias Ringwald // Multiplexer message types
762e2577bd7SMatthias Ringwald #define BT_RFCOMM_CLD_CMD    0xC3
763e2577bd7SMatthias Ringwald #define BT_RFCOMM_FCON_CMD   0xA3
764e2577bd7SMatthias Ringwald #define BT_RFCOMM_FCON_RSP   0xA1
765e2577bd7SMatthias Ringwald #define BT_RFCOMM_FCOFF_CMD  0x63
766e2577bd7SMatthias Ringwald #define BT_RFCOMM_FCOFF_RSP  0x61
767e2577bd7SMatthias Ringwald #define BT_RFCOMM_MSC_CMD    0xE3
768e2577bd7SMatthias Ringwald #define BT_RFCOMM_MSC_RSP    0xE1
769e2577bd7SMatthias Ringwald #define BT_RFCOMM_NSC_RSP    0x11
770e2577bd7SMatthias Ringwald #define BT_RFCOMM_PN_CMD     0x83
771e2577bd7SMatthias Ringwald #define BT_RFCOMM_PN_RSP     0x81
772e2577bd7SMatthias Ringwald #define BT_RFCOMM_RLS_CMD    0x53
773e2577bd7SMatthias Ringwald #define BT_RFCOMM_RLS_RSP    0x51
774e2577bd7SMatthias Ringwald #define BT_RFCOMM_RPN_CMD    0x93
775e2577bd7SMatthias Ringwald #define BT_RFCOMM_RPN_RSP    0x91
776e2577bd7SMatthias Ringwald #define BT_RFCOMM_TEST_CMD   0x23
777e2577bd7SMatthias Ringwald #define BT_RFCOMM_TEST_RSP   0x21
778e2577bd7SMatthias Ringwald 
779e2577bd7SMatthias Ringwald // Line Status
780e2577bd7SMatthias Ringwald #define LINE_STATUS_NO_ERROR       0x00
781e2577bd7SMatthias Ringwald #define LINE_STATUS_OVERRUN_ERROR  0x03
782e2577bd7SMatthias Ringwald #define LINE_STATUS_PARITY_ERORR   0x05
783e2577bd7SMatthias Ringwald #define LINE_STATUS_FRAMING_ERROR  0x09
784e2577bd7SMatthias Ringwald 
785e2577bd7SMatthias Ringwald // Modem Status Flags
786e2577bd7SMatthias Ringwald #define MODEM_STATUS_FC   0x02
787e2577bd7SMatthias Ringwald #define MODEM_STATUS_RTC  0x04
788e2577bd7SMatthias Ringwald #define MODEM_STATUS_RTR  0x08
789e2577bd7SMatthias Ringwald #define MODEM_STATUS_IC   0x40
790e2577bd7SMatthias Ringwald #define MODEM_STATUS_DV   0x80
791e2577bd7SMatthias Ringwald 
792e2577bd7SMatthias Ringwald typedef enum rpn_baud {
793e2577bd7SMatthias Ringwald     RPN_BAUD_2400 = 0,
794e2577bd7SMatthias Ringwald     RPN_BAUD_4800,
795e2577bd7SMatthias Ringwald     RPN_BAUD_7200,
796e2577bd7SMatthias Ringwald     RPN_BAUD_9600,
797e2577bd7SMatthias Ringwald     RPN_BAUD_19200,
798e2577bd7SMatthias Ringwald     RPN_BAUD_38400,
799e2577bd7SMatthias Ringwald     RPN_BAUD_57600,
800e2577bd7SMatthias Ringwald     RPN_BAUD_115200,
801e2577bd7SMatthias Ringwald     RPN_BAUD_230400
802e2577bd7SMatthias Ringwald } rpn_baud_t;
803e2577bd7SMatthias Ringwald 
804e2577bd7SMatthias Ringwald typedef enum rpn_data_bits {
805e2577bd7SMatthias Ringwald     RPN_DATA_BITS_5 = 0,
806e2577bd7SMatthias Ringwald     RPN_DATA_BITS_6 = 0,
807e2577bd7SMatthias Ringwald     RPN_DATA_BITS_7 = 0,
808e2577bd7SMatthias Ringwald     RPN_DATA_BITS_8 = 0
809e2577bd7SMatthias Ringwald } rpn_data_bits_t;
810e2577bd7SMatthias Ringwald 
811e2577bd7SMatthias Ringwald typedef enum rpn_stop_bits {
812e2577bd7SMatthias Ringwald     RPN_STOP_BITS_1_0 = 0,
813e2577bd7SMatthias Ringwald     RPN_STOP_BITS_1_5
814e2577bd7SMatthias Ringwald } rpn_stop_bits_t;
815e2577bd7SMatthias Ringwald 
816e2577bd7SMatthias Ringwald typedef enum rpn_parity {
817e2577bd7SMatthias Ringwald     RPN_PARITY_NONE  = 0,
818e2577bd7SMatthias Ringwald     RPN_PARITY_ODD   = 1,
819e2577bd7SMatthias Ringwald     RPN_PARITY_EVEN  = 3,
820e2577bd7SMatthias Ringwald     RPN_PARITY_MARK  = 5,
821e2577bd7SMatthias Ringwald     RPN_PARITY_SPACE = 7,
822e2577bd7SMatthias Ringwald } rpn_parity_t;
823e2577bd7SMatthias Ringwald 
824e2577bd7SMatthias Ringwald typedef enum rpn_flow_control {
825e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_XONXOFF_ON_INPUT  = 1 << 0,
826e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_XONXOFF_ON_OUTPUT = 1 << 1,
827e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_RTR_ON_INPUT  = 1 << 2,
828e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_RTR_ON_OUTPUT = 1 << 3,
829e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_RTC_ON_INPUT  = 1 << 4,
830e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_RTC_ON_OUTPUT = 1 << 5,
831e2577bd7SMatthias Ringwald } rpn_flow_control_t;
832e2577bd7SMatthias Ringwald 
833e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_BAUD             0x01
834e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_DATA_BITS        0x02
835e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_STOP_BITS        0x04
836e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_PARITY           0x08
837e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_PARITY_TYPE      0x10
838e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_XON_CHAR         0x20
839e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_XOFF_CHAR        0x40
840e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_RESERVED         0x80
841e2577bd7SMatthias Ringwald 
842e2577bd7SMatthias Ringwald // @note: values are identical to rpn_flow_control_t
843e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_XONOFF_ON_INPUT  0x01
844e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_XONOFF_ON_OUTPUT 0x02
845e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RTR_ON_INPUT     0x04
846e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RTR_ON_OUTPUT    0x08
847e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RTC_ON_INPUT     0x10
848e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RTC_ON_OUTPUT    0x20
849e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RESERVED_0       0x40
850e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RESERVED_1       0x80
851e2577bd7SMatthias Ringwald 
852e2577bd7SMatthias Ringwald /**
85366b1fcb3SMatthias Ringwald  * BNEP Protocol
85466b1fcb3SMatthias Ringwald  */
85547f4e325SMatthias Ringwald 
85666b1fcb3SMatthias Ringwald #ifndef ETHER_ADDR_LEN
8579a73f75dSMatthias Ringwald #define ETHER_ADDR_LEN 6
85866b1fcb3SMatthias Ringwald #endif
85947f4e325SMatthias Ringwald 
86066b1fcb3SMatthias Ringwald #ifndef ETHERTYPE_VLAN
86166b1fcb3SMatthias Ringwald #define ETHERTYPE_VLAN                                  0x8100 /* IEEE 802.1Q VLAN tag */
86266b1fcb3SMatthias Ringwald #endif
86366b1fcb3SMatthias Ringwald 
86466b1fcb3SMatthias Ringwald #define BNEP_MTU_MIN                                    1691
86566b1fcb3SMatthias Ringwald 
86666b1fcb3SMatthias Ringwald #define BNEP_EXT_FLAG                                   0x80
86766b1fcb3SMatthias Ringwald #define BNEP_TYPE_MASK                                  0x7F
86866b1fcb3SMatthias Ringwald #define BNEP_TYPE(header)                               ((header) & BNEP_TYPE_MASK)
86966b1fcb3SMatthias Ringwald #define BNEP_HEADER_HAS_EXT(x)                          (((x) & BNEP_EXT_FLAG) == BNEP_EXT_FLAG)
87066b1fcb3SMatthias Ringwald 
87166b1fcb3SMatthias Ringwald /* BNEP packet types */
87266b1fcb3SMatthias Ringwald #define BNEP_PKT_TYPE_GENERAL_ETHERNET                  0x00
87366b1fcb3SMatthias Ringwald #define BNEP_PKT_TYPE_CONTROL                           0x01
87466b1fcb3SMatthias Ringwald #define BNEP_PKT_TYPE_COMPRESSED_ETHERNET               0x02
87566b1fcb3SMatthias Ringwald #define BNEP_PKT_TYPE_COMPRESSED_ETHERNET_SOURCE_ONLY   0x03
87666b1fcb3SMatthias Ringwald #define BNEP_PKT_TYPE_COMPRESSED_ETHERNET_DEST_ONLY     0x04
87766b1fcb3SMatthias Ringwald 
87866b1fcb3SMatthias Ringwald /* BNEP control types */
87966b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_COMMAND_NOT_UNDERSTOOD        0x00
88066b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_SETUP_CONNECTION_REQUEST      0x01
88166b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_SETUP_CONNECTION_RESPONSE     0x02
88266b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_FILTER_NET_TYPE_SET           0x03
88366b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_FILTER_NET_TYPE_RESPONSE      0x04
88466b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_FILTER_MULTI_ADDR_SET         0x05
88566b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_FILTER_MULTI_ADDR_RESPONSE    0x06
88666b1fcb3SMatthias Ringwald 
88766b1fcb3SMatthias Ringwald /* BNEP extension header types */
88866b1fcb3SMatthias Ringwald #define BNEP_EXT_HEADER_TYPE_EXTENSION_CONTROL          0x00
88966b1fcb3SMatthias Ringwald 
89066b1fcb3SMatthias Ringwald /* BNEP setup response codes */
89166b1fcb3SMatthias Ringwald #define BNEP_RESP_SETUP_SUCCESS                         0x0000
89266b1fcb3SMatthias Ringwald #define BNEP_RESP_SETUP_INVALID_DEST_UUID               0x0001
89366b1fcb3SMatthias Ringwald #define BNEP_RESP_SETUP_INVALID_SOURCE_UUID             0x0002
89466b1fcb3SMatthias Ringwald #define BNEP_RESP_SETUP_INVALID_SERVICE_UUID_SIZE       0x0003
89566b1fcb3SMatthias Ringwald #define BNEP_RESP_SETUP_CONNECTION_NOT_ALLOWED          0x0004
89666b1fcb3SMatthias Ringwald 
89766b1fcb3SMatthias Ringwald /* BNEP filter response codes */
89866b1fcb3SMatthias Ringwald #define BNEP_RESP_FILTER_SUCCESS                        0x0000
89966b1fcb3SMatthias Ringwald #define BNEP_RESP_FILTER_UNSUPPORTED_REQUEST            0x0001
90066b1fcb3SMatthias Ringwald #define BNEP_RESP_FILTER_ERR_INVALID_RANGE              0x0002
90166b1fcb3SMatthias Ringwald #define BNEP_RESP_FILTER_ERR_TOO_MANY_FILTERS           0x0003
90266b1fcb3SMatthias Ringwald #define BNEP_RESP_FILTER_ERR_SECURITY                   0x0004
90366b1fcb3SMatthias Ringwald 
90466b1fcb3SMatthias Ringwald /**
90566b1fcb3SMatthias Ringwald  * PAN Profile
90666b1fcb3SMatthias Ringwald  */
90766b1fcb3SMatthias Ringwald 
90866b1fcb3SMatthias Ringwald typedef enum {
90966b1fcb3SMatthias Ringwald     PANU_UUID = 0x1115,
91066b1fcb3SMatthias Ringwald     NAP_UUID = 0x1116,
91166b1fcb3SMatthias Ringwald     GN_UUID = 0x1117
91266b1fcb3SMatthias Ringwald } bnep_service_uuid_t;
91366b1fcb3SMatthias Ringwald 
91466b1fcb3SMatthias Ringwald typedef enum {
91566b1fcb3SMatthias Ringwald     BNEP_SECURITY_NONE = 0x0000,
91666b1fcb3SMatthias Ringwald     BNEP_SECURITY_SERVICE_LEVEL_ENFORCED,
91766b1fcb3SMatthias Ringwald     BNEP_SECURITY_802_1X
91866b1fcb3SMatthias Ringwald } security_description_t;
91966b1fcb3SMatthias Ringwald 
92066b1fcb3SMatthias Ringwald typedef enum {
92166b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_PSTN = 0x0000,
92266b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_ISDN,
92366b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_DSL,
92466b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_CABLE_MODEM,
92566b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_10MB_ETHERNET,
92666b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_100MB_ETHERNET,
92766b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_4MB_TOKEN_RING,
92866b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_16MB_TOKEN_RING,
92966b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_100MB_TOKEN_RING,
93066b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_FDDI,
93166b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_GSM,
93266b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_CDMA,
93366b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_GPRS,
93466b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_3G,
93566b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_CELULAR,
93666b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_OTHER = 0xFFFE,
93766b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_NONE
93866b1fcb3SMatthias Ringwald } net_access_type_t;
93947f4e325SMatthias Ringwald 
9404c1900e6SMatthias Ringwald /**
9414c1900e6SMatthias Ringwald  * ATT
9424c1900e6SMatthias Ringwald  */
9434c1900e6SMatthias Ringwald 
9444c1900e6SMatthias Ringwald // Minimum/default MTU
9454c1900e6SMatthias Ringwald #define ATT_DEFAULT_MTU               23
9464c1900e6SMatthias Ringwald 
9474c1900e6SMatthias Ringwald // MARK: Attribute PDU Opcodes
9484c1900e6SMatthias Ringwald #define ATT_ERROR_RESPONSE              0x01
9494c1900e6SMatthias Ringwald 
9504c1900e6SMatthias Ringwald #define ATT_EXCHANGE_MTU_REQUEST        0x02
9514c1900e6SMatthias Ringwald #define ATT_EXCHANGE_MTU_RESPONSE       0x03
9524c1900e6SMatthias Ringwald 
9534c1900e6SMatthias Ringwald #define ATT_FIND_INFORMATION_REQUEST    0x04
9544c1900e6SMatthias Ringwald #define ATT_FIND_INFORMATION_REPLY      0x05
9554c1900e6SMatthias Ringwald #define ATT_FIND_BY_TYPE_VALUE_REQUEST  0x06
9564c1900e6SMatthias Ringwald #define ATT_FIND_BY_TYPE_VALUE_RESPONSE 0x07
9574c1900e6SMatthias Ringwald 
9584c1900e6SMatthias Ringwald #define ATT_READ_BY_TYPE_REQUEST        0x08
9594c1900e6SMatthias Ringwald #define ATT_READ_BY_TYPE_RESPONSE       0x09
9604c1900e6SMatthias Ringwald #define ATT_READ_REQUEST                0x0a
9614c1900e6SMatthias Ringwald #define ATT_READ_RESPONSE               0x0b
9624c1900e6SMatthias Ringwald #define ATT_READ_BLOB_REQUEST           0x0c
9634c1900e6SMatthias Ringwald #define ATT_READ_BLOB_RESPONSE          0x0d
9644c1900e6SMatthias Ringwald #define ATT_READ_MULTIPLE_REQUEST       0x0e
9654c1900e6SMatthias Ringwald #define ATT_READ_MULTIPLE_RESPONSE      0x0f
9664c1900e6SMatthias Ringwald #define ATT_READ_BY_GROUP_TYPE_REQUEST  0x10
9674c1900e6SMatthias Ringwald #define ATT_READ_BY_GROUP_TYPE_RESPONSE 0x11
9684c1900e6SMatthias Ringwald 
9694c1900e6SMatthias Ringwald #define ATT_WRITE_REQUEST               0x12
9704c1900e6SMatthias Ringwald #define ATT_WRITE_RESPONSE              0x13
9714c1900e6SMatthias Ringwald 
9724c1900e6SMatthias Ringwald #define ATT_PREPARE_WRITE_REQUEST       0x16
9734c1900e6SMatthias Ringwald #define ATT_PREPARE_WRITE_RESPONSE      0x17
9744c1900e6SMatthias Ringwald #define ATT_EXECUTE_WRITE_REQUEST       0x18
9754c1900e6SMatthias Ringwald #define ATT_EXECUTE_WRITE_RESPONSE      0x19
9764c1900e6SMatthias Ringwald 
9774c1900e6SMatthias Ringwald #define ATT_HANDLE_VALUE_NOTIFICATION   0x1b
9784c1900e6SMatthias Ringwald #define ATT_HANDLE_VALUE_INDICATION     0x1d
9794c1900e6SMatthias Ringwald #define ATT_HANDLE_VALUE_CONFIRMATION   0x1e
9804c1900e6SMatthias Ringwald 
9814c1900e6SMatthias Ringwald 
9824c1900e6SMatthias Ringwald #define ATT_WRITE_COMMAND                0x52
9834c1900e6SMatthias Ringwald #define ATT_SIGNED_WRITE_COMMAND         0xD2
9844c1900e6SMatthias Ringwald 
9854c1900e6SMatthias Ringwald // MARK: ATT Error Codes
9864c1900e6SMatthias Ringwald #define ATT_ERROR_INVALID_HANDLE                   0x01
9874c1900e6SMatthias Ringwald #define ATT_ERROR_READ_NOT_PERMITTED               0x02
9884c1900e6SMatthias Ringwald #define ATT_ERROR_WRITE_NOT_PERMITTED              0x03
9894c1900e6SMatthias Ringwald #define ATT_ERROR_INVALID_PDU                      0x04
9904c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_AUTHENTICATION      0x05
9914c1900e6SMatthias Ringwald #define ATT_ERROR_REQUEST_NOT_SUPPORTED            0x06
9924c1900e6SMatthias Ringwald #define ATT_ERROR_INVALID_OFFSET                   0x07
9934c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_AUTHORIZATION       0x08
9944c1900e6SMatthias Ringwald #define ATT_ERROR_PREPARE_QUEUE_FULL               0x09
9954c1900e6SMatthias Ringwald #define ATT_ERROR_ATTRIBUTE_NOT_FOUND              0x0a
9964c1900e6SMatthias Ringwald #define ATT_ERROR_ATTRIBUTE_NOT_LONG               0x0b
9974c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_ENCRYPTION_KEY_SIZE 0x0c
9984c1900e6SMatthias Ringwald #define ATT_ERROR_INVALID_ATTRIBUTE_VALUE_LENGTH   0x0d
9994c1900e6SMatthias Ringwald #define ATT_ERROR_UNLIKELY_ERROR                   0x0e
10004c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_ENCRYPTION          0x0f
10014c1900e6SMatthias Ringwald #define ATT_ERROR_UNSUPPORTED_GROUP_TYPE           0x10
10024c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_RESOURCES           0x11
10034c1900e6SMatthias Ringwald 
10044c1900e6SMatthias Ringwald // MARK: Attribute Property Flags
10054c1900e6SMatthias Ringwald #define ATT_PROPERTY_BROADCAST           0x01
10064c1900e6SMatthias Ringwald #define ATT_PROPERTY_READ                0x02
10074c1900e6SMatthias Ringwald #define ATT_PROPERTY_WRITE_WITHOUT_RESPONSE 0x04
10084c1900e6SMatthias Ringwald #define ATT_PROPERTY_WRITE               0x08
10094c1900e6SMatthias Ringwald #define ATT_PROPERTY_NOTIFY              0x10
10104c1900e6SMatthias Ringwald #define ATT_PROPERTY_INDICATE            0x20
10114c1900e6SMatthias Ringwald #define ATT_PROPERTY_AUTHENTICATED_SIGNED_WRITE 0x40
10124c1900e6SMatthias Ringwald #define ATT_PROPERTY_EXTENDED_PROPERTIES 0x80
10134c1900e6SMatthias Ringwald 
10144c1900e6SMatthias Ringwald // MARK: Attribute Property Flag, BTstack extension
10154c1900e6SMatthias Ringwald // value is asked from client
10164c1900e6SMatthias Ringwald #define ATT_PROPERTY_DYNAMIC             0x100
10174c1900e6SMatthias Ringwald // 128 bit UUID used
10184c1900e6SMatthias Ringwald #define ATT_PROPERTY_UUID128             0x200
10194c1900e6SMatthias Ringwald // Authentication required
10204c1900e6SMatthias Ringwald #define ATT_PROPERTY_AUTHENTICATION_REQUIRED 0x400
10214c1900e6SMatthias Ringwald // Authorization from user required
10224c1900e6SMatthias Ringwald #define ATT_PROPERTY_AUTHORIZATION_REQUIRED  0x800
10234c1900e6SMatthias Ringwald // Encryption key size stored in upper 4 bits, 0 == no encryption, encryption key size - 1 otherwise
10244c1900e6SMatthias Ringwald 
10254c1900e6SMatthias Ringwald // ATT Transaction Timeout of 30 seconds for Command/Response or Incidationc/Confirmation
10264c1900e6SMatthias Ringwald #define ATT_TRANSACTION_TIMEOUT_MS     30000
10274c1900e6SMatthias Ringwald 
10284c1900e6SMatthias Ringwald #define ATT_TRANSACTION_MODE_NONE      0x0
10294c1900e6SMatthias Ringwald #define ATT_TRANSACTION_MODE_ACTIVE    0x1
10304c1900e6SMatthias Ringwald #define ATT_TRANSACTION_MODE_EXECUTE   0x2
10314c1900e6SMatthias Ringwald #define ATT_TRANSACTION_MODE_CANCEL    0x3
10324c1900e6SMatthias Ringwald 
10334c1900e6SMatthias Ringwald // MARK: GATT UUIDs
10344c1900e6SMatthias Ringwald #define GATT_PRIMARY_SERVICE_UUID                   0x2800
10354c1900e6SMatthias Ringwald #define GATT_SECONDARY_SERVICE_UUID                 0x2801
10364c1900e6SMatthias Ringwald #define GATT_INCLUDE_SERVICE_UUID                   0x2802
10374c1900e6SMatthias Ringwald #define GATT_CHARACTERISTICS_UUID                   0x2803
10384c1900e6SMatthias Ringwald #define GATT_CHARACTERISTIC_EXTENDED_PROPERTIES     0x2900
10394c1900e6SMatthias Ringwald #define GATT_CHARACTERISTIC_USER_DESCRIPTION        0x2901
10404c1900e6SMatthias Ringwald #define GATT_CLIENT_CHARACTERISTICS_CONFIGURATION   0x2902
10414c1900e6SMatthias Ringwald #define GATT_SERVER_CHARACTERISTICS_CONFIGURATION   0x2903
10424c1900e6SMatthias Ringwald #define GATT_CHARACTERISTIC_PRESENTATION_FORMAT     0x2904
10434c1900e6SMatthias Ringwald #define GATT_CHARACTERISTIC_AGGREGATE_FORMAT        0x2905
10444c1900e6SMatthias Ringwald 
10454c1900e6SMatthias Ringwald #define GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NONE          0
10464c1900e6SMatthias Ringwald #define GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NOTIFICATION  1
10474c1900e6SMatthias Ringwald #define GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_INDICATION    2
10484c1900e6SMatthias Ringwald 
10494c1900e6SMatthias Ringwald // GAP Service and Characteristics
10504c1900e6SMatthias Ringwald #define GAP_SERVICE_UUID               0x1800
10514c1900e6SMatthias Ringwald #define GAP_DEVICE_NAME_UUID           0x2a00
10524c1900e6SMatthias Ringwald #define GAP_APPEARANCE_UUID            0x2a01
10534c1900e6SMatthias Ringwald #define GAP_PERIPHERAL_PRIVACY_FLAG    0x2a02
10544c1900e6SMatthias Ringwald #define GAP_RECONNECTION_ADDRESS_UUID  0x2a03
10554c1900e6SMatthias Ringwald #define GAP_PERIPHERAL_PREFERRED_CONNECTION_PARAMETERS_UUID 0x2a04
105617fe8172SMatthias Ringwald #define GAP_SERVICE_CHANGED            0x2a05
10574c1900e6SMatthias Ringwald 
10584c1900e6SMatthias Ringwald /**
10594c1900e6SMatthias Ringwald  * SM - LE Security Manager
10604c1900e6SMatthias Ringwald  */
10614c1900e6SMatthias Ringwald // Bluetooth Spec definitions
10624c1900e6SMatthias Ringwald typedef enum {
10634c1900e6SMatthias Ringwald     SM_CODE_PAIRING_REQUEST = 0X01,
10644c1900e6SMatthias Ringwald     SM_CODE_PAIRING_RESPONSE,
10654c1900e6SMatthias Ringwald     SM_CODE_PAIRING_CONFIRM,
10664c1900e6SMatthias Ringwald     SM_CODE_PAIRING_RANDOM,
10674c1900e6SMatthias Ringwald     SM_CODE_PAIRING_FAILED,
10684c1900e6SMatthias Ringwald     SM_CODE_ENCRYPTION_INFORMATION,
10694c1900e6SMatthias Ringwald     SM_CODE_MASTER_IDENTIFICATION,
10704c1900e6SMatthias Ringwald     SM_CODE_IDENTITY_INFORMATION,
10714c1900e6SMatthias Ringwald     SM_CODE_IDENTITY_ADDRESS_INFORMATION,
10724c1900e6SMatthias Ringwald     SM_CODE_SIGNING_INFORMATION,
107374a9b3d5SMatthias Ringwald     SM_CODE_SECURITY_REQUEST,
107474a9b3d5SMatthias Ringwald     SM_CODE_PAIRING_PUBLIC_KEY,
107574a9b3d5SMatthias Ringwald     SM_CODE_PAIRING_DHKEY_CHECK,
107644e8d9acSMatthias Ringwald     SM_CODE_KEYPRESS_NOTIFICATION,
10774c1900e6SMatthias Ringwald } SECURITY_MANAGER_COMMANDS;
10784c1900e6SMatthias Ringwald 
10794c1900e6SMatthias Ringwald // IO Capability Values
10804c1900e6SMatthias Ringwald typedef enum {
10814c1900e6SMatthias Ringwald     IO_CAPABILITY_DISPLAY_ONLY = 0,
10824c1900e6SMatthias Ringwald     IO_CAPABILITY_DISPLAY_YES_NO,
10834c1900e6SMatthias Ringwald     IO_CAPABILITY_KEYBOARD_ONLY,
10844c1900e6SMatthias Ringwald     IO_CAPABILITY_NO_INPUT_NO_OUTPUT,
10854c1900e6SMatthias Ringwald     IO_CAPABILITY_KEYBOARD_DISPLAY, // not used by secure simple pairing
10864c1900e6SMatthias Ringwald } io_capability_t;
10874c1900e6SMatthias Ringwald 
10884c1900e6SMatthias Ringwald // Authentication requirement flags
10894c1900e6SMatthias Ringwald #define SM_AUTHREQ_NO_BONDING        0x00
10904c1900e6SMatthias Ringwald #define SM_AUTHREQ_BONDING           0x01
10914c1900e6SMatthias Ringwald #define SM_AUTHREQ_MITM_PROTECTION   0x04
109274a9b3d5SMatthias Ringwald #define SM_AUTHREQ_SECURE_CONNECTION 0x08
109374a9b3d5SMatthias Ringwald #define SM_AUTHREQ_KEYPRESS          0x10
10944c1900e6SMatthias Ringwald 
10954c1900e6SMatthias Ringwald // Key distribution flags used by spec
109652f9cf63SMatthias Ringwald #define SM_KEYDIST_ENC_KEY  0x01
10974c1900e6SMatthias Ringwald #define SM_KEYDIST_ID_KEY   0x02
10984c1900e6SMatthias Ringwald #define SM_KEYDIST_SIGN     0x04
109952f9cf63SMatthias Ringwald #define SM_KEYDIST_LINK_KEY 0x08
11004c1900e6SMatthias Ringwald 
11014c1900e6SMatthias Ringwald // Key distribution flags used internally
11024c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_ENCRYPTION_INFORMATION       0x01
11034c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_MASTER_IDENTIFICATION        0x02
11044c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_IDENTITY_INFORMATION         0x04
11054c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_IDENTITY_ADDRESS_INFORMATION 0x08
11064c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_SIGNING_IDENTIFICATION       0x10
11074c1900e6SMatthias Ringwald 
11084c1900e6SMatthias Ringwald // STK Generation Methods
11094c1900e6SMatthias Ringwald #define SM_STK_GENERATION_METHOD_JUST_WORKS          0x01
11104c1900e6SMatthias Ringwald #define SM_STK_GENERATION_METHOD_OOB                 0x02
11114c1900e6SMatthias Ringwald #define SM_STK_GENERATION_METHOD_PASSKEY             0x04
1112b4343428SMatthias Ringwald #define SM_STK_GENERATION_METHOD_NUMERIC_COMPARISON  0x08
11134c1900e6SMatthias Ringwald 
11144c1900e6SMatthias Ringwald // Pairing Failed Reasons
11154c1900e6SMatthias Ringwald #define SM_REASON_RESERVED                     0x00
11164c1900e6SMatthias Ringwald #define SM_REASON_PASSKEYT_ENTRY_FAILED        0x01
11174c1900e6SMatthias Ringwald #define SM_REASON_OOB_NOT_AVAILABLE            0x02
11184c1900e6SMatthias Ringwald #define SM_REASON_AUTHENTHICATION_REQUIREMENTS 0x03
11194c1900e6SMatthias Ringwald #define SM_REASON_CONFIRM_VALUE_FAILED         0x04
11204c1900e6SMatthias Ringwald #define SM_REASON_PAIRING_NOT_SUPPORTED        0x05
11214c1900e6SMatthias Ringwald #define SM_REASON_ENCRYPTION_KEY_SIZE          0x06
11224c1900e6SMatthias Ringwald #define SM_REASON_COMMAND_NOT_SUPPORTED        0x07
11234c1900e6SMatthias Ringwald #define SM_REASON_UNSPECIFIED_REASON           0x08
11244c1900e6SMatthias Ringwald #define SM_REASON_REPEATED_ATTEMPTS            0x09
1125a9f29768SMatthias Ringwald #define SM_REASON_INVALID_PARAMETERS           0x0a
1126a9f29768SMatthias Ringwald #define SM_REASON_DHKEY_CHECK_FAILED           0x0b
1127a9f29768SMatthias Ringwald #define SM_REASON_NUMERIC_COMPARISON_FAILED    0x0c
1128a9f29768SMatthias Ringwald 
11294c1900e6SMatthias Ringwald // also, invalid parameters
11304c1900e6SMatthias Ringwald // and reserved
11314c1900e6SMatthias Ringwald 
113244e8d9acSMatthias Ringwald // Keypress Notifications
113344e8d9acSMatthias Ringwald #define SM_KEYPRESS_PASSKEY_ENTRY_STARTED      0x00
113444e8d9acSMatthias Ringwald #define SM_KEYPRESS_PASSKEY_DIGIT_ENTERED      0x01
113544e8d9acSMatthias Ringwald #define SM_KEYPRESS_PASSKEY_DIGIT_ERASED       0x02
113644e8d9acSMatthias Ringwald #define SM_KEYPRESS_PASSKEY_CLEARED            0x03
113744e8d9acSMatthias Ringwald #define SM_KEYPRESS_PASSKEY_ENTRY_COMPLETED    0x04
113844e8d9acSMatthias Ringwald 
113944e8d9acSMatthias Ringwald 
1140c6d1dbedSMatthias Ringwald // Company identifiers / manufacturers
1141c6d1dbedSMatthias Ringwald #define COMPANY_ID_CAMBRIDGE_SILICON_RADIO     0x000A
1142c6d1dbedSMatthias Ringwald #define COMPANY_ID_TEXAS_INSTRUMENTS_INC       0x000D
1143c6d1dbedSMatthias Ringwald #define COMPANY_ID_BROADCOM_CORPORATION        0x000F
1144c6d1dbedSMatthias Ringwald #define COMPANY_ID_ST_MICROELECTRONICS         0x0030
1145*33373e40SMatthias Ringwald #define COMPANY_ID_NORDIC_SEMICONDUCTOR_ASA    0x0059
1146c6d1dbedSMatthias Ringwald #define COMPANY_ID_EM_MICROELECTRONICS_MARIN   0x005A
1147c6d1dbedSMatthias Ringwald 
11484c1900e6SMatthias Ringwald 
114947f4e325SMatthias Ringwald #endif