{"errCode":10008,"errMsg":"notifyBLECharacteristicValueChange:fail:no descriptor"}
华为Mate20X,微信7.0.19,EMUI10.1.0.166,Android10,基础库2.13.1
getBLEDeviceServices(deviceId) {
let that = this
wx.getBLEDeviceServices({
deviceId,
success: (res) => {
for (let i = 0; i < res.services.length; i++) {
let serviceId = res.services[i].uuid
wx.getBLEDeviceCharacteristics({
deviceId,
serviceId,
success: (res) => {
for (let j = 0; j < res.characteristics.length; j++) {
let item = res.characteristics[j]
if (item.properties.read) {}
if (item.properties.write) {}
if (item.properties.notify || item.properties.indicate) {
wx.notifyBLECharacteristicValueChange({
deviceId,
serviceId,
characteristicId: item.uuid,
state: true,
})
}
}
},
fail(res) {
console.error('getBLEDeviceCharacteristics', res)
}
})
wx.onBLECharacteristicValueChange((characteristic) => {
console.log("characteristicId:" + res.characteristicId)
console.log("serviceId:" + res.serviceId)
console.log("deviceId" + res.deviceId)
console.log("Length:" + res.value.byteLength)
// const idx = inArray(this.data.chs, characteristic.characteristicId)
// const data = {}
// if (idx === -1) {
// data[`ser[${this.data.chs.length}]`] = {
// uuid: characteristic.characteristicId,
// value: ab2hex(characteristic.value)
// }
// } else {
// data[`chs[${idx}]`] = {
// uuid: characteristic.characteristicId,
// value: ab2hex(characteristic.value)
// }
// }
// this.setData(data)
})
}
that.setData(services)
this.setData({
ser: services
})
console.log(services)
},
})
},
writeBLECharacteristicValue() {
let that = this
// let dataView = new DataView(buffer)
// dataView.setUint8(0, Math.random() * 255 | 0)
console.log(that.data.text)
console.log(that.data.ser)
wx.writeBLECharacteristicValue({
deviceId: that.data.deviceId,
serviceId: "10000000-0000-0000-0000-000000000000",
characteristicId: "12000000-0000-0000-0000-000000000000",
value: new ArrayBuffer(that.data.text),
})
},
你好,麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html),麻烦在手机微信那里上传下日志: 我->设置->帮助与反馈右上角有个上报日志的入口,麻烦提供一下微信号,时间点(具体到分钟)。