wx.openBluetoothAdapter({
success: function () {
var scaning = true;
wx.onBluetoothDeviceFound(function (res) {
console.log(res)
for (var d in res.devices) {
console.log(‘advertisData:’+d.advertisData)
console.log(typeof d.advertisData)
}
});
setTimeout(function () {
if (scaning) {
console.warn(“ble搜索超时,停止搜索”)
wx.stopBluetoothDevicesDiscovery()
fail()
}
}, 10 * 1000);
wx.startBluetoothDevicesDiscovery({
services: [‘18EE’],
allowDuplicatesKey: true,
success: function (res) {
console.log(res)
}
})
}, fail: function (e) {
fail(e)
}
})
用第三方工具扫描蓝牙,是能看到广播数据的(第二张图);
分别使用Android和iOS测试过小程序,都获取不到;