微信小程序向低功耗蓝牙设备写入数据的函数无响应,怎么回事?
我正在开发一个低功耗蓝牙的小程序,蓝牙设备是用的HC-08.在尝试向蓝牙设备写入数据时,我调用了wx.writeBLECharacteristicValue函数,并向其中加入了回调函数success, fail和complete。但是包括complete在内,没有任何一个回调函数被执行,就是说,我的数据没有发出去。我已经确定了我的设备有write标签,并且我要发送的数据也没有超过20个字节,请问这是怎么一回事呢? [代码]writeBLECharValStandAlone()[代码][代码] [代码][代码]{[代码][代码] [代码][代码]var[代码] [代码]that = [代码][代码]this[代码][代码];[代码][代码] [代码][代码]var[代码] [代码]i = 1;[代码][代码] [代码][代码]let buffer = [代码][代码]new[代码] [代码]ArrayBuffer(1)[代码][代码] [代码][代码]let dataView = [代码][代码]new[代码] [代码]DataView(buffer)[代码][代码] [代码][代码]dataView.setUint8(0, 9)[代码][代码] [代码][代码]while[代码][代码](i!=0){[代码][代码] [代码][代码]wx.writeBLECharacteristicValue({[代码][代码] [代码][代码]deviceId: that.data._deviceId,[代码][代码] [代码][代码]serviceId: that.data._serviceId,[代码][代码] [代码][代码]characteristicId: that.data._characteristicId,[代码][代码] [代码][代码]value: buffer,[代码][代码] [代码][代码]success: [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]console.log([代码][代码]"wrote:"[代码] [代码]+ dataView.getUint8(0))[代码][代码] [代码][代码]i=0;[代码][代码] [代码][代码]},[代码][代码] [代码][代码]fail: [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]console.log([代码][代码]"write failed."[代码] [代码]+ res.errMsg + res.errCode)[代码][代码] [代码][代码]},[代码][代码] [代码][代码]complete: [代码][代码]function[代码] [代码]() {[代码][代码] [代码][代码]console.log([代码][代码]"finished."[代码][代码])[代码][代码] [代码][代码]},[代码][代码] [代码][代码]})[代码][代码] [代码][代码]i += 1[代码][代码] [代码][代码]console.log([代码][代码]"trying"[代码][代码]+i)[代码][代码] [代码][代码]}[代码][代码] [代码][代码]},[代码][图片]