自己建网站花钱吗,建设企业网站用动态还是静态,建设注册中心网站,辽宁自助网站建设公司1.解决方案的核心内容#xff1a;第一次设置失败不要管#xff0c;在complate函数里面继续往下连接#xff0c;然后设置一个定时器每1秒钟在重新设置一次#xff0c;肯定会成功的#xff01;#xff01;#xff01;#xff01;#xff01;#xff01;#xff01;第一次设置失败不要管在complate函数里面继续往下连接然后设置一个定时器每1秒钟在重新设置一次肯定会成功的
2.参考代码 /*开启监听蓝牙传值*/notifyEquip() {let _ this;console.log(*************************)if (uni.getSystemInfoSync().platform android) {uni.setBLEMTU({deviceId: _.deviceId, // 设备ID在【4】里获取到mtu: 512, // 服务UUID在【6】里能获取到success(res) {console.log(设置mtu成功)wx.getBLEMTU({deviceId: _.deviceId,writeType: write,success (res) {console.log(res)}})_.notifyBLECharacter()},fail(err) {console.error(err)_.setAndroidMTU() // 重要代码如果失败继续往下连接然后重复设置}})} else {_.notifyBLECharacter()}},/*处理设置失败安卓协商低功耗最大传输单元*/setAndroidMTU() {let _ this;console.log(处理安卓协商低功耗最大传输单元失败的方法)_.notifyBLECharacter()_.mtuTimer setInterval(() {console.log(开始循环设置MTU值)uni.setBLEMTU({deviceId: _.deviceId, // 设备ID在【4】里获取到mtu: 512, // 服务UUID在【6】里能获取到success(res) {console.log(设置mtu成功)},fail(err) {console.error(err)},complete() {wx.getBLEMTU({deviceId: _.deviceId,writeType: write,success(res) {console.log(res)clearInterval(_.mtuTimer)_.mtuTimer null;}})}})},1500)},3.基本上设置一两次虽然设置还是显示设置失败但是wx.getBLEMTU里面查到的低功耗最大传输单元会比23大我这边显示的是517