Android UWB控制器未及时接收RangingResultPeerDisconnected问题咨询
UWB重连逻辑异常问题:断开事件延迟触发与无限循环
问题描述
我基于UWB示例应用开发,给控制器和被控端(均为手机设备)添加UWB断开重连逻辑时遇到问题:UWB断开后,控制器无法及时收到RangingResult.RangingResultPeerDisconnected事件;多次尝试失败后才突然收到该事件,最终导致两端陷入重连-断开的无限循环。
设备与依赖信息
- 控制器:三星Galaxy S23 Ultra,Android 13
- 被控端:三星Galaxy S22 Ultra,Android 14
- 依赖库:
androidx.core.uwb:uwb:1.0.0-alpha05
相关代码片段
override fun prepareSession() = channelFlow { val job = coroutineScope.launch { //nearby connection starts connector.start().collect { event -> when (event) { //nearby connection succeed and found nearby device is UwbOobEvent.UwbEndpointFound -> { //make uwb session and ready for uwb ranging val rangingEvents = processEndpointFound(event) activeJobs[event.endpoint] = launch { // rangingEvents.collectLatest { sendResult(it) } } } ... ... } private suspend fun ProducerScope<EndpointEvents>.sendResult(result: RangingResult) { val endpoint = if (localAddresses.contains(result.device.address)) localEndpoint else remoteDeviceMap[result.device.address] ?: return when (result) { is RangingResult.RangingResultPosition -> trySend(EndpointEvents.PositionUpdated(endpoint, result.position)) // UWB断开时应触发该事件 is RangingResult.RangingResultPeerDisconnected -> { Log.e("##UwbSessionScopeImpl", "sendResult: peerDisconnected") connector.reconnectUwb() trySend(EndpointEvents.UwbDisconnected(endpoint)) } } }
疑问
请问该控制器的表现是否正常?
内容的提问来源于stack exchange,提问作者fugage
相关产品推荐
相关产品推荐

