diff --git a/bluetooth/bundle.json b/bluetooth/bundle.json new file mode 100644 index 0000000000000000000000000000000000000000..2ad4879961d78fc2298f3fae0eebb5fe8385bc03 --- /dev/null +++ b/bluetooth/bundle.json @@ -0,0 +1,50 @@ +{ + "name": "drivers_interface_bluetooth", + "description": "bluetooth device driver interface", + "version": "3.2", + "license": "Apache License 2.0", + "component": { + "name": "drivers_interface_bluetooth", + "subsystem": "hdf", + "syscap": [""], + "adapter_system_type": ["standard"], + "rom": "675KB", + "ram": "1024KB", + "deps": { + "components": [ + "ipc", + "hdf_core", + "hiviewdfx_hilog_native", + "utils_base" + ], + "third_part": [ + "bounds_checking_function" + ] + }, + "build": { + "sub_component": [ + "//drivers/interface/bluetooth/hci/v1_0:bluetooth_hci_idl_target" + ], + "test": [ + ], + "inner_kits": [ + { + "name": "//drivers/interface/bluetooth/hci/v1_0:libbluetooth_hci_proxy_1.0", + "header": { + "header_files": [ + ], + "header_base": "//drivers/interface/bluetooth/hci" + } + }, + { + "name": "//drivers/interface/bluetooth/hci/v1_0:bluetooth_hci_idl_headers", + "header": { + "header_files": [ + ], + "header_base": "//drivers/interface/bluetooth/hci" + } + } + ] + } + } + } \ No newline at end of file diff --git a/bluetooth/hci/v1_0/BUILD.gn b/bluetooth/hci/v1_0/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..eb386995071eca4c64714e73bfbb15822baec206 --- /dev/null +++ b/bluetooth/hci/v1_0/BUILD.gn @@ -0,0 +1,27 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") +hdi("bluetooth_hci") { + module_name = "bluetooth_hci" + + sources = [ + "HciTypes.idl", + "IHciCallback.idl", + "IHciInterface.idl", + ] + + language = "cpp" + subsystem_name = "hdf" + part_name = "drivers_interface_bluetooth" +} diff --git a/bluetooth/hci/v1_0/HciTypes.idl b/bluetooth/hci/v1_0/HciTypes.idl new file mode 100644 index 0000000000000000000000000000000000000000..a7535993a8035b3204ba75405ad852a882dcef18 --- /dev/null +++ b/bluetooth/hci/v1_0/HciTypes.idl @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * @addtogroup HdiHci + * @{ + * + * @brief Provides unified APIs for the HCI service. + * + * The Host can use the interface provided by the module to initialize the HCI(Host Controller Interface), + * and exchange data with the Controller through the service. + * + * @since 3.2 + */ + +/* + * @file HciTypes.idl + * + * @brief Defines the data structure used by the HCI module. + * + * @since 3.2 + * @version 1.0 + */ + +package ohos.hdi.bluetooth.hci.v1_0; + +/* + * @brief Defines the operation result of the interface. + * + * @since 3.2 + */ +enum BtStatus { + SUCCESS = 0, + INITIAL_ERROR = 1, + UNKNOWN = 2, +}; + +/* + * @brief Defines the data type transmitted over the HCI. + * + * @since 3.2 + */ +enum BtType { + HCI_CMD = 1, + ACL_DATA = 2, + SCO_DATA = 3, + HCI_EVENT = 4, + ISO_DATA = 5, +}; \ No newline at end of file diff --git a/bluetooth/hci/v1_0/IHciCallback.idl b/bluetooth/hci/v1_0/IHciCallback.idl new file mode 100644 index 0000000000000000000000000000000000000000..8b4ed7e2c69b25149dd9b2ae79e1fd37dbd8b853 --- /dev/null +++ b/bluetooth/hci/v1_0/IHciCallback.idl @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup HdiHci + * @{ + * + * @brief Provides unified APIs for the HCI service. + * + * The Host can use the interface provided by the module to initialize the HCI(Host Controller Interface), + * and exchange data with the Controller through the service. + * + * @since 3.2 + */ + +/** + * @file IHciCallback.idl + * + * @brief Defines the HCI callback function, including the initialization result and data received from the controller. + * + * @since 3.2 + * @version 1.0 + */ + +package ohos.hdi.bluetooth.hci.v1_0; + +import ohos.hdi.bluetooth.hci.v1_0.HciTypes; + +/** + * @brief Defines the HCI callback function, including the initialization result and data received from the controller. + * + * @since 3.2 + */ +[callback] interface IHciCallback { + /** + * @brief HCI initialization callback function. + * + * @param status Indicates the HCI initialization result. For details, see {@link BtStatus}. + * @return Returns 0 if the initialization result is returned successfully; returns a negative value otherwise. + * + * @since 3.2 + * @version 1.0 + */ + OnInited([in] enum BtStatus status); + + /** + * @brief Receives data packets sent by the controller.. + * + * @param type Indicates the HCI packet type. For details, see {@link BtType}. + * @param data Indicates the HCI data packets received from the Controller. + * @return Returns 0 if the data is received successfully; returns a negative value otherwise. + * + * @since 3.2 + * @version 1.0 + */ + OnReceivedHciPacket([in] enum BtType type, [in] unsigned char[] data); +} diff --git a/bluetooth/hci/v1_0/IHciInterface.idl b/bluetooth/hci/v1_0/IHciInterface.idl new file mode 100644 index 0000000000000000000000000000000000000000..f18b1275c17d6bfa395b668bd4f942c38c557768 --- /dev/null +++ b/bluetooth/hci/v1_0/IHciInterface.idl @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup HdiHci + * @{ + * + * @brief Provides unified APIs for the HCI service. + * + * The Host can use the interface provided by the module to initialize the HCI(Host Controller Interface), + * and exchange data with the Controller through the service. + * + * @since 3.2 + */ + +/** + * @file IHciInterface.idl + * + * @brief Defines the interfaces to initialize the HCI, send data to the Controller, + * and disable the HCI interface. + * + * @since 3.2 + * @version 1.0 + */ + +package ohos.hdi.bluetooth.hci.v1_0; + +import ohos.hdi.bluetooth.hci.v1_0.IHciCallback; +import ohos.hdi.bluetooth.hci.v1_0.HciTypes; + +/** + * @brief Defines the interfaces to initialize the HCI, send data to the Controller, + * and disable the HCI interface. + * + * @since 3.2 + */ +interface IHciInterface { + /** + * @brief Initialize the HCI and register the callback function. + * + * @param callbackObj Indicates the callback function. For details, see {@link IHciCallback}. + * @return Returns 0 if the HCI is initialized successfully; returns a negative value otherwise. + * + * @since 3.2 + * @version 1.0 + */ + Init([in] IHciCallback callbackObj); + + /** + * @brief Sends data packets to the Controller. + * + * @param type Indicates the HCI packet type. For details, see {@link BtType}. + * @param data Indicates the HCI data packets sent to the Controller. + * @return Returns 0 if the HCI data packets is sent successfully; returns a negative value otherwise. + * + * @since 3.2 + * @version 1.0 + */ + SendHciPacket([in] enum BtType type, [in] unsigned char[] data); + + /** + * @brief Disable the HCI interface. + * + * @return Returns 0 if the HCI is disabled successfully; returns a negative value otherwise. + * + * @since 3.2 + * @version 1.0 + */ + Close(); +}