1***@qq.com
1***@qq.com
  • 发布:2024-12-11 14:19
  • 更新:2024-12-11 14:19
  • 阅读:54

【报Bug】uts调用鸿蒙低功耗蓝牙扫描APP闪退

分类:鸿蒙Next

产品分类: uniapp/App

PC开发环境操作系统: Windows

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

HBuilderX类型: Alpha

HBuilderX版本号: 4.36

手机系统: HarmonyOS NEXT

手机系统版本号: HarmonyOS NEXT Developer Beta1

手机厂商: 华为

手机机型: Mate 60

页面类型: vue

vue版本: vue3

打包方式: 离线

项目创建方式: HBuilderX

示例代码:

import {
OnBluetoothDeviceFoundOptions,
OnBluetoothDeviceFoundCallback
} from '../../interface.uts'

import {
DevicesOptions
} from '../type.uts'

import { ble } from '@kit.ConnectivityKit';
import { AsyncCallback, BusinessError } from '@kit.BasicServicesKit';

export function onBluetoothDeviceFound(options : OnBluetoothDeviceFoundCallback,name ?:string) {
let isSuccess = true;
console.log(JSON.stringify(options),name)
try {

    let devicesData : Array<DevicesOptions> = [];  
    ble.on("BLEDeviceFind", (data: Array<ble.ScanResult>)=>{  
        // console.info(JSON.stringify(data))  
        for(let i = 0; i < data.length; i++){  
            let obj : DevicesOptions = {  
                deviceId: data[i].deviceId,  
                RSSI: data[i].rssi,   
                name: data[i].deviceName  
            }  
            devicesData.push(obj)  
        }  
        let res : OnBluetoothDeviceFoundOptions = {  
            devices: devicesData  
        };  

        options?.(res);  
    });  

    let scanOptions: ble.ScanOptions = {  
        interval: 500,  
        dutyMode: ble.ScanDuty.SCAN_MODE_LOW_LATENCY,  
        matchMode: ble.MatchMode.MATCH_MODE_AGGRESSIVE  
    }  
    ble.startBLEScan(name ? [{name: name}] as ble.ScanFilter[] : null,scanOptions);  

} catch (err) {  
    isSuccess = false;  
    console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message);  

}  

}

操作步骤:

let scanOptions: ble.ScanOptions = {
interval: 500,
dutyMode: ble.ScanDuty.SCAN_MODE_LOW_LATENCY,
matchMode: ble.MatchMode.MATCH_MODE_AGGRESSIVE
}

预期结果:

正常扫描APP不会崩溃

实际结果:

正常扫描APP崩溃

bug描述:

鸿蒙低功耗蓝牙搜索,会导致APP崩溃退出
设置 ScanOptions 扫描的配置参数, 低功耗模式 3分钟左右,会退;均衡模式 1分10秒左右会退;低延迟模式 20 秒

2024-12-11 14:19 负责人:无 分享
已邀请:

要回复问题请先登录注册