addDeviceStatusListener
功能描述
添加设备连接状态监听器
该监听器只针对SDK中的蓝牙适配器
发送参数
Object
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| id | string | 是 | 监听器的id | |
| callback | function | 是 | 监听的回调 |
返回类型
是否为Promise: 是
返回值
Object
| 属性 | 类型 | 说明 |
|---|---|---|
| errCode | number | 错误码 |
| errMsg | string | 错误消息 |
callback 回调值
Object
| 属性 | 类型 | 说明 |
|---|---|---|
| connected | boolean | 设备连接状态。false为断开,true为已连接 |
调用示例
app.imcamWx.addDeviceStatusListener({
id: 'deviceStatusListener',
callback: res => {
if (!res.connected) console.error('设备断开连接')
}
})
.then(res => {
console.log(res)
})返回值示例
{
errCode: 0,
errMsg: 'ok'
}callback 回调值示例
{
connected: true
}