# startBluetoothDiscovery ^6.8
开始扫描附近蓝牙设备
# 请求参数
Prop | Type | Default | Comment |
---|---|---|---|
mac | String | N/A | //安卓:蓝牙 Mac 地址;iOS:外设 uuid |
name | String | N/A | 筛选的名字 |
duration | String | N/A | 扫描持续时间 单位秒 |
# 引入接口模块
import bridge from '@minix-iot/etsbridge-sdk'
1
# 接口调用示例
let params = {
name: 'QWQ001-', // 可选 筛选的名字
mac: '1812', // 可选 筛选的mac
duration: '5', //单位秒, 可选
}
bridge
.startBluetoothDiscovery(params)
.then((res) => {
console.log(res)
})
.catch((err) => {
console.log(err)
})
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
# 返回参数
- 成功时返回
Prop | Type | Comment |
---|---|---|
code | Number | - |
name | String | 名字 |
rssi | String | - |
deviceId | String | - |
# 返回示例
- 当扫描到的蓝牙设备(蓝牙信息)时,APP 通知插件结果
- 扫描期间会多次通知,每发现一个记录通知一次
// 通过receiveMessageFromApp事件返回。
this.$bridge.addEventListener('receiveMessageFromApp', (res) => {
console.log('startBluetoothDiscovery', JSON.stringify(res))
this.$bridge.showToast({
title: JSON.stringify(res),
duration: 5,
})
})
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8