iOS 下 BLE 设备获取的data .advertisData为空,安卓正常
如题所示,我在安卓(荣耀9)下可以正常获取到数据,但是在 iOS (iPhone5s,iPhone6,系统10.3.3版本)下则提示错误。
主要对应区域的代码是:
var getDevList = setInterval( function () { wx.getBluetoothDevices({ success: function (res) { console.log( 'bleLength' ,that.data.bleLength,res.devices.length); if (that.data.bleList) { that.connectBle(); wx.stopBluetoothDevicesDiscovery({ success: function (res) { console.log(res) } }) clearInterval(getDevList); console.log( '已找到设备' ); return false ; } if (that.data.bleLength == res.devices.length) { wx.stopBluetoothDevicesDiscovery({ success: function (res) { console.log(res) } }) clearInterval(getDevList); console.log( 'clearInterval' ); that.setData({ bleUpdateStatus: '搜索结束,暂未找到手环...' }) setTimeout( function (){ that.setData({ bleUpdateStatus: '' }) },3000) } else { that.setData({ bleLength: res.devices.length }) } var resData = res.devices; for ( var i in resData) { var data = resData[i]; if (data.name == 'nfWatch' || data.name == 'nfWCH++' ) { console.log( 'mac' ,curMac,data.advertisData,that.buf2hex(data.advertisData)); // if (curMac == that.buf2hex(data.advertisData).slice(4)) { that.setData({ bleList: data, bleUpdateStatus: '已找到手环,同步中...' }) // } // console.log(data.name, data.deviceId, data.advertisServiceUUIDs, data.RSSI, data.advertisData, that.buf2hex(data.advertisData)); // console.log(data.name, data.deviceId, that.buf2hex(data.advertisData).slice(4)); } } }, fail: function (res) { console.log(res); } }) }, 6000) |