!10863 蓝牙模块新增@atomicservice标签

Merge pull request !10863 from liuqian_herb/master
This commit is contained in:
openharmony_ci 2024-05-08 12:38:23 +00:00 committed by Gitee
commit 652b35a79f
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 1202 additions and 0 deletions

View File

@ -47,6 +47,18 @@ declare namespace access {
* @syscap SystemCapability.Communication.Bluetooth.Core * @syscap SystemCapability.Communication.Bluetooth.Core
* @since 10 * @since 10
*/ */
/**
* Enables Bluetooth on a device.
*
* @permission ohos.permission.ACCESS_BLUETOOTH
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 801 - Capability not supported.
* @throws { BusinessError } 2900001 - Service stopped.
* @throws { BusinessError } 2900099 - Operation failed.
* @syscap SystemCapability.Communication.Bluetooth.Core
* @atomicservice
* @since 12
*/
function enableBluetooth(): void; function enableBluetooth(): void;
/** /**
@ -60,6 +72,18 @@ declare namespace access {
* @syscap SystemCapability.Communication.Bluetooth.Core * @syscap SystemCapability.Communication.Bluetooth.Core
* @since 10 * @since 10
*/ */
/**
* Disables Bluetooth on a device.
*
* @permission ohos.permission.ACCESS_BLUETOOTH
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 801 - Capability not supported.
* @throws { BusinessError } 2900001 - Service stopped.
* @throws { BusinessError } 2900099 - Operation failed.
* @syscap SystemCapability.Communication.Bluetooth.Core
* @atomicservice
* @since 12
*/
function disableBluetooth(): void; function disableBluetooth(): void;
/** /**
@ -151,6 +175,20 @@ declare namespace access {
* @syscap SystemCapability.Communication.Bluetooth.Core * @syscap SystemCapability.Communication.Bluetooth.Core
* @since 10 * @since 10
*/ */
/**
* Subscribe the event reported when the Bluetooth state changes.
*
* @permission ohos.permission.ACCESS_BLUETOOTH
* @param { 'stateChange' } type - Type of the Bluetooth state changes event to listen for.
* @param { Callback<BluetoothState> } 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.
* @syscap SystemCapability.Communication.Bluetooth.Core
* @atomicservice
* @since 12
*/
function on(type: 'stateChange', callback: Callback<BluetoothState>): void; function on(type: 'stateChange', callback: Callback<BluetoothState>): void;
/** /**
@ -166,6 +204,20 @@ declare namespace access {
* @syscap SystemCapability.Communication.Bluetooth.Core * @syscap SystemCapability.Communication.Bluetooth.Core
* @since 10 * @since 10
*/ */
/**
* Unsubscribe the event reported when the Bluetooth state changes.
*
* @permission ohos.permission.ACCESS_BLUETOOTH
* @param { 'stateChange' } type - Type of the Bluetooth state changes event to listen for.
* @param { Callback<BluetoothState> } 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.
* @syscap SystemCapability.Communication.Bluetooth.Core
* @atomicservice
* @since 12
*/
function off(type: 'stateChange', callback?: Callback<BluetoothState>): void; function off(type: 'stateChange', callback?: Callback<BluetoothState>): void;
/** /**

File diff suppressed because it is too large Load Diff

View File

@ -28,10 +28,19 @@ import type constant from './@ohos.bluetooth.constant';
* @syscap SystemCapability.Communication.Bluetooth.Core * @syscap SystemCapability.Communication.Bluetooth.Core
* @since 10 * @since 10
*/ */
/**
* Provides methods to operate or manage Bluetooth.
*
* @namespace connection
* @syscap SystemCapability.Communication.Bluetooth.Core
* @atomicservice
* @since 12
*/
declare namespace connection { declare namespace connection {
/** /**
* Indicate the profile connection state. * Indicate the profile connection state.
* *
* @typedef { constant.ProfileConnectionState } ProfileConnectionState
* @syscap SystemCapability.Communication.Bluetooth.Core * @syscap SystemCapability.Communication.Bluetooth.Core
* @since 10 * @since 10
*/ */
@ -40,6 +49,7 @@ declare namespace connection {
/** /**
* Indicate the profile id. * Indicate the profile id.
* *
* @typedef { constant.ProfileId } ProfileId
* @syscap SystemCapability.Communication.Bluetooth.Core * @syscap SystemCapability.Communication.Bluetooth.Core
* @since 10 * @since 10
*/ */
@ -48,6 +58,7 @@ declare namespace connection {
/** /**
* Indicate the profile uuid. * Indicate the profile uuid.
* *
* @typedef { constant.ProfileUuids } ProfileUuids
* @syscap SystemCapability.Communication.Bluetooth.Core * @syscap SystemCapability.Communication.Bluetooth.Core
* @systemapi * @systemapi
* @since 10 * @since 10
@ -57,6 +68,7 @@ declare namespace connection {
/** /**
* Indicate the major class of a bluetooth device. * Indicate the major class of a bluetooth device.
* *
* @typedef { constant.MajorClass } MajorClass
* @syscap SystemCapability.Communication.Bluetooth.Core * @syscap SystemCapability.Communication.Bluetooth.Core
* @since 10 * @since 10
*/ */
@ -65,6 +77,7 @@ declare namespace connection {
/** /**
* Indicate the major minor class of a bluetooth device. * Indicate the major minor class of a bluetooth device.
* *
* @typedef { constant.MajorMinorClass } MajorMinorClass
* @syscap SystemCapability.Communication.Bluetooth.Core * @syscap SystemCapability.Communication.Bluetooth.Core
* @since 10 * @since 10
*/ */
@ -106,6 +119,22 @@ declare namespace connection {
* @syscap SystemCapability.Communication.Bluetooth.Core * @syscap SystemCapability.Communication.Bluetooth.Core
* @since 10 * @since 10
*/ */
/**
* Starts pairing with a remote Bluetooth device.
*
* @permission ohos.permission.ACCESS_BLUETOOTH
* @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF".
* @param { AsyncCallback<void> } callback - the callback of pairDevice.
* @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.
* @syscap SystemCapability.Communication.Bluetooth.Core
* @atomicservice
* @since 12
*/
function pairDevice(deviceId: string, callback: AsyncCallback<void>): void; function pairDevice(deviceId: string, callback: AsyncCallback<void>): void;
/** /**
@ -123,6 +152,22 @@ declare namespace connection {
* @syscap SystemCapability.Communication.Bluetooth.Core * @syscap SystemCapability.Communication.Bluetooth.Core
* @since 10 * @since 10
*/ */
/**
* Starts pairing with a remote Bluetooth device.
*
* @permission ohos.permission.ACCESS_BLUETOOTH
* @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF".
* @returns { Promise<void> } Returns the promise object.
* @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.
* @syscap SystemCapability.Communication.Bluetooth.Core
* @atomicservice
* @since 12
*/
function pairDevice(deviceId: string): Promise<void>; function pairDevice(deviceId: string): Promise<void>;
/** /**
@ -260,6 +305,22 @@ declare namespace connection {
* @syscap SystemCapability.Communication.Bluetooth.Core * @syscap SystemCapability.Communication.Bluetooth.Core
* @since 10 * @since 10
*/ */
/**
* Obtains the name of a peer Bluetooth device.
*
* @permission ohos.permission.ACCESS_BLUETOOTH
* @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF".
* @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.
* @syscap SystemCapability.Communication.Bluetooth.Core
* @atomicservice
* @since 12
*/
function getRemoteDeviceName(deviceId: string): string; function getRemoteDeviceName(deviceId: string): string;
/** /**
@ -306,6 +367,20 @@ declare namespace connection {
* @syscap SystemCapability.Communication.Bluetooth.Core * @syscap SystemCapability.Communication.Bluetooth.Core
* @since 10 * @since 10
*/ */
/**
* Obtains the list of Bluetooth devices that have been paired with the current device.
*
* @permission ohos.permission.ACCESS_BLUETOOTH
* @returns { Array<string> } 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.
* @syscap SystemCapability.Communication.Bluetooth.Core
* @atomicservice
* @since 12
*/
function getPairedDevices(): Array<string>; function getPairedDevices(): Array<string>;
/** /**
@ -323,6 +398,22 @@ declare namespace connection {
* @syscap SystemCapability.Communication.Bluetooth.Core * @syscap SystemCapability.Communication.Bluetooth.Core
* @since 11 * @since 11
*/ */
/**
* Obtains the pair state of a specified device.
*
* @permission ohos.permission.ACCESS_BLUETOOTH
* @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF".
* @returns { BondState } Returns the pair 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 } 2900099 - Operation failed.
* @syscap SystemCapability.Communication.Bluetooth.Core
* @atomicservice
* @since 12
*/
function getPairState(deviceId: string): BondState; function getPairState(deviceId: string): BondState;
/** /**
@ -438,6 +529,19 @@ declare namespace connection {
* @syscap SystemCapability.Communication.Bluetooth.Core * @syscap SystemCapability.Communication.Bluetooth.Core
* @since 10 * @since 10
*/ */
/**
* Starts scanning Bluetooth devices.
*
* @permission ohos.permission.ACCESS_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.
* @syscap SystemCapability.Communication.Bluetooth.Core
* @atomicservice
* @since 12
*/
function startBluetoothDiscovery(): void; function startBluetoothDiscovery(): void;
/** /**
@ -452,6 +556,19 @@ declare namespace connection {
* @syscap SystemCapability.Communication.Bluetooth.Core * @syscap SystemCapability.Communication.Bluetooth.Core
* @since 10 * @since 10
*/ */
/**
* Stops Bluetooth device scanning.
*
* @permission ohos.permission.ACCESS_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.
* @syscap SystemCapability.Communication.Bluetooth.Core
* @atomicservice
* @since 12
*/
function stopBluetoothDiscovery(): void; function stopBluetoothDiscovery(): void;
/** /**
@ -700,6 +817,20 @@ declare namespace connection {
* @syscap SystemCapability.Communication.Bluetooth.Core * @syscap SystemCapability.Communication.Bluetooth.Core
* @since 10 * @since 10
*/ */
/**
* Subscribe the event reported when a remote Bluetooth device is discovered.
*
* @permission ohos.permission.ACCESS_BLUETOOTH
* @param { 'bluetoothDeviceFind' } type - Type of the discovering event to listen for.
* @param { Callback<Array<string>> } 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.
* @syscap SystemCapability.Communication.Bluetooth.Core
* @atomicservice
* @since 12
*/
function on(type: 'bluetoothDeviceFind', callback: Callback<Array<string>>): void; function on(type: 'bluetoothDeviceFind', callback: Callback<Array<string>>): void;
/** /**
@ -714,6 +845,19 @@ declare namespace connection {
* @syscap SystemCapability.Communication.Bluetooth.Core * @syscap SystemCapability.Communication.Bluetooth.Core
* @since 10 * @since 10
*/ */
/**
* Unsubscribe the event reported when a remote Bluetooth device is discovered.
*
* @permission ohos.permission.ACCESS_BLUETOOTH
* @param { 'bluetoothDeviceFind' } type - Type of the discovering event to listen for.
* @param { Callback<Array<string>> } 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.
* @syscap SystemCapability.Communication.Bluetooth.Core
* @atomicservice
* @since 12
*/
function off(type: 'bluetoothDeviceFind', callback?: Callback<Array<string>>): void; function off(type: 'bluetoothDeviceFind', callback?: Callback<Array<string>>): void;
/** /**
@ -984,6 +1128,14 @@ declare namespace connection {
* @syscap SystemCapability.Communication.Bluetooth.Core * @syscap SystemCapability.Communication.Bluetooth.Core
* @since 10 * @since 10
*/ */
/**
* The enum of bond state.
*
* @enum { number }
* @syscap SystemCapability.Communication.Bluetooth.Core
* @atomicservice
* @since 12
*/
enum BondState { enum BondState {
/** /**
* Indicate the bond state is invalid * Indicate the bond state is invalid
@ -991,6 +1143,13 @@ declare namespace connection {
* @syscap SystemCapability.Communication.Bluetooth.Core * @syscap SystemCapability.Communication.Bluetooth.Core
* @since 10 * @since 10
*/ */
/**
* Indicate the bond state is invalid
*
* @syscap SystemCapability.Communication.Bluetooth.Core
* @atomicservice
* @since 12
*/
BOND_STATE_INVALID = 0, BOND_STATE_INVALID = 0,
/** /**
* Indicate the bond state is bonding * Indicate the bond state is bonding
@ -998,6 +1157,13 @@ declare namespace connection {
* @syscap SystemCapability.Communication.Bluetooth.Core * @syscap SystemCapability.Communication.Bluetooth.Core
* @since 10 * @since 10
*/ */
/**
* Indicate the bond state is bonding
*
* @syscap SystemCapability.Communication.Bluetooth.Core
* @atomicservice
* @since 12
*/
BOND_STATE_BONDING = 1, BOND_STATE_BONDING = 1,
/** /**
* Indicate the bond state is bonded * Indicate the bond state is bonded
@ -1005,6 +1171,13 @@ declare namespace connection {
* @syscap SystemCapability.Communication.Bluetooth.Core * @syscap SystemCapability.Communication.Bluetooth.Core
* @since 10 * @since 10
*/ */
/**
* Indicate the bond state is bonded
*
* @syscap SystemCapability.Communication.Bluetooth.Core
* @atomicservice
* @since 12
*/
BOND_STATE_BONDED = 2 BOND_STATE_BONDED = 2
} }

View File

@ -25,6 +25,14 @@
* @syscap SystemCapability.Communication.Bluetooth.Core * @syscap SystemCapability.Communication.Bluetooth.Core
* @since 10 * @since 10
*/ */
/**
* The definition of constant.
*
* @namespace constant
* @syscap SystemCapability.Communication.Bluetooth.Core
* @atomicservice
* @since 12
*/
declare namespace constant { declare namespace constant {
/** /**
* The enum of profile id. * The enum of profile id.
@ -165,6 +173,14 @@ declare namespace constant {
* @syscap SystemCapability.Communication.Bluetooth.Core * @syscap SystemCapability.Communication.Bluetooth.Core
* @since 10 * @since 10
*/ */
/**
* The enum of profile connection state.
*
* @enum { number }
* @syscap SystemCapability.Communication.Bluetooth.Core
* @atomicservice
* @since 12
*/
export enum ProfileConnectionState { export enum ProfileConnectionState {
/** /**
* the current profile is disconnected * the current profile is disconnected
@ -172,6 +188,13 @@ declare namespace constant {
* @syscap SystemCapability.Communication.Bluetooth.Core * @syscap SystemCapability.Communication.Bluetooth.Core
* @since 10 * @since 10
*/ */
/**
* the current profile is disconnected
*
* @syscap SystemCapability.Communication.Bluetooth.Core
* @atomicservice
* @since 12
*/
STATE_DISCONNECTED = 0, STATE_DISCONNECTED = 0,
/** /**
* the current profile is being connected * the current profile is being connected
@ -179,6 +202,13 @@ declare namespace constant {
* @syscap SystemCapability.Communication.Bluetooth.Core * @syscap SystemCapability.Communication.Bluetooth.Core
* @since 10 * @since 10
*/ */
/**
* the current profile is being connected
*
* @syscap SystemCapability.Communication.Bluetooth.Core
* @atomicservice
* @since 12
*/
STATE_CONNECTING = 1, STATE_CONNECTING = 1,
/** /**
* the current profile is connected * the current profile is connected
@ -186,6 +216,13 @@ declare namespace constant {
* @syscap SystemCapability.Communication.Bluetooth.Core * @syscap SystemCapability.Communication.Bluetooth.Core
* @since 10 * @since 10
*/ */
/**
* the current profile is connected
*
* @syscap SystemCapability.Communication.Bluetooth.Core
* @atomicservice
* @since 12
*/
STATE_CONNECTED = 2, STATE_CONNECTED = 2,
/** /**
* the current profile is being disconnected * the current profile is being disconnected
@ -193,6 +230,13 @@ declare namespace constant {
* @syscap SystemCapability.Communication.Bluetooth.Core * @syscap SystemCapability.Communication.Bluetooth.Core
* @since 10 * @since 10
*/ */
/**
* the current profile is being disconnected
*
* @syscap SystemCapability.Communication.Bluetooth.Core
* @atomicservice
* @since 12
*/
STATE_DISCONNECTING = 3 STATE_DISCONNECTING = 3
} }