蓝牙模块现在是都搜索不到设备了吗?
发布于 6 年前 作者 jinna 2013 次浏览 来自 问答

//index.js

//获取应用实例

const app = getApp()

Page({

data: {

},

onLoad: function () {

wx.openBluetoothAdapter({

success: function (res) {

console.info(res);

},

fail: function (res) {

console.info(res);

wx.showModal({

title: ‘提示’,

content: ‘监测到系统未开启蓝牙,请前往设置开启蓝牙模块!’,

})

}

})

wx.onBluetoothAdapterStateChange(function (res) {

console.log(`adapterState changed, now is`, res)

if (res.available) {

wx.showToast({

title: ‘蓝牙已开启’

});

} else {

wx.showToast({

title: ‘蓝牙已关闭’

});

}

})

wx.startBluetoothDevicesDiscovery({

success: function (res) {

console.log(res)

}

})

setTimeout(function (res) {

wx.getBluetoothDevices({

success: function (res) {

console.log(res)

}

})

}, 10000);

wx.onBluetoothDeviceFound(function (devices) {

console.log(‘new device list has founded’)

console.dir(devices);

wx.getBluetoothDevices({

success: function (res) {

console.log(res)

}

})

})

},

getBluetoothDevices: function () {

let that = this;

wx.getBluetoothDevices({

success: function (res4) {

console.log(res4);

for (let item of res4.devices) {

console.log(item.name.trim())

console.log(item.name.trim().length)

}

}

})

},

startsearch:function(){

wx.startBluetoothDevicesDiscovery({

success: function (res) {

console.log(res)

}

})

},

})

我这样写得到的array永远为0,用了多个真机调试都没用,是不是蓝牙模块有问题?

7 回复

现在又可以搜索到了。。但是搜索到到都是未知设备,根据deviceId看了一下周边都设备也不知道哪来都,一些自己开着的蓝牙设备又搜索不到,代码都没动过,调试也就是那几个手机,好不稳定啊,晚上回家换个环境试试看把,排除一些客观的因素。

我们买到是蓝牙2.0的,手机能搜索到,小程序到api不行吗?

对手机的蓝牙有什么要求吗?

问题再描述详细点 ?

你好,不是的,我们只支持 BLE4.0 以上的设备,手机蓝牙列表页的设备 与 低功耗蓝牙接口搜索到的设备 是不一致的。

师兄,问下是不是手机蓝牙能搜索到到设备,微信到蓝牙api就一定能搜索到?

你好,目前接口是正常的。

请问是什么机型遇到的问题,微信版本是?

确定周边有蓝牙设备在广播么?

确定下手机的蓝牙模块是否已经打开了

确定下手机的定位开关是否已经打开了

回到顶部