无法搜索到蓝牙外设
发布于 5 年前 作者 rcai 5983 次浏览 来自 问答

使用华为有时候会出现无法搜索到设备列表,周边一个设备都搜索不到,然后用nrf Connect等工具也无法搜索到,这个时候关闭小程序,nrf Connect就可以立刻搜索到

使用oppo手机就一直都搜索不到周边设备,列表返回空

请帮忙,今天已提交日志,微信id AIRkai

4 回复

  “compileType”: “miniprogram”,

  “libVersion”: “2.9.1”,

遇到同样的问题

  1. {errCode: 0, errMsg: "startBluetoothDevicesDiscovery:ok", isDiscovering: true}

    1. errCode0

    2. errMsg"startBluetoothDevicesDiscovery:ok"

    3. isDiscoveringtrue

首先需要确认,在搜索之前已经初始化了蓝牙模块。

也就是说,蓝牙设备的状态需要严格控制。如果在使用前已经打开,则可以试着先关闭再打开。

您可以尝试一下。

定位开关,微信定位权限看看是否获取到了。

部分手机如果灭有这两个权限搜索不到设备。

有的,在其他机型小米,ios都很稳定,而且为了防止蓝牙的问题,我们每次使用都会关闭打开蓝牙再使用

restartMatchDevice(restartCallBack) {
 
var that = this   // 注意this的层级关系
 
wx.closeBluetoothAdapter({
 
complete: function (res) {
 
console.log('关闭完毕')
 
console.log(res)
 

 
wx.openBluetoothAdapter({
 
success: function (res) {
 
that.openAdapter = true
 
that.beganSearch(restartCallBack)
 
},
 
fail: function (res) {
 
that.openAdapter = false
 
tool.showMention('请打开蓝牙1', true);
 
}
 
})
 
}
 
})
 
}
 
回到顶部