diff --git a/api/@ohos.bluetooth.d.ts b/api/@ohos.bluetooth.d.ts index b3dde1d0f94f8727c4ddc8530bf3bf44bc8dfdf8..38e7044b419687b8c9cff20d0c70fc809787a041 100644 --- a/api/@ohos.bluetooth.d.ts +++ b/api/@ohos.bluetooth.d.ts @@ -18,19 +18,20 @@ import { AsyncCallback, Callback } from "./basic"; /** * Provides methods to operate or manage Bluetooth. * @since 7 + * @import import bluetooth frome '@ohos.bluetooth'; * @syscap SystemCapability.Communication.Bluetooth.Core */ declare namespace bluetooth { - /** - * Obtains the Bluetooth status of a device. - * - * @return 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}. - * @since 7 - * @permission ohos.permission.USE_BLUETOOTH - */ + /** + * Obtains the Bluetooth status of a device. + * + * @return 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}. + * @since 7 + * @permission ohos.permission.USE_BLUETOOTH + */ function getState(): BluetoothState; /** @@ -359,24 +360,24 @@ declare namespace bluetooth { * Base interface of profile. */ interface BaseProfile { - /** - * Obtains the connected devices list of profile. - * - * @return Returns the address of connected devices list. - * @since 8 - * @permission ohos.permission.USE_BLUETOOTH - */ - getConnectionDevices(): Array; - - /** - * Obtains the profile state of device. - * - * @param device The address of bluetooth device. - * @return Returns {@link ProfileConnectionState} of device. - * @since 8 - * @permission ohos.permission.USE_BLUETOOTH - */ - getDeviceState(device: string): ProfileConnectionState; + /** + * Obtains the connected devices list of profile. + * + * @return Returns the address of connected devices list. + * @since 8 + * @permission ohos.permission.USE_BLUETOOTH + */ + getConnectionDevices(): Array; + + /** + * Obtains the profile state of device. + * + * @param device The address of bluetooth device. + * @return Returns {@link ProfileConnectionState} of device. + * @since 8 + * @permission ohos.permission.USE_BLUETOOTH + */ + getDeviceState(device: string): ProfileConnectionState; } /** @@ -384,23 +385,23 @@ declare namespace bluetooth { */ interface A2dpSourceProfile extends BaseProfile { /** - * Connect to device with a2dp. - * - * @param device The address of the remote device to connect. - * @return Returns {@code true} if the connect is in process; returns {@code false} otherwise. - * @since 8 - * @permission permission ohos.permission.DISCOVER_BLUETOOTH - */ + * Connect to device with a2dp. + * + * @param device The address of the remote device to connect. + * @return Returns {@code true} if the connect is in process; returns {@code false} otherwise. + * @since 8 + * @permission permission ohos.permission.DISCOVER_BLUETOOTH + */ connect(device: string): boolean; /** - * Disconnect to device with a2dp. - * - * @param device The address of the remote device to disconnect. - * @return Returns {@code true} if the disconnect is in process; returns {@code false} otherwise. - * @since 8 - * @permission permission ohos.permission.DISCOVER_BLUETOOTH - */ + * Disconnect to device with a2dp. + * + * @param device The address of the remote device to disconnect. + * @return Returns {@code true} if the disconnect is in process; returns {@code false} otherwise. + * @since 8 + * @permission permission ohos.permission.DISCOVER_BLUETOOTH + */ disconnect(device: string): boolean; /** @@ -422,12 +423,12 @@ declare namespace bluetooth { off(type: "connectionStateChange", callback?: Callback): void; /** - * Obtains the playing state of device. - * - * @param device The address of the remote device. - * @return Returns {@link PlayingState} of the remote device. - * - */ + * Obtains the playing state of device. + * + * @param device The address of the remote device. + * @return Returns {@link PlayingState} of the remote device. + * + */ getPlayingState(device: string): PlayingState; } @@ -436,110 +437,42 @@ declare namespace bluetooth { */ interface HandsFreeAudioGatewayProfile extends BaseProfile { /** - * Connect to device with hfp. - * - * @param device The address of the remote device to connect. - * @return Returns {@code true} if the connect is in process; returns {@code false} otherwise. - * @since 8 - * @permission permission ohos.permission.DISCOVER_BLUETOOTH - */ - connect(device: string): boolean; - - /** - * Disconnect to device with hfp. - * - * @param device The address of the remote device to disconnect. - * @return Returns {@code true} if the disconnect is in process; returns {@code false} otherwise. - * @since 8 - * @permission permission ohos.permission.DISCOVER_BLUETOOTH - */ - disconnect(device: string): boolean; - - /** - * Obtains the sco state of device. - * - * @param device The address of the remote device. - * @return Returns {@code true} if the disconnect is in process; returns {@code false} otherwise. - * @since 8 - * @permission permission ohos.permission.USE_BLUETOOTH - */ - getScoState(device: string): number; - - /** - * Create audio channel. - * - * @param device The address of the remote device. - * @return Returns {@code true} if the request is in process; returns {@code false} otherwise. - * @since 8 - * @permission permission ohos.permission.DISCOVER_BLUETOOTH - */ - connectSco(device: string): boolean; - - /** - * Close audio channel. - * - * @param device The address of the remote device. - * @return Returns {@code true} if the request is in process; returns {@code false} otherwise. - * @since 8 - * @permission permission ohos.permission.DISCOVER_BLUETOOTH - */ - disconnectSco(device: string): boolean; - - /** - * Subscribe the event reported when the profile connection state changes . + * Connect to device with hfp. * - * @param type Type of the profile connection state changes event to listen for . - * @param callback Callback used to listen for event. + * @param device The address of the remote device to connect. + * @return Returns {@code true} if the connect is in process; returns {@code false} otherwise. * @since 8 + * @permission permission ohos.permission.DISCOVER_BLUETOOTH */ - on(type: "connectionStateChange", callback: Callback): void; + connect(device: string): boolean; /** - * Unsubscribe the event reported when the profile connection state changes . + * Disconnect to device with hfp. * - * @param type Type of the profile connection state changes event to listen for . - * @param callback Callback used to listen for event. + * @param device The address of the remote device to disconnect. + * @return Returns {@code true} if the disconnect is in process; returns {@code false} otherwise. * @since 8 + * @permission permission ohos.permission.DISCOVER_BLUETOOTH */ - off(type: "connectionStateChange", callback?: Callback): void; + disconnect(device: string): boolean; /** - * Subscribe the event reported when the sco state changes . + * 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 8 */ - on(type: "scoStateChange", callback: Callback): void; + on(type: "connectionStateChange", callback: Callback): void; /** - * Unsubscribe the event reported when the sco state changes . + * 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 8 */ - off(type: "scoStateChange", callback?: Callback): void; - - /** - * Open voice recognition function. - * - * @param device The address of the remote device to disconnect. - * @return Returns {@code true} if success; returns {@code false} otherwise. - * @since 8 - * @permission permission ohos.permission.DISCOVER_BLUETOOTH - */ - openVoiceRecognition(device: string): boolean; - - /** - * Close voice recognition function. - * - * @param device The address of the remote device to disconnect. - * @return Returns {@code true} if success; returns {@code false} otherwise. - * @since 8 - * @permission permission ohos.permission.DISCOVER_BLUETOOTH - */ - closeVoiceRecognition(device: string): boolean; + off(type: "connectionStateChange", callback?: Callback): void; } namespace BLE { @@ -617,7 +550,6 @@ declare namespace bluetooth { * Manages GATT server. Before calling an Gatt server method, you must use {@link createGattServer} to create an GattServer instance. */ interface GattServer { - /** * Starts BLE advertising. * @@ -987,9 +919,9 @@ declare namespace bluetooth { /** The UUID of the {@link GattService} instance to which the characteristic belongs */ serviceUuid: string; /** The UUID of a BLECharacteristic instance */ - characteristicUuid: string; + characteristicUuid: string; /** The value of a BLECharacteristic instance */ - characteristicValue: ArrayBuffer; + characteristicValue: ArrayBuffer; /** The list of {@link BLEDescriptor} contained in the characteristic */ descriptors: Array; } @@ -1522,23 +1454,10 @@ declare namespace bluetooth { /** The address of device */ deviceId: string; - /** Profile state value */ + /** Profile state value */ state: ProfileConnectionState; } - /** - * Sco state change parameters. - * - * @since 8 - */ - Interface ScoStateParam { - /** The address of device */ - deviceId: string, - - /** Sco state value */ - state: ScoState - } - /** * The enum of a2dp playing state. * @@ -1549,26 +1468,14 @@ declare namespace bluetooth { STATE_PLAYING, } - /** - * The enum of sco audio state. - * - * @since 8 - */ - enum ScoState { - SCO_DISCONNECTED, - SCO_CONNECTING, - SCO_DISCONNECTING, - SCO_CONNECTED - } - /** * The enum of profile id. * * @since 8 */ enum ProfileId { - PROFILE_A2DP_SOURCE = 1, - PROFILE_HANDS_FREE_AUDIO_GATEWAY = 4, + PROFILE_A2DP_SOURCE = 1, + PROFILE_HANDS_FREE_AUDIO_GATEWAY = 4, } }