w***@163.com
w***@163.com
  • 发布:2024-01-29 14:25
  • 更新:2024-05-31 11:33
  • 阅读:192

【报Bug】安卓APP低功耗蓝牙写入数据经常失败,报10007错误

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: 10

HBuilderX类型: 正式

HBuilderX版本号: 3.99

手机系统: Android

手机系统版本号: Android 13

手机厂商: OPPO

手机机型: oppo reno 7

页面类型: vue

vue版本: vue2

打包方式: 云端

项目创建方式: HBuilderX

示例代码:
setTimeout(()=>{  
                  console.log(that.characteristics)  
                  console.log(that.connectedDeviceId)  
                  console.log(that.services[getApp().globalData.services_code].uuid)  
                  console.log(that.characteristics[getApp().globalData.Tcharacter_code].uuid)  
                  uni.writeBLECharacteristicValue({            //向低功耗蓝牙设备特征值中写入二进制数据  
                    deviceId: that.connectedDeviceId,  
                    serviceId: that.services[getApp().globalData.services_code].uuid,  
                    characteristicId: that.characteristics[getApp().globalData.Tcharacter_code].uuid,  
                    value: buffer,  
                    success: function (res) {  
                      setTimeout(()=>{  
                          console.log(res)  
                          console.log('助手发送成功home信息')  
                      },10)  
                    },  
                    fail: function (res) {  
                        console.log(res)  
                        console.log(that.connectedDeviceId)  
                        console.log(that.services[getApp().globalData.services_code].uuid)  
                        console.log(that.characteristics[getApp().globalData.Tcharacter_code].uuid)  
                            console.log('助手发送失败home信息')  
                    }  
                  })  
              },1000) 

操作步骤:

连接蓝牙后,写入数据时有时报错10007有时正常

预期结果:

{"errMsg":"writeBLECharacteristicValue:ok"}

实际结果:

{"errMsg":"writeBLECharacteristicValue:fail property not support","errCode":10007}

bug描述:

使用uniapp开发低功耗蓝牙时,小程序端一切正常,但安卓APP端和安卓APP基座经常会写入数据失败提示10007错误,

{    
  "errMsg": "writeBLECharacteristicValue:fail property not support",    
  "errCode": 10007    
}

但此时读到的特征值是有write权限的,失败一段时间后会突然又可以正常收发数据。基座端如果不断开手机连接会一直可以成功发送数据,APP端有时可以有时候不行。

2024-01-29 14:25 负责人:无 分享
已邀请:
小许吃得饱

小许吃得饱

你好,这个问题解决了吗

5***@qq.com

5***@qq.com

并行调用多次会存在写失败的可能性。
会不会是因为你放在异步中,然后在重复调用。

要回复问题请先登录注册