From cfc5b6f581ad3d0e03ae83b88db7508db2fd8294 Mon Sep 17 00:00:00 2001 From: tangjia Date: Wed, 21 Dec 2022 18:07:10 +0800 Subject: [PATCH 1/2] add the bluetoothManager Signed-off-by: tangjia --- api/@ohos.bluetooth.d.ts | 297 +++++ api/@ohos.bluetoothManager.d.ts | 1935 +++++++++++++++++++++++++++++++ 2 files changed, 2232 insertions(+) create mode 100644 api/@ohos.bluetoothManager.d.ts diff --git a/api/@ohos.bluetooth.d.ts b/api/@ohos.bluetooth.d.ts index 13cca971aa..f4dbc3d94a 100644 --- a/api/@ohos.bluetooth.d.ts +++ b/api/@ohos.bluetooth.d.ts @@ -20,6 +20,8 @@ import { AsyncCallback, Callback } from './basic'; * @namespace bluetooth * @syscap SystemCapability.Communication.Bluetooth.Core * @since 7 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager */ declare namespace bluetooth { /** @@ -31,6 +33,8 @@ declare namespace bluetooth { * or {@link BluetoothState#STATE_BLE_TURNING_OFF}. * @since 7 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.getState */ function getState(): BluetoothState; @@ -42,6 +46,8 @@ declare namespace bluetooth { * {@link ProfileConnectionState#STATE_DISCONNECTING}. * @since 7 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.getBtConnectionState */ function getBtConnectionState(): ProfileConnectionState; @@ -52,6 +58,8 @@ declare namespace bluetooth { * @returns { boolean } Returns {@code true} if the pairing process is started; returns {@code false} otherwise. * @since 7 * @permission ohos.permission.DISCOVER_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.pairDevice */ function pairDevice(deviceId: string): boolean; @@ -63,6 +71,8 @@ declare namespace bluetooth { * @since 8 * @permission ohos.permission.DISCOVER_BLUETOOTH * @systemapi Hide this for inner system use + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.cancelPairedDevice */ function cancelPairedDevice(deviceId: string): boolean; @@ -73,6 +83,8 @@ declare namespace bluetooth { * @returns { string } Returns the device name in character string format. * @since 8 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.getRemoteDeviceName */ function getRemoteDeviceName(deviceId: string): string; @@ -83,6 +95,8 @@ declare namespace bluetooth { * @returns { DeviceClass } The class of the remote device, {@link DeviceClass}. * @since 8 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.getRemoteDeviceClass */ function getRemoteDeviceClass(deviceId: string): DeviceClass; @@ -92,6 +106,8 @@ declare namespace bluetooth { * @returns { boolean } Returns {@code true} if Bluetooth is being enabled; returns {@code false} if an error occurs. * @since 8 * @permission ohos.permission.DISCOVER_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.enableBluetooth */ function enableBluetooth(): boolean; @@ -101,6 +117,8 @@ declare namespace bluetooth { * @returns { boolean } Returns {@code true} if Bluetooth is being disabled; returns {@code false} if an error occurs. * @since 8 * @permission ohos.permission.DISCOVER_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.disableBluetooth */ function disableBluetooth(): boolean; @@ -110,6 +128,8 @@ declare namespace bluetooth { * @returns { string } Returns the name the device. * @since 8 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.getLocalName */ function getLocalName(): string; @@ -119,6 +139,8 @@ declare namespace bluetooth { * @returns { Array } Returns a list of paired Bluetooth devices's address. * @since 8 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.getPairedDevices */ function getPairedDevices(): Array; @@ -129,6 +151,8 @@ declare namespace bluetooth { * @returns { ProfileConnectionState } Returns the connection state. * @since 8 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.getProfileConnectionState */ function getProfileConnState(profileId: ProfileId): ProfileConnectionState; @@ -140,6 +164,8 @@ declare namespace bluetooth { * @returns { boolean } Returns {@code true} if the pairing confirmation is set; returns {@code false} otherwise. * @since 8 * @permission ohos.permission.MANAGE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.setDevicePairingConfirmation */ function setDevicePairingConfirmation(device: string, accept: boolean): boolean; @@ -150,6 +176,8 @@ declare namespace bluetooth { * @returns { boolean } Returns {@code true} if the Bluetooth name is set successfully; returns {@code false} otherwise. * @since 8 * @permission ohos.permission.DISCOVER_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.setLocalName */ function setLocalName(name: string): boolean; @@ -161,6 +189,8 @@ declare namespace bluetooth { * @returns { boolean } Returns {@code true} if the Bluetooth scan mode is set; returns {@code false} otherwise. * @since 8 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.setBluetoothScanMode */ function setBluetoothScanMode(mode: ScanMode, duration: number): boolean; @@ -170,6 +200,8 @@ declare namespace bluetooth { * @returns { ScanMode } Returns the Bluetooth scanning mode, {@link ScanMode}. * @since 8 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.getBluetoothScanMode */ function getBluetoothScanMode(): ScanMode; @@ -179,6 +211,8 @@ declare namespace bluetooth { * @returns { boolean } Returns {@code true} if the scan is started successfully; returns {@code false} otherwise. * @since 8 * @permission ohos.permission.DISCOVER_BLUETOOTH and ohos.permission.LOCATION + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.startBluetoothDiscovery */ function startBluetoothDiscovery(): boolean; @@ -188,6 +222,8 @@ declare namespace bluetooth { * @returns { boolean } Returns {@code true} if scanning is stopped successfully; returns {@code false} otherwise. * @since 8 * @permission ohos.permission.DISCOVER_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.stopBluetoothDiscovery */ function stopBluetoothDiscovery(): boolean; @@ -198,6 +234,8 @@ declare namespace bluetooth { * @param callback Callback used to listen for the discovering event. * @since 8 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.on#event:bluetoothDeviceFind */ function on(type: "bluetoothDeviceFind", callback: Callback>): void; @@ -208,6 +246,8 @@ declare namespace bluetooth { * @param callback Callback used to listen for the discovering event. * @since 8 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.off#event:bluetoothDeviceFind */ function off(type: "bluetoothDeviceFind", callback?: Callback>): void; @@ -218,6 +258,8 @@ declare namespace bluetooth { * @param callback Callback used to listen for the bond state event, {@link BondStateParam}. * @since 8 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.on#event:bondStateChange */ function on(type: "bondStateChange", callback: Callback): void; @@ -228,6 +270,8 @@ declare namespace bluetooth { * @param callback Callback used to listen for the bond state event. * @since 8 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.off#event:bondStateChange */ function off(type: "bondStateChange", callback?: Callback): void; @@ -238,6 +282,8 @@ declare namespace bluetooth { * @param callback Callback used to listen for the pairing request event. * @since 8 * @permission ohos.permission.DISCOVER_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.on#event:pinRequired */ function on(type: "pinRequired", callback: Callback): void; @@ -248,6 +294,8 @@ declare namespace bluetooth { * @param callback Callback used to listen for the pairing request event. * @since 8 * @permission ohos.permission.DISCOVER_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.off#event:pinRequired */ function off(type: "pinRequired", callback?: Callback): void; @@ -258,6 +306,8 @@ declare namespace bluetooth { * @param callback Callback used to listen for the Bluetooth state event. * @since 8 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.on#event:stateChange */ function on(type: "stateChange", callback: Callback): void; @@ -268,6 +318,8 @@ declare namespace bluetooth { * @param callback Callback used to listen for the Bluetooth state event. * @since 8 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.off#event:stateChange */ function off(type: "stateChange", callback?: Callback): void; @@ -279,6 +331,8 @@ declare namespace bluetooth { * @param callback Callback used to return a server socket ID. * @since 8 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.sppListen */ function sppListen(name: string, option: SppOption, callback: AsyncCallback): void; @@ -288,6 +342,8 @@ declare namespace bluetooth { * @param serverSocket Indicates the server socket ID, returned by {@link sppListen}. * @param callback Callback used to return a client socket ID. * @since 8 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.sppAccept */ function sppAccept(serverSocket: number, callback: AsyncCallback): void; @@ -299,6 +355,8 @@ declare namespace bluetooth { * @param callback Callback used to return a client socket ID. * @since 8 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.sppConnect */ function sppConnect(device: string, option: SppOption, callback: AsyncCallback): void; @@ -307,6 +365,8 @@ declare namespace bluetooth { * * @param socket Indicates the server socket ID, returned by {@link sppListen}. * @since 8 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.sppCloseServerSocket */ function sppCloseServerSocket(socket: number): void; @@ -315,6 +375,8 @@ declare namespace bluetooth { * * @param socket Indicates the client socket ID, returned by {@link sppAccept} or {@link sppConnect}. * @since 8 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.sppCloseClientSocket */ function sppCloseClientSocket(socket: number): void; @@ -325,6 +387,8 @@ declare namespace bluetooth { * @param data Indicates the data to write. * @returns { boolean } Returns {@code true} if the data is write successfully; returns {@code false} otherwise. * @since 8 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.sppWrite */ function sppWrite(clientSocket: number, data: ArrayBuffer): boolean; @@ -334,6 +398,8 @@ declare namespace bluetooth { * @param type Type of the spp read event to listen for. * @param callback Callback used to listen for the spp read event. * @since 8 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.on#event:sppRead */ function on(type: "sppRead", clientSocket: number, callback: Callback): void; @@ -343,6 +409,8 @@ declare namespace bluetooth { * @param type Type of the spp read event to listen for. * @param callback Callback used to listen for the spp read event. * @since 8 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.off#event:sppRead */ function off(type: "sppRead", clientSocket: number, callback?: Callback): void; @@ -352,6 +420,8 @@ declare namespace bluetooth { * @param profileId The profile id.. * @returns { A2dpSourceProfile | HandsFreeAudioGatewayProfile } Returns instance of profile. * @since 8 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.getProfileInstance */ function getProfile(profileId: ProfileId): A2dpSourceProfile | HandsFreeAudioGatewayProfile; @@ -361,11 +431,16 @@ declare namespace bluetooth { * @param profileId The profile id.. * @returns { A2dpSourceProfile | HandsFreeAudioGatewayProfile | HidHostProfile | PanProfile } Returns the instance of profile. * @since 9 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.getProfileInstance */ function getProfileInst(profileId: ProfileId): A2dpSourceProfile | HandsFreeAudioGatewayProfile | HidHostProfile | PanProfile; /** * Base interface of profile. + * + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.BaseProfile */ interface BaseProfile { /** @@ -374,6 +449,8 @@ declare namespace bluetooth { * @returns { Array } Returns the address of connected devices list. * @since 8 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.BaseProfile#getConnectionDevices */ getConnectionDevices(): Array; @@ -384,12 +461,17 @@ declare namespace bluetooth { * @returns { ProfileConnectionState } Returns {@link ProfileConnectionState} of device. * @since 8 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.BaseProfile#getDeviceState */ getDeviceState(device: string): ProfileConnectionState; } /** * Manager a2dp source profile. + * + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.A2dpSourceProfile */ interface A2dpSourceProfile extends BaseProfile { /** @@ -399,6 +481,8 @@ declare namespace bluetooth { * @returns { boolean } Returns {@code true} if the connect is in process; returns {@code false} otherwise. * @since 8 * @permission ohos.permission.DISCOVER_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.A2dpSourceProfile#connect */ connect(device: string): boolean; @@ -409,6 +493,8 @@ declare namespace bluetooth { * @returns { boolean } Returns {@code true} if the disconnect is in process; returns {@code false} otherwise. * @since 8 * @permission ohos.permission.DISCOVER_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.A2dpSourceProfile#disconnect */ disconnect(device: string): boolean; @@ -418,6 +504,8 @@ declare namespace bluetooth { * @param type Type of the profile connection state changes event to listen for . * @param callback Callback used to listen for event. * @since 8 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.A2dpSourceProfile.on#event:connectionStateChange */ on(type: "connectionStateChange", callback: Callback): void; @@ -427,6 +515,8 @@ declare namespace bluetooth { * @param type Type of the profile connection state changes event to listen for . * @param callback Callback used to listen for event. * @since 8 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.A2dpSourceProfile.off#event:connectionStateChange */ off(type: "connectionStateChange", callback?: Callback): void; @@ -436,12 +526,17 @@ declare namespace bluetooth { * @param device The address of the remote device. * @returns { PlayingState } Returns {@link PlayingState} of the remote device. * @since 8 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.A2dpSourceProfile#getPlayingState */ getPlayingState(device: string): PlayingState; } /** * Manager handsfree AG profile. + * + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.HandsFreeAudioGatewayProfile */ interface HandsFreeAudioGatewayProfile extends BaseProfile { /** @@ -451,6 +546,8 @@ declare namespace bluetooth { * @returns { boolean } Returns {@code true} if the connect is in process; returns {@code false} otherwise. * @since 8 * @permission ohos.permission.DISCOVER_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.HandsFreeAudioGatewayProfile#connect */ connect(device: string): boolean; @@ -461,6 +558,8 @@ declare namespace bluetooth { * @returns { boolean } Returns {@code true} if the disconnect is in process; returns {@code false} otherwise. * @since 8 * @permission ohos.permission.DISCOVER_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.HandsFreeAudioGatewayProfile#disconnect */ disconnect(device: string): boolean; @@ -470,6 +569,8 @@ declare namespace bluetooth { * @param type Type of the profile connection state changes event to listen for . * @param callback Callback used to listen for event. * @since 8 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.HandsFreeAudioGatewayProfile.on#event:connectionStateChange */ on(type: "connectionStateChange", callback: Callback): void; @@ -479,12 +580,17 @@ declare namespace bluetooth { * @param type Type of the profile connection state changes event to listen for . * @param callback Callback used to listen for event. * @since 8 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.HandsFreeAudioGatewayProfile.off#event:connectionStateChange */ off(type: "connectionStateChange", callback?: Callback): void; } /** * Manager hid host profile. + * + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.HidHostProfile */ interface HidHostProfile extends BaseProfile { /** @@ -495,6 +601,8 @@ declare namespace bluetooth { * @since 9 * @permission ohos.permission.DISCOVER_BLUETOOTH * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.HidHostProfile#connect */ connect(device: string): boolean; @@ -506,6 +614,8 @@ declare namespace bluetooth { * @since 9 * @permission ohos.permission.DISCOVER_BLUETOOTH * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.HidHostProfile#disconnect */ disconnect(device: string): boolean; @@ -515,6 +625,8 @@ declare namespace bluetooth { * @param type Type of the profile connection state changes event to listen for . * @param callback Callback used to listen for event. * @since 9 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.HidHostProfile.on#event:connectionStateChange */ on(type: "connectionStateChange", callback: Callback): void; @@ -524,12 +636,17 @@ declare namespace bluetooth { * @param type Type of the profile connection state changes event to listen for. * @param callback Callback used to listen for event. * @since 9 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.HidHostProfile.off#event:connectionStateChange */ off(type: "connectionStateChange", callback?: Callback): void; } /** * Manager pan profile. + * + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.PanProfile */ interface PanProfile extends BaseProfile { /** @@ -540,6 +657,8 @@ declare namespace bluetooth { * @since 9 * @permission ohos.permission.USE_BLUETOOTH * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.PanProfile#disconnect */ disconnect(device: string): boolean; @@ -549,6 +668,8 @@ declare namespace bluetooth { * @param type Type of the profile connection state changes event to listen for . * @param callback Callback used to listen for event. * @since 9 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.PanProfile.on#event:connectionStateChange */ on(type: "connectionStateChange", callback: Callback): void; @@ -558,6 +679,8 @@ declare namespace bluetooth { * @param type Type of the profile connection state changes event to listen for. * @param callback Callback used to listen for event. * @since 9 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.PanProfile.off#event:connectionStateChange */ off(type: "connectionStateChange", callback?: Callback): void; @@ -569,6 +692,8 @@ declare namespace bluetooth { * @since 9 * @permission ohos.permission.DISCOVER_BLUETOOTH * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.PanProfile#setTethering */ setTethering(enable: boolean): void; @@ -578,6 +703,8 @@ declare namespace bluetooth { * @returns { boolean } Returns the value {@code true} is tethering is on, returns {@code false} otherwise. * @since 9 * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.PanProfile#isTetheringOn */ isTetheringOn(): boolean; } @@ -588,6 +715,8 @@ declare namespace bluetooth { * * @returns { GattServer } Returns a JavaScript Gatt server instance {@code GattServer}. * @since 7 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.BLE.createGattServer */ function createGattServer(): GattServer; @@ -597,6 +726,8 @@ declare namespace bluetooth { * @param deviceId The address of the remote device. * @returns { GattClientDevice } Returns a JavaScript Gatt client device instance {@code GattClientDevice}. * @since 7 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.BLE.createGattClientDevice */ function createGattClientDevice(deviceId: string): GattClientDevice; @@ -606,6 +737,8 @@ declare namespace bluetooth { * @returns { Array } Returns the list of device address. * @since 7 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.BLE.getConnectedBLEDevices */ function getConnectedBLEDevices(): Array; @@ -619,6 +752,8 @@ declare namespace bluetooth { * and {@link ScanOptions#matchMode} set to {@link MATCH_MODE_AGGRESSIVE}. * @since 7 * @permission ohos.permission.DISCOVER_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH and ohos.permission.LOCATION + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.BLE.startBLEScan */ function startBLEScan(filters: Array, options?: ScanOptions): void; @@ -627,6 +762,8 @@ declare namespace bluetooth { * * @since 7 * @permission ohos.permission.DISCOVER_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.BLE.stopBLEScan */ function stopBLEScan(): void; @@ -637,6 +774,8 @@ declare namespace bluetooth { * @param callback Callback used to listen for the scan result event. * @since 7 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.BLE.on#event:BLEDeviceFind */ function on(type: "BLEDeviceFind", callback: Callback>): void; @@ -647,12 +786,17 @@ declare namespace bluetooth { * @param callback Callback used to listen for the scan result event. * @since 7 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.BLE.off#event:BLEDeviceFind */ function off(type: "BLEDeviceFind", callback?: Callback>): void; } /** * Manages GATT server. Before calling an Gatt server method, you must use {@link createGattServer} to create an GattServer instance. + * + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.GattServer */ interface GattServer { /** @@ -664,6 +808,8 @@ declare namespace bluetooth { * @param advResponse Indicates the scan response associated with the advertising data. * @since 7 * @permission ohos.permission.DISCOVER_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.GattServer#startAdvertising */ startAdvertising(setting: AdvertiseSetting, advData: AdvertiseData, advResponse?: AdvertiseData): void; @@ -672,6 +818,8 @@ declare namespace bluetooth { * * @since 7 * @permission ohos.permission.DISCOVER_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.GattServer#stopAdvertising */ stopAdvertising(): void; @@ -684,6 +832,8 @@ declare namespace bluetooth { * @returns { boolean } Returns {@code true} if the service is added; returns {@code false} otherwise. * @since 7 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.GattServer#addService */ addService(service: GattService): boolean; @@ -694,6 +844,8 @@ declare namespace bluetooth { * @returns { boolean } Returns {@code true} if the service is removed; returns {@code false} otherwise. * @since 7 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.GattServer#removeService */ removeService(serviceUuid: string): boolean; @@ -702,6 +854,8 @@ declare namespace bluetooth { * * @since 7 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.GattServer#close */ close(): void; @@ -715,6 +869,8 @@ declare namespace bluetooth { * @returns { boolean } Returns {@code true} if the notification is sent successfully; returns {@code false} otherwise. * @since 7 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.GattServer#notifyCharacteristicChanged */ notifyCharacteristicChanged(deviceId: string, notifyCharacteristic: NotifyCharacteristic): boolean; @@ -725,6 +881,8 @@ declare namespace bluetooth { * @returns { boolean } Returns {@code true} if the response is sent successfully; returns {@code false} otherwise. * @since 7 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.GattServer#sendResponse */ sendResponse(serverResponse: ServerResponse): boolean; @@ -735,6 +893,8 @@ declare namespace bluetooth { * @param callback Callback used to listen for the characteristic read event. * @since 7 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.GattServer#on#event:characteristicRead */ on(type: "characteristicRead", callback: Callback): void; @@ -745,6 +905,8 @@ declare namespace bluetooth { * @param callback Callback used to listen for the characteristic read event. * @since 7 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.GattServer#off#event:characteristicRead */ off(type: "characteristicRead", callback?: Callback): void; @@ -755,6 +917,8 @@ declare namespace bluetooth { * @param callback Callback used to listen for the characteristic write event. * @since 7 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.GattServer#on#event:characteristicWrite */ on(type: "characteristicWrite", callback: Callback): void; @@ -765,6 +929,8 @@ declare namespace bluetooth { * @param callback Callback used to listen for the characteristic write event. * @since 7 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.GattServer#off#event:characteristicWrite */ off(type: "characteristicWrite", callback?: Callback): void; @@ -775,6 +941,8 @@ declare namespace bluetooth { * @param callback Callback used to listen for the descriptor read event. * @since 7 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.GattServer#on#event:descriptorRead */ on(type: "descriptorRead", callback: Callback): void; @@ -785,6 +953,8 @@ declare namespace bluetooth { * @param callback Callback used to listen for the descriptor read event. * @since 7 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.GattServer#off#event:descriptorRead */ off(type: "descriptorRead", callback?: Callback): void; @@ -795,6 +965,9 @@ declare namespace bluetooth { * @param callback Callback used to listen for the descriptor write event. * @since 7 * @permission ohos.permission.USE_BLUETOOTH + * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.GattServer#on#event:descriptorWrite */ on(type: "descriptorWrite", callback: Callback): void; @@ -805,6 +978,8 @@ declare namespace bluetooth { * @param callback Callback used to listen for the descriptor write event. * @since 7 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.GattServer#off#event:descriptorWrite */ off(type: "descriptorWrite", callback?: Callback): void; @@ -815,6 +990,8 @@ declare namespace bluetooth { * @param callback Callback used to listen for the connection state changed event. * @since 7 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.GattServer#on#event:connectStateChange */ on(type: "connectStateChange", callback: Callback): void; @@ -825,12 +1002,17 @@ declare namespace bluetooth { * @param callback Callback used to listen for the connection state changed event. * @since 7 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.GattServer#off#event:connectStateChange */ off(type: "connectStateChange", callback?: Callback): void; } /** * Manages GATT client. Before calling an Gatt client method, you must use {@link createGattClientDevice} to create an GattClientDevice instance. + * + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.GattClientDevice */ interface GattClientDevice { @@ -842,6 +1024,8 @@ declare namespace bluetooth { * @returns { boolean } Returns {@code true} if the connection process starts; returns {@code false} otherwise. * @since 7 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.GattClientDevice#connect */ connect(): boolean; @@ -851,6 +1035,8 @@ declare namespace bluetooth { * @returns { boolean } Returns {@code true} if the disconnection process starts; returns {@code false} otherwise. * @since 7 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.GattClientDevice#disconnect */ disconnect(): boolean; @@ -862,6 +1048,8 @@ declare namespace bluetooth { * @returns { boolean } Returns {@code true} if the the device is disabled; returns {@code false} otherwise. * @since 7 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.GattClientDevice#close */ close(): boolean; @@ -872,6 +1060,8 @@ declare namespace bluetooth { * returns {@code null} if the name fails to be obtained or the name does not exist. * @since 7 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.GattClientDevice#getDeviceName */ getDeviceName(callback: AsyncCallback): void; getDeviceName(): Promise; @@ -882,6 +1072,8 @@ declare namespace bluetooth { * @returns { Promise> } Returns the list of services {@link GattService} of the BLE peripheral device. * @since 7 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.GattClientDevice#getServices */ getServices(callback: AsyncCallback>): void; getServices(): Promise>; @@ -892,6 +1084,8 @@ declare namespace bluetooth { * @param characteristic Indicates the characteristic to read. * @since 7 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.GattClientDevice#readCharacteristicValue */ readCharacteristicValue(characteristic: BLECharacteristic, callback: AsyncCallback): void; readCharacteristicValue(characteristic: BLECharacteristic): Promise; @@ -902,6 +1096,8 @@ declare namespace bluetooth { * @param descriptor Indicates the descriptor to read. * @since 7 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.GattClientDevice#readDescriptorValue */ readDescriptorValue(descriptor: BLEDescriptor, callback: AsyncCallback): void; readDescriptorValue(descriptor: BLEDescriptor): Promise; @@ -913,6 +1109,8 @@ declare namespace bluetooth { * @returns { boolean } Returns {@code true} if the characteristic is written successfully; returns {@code false} otherwise. * @since 7 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.GattClientDevice#writeCharacteristicValue */ writeCharacteristicValue(characteristic: BLECharacteristic): boolean; @@ -923,6 +1121,8 @@ declare namespace bluetooth { * @returns { boolean } Returns {@code true} if the descriptor is written successfully; returns {@code false} otherwise. * @since 7 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.GattClientDevice#writeDescriptorValue */ writeDescriptorValue(descriptor: BLEDescriptor): boolean; @@ -932,6 +1132,8 @@ declare namespace bluetooth { * @returns { Promise } Returns the RSSI value. * @since 7 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.GattClientDevice#getRssiValue */ getRssiValue(callback: AsyncCallback): void; getRssiValue(): Promise; @@ -943,6 +1145,8 @@ declare namespace bluetooth { * @returns { boolean } Returns {@code true} if the set mtu is successfully; returns {@code false} otherwise. * @since 7 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.GattClientDevice#setBLEMtuSize */ setBLEMtuSize(mtu: number): boolean; @@ -955,6 +1159,8 @@ declare namespace bluetooth { * returns {@code false} otherwise. * @since 7 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.GattClientDevice#setNotifyCharacteristicChanged */ setNotifyCharacteristicChanged(characteristic: BLECharacteristic, enable: boolean): boolean; @@ -965,6 +1171,8 @@ declare namespace bluetooth { * @param callback Callback used to listen for the characteristic value changed event. * @since 7 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.GattClientDevice#on#event:BLECharacteristicChange */ on(type: "BLECharacteristicChange", callback: Callback): void; @@ -975,6 +1183,8 @@ declare namespace bluetooth { * @param callback Callback used to listen for the characteristic value changed event. * @since 7 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.GattClientDevice#off#event:BLECharacteristicChange */ off(type: "BLECharacteristicChange", callback?: Callback): void; @@ -985,6 +1195,8 @@ declare namespace bluetooth { * @param callback Callback used to listen for the connection state changed event. * @since 7 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.GattClientDevice#on#event:BLEConnectionStateChange */ on(type: "BLEConnectionStateChange", callback: Callback): void; @@ -995,6 +1207,8 @@ declare namespace bluetooth { * @param callback Callback used to listen for the connection state changed event. * @since 7 * @permission ohos.permission.USE_BLUETOOTH + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.GattClientDevice#off#event:BLEConnectionStateChange */ off(type: "BLEConnectionStateChange", callback?: Callback): void; } @@ -1003,6 +1217,8 @@ declare namespace bluetooth { * Describes the Gatt service. * * @since 7 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.GattService */ interface GattService { /** The UUID of a GattService instance */ @@ -1019,6 +1235,8 @@ declare namespace bluetooth { * Describes the Gatt characteristic. * * @since 7 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.BLECharacteristic */ interface BLECharacteristic { /** The UUID of the {@link GattService} instance to which the characteristic belongs */ @@ -1035,6 +1253,8 @@ declare namespace bluetooth { * Describes the Gatt descriptor. * * @since 7 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.BLEDescriptor */ interface BLEDescriptor { /** The UUID of the {@link GattService} instance to which the descriptor belongs */ @@ -1051,6 +1271,8 @@ declare namespace bluetooth { * Describes the value of the indication or notification sent by the Gatt server. * * @since 7 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.NotifyCharacteristic */ interface NotifyCharacteristic { /** The UUID of the {@link GattService} instance to which the characteristic belongs */ @@ -1070,6 +1292,8 @@ declare namespace bluetooth { * Describes the parameters of the Gatt client's characteristic read request. * * @since 7 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.CharacteristicReadRequest */ interface CharacteristicReadReq { /** Indicates the address of the client that initiates the read request */ @@ -1088,6 +1312,8 @@ declare namespace bluetooth { * Describes the parameters of the of the Gatt client's characteristic write request. * * @since 7 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.CharacteristicWriteRequest */ interface CharacteristicWriteReq { /** Indicates the address of the client that initiates the write request */ @@ -1112,6 +1338,8 @@ declare namespace bluetooth { * Describes the parameters of the Gatt client's descriptor read request. * * @since 7 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.DescriptorReadRequest */ interface DescriptorReadReq { /** Indicates the address of the client that initiates the read request */ @@ -1132,6 +1360,8 @@ declare namespace bluetooth { * Describes the parameters of the Gatt client's characteristic write request. * * @since 7 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.DescriptorWriteRequest */ interface DescriptorWriteReq { /** Indicates the address of the client that initiates the write request */ @@ -1158,6 +1388,8 @@ declare namespace bluetooth { * Describes the parameters of a response send by the server to a specified read or write request. * * @since 7 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.ServerResponse */ interface ServerResponse { /** Indicates the address of the client to which to send the response */ @@ -1176,6 +1408,8 @@ declare namespace bluetooth { * Describes the Gatt profile connection state. * * @since 7 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.BLEConnectChangedState */ interface BLEConnectChangedState { /** Indicates the peer device address */ @@ -1188,6 +1422,8 @@ declare namespace bluetooth { * Describes the contents of the scan results. * * @since 7 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.ScanResult */ interface ScanResult { /** Address of the scanned device */ @@ -1202,6 +1438,8 @@ declare namespace bluetooth { * Describes the settings for BLE advertising. * * @since 7 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.AdvertiseSetting */ interface AdvertiseSetting { /** @@ -1224,6 +1462,8 @@ declare namespace bluetooth { * Describes the advertising data. * * @since 7 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.AdvertiseData */ interface AdvertiseData { /** The specified service UUID list to this advertisement */ @@ -1238,6 +1478,8 @@ declare namespace bluetooth { * Describes the manufacturer data. * * @since 7 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.ManufactureData */ interface ManufactureData { /** Indicates the manufacturer ID assigned by Bluetooth SIG */ @@ -1250,6 +1492,8 @@ declare namespace bluetooth { * Describes the service data. * * @since 7 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.ServiceData */ interface ServiceData { /** Indicates the UUID of the service data to add */ @@ -1261,6 +1505,8 @@ declare namespace bluetooth { /** * Describes the criteria for filtering scanning results can be set. * + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.ScanFilter */ interface ScanFilter { /** @@ -1334,6 +1580,8 @@ declare namespace bluetooth { * Describes the parameters for scan. * * @since 7 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.ScanOptions */ interface ScanOptions { /** Time of delay for reporting the scan result */ @@ -1348,6 +1596,8 @@ declare namespace bluetooth { * Describes the spp parameters. * * @since 8 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.SppOption */ interface SppOption { /** Indicates the UUID in the SDP record. */ @@ -1362,6 +1612,8 @@ declare namespace bluetooth { * Describes the bond key param. * * @since 8 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.PinRequiredParam */ interface PinRequiredParam { deviceId: string; @@ -1372,6 +1624,8 @@ declare namespace bluetooth { * Describes the class of a bluetooth device. * * @since 8 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.DeviceClass */ interface DeviceClass { majorClass: MajorClass; @@ -1383,12 +1637,20 @@ declare namespace bluetooth { * Describes the class of a bluetooth device. * * @since 8 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.BondStateParam */ interface BondStateParam { deviceId: string; state: BondState; } + /** + * The enum of scan duty. + * + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.ScanDuty + */ enum ScanDuty { /** low power mode */ SCAN_MODE_LOW_POWER = 0, @@ -1398,6 +1660,12 @@ declare namespace bluetooth { SCAN_MODE_LOW_LATENCY = 2 } + /** + * The enum of BLE match mode. + * + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.MatchMode + */ enum MatchMode { /** aggressive mode */ MATCH_MODE_AGGRESSIVE = 1, @@ -1405,6 +1673,12 @@ declare namespace bluetooth { MATCH_MODE_STICKY = 2 } + /** + * The enum of profile connection state. + * + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.ProfileConnectionState + */ enum ProfileConnectionState { /** the current profile is disconnected */ STATE_DISCONNECTED = 0, @@ -1416,6 +1690,12 @@ declare namespace bluetooth { STATE_DISCONNECTING = 3 } + /** + * The enum of bluetooth state. + * + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.BluetoothState + */ enum BluetoothState { /** Indicates the local Bluetooth is off */ STATE_OFF = 0, @@ -1437,6 +1717,8 @@ declare namespace bluetooth { * The enum of SPP type. * * @since 8 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.SppType */ enum SppType { /** RFCOMM */ @@ -1447,6 +1729,8 @@ declare namespace bluetooth { * The enum of BR scan mode. * * @since 8 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.ScanMode */ enum ScanMode { /** Indicates the scan mode is none */ @@ -1467,6 +1751,8 @@ declare namespace bluetooth { * The enum of bond state. * * @since 8 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.BondState */ enum BondState { /** Indicate the bond state is invalid */ @@ -1481,6 +1767,8 @@ declare namespace bluetooth { * The enum of major class of a bluetooth device. * * @since 8 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.MajorClass */ enum MajorClass { MAJOR_MISC = 0x0000, @@ -1500,6 +1788,8 @@ declare namespace bluetooth { * The enum of major minor class of a bluetooth device. * * @since 8 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.MajorMinorClass */ enum MajorMinorClass { // The Minor Device Class field @@ -1612,6 +1902,8 @@ declare namespace bluetooth { * Profile state change parameters. * * @since 8 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.StateChangeParam */ interface StateChangeParam { /** The address of device */ @@ -1625,6 +1917,8 @@ declare namespace bluetooth { * The enum of a2dp playing state. * * @since 8 + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.PlayingState */ enum PlayingState { STATE_NOT_PLAYING, @@ -1633,6 +1927,9 @@ declare namespace bluetooth { /** * The enum of profile id. + * + * @deprecated since 9 + * @useinstead ohos.bluetoothManager/bluetoothManager.ProfileId */ enum ProfileId { /** diff --git a/api/@ohos.bluetoothManager.d.ts b/api/@ohos.bluetoothManager.d.ts new file mode 100644 index 0000000000..f2e9e6f120 --- /dev/null +++ b/api/@ohos.bluetoothManager.d.ts @@ -0,0 +1,1935 @@ +/* + * 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 { AsyncCallback, Callback } from './basic'; + +/** + * Provides methods to operate or manage Bluetooth. + * @namespace bluetoothManager + * @syscap SystemCapability.Communication.Bluetooth.Core + * @since 9 + */ +declare namespace bluetoothManager { + /** + * Obtains the Bluetooth status of a device. + * + * @permission ohos.permission.USE_BLUETOOTH + * @returns { BluetoothState } Returns the Bluetooth status, which can be {@link BluetoothState#STATE_OFF}, + * {@link BluetoothState#STATE_TURNING_ON}, {@link BluetoothState#STATE_ON}, {@link BluetoothState#STATE_TURNING_OFF}, + * {@link BluetoothState#STATE_BLE_TURNING_ON}, {@link BluetoothState#STATE_BLE_ON}, + * or {@link BluetoothState#STATE_BLE_TURNING_OFF}. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + function getState(): BluetoothState; + + /** + * Get the local device connection state to any profile of any remote device. + * + * @permission ohos.permission.USE_BLUETOOTH + * @returns { ProfileConnectionState } One of {@link ProfileConnectionState#STATE_DISCONNECTED}, + * {@link ProfileConnectionState#STATE_CONNECTING}, {@link ProfileConnectionState#STATE_CONNECTED}, + * {@link ProfileConnectionState#STATE_DISCONNECTING}. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + function getBtConnectionState(): ProfileConnectionState; + + /** + * Starts pairing with a remote Bluetooth device. + * + * @permission ohos.permission.DISCOVER_BLUETOOTH + * @param deviceId The address of the remote device to pair. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + function pairDevice(deviceId: string): void; + + /** + * Remove a paired remote device. + * + * @permission ohos.permission.DISCOVER_BLUETOOTH + * @param deviceId The address of the remote device to be removed. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900099 - Operation failed. + * @systemapi Hide this for inner system use. + * @since 9 + */ + function cancelPairedDevice(deviceId: string): void; + + /** + * Obtains the name of a peer Bluetooth device. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param deviceId The address of the remote device. + * @returns { string } Returns the device name in character string format. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + function getRemoteDeviceName(deviceId: string): string; + + /** + * Obtains the class of a peer Bluetooth device. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param deviceId The address of the remote device. + * @returns { DeviceClass } The class of the remote device, {@link DeviceClass}. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + function getRemoteDeviceClass(deviceId: string): DeviceClass; + + /** + * Enables Bluetooth on a device. + * + * @permission ohos.permission.DISCOVER_BLUETOOTH + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + function enableBluetooth(): void; + + /** + * Disables Bluetooth on a device. + * + * @permission ohos.permission.DISCOVER_BLUETOOTH + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + function disableBluetooth(): void; + + /** + * Obtains the Bluetooth local name of a device. + * + * @permission ohos.permission.USE_BLUETOOTH + * @returns { string } Returns the name the device. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + function getLocalName(): string; + + /** + * Obtains the list of Bluetooth devices that have been paired with the current device. + * + * @permission ohos.permission.USE_BLUETOOTH + * @returns { Array } Returns a list of paired Bluetooth devices's address. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + function getPairedDevices(): Array; + + /** + * Obtains the connection state of profile. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param profileId The profile id. + * @returns { ProfileConnectionState } Returns the connection state. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900004 - Profile is not supported. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + function getProfileConnectionState(profileId: ProfileId): ProfileConnectionState; + + /** + * Sets the confirmation of pairing with a certain device. + * + * @permission ohos.permission.MANAGE_BLUETOOTH + * @param device The address of the remote device. + * @param accept Indicates whether to accept the pairing request, {@code true} indicates accept or {@code false} otherwise. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + function setDevicePairingConfirmation(device: string, accept: boolean): void; + + /** + * Sets the Bluetooth friendly name of a device. + * + * @permission ohos.permission.DISCOVER_BLUETOOTH + * @param name Indicates a valid Bluetooth name. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + function setLocalName(name: string): void; + + /** + * Sets the Bluetooth scan mode for a device. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param mode Indicates the Bluetooth scan mode to set, {@link ScanMode}. + * @param duration Indicates the duration in seconds, in which the host is discoverable. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + function setBluetoothScanMode(mode: ScanMode, duration: number): void; + + /** + * Obtains the Bluetooth scanning mode of a device. + * + * @permission ohos.permission.USE_BLUETOOTH + * @returns { ScanMode } Returns the Bluetooth scanning mode, {@link ScanMode}. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + function getBluetoothScanMode(): ScanMode; + + /** + * Starts scanning Bluetooth devices. + * + * @permission ohos.permission.DISCOVER_BLUETOOTH and ohos.permission.LOCATION + * and ohos.permission.APPROXIMATELY_LOCATION + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + function startBluetoothDiscovery(): void; + + /** + * Stops Bluetooth device scanning. + * + * @permission ohos.permission.DISCOVER_BLUETOOTH + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + function stopBluetoothDiscovery(): void; + + /** + * Subscribe the event reported when a remote Bluetooth device is discovered. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param type Type of the discovering event to listen for. + * @param callback Callback used to listen for the discovering event. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + function on(type: "bluetoothDeviceFind", callback: Callback>): void; + + /** + * Unsubscribe the event reported when a remote Bluetooth device is discovered. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param type Type of the discovering event to listen for. + * @param callback Callback used to listen for the discovering event. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + function off(type: "bluetoothDeviceFind", callback?: Callback>): void; + + /** + * Subscribe the event reported when a remote Bluetooth device is bonded. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param type Type of the bond state event to listen for. + * @param callback Callback used to listen for the bond state event, {@link BondStateParam}. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + function on(type: "bondStateChange", callback: Callback): void; + + /** + * Unsubscribe the event reported when a remote Bluetooth device is bonded. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param type Type of the bond state event to listen for. + * @param callback Callback used to listen for the bond state event. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + function off(type: "bondStateChange", callback?: Callback): void; + + /** + * Subscribe the event of a pairing request from a remote Bluetooth device. + * + * @permission ohos.permission.DISCOVER_BLUETOOTH + * @param type Type of the pairing request event to listen for. + * @param callback Callback used to listen for the pairing request event. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + function on(type: "pinRequired", callback: Callback): void; + + /** + * Unsubscribe the event of a pairing request from a remote Bluetooth device. + * + * @permission ohos.permission.DISCOVER_BLUETOOTH + * @param type Type of the pairing request event to listen for. + * @param callback Callback used to listen for the pairing request event. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + function off(type: "pinRequired", callback?: Callback): void; + + /** + * Subscribe the event reported when the Bluetooth state changes. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param type Type of the Bluetooth state changes event to listen for. + * @param callback Callback used to listen for the Bluetooth state event. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + function on(type: "stateChange", callback: Callback): void; + + /** + * Unsubscribe the event reported when the Bluetooth state changes. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param type Type of the Bluetooth state changes event to listen for. + * @param callback Callback used to listen for the Bluetooth state event. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + function off(type: "stateChange", callback?: Callback): void; + + /** + * Creates a Bluetooth server listening socket. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param name Indicates the service name. + * @param option Indicates the listen parameters {@link SppOption}. + * @param callback Callback used to return a server socket ID. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900004 - Profile is not supported. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + function sppListen(name: string, option: SppOption, callback: AsyncCallback): void; + + /** + * Waits for a remote device to connect. + * + * @param serverSocket Indicates the server socket ID, returned by {@link sppListen}. + * @param callback Callback used to return a client socket ID. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900004 - Profile is not supported. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + function sppAccept(serverSocket: number, callback: AsyncCallback): void; + + /** + * Connects to a remote device over the socket. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param device The address of the remote device to connect. + * @param option Indicates the connect parameters {@link SppOption}. + * @param callback Callback used to return a client socket ID. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900004 - Profile is not supported. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + function sppConnect(device: string, option: SppOption, callback: AsyncCallback): void; + + /** + * Disables an spp server socket and releases related resources. + * + * @param socket Indicates the server socket ID, returned by {@link sppListen}. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + function sppCloseServerSocket(socket: number): void; + + /** + * Disables an spp client socket and releases related resources. + * + * @param socket Indicates the client socket ID, returned by {@link sppAccept} or {@link sppConnect}. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + function sppCloseClientSocket(socket: number): void; + + /** + * Write data through the socket. + * + * @param clientSocket Indicates the client socket ID, returned by {@link sppAccept} or {@link sppConnect}. + * @param data Indicates the data to write. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 2901054 - IO error. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + function sppWrite(clientSocket: number, data: ArrayBuffer): void; + + /** + * Subscribe the event reported when data is read from the socket. + * + * @param type Type of the spp read event to listen for. + * @param callback Callback used to listen for the spp read event. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 2901054 - IO error. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + function on(type: "sppRead", clientSocket: number, callback: Callback): void; + + /** + * Unsubscribe the event reported when data is read from the socket. + * + * @param type Type of the spp read event to listen for. + * @param callback Callback used to listen for the spp read event. + * @since 9 + */ + function off(type: "sppRead", clientSocket: number, callback?: Callback): void; + + /** + * Obtains the instance of profile. + * + * @param profileId The profile id.. + * @returns { A2dpSourceProfile | HandsFreeAudioGatewayProfile | HidHostProfile | PanProfile } Returns the instance of profile. + * @since 9 + */ + function getProfileInstance(profileId: ProfileId): A2dpSourceProfile | HandsFreeAudioGatewayProfile | HidHostProfile | PanProfile; + + /** + * Base interface of profile. + */ + interface BaseProfile { + /** + * Obtains the connected devices list of profile. + * + * @permission ohos.permission.USE_BLUETOOTH + * @returns { Array } Returns the address of connected devices list. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900004 - Profile is not supported. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + getConnectionDevices(): Array; + + /** + * Obtains the profile state of device. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param device The address of bluetooth device. + * @returns { ProfileConnectionState } Returns {@link ProfileConnectionState} of device. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900004 - Profile is not supported. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + getDeviceState(device: string): ProfileConnectionState; + } + + /** + * Manager a2dp source profile. + */ + interface A2dpSourceProfile extends BaseProfile { + /** + * Connect to device with a2dp. + * + * @permission ohos.permission.DISCOVER_BLUETOOTH + * @param device The address of the remote device to connect. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900004 - Profile is not supported. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + connect(device: string): void; + + /** + * Disconnect to device with a2dp. + * + * @permission ohos.permission.DISCOVER_BLUETOOTH + * @param device The address of the remote device to disconnect. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900004 - Profile is not supported. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + disconnect(device: string): void; + + /** + * Subscribe the event reported when the profile connection state changes . + * + * @param type Type of the profile connection state changes event to listen for . + * @param callback Callback used to listen for event. + * @since 9 + */ + on(type: "connectionStateChange", callback: Callback): void; + + /** + * Unsubscribe the event reported when the profile connection state changes . + * + * @param type Type of the profile connection state changes event to listen for . + * @param callback Callback used to listen for event. + * @since 9 + */ + off(type: "connectionStateChange", callback?: Callback): void; + + /** + * Obtains the playing state of device. + * + * @param device The address of the remote device. + * @returns { PlayingState } Returns {@link PlayingState} of the remote device. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900004 - Profile is not supported. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + getPlayingState(device: string): PlayingState; + } + + /** + * Manager handsfree AG profile. + */ + interface HandsFreeAudioGatewayProfile extends BaseProfile { + /** + * Connect to device with hfp. + * + * @permission ohos.permission.DISCOVER_BLUETOOTH + * @param device The address of the remote device to connect. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900004 - Profile is not supported. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + connect(device: string): void; + + /** + * Disconnect to device with hfp. + * + * @permission ohos.permission.DISCOVER_BLUETOOTH + * @param device The address of the remote device to disconnect. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900004 - Profile is not supported. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + disconnect(device: string): void; + + /** + * Subscribe the event reported when the profile connection state changes . + * + * @param type Type of the profile connection state changes event to listen for . + * @param callback Callback used to listen for event. + * @since 9 + */ + on(type: "connectionStateChange", callback: Callback): void; + + /** + * Unsubscribe the event reported when the profile connection state changes . + * + * @param type Type of the profile connection state changes event to listen for . + * @param callback Callback used to listen for event. + * @since 9 + */ + off(type: "connectionStateChange", callback?: Callback): void; + } + + /** + * Manager hid host profile. + */ + interface HidHostProfile extends BaseProfile { + /** + * Connect to device with hid host. + * + * @permission ohos.permission.DISCOVER_BLUETOOTH + * @param device The address of the remote device to connect. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900004 - Profile is not supported. + * @throws { BusinessError } 2900099 - Operation failed. + * @systemapi Hide this for inner system use. + * @since 9 + */ + connect(device: string): void; + + /** + * Disconnect to device with hid host. + * + * @permission ohos.permission.DISCOVER_BLUETOOTH + * @param device The address of the remote device to disconnect. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900004 - Profile is not supported. + * @throws { BusinessError } 2900099 - Operation failed. + * @systemapi Hide this for inner system use. + * @since 9 + */ + disconnect(device: string): void; + + /** + * Subscribe the event reported when the profile connection state changes . + * + * @param type Type of the profile connection state changes event to listen for . + * @param callback Callback used to listen for event. + * @since 9 + */ + on(type: "connectionStateChange", callback: Callback): void; + + /** + * Unsubscribe the event reported when the profile connection state changes. + * + * @param type Type of the profile connection state changes event to listen for. + * @param callback Callback used to listen for event. + * @since 9 + */ + off(type: "connectionStateChange", callback?: Callback): void; + } + + /** + * Manager pan profile. + */ + interface PanProfile extends BaseProfile { + /** + * Disconnect to device with pan. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param device The address of the remote device to disconnect. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900004 - Profile is not supported. + * @throws { BusinessError } 2900099 - Operation failed. + * @systemapi Hide this for inner system use. + * @since 9 + */ + disconnect(device: string): void; + + /** + * Subscribe the event reported when the profile connection state changes . + * + * @param type Type of the profile connection state changes event to listen for . + * @param callback Callback used to listen for event. + * @since 9 + */ + on(type: "connectionStateChange", callback: Callback): void; + + /** + * Unsubscribe the event reported when the profile connection state changes. + * + * @param type Type of the profile connection state changes event to listen for. + * @param callback Callback used to listen for event. + * @since 9 + */ + off(type: "connectionStateChange", callback?: Callback): void; + + /** + * Enable bluetooth tethering. + * + * @permission ohos.permission.DISCOVER_BLUETOOTH + * @param enable Specifies whether to enable tethering. The value {@code true} indicates + * that tethering is enabled, and the value {@code false} indicates that tethering is disabled. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900004 - Profile is not supported. + * @throws { BusinessError } 2900099 - Operation failed. + * @systemapi Hide this for inner system use. + * @since 9 + */ + setTethering(enable: boolean): void; + + /** + * Obtains the tethering enable or disable. + * + * @returns { boolean } Returns the value {@code true} is tethering is on, returns {@code false} otherwise. + * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. + * @systemapi Hide this for inner system use. + * @since 9 + */ + isTetheringOn(): boolean; + } + + namespace BLE { + /** + * create a JavaScript Gatt server instance. + * + * @returns { GattServer } Returns a JavaScript Gatt server instance {@code GattServer}. + * @since 9 + */ + function createGattServer(): GattServer; + + /** + * create a JavaScript Gatt client device instance. + * + * @param deviceId The address of the remote device. + * @returns { GattClientDevice } Returns a JavaScript Gatt client device instance {@code GattClientDevice}. + * @since 9 + * @throws { BusinessError } 401 - Invalid parameter. + */ + function createGattClientDevice(deviceId: string): GattClientDevice; + + /** + * Obtains the list of devices in the connected status. + * + * @permission ohos.permission.USE_BLUETOOTH + * @returns { Array } Returns the list of device address. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + function getConnectedBLEDevices(): Array; + + /** + * Starts scanning for specified BLE devices with filters. + * + * @permission ohos.permission.DISCOVER_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH and ohos.permission.LOCATION + * and ohos.permission.APPROXIMATELY_LOCATION + * @param filters Indicates the list of filters used to filter out specified devices. + * If you do not want to use filter, set this parameter to {@code null}. + * @param options Indicates the parameters for scanning and if the user does not assign a value, the default value will be used. + * {@link ScanOptions#interval} set to 0, {@link ScanOptions#dutyMode} set to {@link SCAN_MODE_LOW_POWER} + * and {@link ScanOptions#matchMode} set to {@link MATCH_MODE_AGGRESSIVE}. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + function startBLEScan(filters: Array, options?: ScanOptions): void; + + /** + * Stops BLE scanning. + * + * @since 9 + * @permission ohos.permission.DISCOVER_BLUETOOTH + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900099 - Operation failed. + */ + function stopBLEScan(): void; + + /** + * Subscribe BLE scan result. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param type Type of the scan result event to listen for. + * @param callback Callback used to listen for the scan result event. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + function on(type: "BLEDeviceFind", callback: Callback>): void; + + /** + * Unsubscribe BLE scan result. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param type Type of the scan result event to listen for. + * @param callback Callback used to listen for the scan result event. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + function off(type: "BLEDeviceFind", callback?: Callback>): void; + } + + /** + * Manages GATT server. Before calling an Gatt server method, you must use {@link createGattServer} to create an GattServer instance. + */ + interface GattServer { + /** + * Starts BLE advertising. + * + * @permission ohos.permission.DISCOVER_BLUETOOTH + * @param setting Indicates the settings for BLE advertising. + * If you need to use the default value, set this parameter to {@code null}. + * @param advData Indicates the advertising data. + * @param advResponse Indicates the scan response associated with the advertising data. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + startAdvertising(setting: AdvertiseSetting, advData: AdvertiseData, advResponse?: AdvertiseData): void; + + /** + * Stops BLE advertising. + * + * @permission ohos.permission.DISCOVER_BLUETOOTH + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + stopAdvertising(): void; + + /** + * Adds a specified service to be hosted. + * + *

The added service and its characteristics are provided by the local device. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param service Indicates the service to add. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + addService(service: GattService): void; + + /** + * Removes a specified service from the list of GATT services provided by this device. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param serviceUuid Indicates the UUID of the service to remove. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900004 - Profile is not supported. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + removeService(serviceUuid: string): void; + + /** + * Closes this {@code GattServer} object and unregisters its callbacks. + * + * @permission ohos.permission.USE_BLUETOOTH + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + close(): void; + + /** + * Sends a notification of a change in a specified local characteristic. + * + *

This method should be called for every BLE peripheral device that has requested notifications. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param deviceId Indicates the address of the BLE peripheral device to receive the notification. + * @param notifyCharacteristic Indicates the local characteristic that has changed. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + notifyCharacteristicChanged(deviceId: string, notifyCharacteristic: NotifyCharacteristic): void; + + /** + * Sends a response to a specified read or write request to a given BLE peripheral device. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param serverResponse Indicates the response parameters {@link ServerResponse}. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + sendResponse(serverResponse: ServerResponse): void; + + /** + * Subscribe characteristic read event. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param type Type of the characteristic read event to listen for. + * @param callback Callback used to listen for the characteristic read event. + * @since 9 + */ + on(type: "characteristicRead", callback: Callback): void; + + /** + * Unsubscribe characteristic read event. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param type Type of the characteristic read event to listen for. + * @param callback Callback used to listen for the characteristic read event. + * @since 9 + */ + off(type: "characteristicRead", callback?: Callback): void; + + /** + * Subscribe characteristic write event. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param type Type of the characteristic write event to listen for. + * @param callback Callback used to listen for the characteristic write event. + * @since 9 + */ + on(type: "characteristicWrite", callback: Callback): void; + + /** + * Unsubscribe characteristic write event. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param type Type of the characteristic write event to listen for. + * @param callback Callback used to listen for the characteristic write event. + * @since 9 + */ + off(type: "characteristicWrite", callback?: Callback): void; + + /** + * Subscribe descriptor read event. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param type Type of the descriptor read event to listen for. + * @param callback Callback used to listen for the descriptor read event. + * @since 9 + */ + on(type: "descriptorRead", callback: Callback): void; + + /** + * Unsubscribe descriptor read event. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param type Type of the descriptor read event to listen for. + * @param callback Callback used to listen for the descriptor read event. + * @since 9 + */ + off(type: "descriptorRead", callback?: Callback): void; + + /** + * Subscribe descriptor write event. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param type Type of the descriptor write event to listen for. + * @param callback Callback used to listen for the descriptor write event. + * @since 9 + */ + on(type: "descriptorWrite", callback: Callback): void; + + /** + * Unsubscribe descriptor write event. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param type Type of the descriptor write event to listen for. + * @param callback Callback used to listen for the descriptor write event. + * @since 9 + */ + off(type: "descriptorWrite", callback?: Callback): void; + + /** + * Subscribe server connection state changed event. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param type Type of the connection state changed event to listen for. + * @param callback Callback used to listen for the connection state changed event. + * @since 9 + */ + on(type: "connectStateChange", callback: Callback): void; + + /** + * Unsubscribe server connection state changed event. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param type Type of the connection state changed event to listen for. + * @param callback Callback used to listen for the connection state changed event. + * @since 9 + */ + off(type: "connectStateChange", callback?: Callback): void; + } + + /** + * Manages GATT client. Before calling an Gatt client method, you must use {@link createGattClientDevice} to create an GattClientDevice instance. + */ + interface GattClientDevice { + + /** + * Connects to a BLE peripheral device. + * + *

The 'BLEConnectionStateChange' event is subscribed to return the connection state. + * + * @permission ohos.permission.USE_BLUETOOTH + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + connect(): void; + + /** + * Disconnects from or stops an ongoing connection to a BLE peripheral device. + * + * @permission ohos.permission.USE_BLUETOOTH + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + disconnect(): void; + + /** + * Disables a BLE peripheral device. + * + *

This method unregisters the device and clears the registered callbacks and handles. + * + * @permission ohos.permission.USE_BLUETOOTH + * @returns { boolean } Returns {@code true} if the the device is disabled; returns {@code false} otherwise. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900003 - Bluetooth switch is off. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + close(): void; + + /** + * Obtains the name of BLE peripheral device. + * + * @permission ohos.permission.USE_BLUETOOTH + * @returns { Promise } Returns a string representation of the name if obtained; + * returns {@code null} if the name fails to be obtained or the name does not exist. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + getDeviceName(callback: AsyncCallback): void; + getDeviceName(): Promise; + + /** + * Starts discovering services. + * + * @permission ohos.permission.USE_BLUETOOTH + * @returns { Promise> } Returns the list of services {@link GattService} of the BLE peripheral device. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + getServices(callback: AsyncCallback>): void; + getServices(): Promise>; + + /** + * Reads the characteristic of a BLE peripheral device. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param characteristic Indicates the characteristic to read. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2901000 - Read forbidden. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + readCharacteristicValue(characteristic: BLECharacteristic, callback: AsyncCallback): void; + readCharacteristicValue(characteristic: BLECharacteristic): Promise; + + /** + * Reads the descriptor of a BLE peripheral device. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param descriptor Indicates the descriptor to read. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2901000 - Read forbidden. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + readDescriptorValue(descriptor: BLEDescriptor, callback: AsyncCallback): void; + readDescriptorValue(descriptor: BLEDescriptor): Promise; + + /** + * Writes the characteristic of a BLE peripheral device. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param characteristic Indicates the characteristic to write. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2901001 - Write forbidden. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + writeCharacteristicValue(characteristic: BLECharacteristic): void; + + /** + * Writes the descriptor of a BLE peripheral device. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param descriptor Indicates the descriptor to write. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2901001 - Write forbidden. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + writeDescriptorValue(descriptor: BLEDescriptor): void; + + /** + * Get the RSSI value of this BLE peripheral device. + * + * @permission ohos.permission.USE_BLUETOOTH + * @returns { Promise } Returns the RSSI value. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + getRssiValue(callback: AsyncCallback): void; + getRssiValue(): Promise; + + /** + * Set the mtu size of a BLE peripheral device. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param mtu The maximum transmission unit. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + setBLEMtuSize(mtu: number): void; + + /** + * Enables or disables notification of a characteristic when value changed. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param enable Specifies whether to enable notification of the characteristic. The value {@code true} indicates + * that notification is enabled, and the value {@code false} indicates that notification is disabled. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900099 - Operation failed. + * @since 9 + */ + setNotifyCharacteristicChanged(characteristic: BLECharacteristic, enable: boolean): void; + + /** + * Subscribe characteristic value changed event. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param type Type of the characteristic value changed event to listen for. + * @param callback Callback used to listen for the characteristic value changed event. + * @since 9 + */ + on(type: "BLECharacteristicChange", callback: Callback): void; + + /** + * Unsubscribe characteristic value changed event. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param type Type of the characteristic value changed event to listen for. + * @param callback Callback used to listen for the characteristic value changed event. + * @since 9 + */ + off(type: "BLECharacteristicChange", callback?: Callback): void; + + /** + * Subscribe client connection state changed event. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param type Type of the connection state changed event to listen for. + * @param callback Callback used to listen for the connection state changed event. + * @since 9 + */ + on(type: "BLEConnectionStateChange", callback: Callback): void; + + /** + * Unsubscribe client connection state changed event. + * + * @permission ohos.permission.USE_BLUETOOTH + * @param type Type of the connection state changed event to listen for. + * @param callback Callback used to listen for the connection state changed event. + * @since 9 + */ + off(type: "BLEConnectionStateChange", callback?: Callback): void; + } + + /** + * Describes the Gatt service. + * + * @since 9 + */ + interface GattService { + /** The UUID of a GattService instance */ + serviceUuid: string; + /** Indicates whether the GattService instance is primary or secondary. */ + isPrimary: boolean; + /** The {@link BLECharacteristic} list belongs to this GattService instance */ + characteristics: Array; + /** The list of GATT services contained in the service */ + includeServices?: Array; + } + + /** + * Describes the Gatt characteristic. + * + * @since 9 + */ + interface BLECharacteristic { + /** The UUID of the {@link GattService} instance to which the characteristic belongs */ + serviceUuid: string; + /** The UUID of a BLECharacteristic instance */ + characteristicUuid: string; + /** The value of a BLECharacteristic instance */ + characteristicValue: ArrayBuffer; + /** The list of {@link BLEDescriptor} contained in the characteristic */ + descriptors: Array; + } + + /** + * Describes the Gatt descriptor. + * + * @since 9 + */ + interface BLEDescriptor { + /** The UUID of the {@link GattService} instance to which the descriptor belongs */ + serviceUuid: string; + /** The UUID of the {@link BLECharacteristic} instance to which the descriptor belongs */ + characteristicUuid: string; + /** The UUID of the BLEDescriptor instance */ + descriptorUuid: string; + /** The value of the BLEDescriptor instance */ + descriptorValue: ArrayBuffer; + } + + /** + * Describes the value of the indication or notification sent by the Gatt server. + * + * @since 9 + */ + interface NotifyCharacteristic { + /** The UUID of the {@link GattService} instance to which the characteristic belongs */ + serviceUuid: string; + /** The UUID of a NotifyCharacteristic instance */ + characteristicUuid: string; + /** The value of a NotifyCharacteristic instance */ + characteristicValue: ArrayBuffer; + /** + * Specifies whether to request confirmation from the BLE peripheral device (indication) or + * send a notification. Value {@code true} indicates the former and {@code false} indicates the latter. + */ + confirm: boolean; + } + + /** + * Describes the parameters of the Gatt client's characteristic read request. + * + * @since 9 + */ + interface CharacteristicReadRequest { + /** Indicates the address of the client that initiates the read request */ + deviceId: string; + /** The Id of the read request */ + transId: number; + /** Indicates the byte offset of the start position for reading characteristic value */ + offset: number; + /** The UUID of a CharacteristicReadRequest instance */ + characteristicUuid: string; + /** The UUID of the service to which the characteristic belongs */ + serviceUuid: string; + } + + /** + * Describes the parameters of the of the Gatt client's characteristic write request. + * + * @since 9 + */ + interface CharacteristicWriteRequest { + /** Indicates the address of the client that initiates the write request */ + deviceId: string; + /** The Id of the write request */ + transId: number; + /** Indicates the byte offset of the start position for writing characteristic value */ + offset: number; + /** Whether this request should be pending for later operation */ + isPrep: boolean; + /** Whether the remote client need a response */ + needRsp: boolean; + /** Indicates the value to be written */ + value: ArrayBuffer; + /** The UUID of a CharacteristicWriteRequest instance */ + characteristicUuid: string; + /** The UUID of the service to which the characteristic belongs */ + serviceUuid: string; + } + + /** + * Describes the parameters of the Gatt client's descriptor read request. + * + * @since 9 + */ + interface DescriptorReadRequest { + /** Indicates the address of the client that initiates the read request */ + deviceId: string; + /** The Id of the read request */ + transId: number; + /** Indicates the byte offset of the start position for reading characteristic value */ + offset: number; + /** The UUID of a DescriptorReadRequest instance */ + descriptorUuid: string; + /** The UUID of the characteristic to which the descriptor belongs */ + characteristicUuid: string; + /** The UUID of the service to which the descriptor belongs */ + serviceUuid: string; + } + + /** + * Describes the parameters of the Gatt client's characteristic write request. + * + * @since 9 + */ + interface DescriptorWriteRequest { + /** Indicates the address of the client that initiates the write request */ + deviceId: string; + /** The Id of the write request */ + transId: number; + /** Indicates the byte offset of the start position for writing characteristic value */ + offset: number; + /** Whether this request should be pending for later operation */ + isPrep: boolean; + /** Whether the remote client need a response */ + needRsp: boolean; + /** Indicates the value to be written */ + value: ArrayBuffer; + /** The UUID of a DescriptorWriteRequest instance */ + descriptorUuid: string; + /** The UUID of the characteristic to which the descriptor belongs */ + characteristicUuid: string; + /** The UUID of the service to which the descriptor belongs */ + serviceUuid: string; + } + + /** + * Describes the parameters of a response send by the server to a specified read or write request. + * + * @since 9 + */ + interface ServerResponse { + /** Indicates the address of the client to which to send the response */ + deviceId: string; + /** The Id of the write request */ + transId: number; + /** Indicates the status of the read or write request, set this parameter to '0' in normal cases */ + status: number; + /** Indicates the byte offset of the start position for reading or writing operation */ + offset: number; + /** Indicates the value to be sent */ + value: ArrayBuffer; + } + + /** + * Describes the Gatt profile connection state. + * + * @since 9 + */ + interface BLEConnectChangedState { + /** Indicates the peer device address */ + deviceId: string; + /** Connection state of the Gatt profile */ + state: ProfileConnectionState; + } + + /** + * Describes the contents of the scan results. + * + * @since 9 + */ + interface ScanResult { + /** Address of the scanned device */ + deviceId: string; + /** RSSI of the remote device */ + rssi: number; + /** The raw data of broadcast packet */ + data: ArrayBuffer; + } + + /** + * Describes the settings for BLE advertising. + * + * @since 9 + */ + interface AdvertiseSetting { + /** + * Minimum slot value for the advertising interval, which is {@code 32} (20 ms) + * Maximum slot value for the advertising interval, which is {@code 16777215} (10485.759375s) + * Default slot value for the advertising interval, which is {@code 1600} (1s) + */ + interval?: number; + /** + * Minimum transmission power level for advertising, which is {@code -127} + * Maximum transmission power level for advertising, which is {@code 1} + * Default transmission power level for advertising, which is {@code -7} + */ + txPower?: number; + /** Indicates whether the BLE is connectable, default is {@code true} */ + connectable?: boolean; + } + + /** + * Describes the advertising data. + * + * @since 9 + */ + interface AdvertiseData { + /** The specified service UUID list to this advertisement */ + serviceUuids: Array; + /** The specified manufacturer data list to this advertisement */ + manufactureData: Array; + /** The specified service data list to this advertisement */ + serviceData: Array; + } + + /** + * Describes the manufacturer data. + * + * @since 9 + */ + interface ManufactureData { + /** Indicates the manufacturer ID assigned by Bluetooth SIG */ + manufactureId: number; + /** Indicates the manufacturer data to add */ + manufactureValue: ArrayBuffer; + } + + /** + * Describes the service data. + * + * @since 9 + */ + interface ServiceData { + /** Indicates the UUID of the service data to add */ + serviceUuid: string; + /** Indicates the service data to add */ + serviceValue: ArrayBuffer; + } + + /** + * Describes the criteria for filtering scanning results can be set. + * + * @since 9 + */ + interface ScanFilter { + /** + * The address of a BLE peripheral device + * @since 9 + */ + deviceId?: string; + + /** + * The name of a BLE peripheral device + * @since 9 + */ + name?: string; + + /** + * The service UUID of a BLE peripheral device + * @since 9 + */ + serviceUuid?: string; + + /** + * Service UUID mask. + * @since 9 + */ + serviceUuidMask?: string; + + /** + * Service solicitation UUID mask. + * @since 9 + */ + serviceSolicitationUuid?: string; + + /** + * Service solicitation UUID mask. + * @since 9 + */ + serviceSolicitationUuidMask?: string; + + /** + * Service data. + * @since 9 + */ + serviceData?: ArrayBuffer; + + /** + * Service data mask. + * @since 9 + */ + serviceDataMask?: ArrayBuffer; + + /** + * Manufacture id. + * @since 9 + */ + manufactureId?: number; + + /** + * Manufacture data. + * @since 9 + */ + manufactureData?: ArrayBuffer; + + /** + * Manufacture data mask. + * @since 9 + */ + manufactureDataMask?: ArrayBuffer; + } + + /** + * Describes the parameters for scan. + * + * @since 9 + */ + interface ScanOptions { + /** Time of delay for reporting the scan result */ + interval?: number; + /** Bluetooth LE scan mode */ + dutyMode?: ScanDuty; + /** Match mode for Bluetooth LE scan filters hardware match */ + matchMode?: MatchMode; + } + + /** + * Describes the spp parameters. + * + * @since 9 + */ + interface SppOption { + /** Indicates the UUID in the SDP record. */ + uuid: string; + /** Indicates secure channel or not */ + secure: boolean; + /** Spp link type {@link SppType}*/ + type: SppType; + } + + /** + * Describes the bond key param. + * + * @since 9 + */ + interface PinRequiredParam { + deviceId: string; + pinCode: string; + } + + /** + * Describes the class of a bluetooth device. + * + * @since 9 + */ + interface DeviceClass { + majorClass: MajorClass; + majorMinorClass: MajorMinorClass; + classOfDevice: number; + } + + /** + * Describes the class of a bluetooth device. + * + * @since 9 + */ + interface BondStateParam { + deviceId: string; + state: BondState; + } + + /** + * Profile state change parameters. + * + * @since 9 + */ + interface StateChangeParam { + /** The address of device */ + deviceId: string; + + /** Profile state value */ + state: ProfileConnectionState; + } + + /** + * The enum of scan duty. + * + * @since 9 + */ + enum ScanDuty { + /** low power mode */ + SCAN_MODE_LOW_POWER = 0, + /** balanced power mode */ + SCAN_MODE_BALANCED = 1, + /** Scan using highest duty cycle */ + SCAN_MODE_LOW_LATENCY = 2 + } + + /** + * The enum of BLE match mode. + * + * @since 9 + */ + enum MatchMode { + /** aggressive mode */ + MATCH_MODE_AGGRESSIVE = 1, + /** sticky mode */ + MATCH_MODE_STICKY = 2 + } + + /** + * The enum of profile connection state. + * + * @since 9 + */ + enum ProfileConnectionState { + /** the current profile is disconnected */ + STATE_DISCONNECTED = 0, + /** the current profile is being connected */ + STATE_CONNECTING = 1, + /** the current profile is connected */ + STATE_CONNECTED = 2, + /** the current profile is being disconnected */ + STATE_DISCONNECTING = 3 + } + + /** + * The enum of bluetooth state. + * + * @since 9 + */ + enum BluetoothState { + /** Indicates the local Bluetooth is off */ + STATE_OFF = 0, + /** Indicates the local Bluetooth is turning on */ + STATE_TURNING_ON = 1, + /** Indicates the local Bluetooth is on, and ready for use */ + STATE_ON = 2, + /** Indicates the local Bluetooth is turning off */ + STATE_TURNING_OFF = 3, + /** Indicates the local Bluetooth is turning LE mode on */ + STATE_BLE_TURNING_ON = 4, + /** Indicates the local Bluetooth is in LE only mode */ + STATE_BLE_ON = 5, + /** Indicates the local Bluetooth is turning off LE only mode */ + STATE_BLE_TURNING_OFF = 6 + } + + /** + * The enum of SPP type. + * + * @since 9 + */ + enum SppType { + /** RFCOMM */ + SPP_RFCOMM + } + + /** + * The enum of BR scan mode. + * + * @since 9 + */ + enum ScanMode { + /** Indicates the scan mode is none */ + SCAN_MODE_NONE = 0, + /** Indicates the scan mode is connectable */ + SCAN_MODE_CONNECTABLE = 1, + /** Indicates the scan mode is general discoverable */ + SCAN_MODE_GENERAL_DISCOVERABLE = 2, + /** Indicates the scan mode is limited discoverable */ + SCAN_MODE_LIMITED_DISCOVERABLE = 3, + /** Indicates the scan mode is connectable and general discoverable */ + SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE = 4, + /** Indicates the scan mode is connectable and limited discoverable */ + SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE = 5 + } + + /** + * The enum of bond state. + * + * @since 9 + */ + enum BondState { + /** Indicate the bond state is invalid */ + BOND_STATE_INVALID = 0, + /** Indicate the bond state is bonding */ + BOND_STATE_BONDING = 1, + /** Indicate the bond state is bonded*/ + BOND_STATE_BONDED = 2 + } + + /** + * The enum of major class of a bluetooth device. + * + * @since 9 + */ + enum MajorClass { + MAJOR_MISC = 0x0000, + MAJOR_COMPUTER = 0x0100, + MAJOR_PHONE = 0x0200, + MAJOR_NETWORKING = 0x0300, + MAJOR_AUDIO_VIDEO = 0x0400, + MAJOR_PERIPHERAL = 0x0500, + MAJOR_IMAGING = 0x0600, + MAJOR_WEARABLE = 0x0700, + MAJOR_TOY = 0x0800, + MAJOR_HEALTH = 0x0900, + MAJOR_UNCATEGORIZED = 0x1F00 + } + + /** + * The enum of major minor class of a bluetooth device. + * + * @since 9 + */ + enum MajorMinorClass { + // The Minor Device Class field + // Computer Major Class + COMPUTER_UNCATEGORIZED = 0x0100, + COMPUTER_DESKTOP = 0x0104, + COMPUTER_SERVER = 0x0108, + COMPUTER_LAPTOP = 0x010C, + COMPUTER_HANDHELD_PC_PDA = 0x0110, + COMPUTER_PALM_SIZE_PC_PDA = 0x0114, + COMPUTER_WEARABLE = 0x0118, + COMPUTER_TABLET = 0x011C, + + // Phone Major Class + PHONE_UNCATEGORIZED = 0x0200, + PHONE_CELLULAR = 0x0204, + PHONE_CORDLESS = 0x0208, + PHONE_SMART = 0x020C, + PHONE_MODEM_OR_GATEWAY = 0x0210, + PHONE_ISDN = 0x0214, + + // LAN/Network Access Point Major Class + NETWORK_FULLY_AVAILABLE = 0x0300, + NETWORK_1_TO_17_UTILIZED = 0x0320, + NETWORK_17_TO_33_UTILIZED = 0x0340, + NETWORK_33_TO_50_UTILIZED = 0x0360, + NETWORK_60_TO_67_UTILIZED = 0x0380, + NETWORK_67_TO_83_UTILIZED = 0x03A0, + NETWORK_83_TO_99_UTILIZED = 0x03C0, + NETWORK_NO_SERVICE = 0x03E0, + + // Audio/Video Major Class + AUDIO_VIDEO_UNCATEGORIZED = 0x0400, + AUDIO_VIDEO_WEARABLE_HEADSET = 0x0404, + AUDIO_VIDEO_HANDSFREE = 0x0408, + AUDIO_VIDEO_MICROPHONE = 0x0410, + AUDIO_VIDEO_LOUDSPEAKER = 0x0414, + AUDIO_VIDEO_HEADPHONES = 0x0418, + AUDIO_VIDEO_PORTABLE_AUDIO = 0x041C, + AUDIO_VIDEO_CAR_AUDIO = 0x0420, + AUDIO_VIDEO_SET_TOP_BOX = 0x0424, + AUDIO_VIDEO_HIFI_AUDIO = 0x0428, + AUDIO_VIDEO_VCR = 0x042C, + AUDIO_VIDEO_VIDEO_CAMERA = 0x0430, + AUDIO_VIDEO_CAMCORDER = 0x0434, + AUDIO_VIDEO_VIDEO_MONITOR = 0x0438, + AUDIO_VIDEO_VIDEO_DISPLAY_AND_LOUDSPEAKER = 0x043C, + AUDIO_VIDEO_VIDEO_CONFERENCING = 0x0440, + AUDIO_VIDEO_VIDEO_GAMING_TOY = 0x0448, + + // Peripheral Major Class + PERIPHERAL_NON_KEYBOARD_NON_POINTING = 0x0500, + PERIPHERAL_KEYBOARD = 0x0540, + PERIPHERAL_POINTING_DEVICE = 0x0580, + PERIPHERAL_KEYBOARD_POINTING = 0x05C0, + PERIPHERAL_UNCATEGORIZED = 0x0500, + PERIPHERAL_JOYSTICK = 0x0504, + PERIPHERAL_GAMEPAD = 0x0508, + PERIPHERAL_REMOTE_CONTROL = 0x05C0, + PERIPHERAL_SENSING_DEVICE = 0x0510, + PERIPHERAL_DIGITIZER_TABLET = 0x0514, + PERIPHERAL_CARD_READER = 0x0518, + PERIPHERAL_DIGITAL_PEN = 0x051C, + PERIPHERAL_SCANNER_RFID = 0x0520, + PERIPHERAL_GESTURAL_INPUT = 0x0522, + + // Imaging Major Class + IMAGING_UNCATEGORIZED = 0x0600, + IMAGING_DISPLAY = 0x0610, + IMAGING_CAMERA = 0x0620, + IMAGING_SCANNER = 0x0640, + IMAGING_PRINTER = 0x0680, + + // Wearable Major Class + WEARABLE_UNCATEGORIZED = 0x0700, + WEARABLE_WRIST_WATCH = 0x0704, + WEARABLE_PAGER = 0x0708, + WEARABLE_JACKET = 0x070C, + WEARABLE_HELMET = 0x0710, + WEARABLE_GLASSES = 0x0714, + + // Minor Device Class field - Toy Major Class + TOY_UNCATEGORIZED = 0x0800, + TOY_ROBOT = 0x0804, + TOY_VEHICLE = 0x0808, + TOY_DOLL_ACTION_FIGURE = 0x080C, + TOY_CONTROLLER = 0x0810, + TOY_GAME = 0x0814, + + // Minor Device Class field - Health + HEALTH_UNCATEGORIZED = 0x0900, + HEALTH_BLOOD_PRESSURE = 0x0904, + HEALTH_THERMOMETER = 0x0908, + HEALTH_WEIGHING = 0x090C, + HEALTH_GLUCOSE = 0x0910, + HEALTH_PULSE_OXIMETER = 0x0914, + HEALTH_PULSE_RATE = 0x0918, + HEALTH_DATA_DISPLAY = 0x091C, + HEALTH_STEP_COUNTER = 0x0920, + HEALTH_BODY_COMPOSITION_ANALYZER = 0x0924, + HEALTH_PEAK_FLOW_MONITOR = 0x0928, + HEALTH_MEDICATION_MONITOR = 0x092C, + HEALTH_KNEE_PROSTHESIS = 0x0930, + HEALTH_ANKLE_PROSTHESIS = 0x0934, + HEALTH_GENERIC_HEALTH_MANAGER = 0x0938, + HEALTH_PERSONAL_MOBILITY_DEVICE = 0x093C, + } + + /** + * The enum of a2dp playing state. + * + * @since 9 + */ + enum PlayingState { + STATE_NOT_PLAYING, + STATE_PLAYING, + } + + /** + * The enum of profile id. + * + * @since 9 + */ + enum ProfileId { + /** + * @since 9 + */ + PROFILE_A2DP_SOURCE = 1, + + /** + * @since 9 + */ + PROFILE_HANDS_FREE_AUDIO_GATEWAY = 4, + + /** + * @since 9 + */ + PROFILE_HID_HOST = 6, + + /** + * @since 9 + */ + PROFILE_PAN_NETWORK = 7, + } +} + +export default bluetoothManager; \ No newline at end of file -- Gitee From ca092c53c5f9fe90fa0f63d902e75905a9a2e81b Mon Sep 17 00:00:00 2001 From: tangjia Date: Mon, 6 Feb 2023 14:47:47 +0800 Subject: [PATCH 2/2] add the 801 errorCode Signed-off-by: tangjia --- api/@ohos.bluetoothManager.d.ts | 144 +++++++++++++++++++++++++++++++- 1 file changed, 142 insertions(+), 2 deletions(-) diff --git a/api/@ohos.bluetoothManager.d.ts b/api/@ohos.bluetoothManager.d.ts index f2e9e6f120..348db1a618 100644 --- a/api/@ohos.bluetoothManager.d.ts +++ b/api/@ohos.bluetoothManager.d.ts @@ -31,6 +31,7 @@ declare namespace bluetoothManager { * {@link BluetoothState#STATE_BLE_TURNING_ON}, {@link BluetoothState#STATE_BLE_ON}, * or {@link BluetoothState#STATE_BLE_TURNING_OFF}. * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900099 - Operation failed. * @since 9 @@ -45,6 +46,7 @@ declare namespace bluetoothManager { * {@link ProfileConnectionState#STATE_CONNECTING}, {@link ProfileConnectionState#STATE_CONNECTED}, * {@link ProfileConnectionState#STATE_DISCONNECTING}. * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900099 - Operation failed. @@ -59,6 +61,7 @@ declare namespace bluetoothManager { * @param deviceId The address of the remote device to pair. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900099 - Operation failed. @@ -74,6 +77,7 @@ declare namespace bluetoothManager { * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900099 - Operation failed. @@ -90,6 +94,7 @@ declare namespace bluetoothManager { * @returns { string } Returns the device name in character string format. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900099 - Operation failed. @@ -105,6 +110,7 @@ declare namespace bluetoothManager { * @returns { DeviceClass } The class of the remote device, {@link DeviceClass}. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900099 - Operation failed. @@ -117,6 +123,7 @@ declare namespace bluetoothManager { * * @permission ohos.permission.DISCOVER_BLUETOOTH * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900099 - Operation failed. * @since 9 @@ -128,6 +135,7 @@ declare namespace bluetoothManager { * * @permission ohos.permission.DISCOVER_BLUETOOTH * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900099 - Operation failed. * @since 9 @@ -140,6 +148,7 @@ declare namespace bluetoothManager { * @permission ohos.permission.USE_BLUETOOTH * @returns { string } Returns the name the device. * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900099 - Operation failed. * @since 9 @@ -152,6 +161,7 @@ declare namespace bluetoothManager { * @permission ohos.permission.USE_BLUETOOTH * @returns { Array } Returns a list of paired Bluetooth devices's address. * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900099 - Operation failed. @@ -167,6 +177,7 @@ declare namespace bluetoothManager { * @returns { ProfileConnectionState } Returns the connection state. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900004 - Profile is not supported. @@ -183,6 +194,7 @@ declare namespace bluetoothManager { * @param accept Indicates whether to accept the pairing request, {@code true} indicates accept or {@code false} otherwise. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900099 - Operation failed. @@ -197,6 +209,7 @@ declare namespace bluetoothManager { * @param name Indicates a valid Bluetooth name. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900099 - Operation failed. @@ -212,6 +225,7 @@ declare namespace bluetoothManager { * @param duration Indicates the duration in seconds, in which the host is discoverable. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900099 - Operation failed. @@ -225,6 +239,7 @@ declare namespace bluetoothManager { * @permission ohos.permission.USE_BLUETOOTH * @returns { ScanMode } Returns the Bluetooth scanning mode, {@link ScanMode}. * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900099 - Operation failed. @@ -238,6 +253,7 @@ declare namespace bluetoothManager { * @permission ohos.permission.DISCOVER_BLUETOOTH and ohos.permission.LOCATION * and ohos.permission.APPROXIMATELY_LOCATION * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900099 - Operation failed. @@ -250,6 +266,7 @@ declare namespace bluetoothManager { * * @permission ohos.permission.DISCOVER_BLUETOOTH * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900099 - Operation failed. @@ -264,6 +281,8 @@ declare namespace bluetoothManager { * @param type Type of the discovering event to listen for. * @param callback Callback used to listen for the discovering event. * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900099 - Operation failed. * @since 9 */ @@ -276,6 +295,7 @@ declare namespace bluetoothManager { * @param type Type of the discovering event to listen for. * @param callback Callback used to listen for the discovering event. * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900099 - Operation failed. * @since 9 */ @@ -288,6 +308,8 @@ declare namespace bluetoothManager { * @param type Type of the bond state event to listen for. * @param callback Callback used to listen for the bond state event, {@link BondStateParam}. * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900099 - Operation failed. * @since 9 */ @@ -300,6 +322,8 @@ declare namespace bluetoothManager { * @param type Type of the bond state event to listen for. * @param callback Callback used to listen for the bond state event. * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900099 - Operation failed. * @since 9 */ @@ -312,6 +336,8 @@ declare namespace bluetoothManager { * @param type Type of the pairing request event to listen for. * @param callback Callback used to listen for the pairing request event. * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900099 - Operation failed. * @since 9 */ @@ -324,6 +350,8 @@ declare namespace bluetoothManager { * @param type Type of the pairing request event to listen for. * @param callback Callback used to listen for the pairing request event. * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900099 - Operation failed. * @since 9 */ @@ -336,6 +364,8 @@ declare namespace bluetoothManager { * @param type Type of the Bluetooth state changes event to listen for. * @param callback Callback used to listen for the Bluetooth state event. * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900099 - Operation failed. * @since 9 */ @@ -348,6 +378,8 @@ declare namespace bluetoothManager { * @param type Type of the Bluetooth state changes event to listen for. * @param callback Callback used to listen for the Bluetooth state event. * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900099 - Operation failed. * @since 9 */ @@ -362,6 +394,7 @@ declare namespace bluetoothManager { * @param callback Callback used to return a server socket ID. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900004 - Profile is not supported. @@ -376,6 +409,7 @@ declare namespace bluetoothManager { * @param serverSocket Indicates the server socket ID, returned by {@link sppListen}. * @param callback Callback used to return a client socket ID. * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900004 - Profile is not supported. @@ -391,7 +425,9 @@ declare namespace bluetoothManager { * @param device The address of the remote device to connect. * @param option Indicates the connect parameters {@link SppOption}. * @param callback Callback used to return a client socket ID. + * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900004 - Profile is not supported. @@ -405,6 +441,7 @@ declare namespace bluetoothManager { * * @param socket Indicates the server socket ID, returned by {@link sppListen}. * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900099 - Operation failed. * @since 9 @@ -416,6 +453,7 @@ declare namespace bluetoothManager { * * @param socket Indicates the client socket ID, returned by {@link sppAccept} or {@link sppConnect}. * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900099 - Operation failed. * @since 9 @@ -428,6 +466,7 @@ declare namespace bluetoothManager { * @param clientSocket Indicates the client socket ID, returned by {@link sppAccept} or {@link sppConnect}. * @param data Indicates the data to write. * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2901054 - IO error. * @throws { BusinessError } 2900099 - Operation failed. * @since 9 @@ -440,6 +479,7 @@ declare namespace bluetoothManager { * @param type Type of the spp read event to listen for. * @param callback Callback used to listen for the spp read event. * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2901054 - IO error. * @throws { BusinessError } 2900099 - Operation failed. * @since 9 @@ -451,6 +491,8 @@ declare namespace bluetoothManager { * * @param type Type of the spp read event to listen for. * @param callback Callback used to listen for the spp read event. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @since 9 */ function off(type: "sppRead", clientSocket: number, callback?: Callback): void; @@ -460,6 +502,8 @@ declare namespace bluetoothManager { * * @param profileId The profile id.. * @returns { A2dpSourceProfile | HandsFreeAudioGatewayProfile | HidHostProfile | PanProfile } Returns the instance of profile. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @since 9 */ function getProfileInstance(profileId: ProfileId): A2dpSourceProfile | HandsFreeAudioGatewayProfile | HidHostProfile | PanProfile; @@ -474,6 +518,7 @@ declare namespace bluetoothManager { * @permission ohos.permission.USE_BLUETOOTH * @returns { Array } Returns the address of connected devices list. * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900004 - Profile is not supported. @@ -490,6 +535,7 @@ declare namespace bluetoothManager { * @returns { ProfileConnectionState } Returns {@link ProfileConnectionState} of device. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900004 - Profile is not supported. @@ -510,6 +556,7 @@ declare namespace bluetoothManager { * @param device The address of the remote device to connect. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900004 - Profile is not supported. @@ -525,6 +572,7 @@ declare namespace bluetoothManager { * @param device The address of the remote device to disconnect. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900004 - Profile is not supported. @@ -538,6 +586,8 @@ declare namespace bluetoothManager { * * @param type Type of the profile connection state changes event to listen for . * @param callback Callback used to listen for event. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @since 9 */ on(type: "connectionStateChange", callback: Callback): void; @@ -547,6 +597,8 @@ declare namespace bluetoothManager { * * @param type Type of the profile connection state changes event to listen for . * @param callback Callback used to listen for event. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @since 9 */ off(type: "connectionStateChange", callback?: Callback): void; @@ -557,6 +609,7 @@ declare namespace bluetoothManager { * @param device The address of the remote device. * @returns { PlayingState } Returns {@link PlayingState} of the remote device. * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900004 - Profile is not supported. @@ -577,6 +630,7 @@ declare namespace bluetoothManager { * @param device The address of the remote device to connect. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900004 - Profile is not supported. @@ -592,6 +646,7 @@ declare namespace bluetoothManager { * @param device The address of the remote device to disconnect. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900004 - Profile is not supported. @@ -605,6 +660,8 @@ declare namespace bluetoothManager { * * @param type Type of the profile connection state changes event to listen for . * @param callback Callback used to listen for event. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @since 9 */ on(type: "connectionStateChange", callback: Callback): void; @@ -614,6 +671,8 @@ declare namespace bluetoothManager { * * @param type Type of the profile connection state changes event to listen for . * @param callback Callback used to listen for event. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @since 9 */ off(type: "connectionStateChange", callback?: Callback): void; @@ -631,6 +690,7 @@ declare namespace bluetoothManager { * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900004 - Profile is not supported. @@ -648,6 +708,7 @@ declare namespace bluetoothManager { * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900004 - Profile is not supported. @@ -662,6 +723,8 @@ declare namespace bluetoothManager { * * @param type Type of the profile connection state changes event to listen for . * @param callback Callback used to listen for event. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @since 9 */ on(type: "connectionStateChange", callback: Callback): void; @@ -671,6 +734,8 @@ declare namespace bluetoothManager { * * @param type Type of the profile connection state changes event to listen for. * @param callback Callback used to listen for event. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @since 9 */ off(type: "connectionStateChange", callback?: Callback): void; @@ -688,6 +753,7 @@ declare namespace bluetoothManager { * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900004 - Profile is not supported. @@ -702,6 +768,8 @@ declare namespace bluetoothManager { * * @param type Type of the profile connection state changes event to listen for . * @param callback Callback used to listen for event. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @since 9 */ on(type: "connectionStateChange", callback: Callback): void; @@ -711,6 +779,8 @@ declare namespace bluetoothManager { * * @param type Type of the profile connection state changes event to listen for. * @param callback Callback used to listen for event. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @since 9 */ off(type: "connectionStateChange", callback?: Callback): void; @@ -723,6 +793,8 @@ declare namespace bluetoothManager { * that tethering is enabled, and the value {@code false} indicates that tethering is disabled. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900004 - Profile is not supported. @@ -737,6 +809,7 @@ declare namespace bluetoothManager { * * @returns { boolean } Returns the value {@code true} is tethering is on, returns {@code false} otherwise. * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. + * @throws { BusinessError } 801 - Capability not supported. * @systemapi Hide this for inner system use. * @since 9 */ @@ -759,6 +832,7 @@ declare namespace bluetoothManager { * @returns { GattClientDevice } Returns a JavaScript Gatt client device instance {@code GattClientDevice}. * @since 9 * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. */ function createGattClientDevice(deviceId: string): GattClientDevice; @@ -768,6 +842,7 @@ declare namespace bluetoothManager { * @permission ohos.permission.USE_BLUETOOTH * @returns { Array } Returns the list of device address. * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900099 - Operation failed. @@ -787,6 +862,7 @@ declare namespace bluetoothManager { * and {@link ScanOptions#matchMode} set to {@link MATCH_MODE_AGGRESSIVE}. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900099 - Operation failed. @@ -800,7 +876,7 @@ declare namespace bluetoothManager { * @since 9 * @permission ohos.permission.DISCOVER_BLUETOOTH * @throws { BusinessError } 201 - Permission denied. - * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900099 - Operation failed. @@ -814,6 +890,8 @@ declare namespace bluetoothManager { * @param type Type of the scan result event to listen for. * @param callback Callback used to listen for the scan result event. * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900099 - Operation failed. * @since 9 */ @@ -826,6 +904,8 @@ declare namespace bluetoothManager { * @param type Type of the scan result event to listen for. * @param callback Callback used to listen for the scan result event. * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900099 - Operation failed. * @since 9 */ @@ -846,6 +926,7 @@ declare namespace bluetoothManager { * @param advResponse Indicates the scan response associated with the advertising data. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900099 - Operation failed. @@ -858,6 +939,7 @@ declare namespace bluetoothManager { * * @permission ohos.permission.DISCOVER_BLUETOOTH * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900099 - Operation failed. @@ -874,6 +956,7 @@ declare namespace bluetoothManager { * @param service Indicates the service to add. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900099 - Operation failed. @@ -888,6 +971,7 @@ declare namespace bluetoothManager { * @param serviceUuid Indicates the UUID of the service to remove. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900004 - Profile is not supported. @@ -901,6 +985,7 @@ declare namespace bluetoothManager { * * @permission ohos.permission.USE_BLUETOOTH * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900099 - Operation failed. @@ -918,6 +1003,7 @@ declare namespace bluetoothManager { * @param notifyCharacteristic Indicates the local characteristic that has changed. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900099 - Operation failed. @@ -932,6 +1018,7 @@ declare namespace bluetoothManager { * @param serverResponse Indicates the response parameters {@link ServerResponse}. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900099 - Operation failed. @@ -945,6 +1032,9 @@ declare namespace bluetoothManager { * @permission ohos.permission.USE_BLUETOOTH * @param type Type of the characteristic read event to listen for. * @param callback Callback used to listen for the characteristic read event. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @since 9 */ on(type: "characteristicRead", callback: Callback): void; @@ -955,6 +1045,9 @@ declare namespace bluetoothManager { * @permission ohos.permission.USE_BLUETOOTH * @param type Type of the characteristic read event to listen for. * @param callback Callback used to listen for the characteristic read event. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @since 9 */ off(type: "characteristicRead", callback?: Callback): void; @@ -965,6 +1058,9 @@ declare namespace bluetoothManager { * @permission ohos.permission.USE_BLUETOOTH * @param type Type of the characteristic write event to listen for. * @param callback Callback used to listen for the characteristic write event. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @since 9 */ on(type: "characteristicWrite", callback: Callback): void; @@ -975,6 +1071,9 @@ declare namespace bluetoothManager { * @permission ohos.permission.USE_BLUETOOTH * @param type Type of the characteristic write event to listen for. * @param callback Callback used to listen for the characteristic write event. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @since 9 */ off(type: "characteristicWrite", callback?: Callback): void; @@ -985,6 +1084,9 @@ declare namespace bluetoothManager { * @permission ohos.permission.USE_BLUETOOTH * @param type Type of the descriptor read event to listen for. * @param callback Callback used to listen for the descriptor read event. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @since 9 */ on(type: "descriptorRead", callback: Callback): void; @@ -995,6 +1097,9 @@ declare namespace bluetoothManager { * @permission ohos.permission.USE_BLUETOOTH * @param type Type of the descriptor read event to listen for. * @param callback Callback used to listen for the descriptor read event. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @since 9 */ off(type: "descriptorRead", callback?: Callback): void; @@ -1005,6 +1110,9 @@ declare namespace bluetoothManager { * @permission ohos.permission.USE_BLUETOOTH * @param type Type of the descriptor write event to listen for. * @param callback Callback used to listen for the descriptor write event. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @since 9 */ on(type: "descriptorWrite", callback: Callback): void; @@ -1015,6 +1123,9 @@ declare namespace bluetoothManager { * @permission ohos.permission.USE_BLUETOOTH * @param type Type of the descriptor write event to listen for. * @param callback Callback used to listen for the descriptor write event. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @since 9 */ off(type: "descriptorWrite", callback?: Callback): void; @@ -1025,6 +1136,9 @@ declare namespace bluetoothManager { * @permission ohos.permission.USE_BLUETOOTH * @param type Type of the connection state changed event to listen for. * @param callback Callback used to listen for the connection state changed event. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @since 9 */ on(type: "connectStateChange", callback: Callback): void; @@ -1035,6 +1149,9 @@ declare namespace bluetoothManager { * @permission ohos.permission.USE_BLUETOOTH * @param type Type of the connection state changed event to listen for. * @param callback Callback used to listen for the connection state changed event. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @since 9 */ off(type: "connectStateChange", callback?: Callback): void; @@ -1052,6 +1169,7 @@ declare namespace bluetoothManager { * * @permission ohos.permission.USE_BLUETOOTH * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900099 - Operation failed. @@ -1064,6 +1182,7 @@ declare namespace bluetoothManager { * * @permission ohos.permission.USE_BLUETOOTH * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900099 - Operation failed. @@ -1079,6 +1198,7 @@ declare namespace bluetoothManager { * @permission ohos.permission.USE_BLUETOOTH * @returns { boolean } Returns {@code true} if the the device is disabled; returns {@code false} otherwise. * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900003 - Bluetooth switch is off. * @throws { BusinessError } 2900099 - Operation failed. @@ -1093,6 +1213,8 @@ declare namespace bluetoothManager { * @returns { Promise } Returns a string representation of the name if obtained; * returns {@code null} if the name fails to be obtained or the name does not exist. * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900099 - Operation failed. * @since 9 @@ -1106,6 +1228,8 @@ declare namespace bluetoothManager { * @permission ohos.permission.USE_BLUETOOTH * @returns { Promise> } Returns the list of services {@link GattService} of the BLE peripheral device. * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900099 - Operation failed. * @since 9 @@ -1120,6 +1244,7 @@ declare namespace bluetoothManager { * @param characteristic Indicates the characteristic to read. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2901000 - Read forbidden. * @throws { BusinessError } 2900099 - Operation failed. @@ -1135,6 +1260,7 @@ declare namespace bluetoothManager { * @param descriptor Indicates the descriptor to read. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2901000 - Read forbidden. * @throws { BusinessError } 2900099 - Operation failed. @@ -1150,6 +1276,7 @@ declare namespace bluetoothManager { * @param characteristic Indicates the characteristic to write. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2901001 - Write forbidden. * @throws { BusinessError } 2900099 - Operation failed. @@ -1164,6 +1291,7 @@ declare namespace bluetoothManager { * @param descriptor Indicates the descriptor to write. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2901001 - Write forbidden. * @throws { BusinessError } 2900099 - Operation failed. @@ -1177,6 +1305,8 @@ declare namespace bluetoothManager { * @permission ohos.permission.USE_BLUETOOTH * @returns { Promise } Returns the RSSI value. * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900099 - Operation failed. * @since 9 */ @@ -1190,6 +1320,7 @@ declare namespace bluetoothManager { * @param mtu The maximum transmission unit. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900099 - Operation failed. * @since 9 @@ -1204,6 +1335,7 @@ declare namespace bluetoothManager { * that notification is enabled, and the value {@code false} indicates that notification is disabled. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - Invalid parameter. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 2900001 - Service stopped. * @throws { BusinessError } 2900099 - Operation failed. * @since 9 @@ -1216,6 +1348,8 @@ declare namespace bluetoothManager { * @permission ohos.permission.USE_BLUETOOTH * @param type Type of the characteristic value changed event to listen for. * @param callback Callback used to listen for the characteristic value changed event. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. * @since 9 */ on(type: "BLECharacteristicChange", callback: Callback): void; @@ -1226,6 +1360,8 @@ declare namespace bluetoothManager { * @permission ohos.permission.USE_BLUETOOTH * @param type Type of the characteristic value changed event to listen for. * @param callback Callback used to listen for the characteristic value changed event. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. * @since 9 */ off(type: "BLECharacteristicChange", callback?: Callback): void; @@ -1236,6 +1372,8 @@ declare namespace bluetoothManager { * @permission ohos.permission.USE_BLUETOOTH * @param type Type of the connection state changed event to listen for. * @param callback Callback used to listen for the connection state changed event. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. * @since 9 */ on(type: "BLEConnectionStateChange", callback: Callback): void; @@ -1246,6 +1384,8 @@ declare namespace bluetoothManager { * @permission ohos.permission.USE_BLUETOOTH * @param type Type of the connection state changed event to listen for. * @param callback Callback used to listen for the connection state changed event. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. * @since 9 */ off(type: "BLEConnectionStateChange", callback?: Callback): void; @@ -1541,7 +1681,7 @@ declare namespace bluetoothManager { serviceUuidMask?: string; /** - * Service solicitation UUID mask. + * Service solicitation UUID. * @since 9 */ serviceSolicitationUuid?: string; -- Gitee