如何解决低功耗蓝牙设备,在安卓手机上控制设备比如(喇叭响)几乎没延迟,在苹果手机上控制设备有延迟?
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>