119e95205Sopenharmony_ci/* 219e95205Sopenharmony_ci * Copyright (C) 2021 Huawei Device Co., Ltd. 319e95205Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 419e95205Sopenharmony_ci * you may not use this file except in compliance with the License. 519e95205Sopenharmony_ci * You may obtain a copy of the License at 619e95205Sopenharmony_ci * 719e95205Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 819e95205Sopenharmony_ci * 919e95205Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1019e95205Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1119e95205Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1219e95205Sopenharmony_ci * See the License for the specific language governing permissions and 1319e95205Sopenharmony_ci * limitations under the License. 1419e95205Sopenharmony_ci */ 1519e95205Sopenharmony_ci#ifndef BT_STACK_H 1619e95205Sopenharmony_ci#define BT_STACK_H 1719e95205Sopenharmony_ci 1819e95205Sopenharmony_ci#include <stdint.h> 1919e95205Sopenharmony_ci#include <stddef.h> 2019e95205Sopenharmony_ci 2119e95205Sopenharmony_ci#ifdef __cplusplus 2219e95205Sopenharmony_ciextern "C" { 2319e95205Sopenharmony_ci#endif 2419e95205Sopenharmony_ci 2519e95205Sopenharmony_ci#ifndef NO_SANITIZE 2619e95205Sopenharmony_ci#ifdef __has_attribute 2719e95205Sopenharmony_ci#if __has_attribute(no_sanitize) 2819e95205Sopenharmony_ci#define NO_SANITIZE(type) __attribute__((no_sanitize(type))) 2919e95205Sopenharmony_ci#endif 3019e95205Sopenharmony_ci#endif 3119e95205Sopenharmony_ci#endif 3219e95205Sopenharmony_ci 3319e95205Sopenharmony_ci#ifndef NO_SANITIZE 3419e95205Sopenharmony_ci#define NO_SANITIZE(type) 3519e95205Sopenharmony_ci#endif 3619e95205Sopenharmony_ci 3719e95205Sopenharmony_ci#define BT_CONNECT_NUM_MAX 6 3819e95205Sopenharmony_ci 3919e95205Sopenharmony_ci#define BT_SUCCESS 0 4019e95205Sopenharmony_ci#define BT_OPERATION_FAILED (-1) 4119e95205Sopenharmony_ci#define BT_BAD_PARAM (-1000) 4219e95205Sopenharmony_ci#define BT_BAD_STATUS (-1001) 4319e95205Sopenharmony_ci#define BT_TIMEOUT (-1002) 4419e95205Sopenharmony_ci#define BT_OS_ERROR (-1003) 4519e95205Sopenharmony_ci#define BT_NO_MEMORY (-1004) 4619e95205Sopenharmony_ci#define BT_IO_ERROR (-1005) 4719e95205Sopenharmony_ci#define BT_CREATE_FILE (-1006) 4819e95205Sopenharmony_ci#define BT_CONFIG_ERROR (-1007) 4919e95205Sopenharmony_ci#define BT_DEVICE_ERROR (-1008) 5019e95205Sopenharmony_ci 5119e95205Sopenharmony_ci#define BT_NOT_SUPPORT (-2000) 5219e95205Sopenharmony_ci#define BT_ALREADY (-2001) 5319e95205Sopenharmony_ci 5419e95205Sopenharmony_ci#define BT_ADDRESS_SIZE 6 5519e95205Sopenharmony_ci 5619e95205Sopenharmony_ci#define BT_PUBLIC_DEVICE_ADDRESS 0x00 5719e95205Sopenharmony_ci#define BT_RANDOM_DEVICE_ADDRESS 0x01 5819e95205Sopenharmony_ci#define BT_PUBLIC_IDENTITY_ADDRESS 0x02 5919e95205Sopenharmony_ci#define BT_RANDOM_IDENTITY_ADDRESS 0x03 6019e95205Sopenharmony_ci 6119e95205Sopenharmony_citypedef struct { 6219e95205Sopenharmony_ci uint8_t addr[6]; 6319e95205Sopenharmony_ci uint8_t type; 6419e95205Sopenharmony_ci} BtAddr; 6519e95205Sopenharmony_ci 6619e95205Sopenharmony_ci#define BT_UUID_16 0x01 6719e95205Sopenharmony_ci#define BT_UUID_32 0x02 6819e95205Sopenharmony_ci#define BT_UUID_128 0x03 6919e95205Sopenharmony_ci 7019e95205Sopenharmony_citypedef struct { 7119e95205Sopenharmony_ci uint8_t type; 7219e95205Sopenharmony_ci union { 7319e95205Sopenharmony_ci uint16_t uuid16; 7419e95205Sopenharmony_ci uint32_t uuid32; 7519e95205Sopenharmony_ci uint8_t uuid128[16]; 7619e95205Sopenharmony_ci }; 7719e95205Sopenharmony_ci} BtUuid; 7819e95205Sopenharmony_ci 7919e95205Sopenharmony_ci#define L2CAP_MTU_SIZE 1691 8019e95205Sopenharmony_ci#define SCO_HOST_BUFFER_SIZE 255 8119e95205Sopenharmony_ci#define HOST_ACL_DATA_PACKETS 20 8219e95205Sopenharmony_ci#define HOST_SCO_DATA_PACKETS 10 8319e95205Sopenharmony_ci 8419e95205Sopenharmony_ci// The Link Manager Version parameter 8519e95205Sopenharmony_ci// The HCI Version 8619e95205Sopenharmony_ci#define BLUETOOTH_CORE_SPECIFICATION_1_0 0 // Bluetooth® Core Specification 1.0b (Withdrawn) 8719e95205Sopenharmony_ci#define BLUETOOTH_CORE_SPECIFICATION_1_1 1 // Bluetooth Core Specification 1.1 (Withdrawn) 8819e95205Sopenharmony_ci#define BLUETOOTH_CORE_SPECIFICATION_1_2 2 // Bluetooth Core Specification 1.2 (Withdrawn) 8919e95205Sopenharmony_ci#define BLUETOOTH_CORE_SPECIFICATION_2_0 3 // Bluetooth Core Specification 2.0 + EDR (Withdrawn) 9019e95205Sopenharmony_ci#define BLUETOOTH_CORE_SPECIFICATION_2_1 4 // Bluetooth Core Specification 2.1 + EDR (Withdrawn) 9119e95205Sopenharmony_ci#define BLUETOOTH_CORE_SPECIFICATION_3_0 5 // Bluetooth Core Specification 3.0 + HS (Withdrawn) 9219e95205Sopenharmony_ci#define BLUETOOTH_CORE_SPECIFICATION_4_0 6 // Bluetooth Core Specification 4.0 9319e95205Sopenharmony_ci#define BLUETOOTH_CORE_SPECIFICATION_4_1 7 // Bluetooth Core Specification 4.1 9419e95205Sopenharmony_ci#define BLUETOOTH_CORE_SPECIFICATION_4_2 8 // Bluetooth Core Specification 4.2 9519e95205Sopenharmony_ci#define BLUETOOTH_CORE_SPECIFICATION_5_0 9 // Bluetooth Core Specification 5.0 9619e95205Sopenharmony_ci#define BLUETOOTH_CORE_SPECIFICATION_5_1 10 // Bluetooth Core Specification 5.1 9719e95205Sopenharmony_ci#define BLUETOOTH_CORE_SPECIFICATION_5_2 11 // Bluetooth Core Specification 5.2 9819e95205Sopenharmony_ci 9919e95205Sopenharmony_ci// Modules 10019e95205Sopenharmony_ci#define MODULE_NAME_HCI "hci" 10119e95205Sopenharmony_ci#define MODULE_NAME_GAP "gap" 10219e95205Sopenharmony_ci#define MODULE_NAME_L2CAP "l2cap" 10319e95205Sopenharmony_ci#define MODULE_NAME_AVDTP "avdtp" 10419e95205Sopenharmony_ci#define MODULE_NAME_AVCTP "avctp" 10519e95205Sopenharmony_ci#define MODULE_NAME_RFCOMM "rfcomm" 10619e95205Sopenharmony_ci#define MODULE_NAME_SDP "sdp" 10719e95205Sopenharmony_ci#define MODULE_NAME_ATT "att" 10819e95205Sopenharmony_ci#define MODULE_NAME_SMP "smp" 10919e95205Sopenharmony_ci 11019e95205Sopenharmony_ci// Transport 11119e95205Sopenharmony_ci#define TRANSPORT_BREDR 1 11219e95205Sopenharmony_ci#define TRANSPORT_LE 2 11319e95205Sopenharmony_ci 11419e95205Sopenharmony_ci#ifdef BLUETOOTH_EXPORT 11519e95205Sopenharmony_ci#define BTSTACK_API __attribute__((visibility("default"))) 11619e95205Sopenharmony_ci#else 11719e95205Sopenharmony_ci#define BTSTACK_API 11819e95205Sopenharmony_ci#endif 11919e95205Sopenharmony_ci 12019e95205Sopenharmony_ci#ifdef __cplusplus 12119e95205Sopenharmony_ci} 12219e95205Sopenharmony_ci#endif // __cplusplus 12319e95205Sopenharmony_ci 12419e95205Sopenharmony_ci#endif // BT_STACK_H 125