js代码:
labaSoundAll:function () {
let that = this;
this.setData({
isPressstop: true
});
labatime = setInterval(() => {
// 使用 Promise 来确保微任务结束前停止所有操作
that.labaSound();
}, 100);
},
labaSound: function () {
if(this.data.isPressstop==false){
return
}
var realdata = [0xA5, 0x01, 0xB3, 0x01, 0x26, 0x01];
var buffer = new ArrayBuffer(6);
var dataView = new DataView(buffer);
realdata.forEach(function (item, index) {
dataView.setUint8(index, item)
})
wx.writeBLECharacteristicValue({
characteristicId: app.globalData.globalcharacteristicId,
deviceId: app.globalData.globalDeviceId,
serviceId: app.globalData.globalservices,
value: buffer,
success: function (res) {
// console.log('停止成功')
},
fail: function (res) {
// console.log('停止失败')
},
})
},
页面代码:
<view class="stopView" bindtouchstart="labaSoundAll" bindtouchend="uplabaSound">
<image src="{{isPressstop?'../../images/control/btn_laba_pre.png':'../../images/control/btn_laba_nor.png'}}" class="stopimage"></image>
<!-- <view class="stoptext">停止</view> -->
</view>
iPhone上的蓝牙延迟本来就比较高,这个是硬件问题呀,解决方法,给用户配备安卓手机
有哪个宝子知道嘛,E95低功耗蓝牙