windows操作系统,版本号:版本(1.06.2504010win32-x64)。
代码片段:
onBluetoothDeviceFound() {
wx.onBluetoothDeviceFound((res) => {
res.devices.forEach(device => {
const foundDevices = this.data.devices
const idx = inArray(foundDevices, 'deviceId', device.deviceId)
const data = {}
if (idx === -1) {
data[`devices[${foundDevices.length}]`] = device//设备不存在于列表中, 把设备添加到数组末尾
} else {
data[`devices[${idx}]`] = device//设备已经存在,更新已有设备信息
}
this.setData(data)//使用 setData 更新页面数据,触发视图刷新。
})
})
},
// ArrayBuffer转16进度字符串示例
function ab2hex(buffer) {
if (!buffer || buffer.length <= 0) {
return "";
}
var hexArr = Array.prototype.map.call(
new Uint8Array(buffer),
function (bit) {
return ('00' + bit.toString(16)).slice(-2)
}
)
return hexArr.join('').toUpperCase();
}
问题:在微信端获取的“ArrayBuffer”数据,在使用ab2hex()函数后,与安卓app的lightblue软件所获取的值不一样或者直接就没有,但是其它的参数可以正常获取到。请问我该如何解决,谢谢。
我开发环境是windows系统,测试用的是荣耀手机