From 421c41547c1599e9ffc8226c393a9ee689bd45dc Mon Sep 17 00:00:00 2001 From: gchen <2038454922@qq.com> Date: Fri, 12 Sep 2025 10:55:02 +0800 Subject: [PATCH 1/4] support real mac Signed-off-by: gchen <2038454922@qq.com> --- api/@ohos.bluetooth.common.d.ts | 86 +++++++++++++++++++++++++++++ api/@ohos.bluetooth.connection.d.ts | 11 ++++ 2 files changed, 97 insertions(+) create mode 100644 api/@ohos.bluetooth.common.d.ts diff --git a/api/@ohos.bluetooth.common.d.ts b/api/@ohos.bluetooth.common.d.ts new file mode 100644 index 0000000000..ec15b1511d --- /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 4cd7019ad7..60be2b4212 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. * -- Gitee From 25e8450663d12c6d455c8217fa04e5bdd7aa02d9 Mon Sep 17 00:00:00 2001 From: gchen <2038454922@qq.com> Date: Fri, 12 Sep 2025 11:16:33 +0800 Subject: [PATCH 2/4] support real mac Signed-off-by: gchen <2038454922@qq.com> --- api/@ohos.bluetooth.connection.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/@ohos.bluetooth.connection.d.ts b/api/@ohos.bluetooth.connection.d.ts index 60be2b4212..21346748e1 100644 --- a/api/@ohos.bluetooth.connection.d.ts +++ b/api/@ohos.bluetooth.connection.d.ts @@ -20,7 +20,7 @@ import type { AsyncCallback, Callback } from './@ohos.base'; import type constant from './@ohos.bluetooth.constant'; -import type common from './@ohos.bluetooth.common' +import type common from './@ohos.bluetooth.common'; /** * Provides methods to operate or manage Bluetooth. -- Gitee From 41cbc5977d2dc95fac9e907ff8ae2b9fb7ff4a38 Mon Sep 17 00:00:00 2001 From: gchen <2038454922@qq.com> Date: Fri, 12 Sep 2025 11:29:37 +0800 Subject: [PATCH 3/4] support real mac Signed-off-by: gchen <2038454922@qq.com> --- api/@ohos.bluetooth.connection.d.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/api/@ohos.bluetooth.connection.d.ts b/api/@ohos.bluetooth.connection.d.ts index 21346748e1..1676f001f3 100644 --- a/api/@ohos.bluetooth.connection.d.ts +++ b/api/@ohos.bluetooth.connection.d.ts @@ -300,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. -- Gitee From cce1cdeab522b99a6178422114dd8b78ca10112c Mon Sep 17 00:00:00 2001 From: gchen <2038454922@qq.com> Date: Sat, 13 Sep 2025 17:41:34 +0800 Subject: [PATCH 4/4] support real mac Signed-off-by: gchen <2038454922@qq.com> --- api/@ohos.bluetooth.common.d.ts | 28 ++++++++++++++-------------- kits/@kit.ConnectivityKit.d.ts | 3 ++- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/api/@ohos.bluetooth.common.d.ts b/api/@ohos.bluetooth.common.d.ts index ec15b1511d..88fb6ba59b 100644 --- a/api/@ohos.bluetooth.common.d.ts +++ b/api/@ohos.bluetooth.common.d.ts @@ -1,7 +1,7 @@ /* * Copyright (C) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); + * 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 * @@ -21,7 +21,7 @@ /** * Provide common Bluetooth interfaces and types. - * + * * @namespace common * @syscap SystemCapability.Communication.Bluetooth.Core * @since 21 dynamic @@ -30,53 +30,53 @@ 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, - /** + address: string; + /** * The type of the Bluetooth address. - * + * * @type { BluetoothAddressType } * @syscap SystemCapability.Communication.Bluetooth.Core * @since 21 dynamic * @since 22 static */ - addressType: BluetoothAddressType, + 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 diff --git a/kits/@kit.ConnectivityKit.d.ts b/kits/@kit.ConnectivityKit.d.ts index cf228c1061..8abb3083e5 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 }; -- Gitee