真机调试截图如下:
代码如下,
parkmap: function () {
var devices = [];
var that = this
wx.startBeaconDiscovery({
uuids: ['00001800-0000-1000-8000-00805F9B34FB','FDA50693-A4E2-4FB1-AFCF-C6EB07647825','00001801-0000-1000-8000-00805F9B34FB','0000180F-0000-1000-8000-00805F9B34FB','0000180A-0000-1000-8000-00805F9B34FB','0000FFF0-0000-1000-8000-00805F9B34FB'],
success: function (res) {
console.log("开始扫描设备...", res);
// 监听iBeacon信号
wx.onBeaconUpdate(function (res2) {
console.log("onBeaconUpdate", res2)
wx.getBeacons({
success:function(res1){
console.log('getBeacons....'+res1.beacons.length);
}
})
if (res && res.beacons && res.beacons.length > 0) {
devices = res.beacons
// 此处最好检测rssi是否等于0,等于0的话信号强度等信息不准确。我是5秒内重复扫描排重。
}
})
},
fail: function(res) {
console.log("fail", res)
},
complete: function(res) {
console.log("complete", res)
}
})
},
找到原因了,是uuid不对。用BLE之类的调试助手APP获取的uuid不行,要找蓝牙信标厂商要uuid