ios版本11.41,微信版本6.7.1,基础库版本2.2.5
直接上代码了,deviceId、serviceId、characteristicId都是通过api获取到的,在向蓝牙设备做写操作的时候,一直返回错误代码10008,错误信息“The value’s length is invalid”,请问是接口参数调用问题,还是蓝牙设备返回了错误信息。跪求各位大佬帮忙解决一下,万分感谢。
var hex = ‘1b840084’
var typedArray = new Uint8Array(hex.match(/[\da-f]{2}/gi).map(function (h) {
return parseInt(h, 16)
}))
var buffer = typedArray.buffer;//that.hexStringToArrayBuffer(test)
wx.writeBLECharacteristicValue({
deviceId: ‘291B5157-23FD-61D3-90D5-2D44D314FB97’,
serviceId: ‘0000FFE5-0000-1000-8000-00805F9B34FB’,
characteristicId: ‘0000FFE9-0000-1000-8000-00805F9B34FB’,
value: buffer,
success: function (res) {
console.log(‘write success’)
},
fail: function(res) {
console.log(‘write fail’)
console.log(res)
}
})