xref: /btstack/src/bluetooth.h (revision 09f91c9f55cbd0ab8779b6f3a3fb1f6d5365cb42)
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 
4480e33422SMatthias Ringwald #ifndef BLUETOOTH_H
4580e33422SMatthias Ringwald #define BLUETOOTH_H
4647f4e325SMatthias Ringwald 
4747f4e325SMatthias Ringwald #include <stdint.h>
4847f4e325SMatthias Ringwald 
4947f4e325SMatthias Ringwald /**
508974fcd6SMatthias Ringwald  * @brief hci connection handle type
518974fcd6SMatthias Ringwald  */
528974fcd6SMatthias Ringwald typedef uint16_t hci_con_handle_t;
538974fcd6SMatthias Ringwald 
548974fcd6SMatthias Ringwald /**
558974fcd6SMatthias Ringwald  * @brief Length of a bluetooth device address.
568974fcd6SMatthias Ringwald  */
578974fcd6SMatthias Ringwald #define BD_ADDR_LEN 6
588974fcd6SMatthias Ringwald 
598974fcd6SMatthias Ringwald /**
608974fcd6SMatthias Ringwald  * @brief Bluetooth address
618974fcd6SMatthias Ringwald  */
628974fcd6SMatthias Ringwald typedef uint8_t bd_addr_t[BD_ADDR_LEN];
638974fcd6SMatthias Ringwald 
648974fcd6SMatthias Ringwald /**
658974fcd6SMatthias Ringwald  * Address types
668974fcd6SMatthias Ringwald  * @note: BTstack uses a custom addr type to refer to classic ACL and SCO devices
678974fcd6SMatthias Ringwald  */
688974fcd6SMatthias Ringwald  typedef enum {
698974fcd6SMatthias Ringwald     BD_ADDR_TYPE_LE_PUBLIC = 0,
708974fcd6SMatthias Ringwald     BD_ADDR_TYPE_LE_RANDOM = 1,
71b95a5a35SMatthias Ringwald     BD_ADDR_TYPE_LE_PRIVAT_FALLBACK_PUBLIC = 2,
72b95a5a35SMatthias Ringwald     BD_ADDR_TYPE_LE_PRIVAT_FALLBACK_RANDOM = 3,
738974fcd6SMatthias Ringwald     BD_ADDR_TYPE_SCO       = 0xfe,
748974fcd6SMatthias Ringwald     BD_ADDR_TYPE_CLASSIC   = 0xff,
758974fcd6SMatthias Ringwald     BD_ADDR_TYPE_UNKNOWN   = 0xfe
768974fcd6SMatthias Ringwald } bd_addr_type_t;
778974fcd6SMatthias Ringwald 
78b95a5a35SMatthias Ringwald 
79b95a5a35SMatthias Ringwald 
808974fcd6SMatthias Ringwald /**
818974fcd6SMatthias Ringwald  * @brief link key
828974fcd6SMatthias Ringwald  */
838974fcd6SMatthias Ringwald #define LINK_KEY_LEN 16
848974fcd6SMatthias Ringwald #define LINK_KEY_STR_LEN (LINK_KEY_LEN*2)
858974fcd6SMatthias Ringwald typedef uint8_t link_key_t[LINK_KEY_LEN];
868974fcd6SMatthias Ringwald 
878974fcd6SMatthias Ringwald /**
888974fcd6SMatthias Ringwald  * @brief link key type
898974fcd6SMatthias Ringwald  */
908974fcd6SMatthias Ringwald typedef enum {
918974fcd6SMatthias Ringwald   COMBINATION_KEY = 0,  // standard pairing
928974fcd6SMatthias Ringwald   LOCAL_UNIT_KEY,     // ?
938974fcd6SMatthias Ringwald   REMOTE_UNIT_KEY,    // ?
948974fcd6SMatthias Ringwald   DEBUG_COMBINATION_KEY,  // SSP with debug
958974fcd6SMatthias Ringwald   UNAUTHENTICATED_COMBINATION_KEY_GENERATED_FROM_P192, // SSP Simple Pairing
968974fcd6SMatthias Ringwald   AUTHENTICATED_COMBINATION_KEY_GENERATED_FROM_P192,   // SSP Passkey, Number confirm, OOB
978974fcd6SMatthias Ringwald   CHANGED_COMBINATION_KEY,               // Link key changed using Change Connection Lnk Key
988974fcd6SMatthias Ringwald   UNAUTHENTICATED_COMBINATION_KEY_GENERATED_FROM_P256, // SSP Simpe Pairing
998974fcd6SMatthias Ringwald   AUTHENTICATED_COMBINATION_KEY_GENERATED_FROM_P256,   // SSP Passkey, Number confirm, OOB
1008974fcd6SMatthias Ringwald } link_key_type_t;
1018974fcd6SMatthias Ringwald 
1028974fcd6SMatthias Ringwald /**
103f6858d14SMatthias Ringwald  * @brief Inquiry modes
104f6858d14SMatthias Ringwald  */
105f6858d14SMatthias Ringwald typedef enum {
106f6858d14SMatthias Ringwald   INQUIRY_MODE_STANDARD = 0,
107f6858d14SMatthias Ringwald   INQUIRY_MODE_RSSI,
108f6858d14SMatthias Ringwald   INQUIRY_MODE_RSSI_AND_EIR,
109f6858d14SMatthias Ringwald } inquiry_mode_t;
110f6858d14SMatthias Ringwald 
11185ddcd84SMatthias Ringwald 
112671fb338SMatthias Ringwald /**
11347f4e325SMatthias Ringwald  * HCI Transport
11447f4e325SMatthias Ringwald  */
11547f4e325SMatthias Ringwald 
11647f4e325SMatthias Ringwald /**
11747f4e325SMatthias Ringwald  * packet types - used in BTstack and over the H4 UART interface
11847f4e325SMatthias Ringwald  */
11947f4e325SMatthias Ringwald #define HCI_COMMAND_DATA_PACKET 0x01
12047f4e325SMatthias Ringwald #define HCI_ACL_DATA_PACKET     0x02
12147f4e325SMatthias Ringwald #define HCI_SCO_DATA_PACKET     0x03
12247f4e325SMatthias Ringwald #define HCI_EVENT_PACKET        0x04
12347f4e325SMatthias Ringwald 
1248799c043SMatthias Ringwald // packet header sizes
1258799c043SMatthias Ringwald #define HCI_CMD_HEADER_SIZE          3
1268799c043SMatthias Ringwald #define HCI_ACL_HEADER_SIZE          4
1278799c043SMatthias Ringwald #define HCI_SCO_HEADER_SIZE          3
1288799c043SMatthias Ringwald #define HCI_EVENT_HEADER_SIZE        2
1298799c043SMatthias Ringwald 
13047f4e325SMatthias Ringwald /**
13147f4e325SMatthias Ringwald  * HCI Layer
13247f4e325SMatthias Ringwald  */
13347f4e325SMatthias Ringwald 
13447f4e325SMatthias Ringwald //
135f193890fSMatthias Ringwald // Error Codes rfom Bluetooth Core Specification
13647f4e325SMatthias Ringwald //
13747f4e325SMatthias Ringwald 
138f193890fSMatthias Ringwald /* ENUM_START: BLUETOOTH_ERROR_CODE */
139616edd56SMatthias Ringwald #define ERROR_CODE_SUCCESS                                 0x00
14047f4e325SMatthias Ringwald #define ERROR_CODE_UNKNOWN_HCI_COMMAND                     0x01
14147f4e325SMatthias Ringwald #define ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER           0x02
14247f4e325SMatthias Ringwald #define ERROR_CODE_HARDWARE_FAILURE                        0x03
14347f4e325SMatthias Ringwald #define ERROR_CODE_PAGE_TIMEOUT                            0x04
14447f4e325SMatthias Ringwald #define ERROR_CODE_AUTHENTICATION_FAILURE                  0x05
14547f4e325SMatthias Ringwald #define ERROR_CODE_PIN_OR_KEY_MISSING                      0x06
14647f4e325SMatthias Ringwald #define ERROR_CODE_MEMORY_CAPACITY_EXCEEDED                0x07
14747f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_TIMEOUT                      0x08
14847f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_LIMIT_EXCEEDED               0x09
14947f4e325SMatthias Ringwald #define ERROR_CODE_SYNCHRONOUS_CONNECTION_LIMIT_TO_A_DEVICE_EXCEEDED  0x0A
15047f4e325SMatthias Ringwald #define ERROR_CODE_ACL_CONNECTION_ALREADY_EXISTS           0x0B
15147f4e325SMatthias Ringwald #define ERROR_CODE_COMMAND_DISALLOWED                      0x0C
15247f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_REJECTED_DUE_TO_LIMITED_RESOURCES 0x0D
15347f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_REJECTED_DUE_TO_SECURITY_REASONS  0x0E
15447f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_REJECTED_DUE_TO_UNACCEPTABLE_BD_ADDR 0x0F
15547f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_ACCEPT_TIMEOUT_EXCEEDED      0x10
15647f4e325SMatthias Ringwald #define ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE  0x11
15747f4e325SMatthias Ringwald #define ERROR_CODE_INVALID_HCI_COMMAND_PARAMETERS          0x12
15847f4e325SMatthias Ringwald #define ERROR_CODE_REMOTE_USER_TERMINATED_CONNECTION       0x13
15947f4e325SMatthias Ringwald #define ERROR_CODE_REMOTE_DEVICE_TERMINATED_CONNECTION_DUE_TO_LOW_RESOURCES 0x14
16047f4e325SMatthias Ringwald #define ERROR_CODE_REMOTE_DEVICE_TERMINATED_CONNECTION_DUE_TO_POWER_OFF     0x15
16147f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_TERMINATED_BY_LOCAL_HOST     0x16
16247f4e325SMatthias Ringwald #define ERROR_CODE_REPEATED_ATTEMPTS                       0x17
16347f4e325SMatthias Ringwald #define ERROR_CODE_PAIRING_NOT_ALLOWED                     0x18
16447f4e325SMatthias Ringwald #define ERROR_CODE_UNKNOWN_LMP_PDU                         0x19
16547f4e325SMatthias Ringwald #define ERROR_CODE_UNSUPPORTED_REMOTE_FEATURE_UNSUPPORTED_LMP_FEATURE 0x1A
16647f4e325SMatthias Ringwald #define ERROR_CODE_SCO_OFFSET_REJECTED                     0x1B
16747f4e325SMatthias Ringwald #define ERROR_CODE_SCO_INTERVAL_REJECTED                   0x1C
16847f4e325SMatthias Ringwald #define ERROR_CODE_SCO_AIR_MODE_REJECTED                   0x1D
16947f4e325SMatthias Ringwald #define ERROR_CODE_INVALID_LMP_PARAMETERS_INVALID_LL_PARAMETERS 0x1E
17047f4e325SMatthias Ringwald #define ERROR_CODE_UNSPECIFIED_ERROR                       0x1F
17147f4e325SMatthias Ringwald #define ERROR_CODE_UNSUPPORTED_LMP_PARAMETER_VALUE_UNSUPPORTED_LL_PARAMETER_VALUE 0x20
17247f4e325SMatthias Ringwald #define ERROR_CODE_ROLE_CHANGE_NOT_ALLOWED                 0x21
17347f4e325SMatthias Ringwald #define ERROR_CODE_LMP_RESPONSE_TIMEOUT_LL_RESPONSE_TIMEOUT 0x22
17447f4e325SMatthias Ringwald #define ERROR_CODE_LMP_ERROR_TRANSACTION_COLLISION         0x23
17547f4e325SMatthias Ringwald #define ERROR_CODE_LMP_PDU_NOT_ALLOWED                     0x24
17647f4e325SMatthias Ringwald #define ERROR_CODE_ENCRYPTION_MODE_NOT_ACCEPTABLE          0x25
17747f4e325SMatthias Ringwald #define ERROR_CODE_LINK_KEY_CANNOT_BE_CHANGED              0x26
17847f4e325SMatthias Ringwald #define ERROR_CODE_REQUESTED_QOS_NOT_SUPPORTED             0x27
17947f4e325SMatthias Ringwald #define ERROR_CODE_INSTANT_PASSED                          0x28
18047f4e325SMatthias Ringwald #define ERROR_CODE_PAIRING_WITH_UNIT_KEY_NOT_SUPPORTED     0x29
18147f4e325SMatthias Ringwald #define ERROR_CODE_DIFFERENT_TRANSACTION_COLLISION         0x2A
18247f4e325SMatthias Ringwald #define ERROR_CODE_RESERVED                                0x2B
18347f4e325SMatthias Ringwald #define ERROR_CODE_QOS_UNACCEPTABLE_PARAMETER              0x2C
18447f4e325SMatthias Ringwald #define ERROR_CODE_QOS_REJECTED                            0x2D
18547f4e325SMatthias Ringwald #define ERROR_CODE_CHANNEL_CLASSIFICATION_NOT_SUPPORTED    0x2E
18647f4e325SMatthias Ringwald #define ERROR_CODE_INSUFFICIENT_SECURITY                   0x2F
18747f4e325SMatthias Ringwald #define ERROR_CODE_PARAMETER_OUT_OF_MANDATORY_RANGE        0x30
18847f4e325SMatthias Ringwald // #define ERROR_CODE_RESERVED
18947f4e325SMatthias Ringwald #define ERROR_CODE_ROLE_SWITCH_PENDING                     0x32
19047f4e325SMatthias Ringwald // #define ERROR_CODE_RESERVED
19147f4e325SMatthias Ringwald #define ERROR_CODE_RESERVED_SLOT_VIOLATION                 0x34
19247f4e325SMatthias Ringwald #define ERROR_CODE_ROLE_SWITCH_FAILED                      0x35
19347f4e325SMatthias Ringwald #define ERROR_CODE_EXTENDED_INQUIRY_RESPONSE_TOO_LARGE     0x36
19447f4e325SMatthias Ringwald #define ERROR_CODE_SECURE_SIMPLE_PAIRING_NOT_SUPPORTED_BY_HOST 0x37
19547f4e325SMatthias Ringwald #define ERROR_CODE_HOST_BUSY_PAIRING                       0x38
19647f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_REJECTED_DUE_TO_NO_SUITABLE_CHANNEL_FOUND 0x39
19747f4e325SMatthias Ringwald #define ERROR_CODE_CONTROLLER_BUSY                         0x3A
19847f4e325SMatthias Ringwald #define ERROR_CODE_UNACCEPTABLE_CONNECTION_PARAMETERS      0x3B
19947f4e325SMatthias Ringwald #define ERROR_CODE_DIRECTED_ADVERTISING_TIMEOUT            0x3C
20047f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_TERMINATED_DUE_TO_MIC_FAILURE 0x3D
20147f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_FAILED_TO_BE_ESTABLISHED     0x3E
20247f4e325SMatthias Ringwald #define ERROR_CODE_MAC_CONNECTION_FAILED                   0x3F
20347f4e325SMatthias Ringwald #define ERROR_CODE_COARSE_CLOCK_ADJUSTMENT_REJECTED_BUT_WILL_TRY_TO_ADJUST_USING_CLOCK_DRAGGING 0x40
20496c69d4aSMilanka Ringwald 
20596c69d4aSMilanka Ringwald // BTstack defined ERRORS, mapped into BLuetooth status code range
20696c69d4aSMilanka Ringwald 
20796c69d4aSMilanka Ringwald #define BTSTACK_CONNECTION_TO_BTDAEMON_FAILED              0x50
20896c69d4aSMilanka Ringwald #define BTSTACK_ACTIVATION_FAILED_SYSTEM_BLUETOOTH         0x51
20996c69d4aSMilanka Ringwald #define BTSTACK_ACTIVATION_POWERON_FAILED                  0x52
21096c69d4aSMilanka Ringwald #define BTSTACK_ACTIVATION_FAILED_UNKNOWN                  0x53
21196c69d4aSMilanka Ringwald #define BTSTACK_NOT_ACTIVATED                              0x54
21296c69d4aSMilanka Ringwald #define BTSTACK_BUSY                                       0x55
21396c69d4aSMilanka Ringwald #define BTSTACK_MEMORY_ALLOC_FAILED                        0x56
21496c69d4aSMilanka Ringwald #define BTSTACK_ACL_BUFFERS_FULL                           0x57
21596c69d4aSMilanka Ringwald 
21696c69d4aSMilanka Ringwald // l2cap errors - enumeration by the command that created them
21796c69d4aSMilanka Ringwald #define L2CAP_COMMAND_REJECT_REASON_COMMAND_NOT_UNDERSTOOD 0x60
21896c69d4aSMilanka Ringwald #define L2CAP_COMMAND_REJECT_REASON_SIGNALING_MTU_EXCEEDED 0x61
21996c69d4aSMilanka Ringwald #define L2CAP_COMMAND_REJECT_REASON_INVALID_CID_IN_REQUEST 0x62
22096c69d4aSMilanka Ringwald 
22196c69d4aSMilanka Ringwald #define L2CAP_CONNECTION_RESPONSE_RESULT_SUCCESSFUL        0x63
22296c69d4aSMilanka Ringwald #define L2CAP_CONNECTION_RESPONSE_RESULT_PENDING           0x64
22396c69d4aSMilanka Ringwald #define L2CAP_CONNECTION_RESPONSE_RESULT_REFUSED_PSM       0x65
22496c69d4aSMilanka Ringwald #define L2CAP_CONNECTION_RESPONSE_RESULT_REFUSED_SECURITY  0x66
22596c69d4aSMilanka Ringwald #define L2CAP_CONNECTION_RESPONSE_RESULT_REFUSED_RESOURCES 0x67
22696c69d4aSMilanka Ringwald #define L2CAP_CONNECTION_RESPONSE_RESULT_ERTM_NOT_SUPPORTED 0x68
22796c69d4aSMilanka Ringwald 
22896c69d4aSMilanka Ringwald // should be L2CAP_CONNECTION_RTX_TIMEOUT
22996c69d4aSMilanka Ringwald #define L2CAP_CONNECTION_RESPONSE_RESULT_RTX_TIMEOUT       0x69
23096c69d4aSMilanka Ringwald #define L2CAP_CONNECTION_BASEBAND_DISCONNECT               0x6A
23196c69d4aSMilanka Ringwald #define L2CAP_SERVICE_ALREADY_REGISTERED                   0x6B
23296c69d4aSMilanka Ringwald #define L2CAP_DATA_LEN_EXCEEDS_REMOTE_MTU                  0x6C
23396c69d4aSMilanka Ringwald #define L2CAP_SERVICE_DOES_NOT_EXIST                       0x6D
23496c69d4aSMilanka Ringwald #define L2CAP_LOCAL_CID_DOES_NOT_EXIST                     0x6E
23596c69d4aSMilanka Ringwald 
23696c69d4aSMilanka Ringwald #define RFCOMM_MULTIPLEXER_STOPPED                         0x70
23796c69d4aSMilanka Ringwald #define RFCOMM_CHANNEL_ALREADY_REGISTERED                  0x71
23896c69d4aSMilanka Ringwald #define RFCOMM_NO_OUTGOING_CREDITS                         0x72
23996c69d4aSMilanka Ringwald #define RFCOMM_AGGREGATE_FLOW_OFF                          0x73
24096c69d4aSMilanka Ringwald #define RFCOMM_DATA_LEN_EXCEEDS_MTU                        0x74
24196c69d4aSMilanka Ringwald 
24296c69d4aSMilanka Ringwald #define SDP_HANDLE_ALREADY_REGISTERED                      0x80
24396c69d4aSMilanka Ringwald #define SDP_QUERY_INCOMPLETE                               0x81
24496c69d4aSMilanka Ringwald #define SDP_SERVICE_NOT_FOUND                              0x82
24596c69d4aSMilanka Ringwald #define SDP_HANDLE_INVALID                                 0x83
24696c69d4aSMilanka Ringwald #define SDP_QUERY_BUSY                                     0x84
24796c69d4aSMilanka Ringwald 
24896c69d4aSMilanka Ringwald #define ATT_HANDLE_VALUE_INDICATION_IN_PROGRESS            0x90
24996c69d4aSMilanka Ringwald #define ATT_HANDLE_VALUE_INDICATION_TIMEOUT                0x91
25096c69d4aSMilanka Ringwald #define ATT_HANDLE_VALUE_INDICATION_DISCONNECT             0x92
25196c69d4aSMilanka Ringwald 
25296c69d4aSMilanka Ringwald #define GATT_CLIENT_NOT_CONNECTED                          0x93
25396c69d4aSMilanka Ringwald #define GATT_CLIENT_BUSY                                   0x94
25496c69d4aSMilanka Ringwald #define GATT_CLIENT_IN_WRONG_STATE                         0x95
25596c69d4aSMilanka Ringwald #define GATT_CLIENT_DIFFERENT_CONTEXT_FOR_ADDRESS_ALREADY_EXISTS 0x96
25696c69d4aSMilanka Ringwald #define GATT_CLIENT_VALUE_TOO_LONG                         0x97
25796c69d4aSMilanka Ringwald #define GATT_CLIENT_CHARACTERISTIC_NOTIFICATION_NOT_SUPPORTED 0x98
25896c69d4aSMilanka Ringwald #define GATT_CLIENT_CHARACTERISTIC_INDICATION_NOT_SUPPORTED   0x99
25996c69d4aSMilanka Ringwald 
26096c69d4aSMilanka Ringwald #define BNEP_SERVICE_ALREADY_REGISTERED                    0xA0
26196c69d4aSMilanka Ringwald #define BNEP_CHANNEL_NOT_CONNECTED                         0xA1
26296c69d4aSMilanka Ringwald #define BNEP_DATA_LEN_EXCEEDS_MTU                          0xA2
26396c69d4aSMilanka Ringwald 
26496c69d4aSMilanka Ringwald // OBEX ERRORS
26596c69d4aSMilanka Ringwald #define OBEX_UNKNOWN_ERROR                                 0xB0
26696c69d4aSMilanka Ringwald #define OBEX_CONNECT_FAILED                                0xB1
26796c69d4aSMilanka Ringwald #define OBEX_DISCONNECTED                                  0xB2
26896c69d4aSMilanka Ringwald #define OBEX_NOT_FOUND                                     0xB3
26996c69d4aSMilanka Ringwald #define OBEX_NOT_ACCEPTABLE                                0xB4
27096c69d4aSMilanka Ringwald 
27196c69d4aSMilanka Ringwald #define AVDTP_SEID_DOES_NOT_EXIST                          0xC0
27296c69d4aSMilanka Ringwald #define AVDTP_CONNECTION_DOES_NOT_EXIST                    0xC1
27396c69d4aSMilanka Ringwald #define AVDTP_CONNECTION_IN_WRONG_STATE                    0xC2
27496c69d4aSMilanka Ringwald #define AVDTP_STREAM_ENDPOINT_IN_WRONG_STATE               0xC3
27596c69d4aSMilanka Ringwald #define AVDTP_STREAM_ENDPOINT_DOES_NOT_EXIST               0xC4
27696c69d4aSMilanka Ringwald #define AVDTP_MEDIA_CONNECTION_DOES_NOT_EXIST              0xC5
27796c69d4aSMilanka Ringwald 
27896c69d4aSMilanka Ringwald #define MESH_ERROR_APPKEY_INDEX_INVALID                    0xD0
279f193890fSMatthias Ringwald /* ENUM_END */
28047f4e325SMatthias Ringwald 
28132272f12SMilanka Ringwald 
282954cc391SMilanka Ringwald /* ENUM_START: AVRCP_BROWSING_ERROR_CODE */
283954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_INVALID_COMMAND                     0x00  // Sent if TG received a PDU that it did not understand. Valid for All.
284954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_INVALID_PARAMETER                   0x01  // Sent if the TG received a PDU with a parameter ID that it did not understand. Sent if there is only one parameter ID in the PDU. Valid for All.
285954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_SPECIFIED_PARAMETER_NOT_FOUND       0x02  // Sent if the parameter ID is understood, but content is wrong or corrupted. Valid for All.
286954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_INTERNAL_ERROR                      0x03  // Sent if there are error conditions not covered by a more specific error code. Valid for All.
287954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_SUCCESS                             0x04  // This is the status that should be returned if the operation was successful. Valid for All except where the response CType is AV/C REJECTED.
288954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_UID_CHANGED                         0x05  // The UIDs on the device have changed. Valid for All.
289954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_RESERVED_06                         0x06  // Valid for All.
290954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_INVALID_DIRECTION                   0x07  // The Direction parameter is invalid. Valid for Change Path.
291954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_NOT_A_DIRECTORY                     0x08  // The UID provided does not refer to a folder item. Valid for Change Path.
292954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_DOES_NOT_EXIST                      0x09  // The UID provided does not refer to any currently valid. Valid for Change Path, PlayItem, AddToNowPlaying, GetItemAttributes.
293954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_INVALID_SCOPE                       0x0a  // The scope parameter is invalid. Valid for GetFolderItems, PlayItem, AddToNowPlayer, GetItemAttributes,.
294954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_RANGE_OUT_OF_BOUNDS                 0x0b  // The start of range provided is not valid. Valid for GetFolderItems.
295954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_UID_IS_A_DIRECTORY                  0x0c  // The UID provided refers to a directory, which cannot be handled by this media player. Valid for PlayItem, AddToNowPlaying.
296954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_MEDIA_IN_USES                       0x0d  // The media is not able to be used for this operation at this time. Valid for PlayItem, AddToNowPlaying.
297954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_NOW_PLAYING_LIST_FULL               0x0e  // No more items can be added to the Now Playing List. Valid for AddToNowPlaying.
298954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_SEARCH_NOT_SUPPORTED                0x0f  // The Browsed Media Player does not support search. Valid for Search.
299954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_SEARCH_IN_PROGRESS                  0x10  // A search operation is already in progress. Valid for Search.
300954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_INVALID_PLAYER_ID                   0x11  // The specified Player Id does not refer to a valid player. Valid for SetAddressedPlayer, SetBrowsedPlayer.
301954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_PLAYER_NOT_BROWSABLE                0x12  // The Player Id supplied refers to a Media Player which does not support browsing. Valid for SetBrowsedPlayer.
302954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_PLAYER_NOT_ADDRESSED                0x13  // The Player Id supplied refers to a player which is not currently addressed, and the command is not able to be performed if the player is not set as addressed. Valid for Search SetBrowsedPlayer.
303954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_NO_VALID_SEARCH_RESULTS             0x14  // The Search result list does not contain valid entries, e.g. after being invalidated due to change of browsed player. Valid for GetFolderItems.
304954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_NO_AVAILABLE_PLAYERS                0x15  // Valid for All.
305954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_ADDRESSED_PLAYER_CHANGED            0x16  // Valid for Register Notification.
306954cc391SMilanka Ringwald // 0x17-0xff Reserved
307954cc391SMilanka Ringwald /* ENUM_END */
308954cc391SMilanka Ringwald 
3098799c043SMatthias Ringwald // HCI roles
3108799c043SMatthias Ringwald #define HCI_ROLE_MASTER 0
3118799c043SMatthias Ringwald #define HCI_ROLE_SLAVE  1
3128799c043SMatthias Ringwald 
3138799c043SMatthias Ringwald // packet sizes (max payload)
3148799c043SMatthias Ringwald #define HCI_ACL_DM1_SIZE            17
3158799c043SMatthias Ringwald #define HCI_ACL_DH1_SIZE            27
3168799c043SMatthias Ringwald #define HCI_ACL_2DH1_SIZE           54
3178799c043SMatthias Ringwald #define HCI_ACL_3DH1_SIZE           83
3188799c043SMatthias Ringwald #define HCI_ACL_DM3_SIZE           121
3198799c043SMatthias Ringwald #define HCI_ACL_DH3_SIZE           183
3208799c043SMatthias Ringwald #define HCI_ACL_DM5_SIZE           224
3218799c043SMatthias Ringwald #define HCI_ACL_DH5_SIZE           339
3228799c043SMatthias Ringwald #define HCI_ACL_2DH3_SIZE          367
3238799c043SMatthias Ringwald #define HCI_ACL_3DH3_SIZE          552
3248799c043SMatthias Ringwald #define HCI_ACL_2DH5_SIZE          679
3258799c043SMatthias Ringwald #define HCI_ACL_3DH5_SIZE         1021
3268799c043SMatthias Ringwald 
3278799c043SMatthias Ringwald #define HCI_EVENT_PAYLOAD_SIZE     255
3288799c043SMatthias Ringwald #define HCI_CMD_PAYLOAD_SIZE       255
3298799c043SMatthias Ringwald 
3308799c043SMatthias Ringwald #define LE_ADVERTISING_DATA_SIZE    31
33147f4e325SMatthias Ringwald 
332c33e56d3SMatthias Ringwald // Link Policy Settings
333c33e56d3SMatthias Ringwald #define LM_LINK_POLICY_DISABLE_ALL_LM_MODES  0
334c33e56d3SMatthias Ringwald #define LM_LINK_POLICY_ENABLE_ROLE_SWITCH    1
335c33e56d3SMatthias Ringwald #define LM_LINK_POLICY_ENABLE_HOLD_MODE      2
336c33e56d3SMatthias Ringwald #define LM_LINK_POLICY_ENABLE_SNIFF_MODE     3
337c33e56d3SMatthias Ringwald 
33851fd61e9SMatthias Ringwald // ACL Connection Modes
33951fd61e9SMatthias Ringwald #define ACL_CONNECTION_MODE_ACTIVE 0
34051fd61e9SMatthias Ringwald #define ACL_CONNECTION_MODE_HOLD   1
34151fd61e9SMatthias Ringwald #define ACL_CONNECTION_MODE_SNIFF  2
34251fd61e9SMatthias Ringwald 
34347f4e325SMatthias Ringwald /**
34447f4e325SMatthias Ringwald  * Default INQ Mode
34547f4e325SMatthias Ringwald  */
3468aee7be2SMilanka Ringwald #define GAP_IAC_GENERAL_INQUIRY 0x9E8B33L // General/Unlimited Inquiry Access Code (GIAC)
3478aee7be2SMilanka Ringwald #define GAP_IAC_LIMITED_INQUIRY 0x9E8B00L // Limited Dedicated Inquiry Access Code (LIAC)
34847f4e325SMatthias Ringwald 
34947f4e325SMatthias Ringwald /**
35047f4e325SMatthias Ringwald  * SSP IO Capabilities
35147f4e325SMatthias Ringwald  */
35247f4e325SMatthias Ringwald #define SSP_IO_CAPABILITY_DISPLAY_ONLY   0
35347f4e325SMatthias Ringwald #define SSP_IO_CAPABILITY_DISPLAY_YES_NO 1
35447f4e325SMatthias Ringwald #define SSP_IO_CAPABILITY_KEYBOARD_ONLY  2
35547f4e325SMatthias Ringwald #define SSP_IO_CAPABILITY_NO_INPUT_NO_OUTPUT 3
35647f4e325SMatthias Ringwald #define SSP_IO_CAPABILITY_UNKNOWN 0xff
35747f4e325SMatthias Ringwald 
35847f4e325SMatthias Ringwald 
35947f4e325SMatthias Ringwald /**
36047f4e325SMatthias Ringwald  * SSP Authentication Requirements, see IO Capability Request Reply Commmand
36147f4e325SMatthias Ringwald  */
36247f4e325SMatthias Ringwald 
36347f4e325SMatthias Ringwald // Numeric comparison with automatic accept allowed.
36447f4e325SMatthias Ringwald #define SSP_IO_AUTHREQ_MITM_PROTECTION_NOT_REQUIRED_NO_BONDING 0x00
36547f4e325SMatthias Ringwald 
36647f4e325SMatthias Ringwald // Use IO Capabilities to deter- mine authentication procedure
36747f4e325SMatthias Ringwald #define SSP_IO_AUTHREQ_MITM_PROTECTION_REQUIRED_NO_BONDING 0x01
36847f4e325SMatthias Ringwald 
36947f4e325SMatthias Ringwald // Numeric compar- ison with automatic accept allowed.
37047f4e325SMatthias Ringwald #define SSP_IO_AUTHREQ_MITM_PROTECTION_NOT_REQUIRED_DEDICATED_BONDING 0x02
37147f4e325SMatthias Ringwald 
37247f4e325SMatthias Ringwald // Use IO Capabilities to determine authentication procedure
37347f4e325SMatthias Ringwald #define SSP_IO_AUTHREQ_MITM_PROTECTION_REQUIRED_DEDICATED_BONDING 0x03
37447f4e325SMatthias Ringwald 
37547f4e325SMatthias Ringwald // Numeric Compari- son with automatic accept allowed.
37647f4e325SMatthias Ringwald #define SSP_IO_AUTHREQ_MITM_PROTECTION_NOT_REQUIRED_GENERAL_BONDING 0x04
37747f4e325SMatthias Ringwald 
3788799c043SMatthias Ringwald // Use IO capabilities to determine authentication procedure.
37947f4e325SMatthias Ringwald #define SSP_IO_AUTHREQ_MITM_PROTECTION_REQUIRED_GENERAL_BONDING 0x05
38047f4e325SMatthias Ringwald 
38147f4e325SMatthias Ringwald 
3828799c043SMatthias Ringwald // OGFs
3838799c043SMatthias Ringwald #define OGF_LINK_CONTROL          0x01
3848799c043SMatthias Ringwald #define OGF_LINK_POLICY           0x02
3858799c043SMatthias Ringwald #define OGF_CONTROLLER_BASEBAND   0x03
3868799c043SMatthias Ringwald #define OGF_INFORMATIONAL_PARAMETERS 0x04
3878799c043SMatthias Ringwald #define OGF_STATUS_PARAMETERS     0x05
3888799c043SMatthias Ringwald #define OGF_TESTING               0x06
3898799c043SMatthias Ringwald #define OGF_LE_CONTROLLER 0x08
3908799c043SMatthias Ringwald #define OGF_VENDOR  0x3f
3918799c043SMatthias Ringwald 
3928799c043SMatthias Ringwald 
39347f4e325SMatthias Ringwald 
39447f4e325SMatthias Ringwald 
39547f4e325SMatthias Ringwald /**
39647f4e325SMatthias Ringwald  * L2CAP Layer
39747f4e325SMatthias Ringwald  */
39847f4e325SMatthias Ringwald 
399a8373a41SMatthias Ringwald #define L2CAP_HEADER_SIZE 4
400a8373a41SMatthias Ringwald 
401a8373a41SMatthias Ringwald // minimum signaling MTU
402a8373a41SMatthias Ringwald #define L2CAP_MINIMAL_MTU 48
403a8373a41SMatthias Ringwald #define L2CAP_DEFAULT_MTU 672
404a8373a41SMatthias Ringwald 
405a8373a41SMatthias Ringwald // Minimum/default MTU
406a8373a41SMatthias Ringwald #define L2CAP_LE_DEFAULT_MTU  23
407a8373a41SMatthias Ringwald 
408a8373a41SMatthias Ringwald // L2CAP Fixed Channel IDs
409a8373a41SMatthias Ringwald #define L2CAP_CID_SIGNALING                        0x0001
410a8373a41SMatthias Ringwald #define L2CAP_CID_CONNECTIONLESS_CHANNEL           0x0002
411a8373a41SMatthias Ringwald #define L2CAP_CID_ATTRIBUTE_PROTOCOL               0x0004
412a8373a41SMatthias Ringwald #define L2CAP_CID_SIGNALING_LE                     0x0005
413a8373a41SMatthias Ringwald #define L2CAP_CID_SECURITY_MANAGER_PROTOCOL        0x0006
414a8373a41SMatthias Ringwald 
41566b1fcb3SMatthias Ringwald /**
416235946f1SMatthias Ringwald  * SDP Protocol
417ef907034SMatthias Ringwald  */
418ef907034SMatthias Ringwald 
419c4b3290dSMatthias Ringwald // Device Vendor ID Sources
420c4b3290dSMatthias Ringwald #define DEVICE_ID_VENDOR_ID_SOURCE_BLUETOOTH 0x0001
421c4b3290dSMatthias Ringwald #define DEVICE_ID_VENDOR_ID_SOURCE_USB       0x0002
422c4b3290dSMatthias Ringwald 
423ef907034SMatthias Ringwald // OBEX
424ef907034SMatthias Ringwald #define SDP_vCard_2_1       0x01
425ef907034SMatthias Ringwald #define SDP_vCard_3_0       0x02
426ef907034SMatthias Ringwald #define SDP_vCal_1_0        0x03
427ef907034SMatthias Ringwald #define SDP_iCal_2_0        0x04
428ef907034SMatthias Ringwald #define SDP_vNote           0x05
429ef907034SMatthias Ringwald #define SDP_vMessage        0x06
430ef907034SMatthias Ringwald #define SDP_OBEXFileTypeAny 0xFF
431ef907034SMatthias Ringwald 
432ef907034SMatthias Ringwald /**
433e2577bd7SMatthias Ringwald  * RFCOMM Protocol
434e2577bd7SMatthias Ringwald  */
435e2577bd7SMatthias Ringwald 
436e2577bd7SMatthias Ringwald // Line Status
437e2577bd7SMatthias Ringwald #define LINE_STATUS_NO_ERROR       0x00
438e2577bd7SMatthias Ringwald #define LINE_STATUS_OVERRUN_ERROR  0x03
439e2577bd7SMatthias Ringwald #define LINE_STATUS_PARITY_ERORR   0x05
440e2577bd7SMatthias Ringwald #define LINE_STATUS_FRAMING_ERROR  0x09
441e2577bd7SMatthias Ringwald 
442e2577bd7SMatthias Ringwald // Modem Status Flags
443e2577bd7SMatthias Ringwald #define MODEM_STATUS_FC   0x02
444e2577bd7SMatthias Ringwald #define MODEM_STATUS_RTC  0x04
445e2577bd7SMatthias Ringwald #define MODEM_STATUS_RTR  0x08
446e2577bd7SMatthias Ringwald #define MODEM_STATUS_IC   0x40
447e2577bd7SMatthias Ringwald #define MODEM_STATUS_DV   0x80
448e2577bd7SMatthias Ringwald 
449e2577bd7SMatthias Ringwald typedef enum rpn_baud {
450e2577bd7SMatthias Ringwald     RPN_BAUD_2400 = 0,
451e2577bd7SMatthias Ringwald     RPN_BAUD_4800,
452e2577bd7SMatthias Ringwald     RPN_BAUD_7200,
453e2577bd7SMatthias Ringwald     RPN_BAUD_9600,
454e2577bd7SMatthias Ringwald     RPN_BAUD_19200,
455e2577bd7SMatthias Ringwald     RPN_BAUD_38400,
456e2577bd7SMatthias Ringwald     RPN_BAUD_57600,
457e2577bd7SMatthias Ringwald     RPN_BAUD_115200,
458e2577bd7SMatthias Ringwald     RPN_BAUD_230400
459e2577bd7SMatthias Ringwald } rpn_baud_t;
460e2577bd7SMatthias Ringwald 
461e2577bd7SMatthias Ringwald typedef enum rpn_data_bits {
462e2577bd7SMatthias Ringwald     RPN_DATA_BITS_5 = 0,
463e2577bd7SMatthias Ringwald     RPN_DATA_BITS_6 = 0,
464e2577bd7SMatthias Ringwald     RPN_DATA_BITS_7 = 0,
465e2577bd7SMatthias Ringwald     RPN_DATA_BITS_8 = 0
466e2577bd7SMatthias Ringwald } rpn_data_bits_t;
467e2577bd7SMatthias Ringwald 
468e2577bd7SMatthias Ringwald typedef enum rpn_stop_bits {
469e2577bd7SMatthias Ringwald     RPN_STOP_BITS_1_0 = 0,
470e2577bd7SMatthias Ringwald     RPN_STOP_BITS_1_5
471e2577bd7SMatthias Ringwald } rpn_stop_bits_t;
472e2577bd7SMatthias Ringwald 
473e2577bd7SMatthias Ringwald typedef enum rpn_parity {
474e2577bd7SMatthias Ringwald     RPN_PARITY_NONE  = 0,
475e2577bd7SMatthias Ringwald     RPN_PARITY_ODD   = 1,
476e2577bd7SMatthias Ringwald     RPN_PARITY_EVEN  = 3,
477e2577bd7SMatthias Ringwald     RPN_PARITY_MARK  = 5,
478e2577bd7SMatthias Ringwald     RPN_PARITY_SPACE = 7,
479e2577bd7SMatthias Ringwald } rpn_parity_t;
480e2577bd7SMatthias Ringwald 
481e2577bd7SMatthias Ringwald typedef enum rpn_flow_control {
482e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_XONXOFF_ON_INPUT  = 1 << 0,
483e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_XONXOFF_ON_OUTPUT = 1 << 1,
484e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_RTR_ON_INPUT  = 1 << 2,
485e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_RTR_ON_OUTPUT = 1 << 3,
486e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_RTC_ON_INPUT  = 1 << 4,
487e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_RTC_ON_OUTPUT = 1 << 5,
488e2577bd7SMatthias Ringwald } rpn_flow_control_t;
489e2577bd7SMatthias Ringwald 
490e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_BAUD             0x01
491e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_DATA_BITS        0x02
492e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_STOP_BITS        0x04
493e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_PARITY           0x08
494e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_PARITY_TYPE      0x10
495e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_XON_CHAR         0x20
496e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_XOFF_CHAR        0x40
497e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_RESERVED         0x80
498e2577bd7SMatthias Ringwald 
499e2577bd7SMatthias Ringwald // @note: values are identical to rpn_flow_control_t
500e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_XONOFF_ON_INPUT  0x01
501e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_XONOFF_ON_OUTPUT 0x02
502e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RTR_ON_INPUT     0x04
503e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RTR_ON_OUTPUT    0x08
504e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RTC_ON_INPUT     0x10
505e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RTC_ON_OUTPUT    0x20
506e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RESERVED_0       0x40
507e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RESERVED_1       0x80
508e2577bd7SMatthias Ringwald 
509e2577bd7SMatthias Ringwald /**
51066b1fcb3SMatthias Ringwald  * BNEP Protocol
51166b1fcb3SMatthias Ringwald  */
51247f4e325SMatthias Ringwald 
51366b1fcb3SMatthias Ringwald #ifndef ETHER_ADDR_LEN
5149a73f75dSMatthias Ringwald #define ETHER_ADDR_LEN 6
51566b1fcb3SMatthias Ringwald #endif
51647f4e325SMatthias Ringwald 
51766b1fcb3SMatthias Ringwald #ifndef ETHERTYPE_VLAN
51866b1fcb3SMatthias Ringwald #define ETHERTYPE_VLAN                                  0x8100 /* IEEE 802.1Q VLAN tag */
51966b1fcb3SMatthias Ringwald #endif
52066b1fcb3SMatthias Ringwald 
52166b1fcb3SMatthias Ringwald #define BNEP_MTU_MIN                                    1691
52266b1fcb3SMatthias Ringwald 
52366b1fcb3SMatthias Ringwald 
52466b1fcb3SMatthias Ringwald /**
52566b1fcb3SMatthias Ringwald  * PAN Profile
52666b1fcb3SMatthias Ringwald  */
52766b1fcb3SMatthias Ringwald 
52866b1fcb3SMatthias Ringwald typedef enum {
52966b1fcb3SMatthias Ringwald     BNEP_SECURITY_NONE = 0x0000,
53066b1fcb3SMatthias Ringwald     BNEP_SECURITY_SERVICE_LEVEL_ENFORCED,
53166b1fcb3SMatthias Ringwald     BNEP_SECURITY_802_1X
53266b1fcb3SMatthias Ringwald } security_description_t;
53366b1fcb3SMatthias Ringwald 
53466b1fcb3SMatthias Ringwald typedef enum {
53566b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_PSTN = 0x0000,
53666b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_ISDN,
53766b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_DSL,
53866b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_CABLE_MODEM,
53966b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_10MB_ETHERNET,
54066b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_100MB_ETHERNET,
54166b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_4MB_TOKEN_RING,
54266b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_16MB_TOKEN_RING,
54366b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_100MB_TOKEN_RING,
54466b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_FDDI,
54566b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_GSM,
54666b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_CDMA,
54766b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_GPRS,
54866b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_3G,
54966b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_CELULAR,
55066b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_OTHER = 0xFFFE,
55166b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_NONE
55266b1fcb3SMatthias Ringwald } net_access_type_t;
55347f4e325SMatthias Ringwald 
5544c1900e6SMatthias Ringwald /**
5554c1900e6SMatthias Ringwald  * ATT
5564c1900e6SMatthias Ringwald  */
5574c1900e6SMatthias Ringwald 
5584c1900e6SMatthias Ringwald // Minimum/default MTU
5594c1900e6SMatthias Ringwald #define ATT_DEFAULT_MTU               23
5604c1900e6SMatthias Ringwald 
5614c1900e6SMatthias Ringwald // MARK: ATT Error Codes
5629cb80b17SMilanka Ringwald #define ATT_ERROR_SUCCESS                          0x00
5634c1900e6SMatthias Ringwald #define ATT_ERROR_INVALID_HANDLE                   0x01
5644c1900e6SMatthias Ringwald #define ATT_ERROR_READ_NOT_PERMITTED               0x02
5654c1900e6SMatthias Ringwald #define ATT_ERROR_WRITE_NOT_PERMITTED              0x03
5664c1900e6SMatthias Ringwald #define ATT_ERROR_INVALID_PDU                      0x04
5674c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_AUTHENTICATION      0x05
5684c1900e6SMatthias Ringwald #define ATT_ERROR_REQUEST_NOT_SUPPORTED            0x06
5694c1900e6SMatthias Ringwald #define ATT_ERROR_INVALID_OFFSET                   0x07
5704c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_AUTHORIZATION       0x08
5714c1900e6SMatthias Ringwald #define ATT_ERROR_PREPARE_QUEUE_FULL               0x09
5724c1900e6SMatthias Ringwald #define ATT_ERROR_ATTRIBUTE_NOT_FOUND              0x0a
5734c1900e6SMatthias Ringwald #define ATT_ERROR_ATTRIBUTE_NOT_LONG               0x0b
5744c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_ENCRYPTION_KEY_SIZE 0x0c
5754c1900e6SMatthias Ringwald #define ATT_ERROR_INVALID_ATTRIBUTE_VALUE_LENGTH   0x0d
5764c1900e6SMatthias Ringwald #define ATT_ERROR_UNLIKELY_ERROR                   0x0e
5774c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_ENCRYPTION          0x0f
5784c1900e6SMatthias Ringwald #define ATT_ERROR_UNSUPPORTED_GROUP_TYPE           0x10
5794c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_RESOURCES           0x11
580204991f3SMilanka Ringwald 
581*09f91c9fSMatthias Ringwald // MARK: ATT Error Codes used internally by BTstack
5822865193aSMilanka Ringwald #define ATT_ERROR_HCI_DISCONNECT_RECEIVED          0x1f
583*09f91c9fSMatthias Ringwald #define ATT_ERROR_BONDING_INFORMATION_MISSING      0x70
5842865193aSMilanka Ringwald #define ATT_ERROR_DATA_MISMATCH                    0x7e
5852865193aSMilanka Ringwald #define ATT_ERROR_TIMEOUT                          0x7F
5862865193aSMilanka Ringwald #define ATT_ERROR_WRITE_RESPONSE_PENDING           0x100
5872865193aSMilanka Ringwald 
588204991f3SMilanka Ringwald // MARK: ATT Error Codes from Cycling Power Service spec
589204991f3SMilanka Ringwald #define CYCLING_POWER_ERROR_CODE_INAPPROPRIATE_CONNECTION_PARAMETERS                          0x80
590204991f3SMilanka Ringwald #define CYCLING_POWER_ERROR_CODE_PROCEDURE_ALREADY_IN_PROGRESS                                0xFE
591204991f3SMilanka Ringwald #define CYCLING_POWER_ERROR_CODE_CCC_DESCRIPTOR_IMPROPERLY_CONFIGURED                         0xFD
592204991f3SMilanka Ringwald 
593204991f3SMilanka Ringwald // MARK: ATT Error Codes from Cycling Speed and Cadence Service spec
594204991f3SMilanka Ringwald #define CYCLING_SPEED_AND_CADENCE_ERROR_CODE_PROCEDURE_ALREADY_IN_PROGRESS                    0x80
595204991f3SMilanka Ringwald #define CYCLING_SPEED_AND_CADENCE_ERROR_CODE_CCC_DESCRIPTOR_IMPROPERLY_CONFIGURED             0x81
596204991f3SMilanka Ringwald 
5974c1900e6SMatthias Ringwald 
5984c1900e6SMatthias Ringwald // MARK: Attribute Property Flags
5994c1900e6SMatthias Ringwald #define ATT_PROPERTY_BROADCAST           0x01
6004c1900e6SMatthias Ringwald #define ATT_PROPERTY_READ                0x02
6014c1900e6SMatthias Ringwald #define ATT_PROPERTY_WRITE_WITHOUT_RESPONSE 0x04
6024c1900e6SMatthias Ringwald #define ATT_PROPERTY_WRITE               0x08
6034c1900e6SMatthias Ringwald #define ATT_PROPERTY_NOTIFY              0x10
6044c1900e6SMatthias Ringwald #define ATT_PROPERTY_INDICATE            0x20
6054c1900e6SMatthias Ringwald #define ATT_PROPERTY_AUTHENTICATED_SIGNED_WRITE 0x40
6064c1900e6SMatthias Ringwald #define ATT_PROPERTY_EXTENDED_PROPERTIES 0x80
6074c1900e6SMatthias Ringwald 
6084c1900e6SMatthias Ringwald // MARK: Attribute Property Flag, BTstack extension
6094c1900e6SMatthias Ringwald // value is asked from client
6104c1900e6SMatthias Ringwald #define ATT_PROPERTY_DYNAMIC             0x100
611ff04bac7SMatthias Ringwald 
612ff04bac7SMatthias Ringwald // Security levels
613ff04bac7SMatthias Ringwald #define ATT_SECURITY_NONE 0
614ff04bac7SMatthias Ringwald #define ATT_SECURITY_ENCRYPTED 1
615ff04bac7SMatthias Ringwald #define ATT_SECURITY_AUTHENTICATED 2
616ff04bac7SMatthias Ringwald #define ATT_SECURITY_AUTHORIZED 3
617bb96f9f8SMatthias Ringwald #define ATT_SECURITY_AUTHENTICATED_SC 4
618ff04bac7SMatthias Ringwald 
6199b31df63SMatthias Ringwald // ATT Transaction Timeout of 30 seconds for Command/Response or Indication/Confirmation
6204c1900e6SMatthias Ringwald #define ATT_TRANSACTION_TIMEOUT_MS     30000
6214c1900e6SMatthias Ringwald 
6224c1900e6SMatthias Ringwald #define ATT_TRANSACTION_MODE_NONE      0x0
6234c1900e6SMatthias Ringwald #define ATT_TRANSACTION_MODE_ACTIVE    0x1
6244c1900e6SMatthias Ringwald #define ATT_TRANSACTION_MODE_EXECUTE   0x2
6254c1900e6SMatthias Ringwald #define ATT_TRANSACTION_MODE_CANCEL    0x3
6269b31df63SMatthias Ringwald #define ATT_TRANSACTION_MODE_VALIDATE  0x4
6274c1900e6SMatthias Ringwald 
6284c1900e6SMatthias Ringwald // MARK: GATT UUIDs
6294c1900e6SMatthias Ringwald #define GATT_PRIMARY_SERVICE_UUID                   0x2800
6304c1900e6SMatthias Ringwald #define GATT_SECONDARY_SERVICE_UUID                 0x2801
6314c1900e6SMatthias Ringwald #define GATT_INCLUDE_SERVICE_UUID                   0x2802
6324c1900e6SMatthias Ringwald #define GATT_CHARACTERISTICS_UUID                   0x2803
6334c1900e6SMatthias Ringwald #define GATT_CHARACTERISTIC_EXTENDED_PROPERTIES     0x2900
6344c1900e6SMatthias Ringwald #define GATT_CHARACTERISTIC_USER_DESCRIPTION        0x2901
6354c1900e6SMatthias Ringwald #define GATT_CLIENT_CHARACTERISTICS_CONFIGURATION   0x2902
6364c1900e6SMatthias Ringwald #define GATT_SERVER_CHARACTERISTICS_CONFIGURATION   0x2903
6374c1900e6SMatthias Ringwald #define GATT_CHARACTERISTIC_PRESENTATION_FORMAT     0x2904
6384c1900e6SMatthias Ringwald #define GATT_CHARACTERISTIC_AGGREGATE_FORMAT        0x2905
6394c1900e6SMatthias Ringwald 
6404c1900e6SMatthias Ringwald #define GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NONE          0
6414c1900e6SMatthias Ringwald #define GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NOTIFICATION  1
6424c1900e6SMatthias Ringwald #define GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_INDICATION    2
6434c1900e6SMatthias Ringwald 
6444c1900e6SMatthias Ringwald // GAP Service and Characteristics
6454c1900e6SMatthias Ringwald #define GAP_SERVICE_UUID               0x1800
6464c1900e6SMatthias Ringwald #define GAP_DEVICE_NAME_UUID           0x2a00
6474c1900e6SMatthias Ringwald #define GAP_APPEARANCE_UUID            0x2a01
6484c1900e6SMatthias Ringwald #define GAP_PERIPHERAL_PRIVACY_FLAG    0x2a02
6494c1900e6SMatthias Ringwald #define GAP_RECONNECTION_ADDRESS_UUID  0x2a03
6504c1900e6SMatthias Ringwald #define GAP_PERIPHERAL_PREFERRED_CONNECTION_PARAMETERS_UUID 0x2a04
65117fe8172SMatthias Ringwald #define GAP_SERVICE_CHANGED            0x2a05
6524c1900e6SMatthias Ringwald 
653bb7f3677SMilanka Ringwald // Bluetooth GATT types
654bb7f3677SMilanka Ringwald 
655bb7f3677SMilanka Ringwald typedef struct {
656bb7f3677SMilanka Ringwald     uint16_t year;      // 0 - year  is not known; or [1582,9999]
657bb7f3677SMilanka Ringwald     uint8_t  month;     // 0 - month is not known; or [1,12]
658bb7f3677SMilanka Ringwald     uint8_t  day;       // 0 - day   is not known; or [1,31]
659bb7f3677SMilanka Ringwald     uint8_t  hours;     // [0,23]
660bb7f3677SMilanka Ringwald     uint8_t  minutes;   // [0,59]
661bb7f3677SMilanka Ringwald     uint8_t  seconds;   // [0,59]
662bb7f3677SMilanka Ringwald } gatt_date_time_t;
663bb7f3677SMilanka Ringwald 
6644c1900e6SMatthias Ringwald /**
6654c1900e6SMatthias Ringwald  * SM - LE Security Manager
6664c1900e6SMatthias Ringwald  */
6674c1900e6SMatthias Ringwald // Bluetooth Spec definitions
6684c1900e6SMatthias Ringwald typedef enum {
6694c1900e6SMatthias Ringwald     SM_CODE_PAIRING_REQUEST = 0X01,
6704c1900e6SMatthias Ringwald     SM_CODE_PAIRING_RESPONSE,
6714c1900e6SMatthias Ringwald     SM_CODE_PAIRING_CONFIRM,
6724c1900e6SMatthias Ringwald     SM_CODE_PAIRING_RANDOM,
6734c1900e6SMatthias Ringwald     SM_CODE_PAIRING_FAILED,
6744c1900e6SMatthias Ringwald     SM_CODE_ENCRYPTION_INFORMATION,
6754c1900e6SMatthias Ringwald     SM_CODE_MASTER_IDENTIFICATION,
6764c1900e6SMatthias Ringwald     SM_CODE_IDENTITY_INFORMATION,
6774c1900e6SMatthias Ringwald     SM_CODE_IDENTITY_ADDRESS_INFORMATION,
6784c1900e6SMatthias Ringwald     SM_CODE_SIGNING_INFORMATION,
67974a9b3d5SMatthias Ringwald     SM_CODE_SECURITY_REQUEST,
68074a9b3d5SMatthias Ringwald     SM_CODE_PAIRING_PUBLIC_KEY,
68174a9b3d5SMatthias Ringwald     SM_CODE_PAIRING_DHKEY_CHECK,
68244e8d9acSMatthias Ringwald     SM_CODE_KEYPRESS_NOTIFICATION,
6834c1900e6SMatthias Ringwald } SECURITY_MANAGER_COMMANDS;
6844c1900e6SMatthias Ringwald 
6854c1900e6SMatthias Ringwald // IO Capability Values
6864c1900e6SMatthias Ringwald typedef enum {
6874c1900e6SMatthias Ringwald     IO_CAPABILITY_DISPLAY_ONLY = 0,
6884c1900e6SMatthias Ringwald     IO_CAPABILITY_DISPLAY_YES_NO,
6894c1900e6SMatthias Ringwald     IO_CAPABILITY_KEYBOARD_ONLY,
6904c1900e6SMatthias Ringwald     IO_CAPABILITY_NO_INPUT_NO_OUTPUT,
6914c1900e6SMatthias Ringwald     IO_CAPABILITY_KEYBOARD_DISPLAY, // not used by secure simple pairing
6924c1900e6SMatthias Ringwald } io_capability_t;
6934c1900e6SMatthias Ringwald 
6944c1900e6SMatthias Ringwald // Authentication requirement flags
6954c1900e6SMatthias Ringwald #define SM_AUTHREQ_NO_BONDING        0x00
6964c1900e6SMatthias Ringwald #define SM_AUTHREQ_BONDING           0x01
6974c1900e6SMatthias Ringwald #define SM_AUTHREQ_MITM_PROTECTION   0x04
69874a9b3d5SMatthias Ringwald #define SM_AUTHREQ_SECURE_CONNECTION 0x08
69974a9b3d5SMatthias Ringwald #define SM_AUTHREQ_KEYPRESS          0x10
7004c1900e6SMatthias Ringwald 
7014c1900e6SMatthias Ringwald // Key distribution flags used by spec
70252f9cf63SMatthias Ringwald #define SM_KEYDIST_ENC_KEY  0x01
7034c1900e6SMatthias Ringwald #define SM_KEYDIST_ID_KEY   0x02
7044c1900e6SMatthias Ringwald #define SM_KEYDIST_SIGN     0x04
70552f9cf63SMatthias Ringwald #define SM_KEYDIST_LINK_KEY 0x08
7064c1900e6SMatthias Ringwald 
7074c1900e6SMatthias Ringwald // Key distribution flags used internally
7084c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_ENCRYPTION_INFORMATION       0x01
7094c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_MASTER_IDENTIFICATION        0x02
7104c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_IDENTITY_INFORMATION         0x04
7114c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_IDENTITY_ADDRESS_INFORMATION 0x08
7124c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_SIGNING_IDENTIFICATION       0x10
7134c1900e6SMatthias Ringwald 
7144c1900e6SMatthias Ringwald // STK Generation Methods
7154c1900e6SMatthias Ringwald #define SM_STK_GENERATION_METHOD_JUST_WORKS          0x01
7164c1900e6SMatthias Ringwald #define SM_STK_GENERATION_METHOD_OOB                 0x02
7174c1900e6SMatthias Ringwald #define SM_STK_GENERATION_METHOD_PASSKEY             0x04
718b4343428SMatthias Ringwald #define SM_STK_GENERATION_METHOD_NUMERIC_COMPARISON  0x08
7194c1900e6SMatthias Ringwald 
7204c1900e6SMatthias Ringwald // Pairing Failed Reasons
7214c1900e6SMatthias Ringwald #define SM_REASON_RESERVED                     0x00
72216a1a3e5SMatthias Ringwald #define SM_REASON_PASSKEY_ENTRY_FAILED         0x01
7234c1900e6SMatthias Ringwald #define SM_REASON_OOB_NOT_AVAILABLE            0x02
7244c1900e6SMatthias Ringwald #define SM_REASON_AUTHENTHICATION_REQUIREMENTS 0x03
7254c1900e6SMatthias Ringwald #define SM_REASON_CONFIRM_VALUE_FAILED         0x04
7264c1900e6SMatthias Ringwald #define SM_REASON_PAIRING_NOT_SUPPORTED        0x05
7274c1900e6SMatthias Ringwald #define SM_REASON_ENCRYPTION_KEY_SIZE          0x06
7284c1900e6SMatthias Ringwald #define SM_REASON_COMMAND_NOT_SUPPORTED        0x07
7294c1900e6SMatthias Ringwald #define SM_REASON_UNSPECIFIED_REASON           0x08
7304c1900e6SMatthias Ringwald #define SM_REASON_REPEATED_ATTEMPTS            0x09
731a9f29768SMatthias Ringwald #define SM_REASON_INVALID_PARAMETERS           0x0a
732a9f29768SMatthias Ringwald #define SM_REASON_DHKEY_CHECK_FAILED           0x0b
733a9f29768SMatthias Ringwald #define SM_REASON_NUMERIC_COMPARISON_FAILED    0x0c
734a9f29768SMatthias Ringwald 
7354c1900e6SMatthias Ringwald // also, invalid parameters
7364c1900e6SMatthias Ringwald // and reserved
7374c1900e6SMatthias Ringwald 
73844e8d9acSMatthias Ringwald // Keypress Notifications
73944e8d9acSMatthias Ringwald #define SM_KEYPRESS_PASSKEY_ENTRY_STARTED      0x00
74044e8d9acSMatthias Ringwald #define SM_KEYPRESS_PASSKEY_DIGIT_ENTERED      0x01
74144e8d9acSMatthias Ringwald #define SM_KEYPRESS_PASSKEY_DIGIT_ERASED       0x02
74244e8d9acSMatthias Ringwald #define SM_KEYPRESS_PASSKEY_CLEARED            0x03
74344e8d9acSMatthias Ringwald #define SM_KEYPRESS_PASSKEY_ENTRY_COMPLETED    0x04
74444e8d9acSMatthias Ringwald 
74544e8d9acSMatthias Ringwald 
74647f4e325SMatthias Ringwald #endif
747