小程序
小游戏
企业微信
微信支付
扫描小程序码分享
使用华为有时候会出现无法搜索到设备列表,周边一个设备都搜索不到,然后用nrf Connect等工具也无法搜索到,这个时候关闭小程序,nrf Connect就可以立刻搜索到
使用oppo手机就一直都搜索不到周边设备,列表返回空
请帮忙,今天已提交日志,微信id AIRkai
4 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
定位开关,微信定位权限看看是否获取到了。
部分手机如果灭有这两个权限搜索不到设备。
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
oppo打开定位后可以,
但华为的一直都是开着的,但有几率出现搜不到
搜索相关的代码贴一下,有过滤设备么?
// 搜索指定名称的设备
searchMatchDevice(searchCallBack, matchName) {
tool.showMention(
'匹配中'
,
false
);
var
that =
this
// 注意this的层级关系
console.log(
'需要查找的设备:'
+ matchName)
console.log(that.openAdapter)
if
(that.openAdapter ==
) {
searchCallBack(
null
'请打开蓝牙3'
)
return
}
wx.getBluetoothDevices({
success:
function
(res) {
let devices = res.devices
'找到'
+ devices.length +
'个设备'
//这里devices.length返回的是0
for
(let i =
0
; i < devices.length; i++) {
///
},
fail:
'搜索失败'
console.log(res)
})
谢谢!连续搜索了10次,但返回的日志一直显示0个设备,周边是有5个设备的,其他手机当时也可以搜索到
04
:
15
48.114
BLEManage.js? [sm]:
34
成功,准备开始搜索:
48.115
35
{errCode:
, errMsg:
"startBluetoothDevicesDiscovery:ok"
, isDiscovering:
true
48.197
50
{available:
, discovering:
50.120
index.js? [sm]:
312
搜索:
10
50.126
80
需要查找的设备:MCOD-5acf06940002
50.128
81
50.593
89
找到
个设备
52.134
9
52.140
52.143
52.681
54.149
8
54.153
54.155
54.386
56.158
7
56.164
56.166
56.474
58.170
6
58.175
58.179
58.590
微信号给一下,我拉一下日志看看。
这里我还是比较怀疑微信没有拿到定位的权限导致的。
微信id AIRkai
谢谢
首先需要确认,在搜索之前已经初始化了蓝牙模块。
也就是说,蓝牙设备的状态需要严格控制。如果在使用前已经打开,则可以试着先关闭再打开。
您可以尝试一下。
"compileType": "miniprogram",
"libVersion": "2.9.1",
遇到同样的问题
{errCode: 0, errMsg: "startBluetoothDevicesDiscovery:ok", isDiscovering: true}
errCode: 0
errMsg: "startBluetoothDevicesDiscovery:ok"
isDiscovering: true
有的,在其他机型小米,ios都很稳定,而且为了防止蓝牙的问题,我们每次使用都会关闭打开蓝牙再使用
restartMatchDevice(restartCallBack) {
wx.closeBluetoothAdapter({
complete:
'关闭完毕'
wx.openBluetoothAdapter({
that.openAdapter =
that.beganSearch(restartCallBack)
'请打开蓝牙1'
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
定位开关,微信定位权限看看是否获取到了。
部分手机如果灭有这两个权限搜索不到设备。
oppo打开定位后可以,
但华为的一直都是开着的,但有几率出现搜不到
搜索相关的代码贴一下,有过滤设备么?
// 搜索指定名称的设备searchMatchDevice(searchCallBack, matchName) {tool.showMention('匹配中',false);varthat =this// 注意this的层级关系console.log('需要查找的设备:'+ matchName)console.log(that.openAdapter)if(that.openAdapter ==false) {searchCallBack(null,false,'请打开蓝牙3')return}wx.getBluetoothDevices({success:function(res) {let devices = res.devicesconsole.log('找到'+ devices.length +'个设备')//这里devices.length返回的是0for(let i =0; i < devices.length; i++) {///}},fail:function(res) {console.log('搜索失败')console.log(res)searchCallBack(null,false,'搜索失败')}})}谢谢!连续搜索了10次,但返回的日志一直显示0个设备,周边是有5个设备的,其他手机当时也可以搜索到
04:15:48.114BLEManage.js? [sm]:34成功,准备开始搜索:04:15:48.115BLEManage.js? [sm]:35{errCode:0, errMsg:"startBluetoothDevicesDiscovery:ok", isDiscovering:true}04:15:48.197BLEManage.js? [sm]:50{available:true, discovering:true}04:15:50.120index.js? [sm]:312搜索:1004:15:50.126BLEManage.js? [sm]:80需要查找的设备:MCOD-5acf0694000204:15:50.128BLEManage.js? [sm]:81true04:15:50.593BLEManage.js? [sm]:89找到0个设备04:15:52.134index.js? [sm]:312搜索:904:15:52.140BLEManage.js? [sm]:80需要查找的设备:MCOD-5acf0694000204:15:52.143BLEManage.js? [sm]:81true04:15:52.681BLEManage.js? [sm]:89找到0个设备04:15:54.149index.js? [sm]:312搜索:804:15:54.153BLEManage.js? [sm]:80需要查找的设备:MCOD-5acf0694000204:15:54.155BLEManage.js? [sm]:81true04:15:54.386BLEManage.js? [sm]:89找到0个设备04:15:56.158index.js? [sm]:312搜索:704:15:56.164BLEManage.js? [sm]:80需要查找的设备:MCOD-5acf0694000204:15:56.166BLEManage.js? [sm]:81true04:15:56.474BLEManage.js? [sm]:89找到0个设备04:15:58.170index.js? [sm]:312搜索:604:15:58.175BLEManage.js? [sm]:80需要查找的设备:MCOD-5acf0694000204:15:58.179BLEManage.js? [sm]:81true04:15:58.590BLEManage.js? [sm]:89找到0个设备微信号给一下,我拉一下日志看看。
这里我还是比较怀疑微信没有拿到定位的权限导致的。
微信id AIRkai
谢谢
首先需要确认,在搜索之前已经初始化了蓝牙模块。
也就是说,蓝牙设备的状态需要严格控制。如果在使用前已经打开,则可以试着先关闭再打开。
您可以尝试一下。
"compileType": "miniprogram",
"libVersion": "2.9.1",
遇到同样的问题
{errCode: 0, errMsg: "startBluetoothDevicesDiscovery:ok", isDiscovering: true}
errCode: 0
errMsg: "startBluetoothDevicesDiscovery:ok"
isDiscovering: true
有的,在其他机型小米,ios都很稳定,而且为了防止蓝牙的问题,我们每次使用都会关闭打开蓝牙再使用
restartMatchDevice(restartCallBack) {varthat =this// 注意this的层级关系wx.closeBluetoothAdapter({complete:function(res) {console.log('关闭完毕')console.log(res)wx.openBluetoothAdapter({success:function(res) {that.openAdapter =truethat.beganSearch(restartCallBack)},fail:function(res) {that.openAdapter =falsetool.showMention('请打开蓝牙1',true);}})}})}