diff --git a/en/application-dev/reference/apis/js-apis-bluetooth.md b/en/application-dev/reference/apis/js-apis-bluetooth.md index b65d3e3f9d45c1819ce94926322069c220857669..f28a34c36a36008fab19a381dde43fc18057f8be 100644 --- a/en/application-dev/reference/apis/js-apis-bluetooth.md +++ b/en/application-dev/reference/apis/js-apis-bluetooth.md @@ -12,6 +12,7 @@ The **Bluetooth** module provides classic Bluetooth capabilities and Bluetooth L import bluetooth from '@ohos.bluetooth'; ``` + ## bluetooth.enableBluetooth8+ enableBluetooth(): boolean @@ -279,7 +280,7 @@ let remoteDeviceName = bluetooth.getRemoteDeviceName("XX:XX:XX:XX:XX:XX"); getRemoteDeviceClass(deviceId: string): DeviceClass -Obtains the type of the remote Bluetooth device. +Obtains the class of the remote Bluetooth device. **Required permissions**: ohos.permission.USE_BLUETOOTH @@ -295,7 +296,7 @@ Obtains the type of the remote Bluetooth device. | Type | Description | | --------------------------- | -------- | -| [DeviceClass](#deviceclass) | Type of a remote device obtained.| +| [DeviceClass](#deviceclass) | Class of the remote device obtained.| **Example** @@ -513,7 +514,7 @@ Unsubscribes from the Bluetooth device discovery events. | Name | Type | Mandatory | Description | | -------- | ----------------------------------- | ---- | ---------------------------------------- | | type | string | Yes | Event type. The value **bluetoothDeviceFind** indicates an event reported when a Bluetooth device is discovered. | -| callback | Callback<Array<string>> | No | Callback used to report the discovered devices. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.| +| callback | Callback<Array<string>> | No | Callback for the **bluetoothDeviceFind** event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**. | **Return value** @@ -576,7 +577,7 @@ Unsubscribes from the pairing request events of the remote Bluetooth device. | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ---------------------------------------- | | type | string | Yes | Event type. The value **pinRequired** indicates a pairing request event. | -| callback | Callback<[PinRequiredParam](#pinrequiredparam)> | No | Callback used to report the Bluetooth pairing request. The input parameter is the pairing request parameter. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.| +| callback | Callback<[PinRequiredParam](#pinrequiredparam)> | No | Callback for the **pinRequired** event. The input parameter is the pairing request parameter. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**. | **Return value** @@ -597,7 +598,7 @@ bluetooth.off('pinRequired', onReceiveEvent); on(type: "bondStateChange", callback: Callback<BondStateParam>): void -Subscribes to the Bluetooth bond state change events. +Subscribes to the Bluetooth paring change events. **Required permissions**: ohos.permission.USE_BLUETOOTH @@ -607,8 +608,8 @@ Subscribes to the Bluetooth bond state change events. | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ------------------------------------ | -| type | string | Yes | Event type. The value **bondStateChange** indicates a Bluetooth bond state change event.| -| callback | Callback<[BondStateParam](#bondstateparam8)> | Yes | Callback invoked to return the bond state. You need to implement this callback. | +| type | string | Yes | Event type. The value **bondStateChange** indicates a Bluetooth paring state change event. | +| callback | Callback<[BondStateParam](#bondstateparam8)> | Yes | Callback invoked to return the paring state. You need to implement this callback. | **Return value** @@ -617,7 +618,7 @@ No value is returned. **Example** ```js -function onReceiveEvent(data) { // data, as the input parameter of the callback, indicates the bond state. +function onReceiveEvent(data) { // data, as the input parameter of the callback, indicates the pairing state. console.info('pair state = '+ JSON.stringify(data)); } bluetooth.on('bondStateChange', onReceiveEvent); @@ -628,7 +629,7 @@ bluetooth.on('bondStateChange', onReceiveEvent); off(type: "bondStateChange", callback?: Callback<BondStateParam>): void -Unsubscribes from the Bluetooth bond state change events. +Unsubscribes from the Bluetooth pairing state change events. **Required permissions**: ohos.permission.USE_BLUETOOTH @@ -638,8 +639,8 @@ Unsubscribes from the Bluetooth bond state change events. | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | string | Yes | Event type. The value **bondStateChange** indicates a Bluetooth bond state change event. | -| callback | Callback<[BondStateParam](#bondstateparam8)> | No | Callback used to report the change of the Bluetooth bond state. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.| +| type | string | Yes | Event type. The value **bondStateChange** indicates a Bluetooth pairing state change event. | +| callback | Callback<[BondStateParam](#bondstateparam8)> | No | Callback for the pairing state change event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**. | **Return value** @@ -702,7 +703,7 @@ Unsubscribes from the Bluetooth connection state change events. | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ---------------------------------------- | | type | string | Yes | Event type. The value **stateChange** indicates a Bluetooth connection state change event. | -| callback | Callback<[BluetoothState](#bluetoothstate)> | No | Callback used to report the Bluetooth connection state. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.| +| callback | Callback<[BluetoothState](#bluetoothstate)> | No | Callback for the Bluetooth connection state event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**. | **Return value** @@ -987,7 +988,7 @@ Unsubscribes from the SPP read request events. | ------------ | --------------------------- | ---- | ---------------------------------------- | | type | string | Yes | Event type. The value **sppRead** indicates an SPP read request event. | | clientSocket | number | Yes | Client socket ID, which is obtained by **sppAccept** or **sppConnect**. | -| callback | Callback<ArrayBuffer> | No | Callback used to report an SPP read request event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.| +| callback | Callback<ArrayBuffer> | No | Callback for the SPP read request event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**. | **Return value** @@ -1219,7 +1220,7 @@ Unsubscribes from the BLE device discovery events. | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ---------------------------------------- | | type | string | Yes | Event type. The value **BLEDeviceFind** indicates an event reported when a BLE device is discovered. | -| callback | Callback<Array<[ScanResult](#scanresult)>> | No | Callback used to report the discovered devices. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.| +| callback | Callback<Array<[ScanResult](#scanresult)>> | No | Callback for the **BLEDeviceFind** event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**. | **Return value** @@ -1257,10 +1258,9 @@ No value is returned. **Return value** -| | | +| Type | Description | | ------------------- | ------------- | -| Type | Description | -| Array<string> | Addresses of the connected devices. | +| Array<string> | Addresses of the connected devices.| ### getDeviceState8+ @@ -1278,12 +1278,12 @@ Obtains the connection state of the profile. | Name | Type | Mandatory | Description | | ------ | ------ | ---- | ------- | | device | string | Yes | Address of the target device.| + **Return value** -| | | +| Type | Description | | ------------------------------------------------- | ----------------------- | -| Type | Description | -| [ProfileConnectionState](#profileconnectionstate) | Profile connection state obtained. | +| [ProfileConnectionState](#profileconnectionstate) | Profile connection state obtained.| ## A2dpSourceProfile @@ -1306,14 +1306,12 @@ Sets up an Advanced Audio Distribution Profile (A2DP) connection. | Name | Type | Mandatory | Description | | ------ | ------ | ---- | ------- | | device | string | Yes | Address of the target device.| -| **Return value** -| | | +| Type | Description | | ------- | ------------------- | -| Type | Description | -| boolean | Returns **true** if the operation is successful; returns **false** otherwise. | +| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| **Example** @@ -1338,14 +1336,13 @@ Disconnects an A2DP connection. | Name | Type | Mandatory | Description | | ------ | ------ | ---- | ------- | | device | string | Yes | Address of the target device.| -| + **Return value** -| | | +| Type | Description | | ------- | ------------------- | -| Type | Description | -| boolean | Returns **true** if the operation is successful; returns **false** otherwise. | +| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| **Example** @@ -1397,7 +1394,7 @@ Unsubscribes from the A2DP connection state change events. | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ---------------------------------------- | | type | string | Yes | Event type. The value **connectionStateChange** indicates an A2DP connection state change event.| -| callback | Callback<[StateChangeParam](#StateChangeParam)> | Yes | Callback used to return the A2DP connection state change event. | +| callback | Callback<[StateChangeParam](#StateChangeParam)> | Yes | Callback for the A2DP connection state change event. | **Return value** @@ -1431,10 +1428,9 @@ Obtains the playing state of a device. **Return value** -| | | +| Type | Description | | ----------------------------- | ---------- | -| Type | Description | -| [PlayingState](#PlayingState) | Playing state obtained. | +| [PlayingState](#PlayingState) | Playing state obtained.| **Example** @@ -1464,14 +1460,13 @@ Sets up a Hands-free Profile (HFP) connection of a device. | Name | Type | Mandatory | Description | | ------ | ------ | ---- | ------- | | device | string | Yes | Address of the target device.| -| + **Return value** -| | | +| Type | Description | | ------- | ------------------- | -| Type | Description | -| boolean | Returns **true** if the operation is successful; returns **false** otherwise. | +| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| **Example** @@ -1496,7 +1491,7 @@ Disconnects the HFP connection of a device. | Name | Type | Mandatory | Description | | ------ | ------ | ---- | ------- | | device | string | Yes | Address of the target device.| -| + **Return value** @@ -1554,7 +1549,7 @@ Unsubscribes from the HFP connection state change events. | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ---------------------------------------- | | type | string | Yes | Event type. The value **connectionStateChange** indicates an HFP connection state change event.| -| callback | Callback<[StateChangeParam](#StateChangeParam)> | Yes | Callback used to return the HFP connection state change event. | +| callback | Callback<[StateChangeParam](#StateChangeParam)> | Yes | Callback for the HFP connection state change event. | **Return value** @@ -1741,10 +1736,9 @@ Removes a service from this GATT server. **Return value** -| | | +| Type | Description | | ------- | -------------------------- | -| Type | Description | -| boolean | Returns **true** if the operation is successful; returns **false** otherwise. | +| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| **Example** @@ -1791,10 +1785,9 @@ Notifies the connected client device when a characteristic value changes. **Return value** -| | | +| Type | Description | | ------- | ------------------------ | -| Type | Description | -| boolean | Returns **true** if the operation is successful; returns **false** otherwise. | +| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| **Example** @@ -1837,10 +1830,9 @@ Sends a response to a read or write request from the GATT client. **Return value** -| | | +| Type | Description | | ------- | -------------------------- | -| Type | Description | -| boolean | Returns **true** if the operation is successful; returns **false** otherwise. | +| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| **Example** @@ -1930,7 +1922,7 @@ Unsubscribes from the characteristic read request events. | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ---------------------------------------- | | type | string | Yes | Event type. The value **characteristicRead** indicates a characteristic read request event. | -| callback | Callback<[CharacteristicReadReq](#characteristicreadreq)> | No | Callback used to report a characteristic read request event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.| +| callback | Callback<[CharacteristicReadReq](#characteristicreadreq)> | No | Callback for the characteristic read request event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**. | **Return value** @@ -2010,7 +2002,7 @@ Unsubscribes from the characteristic write request events. | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ---------------------------------------- | | type | string | Yes | Event type. The value **characteristicWrite** indicates a characteristic write request event. | -| callback | Callback<[CharacteristicWriteReq](#characteristicwritereq)> | No | Callback used to report a characteristic write request event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.| +| callback | Callback<[CharacteristicWriteReq](#characteristicwritereq)> | No | Callback for the characteristic write request event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**. | **Return value** @@ -2087,7 +2079,7 @@ Unsubscribes from the descriptor read request events. | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ---------------------------------------- | | type | string | Yes | Event type. The value **descriptorRead** indicates a descriptor read request event. | -| callback | Callback<[DescriptorReadReq](#descriptorreadreq)> | No | Callback used to report a descriptor read request event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.| +| callback | Callback<[DescriptorReadReq](#descriptorreadreq)> | No | Callback for the descriptor read request event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**. | **Return value** @@ -2167,7 +2159,7 @@ Unsubscribes from the descriptor write request events. | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ---------------------------------------- | | type | string | Yes | Event type. The value **descriptorWrite** indicates a descriptor write request event. | -| callback | Callback<[DescriptorWriteReq](#descriptorwritereq)> | No | Callback used to report a descriptor write request event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.| +| callback | Callback<[DescriptorWriteReq](#descriptorwritereq)> | No | Callback for the descriptor write request event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**. | **Return value** @@ -2230,7 +2222,7 @@ Unsubscribes from the BLE connection state change events. | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ---------------------------------------- | | type | string | Yes | Event type. The value **connectStateChange** indicates a BLE connection state change event.| -| callback | Callback<[BLEConnectChangedState](#bleconnectchangedstate)> | No | Callback used to report the BLE connection state. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.| +| callback | Callback<[BLEConnectChangedState](#bleconnectchangedstate)> | No | Callback for the BLE connection state event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**. | **Return value** @@ -2467,10 +2459,9 @@ Reads the characteristic value of the specific service of the remote BLE device. **Return value** -| | | +| Type | Description | | ---------------------------------------- | -------------------------- | -| Type | Description | -| Promise<[BLECharacteristic](#blecharacteristic)> | Promise used to return the characteristic value read. | +| Promise<[BLECharacteristic](#blecharacteristic)> | Promise used to return the characteristic value read.| **Example** @@ -2558,10 +2549,9 @@ Reads the descriptor contained in the specific characteristic of the remote BLE **Return value** -| | | +| Type | Description | | ---------------------------------------- | -------------------------- | -| Type | Description | -| Promise<[BLEDescriptor](#bledescriptor)> | Promise used to return the descriptor read. | +| Promise<[BLEDescriptor](#bledescriptor)> | Promise used to return the descriptor read.| **Example** @@ -3346,7 +3336,7 @@ Defines the pairing request parameters. ## BondStateParam8+ -Defines the bond state parameters. +Defines the pairing state parameters. **System capability**: SystemCapability.Communication.Bluetooth.Core