xref: /btstack/src/bluetooth.h (revision ca0d73dee0f19ab32ba21fb4272d8cff820f9dd8)
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 /**
9947f4e325SMatthias Ringwald  * HCI Transport
10047f4e325SMatthias Ringwald  */
10147f4e325SMatthias Ringwald 
10247f4e325SMatthias Ringwald /**
10347f4e325SMatthias Ringwald  * packet types - used in BTstack and over the H4 UART interface
10447f4e325SMatthias Ringwald  */
10547f4e325SMatthias Ringwald #define HCI_COMMAND_DATA_PACKET 0x01
10647f4e325SMatthias Ringwald #define HCI_ACL_DATA_PACKET     0x02
10747f4e325SMatthias Ringwald #define HCI_SCO_DATA_PACKET     0x03
10847f4e325SMatthias Ringwald #define HCI_EVENT_PACKET        0x04
10947f4e325SMatthias Ringwald 
1108799c043SMatthias Ringwald // packet header sizes
1118799c043SMatthias Ringwald #define HCI_CMD_HEADER_SIZE          3
1128799c043SMatthias Ringwald #define HCI_ACL_HEADER_SIZE          4
1138799c043SMatthias Ringwald #define HCI_SCO_HEADER_SIZE          3
1148799c043SMatthias Ringwald #define HCI_EVENT_HEADER_SIZE        2
1158799c043SMatthias Ringwald 
11647f4e325SMatthias Ringwald /**
11747f4e325SMatthias Ringwald  * HCI Layer
11847f4e325SMatthias Ringwald  */
11947f4e325SMatthias Ringwald 
12047f4e325SMatthias Ringwald //
12147f4e325SMatthias Ringwald // Error Codes
12247f4e325SMatthias Ringwald //
12347f4e325SMatthias Ringwald 
12447f4e325SMatthias Ringwald // from Bluetooth Core Specification
125616edd56SMatthias Ringwald #define ERROR_CODE_SUCCESS                                 0x00
12647f4e325SMatthias Ringwald #define ERROR_CODE_UNKNOWN_HCI_COMMAND                     0x01
12747f4e325SMatthias Ringwald #define ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER           0x02
12847f4e325SMatthias Ringwald #define ERROR_CODE_HARDWARE_FAILURE                        0x03
12947f4e325SMatthias Ringwald #define ERROR_CODE_PAGE_TIMEOUT                            0x04
13047f4e325SMatthias Ringwald #define ERROR_CODE_AUTHENTICATION_FAILURE                  0x05
13147f4e325SMatthias Ringwald #define ERROR_CODE_PIN_OR_KEY_MISSING                      0x06
13247f4e325SMatthias Ringwald #define ERROR_CODE_MEMORY_CAPACITY_EXCEEDED                0x07
13347f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_TIMEOUT                      0x08
13447f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_LIMIT_EXCEEDED               0x09
13547f4e325SMatthias Ringwald #define ERROR_CODE_SYNCHRONOUS_CONNECTION_LIMIT_TO_A_DEVICE_EXCEEDED  0x0A
13647f4e325SMatthias Ringwald #define ERROR_CODE_ACL_CONNECTION_ALREADY_EXISTS           0x0B
13747f4e325SMatthias Ringwald #define ERROR_CODE_COMMAND_DISALLOWED                      0x0C
13847f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_REJECTED_DUE_TO_LIMITED_RESOURCES 0x0D
13947f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_REJECTED_DUE_TO_SECURITY_REASONS  0x0E
14047f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_REJECTED_DUE_TO_UNACCEPTABLE_BD_ADDR 0x0F
14147f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_ACCEPT_TIMEOUT_EXCEEDED      0x10
14247f4e325SMatthias Ringwald #define ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE  0x11
14347f4e325SMatthias Ringwald #define ERROR_CODE_INVALID_HCI_COMMAND_PARAMETERS          0x12
14447f4e325SMatthias Ringwald #define ERROR_CODE_REMOTE_USER_TERMINATED_CONNECTION       0x13
14547f4e325SMatthias Ringwald #define ERROR_CODE_REMOTE_DEVICE_TERMINATED_CONNECTION_DUE_TO_LOW_RESOURCES 0x14
14647f4e325SMatthias Ringwald #define ERROR_CODE_REMOTE_DEVICE_TERMINATED_CONNECTION_DUE_TO_POWER_OFF     0x15
14747f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_TERMINATED_BY_LOCAL_HOST     0x16
14847f4e325SMatthias Ringwald #define ERROR_CODE_REPEATED_ATTEMPTS                       0x17
14947f4e325SMatthias Ringwald #define ERROR_CODE_PAIRING_NOT_ALLOWED                     0x18
15047f4e325SMatthias Ringwald #define ERROR_CODE_UNKNOWN_LMP_PDU                         0x19
15147f4e325SMatthias Ringwald #define ERROR_CODE_UNSUPPORTED_REMOTE_FEATURE_UNSUPPORTED_LMP_FEATURE 0x1A
15247f4e325SMatthias Ringwald #define ERROR_CODE_SCO_OFFSET_REJECTED                     0x1B
15347f4e325SMatthias Ringwald #define ERROR_CODE_SCO_INTERVAL_REJECTED                   0x1C
15447f4e325SMatthias Ringwald #define ERROR_CODE_SCO_AIR_MODE_REJECTED                   0x1D
15547f4e325SMatthias Ringwald #define ERROR_CODE_INVALID_LMP_PARAMETERS_INVALID_LL_PARAMETERS 0x1E
15647f4e325SMatthias Ringwald #define ERROR_CODE_UNSPECIFIED_ERROR                       0x1F
15747f4e325SMatthias Ringwald #define ERROR_CODE_UNSUPPORTED_LMP_PARAMETER_VALUE_UNSUPPORTED_LL_PARAMETER_VALUE 0x20
15847f4e325SMatthias Ringwald #define ERROR_CODE_ROLE_CHANGE_NOT_ALLOWED                 0x21
15947f4e325SMatthias Ringwald #define ERROR_CODE_LMP_RESPONSE_TIMEOUT_LL_RESPONSE_TIMEOUT 0x22
16047f4e325SMatthias Ringwald #define ERROR_CODE_LMP_ERROR_TRANSACTION_COLLISION         0x23
16147f4e325SMatthias Ringwald #define ERROR_CODE_LMP_PDU_NOT_ALLOWED                     0x24
16247f4e325SMatthias Ringwald #define ERROR_CODE_ENCRYPTION_MODE_NOT_ACCEPTABLE          0x25
16347f4e325SMatthias Ringwald #define ERROR_CODE_LINK_KEY_CANNOT_BE_CHANGED              0x26
16447f4e325SMatthias Ringwald #define ERROR_CODE_REQUESTED_QOS_NOT_SUPPORTED             0x27
16547f4e325SMatthias Ringwald #define ERROR_CODE_INSTANT_PASSED                          0x28
16647f4e325SMatthias Ringwald #define ERROR_CODE_PAIRING_WITH_UNIT_KEY_NOT_SUPPORTED     0x29
16747f4e325SMatthias Ringwald #define ERROR_CODE_DIFFERENT_TRANSACTION_COLLISION         0x2A
16847f4e325SMatthias Ringwald #define ERROR_CODE_RESERVED                                0x2B
16947f4e325SMatthias Ringwald #define ERROR_CODE_QOS_UNACCEPTABLE_PARAMETER              0x2C
17047f4e325SMatthias Ringwald #define ERROR_CODE_QOS_REJECTED                            0x2D
17147f4e325SMatthias Ringwald #define ERROR_CODE_CHANNEL_CLASSIFICATION_NOT_SUPPORTED    0x2E
17247f4e325SMatthias Ringwald #define ERROR_CODE_INSUFFICIENT_SECURITY                   0x2F
17347f4e325SMatthias Ringwald #define ERROR_CODE_PARAMETER_OUT_OF_MANDATORY_RANGE        0x30
17447f4e325SMatthias Ringwald // #define ERROR_CODE_RESERVED
17547f4e325SMatthias Ringwald #define ERROR_CODE_ROLE_SWITCH_PENDING                     0x32
17647f4e325SMatthias Ringwald // #define ERROR_CODE_RESERVED
17747f4e325SMatthias Ringwald #define ERROR_CODE_RESERVED_SLOT_VIOLATION                 0x34
17847f4e325SMatthias Ringwald #define ERROR_CODE_ROLE_SWITCH_FAILED                      0x35
17947f4e325SMatthias Ringwald #define ERROR_CODE_EXTENDED_INQUIRY_RESPONSE_TOO_LARGE     0x36
18047f4e325SMatthias Ringwald #define ERROR_CODE_SECURE_SIMPLE_PAIRING_NOT_SUPPORTED_BY_HOST 0x37
18147f4e325SMatthias Ringwald #define ERROR_CODE_HOST_BUSY_PAIRING                       0x38
18247f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_REJECTED_DUE_TO_NO_SUITABLE_CHANNEL_FOUND 0x39
18347f4e325SMatthias Ringwald #define ERROR_CODE_CONTROLLER_BUSY                         0x3A
18447f4e325SMatthias Ringwald #define ERROR_CODE_UNACCEPTABLE_CONNECTION_PARAMETERS      0x3B
18547f4e325SMatthias Ringwald #define ERROR_CODE_DIRECTED_ADVERTISING_TIMEOUT            0x3C
18647f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_TERMINATED_DUE_TO_MIC_FAILURE 0x3D
18747f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_FAILED_TO_BE_ESTABLISHED     0x3E
18847f4e325SMatthias Ringwald #define ERROR_CODE_MAC_CONNECTION_FAILED                   0x3F
18947f4e325SMatthias Ringwald #define ERROR_CODE_COARSE_CLOCK_ADJUSTMENT_REJECTED_BUT_WILL_TRY_TO_ADJUST_USING_CLOCK_DRAGGING 0x40
19047f4e325SMatthias Ringwald 
1918799c043SMatthias Ringwald // HCI roles
1928799c043SMatthias Ringwald #define HCI_ROLE_MASTER 0
1938799c043SMatthias Ringwald #define HCI_ROLE_SLAVE  1
1948799c043SMatthias Ringwald 
1958799c043SMatthias Ringwald // packet sizes (max payload)
1968799c043SMatthias Ringwald #define HCI_ACL_DM1_SIZE            17
1978799c043SMatthias Ringwald #define HCI_ACL_DH1_SIZE            27
1988799c043SMatthias Ringwald #define HCI_ACL_2DH1_SIZE           54
1998799c043SMatthias Ringwald #define HCI_ACL_3DH1_SIZE           83
2008799c043SMatthias Ringwald #define HCI_ACL_DM3_SIZE           121
2018799c043SMatthias Ringwald #define HCI_ACL_DH3_SIZE           183
2028799c043SMatthias Ringwald #define HCI_ACL_DM5_SIZE           224
2038799c043SMatthias Ringwald #define HCI_ACL_DH5_SIZE           339
2048799c043SMatthias Ringwald #define HCI_ACL_2DH3_SIZE          367
2058799c043SMatthias Ringwald #define HCI_ACL_3DH3_SIZE          552
2068799c043SMatthias Ringwald #define HCI_ACL_2DH5_SIZE          679
2078799c043SMatthias Ringwald #define HCI_ACL_3DH5_SIZE         1021
2088799c043SMatthias Ringwald 
2098799c043SMatthias Ringwald #define HCI_EVENT_PAYLOAD_SIZE     255
2108799c043SMatthias Ringwald #define HCI_CMD_PAYLOAD_SIZE       255
2118799c043SMatthias Ringwald 
2128799c043SMatthias Ringwald #define LE_ADVERTISING_DATA_SIZE    31
21347f4e325SMatthias Ringwald 
21447f4e325SMatthias Ringwald /**
21547f4e325SMatthias Ringwald  * Default INQ Mode
21647f4e325SMatthias Ringwald  */
21747f4e325SMatthias Ringwald #define HCI_INQUIRY_LAP 0x9E8B33L  // 0x9E8B33: General/Unlimited Inquiry Access Code (GIAC)
21847f4e325SMatthias Ringwald 
21947f4e325SMatthias Ringwald /**
22047f4e325SMatthias Ringwald  * SSP IO Capabilities
22147f4e325SMatthias Ringwald  */
22247f4e325SMatthias Ringwald #define SSP_IO_CAPABILITY_DISPLAY_ONLY   0
22347f4e325SMatthias Ringwald #define SSP_IO_CAPABILITY_DISPLAY_YES_NO 1
22447f4e325SMatthias Ringwald #define SSP_IO_CAPABILITY_KEYBOARD_ONLY  2
22547f4e325SMatthias Ringwald #define SSP_IO_CAPABILITY_NO_INPUT_NO_OUTPUT 3
22647f4e325SMatthias Ringwald #define SSP_IO_CAPABILITY_UNKNOWN 0xff
22747f4e325SMatthias Ringwald 
22847f4e325SMatthias Ringwald 
22947f4e325SMatthias Ringwald /**
23047f4e325SMatthias Ringwald  * SSP Authentication Requirements, see IO Capability Request Reply Commmand
23147f4e325SMatthias Ringwald  */
23247f4e325SMatthias Ringwald 
23347f4e325SMatthias Ringwald // Numeric comparison with automatic accept allowed.
23447f4e325SMatthias Ringwald #define SSP_IO_AUTHREQ_MITM_PROTECTION_NOT_REQUIRED_NO_BONDING 0x00
23547f4e325SMatthias Ringwald 
23647f4e325SMatthias Ringwald // Use IO Capabilities to deter- mine authentication procedure
23747f4e325SMatthias Ringwald #define SSP_IO_AUTHREQ_MITM_PROTECTION_REQUIRED_NO_BONDING 0x01
23847f4e325SMatthias Ringwald 
23947f4e325SMatthias Ringwald // Numeric compar- ison with automatic accept allowed.
24047f4e325SMatthias Ringwald #define SSP_IO_AUTHREQ_MITM_PROTECTION_NOT_REQUIRED_DEDICATED_BONDING 0x02
24147f4e325SMatthias Ringwald 
24247f4e325SMatthias Ringwald // Use IO Capabilities to determine authentication procedure
24347f4e325SMatthias Ringwald #define SSP_IO_AUTHREQ_MITM_PROTECTION_REQUIRED_DEDICATED_BONDING 0x03
24447f4e325SMatthias Ringwald 
24547f4e325SMatthias Ringwald // Numeric Compari- son with automatic accept allowed.
24647f4e325SMatthias Ringwald #define SSP_IO_AUTHREQ_MITM_PROTECTION_NOT_REQUIRED_GENERAL_BONDING 0x04
24747f4e325SMatthias Ringwald 
2488799c043SMatthias Ringwald // Use IO capabilities to determine authentication procedure.
24947f4e325SMatthias Ringwald #define SSP_IO_AUTHREQ_MITM_PROTECTION_REQUIRED_GENERAL_BONDING 0x05
25047f4e325SMatthias Ringwald 
25147f4e325SMatthias Ringwald 
2528799c043SMatthias Ringwald // OGFs
2538799c043SMatthias Ringwald #define OGF_LINK_CONTROL          0x01
2548799c043SMatthias Ringwald #define OGF_LINK_POLICY           0x02
2558799c043SMatthias Ringwald #define OGF_CONTROLLER_BASEBAND   0x03
2568799c043SMatthias Ringwald #define OGF_INFORMATIONAL_PARAMETERS 0x04
2578799c043SMatthias Ringwald #define OGF_STATUS_PARAMETERS     0x05
2588799c043SMatthias Ringwald #define OGF_TESTING               0x06
2598799c043SMatthias Ringwald #define OGF_LE_CONTROLLER 0x08
2608799c043SMatthias Ringwald #define OGF_VENDOR  0x3f
2618799c043SMatthias Ringwald 
2628799c043SMatthias Ringwald 
26347f4e325SMatthias Ringwald // Events from host controller to host
26447f4e325SMatthias Ringwald 
26547f4e325SMatthias Ringwald /**
26647f4e325SMatthias Ringwald  * @format 1
26747f4e325SMatthias Ringwald  * @param status
26847f4e325SMatthias Ringwald  */
26947f4e325SMatthias Ringwald #define HCI_EVENT_INQUIRY_COMPLETE                         0x01
27047f4e325SMatthias Ringwald // no format yet, can contain multiple results
27147f4e325SMatthias Ringwald 
27247f4e325SMatthias Ringwald /**
27347f4e325SMatthias Ringwald  * @format 1B11132
27447f4e325SMatthias Ringwald  * @param num_responses
27547f4e325SMatthias Ringwald  * @param bd_addr
27647f4e325SMatthias Ringwald  * @param page_scan_repetition_mode
27747f4e325SMatthias Ringwald  * @param reserved1
27847f4e325SMatthias Ringwald  * @param reserved2
27947f4e325SMatthias Ringwald  * @param class_of_device
28047f4e325SMatthias Ringwald  * @param clock_offset
28147f4e325SMatthias Ringwald  */
28247f4e325SMatthias Ringwald #define HCI_EVENT_INQUIRY_RESULT                           0x02
28347f4e325SMatthias Ringwald 
28447f4e325SMatthias Ringwald /**
28547f4e325SMatthias Ringwald  * @format 12B11
28647f4e325SMatthias Ringwald  * @param status
28747f4e325SMatthias Ringwald  * @param connection_handle
28847f4e325SMatthias Ringwald  * @param bd_addr
28947f4e325SMatthias Ringwald  * @param link_type
29047f4e325SMatthias Ringwald  * @param encryption_enabled
29147f4e325SMatthias Ringwald  */
29247f4e325SMatthias Ringwald #define HCI_EVENT_CONNECTION_COMPLETE                      0x03
29347f4e325SMatthias Ringwald /**
29447f4e325SMatthias Ringwald  * @format B31
29547f4e325SMatthias Ringwald  * @param bd_addr
29647f4e325SMatthias Ringwald  * @param class_of_device
29747f4e325SMatthias Ringwald  * @param link_type
29847f4e325SMatthias Ringwald  */
29947f4e325SMatthias Ringwald #define HCI_EVENT_CONNECTION_REQUEST                       0x04
30047f4e325SMatthias Ringwald /**
30147f4e325SMatthias Ringwald  * @format 121
30247f4e325SMatthias Ringwald  * @param status
30347f4e325SMatthias Ringwald  * @param connection_handle
30447f4e325SMatthias Ringwald  * @param reason
30547f4e325SMatthias Ringwald  */
30647f4e325SMatthias Ringwald #define HCI_EVENT_DISCONNECTION_COMPLETE                   0x05
30747f4e325SMatthias Ringwald /**
30847f4e325SMatthias Ringwald  * @format 12
30947f4e325SMatthias Ringwald  * @param status
31047f4e325SMatthias Ringwald  * @param connection_handle
31147f4e325SMatthias Ringwald  */
31247f4e325SMatthias Ringwald #define HCI_EVENT_AUTHENTICATION_COMPLETE_EVENT            0x06
31347f4e325SMatthias Ringwald /**
31447f4e325SMatthias Ringwald  * @format 1BN
31547f4e325SMatthias Ringwald  * @param status
31647f4e325SMatthias Ringwald  * @param bd_addr
31747f4e325SMatthias Ringwald  * @param remote_name
31847f4e325SMatthias Ringwald  */
31947f4e325SMatthias Ringwald #define HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE             0x07
32047f4e325SMatthias Ringwald /**
32147f4e325SMatthias Ringwald  * @format 121
32247f4e325SMatthias Ringwald  * @param status
32347f4e325SMatthias Ringwald  * @param connection_handle
32447f4e325SMatthias Ringwald  * @param encryption_enabled
32547f4e325SMatthias Ringwald  */
32647f4e325SMatthias Ringwald #define HCI_EVENT_ENCRYPTION_CHANGE                        0x08
32747f4e325SMatthias Ringwald /**
32847f4e325SMatthias Ringwald  * @format 12
32947f4e325SMatthias Ringwald  * @param status
33047f4e325SMatthias Ringwald  * @param connection_handle
33147f4e325SMatthias Ringwald  */
33247f4e325SMatthias Ringwald #define HCI_EVENT_CHANGE_CONNECTION_LINK_KEY_COMPLETE      0x09
33347f4e325SMatthias Ringwald /**
33447f4e325SMatthias Ringwald  * @format 121
33547f4e325SMatthias Ringwald  * @param status
33647f4e325SMatthias Ringwald  * @param connection_handle
33747f4e325SMatthias Ringwald  * @param key_flag
33847f4e325SMatthias Ringwald  */
33947f4e325SMatthias Ringwald #define HCI_EVENT_MASTER_LINK_KEY_COMPLETE                 0x0A
34047f4e325SMatthias Ringwald #define HCI_EVENT_READ_REMOTE_SUPPORTED_FEATURES_COMPLETE  0x0B
34147f4e325SMatthias Ringwald #define HCI_EVENT_READ_REMOTE_VERSION_INFORMATION_COMPLETE 0x0C
34247f4e325SMatthias Ringwald #define HCI_EVENT_QOS_SETUP_COMPLETE                       0x0D
34347f4e325SMatthias Ringwald 
34447f4e325SMatthias Ringwald /**
34547f4e325SMatthias Ringwald  * @format 12R
34647f4e325SMatthias Ringwald  * @param num_hci_command_packets
34747f4e325SMatthias Ringwald  * @param command_opcode
34847f4e325SMatthias Ringwald  * @param return_parameters
34947f4e325SMatthias Ringwald  */
35047f4e325SMatthias Ringwald #define HCI_EVENT_COMMAND_COMPLETE                         0x0E
35147f4e325SMatthias Ringwald /**
35247f4e325SMatthias Ringwald  * @format 112
35347f4e325SMatthias Ringwald  * @param status
35447f4e325SMatthias Ringwald  * @param num_hci_command_packets
35547f4e325SMatthias Ringwald  * @param command_opcode
35647f4e325SMatthias Ringwald  */
35747f4e325SMatthias Ringwald #define HCI_EVENT_COMMAND_STATUS                           0x0F
35847f4e325SMatthias Ringwald 
35947f4e325SMatthias Ringwald /**
36047f4e325SMatthias Ringwald  * @format 121
36147f4e325SMatthias Ringwald  * @param hardware_code
36247f4e325SMatthias Ringwald  */
36347f4e325SMatthias Ringwald #define HCI_EVENT_HARDWARE_ERROR                           0x10
36447f4e325SMatthias Ringwald 
36547f4e325SMatthias Ringwald #define HCI_EVENT_FLUSH_OCCURED                            0x11
36647f4e325SMatthias Ringwald 
36747f4e325SMatthias Ringwald /**
36847f4e325SMatthias Ringwald  * @format 1B1
36947f4e325SMatthias Ringwald  * @param status
37047f4e325SMatthias Ringwald  * @param bd_addr
37147f4e325SMatthias Ringwald  * @param role
37247f4e325SMatthias Ringwald  */
37347f4e325SMatthias Ringwald #define HCI_EVENT_ROLE_CHANGE                              0x12
37447f4e325SMatthias Ringwald 
37547f4e325SMatthias Ringwald #define HCI_EVENT_NUMBER_OF_COMPLETED_PACKETS              0x13
37647f4e325SMatthias Ringwald #define HCI_EVENT_MODE_CHANGE_EVENT                        0x14
37747f4e325SMatthias Ringwald #define HCI_EVENT_RETURN_LINK_KEYS                         0x15
37847f4e325SMatthias Ringwald #define HCI_EVENT_PIN_CODE_REQUEST                         0x16
37947f4e325SMatthias Ringwald #define HCI_EVENT_LINK_KEY_REQUEST                         0x17
38047f4e325SMatthias Ringwald #define HCI_EVENT_LINK_KEY_NOTIFICATION                    0x18
38147f4e325SMatthias Ringwald #define HCI_EVENT_DATA_BUFFER_OVERFLOW                     0x1A
38247f4e325SMatthias Ringwald #define HCI_EVENT_MAX_SLOTS_CHANGED                        0x1B
38347f4e325SMatthias Ringwald #define HCI_EVENT_READ_CLOCK_OFFSET_COMPLETE               0x1C
38447f4e325SMatthias Ringwald #define HCI_EVENT_PACKET_TYPE_CHANGED                      0x1D
38547f4e325SMatthias Ringwald 
38647f4e325SMatthias Ringwald /**
38747f4e325SMatthias Ringwald  * @format 1B11321
38847f4e325SMatthias Ringwald  * @param num_responses
38947f4e325SMatthias Ringwald  * @param bd_addr
39047f4e325SMatthias Ringwald  * @param page_scan_repetition_mode
39147f4e325SMatthias Ringwald  * @param reserved
39247f4e325SMatthias Ringwald  * @param class_of_device
39347f4e325SMatthias Ringwald  * @param clock_offset
39447f4e325SMatthias Ringwald  * @param rssi
39547f4e325SMatthias Ringwald  */
39647f4e325SMatthias Ringwald #define HCI_EVENT_INQUIRY_RESULT_WITH_RSSI                 0x22
39747f4e325SMatthias Ringwald 
39847f4e325SMatthias Ringwald /**
39947f4e325SMatthias Ringwald  * @format 1HB111221
40047f4e325SMatthias Ringwald  * @param status
40147f4e325SMatthias Ringwald  * @param handle
40247f4e325SMatthias Ringwald  * @param bd_addr
40347f4e325SMatthias Ringwald  * @param link_type
40447f4e325SMatthias Ringwald  * @param transmission_interval
40547f4e325SMatthias Ringwald  * @param retransmission_interval
40647f4e325SMatthias Ringwald  * @param rx_packet_length
40747f4e325SMatthias Ringwald  * @param tx_packet_length
40847f4e325SMatthias Ringwald  * @param air_mode
40947f4e325SMatthias Ringwald  */
41047f4e325SMatthias Ringwald #define HCI_EVENT_SYNCHRONOUS_CONNECTION_COMPLETE          0x2C
41147f4e325SMatthias Ringwald 
41247f4e325SMatthias Ringwald // TODO: serialize extended_inquiry_response and provide parser
41347f4e325SMatthias Ringwald /**
41447f4e325SMatthias Ringwald  * @format 1B11321
41547f4e325SMatthias Ringwald  * @param num_responses
41647f4e325SMatthias Ringwald  * @param bd_addr
41747f4e325SMatthias Ringwald  * @param page_scan_repetition_mode
41847f4e325SMatthias Ringwald  * @param reserved
41947f4e325SMatthias Ringwald  * @param class_of_device
42047f4e325SMatthias Ringwald  * @param clock_offset
42147f4e325SMatthias Ringwald  * @param rssi
42247f4e325SMatthias Ringwald  */
42347f4e325SMatthias Ringwald #define HCI_EVENT_EXTENDED_INQUIRY_RESPONSE                0x2F
42447f4e325SMatthias Ringwald 
42547f4e325SMatthias Ringwald  /**
42647f4e325SMatthias Ringwald   * @format 1H
42747f4e325SMatthias Ringwald   * @param status
42847f4e325SMatthias Ringwald   * @param handle
42947f4e325SMatthias Ringwald   */
43047f4e325SMatthias Ringwald #define HCI_EVENT_ENCRYPTION_KEY_REFRESH_COMPLETE          0x30
43147f4e325SMatthias Ringwald 
43247f4e325SMatthias Ringwald #define HCI_EVENT_IO_CAPABILITY_REQUEST                    0x31
43347f4e325SMatthias Ringwald #define HCI_EVENT_IO_CAPABILITY_RESPONSE                   0x32
43447f4e325SMatthias Ringwald #define HCI_EVENT_USER_CONFIRMATION_REQUEST                0x33
43547f4e325SMatthias Ringwald #define HCI_EVENT_USER_PASSKEY_REQUEST                     0x34
43647f4e325SMatthias Ringwald #define HCI_EVENT_REMOTE_OOB_DATA_REQUEST                  0x35
43747f4e325SMatthias Ringwald #define HCI_EVENT_SIMPLE_PAIRING_COMPLETE                  0x36
43847f4e325SMatthias Ringwald 
43947f4e325SMatthias Ringwald #define HCI_EVENT_LE_META                                  0x3E
44047f4e325SMatthias Ringwald 
441941b3855SMatthias Ringwald #define HCI_EVENT_VENDOR_SPECIFIC                          0xFF
442941b3855SMatthias Ringwald 
44347f4e325SMatthias Ringwald /**
444*ca0d73deSMatthias Ringwald  * @format 11H11B2221
44547f4e325SMatthias Ringwald  * @param subevent_code
44647f4e325SMatthias Ringwald  * @param status
44747f4e325SMatthias Ringwald  * @param connection_handle
44847f4e325SMatthias Ringwald  * @param role
44947f4e325SMatthias Ringwald  * @param peer_address_type
45047f4e325SMatthias Ringwald  * @param peer_address
45147f4e325SMatthias Ringwald  * @param conn_interval
45247f4e325SMatthias Ringwald  * @param conn_latency
45347f4e325SMatthias Ringwald  * @param supervision_timeout
45447f4e325SMatthias Ringwald  * @param master_clock_accuracy
45547f4e325SMatthias Ringwald  */
45647f4e325SMatthias Ringwald #define HCI_SUBEVENT_LE_CONNECTION_COMPLETE                0x01
45747f4e325SMatthias Ringwald #define HCI_SUBEVENT_LE_ADVERTISING_REPORT                 0x02
45847f4e325SMatthias Ringwald #define HCI_SUBEVENT_LE_CONNECTION_UPDATE_COMPLETE         0x03
45947f4e325SMatthias Ringwald #define HCI_SUBEVENT_LE_READ_REMOTE_USED_FEATURES_COMPLETE 0x04
46047f4e325SMatthias Ringwald #define HCI_SUBEVENT_LE_LONG_TERM_KEY_REQUEST              0x05
46147f4e325SMatthias Ringwald 
46247f4e325SMatthias Ringwald // last used HCI_EVENT in 2.1 is 0x3d
46347f4e325SMatthias Ringwald // last used HCI_EVENT in 4.1 is 0x57
46447f4e325SMatthias Ringwald 
46547f4e325SMatthias Ringwald /**
46647f4e325SMatthias Ringwald  * L2CAP Layer
46747f4e325SMatthias Ringwald  */
46847f4e325SMatthias Ringwald 
469a8373a41SMatthias Ringwald #define L2CAP_HEADER_SIZE 4
470a8373a41SMatthias Ringwald 
471a8373a41SMatthias Ringwald #define L2CAP_SIG_ID_INVALID 0
472a8373a41SMatthias Ringwald 
473a8373a41SMatthias Ringwald // size of HCI ACL + L2CAP Header for regular data packets (8)
474a8373a41SMatthias Ringwald #define COMPLETE_L2CAP_HEADER (HCI_ACL_HEADER_SIZE + L2CAP_HEADER_SIZE)
475a8373a41SMatthias Ringwald 
476a8373a41SMatthias Ringwald // minimum signaling MTU
477a8373a41SMatthias Ringwald #define L2CAP_MINIMAL_MTU 48
478a8373a41SMatthias Ringwald #define L2CAP_DEFAULT_MTU 672
479a8373a41SMatthias Ringwald 
480a8373a41SMatthias Ringwald // Minimum/default MTU
481a8373a41SMatthias Ringwald #define L2CAP_LE_DEFAULT_MTU  23
482a8373a41SMatthias Ringwald 
483a8373a41SMatthias Ringwald // L2CAP Fixed Channel IDs
484a8373a41SMatthias Ringwald #define L2CAP_CID_SIGNALING                 0x0001
485a8373a41SMatthias Ringwald #define L2CAP_CID_CONNECTIONLESS_CHANNEL    0x0002
486a8373a41SMatthias Ringwald #define L2CAP_CID_ATTRIBUTE_PROTOCOL        0x0004
487a8373a41SMatthias Ringwald #define L2CAP_CID_SIGNALING_LE              0x0005
488a8373a41SMatthias Ringwald #define L2CAP_CID_SECURITY_MANAGER_PROTOCOL 0x0006
489a8373a41SMatthias Ringwald 
490a8373a41SMatthias Ringwald // L2CAP Configuration Result Codes
491a8373a41SMatthias Ringwald #define L2CAP_CONF_RESULT_UNKNOWN_OPTIONS   0x0003
492a8373a41SMatthias Ringwald 
493a8373a41SMatthias Ringwald // L2CAP Reject Result Codes
494a8373a41SMatthias Ringwald #define L2CAP_REJ_CMD_UNKNOWN               0x0000
495a8373a41SMatthias Ringwald 
496a8373a41SMatthias Ringwald // Response Timeout eXpired
497a8373a41SMatthias Ringwald #define L2CAP_RTX_TIMEOUT_MS   10000
498a8373a41SMatthias Ringwald 
499a8373a41SMatthias Ringwald // Extended Response Timeout eXpired
500a8373a41SMatthias Ringwald #define L2CAP_ERTX_TIMEOUT_MS 120000
501a8373a41SMatthias Ringwald 
50247f4e325SMatthias Ringwald // Fixed PSM numbers
50347f4e325SMatthias Ringwald #define PSM_SDP           0x01
50447f4e325SMatthias Ringwald #define PSM_RFCOMM        0x03
50547f4e325SMatthias Ringwald #define PSM_BNEP          0x0F
50647f4e325SMatthias Ringwald #define PSM_HID_CONTROL   0x11
50747f4e325SMatthias Ringwald #define PSM_HID_INTERRUPT 0x13
50847f4e325SMatthias Ringwald 
50966b1fcb3SMatthias Ringwald /**
510ef907034SMatthias Ringwald  * SDP Protocl
511ef907034SMatthias Ringwald  */
512ef907034SMatthias Ringwald 
513ef907034SMatthias Ringwald  // PDU Types
514ef907034SMatthias Ringwald typedef enum {
515ef907034SMatthias Ringwald     SDP_Invalid = 0,
516ef907034SMatthias Ringwald     SDP_ErrorResponse = 1,
517ef907034SMatthias Ringwald     SDP_ServiceSearchRequest,
518ef907034SMatthias Ringwald     SDP_ServiceSearchResponse,
519ef907034SMatthias Ringwald     SDP_ServiceAttributeRequest,
520ef907034SMatthias Ringwald     SDP_ServiceAttributeResponse,
521ef907034SMatthias Ringwald     SDP_ServiceSearchAttributeRequest,
522ef907034SMatthias Ringwald     SDP_ServiceSearchAttributeResponse
523ef907034SMatthias Ringwald } SDP_PDU_ID_t;
524ef907034SMatthias Ringwald 
525ef907034SMatthias Ringwald // UNIVERSAL ATTRIBUTE DEFINITIONS
526ef907034SMatthias Ringwald #define SDP_ServiceRecordHandle     0x0000
527ef907034SMatthias Ringwald #define SDP_ServiceClassIDList      0x0001
528ef907034SMatthias Ringwald #define SDP_ServiceRecordState      0x0002
529ef907034SMatthias Ringwald #define SDP_ServiceID               0x0003
530ef907034SMatthias Ringwald #define SDP_ProtocolDescriptorList  0x0004
531ef907034SMatthias Ringwald #define SDP_BrowseGroupList         0x0005
532ef907034SMatthias Ringwald #define SDP_LanguageBaseAttributeIDList 0x0006
533ef907034SMatthias Ringwald #define SDP_ServiceInfoTimeToLive   0x0007
534ef907034SMatthias Ringwald #define SDP_ServiceAvailability     0x0008
535ef907034SMatthias Ringwald #define SDP_BluetoothProfileDescriptorList 0x0009
536ef907034SMatthias Ringwald #define SDP_DocumentationURL        0x000a
537ef907034SMatthias Ringwald #define SDP_ClientExecutableURL     0x000b
538ef907034SMatthias Ringwald #define SDP_IconURL                 0x000c
539ef907034SMatthias Ringwald #define SDP_AdditionalProtocolDescriptorList 0x000d
540ef907034SMatthias Ringwald #define SDP_SupportedFormatsList    0x0303
541ef907034SMatthias Ringwald 
542ef907034SMatthias Ringwald // SERVICE CLASSES
543ef907034SMatthias Ringwald #define SDP_OBEXObjectPush          0x1105
544ef907034SMatthias Ringwald #define SDP_OBEXFileTransfer        0x1106
545ef907034SMatthias Ringwald #define SDP_PublicBrowseGroup       0x1002
546ef907034SMatthias Ringwald #define SDP_HSP                     0x1108
547ef907034SMatthias Ringwald #define SDP_Headset_AG              0x1112
548ef907034SMatthias Ringwald #define SDP_PANU                    0x1115
549ef907034SMatthias Ringwald #define SDP_NAP                     0x1116
550ef907034SMatthias Ringwald #define SDP_GN                      0x1117
551ef907034SMatthias Ringwald #define SDP_Handsfree               0x111E
552ef907034SMatthias Ringwald #define SDP_HandsfreeAudioGateway   0x111F
553ef907034SMatthias Ringwald #define SDP_Headset_HS              0x1131
554ef907034SMatthias Ringwald #define SDP_GenericAudio            0x1203
555ef907034SMatthias Ringwald 
556ef907034SMatthias Ringwald 
557ef907034SMatthias Ringwald // PROTOCOLS
558ef907034SMatthias Ringwald #define SDP_SDPProtocol       0x0001
559ef907034SMatthias Ringwald #define SDP_UDPProtocol       0x0002
560ef907034SMatthias Ringwald #define SDP_RFCOMMProtocol    0x0003
561ef907034SMatthias Ringwald #define SDP_OBEXProtocol      0x0008
562ef907034SMatthias Ringwald #define SDP_L2CAPProtocol     0x0100
563ef907034SMatthias Ringwald #define SDP_BNEPProtocol      0x000F
564ef907034SMatthias Ringwald #define SDP_AVDTPProtocol     0x0019
565ef907034SMatthias Ringwald 
566ef907034SMatthias Ringwald // OFFSETS FOR LOCALIZED ATTRIBUTES - SDP_LanguageBaseAttributeIDList
567ef907034SMatthias Ringwald #define SDP_Offest_ServiceName      0x0000
568ef907034SMatthias Ringwald #define SDP_Offest_ServiceDescription 0x0001
569ef907034SMatthias Ringwald #define SDP_Offest_ProviderName     0x0002
570ef907034SMatthias Ringwald 
571ef907034SMatthias Ringwald // OBEX
572ef907034SMatthias Ringwald #define SDP_vCard_2_1       0x01
573ef907034SMatthias Ringwald #define SDP_vCard_3_0       0x02
574ef907034SMatthias Ringwald #define SDP_vCal_1_0        0x03
575ef907034SMatthias Ringwald #define SDP_iCal_2_0        0x04
576ef907034SMatthias Ringwald #define SDP_vNote           0x05
577ef907034SMatthias Ringwald #define SDP_vMessage        0x06
578ef907034SMatthias Ringwald #define SDP_OBEXFileTypeAny 0xFF
579ef907034SMatthias Ringwald 
580ef907034SMatthias Ringwald /**
581e2577bd7SMatthias Ringwald  * RFCOMM Protocol
582e2577bd7SMatthias Ringwald  */
583e2577bd7SMatthias Ringwald 
584e2577bd7SMatthias Ringwald // Control field values      bit no.       1 2 3 4 PF 6 7 8
585e2577bd7SMatthias Ringwald #define BT_RFCOMM_SABM       0x3F       // 1 1 1 1  1 1 0 0
586e2577bd7SMatthias Ringwald #define BT_RFCOMM_UA         0x73       // 1 1 0 0  1 1 1 0
587e2577bd7SMatthias Ringwald #define BT_RFCOMM_DM         0x0F       // 1 1 1 1  0 0 0 0
588e2577bd7SMatthias Ringwald #define BT_RFCOMM_DM_PF      0x1F       // 1 1 1 1  1 0 0 0
589e2577bd7SMatthias Ringwald #define BT_RFCOMM_DISC       0x53       // 1 1 0 0  1 0 1 0
590e2577bd7SMatthias Ringwald #define BT_RFCOMM_UIH        0xEF       // 1 1 1 1  0 1 1 1
591e2577bd7SMatthias Ringwald #define BT_RFCOMM_UIH_PF     0xFF       // 1 1 1 1  0 1 1 1
592e2577bd7SMatthias Ringwald 
593e2577bd7SMatthias Ringwald // Multiplexer message types
594e2577bd7SMatthias Ringwald #define BT_RFCOMM_CLD_CMD    0xC3
595e2577bd7SMatthias Ringwald #define BT_RFCOMM_FCON_CMD   0xA3
596e2577bd7SMatthias Ringwald #define BT_RFCOMM_FCON_RSP   0xA1
597e2577bd7SMatthias Ringwald #define BT_RFCOMM_FCOFF_CMD  0x63
598e2577bd7SMatthias Ringwald #define BT_RFCOMM_FCOFF_RSP  0x61
599e2577bd7SMatthias Ringwald #define BT_RFCOMM_MSC_CMD    0xE3
600e2577bd7SMatthias Ringwald #define BT_RFCOMM_MSC_RSP    0xE1
601e2577bd7SMatthias Ringwald #define BT_RFCOMM_NSC_RSP    0x11
602e2577bd7SMatthias Ringwald #define BT_RFCOMM_PN_CMD     0x83
603e2577bd7SMatthias Ringwald #define BT_RFCOMM_PN_RSP     0x81
604e2577bd7SMatthias Ringwald #define BT_RFCOMM_RLS_CMD    0x53
605e2577bd7SMatthias Ringwald #define BT_RFCOMM_RLS_RSP    0x51
606e2577bd7SMatthias Ringwald #define BT_RFCOMM_RPN_CMD    0x93
607e2577bd7SMatthias Ringwald #define BT_RFCOMM_RPN_RSP    0x91
608e2577bd7SMatthias Ringwald #define BT_RFCOMM_TEST_CMD   0x23
609e2577bd7SMatthias Ringwald #define BT_RFCOMM_TEST_RSP   0x21
610e2577bd7SMatthias Ringwald 
611e2577bd7SMatthias Ringwald // Line Status
612e2577bd7SMatthias Ringwald #define LINE_STATUS_NO_ERROR       0x00
613e2577bd7SMatthias Ringwald #define LINE_STATUS_OVERRUN_ERROR  0x03
614e2577bd7SMatthias Ringwald #define LINE_STATUS_PARITY_ERORR   0x05
615e2577bd7SMatthias Ringwald #define LINE_STATUS_FRAMING_ERROR  0x09
616e2577bd7SMatthias Ringwald 
617e2577bd7SMatthias Ringwald // Modem Status Flags
618e2577bd7SMatthias Ringwald #define MODEM_STATUS_FC   0x02
619e2577bd7SMatthias Ringwald #define MODEM_STATUS_RTC  0x04
620e2577bd7SMatthias Ringwald #define MODEM_STATUS_RTR  0x08
621e2577bd7SMatthias Ringwald #define MODEM_STATUS_IC   0x40
622e2577bd7SMatthias Ringwald #define MODEM_STATUS_DV   0x80
623e2577bd7SMatthias Ringwald 
624e2577bd7SMatthias Ringwald typedef enum rpn_baud {
625e2577bd7SMatthias Ringwald     RPN_BAUD_2400 = 0,
626e2577bd7SMatthias Ringwald     RPN_BAUD_4800,
627e2577bd7SMatthias Ringwald     RPN_BAUD_7200,
628e2577bd7SMatthias Ringwald     RPN_BAUD_9600,
629e2577bd7SMatthias Ringwald     RPN_BAUD_19200,
630e2577bd7SMatthias Ringwald     RPN_BAUD_38400,
631e2577bd7SMatthias Ringwald     RPN_BAUD_57600,
632e2577bd7SMatthias Ringwald     RPN_BAUD_115200,
633e2577bd7SMatthias Ringwald     RPN_BAUD_230400
634e2577bd7SMatthias Ringwald } rpn_baud_t;
635e2577bd7SMatthias Ringwald 
636e2577bd7SMatthias Ringwald typedef enum rpn_data_bits {
637e2577bd7SMatthias Ringwald     RPN_DATA_BITS_5 = 0,
638e2577bd7SMatthias Ringwald     RPN_DATA_BITS_6 = 0,
639e2577bd7SMatthias Ringwald     RPN_DATA_BITS_7 = 0,
640e2577bd7SMatthias Ringwald     RPN_DATA_BITS_8 = 0
641e2577bd7SMatthias Ringwald } rpn_data_bits_t;
642e2577bd7SMatthias Ringwald 
643e2577bd7SMatthias Ringwald typedef enum rpn_stop_bits {
644e2577bd7SMatthias Ringwald     RPN_STOP_BITS_1_0 = 0,
645e2577bd7SMatthias Ringwald     RPN_STOP_BITS_1_5
646e2577bd7SMatthias Ringwald } rpn_stop_bits_t;
647e2577bd7SMatthias Ringwald 
648e2577bd7SMatthias Ringwald typedef enum rpn_parity {
649e2577bd7SMatthias Ringwald     RPN_PARITY_NONE  = 0,
650e2577bd7SMatthias Ringwald     RPN_PARITY_ODD   = 1,
651e2577bd7SMatthias Ringwald     RPN_PARITY_EVEN  = 3,
652e2577bd7SMatthias Ringwald     RPN_PARITY_MARK  = 5,
653e2577bd7SMatthias Ringwald     RPN_PARITY_SPACE = 7,
654e2577bd7SMatthias Ringwald } rpn_parity_t;
655e2577bd7SMatthias Ringwald 
656e2577bd7SMatthias Ringwald typedef enum rpn_flow_control {
657e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_XONXOFF_ON_INPUT  = 1 << 0,
658e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_XONXOFF_ON_OUTPUT = 1 << 1,
659e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_RTR_ON_INPUT  = 1 << 2,
660e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_RTR_ON_OUTPUT = 1 << 3,
661e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_RTC_ON_INPUT  = 1 << 4,
662e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_RTC_ON_OUTPUT = 1 << 5,
663e2577bd7SMatthias Ringwald } rpn_flow_control_t;
664e2577bd7SMatthias Ringwald 
665e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_BAUD             0x01
666e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_DATA_BITS        0x02
667e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_STOP_BITS        0x04
668e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_PARITY           0x08
669e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_PARITY_TYPE      0x10
670e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_XON_CHAR         0x20
671e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_XOFF_CHAR        0x40
672e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_RESERVED         0x80
673e2577bd7SMatthias Ringwald 
674e2577bd7SMatthias Ringwald // @note: values are identical to rpn_flow_control_t
675e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_XONOFF_ON_INPUT  0x01
676e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_XONOFF_ON_OUTPUT 0x02
677e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RTR_ON_INPUT     0x04
678e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RTR_ON_OUTPUT    0x08
679e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RTC_ON_INPUT     0x10
680e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RTC_ON_OUTPUT    0x20
681e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RESERVED_0       0x40
682e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RESERVED_1       0x80
683e2577bd7SMatthias Ringwald 
684e2577bd7SMatthias Ringwald /**
68566b1fcb3SMatthias Ringwald  * BNEP Protocol
68666b1fcb3SMatthias Ringwald  */
68747f4e325SMatthias Ringwald 
68866b1fcb3SMatthias Ringwald #ifndef ETHER_ADDR_LEN
6899a73f75dSMatthias Ringwald #define ETHER_ADDR_LEN 6
69066b1fcb3SMatthias Ringwald #endif
69147f4e325SMatthias Ringwald 
69266b1fcb3SMatthias Ringwald #ifndef ETHERTYPE_VLAN
69366b1fcb3SMatthias Ringwald #define ETHERTYPE_VLAN                                  0x8100 /* IEEE 802.1Q VLAN tag */
69466b1fcb3SMatthias Ringwald #endif
69566b1fcb3SMatthias Ringwald 
69666b1fcb3SMatthias Ringwald #define BNEP_MTU_MIN                                    1691
69766b1fcb3SMatthias Ringwald 
69866b1fcb3SMatthias Ringwald #define BNEP_EXT_FLAG                                   0x80
69966b1fcb3SMatthias Ringwald #define BNEP_TYPE_MASK                                  0x7F
70066b1fcb3SMatthias Ringwald #define BNEP_TYPE(header)                               ((header) & BNEP_TYPE_MASK)
70166b1fcb3SMatthias Ringwald #define BNEP_HEADER_HAS_EXT(x)                          (((x) & BNEP_EXT_FLAG) == BNEP_EXT_FLAG)
70266b1fcb3SMatthias Ringwald 
70366b1fcb3SMatthias Ringwald /* BNEP packet types */
70466b1fcb3SMatthias Ringwald #define BNEP_PKT_TYPE_GENERAL_ETHERNET                  0x00
70566b1fcb3SMatthias Ringwald #define BNEP_PKT_TYPE_CONTROL                           0x01
70666b1fcb3SMatthias Ringwald #define BNEP_PKT_TYPE_COMPRESSED_ETHERNET               0x02
70766b1fcb3SMatthias Ringwald #define BNEP_PKT_TYPE_COMPRESSED_ETHERNET_SOURCE_ONLY   0x03
70866b1fcb3SMatthias Ringwald #define BNEP_PKT_TYPE_COMPRESSED_ETHERNET_DEST_ONLY     0x04
70966b1fcb3SMatthias Ringwald 
71066b1fcb3SMatthias Ringwald /* BNEP control types */
71166b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_COMMAND_NOT_UNDERSTOOD        0x00
71266b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_SETUP_CONNECTION_REQUEST      0x01
71366b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_SETUP_CONNECTION_RESPONSE     0x02
71466b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_FILTER_NET_TYPE_SET           0x03
71566b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_FILTER_NET_TYPE_RESPONSE      0x04
71666b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_FILTER_MULTI_ADDR_SET         0x05
71766b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_FILTER_MULTI_ADDR_RESPONSE    0x06
71866b1fcb3SMatthias Ringwald 
71966b1fcb3SMatthias Ringwald /* BNEP extension header types */
72066b1fcb3SMatthias Ringwald #define BNEP_EXT_HEADER_TYPE_EXTENSION_CONTROL          0x00
72166b1fcb3SMatthias Ringwald 
72266b1fcb3SMatthias Ringwald /* BNEP setup response codes */
72366b1fcb3SMatthias Ringwald #define BNEP_RESP_SETUP_SUCCESS                         0x0000
72466b1fcb3SMatthias Ringwald #define BNEP_RESP_SETUP_INVALID_DEST_UUID               0x0001
72566b1fcb3SMatthias Ringwald #define BNEP_RESP_SETUP_INVALID_SOURCE_UUID             0x0002
72666b1fcb3SMatthias Ringwald #define BNEP_RESP_SETUP_INVALID_SERVICE_UUID_SIZE       0x0003
72766b1fcb3SMatthias Ringwald #define BNEP_RESP_SETUP_CONNECTION_NOT_ALLOWED          0x0004
72866b1fcb3SMatthias Ringwald 
72966b1fcb3SMatthias Ringwald /* BNEP filter response codes */
73066b1fcb3SMatthias Ringwald #define BNEP_RESP_FILTER_SUCCESS                        0x0000
73166b1fcb3SMatthias Ringwald #define BNEP_RESP_FILTER_UNSUPPORTED_REQUEST            0x0001
73266b1fcb3SMatthias Ringwald #define BNEP_RESP_FILTER_ERR_INVALID_RANGE              0x0002
73366b1fcb3SMatthias Ringwald #define BNEP_RESP_FILTER_ERR_TOO_MANY_FILTERS           0x0003
73466b1fcb3SMatthias Ringwald #define BNEP_RESP_FILTER_ERR_SECURITY                   0x0004
73566b1fcb3SMatthias Ringwald 
73666b1fcb3SMatthias Ringwald /**
73766b1fcb3SMatthias Ringwald  * PAN Profile
73866b1fcb3SMatthias Ringwald  */
73966b1fcb3SMatthias Ringwald 
74066b1fcb3SMatthias Ringwald typedef enum {
74166b1fcb3SMatthias Ringwald     PANU_UUID = 0x1115,
74266b1fcb3SMatthias Ringwald     NAP_UUID = 0x1116,
74366b1fcb3SMatthias Ringwald     GN_UUID = 0x1117
74466b1fcb3SMatthias Ringwald } bnep_service_uuid_t;
74566b1fcb3SMatthias Ringwald 
74666b1fcb3SMatthias Ringwald typedef enum {
74766b1fcb3SMatthias Ringwald     BNEP_SECURITY_NONE = 0x0000,
74866b1fcb3SMatthias Ringwald     BNEP_SECURITY_SERVICE_LEVEL_ENFORCED,
74966b1fcb3SMatthias Ringwald     BNEP_SECURITY_802_1X
75066b1fcb3SMatthias Ringwald } security_description_t;
75166b1fcb3SMatthias Ringwald 
75266b1fcb3SMatthias Ringwald typedef enum {
75366b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_PSTN = 0x0000,
75466b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_ISDN,
75566b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_DSL,
75666b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_CABLE_MODEM,
75766b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_10MB_ETHERNET,
75866b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_100MB_ETHERNET,
75966b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_4MB_TOKEN_RING,
76066b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_16MB_TOKEN_RING,
76166b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_100MB_TOKEN_RING,
76266b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_FDDI,
76366b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_GSM,
76466b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_CDMA,
76566b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_GPRS,
76666b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_3G,
76766b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_CELULAR,
76866b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_OTHER = 0xFFFE,
76966b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_NONE
77066b1fcb3SMatthias Ringwald } net_access_type_t;
77147f4e325SMatthias Ringwald 
7724c1900e6SMatthias Ringwald /**
7734c1900e6SMatthias Ringwald  * ATT
7744c1900e6SMatthias Ringwald  */
7754c1900e6SMatthias Ringwald 
7764c1900e6SMatthias Ringwald // Minimum/default MTU
7774c1900e6SMatthias Ringwald #define ATT_DEFAULT_MTU               23
7784c1900e6SMatthias Ringwald 
7794c1900e6SMatthias Ringwald // MARK: Attribute PDU Opcodes
7804c1900e6SMatthias Ringwald #define ATT_ERROR_RESPONSE              0x01
7814c1900e6SMatthias Ringwald 
7824c1900e6SMatthias Ringwald #define ATT_EXCHANGE_MTU_REQUEST        0x02
7834c1900e6SMatthias Ringwald #define ATT_EXCHANGE_MTU_RESPONSE       0x03
7844c1900e6SMatthias Ringwald 
7854c1900e6SMatthias Ringwald #define ATT_FIND_INFORMATION_REQUEST    0x04
7864c1900e6SMatthias Ringwald #define ATT_FIND_INFORMATION_REPLY      0x05
7874c1900e6SMatthias Ringwald #define ATT_FIND_BY_TYPE_VALUE_REQUEST  0x06
7884c1900e6SMatthias Ringwald #define ATT_FIND_BY_TYPE_VALUE_RESPONSE 0x07
7894c1900e6SMatthias Ringwald 
7904c1900e6SMatthias Ringwald #define ATT_READ_BY_TYPE_REQUEST        0x08
7914c1900e6SMatthias Ringwald #define ATT_READ_BY_TYPE_RESPONSE       0x09
7924c1900e6SMatthias Ringwald #define ATT_READ_REQUEST                0x0a
7934c1900e6SMatthias Ringwald #define ATT_READ_RESPONSE               0x0b
7944c1900e6SMatthias Ringwald #define ATT_READ_BLOB_REQUEST           0x0c
7954c1900e6SMatthias Ringwald #define ATT_READ_BLOB_RESPONSE          0x0d
7964c1900e6SMatthias Ringwald #define ATT_READ_MULTIPLE_REQUEST       0x0e
7974c1900e6SMatthias Ringwald #define ATT_READ_MULTIPLE_RESPONSE      0x0f
7984c1900e6SMatthias Ringwald #define ATT_READ_BY_GROUP_TYPE_REQUEST  0x10
7994c1900e6SMatthias Ringwald #define ATT_READ_BY_GROUP_TYPE_RESPONSE 0x11
8004c1900e6SMatthias Ringwald 
8014c1900e6SMatthias Ringwald #define ATT_WRITE_REQUEST               0x12
8024c1900e6SMatthias Ringwald #define ATT_WRITE_RESPONSE              0x13
8034c1900e6SMatthias Ringwald 
8044c1900e6SMatthias Ringwald #define ATT_PREPARE_WRITE_REQUEST       0x16
8054c1900e6SMatthias Ringwald #define ATT_PREPARE_WRITE_RESPONSE      0x17
8064c1900e6SMatthias Ringwald #define ATT_EXECUTE_WRITE_REQUEST       0x18
8074c1900e6SMatthias Ringwald #define ATT_EXECUTE_WRITE_RESPONSE      0x19
8084c1900e6SMatthias Ringwald 
8094c1900e6SMatthias Ringwald #define ATT_HANDLE_VALUE_NOTIFICATION   0x1b
8104c1900e6SMatthias Ringwald #define ATT_HANDLE_VALUE_INDICATION     0x1d
8114c1900e6SMatthias Ringwald #define ATT_HANDLE_VALUE_CONFIRMATION   0x1e
8124c1900e6SMatthias Ringwald 
8134c1900e6SMatthias Ringwald 
8144c1900e6SMatthias Ringwald #define ATT_WRITE_COMMAND                0x52
8154c1900e6SMatthias Ringwald #define ATT_SIGNED_WRITE_COMMAND         0xD2
8164c1900e6SMatthias Ringwald 
8174c1900e6SMatthias Ringwald // MARK: ATT Error Codes
8184c1900e6SMatthias Ringwald #define ATT_ERROR_INVALID_HANDLE                   0x01
8194c1900e6SMatthias Ringwald #define ATT_ERROR_READ_NOT_PERMITTED               0x02
8204c1900e6SMatthias Ringwald #define ATT_ERROR_WRITE_NOT_PERMITTED              0x03
8214c1900e6SMatthias Ringwald #define ATT_ERROR_INVALID_PDU                      0x04
8224c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_AUTHENTICATION      0x05
8234c1900e6SMatthias Ringwald #define ATT_ERROR_REQUEST_NOT_SUPPORTED            0x06
8244c1900e6SMatthias Ringwald #define ATT_ERROR_INVALID_OFFSET                   0x07
8254c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_AUTHORIZATION       0x08
8264c1900e6SMatthias Ringwald #define ATT_ERROR_PREPARE_QUEUE_FULL               0x09
8274c1900e6SMatthias Ringwald #define ATT_ERROR_ATTRIBUTE_NOT_FOUND              0x0a
8284c1900e6SMatthias Ringwald #define ATT_ERROR_ATTRIBUTE_NOT_LONG               0x0b
8294c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_ENCRYPTION_KEY_SIZE 0x0c
8304c1900e6SMatthias Ringwald #define ATT_ERROR_INVALID_ATTRIBUTE_VALUE_LENGTH   0x0d
8314c1900e6SMatthias Ringwald #define ATT_ERROR_UNLIKELY_ERROR                   0x0e
8324c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_ENCRYPTION          0x0f
8334c1900e6SMatthias Ringwald #define ATT_ERROR_UNSUPPORTED_GROUP_TYPE           0x10
8344c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_RESOURCES           0x11
8354c1900e6SMatthias Ringwald 
8364c1900e6SMatthias Ringwald // MARK: Attribute Property Flags
8374c1900e6SMatthias Ringwald #define ATT_PROPERTY_BROADCAST           0x01
8384c1900e6SMatthias Ringwald #define ATT_PROPERTY_READ                0x02
8394c1900e6SMatthias Ringwald #define ATT_PROPERTY_WRITE_WITHOUT_RESPONSE 0x04
8404c1900e6SMatthias Ringwald #define ATT_PROPERTY_WRITE               0x08
8414c1900e6SMatthias Ringwald #define ATT_PROPERTY_NOTIFY              0x10
8424c1900e6SMatthias Ringwald #define ATT_PROPERTY_INDICATE            0x20
8434c1900e6SMatthias Ringwald #define ATT_PROPERTY_AUTHENTICATED_SIGNED_WRITE 0x40
8444c1900e6SMatthias Ringwald #define ATT_PROPERTY_EXTENDED_PROPERTIES 0x80
8454c1900e6SMatthias Ringwald 
8464c1900e6SMatthias Ringwald // MARK: Attribute Property Flag, BTstack extension
8474c1900e6SMatthias Ringwald // value is asked from client
8484c1900e6SMatthias Ringwald #define ATT_PROPERTY_DYNAMIC             0x100
8494c1900e6SMatthias Ringwald // 128 bit UUID used
8504c1900e6SMatthias Ringwald #define ATT_PROPERTY_UUID128             0x200
8514c1900e6SMatthias Ringwald // Authentication required
8524c1900e6SMatthias Ringwald #define ATT_PROPERTY_AUTHENTICATION_REQUIRED 0x400
8534c1900e6SMatthias Ringwald // Authorization from user required
8544c1900e6SMatthias Ringwald #define ATT_PROPERTY_AUTHORIZATION_REQUIRED  0x800
8554c1900e6SMatthias Ringwald // Encryption key size stored in upper 4 bits, 0 == no encryption, encryption key size - 1 otherwise
8564c1900e6SMatthias Ringwald 
8574c1900e6SMatthias Ringwald // ATT Transaction Timeout of 30 seconds for Command/Response or Incidationc/Confirmation
8584c1900e6SMatthias Ringwald #define ATT_TRANSACTION_TIMEOUT_MS     30000
8594c1900e6SMatthias Ringwald 
8604c1900e6SMatthias Ringwald #define ATT_TRANSACTION_MODE_NONE      0x0
8614c1900e6SMatthias Ringwald #define ATT_TRANSACTION_MODE_ACTIVE    0x1
8624c1900e6SMatthias Ringwald #define ATT_TRANSACTION_MODE_EXECUTE   0x2
8634c1900e6SMatthias Ringwald #define ATT_TRANSACTION_MODE_CANCEL    0x3
8644c1900e6SMatthias Ringwald 
8654c1900e6SMatthias Ringwald // MARK: GATT UUIDs
8664c1900e6SMatthias Ringwald #define GATT_PRIMARY_SERVICE_UUID                   0x2800
8674c1900e6SMatthias Ringwald #define GATT_SECONDARY_SERVICE_UUID                 0x2801
8684c1900e6SMatthias Ringwald #define GATT_INCLUDE_SERVICE_UUID                   0x2802
8694c1900e6SMatthias Ringwald #define GATT_CHARACTERISTICS_UUID                   0x2803
8704c1900e6SMatthias Ringwald #define GATT_CHARACTERISTIC_EXTENDED_PROPERTIES     0x2900
8714c1900e6SMatthias Ringwald #define GATT_CHARACTERISTIC_USER_DESCRIPTION        0x2901
8724c1900e6SMatthias Ringwald #define GATT_CLIENT_CHARACTERISTICS_CONFIGURATION   0x2902
8734c1900e6SMatthias Ringwald #define GATT_SERVER_CHARACTERISTICS_CONFIGURATION   0x2903
8744c1900e6SMatthias Ringwald #define GATT_CHARACTERISTIC_PRESENTATION_FORMAT     0x2904
8754c1900e6SMatthias Ringwald #define GATT_CHARACTERISTIC_AGGREGATE_FORMAT        0x2905
8764c1900e6SMatthias Ringwald 
8774c1900e6SMatthias Ringwald #define GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NONE          0
8784c1900e6SMatthias Ringwald #define GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NOTIFICATION  1
8794c1900e6SMatthias Ringwald #define GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_INDICATION    2
8804c1900e6SMatthias Ringwald 
8814c1900e6SMatthias Ringwald // GAP Service and Characteristics
8824c1900e6SMatthias Ringwald #define GAP_SERVICE_UUID               0x1800
8834c1900e6SMatthias Ringwald #define GAP_DEVICE_NAME_UUID           0x2a00
8844c1900e6SMatthias Ringwald #define GAP_APPEARANCE_UUID            0x2a01
8854c1900e6SMatthias Ringwald #define GAP_PERIPHERAL_PRIVACY_FLAG    0x2a02
8864c1900e6SMatthias Ringwald #define GAP_RECONNECTION_ADDRESS_UUID  0x2a03
8874c1900e6SMatthias Ringwald #define GAP_PERIPHERAL_PREFERRED_CONNECTION_PARAMETERS_UUID 0x2a04
88817fe8172SMatthias Ringwald #define GAP_SERVICE_CHANGED            0x2a05
8894c1900e6SMatthias Ringwald 
8904c1900e6SMatthias Ringwald /**
8914c1900e6SMatthias Ringwald  * SM - LE Security Manager
8924c1900e6SMatthias Ringwald  */
8934c1900e6SMatthias Ringwald // Bluetooth Spec definitions
8944c1900e6SMatthias Ringwald typedef enum {
8954c1900e6SMatthias Ringwald     SM_CODE_PAIRING_REQUEST = 0X01,
8964c1900e6SMatthias Ringwald     SM_CODE_PAIRING_RESPONSE,
8974c1900e6SMatthias Ringwald     SM_CODE_PAIRING_CONFIRM,
8984c1900e6SMatthias Ringwald     SM_CODE_PAIRING_RANDOM,
8994c1900e6SMatthias Ringwald     SM_CODE_PAIRING_FAILED,
9004c1900e6SMatthias Ringwald     SM_CODE_ENCRYPTION_INFORMATION,
9014c1900e6SMatthias Ringwald     SM_CODE_MASTER_IDENTIFICATION,
9024c1900e6SMatthias Ringwald     SM_CODE_IDENTITY_INFORMATION,
9034c1900e6SMatthias Ringwald     SM_CODE_IDENTITY_ADDRESS_INFORMATION,
9044c1900e6SMatthias Ringwald     SM_CODE_SIGNING_INFORMATION,
9054c1900e6SMatthias Ringwald     SM_CODE_SECURITY_REQUEST
9064c1900e6SMatthias Ringwald } SECURITY_MANAGER_COMMANDS;
9074c1900e6SMatthias Ringwald 
9084c1900e6SMatthias Ringwald // IO Capability Values
9094c1900e6SMatthias Ringwald typedef enum {
9104c1900e6SMatthias Ringwald     IO_CAPABILITY_DISPLAY_ONLY = 0,
9114c1900e6SMatthias Ringwald     IO_CAPABILITY_DISPLAY_YES_NO,
9124c1900e6SMatthias Ringwald     IO_CAPABILITY_KEYBOARD_ONLY,
9134c1900e6SMatthias Ringwald     IO_CAPABILITY_NO_INPUT_NO_OUTPUT,
9144c1900e6SMatthias Ringwald     IO_CAPABILITY_KEYBOARD_DISPLAY, // not used by secure simple pairing
9154c1900e6SMatthias Ringwald } io_capability_t;
9164c1900e6SMatthias Ringwald 
9174c1900e6SMatthias Ringwald // Authentication requirement flags
9184c1900e6SMatthias Ringwald #define SM_AUTHREQ_NO_BONDING 0x00
9194c1900e6SMatthias Ringwald #define SM_AUTHREQ_BONDING 0x01
9204c1900e6SMatthias Ringwald #define SM_AUTHREQ_MITM_PROTECTION 0x04
9214c1900e6SMatthias Ringwald 
9224c1900e6SMatthias Ringwald // Key distribution flags used by spec
9234c1900e6SMatthias Ringwald #define SM_KEYDIST_ENC_KEY 0X01
9244c1900e6SMatthias Ringwald #define SM_KEYDIST_ID_KEY  0x02
9254c1900e6SMatthias Ringwald #define SM_KEYDIST_SIGN    0x04
9264c1900e6SMatthias Ringwald 
9274c1900e6SMatthias Ringwald // Key distribution flags used internally
9284c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_ENCRYPTION_INFORMATION       0x01
9294c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_MASTER_IDENTIFICATION        0x02
9304c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_IDENTITY_INFORMATION         0x04
9314c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_IDENTITY_ADDRESS_INFORMATION 0x08
9324c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_SIGNING_IDENTIFICATION       0x10
9334c1900e6SMatthias Ringwald 
9344c1900e6SMatthias Ringwald // STK Generation Methods
9354c1900e6SMatthias Ringwald #define SM_STK_GENERATION_METHOD_JUST_WORKS 0x01
9364c1900e6SMatthias Ringwald #define SM_STK_GENERATION_METHOD_OOB        0x02
9374c1900e6SMatthias Ringwald #define SM_STK_GENERATION_METHOD_PASSKEY    0x04
9384c1900e6SMatthias Ringwald 
9394c1900e6SMatthias Ringwald // Pairing Failed Reasons
9404c1900e6SMatthias Ringwald #define SM_REASON_RESERVED                     0x00
9414c1900e6SMatthias Ringwald #define SM_REASON_PASSKEYT_ENTRY_FAILED        0x01
9424c1900e6SMatthias Ringwald #define SM_REASON_OOB_NOT_AVAILABLE            0x02
9434c1900e6SMatthias Ringwald #define SM_REASON_AUTHENTHICATION_REQUIREMENTS 0x03
9444c1900e6SMatthias Ringwald #define SM_REASON_CONFIRM_VALUE_FAILED         0x04
9454c1900e6SMatthias Ringwald #define SM_REASON_PAIRING_NOT_SUPPORTED        0x05
9464c1900e6SMatthias Ringwald #define SM_REASON_ENCRYPTION_KEY_SIZE          0x06
9474c1900e6SMatthias Ringwald #define SM_REASON_COMMAND_NOT_SUPPORTED        0x07
9484c1900e6SMatthias Ringwald #define SM_REASON_UNSPECIFIED_REASON           0x08
9494c1900e6SMatthias Ringwald #define SM_REASON_REPEATED_ATTEMPTS            0x09
9504c1900e6SMatthias Ringwald // also, invalid parameters
9514c1900e6SMatthias Ringwald // and reserved
9524c1900e6SMatthias Ringwald 
953c6d1dbedSMatthias Ringwald // Company identifiers / manufacturers
954c6d1dbedSMatthias Ringwald #define COMPANY_ID_CAMBRIDGE_SILICON_RADIO     0x000A
955c6d1dbedSMatthias Ringwald #define COMPANY_ID_TEXAS_INSTRUMENTS_INC       0x000D
956c6d1dbedSMatthias Ringwald #define COMPANY_ID_BROADCOM_CORPORATION        0x000F
957c6d1dbedSMatthias Ringwald #define COMPANY_ID_ST_MICROELECTRONICS         0x0030
958c6d1dbedSMatthias Ringwald #define COMPANY_ID_EM_MICROELECTRONICS_MARIN   0x005A
959c6d1dbedSMatthias Ringwald 
9604c1900e6SMatthias Ringwald 
96147f4e325SMatthias Ringwald #endif