xref: /btstack/src/bluetooth.h (revision a9f2976821fbeb54e160267ff8cce9390f75e68c)
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 
37510093bf5SMilanka Ringwald // TODO: number_of_handles 1, connection_handle[H*i], hc_num_of_completed_packets[2*i]
37647f4e325SMatthias Ringwald #define HCI_EVENT_NUMBER_OF_COMPLETED_PACKETS              0x13
37710093bf5SMilanka Ringwald 
37810093bf5SMilanka Ringwald /**
37910093bf5SMilanka Ringwald  * @format 1H12
38010093bf5SMilanka Ringwald  * @param status
38110093bf5SMilanka Ringwald  * @param handle
38210093bf5SMilanka Ringwald  * @param mode
38310093bf5SMilanka Ringwald  * @param interval
38410093bf5SMilanka Ringwald  */
38547f4e325SMatthias Ringwald #define HCI_EVENT_MODE_CHANGE_EVENT                        0x14
38610093bf5SMilanka Ringwald 
38710093bf5SMilanka Ringwald // TODO: num_keys, bd_addr[B*i], link_key[16 octets * i]
38847f4e325SMatthias Ringwald #define HCI_EVENT_RETURN_LINK_KEYS                         0x15
38910093bf5SMilanka Ringwald 
39010093bf5SMilanka Ringwald /**
39110093bf5SMilanka Ringwald  * @format B
39210093bf5SMilanka Ringwald  * @param bd_addr
39310093bf5SMilanka Ringwald  */
39447f4e325SMatthias Ringwald #define HCI_EVENT_PIN_CODE_REQUEST                         0x16
39510093bf5SMilanka Ringwald 
39610093bf5SMilanka Ringwald /**
39710093bf5SMilanka Ringwald  * @format B
39810093bf5SMilanka Ringwald  * @param bd_addr
39910093bf5SMilanka Ringwald  */
40047f4e325SMatthias Ringwald #define HCI_EVENT_LINK_KEY_REQUEST                         0x17
40110093bf5SMilanka Ringwald 
40210093bf5SMilanka Ringwald // TODO: bd_addr B, link_key 16octets, key_type 1
40347f4e325SMatthias Ringwald #define HCI_EVENT_LINK_KEY_NOTIFICATION                    0x18
40410093bf5SMilanka Ringwald 
40510093bf5SMilanka Ringwald /**
40610093bf5SMilanka Ringwald  * @format 1
40710093bf5SMilanka Ringwald  * @param link_type
40810093bf5SMilanka Ringwald  */
40947f4e325SMatthias Ringwald #define HCI_EVENT_DATA_BUFFER_OVERFLOW                     0x1A
41010093bf5SMilanka Ringwald 
41110093bf5SMilanka Ringwald /**
41210093bf5SMilanka Ringwald  * @format H1
41310093bf5SMilanka Ringwald  * @param handle
41410093bf5SMilanka Ringwald  * @param lmp_max_slots
41510093bf5SMilanka Ringwald  */
41647f4e325SMatthias Ringwald #define HCI_EVENT_MAX_SLOTS_CHANGED                        0x1B
41710093bf5SMilanka Ringwald 
41810093bf5SMilanka Ringwald /**
41910093bf5SMilanka Ringwald  * @format 1H2
42010093bf5SMilanka Ringwald  * @param status
42110093bf5SMilanka Ringwald  * @param handle
42210093bf5SMilanka Ringwald  * @param clock_offset
42310093bf5SMilanka Ringwald  */
42447f4e325SMatthias Ringwald #define HCI_EVENT_READ_CLOCK_OFFSET_COMPLETE               0x1C
42510093bf5SMilanka Ringwald 
42610093bf5SMilanka Ringwald /**
42710093bf5SMilanka Ringwald  * @format 1H2
42810093bf5SMilanka Ringwald  * @param status
42910093bf5SMilanka Ringwald  * @param handle
430fea5a680SMatthias Ringwald  * @param packet_types
431fea5a680SMatthias Ringwald  * @pnote packet_type is in plural to avoid clash with Java binding Packet.getPacketType()
43210093bf5SMilanka Ringwald  */
433fea5a680SMatthias Ringwald #define HCI_EVENT_CONNECTION_PACKET_TYPE_CHANGED           0x1D
43447f4e325SMatthias Ringwald 
43547f4e325SMatthias Ringwald /**
43647f4e325SMatthias Ringwald  * @format 1B11321
43747f4e325SMatthias Ringwald  * @param num_responses
43847f4e325SMatthias Ringwald  * @param bd_addr
43947f4e325SMatthias Ringwald  * @param page_scan_repetition_mode
44047f4e325SMatthias Ringwald  * @param reserved
44147f4e325SMatthias Ringwald  * @param class_of_device
44247f4e325SMatthias Ringwald  * @param clock_offset
44347f4e325SMatthias Ringwald  * @param rssi
44447f4e325SMatthias Ringwald  */
44547f4e325SMatthias Ringwald #define HCI_EVENT_INQUIRY_RESULT_WITH_RSSI                 0x22
44647f4e325SMatthias Ringwald 
44747f4e325SMatthias Ringwald /**
44847f4e325SMatthias Ringwald  * @format 1HB111221
44947f4e325SMatthias Ringwald  * @param status
45047f4e325SMatthias Ringwald  * @param handle
45147f4e325SMatthias Ringwald  * @param bd_addr
45247f4e325SMatthias Ringwald  * @param link_type
45347f4e325SMatthias Ringwald  * @param transmission_interval
45447f4e325SMatthias Ringwald  * @param retransmission_interval
45547f4e325SMatthias Ringwald  * @param rx_packet_length
45647f4e325SMatthias Ringwald  * @param tx_packet_length
45747f4e325SMatthias Ringwald  * @param air_mode
45847f4e325SMatthias Ringwald  */
45947f4e325SMatthias Ringwald #define HCI_EVENT_SYNCHRONOUS_CONNECTION_COMPLETE          0x2C
46047f4e325SMatthias Ringwald 
46147f4e325SMatthias Ringwald // TODO: serialize extended_inquiry_response and provide parser
46247f4e325SMatthias Ringwald /**
46347f4e325SMatthias Ringwald  * @format 1B11321
46447f4e325SMatthias Ringwald  * @param num_responses
46547f4e325SMatthias Ringwald  * @param bd_addr
46647f4e325SMatthias Ringwald  * @param page_scan_repetition_mode
46747f4e325SMatthias Ringwald  * @param reserved
46847f4e325SMatthias Ringwald  * @param class_of_device
46947f4e325SMatthias Ringwald  * @param clock_offset
47047f4e325SMatthias Ringwald  * @param rssi
47147f4e325SMatthias Ringwald  */
47247f4e325SMatthias Ringwald #define HCI_EVENT_EXTENDED_INQUIRY_RESPONSE                0x2F
47347f4e325SMatthias Ringwald 
47447f4e325SMatthias Ringwald  /**
47547f4e325SMatthias Ringwald   * @format 1H
47647f4e325SMatthias Ringwald   * @param status
47747f4e325SMatthias Ringwald   * @param handle
47847f4e325SMatthias Ringwald   */
47947f4e325SMatthias Ringwald #define HCI_EVENT_ENCRYPTION_KEY_REFRESH_COMPLETE          0x30
48047f4e325SMatthias Ringwald 
48147f4e325SMatthias Ringwald #define HCI_EVENT_IO_CAPABILITY_REQUEST                    0x31
48247f4e325SMatthias Ringwald #define HCI_EVENT_IO_CAPABILITY_RESPONSE                   0x32
48347f4e325SMatthias Ringwald #define HCI_EVENT_USER_CONFIRMATION_REQUEST                0x33
48447f4e325SMatthias Ringwald #define HCI_EVENT_USER_PASSKEY_REQUEST                     0x34
48547f4e325SMatthias Ringwald #define HCI_EVENT_REMOTE_OOB_DATA_REQUEST                  0x35
48647f4e325SMatthias Ringwald #define HCI_EVENT_SIMPLE_PAIRING_COMPLETE                  0x36
48747f4e325SMatthias Ringwald 
48847f4e325SMatthias Ringwald #define HCI_EVENT_LE_META                                  0x3E
48947f4e325SMatthias Ringwald 
490941b3855SMatthias Ringwald #define HCI_EVENT_VENDOR_SPECIFIC                          0xFF
491941b3855SMatthias Ringwald 
49247f4e325SMatthias Ringwald /**
493ca0d73deSMatthias Ringwald  * @format 11H11B2221
49447f4e325SMatthias Ringwald  * @param subevent_code
49547f4e325SMatthias Ringwald  * @param status
49647f4e325SMatthias Ringwald  * @param connection_handle
49747f4e325SMatthias Ringwald  * @param role
49847f4e325SMatthias Ringwald  * @param peer_address_type
49947f4e325SMatthias Ringwald  * @param peer_address
50047f4e325SMatthias Ringwald  * @param conn_interval
50147f4e325SMatthias Ringwald  * @param conn_latency
50247f4e325SMatthias Ringwald  * @param supervision_timeout
50347f4e325SMatthias Ringwald  * @param master_clock_accuracy
50447f4e325SMatthias Ringwald  */
50547f4e325SMatthias Ringwald #define HCI_SUBEVENT_LE_CONNECTION_COMPLETE                0x01
50647f4e325SMatthias Ringwald #define HCI_SUBEVENT_LE_ADVERTISING_REPORT                 0x02
50747f4e325SMatthias Ringwald #define HCI_SUBEVENT_LE_CONNECTION_UPDATE_COMPLETE         0x03
50847f4e325SMatthias Ringwald #define HCI_SUBEVENT_LE_READ_REMOTE_USED_FEATURES_COMPLETE 0x04
50947f4e325SMatthias Ringwald #define HCI_SUBEVENT_LE_LONG_TERM_KEY_REQUEST              0x05
51047f4e325SMatthias Ringwald 
51147f4e325SMatthias Ringwald // last used HCI_EVENT in 2.1 is 0x3d
51247f4e325SMatthias Ringwald // last used HCI_EVENT in 4.1 is 0x57
51347f4e325SMatthias Ringwald 
51447f4e325SMatthias Ringwald /**
51547f4e325SMatthias Ringwald  * L2CAP Layer
51647f4e325SMatthias Ringwald  */
51747f4e325SMatthias Ringwald 
518a8373a41SMatthias Ringwald #define L2CAP_HEADER_SIZE 4
519a8373a41SMatthias Ringwald 
520a8373a41SMatthias Ringwald #define L2CAP_SIG_ID_INVALID 0
521a8373a41SMatthias Ringwald 
522a8373a41SMatthias Ringwald // size of HCI ACL + L2CAP Header for regular data packets (8)
523a8373a41SMatthias Ringwald #define COMPLETE_L2CAP_HEADER (HCI_ACL_HEADER_SIZE + L2CAP_HEADER_SIZE)
524a8373a41SMatthias Ringwald 
525a8373a41SMatthias Ringwald // minimum signaling MTU
526a8373a41SMatthias Ringwald #define L2CAP_MINIMAL_MTU 48
527a8373a41SMatthias Ringwald #define L2CAP_DEFAULT_MTU 672
528a8373a41SMatthias Ringwald 
529a8373a41SMatthias Ringwald // Minimum/default MTU
530a8373a41SMatthias Ringwald #define L2CAP_LE_DEFAULT_MTU  23
531a8373a41SMatthias Ringwald 
532a8373a41SMatthias Ringwald // L2CAP Fixed Channel IDs
533a8373a41SMatthias Ringwald #define L2CAP_CID_SIGNALING                 0x0001
534a8373a41SMatthias Ringwald #define L2CAP_CID_CONNECTIONLESS_CHANNEL    0x0002
535a8373a41SMatthias Ringwald #define L2CAP_CID_ATTRIBUTE_PROTOCOL        0x0004
536a8373a41SMatthias Ringwald #define L2CAP_CID_SIGNALING_LE              0x0005
537a8373a41SMatthias Ringwald #define L2CAP_CID_SECURITY_MANAGER_PROTOCOL 0x0006
538a8373a41SMatthias Ringwald 
539a8373a41SMatthias Ringwald // L2CAP Configuration Result Codes
540a8373a41SMatthias Ringwald #define L2CAP_CONF_RESULT_UNKNOWN_OPTIONS   0x0003
541a8373a41SMatthias Ringwald 
542a8373a41SMatthias Ringwald // L2CAP Reject Result Codes
543a8373a41SMatthias Ringwald #define L2CAP_REJ_CMD_UNKNOWN               0x0000
544a8373a41SMatthias Ringwald 
545a8373a41SMatthias Ringwald // Response Timeout eXpired
546a8373a41SMatthias Ringwald #define L2CAP_RTX_TIMEOUT_MS   10000
547a8373a41SMatthias Ringwald 
548a8373a41SMatthias Ringwald // Extended Response Timeout eXpired
549a8373a41SMatthias Ringwald #define L2CAP_ERTX_TIMEOUT_MS 120000
550a8373a41SMatthias Ringwald 
55147f4e325SMatthias Ringwald // Fixed PSM numbers
55247f4e325SMatthias Ringwald #define PSM_SDP           0x01
55347f4e325SMatthias Ringwald #define PSM_RFCOMM        0x03
55447f4e325SMatthias Ringwald #define PSM_BNEP          0x0F
55547f4e325SMatthias Ringwald #define PSM_HID_CONTROL   0x11
55647f4e325SMatthias Ringwald #define PSM_HID_INTERRUPT 0x13
55747f4e325SMatthias Ringwald 
55866b1fcb3SMatthias Ringwald /**
559ef907034SMatthias Ringwald  * SDP Protocl
560ef907034SMatthias Ringwald  */
561ef907034SMatthias Ringwald 
562ef907034SMatthias Ringwald  // PDU Types
563ef907034SMatthias Ringwald typedef enum {
564ef907034SMatthias Ringwald     SDP_Invalid = 0,
565ef907034SMatthias Ringwald     SDP_ErrorResponse = 1,
566ef907034SMatthias Ringwald     SDP_ServiceSearchRequest,
567ef907034SMatthias Ringwald     SDP_ServiceSearchResponse,
568ef907034SMatthias Ringwald     SDP_ServiceAttributeRequest,
569ef907034SMatthias Ringwald     SDP_ServiceAttributeResponse,
570ef907034SMatthias Ringwald     SDP_ServiceSearchAttributeRequest,
571ef907034SMatthias Ringwald     SDP_ServiceSearchAttributeResponse
572ef907034SMatthias Ringwald } SDP_PDU_ID_t;
573ef907034SMatthias Ringwald 
574ef907034SMatthias Ringwald // UNIVERSAL ATTRIBUTE DEFINITIONS
575ef907034SMatthias Ringwald #define SDP_ServiceRecordHandle     0x0000
576ef907034SMatthias Ringwald #define SDP_ServiceClassIDList      0x0001
577ef907034SMatthias Ringwald #define SDP_ServiceRecordState      0x0002
578ef907034SMatthias Ringwald #define SDP_ServiceID               0x0003
579ef907034SMatthias Ringwald #define SDP_ProtocolDescriptorList  0x0004
580ef907034SMatthias Ringwald #define SDP_BrowseGroupList         0x0005
581ef907034SMatthias Ringwald #define SDP_LanguageBaseAttributeIDList 0x0006
582ef907034SMatthias Ringwald #define SDP_ServiceInfoTimeToLive   0x0007
583ef907034SMatthias Ringwald #define SDP_ServiceAvailability     0x0008
584ef907034SMatthias Ringwald #define SDP_BluetoothProfileDescriptorList 0x0009
585ef907034SMatthias Ringwald #define SDP_DocumentationURL        0x000a
586ef907034SMatthias Ringwald #define SDP_ClientExecutableURL     0x000b
587ef907034SMatthias Ringwald #define SDP_IconURL                 0x000c
588ef907034SMatthias Ringwald #define SDP_AdditionalProtocolDescriptorList 0x000d
589ef907034SMatthias Ringwald #define SDP_SupportedFormatsList    0x0303
590ef907034SMatthias Ringwald 
591ef907034SMatthias Ringwald // SERVICE CLASSES
592ef907034SMatthias Ringwald #define SDP_OBEXObjectPush          0x1105
593ef907034SMatthias Ringwald #define SDP_OBEXFileTransfer        0x1106
594ef907034SMatthias Ringwald #define SDP_PublicBrowseGroup       0x1002
595ef907034SMatthias Ringwald #define SDP_HSP                     0x1108
596ef907034SMatthias Ringwald #define SDP_Headset_AG              0x1112
597ef907034SMatthias Ringwald #define SDP_PANU                    0x1115
598ef907034SMatthias Ringwald #define SDP_NAP                     0x1116
599ef907034SMatthias Ringwald #define SDP_GN                      0x1117
600ef907034SMatthias Ringwald #define SDP_Handsfree               0x111E
601ef907034SMatthias Ringwald #define SDP_HandsfreeAudioGateway   0x111F
602ef907034SMatthias Ringwald #define SDP_Headset_HS              0x1131
603ef907034SMatthias Ringwald #define SDP_GenericAudio            0x1203
604ef907034SMatthias Ringwald 
605ef907034SMatthias Ringwald 
606ef907034SMatthias Ringwald // PROTOCOLS
607ef907034SMatthias Ringwald #define SDP_SDPProtocol       0x0001
608ef907034SMatthias Ringwald #define SDP_UDPProtocol       0x0002
609ef907034SMatthias Ringwald #define SDP_RFCOMMProtocol    0x0003
610ef907034SMatthias Ringwald #define SDP_OBEXProtocol      0x0008
611ef907034SMatthias Ringwald #define SDP_L2CAPProtocol     0x0100
612ef907034SMatthias Ringwald #define SDP_BNEPProtocol      0x000F
613ef907034SMatthias Ringwald #define SDP_AVDTPProtocol     0x0019
614ef907034SMatthias Ringwald 
615ef907034SMatthias Ringwald // OFFSETS FOR LOCALIZED ATTRIBUTES - SDP_LanguageBaseAttributeIDList
616ef907034SMatthias Ringwald #define SDP_Offest_ServiceName      0x0000
617ef907034SMatthias Ringwald #define SDP_Offest_ServiceDescription 0x0001
618ef907034SMatthias Ringwald #define SDP_Offest_ProviderName     0x0002
619ef907034SMatthias Ringwald 
620ef907034SMatthias Ringwald // OBEX
621ef907034SMatthias Ringwald #define SDP_vCard_2_1       0x01
622ef907034SMatthias Ringwald #define SDP_vCard_3_0       0x02
623ef907034SMatthias Ringwald #define SDP_vCal_1_0        0x03
624ef907034SMatthias Ringwald #define SDP_iCal_2_0        0x04
625ef907034SMatthias Ringwald #define SDP_vNote           0x05
626ef907034SMatthias Ringwald #define SDP_vMessage        0x06
627ef907034SMatthias Ringwald #define SDP_OBEXFileTypeAny 0xFF
628ef907034SMatthias Ringwald 
629ef907034SMatthias Ringwald /**
630e2577bd7SMatthias Ringwald  * RFCOMM Protocol
631e2577bd7SMatthias Ringwald  */
632e2577bd7SMatthias Ringwald 
633e2577bd7SMatthias Ringwald // Control field values      bit no.       1 2 3 4 PF 6 7 8
634e2577bd7SMatthias Ringwald #define BT_RFCOMM_SABM       0x3F       // 1 1 1 1  1 1 0 0
635e2577bd7SMatthias Ringwald #define BT_RFCOMM_UA         0x73       // 1 1 0 0  1 1 1 0
636e2577bd7SMatthias Ringwald #define BT_RFCOMM_DM         0x0F       // 1 1 1 1  0 0 0 0
637e2577bd7SMatthias Ringwald #define BT_RFCOMM_DM_PF      0x1F       // 1 1 1 1  1 0 0 0
638e2577bd7SMatthias Ringwald #define BT_RFCOMM_DISC       0x53       // 1 1 0 0  1 0 1 0
639e2577bd7SMatthias Ringwald #define BT_RFCOMM_UIH        0xEF       // 1 1 1 1  0 1 1 1
640e2577bd7SMatthias Ringwald #define BT_RFCOMM_UIH_PF     0xFF       // 1 1 1 1  0 1 1 1
641e2577bd7SMatthias Ringwald 
642e2577bd7SMatthias Ringwald // Multiplexer message types
643e2577bd7SMatthias Ringwald #define BT_RFCOMM_CLD_CMD    0xC3
644e2577bd7SMatthias Ringwald #define BT_RFCOMM_FCON_CMD   0xA3
645e2577bd7SMatthias Ringwald #define BT_RFCOMM_FCON_RSP   0xA1
646e2577bd7SMatthias Ringwald #define BT_RFCOMM_FCOFF_CMD  0x63
647e2577bd7SMatthias Ringwald #define BT_RFCOMM_FCOFF_RSP  0x61
648e2577bd7SMatthias Ringwald #define BT_RFCOMM_MSC_CMD    0xE3
649e2577bd7SMatthias Ringwald #define BT_RFCOMM_MSC_RSP    0xE1
650e2577bd7SMatthias Ringwald #define BT_RFCOMM_NSC_RSP    0x11
651e2577bd7SMatthias Ringwald #define BT_RFCOMM_PN_CMD     0x83
652e2577bd7SMatthias Ringwald #define BT_RFCOMM_PN_RSP     0x81
653e2577bd7SMatthias Ringwald #define BT_RFCOMM_RLS_CMD    0x53
654e2577bd7SMatthias Ringwald #define BT_RFCOMM_RLS_RSP    0x51
655e2577bd7SMatthias Ringwald #define BT_RFCOMM_RPN_CMD    0x93
656e2577bd7SMatthias Ringwald #define BT_RFCOMM_RPN_RSP    0x91
657e2577bd7SMatthias Ringwald #define BT_RFCOMM_TEST_CMD   0x23
658e2577bd7SMatthias Ringwald #define BT_RFCOMM_TEST_RSP   0x21
659e2577bd7SMatthias Ringwald 
660e2577bd7SMatthias Ringwald // Line Status
661e2577bd7SMatthias Ringwald #define LINE_STATUS_NO_ERROR       0x00
662e2577bd7SMatthias Ringwald #define LINE_STATUS_OVERRUN_ERROR  0x03
663e2577bd7SMatthias Ringwald #define LINE_STATUS_PARITY_ERORR   0x05
664e2577bd7SMatthias Ringwald #define LINE_STATUS_FRAMING_ERROR  0x09
665e2577bd7SMatthias Ringwald 
666e2577bd7SMatthias Ringwald // Modem Status Flags
667e2577bd7SMatthias Ringwald #define MODEM_STATUS_FC   0x02
668e2577bd7SMatthias Ringwald #define MODEM_STATUS_RTC  0x04
669e2577bd7SMatthias Ringwald #define MODEM_STATUS_RTR  0x08
670e2577bd7SMatthias Ringwald #define MODEM_STATUS_IC   0x40
671e2577bd7SMatthias Ringwald #define MODEM_STATUS_DV   0x80
672e2577bd7SMatthias Ringwald 
673e2577bd7SMatthias Ringwald typedef enum rpn_baud {
674e2577bd7SMatthias Ringwald     RPN_BAUD_2400 = 0,
675e2577bd7SMatthias Ringwald     RPN_BAUD_4800,
676e2577bd7SMatthias Ringwald     RPN_BAUD_7200,
677e2577bd7SMatthias Ringwald     RPN_BAUD_9600,
678e2577bd7SMatthias Ringwald     RPN_BAUD_19200,
679e2577bd7SMatthias Ringwald     RPN_BAUD_38400,
680e2577bd7SMatthias Ringwald     RPN_BAUD_57600,
681e2577bd7SMatthias Ringwald     RPN_BAUD_115200,
682e2577bd7SMatthias Ringwald     RPN_BAUD_230400
683e2577bd7SMatthias Ringwald } rpn_baud_t;
684e2577bd7SMatthias Ringwald 
685e2577bd7SMatthias Ringwald typedef enum rpn_data_bits {
686e2577bd7SMatthias Ringwald     RPN_DATA_BITS_5 = 0,
687e2577bd7SMatthias Ringwald     RPN_DATA_BITS_6 = 0,
688e2577bd7SMatthias Ringwald     RPN_DATA_BITS_7 = 0,
689e2577bd7SMatthias Ringwald     RPN_DATA_BITS_8 = 0
690e2577bd7SMatthias Ringwald } rpn_data_bits_t;
691e2577bd7SMatthias Ringwald 
692e2577bd7SMatthias Ringwald typedef enum rpn_stop_bits {
693e2577bd7SMatthias Ringwald     RPN_STOP_BITS_1_0 = 0,
694e2577bd7SMatthias Ringwald     RPN_STOP_BITS_1_5
695e2577bd7SMatthias Ringwald } rpn_stop_bits_t;
696e2577bd7SMatthias Ringwald 
697e2577bd7SMatthias Ringwald typedef enum rpn_parity {
698e2577bd7SMatthias Ringwald     RPN_PARITY_NONE  = 0,
699e2577bd7SMatthias Ringwald     RPN_PARITY_ODD   = 1,
700e2577bd7SMatthias Ringwald     RPN_PARITY_EVEN  = 3,
701e2577bd7SMatthias Ringwald     RPN_PARITY_MARK  = 5,
702e2577bd7SMatthias Ringwald     RPN_PARITY_SPACE = 7,
703e2577bd7SMatthias Ringwald } rpn_parity_t;
704e2577bd7SMatthias Ringwald 
705e2577bd7SMatthias Ringwald typedef enum rpn_flow_control {
706e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_XONXOFF_ON_INPUT  = 1 << 0,
707e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_XONXOFF_ON_OUTPUT = 1 << 1,
708e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_RTR_ON_INPUT  = 1 << 2,
709e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_RTR_ON_OUTPUT = 1 << 3,
710e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_RTC_ON_INPUT  = 1 << 4,
711e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_RTC_ON_OUTPUT = 1 << 5,
712e2577bd7SMatthias Ringwald } rpn_flow_control_t;
713e2577bd7SMatthias Ringwald 
714e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_BAUD             0x01
715e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_DATA_BITS        0x02
716e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_STOP_BITS        0x04
717e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_PARITY           0x08
718e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_PARITY_TYPE      0x10
719e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_XON_CHAR         0x20
720e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_XOFF_CHAR        0x40
721e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_RESERVED         0x80
722e2577bd7SMatthias Ringwald 
723e2577bd7SMatthias Ringwald // @note: values are identical to rpn_flow_control_t
724e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_XONOFF_ON_INPUT  0x01
725e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_XONOFF_ON_OUTPUT 0x02
726e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RTR_ON_INPUT     0x04
727e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RTR_ON_OUTPUT    0x08
728e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RTC_ON_INPUT     0x10
729e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RTC_ON_OUTPUT    0x20
730e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RESERVED_0       0x40
731e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RESERVED_1       0x80
732e2577bd7SMatthias Ringwald 
733e2577bd7SMatthias Ringwald /**
73466b1fcb3SMatthias Ringwald  * BNEP Protocol
73566b1fcb3SMatthias Ringwald  */
73647f4e325SMatthias Ringwald 
73766b1fcb3SMatthias Ringwald #ifndef ETHER_ADDR_LEN
7389a73f75dSMatthias Ringwald #define ETHER_ADDR_LEN 6
73966b1fcb3SMatthias Ringwald #endif
74047f4e325SMatthias Ringwald 
74166b1fcb3SMatthias Ringwald #ifndef ETHERTYPE_VLAN
74266b1fcb3SMatthias Ringwald #define ETHERTYPE_VLAN                                  0x8100 /* IEEE 802.1Q VLAN tag */
74366b1fcb3SMatthias Ringwald #endif
74466b1fcb3SMatthias Ringwald 
74566b1fcb3SMatthias Ringwald #define BNEP_MTU_MIN                                    1691
74666b1fcb3SMatthias Ringwald 
74766b1fcb3SMatthias Ringwald #define BNEP_EXT_FLAG                                   0x80
74866b1fcb3SMatthias Ringwald #define BNEP_TYPE_MASK                                  0x7F
74966b1fcb3SMatthias Ringwald #define BNEP_TYPE(header)                               ((header) & BNEP_TYPE_MASK)
75066b1fcb3SMatthias Ringwald #define BNEP_HEADER_HAS_EXT(x)                          (((x) & BNEP_EXT_FLAG) == BNEP_EXT_FLAG)
75166b1fcb3SMatthias Ringwald 
75266b1fcb3SMatthias Ringwald /* BNEP packet types */
75366b1fcb3SMatthias Ringwald #define BNEP_PKT_TYPE_GENERAL_ETHERNET                  0x00
75466b1fcb3SMatthias Ringwald #define BNEP_PKT_TYPE_CONTROL                           0x01
75566b1fcb3SMatthias Ringwald #define BNEP_PKT_TYPE_COMPRESSED_ETHERNET               0x02
75666b1fcb3SMatthias Ringwald #define BNEP_PKT_TYPE_COMPRESSED_ETHERNET_SOURCE_ONLY   0x03
75766b1fcb3SMatthias Ringwald #define BNEP_PKT_TYPE_COMPRESSED_ETHERNET_DEST_ONLY     0x04
75866b1fcb3SMatthias Ringwald 
75966b1fcb3SMatthias Ringwald /* BNEP control types */
76066b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_COMMAND_NOT_UNDERSTOOD        0x00
76166b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_SETUP_CONNECTION_REQUEST      0x01
76266b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_SETUP_CONNECTION_RESPONSE     0x02
76366b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_FILTER_NET_TYPE_SET           0x03
76466b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_FILTER_NET_TYPE_RESPONSE      0x04
76566b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_FILTER_MULTI_ADDR_SET         0x05
76666b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_FILTER_MULTI_ADDR_RESPONSE    0x06
76766b1fcb3SMatthias Ringwald 
76866b1fcb3SMatthias Ringwald /* BNEP extension header types */
76966b1fcb3SMatthias Ringwald #define BNEP_EXT_HEADER_TYPE_EXTENSION_CONTROL          0x00
77066b1fcb3SMatthias Ringwald 
77166b1fcb3SMatthias Ringwald /* BNEP setup response codes */
77266b1fcb3SMatthias Ringwald #define BNEP_RESP_SETUP_SUCCESS                         0x0000
77366b1fcb3SMatthias Ringwald #define BNEP_RESP_SETUP_INVALID_DEST_UUID               0x0001
77466b1fcb3SMatthias Ringwald #define BNEP_RESP_SETUP_INVALID_SOURCE_UUID             0x0002
77566b1fcb3SMatthias Ringwald #define BNEP_RESP_SETUP_INVALID_SERVICE_UUID_SIZE       0x0003
77666b1fcb3SMatthias Ringwald #define BNEP_RESP_SETUP_CONNECTION_NOT_ALLOWED          0x0004
77766b1fcb3SMatthias Ringwald 
77866b1fcb3SMatthias Ringwald /* BNEP filter response codes */
77966b1fcb3SMatthias Ringwald #define BNEP_RESP_FILTER_SUCCESS                        0x0000
78066b1fcb3SMatthias Ringwald #define BNEP_RESP_FILTER_UNSUPPORTED_REQUEST            0x0001
78166b1fcb3SMatthias Ringwald #define BNEP_RESP_FILTER_ERR_INVALID_RANGE              0x0002
78266b1fcb3SMatthias Ringwald #define BNEP_RESP_FILTER_ERR_TOO_MANY_FILTERS           0x0003
78366b1fcb3SMatthias Ringwald #define BNEP_RESP_FILTER_ERR_SECURITY                   0x0004
78466b1fcb3SMatthias Ringwald 
78566b1fcb3SMatthias Ringwald /**
78666b1fcb3SMatthias Ringwald  * PAN Profile
78766b1fcb3SMatthias Ringwald  */
78866b1fcb3SMatthias Ringwald 
78966b1fcb3SMatthias Ringwald typedef enum {
79066b1fcb3SMatthias Ringwald     PANU_UUID = 0x1115,
79166b1fcb3SMatthias Ringwald     NAP_UUID = 0x1116,
79266b1fcb3SMatthias Ringwald     GN_UUID = 0x1117
79366b1fcb3SMatthias Ringwald } bnep_service_uuid_t;
79466b1fcb3SMatthias Ringwald 
79566b1fcb3SMatthias Ringwald typedef enum {
79666b1fcb3SMatthias Ringwald     BNEP_SECURITY_NONE = 0x0000,
79766b1fcb3SMatthias Ringwald     BNEP_SECURITY_SERVICE_LEVEL_ENFORCED,
79866b1fcb3SMatthias Ringwald     BNEP_SECURITY_802_1X
79966b1fcb3SMatthias Ringwald } security_description_t;
80066b1fcb3SMatthias Ringwald 
80166b1fcb3SMatthias Ringwald typedef enum {
80266b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_PSTN = 0x0000,
80366b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_ISDN,
80466b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_DSL,
80566b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_CABLE_MODEM,
80666b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_10MB_ETHERNET,
80766b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_100MB_ETHERNET,
80866b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_4MB_TOKEN_RING,
80966b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_16MB_TOKEN_RING,
81066b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_100MB_TOKEN_RING,
81166b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_FDDI,
81266b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_GSM,
81366b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_CDMA,
81466b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_GPRS,
81566b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_3G,
81666b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_CELULAR,
81766b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_OTHER = 0xFFFE,
81866b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_NONE
81966b1fcb3SMatthias Ringwald } net_access_type_t;
82047f4e325SMatthias Ringwald 
8214c1900e6SMatthias Ringwald /**
8224c1900e6SMatthias Ringwald  * ATT
8234c1900e6SMatthias Ringwald  */
8244c1900e6SMatthias Ringwald 
8254c1900e6SMatthias Ringwald // Minimum/default MTU
8264c1900e6SMatthias Ringwald #define ATT_DEFAULT_MTU               23
8274c1900e6SMatthias Ringwald 
8284c1900e6SMatthias Ringwald // MARK: Attribute PDU Opcodes
8294c1900e6SMatthias Ringwald #define ATT_ERROR_RESPONSE              0x01
8304c1900e6SMatthias Ringwald 
8314c1900e6SMatthias Ringwald #define ATT_EXCHANGE_MTU_REQUEST        0x02
8324c1900e6SMatthias Ringwald #define ATT_EXCHANGE_MTU_RESPONSE       0x03
8334c1900e6SMatthias Ringwald 
8344c1900e6SMatthias Ringwald #define ATT_FIND_INFORMATION_REQUEST    0x04
8354c1900e6SMatthias Ringwald #define ATT_FIND_INFORMATION_REPLY      0x05
8364c1900e6SMatthias Ringwald #define ATT_FIND_BY_TYPE_VALUE_REQUEST  0x06
8374c1900e6SMatthias Ringwald #define ATT_FIND_BY_TYPE_VALUE_RESPONSE 0x07
8384c1900e6SMatthias Ringwald 
8394c1900e6SMatthias Ringwald #define ATT_READ_BY_TYPE_REQUEST        0x08
8404c1900e6SMatthias Ringwald #define ATT_READ_BY_TYPE_RESPONSE       0x09
8414c1900e6SMatthias Ringwald #define ATT_READ_REQUEST                0x0a
8424c1900e6SMatthias Ringwald #define ATT_READ_RESPONSE               0x0b
8434c1900e6SMatthias Ringwald #define ATT_READ_BLOB_REQUEST           0x0c
8444c1900e6SMatthias Ringwald #define ATT_READ_BLOB_RESPONSE          0x0d
8454c1900e6SMatthias Ringwald #define ATT_READ_MULTIPLE_REQUEST       0x0e
8464c1900e6SMatthias Ringwald #define ATT_READ_MULTIPLE_RESPONSE      0x0f
8474c1900e6SMatthias Ringwald #define ATT_READ_BY_GROUP_TYPE_REQUEST  0x10
8484c1900e6SMatthias Ringwald #define ATT_READ_BY_GROUP_TYPE_RESPONSE 0x11
8494c1900e6SMatthias Ringwald 
8504c1900e6SMatthias Ringwald #define ATT_WRITE_REQUEST               0x12
8514c1900e6SMatthias Ringwald #define ATT_WRITE_RESPONSE              0x13
8524c1900e6SMatthias Ringwald 
8534c1900e6SMatthias Ringwald #define ATT_PREPARE_WRITE_REQUEST       0x16
8544c1900e6SMatthias Ringwald #define ATT_PREPARE_WRITE_RESPONSE      0x17
8554c1900e6SMatthias Ringwald #define ATT_EXECUTE_WRITE_REQUEST       0x18
8564c1900e6SMatthias Ringwald #define ATT_EXECUTE_WRITE_RESPONSE      0x19
8574c1900e6SMatthias Ringwald 
8584c1900e6SMatthias Ringwald #define ATT_HANDLE_VALUE_NOTIFICATION   0x1b
8594c1900e6SMatthias Ringwald #define ATT_HANDLE_VALUE_INDICATION     0x1d
8604c1900e6SMatthias Ringwald #define ATT_HANDLE_VALUE_CONFIRMATION   0x1e
8614c1900e6SMatthias Ringwald 
8624c1900e6SMatthias Ringwald 
8634c1900e6SMatthias Ringwald #define ATT_WRITE_COMMAND                0x52
8644c1900e6SMatthias Ringwald #define ATT_SIGNED_WRITE_COMMAND         0xD2
8654c1900e6SMatthias Ringwald 
8664c1900e6SMatthias Ringwald // MARK: ATT Error Codes
8674c1900e6SMatthias Ringwald #define ATT_ERROR_INVALID_HANDLE                   0x01
8684c1900e6SMatthias Ringwald #define ATT_ERROR_READ_NOT_PERMITTED               0x02
8694c1900e6SMatthias Ringwald #define ATT_ERROR_WRITE_NOT_PERMITTED              0x03
8704c1900e6SMatthias Ringwald #define ATT_ERROR_INVALID_PDU                      0x04
8714c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_AUTHENTICATION      0x05
8724c1900e6SMatthias Ringwald #define ATT_ERROR_REQUEST_NOT_SUPPORTED            0x06
8734c1900e6SMatthias Ringwald #define ATT_ERROR_INVALID_OFFSET                   0x07
8744c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_AUTHORIZATION       0x08
8754c1900e6SMatthias Ringwald #define ATT_ERROR_PREPARE_QUEUE_FULL               0x09
8764c1900e6SMatthias Ringwald #define ATT_ERROR_ATTRIBUTE_NOT_FOUND              0x0a
8774c1900e6SMatthias Ringwald #define ATT_ERROR_ATTRIBUTE_NOT_LONG               0x0b
8784c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_ENCRYPTION_KEY_SIZE 0x0c
8794c1900e6SMatthias Ringwald #define ATT_ERROR_INVALID_ATTRIBUTE_VALUE_LENGTH   0x0d
8804c1900e6SMatthias Ringwald #define ATT_ERROR_UNLIKELY_ERROR                   0x0e
8814c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_ENCRYPTION          0x0f
8824c1900e6SMatthias Ringwald #define ATT_ERROR_UNSUPPORTED_GROUP_TYPE           0x10
8834c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_RESOURCES           0x11
8844c1900e6SMatthias Ringwald 
8854c1900e6SMatthias Ringwald // MARK: Attribute Property Flags
8864c1900e6SMatthias Ringwald #define ATT_PROPERTY_BROADCAST           0x01
8874c1900e6SMatthias Ringwald #define ATT_PROPERTY_READ                0x02
8884c1900e6SMatthias Ringwald #define ATT_PROPERTY_WRITE_WITHOUT_RESPONSE 0x04
8894c1900e6SMatthias Ringwald #define ATT_PROPERTY_WRITE               0x08
8904c1900e6SMatthias Ringwald #define ATT_PROPERTY_NOTIFY              0x10
8914c1900e6SMatthias Ringwald #define ATT_PROPERTY_INDICATE            0x20
8924c1900e6SMatthias Ringwald #define ATT_PROPERTY_AUTHENTICATED_SIGNED_WRITE 0x40
8934c1900e6SMatthias Ringwald #define ATT_PROPERTY_EXTENDED_PROPERTIES 0x80
8944c1900e6SMatthias Ringwald 
8954c1900e6SMatthias Ringwald // MARK: Attribute Property Flag, BTstack extension
8964c1900e6SMatthias Ringwald // value is asked from client
8974c1900e6SMatthias Ringwald #define ATT_PROPERTY_DYNAMIC             0x100
8984c1900e6SMatthias Ringwald // 128 bit UUID used
8994c1900e6SMatthias Ringwald #define ATT_PROPERTY_UUID128             0x200
9004c1900e6SMatthias Ringwald // Authentication required
9014c1900e6SMatthias Ringwald #define ATT_PROPERTY_AUTHENTICATION_REQUIRED 0x400
9024c1900e6SMatthias Ringwald // Authorization from user required
9034c1900e6SMatthias Ringwald #define ATT_PROPERTY_AUTHORIZATION_REQUIRED  0x800
9044c1900e6SMatthias Ringwald // Encryption key size stored in upper 4 bits, 0 == no encryption, encryption key size - 1 otherwise
9054c1900e6SMatthias Ringwald 
9064c1900e6SMatthias Ringwald // ATT Transaction Timeout of 30 seconds for Command/Response or Incidationc/Confirmation
9074c1900e6SMatthias Ringwald #define ATT_TRANSACTION_TIMEOUT_MS     30000
9084c1900e6SMatthias Ringwald 
9094c1900e6SMatthias Ringwald #define ATT_TRANSACTION_MODE_NONE      0x0
9104c1900e6SMatthias Ringwald #define ATT_TRANSACTION_MODE_ACTIVE    0x1
9114c1900e6SMatthias Ringwald #define ATT_TRANSACTION_MODE_EXECUTE   0x2
9124c1900e6SMatthias Ringwald #define ATT_TRANSACTION_MODE_CANCEL    0x3
9134c1900e6SMatthias Ringwald 
9144c1900e6SMatthias Ringwald // MARK: GATT UUIDs
9154c1900e6SMatthias Ringwald #define GATT_PRIMARY_SERVICE_UUID                   0x2800
9164c1900e6SMatthias Ringwald #define GATT_SECONDARY_SERVICE_UUID                 0x2801
9174c1900e6SMatthias Ringwald #define GATT_INCLUDE_SERVICE_UUID                   0x2802
9184c1900e6SMatthias Ringwald #define GATT_CHARACTERISTICS_UUID                   0x2803
9194c1900e6SMatthias Ringwald #define GATT_CHARACTERISTIC_EXTENDED_PROPERTIES     0x2900
9204c1900e6SMatthias Ringwald #define GATT_CHARACTERISTIC_USER_DESCRIPTION        0x2901
9214c1900e6SMatthias Ringwald #define GATT_CLIENT_CHARACTERISTICS_CONFIGURATION   0x2902
9224c1900e6SMatthias Ringwald #define GATT_SERVER_CHARACTERISTICS_CONFIGURATION   0x2903
9234c1900e6SMatthias Ringwald #define GATT_CHARACTERISTIC_PRESENTATION_FORMAT     0x2904
9244c1900e6SMatthias Ringwald #define GATT_CHARACTERISTIC_AGGREGATE_FORMAT        0x2905
9254c1900e6SMatthias Ringwald 
9264c1900e6SMatthias Ringwald #define GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NONE          0
9274c1900e6SMatthias Ringwald #define GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NOTIFICATION  1
9284c1900e6SMatthias Ringwald #define GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_INDICATION    2
9294c1900e6SMatthias Ringwald 
9304c1900e6SMatthias Ringwald // GAP Service and Characteristics
9314c1900e6SMatthias Ringwald #define GAP_SERVICE_UUID               0x1800
9324c1900e6SMatthias Ringwald #define GAP_DEVICE_NAME_UUID           0x2a00
9334c1900e6SMatthias Ringwald #define GAP_APPEARANCE_UUID            0x2a01
9344c1900e6SMatthias Ringwald #define GAP_PERIPHERAL_PRIVACY_FLAG    0x2a02
9354c1900e6SMatthias Ringwald #define GAP_RECONNECTION_ADDRESS_UUID  0x2a03
9364c1900e6SMatthias Ringwald #define GAP_PERIPHERAL_PREFERRED_CONNECTION_PARAMETERS_UUID 0x2a04
93717fe8172SMatthias Ringwald #define GAP_SERVICE_CHANGED            0x2a05
9384c1900e6SMatthias Ringwald 
9394c1900e6SMatthias Ringwald /**
9404c1900e6SMatthias Ringwald  * SM - LE Security Manager
9414c1900e6SMatthias Ringwald  */
9424c1900e6SMatthias Ringwald // Bluetooth Spec definitions
9434c1900e6SMatthias Ringwald typedef enum {
9444c1900e6SMatthias Ringwald     SM_CODE_PAIRING_REQUEST = 0X01,
9454c1900e6SMatthias Ringwald     SM_CODE_PAIRING_RESPONSE,
9464c1900e6SMatthias Ringwald     SM_CODE_PAIRING_CONFIRM,
9474c1900e6SMatthias Ringwald     SM_CODE_PAIRING_RANDOM,
9484c1900e6SMatthias Ringwald     SM_CODE_PAIRING_FAILED,
9494c1900e6SMatthias Ringwald     SM_CODE_ENCRYPTION_INFORMATION,
9504c1900e6SMatthias Ringwald     SM_CODE_MASTER_IDENTIFICATION,
9514c1900e6SMatthias Ringwald     SM_CODE_IDENTITY_INFORMATION,
9524c1900e6SMatthias Ringwald     SM_CODE_IDENTITY_ADDRESS_INFORMATION,
9534c1900e6SMatthias Ringwald     SM_CODE_SIGNING_INFORMATION,
95474a9b3d5SMatthias Ringwald     SM_CODE_SECURITY_REQUEST,
95574a9b3d5SMatthias Ringwald     SM_CODE_PAIRING_PUBLIC_KEY,
95674a9b3d5SMatthias Ringwald     SM_CODE_PAIRING_DHKEY_CHECK,
9574c1900e6SMatthias Ringwald } SECURITY_MANAGER_COMMANDS;
9584c1900e6SMatthias Ringwald 
9594c1900e6SMatthias Ringwald // IO Capability Values
9604c1900e6SMatthias Ringwald typedef enum {
9614c1900e6SMatthias Ringwald     IO_CAPABILITY_DISPLAY_ONLY = 0,
9624c1900e6SMatthias Ringwald     IO_CAPABILITY_DISPLAY_YES_NO,
9634c1900e6SMatthias Ringwald     IO_CAPABILITY_KEYBOARD_ONLY,
9644c1900e6SMatthias Ringwald     IO_CAPABILITY_NO_INPUT_NO_OUTPUT,
9654c1900e6SMatthias Ringwald     IO_CAPABILITY_KEYBOARD_DISPLAY, // not used by secure simple pairing
9664c1900e6SMatthias Ringwald } io_capability_t;
9674c1900e6SMatthias Ringwald 
9684c1900e6SMatthias Ringwald // Authentication requirement flags
9694c1900e6SMatthias Ringwald #define SM_AUTHREQ_NO_BONDING        0x00
9704c1900e6SMatthias Ringwald #define SM_AUTHREQ_BONDING           0x01
9714c1900e6SMatthias Ringwald #define SM_AUTHREQ_MITM_PROTECTION   0x04
97274a9b3d5SMatthias Ringwald #define SM_AUTHREQ_SECURE_CONNECTION 0x08
97374a9b3d5SMatthias Ringwald #define SM_AUTHREQ_KEYPRESS          0x10
9744c1900e6SMatthias Ringwald 
9754c1900e6SMatthias Ringwald // Key distribution flags used by spec
97652f9cf63SMatthias Ringwald #define SM_KEYDIST_ENC_KEY  0x01
9774c1900e6SMatthias Ringwald #define SM_KEYDIST_ID_KEY   0x02
9784c1900e6SMatthias Ringwald #define SM_KEYDIST_SIGN     0x04
97952f9cf63SMatthias Ringwald #define SM_KEYDIST_LINK_KEY 0x08
9804c1900e6SMatthias Ringwald 
9814c1900e6SMatthias Ringwald // Key distribution flags used internally
9824c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_ENCRYPTION_INFORMATION       0x01
9834c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_MASTER_IDENTIFICATION        0x02
9844c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_IDENTITY_INFORMATION         0x04
9854c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_IDENTITY_ADDRESS_INFORMATION 0x08
9864c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_SIGNING_IDENTIFICATION       0x10
9874c1900e6SMatthias Ringwald 
9884c1900e6SMatthias Ringwald // STK Generation Methods
9894c1900e6SMatthias Ringwald #define SM_STK_GENERATION_METHOD_JUST_WORKS          0x01
9904c1900e6SMatthias Ringwald #define SM_STK_GENERATION_METHOD_OOB                 0x02
9914c1900e6SMatthias Ringwald #define SM_STK_GENERATION_METHOD_PASSKEY             0x04
992b4343428SMatthias Ringwald #define SM_STK_GENERATION_METHOD_NUMERIC_COMPARISON  0x08
9934c1900e6SMatthias Ringwald 
9944c1900e6SMatthias Ringwald // Pairing Failed Reasons
9954c1900e6SMatthias Ringwald #define SM_REASON_RESERVED                     0x00
9964c1900e6SMatthias Ringwald #define SM_REASON_PASSKEYT_ENTRY_FAILED        0x01
9974c1900e6SMatthias Ringwald #define SM_REASON_OOB_NOT_AVAILABLE            0x02
9984c1900e6SMatthias Ringwald #define SM_REASON_AUTHENTHICATION_REQUIREMENTS 0x03
9994c1900e6SMatthias Ringwald #define SM_REASON_CONFIRM_VALUE_FAILED         0x04
10004c1900e6SMatthias Ringwald #define SM_REASON_PAIRING_NOT_SUPPORTED        0x05
10014c1900e6SMatthias Ringwald #define SM_REASON_ENCRYPTION_KEY_SIZE          0x06
10024c1900e6SMatthias Ringwald #define SM_REASON_COMMAND_NOT_SUPPORTED        0x07
10034c1900e6SMatthias Ringwald #define SM_REASON_UNSPECIFIED_REASON           0x08
10044c1900e6SMatthias Ringwald #define SM_REASON_REPEATED_ATTEMPTS            0x09
1005*a9f29768SMatthias Ringwald #define SM_REASON_INVALID_PARAMETERS           0x0a
1006*a9f29768SMatthias Ringwald #define SM_REASON_DHKEY_CHECK_FAILED           0x0b
1007*a9f29768SMatthias Ringwald #define SM_REASON_NUMERIC_COMPARISON_FAILED    0x0c
1008*a9f29768SMatthias Ringwald 
10094c1900e6SMatthias Ringwald // also, invalid parameters
10104c1900e6SMatthias Ringwald // and reserved
10114c1900e6SMatthias Ringwald 
1012c6d1dbedSMatthias Ringwald // Company identifiers / manufacturers
1013c6d1dbedSMatthias Ringwald #define COMPANY_ID_CAMBRIDGE_SILICON_RADIO     0x000A
1014c6d1dbedSMatthias Ringwald #define COMPANY_ID_TEXAS_INSTRUMENTS_INC       0x000D
1015c6d1dbedSMatthias Ringwald #define COMPANY_ID_BROADCOM_CORPORATION        0x000F
1016c6d1dbedSMatthias Ringwald #define COMPANY_ID_ST_MICROELECTRONICS         0x0030
1017c6d1dbedSMatthias Ringwald #define COMPANY_ID_EM_MICROELECTRONICS_MARIN   0x005A
1018c6d1dbedSMatthias Ringwald 
10194c1900e6SMatthias Ringwald 
102047f4e325SMatthias Ringwald #endif