小程序蓝牙扫描问题
发布于 5 年前 作者 kpan 6016 次浏览 来自 问答

自微信版本更新到6.6.6之后,上线后的小程序蓝牙功能就无法扫描到其它蓝牙设备,

而微信6.6.6之前的版本(6.6.5)都可以正常使用;

苹果没有问题

也看到其它人说这个问题,但一直没有一个解决方案

不知道官方有没有什么好的解决方案

急!!!!!!!!!!!!!!!!

6 回复

贴一下蓝牙扫描相关的代码。

try {
                wx.startBluetoothDevicesDiscovery({
                    allowDuplicatesKey: false,
                    success: (res) => {
                        wx.getBluetoothDevices({
                            success: res => {
                                console.warn('getBluetoothDevices once device:', res);
                            }
                        });
 

                        wx.onBluetoothDeviceFound(res => {

                        //找到新设备


                        });
                        resolve(res);
                    },
                    fail: (res) => {
                        console.warn("startSearch", res, new Date().format("yyyy/MM/dd hh:mm:ss S"));
                        reject(res);
                    }
                });
            } catch (error) {
                console.error('startSearch error!', deviceId, error);
                reject(error);
            }

无法扫到蓝牙设备是指

没有设备发现的回调?还是有回调但事件不正确?

留下微信号,我加你一起看看这个问题。

我也发现在安卓上,小程序蓝牙API获得的device里多数都没有name和localName,但是我同时在手机上蓝牙界面搜索有部分能显示名称,这是什么状况呢?

@Tummy 

仔细检查了一下苹果和安卓的返回数据,发现是安卓的返回参数变了



@tummy  jimmyrogue 这是我的微信,我们也有一些客户反馈类似情况。

回到顶部