记一次微信小程序蓝牙写数据错误Z.createEvent is not a function
错误表现
使用微信小程序官方文档的示例代码测试Ble蓝牙功能
蓝牙搜索设备后,发送数据时引发代码错误
VM13:1 MiniProgramError
Z.createEvent is not a function
TypeError: Z.createEvent is not a function
错误原因
wx.writeBLECharacteristicValue({
deviceId: this._deviceId,
serviceId: this._deviceId,
characteristicId: this._characteristicId,
value: buffer,
})
其中的serviceId
传参写的是_deviceId
修改方法
wx.writeBLECharacteristicValue({
deviceId: this._deviceId,
serviceId: this._serviceId,
characteristicId: this._characteristicId,
value: buffer,
})