uni.notifyBLECharacteristicValueChange({
state: true,
deviceId: this.connectDeviceInfo.deviceId,
serviceId: item.serviceId,
characteristicId: item.uuid,
success: (res) => {
console.log('notify开启成功', res);
}
})
uni.onBLECharacteristicValueChange(res => {
console.log('正式通知开启成功》》》》》》》', bufferTohex(res.value));
})
// 发送蓝牙数据
uni.writeBLECharacteristicValue({
deviceId,
serviceId: this.bluetoothInfo?this.bluetoothInfo.serviceId:writeIds[index].serviceId,
characteristicId: this.bluetoothInfo?this.bluetoothInfo.writeId:writeIds[index].uuid,
value: buffer,
writeType: this.system == 'ios'?'write':'writeNoResponse',
success: (res) => {
console.log('写入成功--', data);
resolve(this.connectDeviceInfo)
},
fail: (err) => {
console.log(err);
console.log('写入失败------', index);
reject(err)
}
})

- 发布:2025-08-16 16:39
- 更新:2025-08-16 16:39
- 阅读:25
产品分类: uniapp/App
PC开发环境操作系统: Mac
PC开发环境操作系统版本号: macos 15.6
HBuilderX类型: 正式
HBuilderX版本号: 4.75
手机系统: Android
手机系统版本号: Android 15
手机厂商: 小米
手机机型: Readmi K70 Ultra
页面类型: vue
vue版本: vue2
打包方式: 云端
项目创建方式: HBuilderX
操作步骤:
预期结果:
可以收到蓝牙设备回复数据
uni.onBLECharacteristicValueChange(res => {
console.log('正式通知开启成功》》》》》》》', bufferTohex(res.value));
})
可以收到蓝牙设备回复数据
uni.onBLECharacteristicValueChange(res => {
console.log('正式通知开启成功》》》》》》》', bufferTohex(res.value));
})
实际结果:
没有收到蓝牙设备回复数据
没有收到蓝牙设备回复数据
bug描述:
蓝牙中的服务存在INDICATE, NOTIFY这两个,INDICATE操作不了,NOTIFY能开启成功,使用uni.notifyBLECharacteristicValueChange 提示服务开启成功,为蓝牙发送数据收不到蓝牙返回的通知消息。
如果服务中只有NOTIFY 为蓝牙发送数据可以收到蓝牙返回的通知消息
