- 低功耗蓝牙wx.getBLEDeviceServices接口问题
- 当前 Bug 的表现(可附上截图) 使用wx.createBLEConnection连接BLE设备后,接着使用wx.getBLEDeviceServices获取服务UUID,获取服务UUID有时候会报错,errCode为:10004(no service),重新调用wx.getBLEDeviceServices接口还是报同样的错误,如果去调用wx.createBLEConnection重新连接设备,会报错,errCode为:-1(already connected) - 预期表现 wx.createBLEConnection连接设备后,wx.getBLEDeviceServices获取服务UUID应该成功 - 复现路径 - 提供一个最简复现 Demo createBLEConnection: function (deviceId){ wx.createBLEConnection({ deviceId: deviceId, success: (res) => { console.log("createBLEConnection success: ", res) this.getBLEDeviceServices(deviceId) }, fail: (res) => { console.error("createBLEConnection fail: ", res) if (res.errCode == -1){ this.getBLEDeviceServices(deviceId) } else { wx.showModal({ title: '提示', content: '连接失败,请稍后重试!', showCancel: false }) } } }) } getBLEDeviceServices: function (deviceId) { wx.getBLEDeviceServices({ deviceId, success: (res) => { for (let i = 0; i < res.services.length; i++) { if (res.services[i].isPrimary) { let serviceId = res.services[i].uuid wx.getBLEDeviceCharacteristics({ deviceId, serviceId, success: (res) => { console.log('getBLEDeviceCharacteristics success: ', res.characteristics) }, fail: (res) => { console.error('getBLEDeviceCharacteristics failed: ', res) } }) return } } }, fail: (res) => { console.error("getBLEDeviceServices failed: ", res) if (res.errCode == 10004){ wx.showLoading({ title: '设备连接出错,自动重连中', }) setTimeout(() => { let _deviceId = deviceId this.createBLEConnection(_deviceId) //this.getBLEDeviceServices(_deviceId) }, 1000) } } }) }
2019-03-07 - 安卓的蓝牙搜索烂啦???
上星期安卓IOS都能正常扫描蓝牙设备,今天的安卓上突然就扫描不到设备了,一个都扫不到; 已测试机型 : oppo A57 -- Android 6.0.1 -- 微信版本6.6.7 Galaxy C9 Pro -- android 7.1.1 -- 微信版本6.6.7
2018-09-25