这是转换为16进制,我想转换为10进制然后复制给"e",求大佬指点
//将bufferArray类型转为string类型
function ab2hex(buffer) {
var hexArr = Array.prototype.map.call(
new Uint8Array(buffer),
//监听蓝牙发送过来的值
function(bit) {
return ('00' + bit.toString(16)).slice(-2)
}
)
return hexArr.join('');
}
wx.onBLECharacteristicValueChange(function (res) {
console.log('characteristic value comed:', ab2hex(res.value))
let hex = ab2hex(res.value);
that.setData({
e:hex
})
})