收藏
回答

oppo手机调用这个方法连接蓝牙门锁设备很慢,有时甚至连接不上

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 Bug wx.createBLEConnection 微信安卓客户端 8.0.32 2.19.4

oppo手机调用这个方法连接蓝牙门锁设备很慢,有时甚至连接不上,手机型号:oppo Reno Ace,系统是 android 12,

https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.createBLEConnection.html

deviceId = that.data.roomMsg.mac
    wx.openBluetoothAdapter({
      mode:"central",
      success (resqq) {
        console.log(resqq)
        if(resqq.errno==0){
          wx.createBLEConnection({
            deviceId:deviceId,
            success (resaa) {
              console.log(resaa)
              if(resaa.errCode==0){
                // 调用开锁接口
                plugin.controlLock(plugin.ControlAction.OPEN, app.data.keyInfo.lockData, res => {
                  if (res.errorCode === 10003) {
                    console.log("获取版本信息时设备连接已断开", res)
                  }
                }, null, deviceId).then(res => {
                  wx.hideLoading();
                  console.log(res)
                  if (!!res.deviceId) deviceId = res.deviceId;
                  if (res.errorCode === 0) {
                    that.insertDoorOperSetLog(res.electricQuantity,0,res.errorCode,'')
                    // wx.showModal({
                    //   content: `已开锁`,
                    //   showCancel: false,
                    //   success(res3) {
                    //     if (res3.confirm) {}
                    //   }
                    // })
                    wx.showToast({
                      title: '已开锁',
                      icon: 'none'
                    })
                  } else {
                    that.insertDoorOperSetLog('',2,res.errorCode,res.errorMsg)
                    wx.showModal({
                      content: `开锁失败: ${res.errorMsg}`,
                      showCancel: false,
                      success(res3) {
                        if (res3.confirm) {}
                      }
                    })
                  }
                })
              }else{
                wx.showModal({
                  content: `开锁失败: ${resaa.errorMsg}`,
                  showCancel: false,
                  success(res3) {
                    
                  }
                })
              }
            }
          })
        }
      }
    })
回答关注问题邀请回答
收藏
登录 后发表内容