1***@qq.com
1***@qq.com
  • 发布:2023-03-13 17:03
  • 更新:2023-03-14 09:06
  • 阅读:158

【报Bug】苹果6p 蓝牙写入命令uni.writeBLECharacteristicValue 无反应

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: Windows 10 专业版--- 21H2

HBuilderX类型: 正式

HBuilderX版本号: 3.7.3

手机系统: iOS

手机系统版本号: iOS 12.4

手机厂商: 苹果

手机机型: 苹果6P

页面类型: vue

vue版本: vue2

打包方式: 云端

项目创建方式: HBuilderX

示例代码:

BleWrite(instruction, deviceId, serviceId, characteristicId) {
let _this = this
//转换数据格式
let buffer = _this.hex2ArrayBuffer(instruction)
uni.writeBLECharacteristicValue({
deviceId:deviceId, // 蓝牙设备 deviceId
serviceId:serviceId, // 蓝牙服务uuid,即第二个uuid
characteristicId:characteristicId, // 蓝牙特征值的 (即 writeId)
value: buffer, // 这里的value是ArrayBuffer类型
writeType: 'write',
complete() {
console.log('complete' + instruction)
},
success(res) {
console.log('指令发送成功' + instruction)
_this.notifyBLECharacteristicValueChange(deviceId, serviceId, _this
.characteristicIdNew1)
},
fail(err) {
console.log('指令发送失败过' + instruction)
}
})
},
// 16进制转buffer
hex2ArrayBuffer(hex_str) {
// let hex_str = 'AA5504B10000B5'
let typedArray = new Uint8Array(hex_str.match(/[\da-f]{2}/gi).map(function(h) {
return parseInt(h, 16)
}))
let buffer = typedArray.buffer
return buffer
},

操作步骤:

连接蓝牙成功,发送写命令

预期结果:

写入成功,有回调

实际结果:

无任何反应

bug描述:

苹果手机连接蓝牙后,写入函数无反应,无任何回调函数;安卓正常

2023-03-13 17:03 负责人:无 分享
已邀请:
1***@qq.com

1***@qq.com (作者)

已解决,硬件那边改,原来是WithoutResponse他们改成write就可以了

要回复问题请先登录注册