ios、安卓都能发送数据,但是只有ios能接收到回传的数据
尝试了其他解决方法,设置MTU,设置延时都不行
js代码如下
const mtu = 512;
wx.setBLEMTU({
deviceId: that.data.connectedDeviceId,
mtu,
success:(res)=>{
console.log("setBLEMTU success>>", res)
},
fail:(res)=>{
console.log("setBLEMTU fail>>", res)
}
})
wx.writeBLECharacteristicValue({
deviceId: that.data.connectedDeviceId,
serviceId: that.data.services[0].uuid,
characteristicId: that.data.characteristics[0].uuid,
value: buffer,
success: function (res) {
console.log('发送成功')
wx.showToast({
title: 'wifi id 发送成功',
})
setTimeout(function () {}, 1000); // 1秒延时
wx.notifyBLECharacteristicValueChange({
state: true,
deviceId: that.data.connectedDeviceId,
serviceId: that.data.services[0].uuid,
characteristicId: that.data.characteristics[0].uuid,
success: function (res) {
console.log('启用notify成功')
wx.onBLECharacteristicValueChange(function (res) {
var receiveText = app.buf2string(res.value)
console.log('接收到数据:' + receiveText)
that.setData({
receiveText: receiveText
})
})
}
})
}
})
你好,麻烦在手机微信那里上传下日志: 我->设置->帮助与反馈右上角有个上报日志的入口,麻烦提供一下微信号,时间点
还有这样可以看一下 wx.getBLEMTU 传输单位 iOS 是按照最大值来传输,Android 的值是变化的需要自己手动设置,我的是这样解决的