/*开始搜索周边蓝牙设备*/
async startBluetoothDeviceDiscovery() {
await bluetooth.openBluetoothAdapter();
let isOpenBle = uni.getStorageSync('isOpenBle');
if(!isOpenBle) {
uni.showToast({
title: '请检查是否打开蓝牙功能',
icon: 'none',
'duration': 2000
});
return;
}
uni.showLoading({
title: '蓝牙搜索中'
})
this.isSearch = true
let self = this;
self.devicesList = []
setTimeout(() => {
uni.startBluetoothDevicesDiscovery({
success: res => {
uni.onBluetoothDeviceFound(devices => {
//不重复,就添加到devicesList中,
if (!self.devicesList.some(item => {
return item.deviceId === devices.devices[0].deviceId
})&&devices.devices[0].name !== '') {
self.devicesList.push(devices.devices[0])
uni.setStorageSync('devicesList',self.devicesList)
}
});
},
fail: res => {
uni.hideLoading();
self.showToast(`搜索设备失败` + JSON.stringify(err));
}
})
}, 200)
},

- 发布:2024-08-09 10:09
- 更新:2024-09-10 01:42
- 阅读:231
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: win10
HBuilderX类型: 正式
HBuilderX版本号: 4.24
手机系统: Android
手机系统版本号: Android 11
手机厂商: 小米
手机机型: 红米 note9
页面类型: vue
vue版本: vue2
打包方式: 云端
项目创建方式: HBuilderX
操作步骤:
预期结果:
搜索正常
搜索正常
实际结果:
执行后无任何反应
执行后无任何反应
bug描述:
本地自定义基座运行蓝牙搜索正常,但云打包后,蓝牙搜索异常,无反应
1 个回复
4***@qq.com
解决了吗?遇到了同样的问题