xref: /btstack/src/bluetooth.h (revision 96c69d4a400f2c269ed656bacfee69a6d7e3e632)
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 
11285ddcd84SMatthias Ringwald /*
11385ddcd84SMatthias Ringwald  * @brief L2CAP Segmentation And Reassembly packet type in I-Frames
11485ddcd84SMatthias Ringwald  */
11585ddcd84SMatthias Ringwald typedef enum {
11685ddcd84SMatthias Ringwald     L2CAP_SEGMENTATION_AND_REASSEMBLY_UNSEGMENTED_L2CAP_SDU = 0,
11785ddcd84SMatthias Ringwald     L2CAP_SEGMENTATION_AND_REASSEMBLY_START_OF_L2CAP_SDU,
11885ddcd84SMatthias Ringwald     L2CAP_SEGMENTATION_AND_REASSEMBLY_END_OF_L2CAP_SDU,
11985ddcd84SMatthias Ringwald     L2CAP_SEGMENTATION_AND_REASSEMBLY_CONTINUATION_OF_L2CAP_SDU
12085ddcd84SMatthias Ringwald } l2cap_segmentation_and_reassembly_t;
12185ddcd84SMatthias Ringwald 
12285ddcd84SMatthias Ringwald /*
12385ddcd84SMatthias Ringwald  * @brief L2CAP Supervisory function in S-Frames
12485ddcd84SMatthias Ringwald  */
12585ddcd84SMatthias Ringwald typedef enum {
12685ddcd84SMatthias Ringwald     L2CAP_SUPERVISORY_FUNCTION_RR_RECEIVER_READY = 0,
12785ddcd84SMatthias Ringwald     L2CAP_SUPERVISORY_FUNCTION_REJ_REJECT,
12885ddcd84SMatthias Ringwald     L2CAP_SUPERVISORY_FUNCTION_RNR_RECEIVER_NOT_READY,
12985ddcd84SMatthias Ringwald     L2CAP_SUPERVISORY_FUNCTION_SREJ_SELECTIVE_REJECT
13085ddcd84SMatthias Ringwald } l2cap_supervisory_function_t;
13185ddcd84SMatthias Ringwald 
132f6858d14SMatthias Ringwald /**
133671fb338SMatthias Ringwald  * @brief L2CAP Information Types used in Information Request & Response
134671fb338SMatthias Ringwald  */
135671fb338SMatthias Ringwald typedef enum {
136671fb338SMatthias Ringwald   L2CAP_INFO_TYPE_CONNECTIONLESS_MTU = 1,
137671fb338SMatthias Ringwald   L2CAP_INFO_TYPE_EXTENDED_FEATURES_SUPPORTED,
138671fb338SMatthias Ringwald   L2CAP_INFO_TYPE_FIXED_CHANNELS_SUPPORTED,
139671fb338SMatthias Ringwald } l2cap_info_type_t;
140671fb338SMatthias Ringwald 
141671fb338SMatthias Ringwald /**
142671fb338SMatthias Ringwald  * @brief L2CAP Configuration Option Types used in Configurateion Request & Response
143671fb338SMatthias Ringwald  */
144671fb338SMatthias Ringwald typedef enum {
145671fb338SMatthias Ringwald   L2CAP_CONFIG_OPTION_TYPE_MAX_TRANSMISSION_UNIT = 1,
146671fb338SMatthias Ringwald   L2CAP_CONFIG_OPTION_TYPE_FLUSH_TIMEOUT,
147671fb338SMatthias Ringwald   L2CAP_CONFIG_OPTION_TYPE_QUALITY_OF_SERVICE,
148671fb338SMatthias Ringwald   L2CAP_CONFIG_OPTION_TYPE_RETRANSMISSION_AND_FLOW_CONTROL,
149671fb338SMatthias Ringwald   L2CAP_CONFIG_OPTION_TYPE_FRAME_CHECK_SEQUENCE,
150671fb338SMatthias Ringwald   L2CAP_CONFIG_OPTION_TYPE_EXTENDED_FLOW_SPECIFICATION,
151671fb338SMatthias Ringwald   L2CAP_CONFIG_OPTION_TYPE_EXTENDED_WINDOW_SIZE,
152671fb338SMatthias Ringwald } l2cap_config_option_type_t;
153671fb338SMatthias Ringwald 
154671fb338SMatthias Ringwald /**
15547f4e325SMatthias Ringwald  * HCI Transport
15647f4e325SMatthias Ringwald  */
15747f4e325SMatthias Ringwald 
15847f4e325SMatthias Ringwald /**
15947f4e325SMatthias Ringwald  * packet types - used in BTstack and over the H4 UART interface
16047f4e325SMatthias Ringwald  */
16147f4e325SMatthias Ringwald #define HCI_COMMAND_DATA_PACKET 0x01
16247f4e325SMatthias Ringwald #define HCI_ACL_DATA_PACKET     0x02
16347f4e325SMatthias Ringwald #define HCI_SCO_DATA_PACKET     0x03
16447f4e325SMatthias Ringwald #define HCI_EVENT_PACKET        0x04
16547f4e325SMatthias Ringwald 
1668799c043SMatthias Ringwald // packet header sizes
1678799c043SMatthias Ringwald #define HCI_CMD_HEADER_SIZE          3
1688799c043SMatthias Ringwald #define HCI_ACL_HEADER_SIZE          4
1698799c043SMatthias Ringwald #define HCI_SCO_HEADER_SIZE          3
1708799c043SMatthias Ringwald #define HCI_EVENT_HEADER_SIZE        2
1718799c043SMatthias Ringwald 
17247f4e325SMatthias Ringwald /**
17347f4e325SMatthias Ringwald  * HCI Layer
17447f4e325SMatthias Ringwald  */
17547f4e325SMatthias Ringwald 
17647f4e325SMatthias Ringwald //
177f193890fSMatthias Ringwald // Error Codes rfom Bluetooth Core Specification
17847f4e325SMatthias Ringwald //
17947f4e325SMatthias Ringwald 
180f193890fSMatthias Ringwald /* ENUM_START: BLUETOOTH_ERROR_CODE */
181616edd56SMatthias Ringwald #define ERROR_CODE_SUCCESS                                 0x00
18247f4e325SMatthias Ringwald #define ERROR_CODE_UNKNOWN_HCI_COMMAND                     0x01
18347f4e325SMatthias Ringwald #define ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER           0x02
18447f4e325SMatthias Ringwald #define ERROR_CODE_HARDWARE_FAILURE                        0x03
18547f4e325SMatthias Ringwald #define ERROR_CODE_PAGE_TIMEOUT                            0x04
18647f4e325SMatthias Ringwald #define ERROR_CODE_AUTHENTICATION_FAILURE                  0x05
18747f4e325SMatthias Ringwald #define ERROR_CODE_PIN_OR_KEY_MISSING                      0x06
18847f4e325SMatthias Ringwald #define ERROR_CODE_MEMORY_CAPACITY_EXCEEDED                0x07
18947f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_TIMEOUT                      0x08
19047f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_LIMIT_EXCEEDED               0x09
19147f4e325SMatthias Ringwald #define ERROR_CODE_SYNCHRONOUS_CONNECTION_LIMIT_TO_A_DEVICE_EXCEEDED  0x0A
19247f4e325SMatthias Ringwald #define ERROR_CODE_ACL_CONNECTION_ALREADY_EXISTS           0x0B
19347f4e325SMatthias Ringwald #define ERROR_CODE_COMMAND_DISALLOWED                      0x0C
19447f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_REJECTED_DUE_TO_LIMITED_RESOURCES 0x0D
19547f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_REJECTED_DUE_TO_SECURITY_REASONS  0x0E
19647f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_REJECTED_DUE_TO_UNACCEPTABLE_BD_ADDR 0x0F
19747f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_ACCEPT_TIMEOUT_EXCEEDED      0x10
19847f4e325SMatthias Ringwald #define ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE  0x11
19947f4e325SMatthias Ringwald #define ERROR_CODE_INVALID_HCI_COMMAND_PARAMETERS          0x12
20047f4e325SMatthias Ringwald #define ERROR_CODE_REMOTE_USER_TERMINATED_CONNECTION       0x13
20147f4e325SMatthias Ringwald #define ERROR_CODE_REMOTE_DEVICE_TERMINATED_CONNECTION_DUE_TO_LOW_RESOURCES 0x14
20247f4e325SMatthias Ringwald #define ERROR_CODE_REMOTE_DEVICE_TERMINATED_CONNECTION_DUE_TO_POWER_OFF     0x15
20347f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_TERMINATED_BY_LOCAL_HOST     0x16
20447f4e325SMatthias Ringwald #define ERROR_CODE_REPEATED_ATTEMPTS                       0x17
20547f4e325SMatthias Ringwald #define ERROR_CODE_PAIRING_NOT_ALLOWED                     0x18
20647f4e325SMatthias Ringwald #define ERROR_CODE_UNKNOWN_LMP_PDU                         0x19
20747f4e325SMatthias Ringwald #define ERROR_CODE_UNSUPPORTED_REMOTE_FEATURE_UNSUPPORTED_LMP_FEATURE 0x1A
20847f4e325SMatthias Ringwald #define ERROR_CODE_SCO_OFFSET_REJECTED                     0x1B
20947f4e325SMatthias Ringwald #define ERROR_CODE_SCO_INTERVAL_REJECTED                   0x1C
21047f4e325SMatthias Ringwald #define ERROR_CODE_SCO_AIR_MODE_REJECTED                   0x1D
21147f4e325SMatthias Ringwald #define ERROR_CODE_INVALID_LMP_PARAMETERS_INVALID_LL_PARAMETERS 0x1E
21247f4e325SMatthias Ringwald #define ERROR_CODE_UNSPECIFIED_ERROR                       0x1F
21347f4e325SMatthias Ringwald #define ERROR_CODE_UNSUPPORTED_LMP_PARAMETER_VALUE_UNSUPPORTED_LL_PARAMETER_VALUE 0x20
21447f4e325SMatthias Ringwald #define ERROR_CODE_ROLE_CHANGE_NOT_ALLOWED                 0x21
21547f4e325SMatthias Ringwald #define ERROR_CODE_LMP_RESPONSE_TIMEOUT_LL_RESPONSE_TIMEOUT 0x22
21647f4e325SMatthias Ringwald #define ERROR_CODE_LMP_ERROR_TRANSACTION_COLLISION         0x23
21747f4e325SMatthias Ringwald #define ERROR_CODE_LMP_PDU_NOT_ALLOWED                     0x24
21847f4e325SMatthias Ringwald #define ERROR_CODE_ENCRYPTION_MODE_NOT_ACCEPTABLE          0x25
21947f4e325SMatthias Ringwald #define ERROR_CODE_LINK_KEY_CANNOT_BE_CHANGED              0x26
22047f4e325SMatthias Ringwald #define ERROR_CODE_REQUESTED_QOS_NOT_SUPPORTED             0x27
22147f4e325SMatthias Ringwald #define ERROR_CODE_INSTANT_PASSED                          0x28
22247f4e325SMatthias Ringwald #define ERROR_CODE_PAIRING_WITH_UNIT_KEY_NOT_SUPPORTED     0x29
22347f4e325SMatthias Ringwald #define ERROR_CODE_DIFFERENT_TRANSACTION_COLLISION         0x2A
22447f4e325SMatthias Ringwald #define ERROR_CODE_RESERVED                                0x2B
22547f4e325SMatthias Ringwald #define ERROR_CODE_QOS_UNACCEPTABLE_PARAMETER              0x2C
22647f4e325SMatthias Ringwald #define ERROR_CODE_QOS_REJECTED                            0x2D
22747f4e325SMatthias Ringwald #define ERROR_CODE_CHANNEL_CLASSIFICATION_NOT_SUPPORTED    0x2E
22847f4e325SMatthias Ringwald #define ERROR_CODE_INSUFFICIENT_SECURITY                   0x2F
22947f4e325SMatthias Ringwald #define ERROR_CODE_PARAMETER_OUT_OF_MANDATORY_RANGE        0x30
23047f4e325SMatthias Ringwald // #define ERROR_CODE_RESERVED
23147f4e325SMatthias Ringwald #define ERROR_CODE_ROLE_SWITCH_PENDING                     0x32
23247f4e325SMatthias Ringwald // #define ERROR_CODE_RESERVED
23347f4e325SMatthias Ringwald #define ERROR_CODE_RESERVED_SLOT_VIOLATION                 0x34
23447f4e325SMatthias Ringwald #define ERROR_CODE_ROLE_SWITCH_FAILED                      0x35
23547f4e325SMatthias Ringwald #define ERROR_CODE_EXTENDED_INQUIRY_RESPONSE_TOO_LARGE     0x36
23647f4e325SMatthias Ringwald #define ERROR_CODE_SECURE_SIMPLE_PAIRING_NOT_SUPPORTED_BY_HOST 0x37
23747f4e325SMatthias Ringwald #define ERROR_CODE_HOST_BUSY_PAIRING                       0x38
23847f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_REJECTED_DUE_TO_NO_SUITABLE_CHANNEL_FOUND 0x39
23947f4e325SMatthias Ringwald #define ERROR_CODE_CONTROLLER_BUSY                         0x3A
24047f4e325SMatthias Ringwald #define ERROR_CODE_UNACCEPTABLE_CONNECTION_PARAMETERS      0x3B
24147f4e325SMatthias Ringwald #define ERROR_CODE_DIRECTED_ADVERTISING_TIMEOUT            0x3C
24247f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_TERMINATED_DUE_TO_MIC_FAILURE 0x3D
24347f4e325SMatthias Ringwald #define ERROR_CODE_CONNECTION_FAILED_TO_BE_ESTABLISHED     0x3E
24447f4e325SMatthias Ringwald #define ERROR_CODE_MAC_CONNECTION_FAILED                   0x3F
24547f4e325SMatthias Ringwald #define ERROR_CODE_COARSE_CLOCK_ADJUSTMENT_REJECTED_BUT_WILL_TRY_TO_ADJUST_USING_CLOCK_DRAGGING 0x40
246*96c69d4aSMilanka Ringwald 
247*96c69d4aSMilanka Ringwald // BTstack defined ERRORS, mapped into BLuetooth status code range
248*96c69d4aSMilanka Ringwald 
249*96c69d4aSMilanka Ringwald #define BTSTACK_CONNECTION_TO_BTDAEMON_FAILED              0x50
250*96c69d4aSMilanka Ringwald #define BTSTACK_ACTIVATION_FAILED_SYSTEM_BLUETOOTH         0x51
251*96c69d4aSMilanka Ringwald #define BTSTACK_ACTIVATION_POWERON_FAILED                  0x52
252*96c69d4aSMilanka Ringwald #define BTSTACK_ACTIVATION_FAILED_UNKNOWN                  0x53
253*96c69d4aSMilanka Ringwald #define BTSTACK_NOT_ACTIVATED                              0x54
254*96c69d4aSMilanka Ringwald #define BTSTACK_BUSY                                       0x55
255*96c69d4aSMilanka Ringwald #define BTSTACK_MEMORY_ALLOC_FAILED                        0x56
256*96c69d4aSMilanka Ringwald #define BTSTACK_ACL_BUFFERS_FULL                           0x57
257*96c69d4aSMilanka Ringwald 
258*96c69d4aSMilanka Ringwald // l2cap errors - enumeration by the command that created them
259*96c69d4aSMilanka Ringwald #define L2CAP_COMMAND_REJECT_REASON_COMMAND_NOT_UNDERSTOOD 0x60
260*96c69d4aSMilanka Ringwald #define L2CAP_COMMAND_REJECT_REASON_SIGNALING_MTU_EXCEEDED 0x61
261*96c69d4aSMilanka Ringwald #define L2CAP_COMMAND_REJECT_REASON_INVALID_CID_IN_REQUEST 0x62
262*96c69d4aSMilanka Ringwald 
263*96c69d4aSMilanka Ringwald #define L2CAP_CONNECTION_RESPONSE_RESULT_SUCCESSFUL        0x63
264*96c69d4aSMilanka Ringwald #define L2CAP_CONNECTION_RESPONSE_RESULT_PENDING           0x64
265*96c69d4aSMilanka Ringwald #define L2CAP_CONNECTION_RESPONSE_RESULT_REFUSED_PSM       0x65
266*96c69d4aSMilanka Ringwald #define L2CAP_CONNECTION_RESPONSE_RESULT_REFUSED_SECURITY  0x66
267*96c69d4aSMilanka Ringwald #define L2CAP_CONNECTION_RESPONSE_RESULT_REFUSED_RESOURCES 0x67
268*96c69d4aSMilanka Ringwald #define L2CAP_CONNECTION_RESPONSE_RESULT_ERTM_NOT_SUPPORTED 0x68
269*96c69d4aSMilanka Ringwald 
270*96c69d4aSMilanka Ringwald // should be L2CAP_CONNECTION_RTX_TIMEOUT
271*96c69d4aSMilanka Ringwald #define L2CAP_CONNECTION_RESPONSE_RESULT_RTX_TIMEOUT       0x69
272*96c69d4aSMilanka Ringwald #define L2CAP_CONNECTION_BASEBAND_DISCONNECT               0x6A
273*96c69d4aSMilanka Ringwald #define L2CAP_SERVICE_ALREADY_REGISTERED                   0x6B
274*96c69d4aSMilanka Ringwald #define L2CAP_DATA_LEN_EXCEEDS_REMOTE_MTU                  0x6C
275*96c69d4aSMilanka Ringwald #define L2CAP_SERVICE_DOES_NOT_EXIST                       0x6D
276*96c69d4aSMilanka Ringwald #define L2CAP_LOCAL_CID_DOES_NOT_EXIST                     0x6E
277*96c69d4aSMilanka Ringwald 
278*96c69d4aSMilanka Ringwald #define RFCOMM_MULTIPLEXER_STOPPED                         0x70
279*96c69d4aSMilanka Ringwald #define RFCOMM_CHANNEL_ALREADY_REGISTERED                  0x71
280*96c69d4aSMilanka Ringwald #define RFCOMM_NO_OUTGOING_CREDITS                         0x72
281*96c69d4aSMilanka Ringwald #define RFCOMM_AGGREGATE_FLOW_OFF                          0x73
282*96c69d4aSMilanka Ringwald #define RFCOMM_DATA_LEN_EXCEEDS_MTU                        0x74
283*96c69d4aSMilanka Ringwald 
284*96c69d4aSMilanka Ringwald #define SDP_HANDLE_ALREADY_REGISTERED                      0x80
285*96c69d4aSMilanka Ringwald #define SDP_QUERY_INCOMPLETE                               0x81
286*96c69d4aSMilanka Ringwald #define SDP_SERVICE_NOT_FOUND                              0x82
287*96c69d4aSMilanka Ringwald #define SDP_HANDLE_INVALID                                 0x83
288*96c69d4aSMilanka Ringwald #define SDP_QUERY_BUSY                                     0x84
289*96c69d4aSMilanka Ringwald 
290*96c69d4aSMilanka Ringwald #define ATT_HANDLE_VALUE_INDICATION_IN_PROGRESS            0x90
291*96c69d4aSMilanka Ringwald #define ATT_HANDLE_VALUE_INDICATION_TIMEOUT                0x91
292*96c69d4aSMilanka Ringwald #define ATT_HANDLE_VALUE_INDICATION_DISCONNECT             0x92
293*96c69d4aSMilanka Ringwald 
294*96c69d4aSMilanka Ringwald #define GATT_CLIENT_NOT_CONNECTED                          0x93
295*96c69d4aSMilanka Ringwald #define GATT_CLIENT_BUSY                                   0x94
296*96c69d4aSMilanka Ringwald #define GATT_CLIENT_IN_WRONG_STATE                         0x95
297*96c69d4aSMilanka Ringwald #define GATT_CLIENT_DIFFERENT_CONTEXT_FOR_ADDRESS_ALREADY_EXISTS 0x96
298*96c69d4aSMilanka Ringwald #define GATT_CLIENT_VALUE_TOO_LONG                         0x97
299*96c69d4aSMilanka Ringwald #define GATT_CLIENT_CHARACTERISTIC_NOTIFICATION_NOT_SUPPORTED 0x98
300*96c69d4aSMilanka Ringwald #define GATT_CLIENT_CHARACTERISTIC_INDICATION_NOT_SUPPORTED   0x99
301*96c69d4aSMilanka Ringwald 
302*96c69d4aSMilanka Ringwald #define BNEP_SERVICE_ALREADY_REGISTERED                    0xA0
303*96c69d4aSMilanka Ringwald #define BNEP_CHANNEL_NOT_CONNECTED                         0xA1
304*96c69d4aSMilanka Ringwald #define BNEP_DATA_LEN_EXCEEDS_MTU                          0xA2
305*96c69d4aSMilanka Ringwald 
306*96c69d4aSMilanka Ringwald // OBEX ERRORS
307*96c69d4aSMilanka Ringwald #define OBEX_UNKNOWN_ERROR                                 0xB0
308*96c69d4aSMilanka Ringwald #define OBEX_CONNECT_FAILED                                0xB1
309*96c69d4aSMilanka Ringwald #define OBEX_DISCONNECTED                                  0xB2
310*96c69d4aSMilanka Ringwald #define OBEX_NOT_FOUND                                     0xB3
311*96c69d4aSMilanka Ringwald #define OBEX_NOT_ACCEPTABLE                                0xB4
312*96c69d4aSMilanka Ringwald 
313*96c69d4aSMilanka Ringwald #define AVDTP_SEID_DOES_NOT_EXIST                          0xC0
314*96c69d4aSMilanka Ringwald #define AVDTP_CONNECTION_DOES_NOT_EXIST                    0xC1
315*96c69d4aSMilanka Ringwald #define AVDTP_CONNECTION_IN_WRONG_STATE                    0xC2
316*96c69d4aSMilanka Ringwald #define AVDTP_STREAM_ENDPOINT_IN_WRONG_STATE               0xC3
317*96c69d4aSMilanka Ringwald #define AVDTP_STREAM_ENDPOINT_DOES_NOT_EXIST               0xC4
318*96c69d4aSMilanka Ringwald #define AVDTP_MEDIA_CONNECTION_DOES_NOT_EXIST              0xC5
319*96c69d4aSMilanka Ringwald 
320*96c69d4aSMilanka Ringwald #define MESH_ERROR_APPKEY_INDEX_INVALID                    0xD0
321f193890fSMatthias Ringwald /* ENUM_END */
32247f4e325SMatthias Ringwald 
32332272f12SMilanka Ringwald 
324954cc391SMilanka Ringwald /* ENUM_START: AVRCP_BROWSING_ERROR_CODE */
325954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_INVALID_COMMAND                     0x00  // Sent if TG received a PDU that it did not understand. Valid for All.
326954cc391SMilanka 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.
327954cc391SMilanka 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.
328954cc391SMilanka 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.
329954cc391SMilanka 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.
330954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_UID_CHANGED                         0x05  // The UIDs on the device have changed. Valid for All.
331954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_RESERVED_06                         0x06  // Valid for All.
332954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_INVALID_DIRECTION                   0x07  // The Direction parameter is invalid. Valid for Change Path.
333954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_NOT_A_DIRECTORY                     0x08  // The UID provided does not refer to a folder item. Valid for Change Path.
334954cc391SMilanka 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.
335954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_INVALID_SCOPE                       0x0a  // The scope parameter is invalid. Valid for GetFolderItems, PlayItem, AddToNowPlayer, GetItemAttributes,.
336954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_RANGE_OUT_OF_BOUNDS                 0x0b  // The start of range provided is not valid. Valid for GetFolderItems.
337954cc391SMilanka 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.
338954cc391SMilanka 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.
339954cc391SMilanka 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.
340954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_SEARCH_NOT_SUPPORTED                0x0f  // The Browsed Media Player does not support search. Valid for Search.
341954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_SEARCH_IN_PROGRESS                  0x10  // A search operation is already in progress. Valid for Search.
342954cc391SMilanka 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.
343954cc391SMilanka 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.
344954cc391SMilanka 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.
345954cc391SMilanka 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.
346954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_NO_AVAILABLE_PLAYERS                0x15  // Valid for All.
347954cc391SMilanka Ringwald #define AVRCP_BROWSING_ERROR_CODE_ADDRESSED_PLAYER_CHANGED            0x16  // Valid for Register Notification.
348954cc391SMilanka Ringwald // 0x17-0xff Reserved
349954cc391SMilanka Ringwald /* ENUM_END */
350954cc391SMilanka Ringwald 
3518799c043SMatthias Ringwald // HCI roles
3528799c043SMatthias Ringwald #define HCI_ROLE_MASTER 0
3538799c043SMatthias Ringwald #define HCI_ROLE_SLAVE  1
3548799c043SMatthias Ringwald 
3558799c043SMatthias Ringwald // packet sizes (max payload)
3568799c043SMatthias Ringwald #define HCI_ACL_DM1_SIZE            17
3578799c043SMatthias Ringwald #define HCI_ACL_DH1_SIZE            27
3588799c043SMatthias Ringwald #define HCI_ACL_2DH1_SIZE           54
3598799c043SMatthias Ringwald #define HCI_ACL_3DH1_SIZE           83
3608799c043SMatthias Ringwald #define HCI_ACL_DM3_SIZE           121
3618799c043SMatthias Ringwald #define HCI_ACL_DH3_SIZE           183
3628799c043SMatthias Ringwald #define HCI_ACL_DM5_SIZE           224
3638799c043SMatthias Ringwald #define HCI_ACL_DH5_SIZE           339
3648799c043SMatthias Ringwald #define HCI_ACL_2DH3_SIZE          367
3658799c043SMatthias Ringwald #define HCI_ACL_3DH3_SIZE          552
3668799c043SMatthias Ringwald #define HCI_ACL_2DH5_SIZE          679
3678799c043SMatthias Ringwald #define HCI_ACL_3DH5_SIZE         1021
3688799c043SMatthias Ringwald 
3698799c043SMatthias Ringwald #define HCI_EVENT_PAYLOAD_SIZE     255
3708799c043SMatthias Ringwald #define HCI_CMD_PAYLOAD_SIZE       255
3718799c043SMatthias Ringwald 
3728799c043SMatthias Ringwald #define LE_ADVERTISING_DATA_SIZE    31
37347f4e325SMatthias Ringwald 
374c33e56d3SMatthias Ringwald // Link Policy Settings
375c33e56d3SMatthias Ringwald #define LM_LINK_POLICY_DISABLE_ALL_LM_MODES  0
376c33e56d3SMatthias Ringwald #define LM_LINK_POLICY_ENABLE_ROLE_SWITCH    1
377c33e56d3SMatthias Ringwald #define LM_LINK_POLICY_ENABLE_HOLD_MODE      2
378c33e56d3SMatthias Ringwald #define LM_LINK_POLICY_ENABLE_SNIFF_MODE     3
379c33e56d3SMatthias Ringwald 
38051fd61e9SMatthias Ringwald // ACL Connection Modes
38151fd61e9SMatthias Ringwald #define ACL_CONNECTION_MODE_ACTIVE 0
38251fd61e9SMatthias Ringwald #define ACL_CONNECTION_MODE_HOLD   1
38351fd61e9SMatthias Ringwald #define ACL_CONNECTION_MODE_SNIFF  2
38451fd61e9SMatthias Ringwald 
38547f4e325SMatthias Ringwald /**
38647f4e325SMatthias Ringwald  * Default INQ Mode
38747f4e325SMatthias Ringwald  */
3888aee7be2SMilanka Ringwald #define GAP_IAC_GENERAL_INQUIRY 0x9E8B33L // General/Unlimited Inquiry Access Code (GIAC)
3898aee7be2SMilanka Ringwald #define GAP_IAC_LIMITED_INQUIRY 0x9E8B00L // Limited Dedicated Inquiry Access Code (LIAC)
39047f4e325SMatthias Ringwald 
39147f4e325SMatthias Ringwald /**
39247f4e325SMatthias Ringwald  * SSP IO Capabilities
39347f4e325SMatthias Ringwald  */
39447f4e325SMatthias Ringwald #define SSP_IO_CAPABILITY_DISPLAY_ONLY   0
39547f4e325SMatthias Ringwald #define SSP_IO_CAPABILITY_DISPLAY_YES_NO 1
39647f4e325SMatthias Ringwald #define SSP_IO_CAPABILITY_KEYBOARD_ONLY  2
39747f4e325SMatthias Ringwald #define SSP_IO_CAPABILITY_NO_INPUT_NO_OUTPUT 3
39847f4e325SMatthias Ringwald #define SSP_IO_CAPABILITY_UNKNOWN 0xff
39947f4e325SMatthias Ringwald 
40047f4e325SMatthias Ringwald 
40147f4e325SMatthias Ringwald /**
40247f4e325SMatthias Ringwald  * SSP Authentication Requirements, see IO Capability Request Reply Commmand
40347f4e325SMatthias Ringwald  */
40447f4e325SMatthias Ringwald 
40547f4e325SMatthias Ringwald // Numeric comparison with automatic accept allowed.
40647f4e325SMatthias Ringwald #define SSP_IO_AUTHREQ_MITM_PROTECTION_NOT_REQUIRED_NO_BONDING 0x00
40747f4e325SMatthias Ringwald 
40847f4e325SMatthias Ringwald // Use IO Capabilities to deter- mine authentication procedure
40947f4e325SMatthias Ringwald #define SSP_IO_AUTHREQ_MITM_PROTECTION_REQUIRED_NO_BONDING 0x01
41047f4e325SMatthias Ringwald 
41147f4e325SMatthias Ringwald // Numeric compar- ison with automatic accept allowed.
41247f4e325SMatthias Ringwald #define SSP_IO_AUTHREQ_MITM_PROTECTION_NOT_REQUIRED_DEDICATED_BONDING 0x02
41347f4e325SMatthias Ringwald 
41447f4e325SMatthias Ringwald // Use IO Capabilities to determine authentication procedure
41547f4e325SMatthias Ringwald #define SSP_IO_AUTHREQ_MITM_PROTECTION_REQUIRED_DEDICATED_BONDING 0x03
41647f4e325SMatthias Ringwald 
41747f4e325SMatthias Ringwald // Numeric Compari- son with automatic accept allowed.
41847f4e325SMatthias Ringwald #define SSP_IO_AUTHREQ_MITM_PROTECTION_NOT_REQUIRED_GENERAL_BONDING 0x04
41947f4e325SMatthias Ringwald 
4208799c043SMatthias Ringwald // Use IO capabilities to determine authentication procedure.
42147f4e325SMatthias Ringwald #define SSP_IO_AUTHREQ_MITM_PROTECTION_REQUIRED_GENERAL_BONDING 0x05
42247f4e325SMatthias Ringwald 
42347f4e325SMatthias Ringwald 
4248799c043SMatthias Ringwald // OGFs
4258799c043SMatthias Ringwald #define OGF_LINK_CONTROL          0x01
4268799c043SMatthias Ringwald #define OGF_LINK_POLICY           0x02
4278799c043SMatthias Ringwald #define OGF_CONTROLLER_BASEBAND   0x03
4288799c043SMatthias Ringwald #define OGF_INFORMATIONAL_PARAMETERS 0x04
4298799c043SMatthias Ringwald #define OGF_STATUS_PARAMETERS     0x05
4308799c043SMatthias Ringwald #define OGF_TESTING               0x06
4318799c043SMatthias Ringwald #define OGF_LE_CONTROLLER 0x08
4328799c043SMatthias Ringwald #define OGF_VENDOR  0x3f
4338799c043SMatthias Ringwald 
4348799c043SMatthias Ringwald 
43547f4e325SMatthias Ringwald // Events from host controller to host
43647f4e325SMatthias Ringwald 
43747f4e325SMatthias Ringwald /**
43847f4e325SMatthias Ringwald  * @format 1
43947f4e325SMatthias Ringwald  * @param status
44047f4e325SMatthias Ringwald  */
44147f4e325SMatthias Ringwald #define HCI_EVENT_INQUIRY_COMPLETE                         0x01
44247f4e325SMatthias Ringwald 
44347f4e325SMatthias Ringwald /**
44447f4e325SMatthias Ringwald  * @format 1B11132
44547f4e325SMatthias Ringwald  * @param num_responses
44647f4e325SMatthias Ringwald  * @param bd_addr
44747f4e325SMatthias Ringwald  * @param page_scan_repetition_mode
44847f4e325SMatthias Ringwald  * @param reserved1
44947f4e325SMatthias Ringwald  * @param reserved2
45047f4e325SMatthias Ringwald  * @param class_of_device
45147f4e325SMatthias Ringwald  * @param clock_offset
45247f4e325SMatthias Ringwald  */
45347f4e325SMatthias Ringwald #define HCI_EVENT_INQUIRY_RESULT                           0x02
45447f4e325SMatthias Ringwald 
45547f4e325SMatthias Ringwald /**
45647f4e325SMatthias Ringwald  * @format 12B11
45747f4e325SMatthias Ringwald  * @param status
45847f4e325SMatthias Ringwald  * @param connection_handle
45947f4e325SMatthias Ringwald  * @param bd_addr
46047f4e325SMatthias Ringwald  * @param link_type
46147f4e325SMatthias Ringwald  * @param encryption_enabled
46247f4e325SMatthias Ringwald  */
46347f4e325SMatthias Ringwald #define HCI_EVENT_CONNECTION_COMPLETE                      0x03
46447f4e325SMatthias Ringwald /**
46547f4e325SMatthias Ringwald  * @format B31
46647f4e325SMatthias Ringwald  * @param bd_addr
46747f4e325SMatthias Ringwald  * @param class_of_device
46847f4e325SMatthias Ringwald  * @param link_type
46947f4e325SMatthias Ringwald  */
47047f4e325SMatthias Ringwald #define HCI_EVENT_CONNECTION_REQUEST                       0x04
47147f4e325SMatthias Ringwald /**
47247f4e325SMatthias Ringwald  * @format 121
47347f4e325SMatthias Ringwald  * @param status
47447f4e325SMatthias Ringwald  * @param connection_handle
47547f4e325SMatthias Ringwald  * @param reason
47647f4e325SMatthias Ringwald  */
47747f4e325SMatthias Ringwald #define HCI_EVENT_DISCONNECTION_COMPLETE                   0x05
47847f4e325SMatthias Ringwald /**
47947f4e325SMatthias Ringwald  * @format 12
48047f4e325SMatthias Ringwald  * @param status
48147f4e325SMatthias Ringwald  * @param connection_handle
48247f4e325SMatthias Ringwald  */
48351fd61e9SMatthias Ringwald #define HCI_EVENT_AUTHENTICATION_COMPLETE                 0x06
48451fd61e9SMatthias Ringwald 
48551fd61e9SMatthias Ringwald // HCI_EVENT_AUTHENTICATION_COMPLETE_EVENT is deprecated, use HCI_EVENT_AUTHENTICATION_COMPLETE instead
48651fd61e9SMatthias Ringwald #define HCI_EVENT_AUTHENTICATION_COMPLETE_EVENT HCI_EVENT_AUTHENTICATION_COMPLETE
48751fd61e9SMatthias Ringwald 
48847f4e325SMatthias Ringwald /**
48947f4e325SMatthias Ringwald  * @format 1BN
49047f4e325SMatthias Ringwald  * @param status
49147f4e325SMatthias Ringwald  * @param bd_addr
49247f4e325SMatthias Ringwald  * @param remote_name
49347f4e325SMatthias Ringwald  */
49447f4e325SMatthias Ringwald #define HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE             0x07
49547f4e325SMatthias Ringwald /**
49647f4e325SMatthias Ringwald  * @format 121
49747f4e325SMatthias Ringwald  * @param status
49847f4e325SMatthias Ringwald  * @param connection_handle
49947f4e325SMatthias Ringwald  * @param encryption_enabled
50047f4e325SMatthias Ringwald  */
50147f4e325SMatthias Ringwald #define HCI_EVENT_ENCRYPTION_CHANGE                        0x08
50247f4e325SMatthias Ringwald /**
50347f4e325SMatthias Ringwald  * @format 12
50447f4e325SMatthias Ringwald  * @param status
50547f4e325SMatthias Ringwald  * @param connection_handle
50647f4e325SMatthias Ringwald  */
50747f4e325SMatthias Ringwald #define HCI_EVENT_CHANGE_CONNECTION_LINK_KEY_COMPLETE      0x09
50847f4e325SMatthias Ringwald /**
50947f4e325SMatthias Ringwald  * @format 121
51047f4e325SMatthias Ringwald  * @param status
51147f4e325SMatthias Ringwald  * @param connection_handle
51247f4e325SMatthias Ringwald  * @param key_flag
51347f4e325SMatthias Ringwald  */
51447f4e325SMatthias Ringwald #define HCI_EVENT_MASTER_LINK_KEY_COMPLETE                 0x0A
515ad71fb17SMatthias Ringwald 
51647f4e325SMatthias Ringwald #define HCI_EVENT_READ_REMOTE_SUPPORTED_FEATURES_COMPLETE  0x0B
517ad71fb17SMatthias Ringwald 
5188b22c04dSMatthias Ringwald /**
5198b22c04dSMatthias Ringwald  * @format 12122
5208b22c04dSMatthias Ringwald  * @param status
5218b22c04dSMatthias Ringwald  * @param connection_handle
5228b22c04dSMatthias Ringwald  * @param version
5238b22c04dSMatthias Ringwald  * @param manufacturer_name
5248b22c04dSMatthias Ringwald  * @param subversion
5258b22c04dSMatthias Ringwald  */
52647f4e325SMatthias Ringwald #define HCI_EVENT_READ_REMOTE_VERSION_INFORMATION_COMPLETE 0x0C
527ad71fb17SMatthias Ringwald 
52847f4e325SMatthias Ringwald #define HCI_EVENT_QOS_SETUP_COMPLETE                       0x0D
52947f4e325SMatthias Ringwald 
53047f4e325SMatthias Ringwald /**
53147f4e325SMatthias Ringwald  * @format 12R
53247f4e325SMatthias Ringwald  * @param num_hci_command_packets
53347f4e325SMatthias Ringwald  * @param command_opcode
53447f4e325SMatthias Ringwald  * @param return_parameters
53547f4e325SMatthias Ringwald  */
53647f4e325SMatthias Ringwald #define HCI_EVENT_COMMAND_COMPLETE                         0x0E
53747f4e325SMatthias Ringwald /**
53847f4e325SMatthias Ringwald  * @format 112
53947f4e325SMatthias Ringwald  * @param status
54047f4e325SMatthias Ringwald  * @param num_hci_command_packets
54147f4e325SMatthias Ringwald  * @param command_opcode
54247f4e325SMatthias Ringwald  */
54347f4e325SMatthias Ringwald #define HCI_EVENT_COMMAND_STATUS                           0x0F
54447f4e325SMatthias Ringwald 
54547f4e325SMatthias Ringwald /**
5462c737695SMatthias Ringwald  * @format 1
54747f4e325SMatthias Ringwald  * @param hardware_code
54847f4e325SMatthias Ringwald  */
54947f4e325SMatthias Ringwald #define HCI_EVENT_HARDWARE_ERROR                           0x10
55047f4e325SMatthias Ringwald 
551ad71fb17SMatthias Ringwald #define HCI_EVENT_FLUSH_OCCURRED                           0x11
55247f4e325SMatthias Ringwald 
55347f4e325SMatthias Ringwald /**
55447f4e325SMatthias Ringwald  * @format 1B1
55547f4e325SMatthias Ringwald  * @param status
55647f4e325SMatthias Ringwald  * @param bd_addr
55747f4e325SMatthias Ringwald  * @param role
55847f4e325SMatthias Ringwald  */
55947f4e325SMatthias Ringwald #define HCI_EVENT_ROLE_CHANGE                              0x12
56047f4e325SMatthias Ringwald 
56110093bf5SMilanka Ringwald // TODO: number_of_handles 1, connection_handle[H*i], hc_num_of_completed_packets[2*i]
56247f4e325SMatthias Ringwald #define HCI_EVENT_NUMBER_OF_COMPLETED_PACKETS              0x13
56310093bf5SMilanka Ringwald 
56410093bf5SMilanka Ringwald /**
56510093bf5SMilanka Ringwald  * @format 1H12
56610093bf5SMilanka Ringwald  * @param status
56710093bf5SMilanka Ringwald  * @param handle
56810093bf5SMilanka Ringwald  * @param mode
56910093bf5SMilanka Ringwald  * @param interval
57010093bf5SMilanka Ringwald  */
57151fd61e9SMatthias Ringwald #define HCI_EVENT_MODE_CHANGE                              0x14
57210093bf5SMilanka Ringwald 
57310093bf5SMilanka Ringwald // TODO: num_keys, bd_addr[B*i], link_key[16 octets * i]
57447f4e325SMatthias Ringwald #define HCI_EVENT_RETURN_LINK_KEYS                         0x15
57510093bf5SMilanka Ringwald 
57610093bf5SMilanka Ringwald /**
57710093bf5SMilanka Ringwald  * @format B
57810093bf5SMilanka Ringwald  * @param bd_addr
57910093bf5SMilanka Ringwald  */
58047f4e325SMatthias Ringwald #define HCI_EVENT_PIN_CODE_REQUEST                         0x16
58110093bf5SMilanka Ringwald 
58210093bf5SMilanka Ringwald /**
58310093bf5SMilanka Ringwald  * @format B
58410093bf5SMilanka Ringwald  * @param bd_addr
58510093bf5SMilanka Ringwald  */
58647f4e325SMatthias Ringwald #define HCI_EVENT_LINK_KEY_REQUEST                         0x17
58710093bf5SMilanka Ringwald 
58810093bf5SMilanka Ringwald // TODO: bd_addr B, link_key 16octets, key_type 1
58947f4e325SMatthias Ringwald #define HCI_EVENT_LINK_KEY_NOTIFICATION                    0x18
59010093bf5SMilanka Ringwald 
59110093bf5SMilanka Ringwald /**
59210093bf5SMilanka Ringwald  * @format 1
59310093bf5SMilanka Ringwald  * @param link_type
59410093bf5SMilanka Ringwald  */
59547f4e325SMatthias Ringwald #define HCI_EVENT_DATA_BUFFER_OVERFLOW                     0x1A
59610093bf5SMilanka Ringwald 
59710093bf5SMilanka Ringwald /**
59810093bf5SMilanka Ringwald  * @format H1
59910093bf5SMilanka Ringwald  * @param handle
60010093bf5SMilanka Ringwald  * @param lmp_max_slots
60110093bf5SMilanka Ringwald  */
60247f4e325SMatthias Ringwald #define HCI_EVENT_MAX_SLOTS_CHANGED                        0x1B
60310093bf5SMilanka Ringwald 
60410093bf5SMilanka Ringwald /**
60510093bf5SMilanka Ringwald  * @format 1H2
60610093bf5SMilanka Ringwald  * @param status
60710093bf5SMilanka Ringwald  * @param handle
60810093bf5SMilanka Ringwald  * @param clock_offset
60910093bf5SMilanka Ringwald  */
61047f4e325SMatthias Ringwald #define HCI_EVENT_READ_CLOCK_OFFSET_COMPLETE               0x1C
61110093bf5SMilanka Ringwald 
61210093bf5SMilanka Ringwald /**
61310093bf5SMilanka Ringwald  * @format 1H2
61410093bf5SMilanka Ringwald  * @param status
61510093bf5SMilanka Ringwald  * @param handle
616fea5a680SMatthias Ringwald  * @param packet_types
617fea5a680SMatthias Ringwald  * @pnote packet_type is in plural to avoid clash with Java binding Packet.getPacketType()
61810093bf5SMilanka Ringwald  */
619fea5a680SMatthias Ringwald #define HCI_EVENT_CONNECTION_PACKET_TYPE_CHANGED           0x1D
62047f4e325SMatthias Ringwald 
62147f4e325SMatthias Ringwald /**
62247f4e325SMatthias Ringwald  * @format 1B11321
62347f4e325SMatthias Ringwald  * @param num_responses
62447f4e325SMatthias Ringwald  * @param bd_addr
62547f4e325SMatthias Ringwald  * @param page_scan_repetition_mode
62647f4e325SMatthias Ringwald  * @param reserved
62747f4e325SMatthias Ringwald  * @param class_of_device
62847f4e325SMatthias Ringwald  * @param clock_offset
62947f4e325SMatthias Ringwald  * @param rssi
63047f4e325SMatthias Ringwald  */
63147f4e325SMatthias Ringwald #define HCI_EVENT_INQUIRY_RESULT_WITH_RSSI                 0x22
63247f4e325SMatthias Ringwald 
63347f4e325SMatthias Ringwald /**
63447f4e325SMatthias Ringwald  * @format 1HB111221
63547f4e325SMatthias Ringwald  * @param status
63647f4e325SMatthias Ringwald  * @param handle
63747f4e325SMatthias Ringwald  * @param bd_addr
63847f4e325SMatthias Ringwald  * @param link_type
63947f4e325SMatthias Ringwald  * @param transmission_interval
64047f4e325SMatthias Ringwald  * @param retransmission_interval
64147f4e325SMatthias Ringwald  * @param rx_packet_length
64247f4e325SMatthias Ringwald  * @param tx_packet_length
64347f4e325SMatthias Ringwald  * @param air_mode
64447f4e325SMatthias Ringwald  */
64547f4e325SMatthias Ringwald #define HCI_EVENT_SYNCHRONOUS_CONNECTION_COMPLETE          0x2C
64647f4e325SMatthias Ringwald 
64747f4e325SMatthias Ringwald // TODO: serialize extended_inquiry_response and provide parser
64847f4e325SMatthias Ringwald /**
64947f4e325SMatthias Ringwald  * @format 1B11321
65047f4e325SMatthias Ringwald  * @param num_responses
65147f4e325SMatthias Ringwald  * @param bd_addr
65247f4e325SMatthias Ringwald  * @param page_scan_repetition_mode
65347f4e325SMatthias Ringwald  * @param reserved
65447f4e325SMatthias Ringwald  * @param class_of_device
65547f4e325SMatthias Ringwald  * @param clock_offset
65647f4e325SMatthias Ringwald  * @param rssi
65747f4e325SMatthias Ringwald  */
65847f4e325SMatthias Ringwald #define HCI_EVENT_EXTENDED_INQUIRY_RESPONSE                0x2F
65947f4e325SMatthias Ringwald 
66047f4e325SMatthias Ringwald  /**
66147f4e325SMatthias Ringwald   * @format 1H
66247f4e325SMatthias Ringwald   * @param status
66347f4e325SMatthias Ringwald   * @param handle
66447f4e325SMatthias Ringwald   */
66547f4e325SMatthias Ringwald #define HCI_EVENT_ENCRYPTION_KEY_REFRESH_COMPLETE          0x30
66647f4e325SMatthias Ringwald 
66747f4e325SMatthias Ringwald #define HCI_EVENT_IO_CAPABILITY_REQUEST                    0x31
66847f4e325SMatthias Ringwald #define HCI_EVENT_IO_CAPABILITY_RESPONSE                   0x32
669ad71fb17SMatthias Ringwald 
670ad71fb17SMatthias Ringwald /**
671ad71fb17SMatthias Ringwald  * @format B4
672ad71fb17SMatthias Ringwald  * @param bd_addr
673ad71fb17SMatthias Ringwald  * @param numeric_value
674ad71fb17SMatthias Ringwald  */
67547f4e325SMatthias Ringwald #define HCI_EVENT_USER_CONFIRMATION_REQUEST                0x33
676ad71fb17SMatthias Ringwald 
677ad71fb17SMatthias Ringwald /**
678ad71fb17SMatthias Ringwald  * @format B
679ad71fb17SMatthias Ringwald  * @param bd_addr
680ad71fb17SMatthias Ringwald  */
68147f4e325SMatthias Ringwald #define HCI_EVENT_USER_PASSKEY_REQUEST                     0x34
682ad71fb17SMatthias Ringwald 
683ad71fb17SMatthias Ringwald /**
684ad71fb17SMatthias Ringwald  * @format B
685ad71fb17SMatthias Ringwald  * @param bd_addr
686ad71fb17SMatthias Ringwald  */
68747f4e325SMatthias Ringwald #define HCI_EVENT_REMOTE_OOB_DATA_REQUEST                  0x35
688ad71fb17SMatthias Ringwald 
689ad71fb17SMatthias Ringwald /**
690ad71fb17SMatthias Ringwald  * @format 1B
691ad71fb17SMatthias Ringwald  * @param status
692ad71fb17SMatthias Ringwald  * @param bd_addr
693ad71fb17SMatthias Ringwald  */
69447f4e325SMatthias Ringwald #define HCI_EVENT_SIMPLE_PAIRING_COMPLETE                  0x36
69547f4e325SMatthias Ringwald 
69647f4e325SMatthias Ringwald #define HCI_EVENT_LE_META                                  0x3E
69747f4e325SMatthias Ringwald 
69882180fcaSMatthias Ringwald // last used HCI_EVENT in 2.1 is 0x3d
69982180fcaSMatthias Ringwald // last used HCI_EVENT in 4.1 is 0x57
70082180fcaSMatthias Ringwald 
701941b3855SMatthias Ringwald #define HCI_EVENT_VENDOR_SPECIFIC                          0xFF
702941b3855SMatthias Ringwald 
70347f4e325SMatthias Ringwald /**
704ca0d73deSMatthias Ringwald  * @format 11H11B2221
70547f4e325SMatthias Ringwald  * @param subevent_code
70647f4e325SMatthias Ringwald  * @param status
70747f4e325SMatthias Ringwald  * @param connection_handle
70847f4e325SMatthias Ringwald  * @param role
70947f4e325SMatthias Ringwald  * @param peer_address_type
71047f4e325SMatthias Ringwald  * @param peer_address
71147f4e325SMatthias Ringwald  * @param conn_interval
71247f4e325SMatthias Ringwald  * @param conn_latency
71347f4e325SMatthias Ringwald  * @param supervision_timeout
71447f4e325SMatthias Ringwald  * @param master_clock_accuracy
71547f4e325SMatthias Ringwald  */
71647f4e325SMatthias Ringwald #define HCI_SUBEVENT_LE_CONNECTION_COMPLETE                0x01
71782180fcaSMatthias Ringwald 
71882180fcaSMatthias Ringwald // array of advertisements, not handled by event accessor generator
71947f4e325SMatthias Ringwald #define HCI_SUBEVENT_LE_ADVERTISING_REPORT                 0x02
72082180fcaSMatthias Ringwald 
72182180fcaSMatthias Ringwald /**
72282180fcaSMatthias Ringwald  * @format 11H222
72382180fcaSMatthias Ringwald  * @param subevent_code
72482180fcaSMatthias Ringwald  * @param status
72582180fcaSMatthias Ringwald  * @param connection_handle
72682180fcaSMatthias Ringwald  * @param conn_interval
72782180fcaSMatthias Ringwald  * @param conn_latency
7282c737695SMatthias Ringwald  * @param supervision_timeout
72982180fcaSMatthias Ringwald  */
73047f4e325SMatthias Ringwald  #define HCI_SUBEVENT_LE_CONNECTION_UPDATE_COMPLETE         0x03
73182180fcaSMatthias Ringwald 
73282180fcaSMatthias Ringwald /**
73382180fcaSMatthias Ringwald  * @format 1HD2
73482180fcaSMatthias Ringwald  * @param subevent_code
73582180fcaSMatthias Ringwald  * @param connection_handle
73682180fcaSMatthias Ringwald  * @param random_number
73782180fcaSMatthias Ringwald  * @param encryption_diversifier
73882180fcaSMatthias Ringwald  */
73947f4e325SMatthias Ringwald #define HCI_SUBEVENT_LE_READ_REMOTE_USED_FEATURES_COMPLETE 0x04
74082180fcaSMatthias Ringwald 
74182180fcaSMatthias Ringwald /**
74282180fcaSMatthias Ringwald  * @format 1HD2
74382180fcaSMatthias Ringwald  * @param subevent_code
74482180fcaSMatthias Ringwald  * @param connection_handle
74582180fcaSMatthias Ringwald  * @param random_number
74682180fcaSMatthias Ringwald  * @param encryption_diversifier
74782180fcaSMatthias Ringwald  */
74847f4e325SMatthias Ringwald #define HCI_SUBEVENT_LE_LONG_TERM_KEY_REQUEST              0x05
74947f4e325SMatthias Ringwald 
75082180fcaSMatthias Ringwald /**
75182180fcaSMatthias Ringwald  * @format 1H2222
75282180fcaSMatthias Ringwald  * @param subevent_code
75382180fcaSMatthias Ringwald  * @param connection_handle
75482180fcaSMatthias Ringwald  * @param interval_min
75582180fcaSMatthias Ringwald  * @param interval_max
75682180fcaSMatthias Ringwald  * @param latency
75782180fcaSMatthias Ringwald  * @param timeout
75882180fcaSMatthias Ringwald  */
75982180fcaSMatthias Ringwald #define HCI_SUBEVENT_LE_REMOTE_CONNECTION_PARAMETER_REQUEST 0x06
76082180fcaSMatthias Ringwald 
76182180fcaSMatthias Ringwald /**
76282180fcaSMatthias Ringwald  * @format 1H2222
76382180fcaSMatthias Ringwald  * @param subevent_code
76482180fcaSMatthias Ringwald  * @param connection_handle
76582180fcaSMatthias Ringwald  * @param max_tx_octets
76682180fcaSMatthias Ringwald  * @param max_tx_time
76782180fcaSMatthias Ringwald  * @param max_rx_octets
76882180fcaSMatthias Ringwald  * @param max_rx_time
76982180fcaSMatthias Ringwald  */
77082180fcaSMatthias Ringwald #define HCI_SUBEVENT_LE_DATA_LENGTH_CHANGE 0x07
77182180fcaSMatthias Ringwald 
77282180fcaSMatthias Ringwald /**
77382180fcaSMatthias Ringwald  * @format 11QQ
77482180fcaSMatthias Ringwald  * @param subevent_code
77582180fcaSMatthias Ringwald  * @param status
77682180fcaSMatthias Ringwald  * @param dhkey_x x coordinate of P256 public key
77782180fcaSMatthias Ringwald  * @param dhkey_y y coordinate of P256 public key
77882180fcaSMatthias Ringwald  */
77982180fcaSMatthias Ringwald #define HCI_SUBEVENT_LE_READ_LOCAL_P256_PUBLIC_KEY_COMPLETE 0x08
78082180fcaSMatthias Ringwald  /**
78143836aa6SMatthias Ringwald  * @format 11Q
78282180fcaSMatthias Ringwald  * @param subevent_code
78382180fcaSMatthias Ringwald  * @param status
78443836aa6SMatthias Ringwald  * @param dhkey Diffie-Hellman key
78582180fcaSMatthias Ringwald  */
78682180fcaSMatthias Ringwald #define HCI_SUBEVENT_LE_GENERATE_DHKEY_COMPLETE            0x09
78782180fcaSMatthias Ringwald 
78882180fcaSMatthias Ringwald /**
78982180fcaSMatthias Ringwald  * @format 11H11BBB2221
79082180fcaSMatthias Ringwald  * @param subevent_code
79182180fcaSMatthias Ringwald  * @param status
79282180fcaSMatthias Ringwald  * @param connection_handle
79382180fcaSMatthias Ringwald  * @param role
79482180fcaSMatthias Ringwald  * @param peer_address_type
79582180fcaSMatthias Ringwald  * @param perr_addresss
79682180fcaSMatthias Ringwald  * @param local_resolvable_private_addres
79782180fcaSMatthias Ringwald  * @param peer_resolvable_private_addres
79882180fcaSMatthias Ringwald  * @param conn_interval
79982180fcaSMatthias Ringwald  * @param conn_latency
80082180fcaSMatthias Ringwald  * @param supervision_timeout
80182180fcaSMatthias Ringwald  * @param master_clock_accuracy
80282180fcaSMatthias Ringwald  */
80382180fcaSMatthias Ringwald #define HCI_SUBEVENT_LE_ENHANCED_CONNECTION_COMPLETE       0x0A
80482180fcaSMatthias Ringwald 
80582180fcaSMatthias Ringwald // array of advertisements, not handled by event accessor generator
80682180fcaSMatthias Ringwald #define HCI_SUBEVENT_LE_DIRECT_ADVERTISING_REPORT          0x0B
80747f4e325SMatthias Ringwald 
80847f4e325SMatthias Ringwald /**
80947f4e325SMatthias Ringwald  * L2CAP Layer
81047f4e325SMatthias Ringwald  */
81147f4e325SMatthias Ringwald 
812a8373a41SMatthias Ringwald #define L2CAP_HEADER_SIZE 4
813a8373a41SMatthias Ringwald 
814a8373a41SMatthias Ringwald #define L2CAP_SIG_ID_INVALID 0
815a8373a41SMatthias Ringwald 
816a8373a41SMatthias Ringwald // size of HCI ACL + L2CAP Header for regular data packets (8)
817a8373a41SMatthias Ringwald #define COMPLETE_L2CAP_HEADER (HCI_ACL_HEADER_SIZE + L2CAP_HEADER_SIZE)
818a8373a41SMatthias Ringwald 
819a8373a41SMatthias Ringwald // minimum signaling MTU
820a8373a41SMatthias Ringwald #define L2CAP_MINIMAL_MTU 48
821a8373a41SMatthias Ringwald #define L2CAP_DEFAULT_MTU 672
822a8373a41SMatthias Ringwald 
823a8373a41SMatthias Ringwald // Minimum/default MTU
824a8373a41SMatthias Ringwald #define L2CAP_LE_DEFAULT_MTU  23
825a8373a41SMatthias Ringwald 
826a8373a41SMatthias Ringwald // L2CAP Fixed Channel IDs
827a8373a41SMatthias Ringwald #define L2CAP_CID_SIGNALING                 0x0001
828a8373a41SMatthias Ringwald #define L2CAP_CID_CONNECTIONLESS_CHANNEL    0x0002
829a8373a41SMatthias Ringwald #define L2CAP_CID_ATTRIBUTE_PROTOCOL        0x0004
830a8373a41SMatthias Ringwald #define L2CAP_CID_SIGNALING_LE              0x0005
831a8373a41SMatthias Ringwald #define L2CAP_CID_SECURITY_MANAGER_PROTOCOL 0x0006
832a8373a41SMatthias Ringwald 
833a8373a41SMatthias Ringwald // L2CAP Configuration Result Codes
8345b180434SMatthias Ringwald #define L2CAP_CONF_RESULT_SUCCESS                  0x0000
8355b180434SMatthias Ringwald #define L2CAP_CONF_RESULT_UNACCEPTABLE_PARAMETERS  0x0001
8365b180434SMatthias Ringwald #define L2CAP_CONF_RESULT_REJECT                   0x0002
837a8373a41SMatthias Ringwald #define L2CAP_CONF_RESULT_UNKNOWN_OPTIONS          0x0003
8385b180434SMatthias Ringwald #define L2CAP_CONF_RESULT_PENDING                  0x0004
8395b180434SMatthias Ringwald #define L2CAP_CONF_RESULT_FLOW_SPEC_REJECTED       0x0005
840a8373a41SMatthias Ringwald 
841a8373a41SMatthias Ringwald // L2CAP Reject Result Codes
842a8373a41SMatthias Ringwald #define L2CAP_REJ_CMD_UNKNOWN               0x0000
843a8373a41SMatthias Ringwald 
844a8373a41SMatthias Ringwald // Response Timeout eXpired
845a8373a41SMatthias Ringwald #define L2CAP_RTX_TIMEOUT_MS   10000
846a8373a41SMatthias Ringwald 
847a8373a41SMatthias Ringwald // Extended Response Timeout eXpired
848a8373a41SMatthias Ringwald #define L2CAP_ERTX_TIMEOUT_MS 120000
849a8373a41SMatthias Ringwald 
85066b1fcb3SMatthias Ringwald /**
851235946f1SMatthias Ringwald  * SDP Protocol
852ef907034SMatthias Ringwald  */
853ef907034SMatthias Ringwald 
854c4b3290dSMatthias Ringwald // Device Vendor ID Sources
855c4b3290dSMatthias Ringwald #define DEVICE_ID_VENDOR_ID_SOURCE_BLUETOOTH 0x0001
856c4b3290dSMatthias Ringwald #define DEVICE_ID_VENDOR_ID_SOURCE_USB       0x0002
857c4b3290dSMatthias Ringwald 
858ef907034SMatthias Ringwald // OBEX
859ef907034SMatthias Ringwald #define SDP_vCard_2_1       0x01
860ef907034SMatthias Ringwald #define SDP_vCard_3_0       0x02
861ef907034SMatthias Ringwald #define SDP_vCal_1_0        0x03
862ef907034SMatthias Ringwald #define SDP_iCal_2_0        0x04
863ef907034SMatthias Ringwald #define SDP_vNote           0x05
864ef907034SMatthias Ringwald #define SDP_vMessage        0x06
865ef907034SMatthias Ringwald #define SDP_OBEXFileTypeAny 0xFF
866ef907034SMatthias Ringwald 
867ef907034SMatthias Ringwald /**
868e2577bd7SMatthias Ringwald  * RFCOMM Protocol
869e2577bd7SMatthias Ringwald  */
870e2577bd7SMatthias Ringwald 
871e2577bd7SMatthias Ringwald // Control field values      bit no.       1 2 3 4 PF 6 7 8
872e2577bd7SMatthias Ringwald #define BT_RFCOMM_SABM       0x3F       // 1 1 1 1  1 1 0 0
873e2577bd7SMatthias Ringwald #define BT_RFCOMM_UA         0x73       // 1 1 0 0  1 1 1 0
874e2577bd7SMatthias Ringwald #define BT_RFCOMM_DM         0x0F       // 1 1 1 1  0 0 0 0
875e2577bd7SMatthias Ringwald #define BT_RFCOMM_DM_PF      0x1F       // 1 1 1 1  1 0 0 0
876e2577bd7SMatthias Ringwald #define BT_RFCOMM_DISC       0x53       // 1 1 0 0  1 0 1 0
877e2577bd7SMatthias Ringwald #define BT_RFCOMM_UIH        0xEF       // 1 1 1 1  0 1 1 1
878e2577bd7SMatthias Ringwald #define BT_RFCOMM_UIH_PF     0xFF       // 1 1 1 1  0 1 1 1
879e2577bd7SMatthias Ringwald 
880e2577bd7SMatthias Ringwald // Multiplexer message types
881e2577bd7SMatthias Ringwald #define BT_RFCOMM_CLD_CMD    0xC3
882e2577bd7SMatthias Ringwald #define BT_RFCOMM_FCON_CMD   0xA3
883e2577bd7SMatthias Ringwald #define BT_RFCOMM_FCON_RSP   0xA1
884e2577bd7SMatthias Ringwald #define BT_RFCOMM_FCOFF_CMD  0x63
885e2577bd7SMatthias Ringwald #define BT_RFCOMM_FCOFF_RSP  0x61
886e2577bd7SMatthias Ringwald #define BT_RFCOMM_MSC_CMD    0xE3
887e2577bd7SMatthias Ringwald #define BT_RFCOMM_MSC_RSP    0xE1
888e2577bd7SMatthias Ringwald #define BT_RFCOMM_NSC_RSP    0x11
889e2577bd7SMatthias Ringwald #define BT_RFCOMM_PN_CMD     0x83
890e2577bd7SMatthias Ringwald #define BT_RFCOMM_PN_RSP     0x81
891e2577bd7SMatthias Ringwald #define BT_RFCOMM_RLS_CMD    0x53
892e2577bd7SMatthias Ringwald #define BT_RFCOMM_RLS_RSP    0x51
893e2577bd7SMatthias Ringwald #define BT_RFCOMM_RPN_CMD    0x93
894e2577bd7SMatthias Ringwald #define BT_RFCOMM_RPN_RSP    0x91
895e2577bd7SMatthias Ringwald #define BT_RFCOMM_TEST_CMD   0x23
896e2577bd7SMatthias Ringwald #define BT_RFCOMM_TEST_RSP   0x21
897e2577bd7SMatthias Ringwald 
898e2577bd7SMatthias Ringwald // Line Status
899e2577bd7SMatthias Ringwald #define LINE_STATUS_NO_ERROR       0x00
900e2577bd7SMatthias Ringwald #define LINE_STATUS_OVERRUN_ERROR  0x03
901e2577bd7SMatthias Ringwald #define LINE_STATUS_PARITY_ERORR   0x05
902e2577bd7SMatthias Ringwald #define LINE_STATUS_FRAMING_ERROR  0x09
903e2577bd7SMatthias Ringwald 
904e2577bd7SMatthias Ringwald // Modem Status Flags
905e2577bd7SMatthias Ringwald #define MODEM_STATUS_FC   0x02
906e2577bd7SMatthias Ringwald #define MODEM_STATUS_RTC  0x04
907e2577bd7SMatthias Ringwald #define MODEM_STATUS_RTR  0x08
908e2577bd7SMatthias Ringwald #define MODEM_STATUS_IC   0x40
909e2577bd7SMatthias Ringwald #define MODEM_STATUS_DV   0x80
910e2577bd7SMatthias Ringwald 
911e2577bd7SMatthias Ringwald typedef enum rpn_baud {
912e2577bd7SMatthias Ringwald     RPN_BAUD_2400 = 0,
913e2577bd7SMatthias Ringwald     RPN_BAUD_4800,
914e2577bd7SMatthias Ringwald     RPN_BAUD_7200,
915e2577bd7SMatthias Ringwald     RPN_BAUD_9600,
916e2577bd7SMatthias Ringwald     RPN_BAUD_19200,
917e2577bd7SMatthias Ringwald     RPN_BAUD_38400,
918e2577bd7SMatthias Ringwald     RPN_BAUD_57600,
919e2577bd7SMatthias Ringwald     RPN_BAUD_115200,
920e2577bd7SMatthias Ringwald     RPN_BAUD_230400
921e2577bd7SMatthias Ringwald } rpn_baud_t;
922e2577bd7SMatthias Ringwald 
923e2577bd7SMatthias Ringwald typedef enum rpn_data_bits {
924e2577bd7SMatthias Ringwald     RPN_DATA_BITS_5 = 0,
925e2577bd7SMatthias Ringwald     RPN_DATA_BITS_6 = 0,
926e2577bd7SMatthias Ringwald     RPN_DATA_BITS_7 = 0,
927e2577bd7SMatthias Ringwald     RPN_DATA_BITS_8 = 0
928e2577bd7SMatthias Ringwald } rpn_data_bits_t;
929e2577bd7SMatthias Ringwald 
930e2577bd7SMatthias Ringwald typedef enum rpn_stop_bits {
931e2577bd7SMatthias Ringwald     RPN_STOP_BITS_1_0 = 0,
932e2577bd7SMatthias Ringwald     RPN_STOP_BITS_1_5
933e2577bd7SMatthias Ringwald } rpn_stop_bits_t;
934e2577bd7SMatthias Ringwald 
935e2577bd7SMatthias Ringwald typedef enum rpn_parity {
936e2577bd7SMatthias Ringwald     RPN_PARITY_NONE  = 0,
937e2577bd7SMatthias Ringwald     RPN_PARITY_ODD   = 1,
938e2577bd7SMatthias Ringwald     RPN_PARITY_EVEN  = 3,
939e2577bd7SMatthias Ringwald     RPN_PARITY_MARK  = 5,
940e2577bd7SMatthias Ringwald     RPN_PARITY_SPACE = 7,
941e2577bd7SMatthias Ringwald } rpn_parity_t;
942e2577bd7SMatthias Ringwald 
943e2577bd7SMatthias Ringwald typedef enum rpn_flow_control {
944e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_XONXOFF_ON_INPUT  = 1 << 0,
945e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_XONXOFF_ON_OUTPUT = 1 << 1,
946e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_RTR_ON_INPUT  = 1 << 2,
947e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_RTR_ON_OUTPUT = 1 << 3,
948e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_RTC_ON_INPUT  = 1 << 4,
949e2577bd7SMatthias Ringwald     RPN_FLOW_CONTROL_RTC_ON_OUTPUT = 1 << 5,
950e2577bd7SMatthias Ringwald } rpn_flow_control_t;
951e2577bd7SMatthias Ringwald 
952e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_BAUD             0x01
953e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_DATA_BITS        0x02
954e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_STOP_BITS        0x04
955e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_PARITY           0x08
956e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_PARITY_TYPE      0x10
957e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_XON_CHAR         0x20
958e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_XOFF_CHAR        0x40
959e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_0_RESERVED         0x80
960e2577bd7SMatthias Ringwald 
961e2577bd7SMatthias Ringwald // @note: values are identical to rpn_flow_control_t
962e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_XONOFF_ON_INPUT  0x01
963e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_XONOFF_ON_OUTPUT 0x02
964e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RTR_ON_INPUT     0x04
965e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RTR_ON_OUTPUT    0x08
966e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RTC_ON_INPUT     0x10
967e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RTC_ON_OUTPUT    0x20
968e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RESERVED_0       0x40
969e2577bd7SMatthias Ringwald #define RPN_PARAM_MASK_1_RESERVED_1       0x80
970e2577bd7SMatthias Ringwald 
971e2577bd7SMatthias Ringwald /**
97266b1fcb3SMatthias Ringwald  * BNEP Protocol
97366b1fcb3SMatthias Ringwald  */
97447f4e325SMatthias Ringwald 
97566b1fcb3SMatthias Ringwald #ifndef ETHER_ADDR_LEN
9769a73f75dSMatthias Ringwald #define ETHER_ADDR_LEN 6
97766b1fcb3SMatthias Ringwald #endif
97847f4e325SMatthias Ringwald 
97966b1fcb3SMatthias Ringwald #ifndef ETHERTYPE_VLAN
98066b1fcb3SMatthias Ringwald #define ETHERTYPE_VLAN                                  0x8100 /* IEEE 802.1Q VLAN tag */
98166b1fcb3SMatthias Ringwald #endif
98266b1fcb3SMatthias Ringwald 
98366b1fcb3SMatthias Ringwald #define BNEP_MTU_MIN                                    1691
98466b1fcb3SMatthias Ringwald 
98566b1fcb3SMatthias Ringwald #define BNEP_EXT_FLAG                                   0x80
98666b1fcb3SMatthias Ringwald #define BNEP_TYPE_MASK                                  0x7F
98766b1fcb3SMatthias Ringwald #define BNEP_TYPE(header)                               ((header) & BNEP_TYPE_MASK)
98866b1fcb3SMatthias Ringwald #define BNEP_HEADER_HAS_EXT(x)                          (((x) & BNEP_EXT_FLAG) == BNEP_EXT_FLAG)
98966b1fcb3SMatthias Ringwald 
99066b1fcb3SMatthias Ringwald /* BNEP packet types */
99166b1fcb3SMatthias Ringwald #define BNEP_PKT_TYPE_GENERAL_ETHERNET                  0x00
99266b1fcb3SMatthias Ringwald #define BNEP_PKT_TYPE_CONTROL                           0x01
99366b1fcb3SMatthias Ringwald #define BNEP_PKT_TYPE_COMPRESSED_ETHERNET               0x02
99466b1fcb3SMatthias Ringwald #define BNEP_PKT_TYPE_COMPRESSED_ETHERNET_SOURCE_ONLY   0x03
99566b1fcb3SMatthias Ringwald #define BNEP_PKT_TYPE_COMPRESSED_ETHERNET_DEST_ONLY     0x04
99666b1fcb3SMatthias Ringwald 
99766b1fcb3SMatthias Ringwald /* BNEP control types */
99866b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_COMMAND_NOT_UNDERSTOOD        0x00
99966b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_SETUP_CONNECTION_REQUEST      0x01
100066b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_SETUP_CONNECTION_RESPONSE     0x02
100166b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_FILTER_NET_TYPE_SET           0x03
100266b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_FILTER_NET_TYPE_RESPONSE      0x04
100366b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_FILTER_MULTI_ADDR_SET         0x05
100466b1fcb3SMatthias Ringwald #define BNEP_CONTROL_TYPE_FILTER_MULTI_ADDR_RESPONSE    0x06
100566b1fcb3SMatthias Ringwald 
100666b1fcb3SMatthias Ringwald /* BNEP extension header types */
100766b1fcb3SMatthias Ringwald #define BNEP_EXT_HEADER_TYPE_EXTENSION_CONTROL          0x00
100866b1fcb3SMatthias Ringwald 
100966b1fcb3SMatthias Ringwald /* BNEP setup response codes */
101066b1fcb3SMatthias Ringwald #define BNEP_RESP_SETUP_SUCCESS                         0x0000
101166b1fcb3SMatthias Ringwald #define BNEP_RESP_SETUP_INVALID_DEST_UUID               0x0001
101266b1fcb3SMatthias Ringwald #define BNEP_RESP_SETUP_INVALID_SOURCE_UUID             0x0002
101366b1fcb3SMatthias Ringwald #define BNEP_RESP_SETUP_INVALID_SERVICE_UUID_SIZE       0x0003
101466b1fcb3SMatthias Ringwald #define BNEP_RESP_SETUP_CONNECTION_NOT_ALLOWED          0x0004
101566b1fcb3SMatthias Ringwald 
101666b1fcb3SMatthias Ringwald /* BNEP filter response codes */
101766b1fcb3SMatthias Ringwald #define BNEP_RESP_FILTER_SUCCESS                        0x0000
101866b1fcb3SMatthias Ringwald #define BNEP_RESP_FILTER_UNSUPPORTED_REQUEST            0x0001
101966b1fcb3SMatthias Ringwald #define BNEP_RESP_FILTER_ERR_INVALID_RANGE              0x0002
102066b1fcb3SMatthias Ringwald #define BNEP_RESP_FILTER_ERR_TOO_MANY_FILTERS           0x0003
102166b1fcb3SMatthias Ringwald #define BNEP_RESP_FILTER_ERR_SECURITY                   0x0004
102266b1fcb3SMatthias Ringwald 
102366b1fcb3SMatthias Ringwald /**
102466b1fcb3SMatthias Ringwald  * PAN Profile
102566b1fcb3SMatthias Ringwald  */
102666b1fcb3SMatthias Ringwald 
102766b1fcb3SMatthias Ringwald typedef enum {
102866b1fcb3SMatthias Ringwald     BNEP_SECURITY_NONE = 0x0000,
102966b1fcb3SMatthias Ringwald     BNEP_SECURITY_SERVICE_LEVEL_ENFORCED,
103066b1fcb3SMatthias Ringwald     BNEP_SECURITY_802_1X
103166b1fcb3SMatthias Ringwald } security_description_t;
103266b1fcb3SMatthias Ringwald 
103366b1fcb3SMatthias Ringwald typedef enum {
103466b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_PSTN = 0x0000,
103566b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_ISDN,
103666b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_DSL,
103766b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_CABLE_MODEM,
103866b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_10MB_ETHERNET,
103966b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_100MB_ETHERNET,
104066b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_4MB_TOKEN_RING,
104166b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_16MB_TOKEN_RING,
104266b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_100MB_TOKEN_RING,
104366b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_FDDI,
104466b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_GSM,
104566b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_CDMA,
104666b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_GPRS,
104766b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_3G,
104866b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_CELULAR,
104966b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_OTHER = 0xFFFE,
105066b1fcb3SMatthias Ringwald     PAN_NET_ACCESS_TYPE_NONE
105166b1fcb3SMatthias Ringwald } net_access_type_t;
105247f4e325SMatthias Ringwald 
10534c1900e6SMatthias Ringwald /**
10544c1900e6SMatthias Ringwald  * ATT
10554c1900e6SMatthias Ringwald  */
10564c1900e6SMatthias Ringwald 
10574c1900e6SMatthias Ringwald // Minimum/default MTU
10584c1900e6SMatthias Ringwald #define ATT_DEFAULT_MTU               23
10594c1900e6SMatthias Ringwald 
10604c1900e6SMatthias Ringwald // MARK: Attribute PDU Opcodes
10614c1900e6SMatthias Ringwald #define ATT_ERROR_RESPONSE              0x01
10624c1900e6SMatthias Ringwald 
10634c1900e6SMatthias Ringwald #define ATT_EXCHANGE_MTU_REQUEST        0x02
10644c1900e6SMatthias Ringwald #define ATT_EXCHANGE_MTU_RESPONSE       0x03
10654c1900e6SMatthias Ringwald 
10664c1900e6SMatthias Ringwald #define ATT_FIND_INFORMATION_REQUEST    0x04
10674c1900e6SMatthias Ringwald #define ATT_FIND_INFORMATION_REPLY      0x05
10684c1900e6SMatthias Ringwald #define ATT_FIND_BY_TYPE_VALUE_REQUEST  0x06
10694c1900e6SMatthias Ringwald #define ATT_FIND_BY_TYPE_VALUE_RESPONSE 0x07
10704c1900e6SMatthias Ringwald 
10714c1900e6SMatthias Ringwald #define ATT_READ_BY_TYPE_REQUEST        0x08
10724c1900e6SMatthias Ringwald #define ATT_READ_BY_TYPE_RESPONSE       0x09
10734c1900e6SMatthias Ringwald #define ATT_READ_REQUEST                0x0a
10744c1900e6SMatthias Ringwald #define ATT_READ_RESPONSE               0x0b
10754c1900e6SMatthias Ringwald #define ATT_READ_BLOB_REQUEST           0x0c
10764c1900e6SMatthias Ringwald #define ATT_READ_BLOB_RESPONSE          0x0d
10774c1900e6SMatthias Ringwald #define ATT_READ_MULTIPLE_REQUEST       0x0e
10784c1900e6SMatthias Ringwald #define ATT_READ_MULTIPLE_RESPONSE      0x0f
10794c1900e6SMatthias Ringwald #define ATT_READ_BY_GROUP_TYPE_REQUEST  0x10
10804c1900e6SMatthias Ringwald #define ATT_READ_BY_GROUP_TYPE_RESPONSE 0x11
10814c1900e6SMatthias Ringwald 
10824c1900e6SMatthias Ringwald #define ATT_WRITE_REQUEST               0x12
10834c1900e6SMatthias Ringwald #define ATT_WRITE_RESPONSE              0x13
10844c1900e6SMatthias Ringwald 
10854c1900e6SMatthias Ringwald #define ATT_PREPARE_WRITE_REQUEST       0x16
10864c1900e6SMatthias Ringwald #define ATT_PREPARE_WRITE_RESPONSE      0x17
10874c1900e6SMatthias Ringwald #define ATT_EXECUTE_WRITE_REQUEST       0x18
10884c1900e6SMatthias Ringwald #define ATT_EXECUTE_WRITE_RESPONSE      0x19
10894c1900e6SMatthias Ringwald 
10904c1900e6SMatthias Ringwald #define ATT_HANDLE_VALUE_NOTIFICATION   0x1b
10914c1900e6SMatthias Ringwald #define ATT_HANDLE_VALUE_INDICATION     0x1d
10924c1900e6SMatthias Ringwald #define ATT_HANDLE_VALUE_CONFIRMATION   0x1e
10934c1900e6SMatthias Ringwald 
10944c1900e6SMatthias Ringwald 
10954c1900e6SMatthias Ringwald #define ATT_WRITE_COMMAND                0x52
10964c1900e6SMatthias Ringwald #define ATT_SIGNED_WRITE_COMMAND         0xD2
10974c1900e6SMatthias Ringwald 
10984c1900e6SMatthias Ringwald // MARK: ATT Error Codes
10994c1900e6SMatthias Ringwald #define ATT_ERROR_INVALID_HANDLE                   0x01
11004c1900e6SMatthias Ringwald #define ATT_ERROR_READ_NOT_PERMITTED               0x02
11014c1900e6SMatthias Ringwald #define ATT_ERROR_WRITE_NOT_PERMITTED              0x03
11024c1900e6SMatthias Ringwald #define ATT_ERROR_INVALID_PDU                      0x04
11034c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_AUTHENTICATION      0x05
11044c1900e6SMatthias Ringwald #define ATT_ERROR_REQUEST_NOT_SUPPORTED            0x06
11054c1900e6SMatthias Ringwald #define ATT_ERROR_INVALID_OFFSET                   0x07
11064c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_AUTHORIZATION       0x08
11074c1900e6SMatthias Ringwald #define ATT_ERROR_PREPARE_QUEUE_FULL               0x09
11084c1900e6SMatthias Ringwald #define ATT_ERROR_ATTRIBUTE_NOT_FOUND              0x0a
11094c1900e6SMatthias Ringwald #define ATT_ERROR_ATTRIBUTE_NOT_LONG               0x0b
11104c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_ENCRYPTION_KEY_SIZE 0x0c
11114c1900e6SMatthias Ringwald #define ATT_ERROR_INVALID_ATTRIBUTE_VALUE_LENGTH   0x0d
11124c1900e6SMatthias Ringwald #define ATT_ERROR_UNLIKELY_ERROR                   0x0e
11134c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_ENCRYPTION          0x0f
11144c1900e6SMatthias Ringwald #define ATT_ERROR_UNSUPPORTED_GROUP_TYPE           0x10
11154c1900e6SMatthias Ringwald #define ATT_ERROR_INSUFFICIENT_RESOURCES           0x11
1116204991f3SMilanka Ringwald 
1117793cf6ceSMatthias Ringwald // MARK: ATT Error Codes used internally by BTstack
1118793cf6ceSMatthias Ringwald #define ATT_ERROR_BONDING_INFORMATION_MISSING      0x70
1119793cf6ceSMatthias Ringwald 
1120204991f3SMilanka Ringwald // MARK: ATT Error Codes from Cycling Power Service spec
1121204991f3SMilanka Ringwald #define CYCLING_POWER_ERROR_CODE_INAPPROPRIATE_CONNECTION_PARAMETERS                          0x80
1122204991f3SMilanka Ringwald #define CYCLING_POWER_ERROR_CODE_PROCEDURE_ALREADY_IN_PROGRESS                                0xFE
1123204991f3SMilanka Ringwald #define CYCLING_POWER_ERROR_CODE_CCC_DESCRIPTOR_IMPROPERLY_CONFIGURED                         0xFD
1124204991f3SMilanka Ringwald 
1125204991f3SMilanka Ringwald // MARK: ATT Error Codes from Cycling Speed and Cadence Service spec
1126204991f3SMilanka Ringwald #define CYCLING_SPEED_AND_CADENCE_ERROR_CODE_PROCEDURE_ALREADY_IN_PROGRESS                    0x80
1127204991f3SMilanka Ringwald #define CYCLING_SPEED_AND_CADENCE_ERROR_CODE_CCC_DESCRIPTOR_IMPROPERLY_CONFIGURED             0x81
1128204991f3SMilanka Ringwald 
11294c1900e6SMatthias Ringwald 
11304c1900e6SMatthias Ringwald // MARK: Attribute Property Flags
11314c1900e6SMatthias Ringwald #define ATT_PROPERTY_BROADCAST           0x01
11324c1900e6SMatthias Ringwald #define ATT_PROPERTY_READ                0x02
11334c1900e6SMatthias Ringwald #define ATT_PROPERTY_WRITE_WITHOUT_RESPONSE 0x04
11344c1900e6SMatthias Ringwald #define ATT_PROPERTY_WRITE               0x08
11354c1900e6SMatthias Ringwald #define ATT_PROPERTY_NOTIFY              0x10
11364c1900e6SMatthias Ringwald #define ATT_PROPERTY_INDICATE            0x20
11374c1900e6SMatthias Ringwald #define ATT_PROPERTY_AUTHENTICATED_SIGNED_WRITE 0x40
11384c1900e6SMatthias Ringwald #define ATT_PROPERTY_EXTENDED_PROPERTIES 0x80
11394c1900e6SMatthias Ringwald 
11404c1900e6SMatthias Ringwald // MARK: Attribute Property Flag, BTstack extension
11414c1900e6SMatthias Ringwald // value is asked from client
11424c1900e6SMatthias Ringwald #define ATT_PROPERTY_DYNAMIC             0x100
1143ff04bac7SMatthias Ringwald 
1144ff04bac7SMatthias Ringwald // Security levels
1145ff04bac7SMatthias Ringwald #define ATT_SECURITY_NONE 0
1146ff04bac7SMatthias Ringwald #define ATT_SECURITY_ENCRYPTED 1
1147ff04bac7SMatthias Ringwald #define ATT_SECURITY_AUTHENTICATED 2
1148ff04bac7SMatthias Ringwald #define ATT_SECURITY_AUTHORIZED 3
1149bb96f9f8SMatthias Ringwald #define ATT_SECURITY_AUTHENTICATED_SC 4
1150ff04bac7SMatthias Ringwald 
1151ff04bac7SMatthias Ringwald // internal additions
11524c1900e6SMatthias Ringwald // 128 bit UUID used
11534c1900e6SMatthias Ringwald #define ATT_PROPERTY_UUID128             0x200
115493fc3012SMatthias Ringwald // Read/Write Permission bits
115593fc3012SMatthias Ringwald #define ATT_PROPERTY_READ_PERMISSION_BIT_0  0x0400
115693fc3012SMatthias Ringwald #define ATT_PROPERTY_READ_PERMISSION_BIT_1  0x0800
115793fc3012SMatthias Ringwald #define ATT_PROPERTY_WRITE_PERMISSION_BIT_0 0x0001
115893fc3012SMatthias Ringwald #define ATT_PROPERTY_WRITE_PERMISSION_BIT_1 0x0010
1159bb96f9f8SMatthias Ringwald #define ATT_PROPERTY_READ_PERMISSION_SC     0x0020
1160bb96f9f8SMatthias Ringwald #define ATT_PROPERTY_WRITE_PERMISSION_SC    0x0080
116193fc3012SMatthias Ringwald 
11624c1900e6SMatthias Ringwald 
11639b31df63SMatthias Ringwald // ATT Transaction Timeout of 30 seconds for Command/Response or Indication/Confirmation
11644c1900e6SMatthias Ringwald #define ATT_TRANSACTION_TIMEOUT_MS     30000
11654c1900e6SMatthias Ringwald 
11664c1900e6SMatthias Ringwald #define ATT_TRANSACTION_MODE_NONE      0x0
11674c1900e6SMatthias Ringwald #define ATT_TRANSACTION_MODE_ACTIVE    0x1
11684c1900e6SMatthias Ringwald #define ATT_TRANSACTION_MODE_EXECUTE   0x2
11694c1900e6SMatthias Ringwald #define ATT_TRANSACTION_MODE_CANCEL    0x3
11709b31df63SMatthias Ringwald #define ATT_TRANSACTION_MODE_VALIDATE  0x4
11714c1900e6SMatthias Ringwald 
11724c1900e6SMatthias Ringwald // MARK: GATT UUIDs
11734c1900e6SMatthias Ringwald #define GATT_PRIMARY_SERVICE_UUID                   0x2800
11744c1900e6SMatthias Ringwald #define GATT_SECONDARY_SERVICE_UUID                 0x2801
11754c1900e6SMatthias Ringwald #define GATT_INCLUDE_SERVICE_UUID                   0x2802
11764c1900e6SMatthias Ringwald #define GATT_CHARACTERISTICS_UUID                   0x2803
11774c1900e6SMatthias Ringwald #define GATT_CHARACTERISTIC_EXTENDED_PROPERTIES     0x2900
11784c1900e6SMatthias Ringwald #define GATT_CHARACTERISTIC_USER_DESCRIPTION        0x2901
11794c1900e6SMatthias Ringwald #define GATT_CLIENT_CHARACTERISTICS_CONFIGURATION   0x2902
11804c1900e6SMatthias Ringwald #define GATT_SERVER_CHARACTERISTICS_CONFIGURATION   0x2903
11814c1900e6SMatthias Ringwald #define GATT_CHARACTERISTIC_PRESENTATION_FORMAT     0x2904
11824c1900e6SMatthias Ringwald #define GATT_CHARACTERISTIC_AGGREGATE_FORMAT        0x2905
11834c1900e6SMatthias Ringwald 
11844c1900e6SMatthias Ringwald #define GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NONE          0
11854c1900e6SMatthias Ringwald #define GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NOTIFICATION  1
11864c1900e6SMatthias Ringwald #define GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_INDICATION    2
11874c1900e6SMatthias Ringwald 
11884c1900e6SMatthias Ringwald // GAP Service and Characteristics
11894c1900e6SMatthias Ringwald #define GAP_SERVICE_UUID               0x1800
11904c1900e6SMatthias Ringwald #define GAP_DEVICE_NAME_UUID           0x2a00
11914c1900e6SMatthias Ringwald #define GAP_APPEARANCE_UUID            0x2a01
11924c1900e6SMatthias Ringwald #define GAP_PERIPHERAL_PRIVACY_FLAG    0x2a02
11934c1900e6SMatthias Ringwald #define GAP_RECONNECTION_ADDRESS_UUID  0x2a03
11944c1900e6SMatthias Ringwald #define GAP_PERIPHERAL_PREFERRED_CONNECTION_PARAMETERS_UUID 0x2a04
119517fe8172SMatthias Ringwald #define GAP_SERVICE_CHANGED            0x2a05
11964c1900e6SMatthias Ringwald 
1197bb7f3677SMilanka Ringwald // Bluetooth GATT types
1198bb7f3677SMilanka Ringwald 
1199bb7f3677SMilanka Ringwald typedef struct {
1200bb7f3677SMilanka Ringwald     uint16_t year;      // 0 - year  is not known; or [1582,9999]
1201bb7f3677SMilanka Ringwald     uint8_t  month;     // 0 - month is not known; or [1,12]
1202bb7f3677SMilanka Ringwald     uint8_t  day;       // 0 - day   is not known; or [1,31]
1203bb7f3677SMilanka Ringwald     uint8_t  hours;     // [0,23]
1204bb7f3677SMilanka Ringwald     uint8_t  minutes;   // [0,59]
1205bb7f3677SMilanka Ringwald     uint8_t  seconds;   // [0,59]
1206bb7f3677SMilanka Ringwald } gatt_date_time_t;
1207bb7f3677SMilanka Ringwald 
12084c1900e6SMatthias Ringwald /**
12094c1900e6SMatthias Ringwald  * SM - LE Security Manager
12104c1900e6SMatthias Ringwald  */
12114c1900e6SMatthias Ringwald // Bluetooth Spec definitions
12124c1900e6SMatthias Ringwald typedef enum {
12134c1900e6SMatthias Ringwald     SM_CODE_PAIRING_REQUEST = 0X01,
12144c1900e6SMatthias Ringwald     SM_CODE_PAIRING_RESPONSE,
12154c1900e6SMatthias Ringwald     SM_CODE_PAIRING_CONFIRM,
12164c1900e6SMatthias Ringwald     SM_CODE_PAIRING_RANDOM,
12174c1900e6SMatthias Ringwald     SM_CODE_PAIRING_FAILED,
12184c1900e6SMatthias Ringwald     SM_CODE_ENCRYPTION_INFORMATION,
12194c1900e6SMatthias Ringwald     SM_CODE_MASTER_IDENTIFICATION,
12204c1900e6SMatthias Ringwald     SM_CODE_IDENTITY_INFORMATION,
12214c1900e6SMatthias Ringwald     SM_CODE_IDENTITY_ADDRESS_INFORMATION,
12224c1900e6SMatthias Ringwald     SM_CODE_SIGNING_INFORMATION,
122374a9b3d5SMatthias Ringwald     SM_CODE_SECURITY_REQUEST,
122474a9b3d5SMatthias Ringwald     SM_CODE_PAIRING_PUBLIC_KEY,
122574a9b3d5SMatthias Ringwald     SM_CODE_PAIRING_DHKEY_CHECK,
122644e8d9acSMatthias Ringwald     SM_CODE_KEYPRESS_NOTIFICATION,
12274c1900e6SMatthias Ringwald } SECURITY_MANAGER_COMMANDS;
12284c1900e6SMatthias Ringwald 
12294c1900e6SMatthias Ringwald // IO Capability Values
12304c1900e6SMatthias Ringwald typedef enum {
12314c1900e6SMatthias Ringwald     IO_CAPABILITY_DISPLAY_ONLY = 0,
12324c1900e6SMatthias Ringwald     IO_CAPABILITY_DISPLAY_YES_NO,
12334c1900e6SMatthias Ringwald     IO_CAPABILITY_KEYBOARD_ONLY,
12344c1900e6SMatthias Ringwald     IO_CAPABILITY_NO_INPUT_NO_OUTPUT,
12354c1900e6SMatthias Ringwald     IO_CAPABILITY_KEYBOARD_DISPLAY, // not used by secure simple pairing
12364c1900e6SMatthias Ringwald } io_capability_t;
12374c1900e6SMatthias Ringwald 
12384c1900e6SMatthias Ringwald // Authentication requirement flags
12394c1900e6SMatthias Ringwald #define SM_AUTHREQ_NO_BONDING        0x00
12404c1900e6SMatthias Ringwald #define SM_AUTHREQ_BONDING           0x01
12414c1900e6SMatthias Ringwald #define SM_AUTHREQ_MITM_PROTECTION   0x04
124274a9b3d5SMatthias Ringwald #define SM_AUTHREQ_SECURE_CONNECTION 0x08
124374a9b3d5SMatthias Ringwald #define SM_AUTHREQ_KEYPRESS          0x10
12444c1900e6SMatthias Ringwald 
12454c1900e6SMatthias Ringwald // Key distribution flags used by spec
124652f9cf63SMatthias Ringwald #define SM_KEYDIST_ENC_KEY  0x01
12474c1900e6SMatthias Ringwald #define SM_KEYDIST_ID_KEY   0x02
12484c1900e6SMatthias Ringwald #define SM_KEYDIST_SIGN     0x04
124952f9cf63SMatthias Ringwald #define SM_KEYDIST_LINK_KEY 0x08
12504c1900e6SMatthias Ringwald 
12514c1900e6SMatthias Ringwald // Key distribution flags used internally
12524c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_ENCRYPTION_INFORMATION       0x01
12534c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_MASTER_IDENTIFICATION        0x02
12544c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_IDENTITY_INFORMATION         0x04
12554c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_IDENTITY_ADDRESS_INFORMATION 0x08
12564c1900e6SMatthias Ringwald #define SM_KEYDIST_FLAG_SIGNING_IDENTIFICATION       0x10
12574c1900e6SMatthias Ringwald 
12584c1900e6SMatthias Ringwald // STK Generation Methods
12594c1900e6SMatthias Ringwald #define SM_STK_GENERATION_METHOD_JUST_WORKS          0x01
12604c1900e6SMatthias Ringwald #define SM_STK_GENERATION_METHOD_OOB                 0x02
12614c1900e6SMatthias Ringwald #define SM_STK_GENERATION_METHOD_PASSKEY             0x04
1262b4343428SMatthias Ringwald #define SM_STK_GENERATION_METHOD_NUMERIC_COMPARISON  0x08
12634c1900e6SMatthias Ringwald 
12644c1900e6SMatthias Ringwald // Pairing Failed Reasons
12654c1900e6SMatthias Ringwald #define SM_REASON_RESERVED                     0x00
126616a1a3e5SMatthias Ringwald #define SM_REASON_PASSKEY_ENTRY_FAILED         0x01
12674c1900e6SMatthias Ringwald #define SM_REASON_OOB_NOT_AVAILABLE            0x02
12684c1900e6SMatthias Ringwald #define SM_REASON_AUTHENTHICATION_REQUIREMENTS 0x03
12694c1900e6SMatthias Ringwald #define SM_REASON_CONFIRM_VALUE_FAILED         0x04
12704c1900e6SMatthias Ringwald #define SM_REASON_PAIRING_NOT_SUPPORTED        0x05
12714c1900e6SMatthias Ringwald #define SM_REASON_ENCRYPTION_KEY_SIZE          0x06
12724c1900e6SMatthias Ringwald #define SM_REASON_COMMAND_NOT_SUPPORTED        0x07
12734c1900e6SMatthias Ringwald #define SM_REASON_UNSPECIFIED_REASON           0x08
12744c1900e6SMatthias Ringwald #define SM_REASON_REPEATED_ATTEMPTS            0x09
1275a9f29768SMatthias Ringwald #define SM_REASON_INVALID_PARAMETERS           0x0a
1276a9f29768SMatthias Ringwald #define SM_REASON_DHKEY_CHECK_FAILED           0x0b
1277a9f29768SMatthias Ringwald #define SM_REASON_NUMERIC_COMPARISON_FAILED    0x0c
1278a9f29768SMatthias Ringwald 
12794c1900e6SMatthias Ringwald // also, invalid parameters
12804c1900e6SMatthias Ringwald // and reserved
12814c1900e6SMatthias Ringwald 
128244e8d9acSMatthias Ringwald // Keypress Notifications
128344e8d9acSMatthias Ringwald #define SM_KEYPRESS_PASSKEY_ENTRY_STARTED      0x00
128444e8d9acSMatthias Ringwald #define SM_KEYPRESS_PASSKEY_DIGIT_ENTERED      0x01
128544e8d9acSMatthias Ringwald #define SM_KEYPRESS_PASSKEY_DIGIT_ERASED       0x02
128644e8d9acSMatthias Ringwald #define SM_KEYPRESS_PASSKEY_CLEARED            0x03
128744e8d9acSMatthias Ringwald #define SM_KEYPRESS_PASSKEY_ENTRY_COMPLETED    0x04
128844e8d9acSMatthias Ringwald 
128944e8d9acSMatthias Ringwald 
129047f4e325SMatthias Ringwald #endif
1291