记一次微信小程序蓝牙写数据错误Z.createEvent is not a function

错误表现

使用微信小程序官方文档的示例代码测试Ble蓝牙功能

蓝牙搜索设备后,发送数据时引发代码错误

image

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,
})
posted @ 2022-08-08 10:34  IT老大哥  阅读(312)  评论(0编辑  收藏  举报