低功耗蓝牙接口writeBLECharacteristicValue执行慢?
发布于 4 年前 作者 guiyingzhou 15190 次浏览 来自 官方Issues

低功耗蓝牙接口writeBLECharacteristicValue平均执行时间2000多毫秒。什么原因导致的,哪里可以设置更快点。设备使用蓝牙调试工具发送信息没有这么长时间延时。

微信版本:7.0.16

基础库版本:2.11.3

测试手机:小米 MIUI 11 安卓10

执行代码

      let buffer = new ArrayBuffer(1)
      let dataView = new DataView(buffer)
      dataView.setUint8(0,0x01);
      let timeStart = Date.now()
      wx.writeBLECharacteristicValue({
        // 这里的 deviceId 需要在 getBluetoothDevices 或 onBluetoothDeviceFound 接口中获取
        deviceId:that.data.deviceId,
        // 这里的 serviceId 需要在 getBLEDeviceServices 接口中获取
        serviceId:that.data.serviceUUID,
        // 这里的 characteristicId 需要在 getBLEDeviceCharacteristics 接口中获取
        characteristicId:that.data.ledCharacteristicId,
        // 这里的value是ArrayBuffer类型
        value: buffer,
        success (res) {
          let timeEnd = Date.now()
          let timeDiff =  timeEnd - timeStart 
          console.log('开关led成功 操作:','执行时长:',timeDiff)
        },
        fail(res){
          console.log('开关led失败',)
        },
        complete(){
        }
      })
1 回复

请具体描述问题出现的流程,并提供能复现问题的简单代码片段https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html,麻烦再重现一次,在手机微信那里上传下日志: 我->设置->帮助与反馈右上角有个上报日志的入口,提供一下微信号,复现问题的详细时间点(如:2020-4-10 10:10)

回到顶部