1 /* 2 * Copyright (C) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef BT_STACK_H 16 #define BT_STACK_H 17 18 #include <stdint.h> 19 #include <stddef.h> 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 #ifndef NO_SANITIZE 26 #ifdef __has_attribute 27 #if __has_attribute(no_sanitize) 28 #define NO_SANITIZE(type) __attribute__((no_sanitize(type))) 29 #endif 30 #endif 31 #endif 32 33 #ifndef NO_SANITIZE 34 #define NO_SANITIZE(type) 35 #endif 36 37 #define BT_CONNECT_NUM_MAX 6 38 39 #define BT_SUCCESS 0 40 #define BT_OPERATION_FAILED (-1) 41 #define BT_BAD_PARAM (-1000) 42 #define BT_BAD_STATUS (-1001) 43 #define BT_TIMEOUT (-1002) 44 #define BT_OS_ERROR (-1003) 45 #define BT_NO_MEMORY (-1004) 46 #define BT_IO_ERROR (-1005) 47 #define BT_CREATE_FILE (-1006) 48 #define BT_CONFIG_ERROR (-1007) 49 #define BT_DEVICE_ERROR (-1008) 50 51 #define BT_NOT_SUPPORT (-2000) 52 #define BT_ALREADY (-2001) 53 54 #define BT_ADDRESS_SIZE 6 55 56 #define BT_PUBLIC_DEVICE_ADDRESS 0x00 57 #define BT_RANDOM_DEVICE_ADDRESS 0x01 58 #define BT_PUBLIC_IDENTITY_ADDRESS 0x02 59 #define BT_RANDOM_IDENTITY_ADDRESS 0x03 60 61 typedef struct { 62 uint8_t addr[6]; 63 uint8_t type; 64 } BtAddr; 65 66 #define BT_UUID_16 0x01 67 #define BT_UUID_32 0x02 68 #define BT_UUID_128 0x03 69 70 typedef struct { 71 uint8_t type; 72 union { 73 uint16_t uuid16; 74 uint32_t uuid32; 75 uint8_t uuid128[16]; 76 }; 77 } BtUuid; 78 79 #define L2CAP_MTU_SIZE 1691 80 #define SCO_HOST_BUFFER_SIZE 255 81 #define HOST_ACL_DATA_PACKETS 20 82 #define HOST_SCO_DATA_PACKETS 10 83 84 // The Link Manager Version parameter 85 // The HCI Version 86 #define BLUETOOTH_CORE_SPECIFICATION_1_0 0 // Bluetooth® Core Specification 1.0b (Withdrawn) 87 #define BLUETOOTH_CORE_SPECIFICATION_1_1 1 // Bluetooth Core Specification 1.1 (Withdrawn) 88 #define BLUETOOTH_CORE_SPECIFICATION_1_2 2 // Bluetooth Core Specification 1.2 (Withdrawn) 89 #define BLUETOOTH_CORE_SPECIFICATION_2_0 3 // Bluetooth Core Specification 2.0 + EDR (Withdrawn) 90 #define BLUETOOTH_CORE_SPECIFICATION_2_1 4 // Bluetooth Core Specification 2.1 + EDR (Withdrawn) 91 #define BLUETOOTH_CORE_SPECIFICATION_3_0 5 // Bluetooth Core Specification 3.0 + HS (Withdrawn) 92 #define BLUETOOTH_CORE_SPECIFICATION_4_0 6 // Bluetooth Core Specification 4.0 93 #define BLUETOOTH_CORE_SPECIFICATION_4_1 7 // Bluetooth Core Specification 4.1 94 #define BLUETOOTH_CORE_SPECIFICATION_4_2 8 // Bluetooth Core Specification 4.2 95 #define BLUETOOTH_CORE_SPECIFICATION_5_0 9 // Bluetooth Core Specification 5.0 96 #define BLUETOOTH_CORE_SPECIFICATION_5_1 10 // Bluetooth Core Specification 5.1 97 #define BLUETOOTH_CORE_SPECIFICATION_5_2 11 // Bluetooth Core Specification 5.2 98 99 // Modules 100 #define MODULE_NAME_HCI "hci" 101 #define MODULE_NAME_GAP "gap" 102 #define MODULE_NAME_L2CAP "l2cap" 103 #define MODULE_NAME_AVDTP "avdtp" 104 #define MODULE_NAME_AVCTP "avctp" 105 #define MODULE_NAME_RFCOMM "rfcomm" 106 #define MODULE_NAME_SDP "sdp" 107 #define MODULE_NAME_ATT "att" 108 #define MODULE_NAME_SMP "smp" 109 110 // Transport 111 #define TRANSPORT_BREDR 1 112 #define TRANSPORT_LE 2 113 114 #ifdef BLUETOOTH_EXPORT 115 #define BTSTACK_API __attribute__((visibility("default"))) 116 #else 117 #define BTSTACK_API 118 #endif 119 120 #ifdef __cplusplus 121 } 122 #endif // __cplusplus 123 124 #endif // BT_STACK_H 125