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)
![w***@163.com](https://img-cdn-tc.dcloud.net.cn/account/identicon/0468e47d4aa53d6c8b6abc7cf9b3b923.png)
- 发布:2024-01-29 14:25
- 更新:2025-01-17 14:14
- 阅读:735
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: 10
HBuilderX类型: 正式
HBuilderX版本号: 3.99
手机系统: Android
手机系统版本号: Android 13
手机厂商: OPPO
手机机型: oppo reno 7
页面类型: vue
vue版本: vue2
打包方式: 云端
项目创建方式: HBuilderX
示例代码:
操作步骤:
连接蓝牙后,写入数据时有时报错10007有时正常
连接蓝牙后,写入数据时有时报错10007有时正常
预期结果:
{"errMsg":"writeBLECharacteristicValue:ok"}
{"errMsg":"writeBLECharacteristicValue:ok"}
实际结果:
{"errMsg":"writeBLECharacteristicValue:fail property not support","errCode":10007}
{"errMsg":"writeBLECharacteristicValue:fail property not support","errCode":10007}
bug描述:
使用uniapp开发低功耗蓝牙时,小程序端一切正常,但安卓APP端和安卓APP基座经常会写入数据失败提示10007错误,
{
"errMsg": "writeBLECharacteristicValue:fail property not support",
"errCode": 10007
}
但此时读到的特征值是有write权限的,失败一段时间后会突然又可以正常收发数据。基座端如果不断开手机连接会一直可以成功发送数据,APP端有时可以有时候不行。
4 个回复
小许吃得饱
你好,这个问题解决了吗
5***@qq.com
并行调用多次会存在写失败的可能性。
会不会是因为你放在异步中,然后在重复调用。
2***@qq.com
请问解决了吗?我也有出现这个问题
不如摸鱼去
写入失败时,在失败的回调里面,尝试用失败的这次的数据再写一次。
2024-11-26 17:42
1***@qq.com
回复 不如摸鱼去: 写数据太慢了 写完全部数据得10分钟
2025-01-16 17:38
不如摸鱼去
回复 1***@qq.com: 用经典蓝牙
2025-01-18 12:02
3***@qq.com
搜了半天,也没找到解决办法,加延迟,失败重写都不行啊