diff --git a/api/@ohos.bluetooth.common.d.ts b/api/@ohos.bluetooth.common.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..88fb6ba59b8ca519ebec43e8cdbd08014a98e27e --- /dev/null +++ b/api/@ohos.bluetooth.common.d.ts @@ -0,0 +1,86 @@ + +/* + * Copyright (C) 2025 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. + */ + +/** + * @file + * @kit ConnectivityKit + */ + +/** + * Provide common Bluetooth interfaces and types. + * + * @namespace common + * @syscap SystemCapability.Communication.Bluetooth.Core + * @since 21 dynamic + * @since 22 static + */ +declare namespace common { + /** + * Describe the type of Bluetooth address. + * + * @typedef BluetoothAddress + * @syscap SystemCapability.Communication.Bluetooth.Core + * @since 21 dynamic + * @since 22 static + */ + export interface BluetoothAddress { + /** + * The string of the Bluetooth address. + * + * @type { string } + * @syscap SystemCapability.Communication.Bluetooth.Core + * @since 21 dynamic + * @since 22 static + */ + address: string; + /** + * The type of the Bluetooth address. + * + * @type { BluetoothAddressType } + * @syscap SystemCapability.Communication.Bluetooth.Core + * @since 21 dynamic + * @since 22 static + */ + addressType: BluetoothAddressType; + } + + /** + * Enum for the type of Bluetooth address. + * + * @enum { int } + * @syscap SystemCapability.Communication.Bluetooth.Core + * @since 21 dynamic + * @since 22 static + */ + export enum BluetoothAddressType { + /** + * virtual address. + * + * @syscap SystemCapability.Communication.Bluetooth.Core + * @since 21 dynamic + * @since 22 static + */ + VIRTUAL = 1, + /** + * real address. + * + * @syscap SystemCapability.Communication.Bluetooth.Core + * @since 21 dynamic + * @since 22 static + */ + REAL = 2 + } +} \ No newline at end of file diff --git a/api/@ohos.bluetooth.connection.d.ts b/api/@ohos.bluetooth.connection.d.ts index 4cd7019ad771958997ac46795bb2e7da73170ba3..1676f001f3f5dd6c4e5b067523cac36f817da620 100644 --- a/api/@ohos.bluetooth.connection.d.ts +++ b/api/@ohos.bluetooth.connection.d.ts @@ -20,6 +20,7 @@ import type { AsyncCallback, Callback } from './@ohos.base'; import type constant from './@ohos.bluetooth.constant'; +import type common from './@ohos.bluetooth.common'; /** * Provides methods to operate or manage Bluetooth. @@ -142,6 +143,16 @@ declare namespace connection { */ type MajorMinorClass = constant.MajorMinorClass; + /** + * Bluetooth device address. + * + * @typedef { common.BluetoothAddress } BluetoothAddress + * @syscap SystemCapability.Communication.Bluetooth.Core + * @since 21 dynamic + * @since 22 static + */ + type BluetoothAddress = common.BluetoothAddress; + /** * Get the profile connection state of the current device. * @@ -289,6 +300,24 @@ declare namespace connection { */ function pairDevice(deviceId: string): Promise; + /** + * Starts pairing with a remote Bluetooth device. + * + * @permission ohos.permission.ACCESS_BLUETOOTH + * @param { BluetoothAddress } deviceId - Indicates address of peer device. + * @returns { Promise } Returns the promise object. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth disabled. + * @throws { BusinessError } 2900099 - Operation failed. + * @syscap SystemCapability.Communication.Bluetooth.Core + * @crossplatform + * @since 21 dynamic + * @since 22 static + */ + function pairDevice(deviceId: BluetoothAddress): Promise; + /** * Starts pairing with a credible remote Bluetooth device with transport. * This interface does not trigger a dialog box and does not require user authorization. diff --git a/kits/@kit.ConnectivityKit.d.ts b/kits/@kit.ConnectivityKit.d.ts index cf228c106143a511857065c4fa0c94dcf0e88b46..8abb3083e54b03d5927a3cbcde241c147e98f44d 100644 --- a/kits/@kit.ConnectivityKit.d.ts +++ b/kits/@kit.ConnectivityKit.d.ts @@ -24,6 +24,7 @@ import baseProfile from '@ohos.bluetooth.baseProfile'; import ble from '@ohos.bluetooth.ble'; import connection from '@ohos.bluetooth.connection'; import constant from '@ohos.bluetooth.constant'; +import common from '@ohos.bluetooth.common'; import bluetooth from '@ohos.bluetooth'; import hfp from '@ohos.bluetooth.hfp'; import hid from '@ohos.bluetooth.hid'; @@ -52,5 +53,5 @@ export { BLEFoundResponse, Bluetooth, BluetoothDevice, StartBLEScanOptions, StopBLEScanOptions, SubscribeBLEFoundOptions, a2dp, access, baseProfile, ble, bluetooth, bluetoothManager, cardEmulation, connectedTag, connection, constant, hfp, hid, map, nfcController, omapi, opp, pan, pbap, socket, tag, wearDetection, wifi, - wifiManager, wifiManagerExt, wifiext + wifiManager, wifiManagerExt, wifiext, common };