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 #define BT_CONNECT_NUM_MAX 6 26 27 #define BT_NO_ERROR 0 28 #define BT_OPERATION_FAILED (-1) 29 #define BT_BAD_PARAM (-1000) 30 #define BT_BAD_STATUS (-1001) 31 #define BT_TIMEOUT (-1002) 32 #define BT_OS_ERROR (-1003) 33 #define BT_NO_MEMORY (-1004) 34 #define BT_IO_ERROR (-1005) 35 #define BT_CREATE_FILE (-1006) 36 #define BT_CONFIG_ERROR (-1007) 37 #define BT_DEVICE_ERROR (-1008) 38 39 #define BT_NOT_SUPPORT (-2000) 40 #define BT_ALREADY (-2001) 41 42 #define BT_ADDRESS_SIZE 6 43 44 #define BT_PUBLIC_DEVICE_ADDRESS 0x00 45 #define BT_RANDOM_DEVICE_ADDRESS 0x01 46 #define BT_PUBLIC_IDENTITY_ADDRESS 0x02 47 #define BT_RANDOM_IDENTITY_ADDRESS 0x03 48 49 typedef struct { 50 uint8_t addr[6]; 51 uint8_t type; 52 } BtAddr; 53 54 #define BT_UUID_16 0x01 55 #define BT_UUID_32 0x02 56 #define BT_UUID_128 0x03 57 58 typedef struct { 59 uint8_t type; 60 union { 61 uint16_t uuid16; 62 uint32_t uuid32; 63 uint8_t uuid128[16]; 64 }; 65 } BtUuid; 66 67 #define L2CAP_MTU_SIZE 1691 68 #define SCO_HOST_BUFFER_SIZE 255 69 #define HOST_ACL_DATA_PACKETS 20 70 #define HOST_SCO_DATA_PACKETS 10 71 72 // The Link Manager Version parameter 73 // The HCI Version 74 #define BLUETOOTH_CORE_SPECIFICATION_1_0 0 // Bluetooth® Core Specification 1.0b (Withdrawn) 75 #define BLUETOOTH_CORE_SPECIFICATION_1_1 1 // Bluetooth Core Specification 1.1 (Withdrawn) 76 #define BLUETOOTH_CORE_SPECIFICATION_1_2 2 // Bluetooth Core Specification 1.2 (Withdrawn) 77 #define BLUETOOTH_CORE_SPECIFICATION_2_0 3 // Bluetooth Core Specification 2.0 + EDR (Withdrawn) 78 #define BLUETOOTH_CORE_SPECIFICATION_2_1 4 // Bluetooth Core Specification 2.1 + EDR (Withdrawn) 79 #define BLUETOOTH_CORE_SPECIFICATION_3_0 5 // Bluetooth Core Specification 3.0 + HS (Withdrawn) 80 #define BLUETOOTH_CORE_SPECIFICATION_4_0 6 // Bluetooth Core Specification 4.0 81 #define BLUETOOTH_CORE_SPECIFICATION_4_1 7 // Bluetooth Core Specification 4.1 82 #define BLUETOOTH_CORE_SPECIFICATION_4_2 8 // Bluetooth Core Specification 4.2 83 #define BLUETOOTH_CORE_SPECIFICATION_5_0 9 // Bluetooth Core Specification 5.0 84 #define BLUETOOTH_CORE_SPECIFICATION_5_1 10 // Bluetooth Core Specification 5.1 85 #define BLUETOOTH_CORE_SPECIFICATION_5_2 11 // Bluetooth Core Specification 5.2 86 87 // Modules 88 #define MODULE_NAME_HCI "hci" 89 #define MODULE_NAME_GAP "gap" 90 #define MODULE_NAME_L2CAP "l2cap" 91 #define MODULE_NAME_AVDTP "avdtp" 92 #define MODULE_NAME_AVCTP "avctp" 93 #define MODULE_NAME_RFCOMM "rfcomm" 94 #define MODULE_NAME_SDP "sdp" 95 #define MODULE_NAME_ATT "att" 96 #define MODULE_NAME_SMP "smp" 97 98 // Transport 99 #define TRANSPORT_BREDR 1 100 #define TRANSPORT_LE 2 101 102 #ifdef BLUETOOTH_EXPORT 103 #define BTSTACK_API __attribute__((visibility("default"))) 104 #else 105 #define BTSTACK_API 106 #endif 107 108 #ifdef __cplusplus 109 } 110 #endif // __cplusplus 111 112 #endif // BT_STACK_H 113