流程是这样的:搜索到设备关闭搜索关闭蓝牙连接然后弹框,点击确定以后继续调用这个方法开启搜索,我的两个手机测试的都没问题,朋友的手机点五次弹框以后就不搜索了,这是什么bug
代码片段:
lanya() {
let that = this
wx.openBluetoothAdapter({
success: function (res) {
console.log(res)
//开始搜索蓝牙
wx.startBluetoothDevicesDiscovery({
success: function (res) {
console.log('search', res)
wx.onBluetoothDeviceFound(function (devices) {
console.log('发现设备22', devices.devices)
for (let i = 0; i < devices.devices.length; i++) {
if (!(undefined == devices.devices[i].localName)) {
//检索指定设备
if (devices.devices[i].localName.split('-')[0] == 'HRC') {
console.log('已找到指定设备:', devices.devices[i].localName);
//关闭搜索
wx.stopBluetoothDevicesDiscovery({
success (res) {
console.log('关闭搜索',res)
}
});
//关闭蓝牙连接
wx.closeBluetoothAdapter({
success: function (res) {
console.log('关闭蓝牙连接',res)
}
});
wx.showModal({
title: '提示',
content: '发现设备:' + devices.devices[i].localName,
showCancel: false,
success: function (res) {
if (res.confirm) {
console.log('用户点击确定')
that.lanya()
}
}
})
break;
}
}
}
})
}
})
},
fail: function (res) {
wx.showModal({
showCancel: false,
content: '请先开启手机蓝牙',
success: function (res) {
setTimeout(function () {
that.lanya()
}, 5000)
}
})
}
})
}
你好,打印一下complete或者fail回调排查下。
问题机型:oppoR17 华为mate20
微信版本号:7.0.14
系统版本号:Android9(oppoR17) 华为mate20的系统不清楚
代码片段:https://developers.weixin.qq.com/s/tJCGwbmX7th5