s***@aliyun.com
s***@aliyun.com
  • 发布:2025-04-28 18:46
  • 更新:2025-06-16 15:44
  • 阅读:147

【报Bug】uniapp的蓝牙api扫描不出蓝牙5.0设备

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

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

HBuilderX类型: 正式

HBuilderX版本号: 4.57

手机系统: Android

手机系统版本号: Android 15

手机厂商: vivo

手机机型: PJA110

页面类型: nvue

vue版本: vue3

打包方式: 云端

项目创建方式: HBuilderX

示例代码:

const onBluetoothDeviceFound = (scanResult : UniNamespace.OnBluetoothDeviceFoundResult) => {
console.log(logTag + ' onBluetoothDeviceFound')
scanResult.devices.forEach((item : UniNamespace.BluetoothDeviceInfo) => {
const find = convert(item)
console.log(logTag + ' find=' + find.deviceName) //实测在app上扫描回调不包含蓝牙5.0的设备
})
}

uni.startBluetoothDevicesDiscovery({
services: scanFilter, allowDuplicatesKey: true, success: (_res) => {
//本机蓝牙适配器状态
console.log(logTag + ' startBluetoothDevicesDiscovery ok')
option.success()
//实测发现监听不会随着扫描结束而释放,所以需做好数据过滤和去重
if (isWeixin()) {
console.log(logTag + ' register onBluetoothDeviceFound event')
//微信上支持uni.offBluetoothDeviceFound(),所以需要重新注册
uni.onBluetoothDeviceFound(onBluetoothDeviceFound);
} else {
console.log(logTag + ' register onBluetoothDeviceFound event')
uni.onBluetoothDeviceFound(onBluetoothDeviceFound);
}
}, fail: (err) => {
console.log(logTag + ' startBluetoothDevicesDiscovery fail', err)
option.fail(onError(err))
}
})

操作步骤:

必现

预期结果:

希望解决

实际结果:

扫描回调中不包括蓝牙5.0设备

bug描述:

使用uniapp的蓝牙api,扫描ble设备,在安卓手机和ios手机上,不能扫描出蓝牙5.0的设备(微信小程序上可以扫出来),蓝牙4.0可以。

2025-04-28 18:46 负责人:无 分享
已邀请:
DCloud_UNI_OttoJi

DCloud_UNI_OttoJi - 日常回复 uni-app/x 问题,如果艾特我没看到,请主动私信

如果现有的 uni api 不满足要求,可以在插件市场看看蓝牙插件。或者你可以配合原生混编开发 uts 插件。

2***@qq.com

2***@qq.com

有没有人反馈过这个问题?因为用uni的应该也很多啊

要回复问题请先登录注册