mirror of
https://gitee.com/openharmony/interface_sdk-js
synced 2024-11-23 07:10:52 +00:00
add bluetooth.baseProfile @crossplatform
Signed-off-by: quguiren <quguiren@huawei.com>
This commit is contained in:
parent
9664094f4c
commit
525dcb35f1
134
api/@ohos.bluetooth.baseProfile.d.ts
vendored
134
api/@ohos.bluetooth.baseProfile.d.ts
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2023-2024 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
|
||||
@ -28,6 +28,14 @@ import type constant from './@ohos.bluetooth.constant';
|
||||
* @syscap SystemCapability.Communication.Bluetooth.Core
|
||||
* @since 10
|
||||
*/
|
||||
/**
|
||||
* Provides basic profile methods.
|
||||
*
|
||||
* @namespace baseProfile
|
||||
* @syscap SystemCapability.Communication.Bluetooth.Core
|
||||
* @crossplatform
|
||||
* @since 13
|
||||
*/
|
||||
declare namespace baseProfile {
|
||||
/**
|
||||
* Indicate the profile connection state.
|
||||
@ -36,6 +44,14 @@ declare namespace baseProfile {
|
||||
* @syscap SystemCapability.Communication.Bluetooth.Core
|
||||
* @since 10
|
||||
*/
|
||||
/**
|
||||
* Indicate the profile connection state.
|
||||
*
|
||||
* @typedef { constant.ProfileConnectionState } ProfileConnectionState
|
||||
* @syscap SystemCapability.Communication.Bluetooth.Core
|
||||
* @crossplatform
|
||||
* @since 13
|
||||
*/
|
||||
type ProfileConnectionState = constant.ProfileConnectionState;
|
||||
|
||||
/**
|
||||
@ -80,6 +96,14 @@ declare namespace baseProfile {
|
||||
* @syscap SystemCapability.Communication.Bluetooth.Core
|
||||
* @since 12
|
||||
*/
|
||||
/**
|
||||
* Enum for cause of disconnect.
|
||||
*
|
||||
* @enum { number }
|
||||
* @syscap SystemCapability.Communication.Bluetooth.Core
|
||||
* @crossplatform
|
||||
* @since 13
|
||||
*/
|
||||
enum DisconnectCause {
|
||||
/**
|
||||
* User disconnect device.
|
||||
@ -87,6 +111,13 @@ declare namespace baseProfile {
|
||||
* @syscap SystemCapability.Communication.Bluetooth.Core
|
||||
* @since 12
|
||||
*/
|
||||
/**
|
||||
* User disconnect device.
|
||||
*
|
||||
* @syscap SystemCapability.Communication.Bluetooth.Core
|
||||
* @crossplatform
|
||||
* @since 13
|
||||
*/
|
||||
USER_DISCONNECT = 0,
|
||||
/**
|
||||
* The connection needs to be initiated from the keyboard side.
|
||||
@ -132,6 +163,14 @@ declare namespace baseProfile {
|
||||
* @syscap SystemCapability.Communication.Bluetooth.Core
|
||||
* @since 10
|
||||
*/
|
||||
/**
|
||||
* Profile state change parameters.
|
||||
*
|
||||
* @typedef StateChangeParam
|
||||
* @syscap SystemCapability.Communication.Bluetooth.Core
|
||||
* @crossplatform
|
||||
* @since 13
|
||||
*/
|
||||
export interface StateChangeParam {
|
||||
/**
|
||||
* The address of device
|
||||
@ -140,6 +179,14 @@ declare namespace baseProfile {
|
||||
* @syscap SystemCapability.Communication.Bluetooth.Core
|
||||
* @since 10
|
||||
*/
|
||||
/**
|
||||
* The address of device
|
||||
*
|
||||
* @type { string }
|
||||
* @syscap SystemCapability.Communication.Bluetooth.Core
|
||||
* @crossplatform
|
||||
* @since 13
|
||||
*/
|
||||
deviceId: string;
|
||||
|
||||
/**
|
||||
@ -149,6 +196,14 @@ declare namespace baseProfile {
|
||||
* @syscap SystemCapability.Communication.Bluetooth.Core
|
||||
* @since 10
|
||||
*/
|
||||
/**
|
||||
* Profile state value
|
||||
*
|
||||
* @type { ProfileConnectionState }
|
||||
* @syscap SystemCapability.Communication.Bluetooth.Core
|
||||
* @crossplatform
|
||||
* @since 13
|
||||
*/
|
||||
state: ProfileConnectionState;
|
||||
|
||||
/**
|
||||
@ -158,6 +213,14 @@ declare namespace baseProfile {
|
||||
* @syscap SystemCapability.Communication.Bluetooth.Core
|
||||
* @since 12
|
||||
*/
|
||||
/**
|
||||
* Cause of disconnect
|
||||
*
|
||||
* @type { DisconnectCause }
|
||||
* @syscap SystemCapability.Communication.Bluetooth.Core
|
||||
* @crossplatform
|
||||
* @since 13
|
||||
*/
|
||||
cause: DisconnectCause;
|
||||
}
|
||||
|
||||
@ -168,6 +231,14 @@ declare namespace baseProfile {
|
||||
* @syscap SystemCapability.Communication.Bluetooth.Core
|
||||
* @since 10
|
||||
*/
|
||||
/**
|
||||
* Base interface of profile.
|
||||
*
|
||||
* @typedef BaseProfile
|
||||
* @syscap SystemCapability.Communication.Bluetooth.Core
|
||||
* @crossplatform
|
||||
* @since 13
|
||||
*/
|
||||
export interface BaseProfile {
|
||||
/**
|
||||
* Set connection strategy of this profile.
|
||||
@ -269,6 +340,21 @@ declare namespace baseProfile {
|
||||
* @syscap SystemCapability.Communication.Bluetooth.Core
|
||||
* @since 10
|
||||
*/
|
||||
/**
|
||||
* Obtains the connected devices list of profile.
|
||||
*
|
||||
* @permission ohos.permission.ACCESS_BLUETOOTH
|
||||
* @returns { Array<string> } 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 disabled.
|
||||
* @throws { BusinessError } 2900004 - Profile not supported.
|
||||
* @throws { BusinessError } 2900099 - Operation failed.
|
||||
* @syscap SystemCapability.Communication.Bluetooth.Core
|
||||
* @crossplatform
|
||||
* @since 13
|
||||
*/
|
||||
getConnectedDevices(): Array<string>;
|
||||
|
||||
/**
|
||||
@ -288,6 +374,24 @@ declare namespace baseProfile {
|
||||
* @syscap SystemCapability.Communication.Bluetooth.Core
|
||||
* @since 10
|
||||
*/
|
||||
/**
|
||||
* Obtains the profile connection state.
|
||||
*
|
||||
* @permission ohos.permission.ACCESS_BLUETOOTH
|
||||
* @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF".
|
||||
* @returns { ProfileConnectionState } Returns the connection state.
|
||||
* @throws { BusinessError } 201 - Permission denied.
|
||||
* @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified.
|
||||
* <br>2. Incorrect parameter types. 3. Parameter verification failed.
|
||||
* @throws { BusinessError } 801 - Capability not supported.
|
||||
* @throws { BusinessError } 2900001 - Service stopped.
|
||||
* @throws { BusinessError } 2900003 - Bluetooth disabled.
|
||||
* @throws { BusinessError } 2900004 - Profile not supported.
|
||||
* @throws { BusinessError } 2900099 - Operation failed.
|
||||
* @syscap SystemCapability.Communication.Bluetooth.Core
|
||||
* @crossplatform
|
||||
* @since 13
|
||||
*/
|
||||
getConnectionState(deviceId: string): ProfileConnectionState;
|
||||
|
||||
/**
|
||||
@ -303,6 +407,20 @@ declare namespace baseProfile {
|
||||
* @syscap SystemCapability.Communication.Bluetooth.Core
|
||||
* @since 10
|
||||
*/
|
||||
/**
|
||||
* Subscribe the event reported when the profile connection state changes .
|
||||
*
|
||||
* @permission ohos.permission.ACCESS_BLUETOOTH
|
||||
* @param { 'connectionStateChange' } type - Type of the profile connection state changes event to listen for.
|
||||
* @param { Callback<StateChangeParam> } callback - Callback used to listen for event.
|
||||
* @throws { BusinessError } 201 - Permission denied.
|
||||
* @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified.
|
||||
* <br>2. Incorrect parameter types. 3. Parameter verification failed.
|
||||
* @throws { BusinessError } 801 - Capability not supported.
|
||||
* @syscap SystemCapability.Communication.Bluetooth.Core
|
||||
* @crossplatform
|
||||
* @since 13
|
||||
*/
|
||||
on(type: 'connectionStateChange', callback: Callback<StateChangeParam>): void;
|
||||
|
||||
/**
|
||||
@ -318,6 +436,20 @@ declare namespace baseProfile {
|
||||
* @syscap SystemCapability.Communication.Bluetooth.Core
|
||||
* @since 10
|
||||
*/
|
||||
/**
|
||||
* Unsubscribe the event reported when the profile connection state changes .
|
||||
*
|
||||
* @permission ohos.permission.ACCESS_BLUETOOTH
|
||||
* @param { 'connectionStateChange' } type - Type of the profile connection state changes event to listen for.
|
||||
* @param { Callback<StateChangeParam> } callback - Callback used to listen for event.
|
||||
* @throws { BusinessError } 201 - Permission denied.
|
||||
* @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified.
|
||||
* <br>2. Incorrect parameter types. 3. Parameter verification failed.
|
||||
* @throws { BusinessError } 801 - Capability not supported.
|
||||
* @syscap SystemCapability.Communication.Bluetooth.Core
|
||||
* @crossplatform
|
||||
* @since 13
|
||||
*/
|
||||
off(type: 'connectionStateChange', callback?: Callback<StateChangeParam>): void;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user