Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Coping0606
Docs
提交
f23fa0a8
D
Docs
项目概览
Coping0606
/
Docs
与 Fork 源项目一致
Fork自
OpenHarmony / Docs
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f23fa0a8
编写于
6月 29, 2022
作者:
L
lverpeng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
示例代码,接口完整性测试docs修改
Signed-off-by:
N
lverpeng
<
lverpeng118@163.com
>
上级
a4b4c216
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
37 addition
and
25 deletion
+37
-25
zh-cn/application-dev/reference/apis/js-apis-bluetooth.md
zh-cn/application-dev/reference/apis/js-apis-bluetooth.md
+32
-13
zh-cn/application-dev/reference/apis/js-apis-system-bluetooth.md
...pplication-dev/reference/apis/js-apis-system-bluetooth.md
+5
-12
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-bluetooth.md
浏览文件 @
f23fa0a8
...
@@ -233,6 +233,8 @@ cancelPairedDevice(deviceId: string): boolean
...
@@ -233,6 +233,8 @@ cancelPairedDevice(deviceId: string): boolean
删除配对的远程设备。
删除配对的远程设备。
此接口为系统接口。
**需要权限**
:ohos.permission.DISCOVER_BLUETOOTH
**需要权限**
:ohos.permission.DISCOVER_BLUETOOTH
**系统能力**
:SystemCapability.Communication.Bluetooth.Core。
**系统能力**
:SystemCapability.Communication.Bluetooth.Core。
...
@@ -397,7 +399,7 @@ startBluetoothDiscovery(): boolean
...
@@ -397,7 +399,7 @@ startBluetoothDiscovery(): boolean
开启蓝牙扫描,可以发现远端设备。
开启蓝牙扫描,可以发现远端设备。
**需要权限**
:ohos.permission.
USE
_BLUETOOTH;ohos.permission.LOCATION
**需要权限**
:ohos.permission.
DISCOVER
_BLUETOOTH;ohos.permission.LOCATION
**系统能力**
:SystemCapability.Communication.Bluetooth.Core。
**系统能力**
:SystemCapability.Communication.Bluetooth.Core。
...
@@ -1125,7 +1127,7 @@ startBLEScan(filters: Array<ScanFilter>, options?: ScanOptions): void
...
@@ -1125,7 +1127,7 @@ startBLEScan(filters: Array<ScanFilter>, options?: ScanOptions): void
发起BLE扫描流程。
发起BLE扫描流程。
**需要权限**
:ohos.permission.DISCOVER_BLUETOOTH;ohos.permission.MANAGE_BLUETOOTH;
ohos.permission.LOCATION
**需要权限**
:ohos.permission.DISCOVER_BLUETOOTH;ohos.permission.MANAGE_BLUETOOTH;ohos.permission.LOCATION
**系统能力**
:SystemCapability.Communication.Bluetooth.Core。
**系统能力**
:SystemCapability.Communication.Bluetooth.Core。
...
@@ -1396,7 +1398,7 @@ A2dpSourceProfile.on('connectionStateChange', onReceiveEvent);
...
@@ -1396,7 +1398,7 @@ A2dpSourceProfile.on('connectionStateChange', onReceiveEvent);
### A2dpSourceProfile.off('connectionStateChange')<sup>8+</sup>
### A2dpSourceProfile.off('connectionStateChange')<sup>8+</sup>
off(type: "connectionStateChange", callback: Callback
<
[StateChangeParam](#StateChangeParam)
>
): void
off(type: "connectionStateChange", callback
?
: Callback
<
[StateChangeParam](#StateChangeParam)
>
): void
取消订阅a2dp连接状态变化事件。
取消订阅a2dp连接状态变化事件。
...
@@ -1423,12 +1425,14 @@ A2dpSourceProfile.off('connectionStateChange', onReceiveEvent);
...
@@ -1423,12 +1425,14 @@ A2dpSourceProfile.off('connectionStateChange', onReceiveEvent);
```
```
### getPlayingState
### getPlayingState
<sup>9+</sup>
getPlayingState(device: string): PlayingState
getPlayingState(device: string): PlayingState
获取设备的播放状态。
获取设备的播放状态。
**需要权限**
:ohos.permission.USE_BLUETOOTH
**系统能力**
:SystemCapability.Communication.Bluetooth.Core。
**系统能力**
:SystemCapability.Communication.Bluetooth.Core。
**参数:**
**参数:**
...
@@ -1551,7 +1555,7 @@ HandsFreeAudioGatewayProfile.on('connectionStateChange', onReceiveEvent);
...
@@ -1551,7 +1555,7 @@ HandsFreeAudioGatewayProfile.on('connectionStateChange', onReceiveEvent);
### HandsFreeAudioGatewayProfile.off('connectionStateChange')<sup>8+</sup>
### HandsFreeAudioGatewayProfile.off('connectionStateChange')<sup>8+</sup>
off(type: "connectionStateChange", callback: Callback
<
[StateChangeParam](#StateChangeParam)
>
): void
off(type: "connectionStateChange", callback
?
: Callback
<
[StateChangeParam](#StateChangeParam)
>
): void
取消订阅HFP连接状态变化事件。
取消订阅HFP连接状态变化事件。
...
@@ -1807,6 +1811,16 @@ server端特征值发生变化时,主动通知已连接的client设备。
...
@@ -1807,6 +1811,16 @@ server端特征值发生变化时,主动通知已连接的client设备。
**示例:**
**示例:**
```
js
```
js
// 创建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
arrayBufferC
=
new
ArrayBuffer
(
8
);
let
characteristic
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
let
characteristic
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
characteristicUuid
:
'
00001820-0000-1000-8000-00805F9B34FB
'
,
characteristicValue
:
arrayBufferC
,
descriptors
:
descriptors
};
characteristicUuid
:
'
00001820-0000-1000-8000-00805F9B34FB
'
,
characteristicValue
:
arrayBufferC
,
descriptors
:
descriptors
};
...
@@ -2385,14 +2399,9 @@ client端获取蓝牙低功耗设备的所有服务,即服务发现。
...
@@ -2385,14 +2399,9 @@ client端获取蓝牙低功耗设备的所有服务,即服务发现。
```
js
```
js
// Promise 模式
// Promise 模式
let
device
=
bluetooth
.
BLE
.
createGattClientDevice
(
'
XX:XX:XX:XX:XX:XX
'
);
gattClientDevice
.
getServices
().
then
(
result
=>
{
device
.
connect
();
console
.
info
(
"
getServices successfully:
"
+
JSON
.
stringify
(
result
));
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
);
}
```
```
...
@@ -2725,6 +2734,16 @@ setNotifyCharacteristicChanged(characteristic: BLECharacteristic, enable: boolea
...
@@ -2725,6 +2734,16 @@ setNotifyCharacteristicChanged(characteristic: BLECharacteristic, enable: boolea
**示例:**
**示例:**
```
js
```
js
// 创建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
arrayBufferC
=
new
ArrayBuffer
(
8
);
let
characteristic
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
let
characteristic
=
{
serviceUuid
:
'
00001810-0000-1000-8000-00805F9B34FB
'
,
characteristicUuid
:
'
00001820-0000-1000-8000-00805F9B34FB
'
,
characteristicValue
:
arrayBufferC
,
descriptors
:
descriptors
};
characteristicUuid
:
'
00001820-0000-1000-8000-00805F9B34FB
'
,
characteristicValue
:
arrayBufferC
,
descriptors
:
descriptors
};
...
...
zh-cn/application-dev/reference/apis/js-apis-system-bluetooth.md
浏览文件 @
f23fa0a8
...
@@ -130,19 +130,12 @@ ohos.permission.MANAGE_BLUETOOTH
...
@@ -130,19 +130,12 @@ ohos.permission.MANAGE_BLUETOOTH
**示例:**
**示例:**
```
```
bluetooth.startBLEScan({
bluetooth.subscribeBLEFound({
success() {
success(data) {
bluetooth.subscribeBLEFound({
console.log('call bluetooth.subscribeBLEFound success, data: ${data}.');
success(data) {
const [device] = data.devices;
if (!!device) {
bluetooth.stopBLEScan();
}
}
});
},
},
fail(
code, data
) {
fail(
data, code
) {
console.log('
Failed to start BLE device scan, code: ${code}, data: ${data}
');
console.log('
call bluetooth.startBLEScan failed, data: ${data}, code: ${code}.
');
}
}
});
});
```
```
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录