提交 b75f3201 编写于 作者: A Annie_wang

update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
上级 7d18c4c3
master OpenHarmony-3.2-Beta2 OpenHarmony-3.2-Beta3 OpenHarmony-3.2-Beta4 OpenHarmony-3.2-Beta5 OpenHarmony-3.2-Release OpenHarmony-4.0-Beta1 OpenHarmony-4.0-Beta2 bak_OpenHarmony-4.0-Beta1_20230529 docs-modify feature_IDL_20220811 monthly_20220816 monthly_20221018 monthly_20230815 revert-merge-17651-master revert-merge-19334-OpenHarmony-4.0-Beta1 revert-merge-19586-master revert-merge-20613-master revert-merge-21757-OpenHarmony-4.0-Beta2 revert-merge-21765-OpenHarmony-4.0-Beta2 revert-merge-23766-master weekly_20220712 weekly_20220719 weekly_20220726 weekly_20220802 weekly_20220809 weekly_20220816 weekly_20220823 weekly_20220830 weekly_20220906 weekly_20220913 weekly_20220920 weekly_20220927 weekly_20221004 weekly_20221011 weekly_20221018 weekly_20221025 weekly_20221101 weekly_20221108 weekly_20221115 weekly_20221122 weekly_20221129 weekly_20221206 weekly_20221213 weekly_20221220 weekly_20221227 weekly_20230103 weekly_20230110 weekly_20230117 weekly_20230124 weekly_20230131 weekly_20230207 weekly_20230214 weekly_20230221 weekly_20230228 weekly_20230307 weekly_20230314 weekly_20230321 weekly_20230328 weekly_20230404 weekly_20230411 weekly_20230418 weekly_20230425 weekly_20230502 weekly_20230509 weekly_20230516 weekly_20230523 weekly_20230530 weekly_20230606 weekly_20230613 weekly_20230619 weekly_20230626 weekly_20230627 weekly_20230704 weekly_20230712 weekly_20230725 weekly_20230801 weekly_20230808 weekly_20230815 weekly_20230822 weekly_20230829 weekly_20230905 OpenHarmony-v4.0-Beta2 OpenHarmony-v4.0-Beta1 OpenHarmony-v3.2.3-Release OpenHarmony-v3.2.2-Release OpenHarmony-v3.2.1-Release OpenHarmony-v3.2-Release OpenHarmony-v3.2-Beta5 OpenHarmony-v3.2-Beta4 OpenHarmony-v3.2-Beta3 OpenHarmony-v3.2-Beta2
无相关合并请求
......@@ -3,7 +3,7 @@
> **NOTE**<br>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides classic Bluetooth capabilities and Bluetooth Low Energy (BLE) scan and advertising.
The Bluetooth module provides classic Bluetooth capabilities and Bluetooth Low Energy (BLE) scan and advertising.
## Modules to Import
......@@ -222,12 +222,12 @@ cancelPairedDevice(deviceId: string): boolean
Cancels a paired remote device.
This is a system API.
**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory | Description |
......@@ -388,7 +388,7 @@ startBluetoothDiscovery(): boolean
Starts Bluetooth scan to discover remote devices.
**Required permissions**: ohos.permission.USE_BLUETOOTH and ohos.permission.LOCATION
**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH and ohos.permission.LOCATION
**System capability**: SystemCapability.Communication.Bluetooth.Core
......@@ -447,7 +447,7 @@ Sets the device pairing confirmation.
| Name | Type | Mandatory | Description |
| ------ | ------- | ---- | -------------------------------- |
| device | string | Yes | Address of the target remote device, for example, XX:XX:XX:XX:XX:XX.|
| device | string | Yes | Address of the remote device, for example, XX:XX:XX:XX:XX:XX.|
| accept | boolean | Yes | Whether to accept the pairing request. The value **true** means to accept the pairing request, and the value **false** means the opposite. |
**Return value**
......@@ -1422,7 +1422,7 @@ a2dpSrc.on('connectionStateChange', onReceiveEvent);
### off('connectionStateChange')<sup>8+</sup>
off(type: "connectionStateChange", callback: Callback&lt;[StateChangeParam](#StateChangeParam)&gt;): void
off(type: "connectionStateChange", callback?: Callback&lt;[StateChangeParam](#StateChangeParam)&gt;): void
Unsubscribes from the A2DP connection state change events.
......@@ -1451,12 +1451,14 @@ a2dpSrc.off('connectionStateChange', onReceiveEvent);
```
### getPlayingState
### getPlayingState<sup>9+</sup>
getPlayingState(device: string): PlayingState
Obtains the playing state of a device.
**Required permissions**: ohos.permission.USE_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
**Parameters**
......@@ -1576,7 +1578,7 @@ hfpAg.on('connectionStateChange', onReceiveEvent);
### off('connectionStateChange')<sup>8+</sup>
off(type: "connectionStateChange", callback: Callback&lt;[StateChangeParam](#StateChangeParam)&gt;): void
off(type: "connectionStateChange", callback?: Callback&lt;[StateChangeParam](#StateChangeParam)&gt;): void
Unsubscribes from the HFP connection state change events.
......@@ -1616,12 +1618,12 @@ connect(device: string): boolean
Connects to the HidHost service of a device.
This is a system API.
**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory | Description |
......@@ -1648,12 +1650,12 @@ disconnect(device: string): boolean
Disconnects from the HidHost service of a device.
This is a system API.
**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
**System capability**: SystemCapability.Communication.Bluetooth.Core
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory | Description |
......@@ -1706,7 +1708,7 @@ hidHost.on('connectionStateChange', onReceiveEvent);
### off('connectionStateChange')<sup>9+</sup>
off(type: "connectionStateChange", callback: Callback&lt;[StateChangeParam](#StateChangeParam)&gt;): void
off(type: "connectionStateChange", callback?: Callback&lt;[StateChangeParam](#StateChangeParam)&gt;): void
Unsubscribes from the HidHost connection state change events.
......@@ -1964,6 +1966,15 @@ Notifies the connected client device when a characteristic value changes.
**Example**
```js
// Create descriptors.
let descriptors = [];
let arrayBuffer = new ArrayBuffer(8);
let descV = new Uint8Array(arrayBuffer);
descV[0] = 11;
let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
descriptors[0] = descriptor;
let arrayBufferC = new ArrayBuffer(8);
let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', characteristicValue: arrayBufferC, descriptors:descriptors};
......@@ -2541,14 +2552,9 @@ Obtains all services of the remote BLE device. This API uses a promise to return
```js
// Promise
let device = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
device.connect();
var services = device.getServices();
console.log("bluetooth services size is ", services.length);
for (let i = 0; i < services.length; i++) {
console.log('bluetooth serviceUuid is ' + services[i].serviceUuid);
}
gattClientDevice.getServices().then(result => {
console.info("Got services successfully:" + JSON.stringify(result));
});
```
......@@ -2881,6 +2887,15 @@ Sets the function of notifying the GATT client when the characteristic value of
**Example**
```js
// Create descriptors.
let descriptors = [];
let arrayBuffer = new ArrayBuffer(8);
let descV = new Uint8Array(arrayBuffer);
descV[0] = 11;
let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
descriptors[0] = descriptor;
let arrayBufferC = new ArrayBuffer(8);
let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', characteristicValue: arrayBufferC, descriptors:descriptors};
......
......@@ -37,6 +37,7 @@ Scans for Bluetooth Low Energy (BLE) devices nearby. This operation consumes sys
```
bluetooth.startBLEScan({
interval:0,
success() {
console.log('call bluetooth.startBLEScan success.');
},
......@@ -71,7 +72,6 @@ Stops scanning for BLE devices nearby. This API is used with [bluetooth.startBLE
```
bluetooth.stopBLEScan({
interval:0,
success() {
console.log('call bluetooth.stopBLEScan success.');
},
......@@ -120,19 +120,12 @@ Subscribes to the newly detected BLE device. If this API is called multiple time
**Example**
```
bluetooth.startBLEScan({
success() {
bluetooth.subscribeBLEFound({
success(data) {
const [device] = data.devices;
if (!!device) {
bluetooth.stopBLEScan();
}
}
});
bluetooth.subscribeBLEFound({
success(data) {
console.log('Called bluetooth.subscribeBLEFound successsully, data: ${data}.');
},
fail(code, data) {
console.log('Failed to start BLE device scan, code: ${code}, data: ${data}');
fail(data, code) {
console.log('Failed to call bluetooth.startBLEScan, data: ${data}, code: ${code}.');
}
});
```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
反馈
建议
客服 返回
顶部