- 用wx.makeBluetoothPair配对success返回成功。但是连接不上设备???
https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.makeBluetoothPair.html
2020-12-14 - 小程序向蓝牙写入二进制数据调用 wx.writeBLECharacteristicValue 报错?
var that = this; let buffer = new ArrayBuffer(5) let dataView = new DataView(buffer) //写入通道指令 dataView.setUint8(0, 0x1B) dataView.setUint8(1, 0x11) dataView.setUint8(2, 0x03) dataView.setUint8(3, 0x00) dataView.setUint8(4, 0x00) console.log("发送的数据:") for (let i = 0; i < dataView.byteLength; i++) { console.log("0x" + dataView.getUint8(i).toString(16)) } wx.writeBLECharacteristicValue({ deviceId: that.data.deviceId, serviceId: that.data.service_id, characteristicId: that.data.write_id, // 这里的value是ArrayBuffer类型 value: buffer, success: function(res) { console.log('写入成功', res.errMsg) }, fail(res) { console.log('写入失败', res.errMsg) }, complete: function() { console.log("写入完成"); } 在调用 wx.writeBLECharacteristicValue时一直报错,错误信息如下 {errCode: 10008, errMsg: "writeBLECharacteristicValue:fail write characteris…ror. 10008, errMsg=The value's length is invalid."} 还了好几个手机都不行,我的deviceId,serviceId,characteristicId 都是通过api获取到的。 测试机型有 iphone7p,华为p10,红米 小程序的基础库是 2.11.1
2020-05-29