diff --git a/server/core/src/main/java/dev/slimevr/firmware/reconnect.kt b/server/core/src/main/java/dev/slimevr/firmware/reconnect.kt index 6695d1ab1..3245ad313 100644 --- a/server/core/src/main/java/dev/slimevr/firmware/reconnect.kt +++ b/server/core/src/main/java/dev/slimevr/firmware/reconnect.kt @@ -9,6 +9,7 @@ import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.map import kotlinx.coroutines.withTimeoutOrNull +import solarxr_protocol.datatypes.DeviceOrigin import solarxr_protocol.datatypes.TrackerStatus fun isOnlineStatus(status: TrackerStatus): Boolean = when (status) { @@ -27,7 +28,7 @@ private fun deviceStatusFlow( ) = server.context.state.flatMapLatest { state -> val device = state.devices.values.find { device -> val deviceState = device.context.state.value - matches(deviceState.id, deviceState.macAddress) + deviceState.origin == DeviceOrigin.UDP && matches(deviceState.id, deviceState.macAddress) } device?.context?.state?.map { it.status } ?: flowOf(TrackerStatus.DISCONNECTED) } @@ -37,25 +38,22 @@ private fun deviceAndConnectionStateFlow( server: VRServer, mac: String, ) = server.context.state.flatMapLatest { serverState -> - val device = serverState.devices.values.filter { d -> - d.context.state.value.macAddress?.uppercase() == mac - }.lastOrNull() - if (device == null) { - flowOf(Pair(TrackerStatus.DISCONNECTED, null)) - } else { - device.appContext.udpServer.context.state.flatMapLatest { udpState -> - val conn = udpState.connections.values.find { c -> - c.context.state.value.deviceId == device.context.state.value.id - } - if (conn == null) { - device.context.state.map { dState -> Pair(dState.status, null) } - } else { - combine(device.context.state, conn.context.state) { dState, cState -> - Pair(dState.status, cState) - } + val device = serverState.devices.values.lastOrNull { d -> + val dState = d.context.state.value + dState.origin == DeviceOrigin.UDP && dState.macAddress?.uppercase() == mac + } + device?.appContext?.udpServer?.context?.state?.flatMapLatest { udpState -> + val conn = udpState.connections.values.find { c -> + c.context.state.value.deviceId == device.context.state.value.id + } + if (conn == null) { + device.context.state.map { dState -> Pair(dState.status, null) } + } else { + combine(device.context.state, conn.context.state) { dState, cState -> + Pair(dState.status, cState) } } - } + } ?: flowOf(Pair(TrackerStatus.DISCONNECTED, null)) } suspend fun waitForConnected( diff --git a/server/core/src/main/java/dev/slimevr/solarxr/provisioning.kt b/server/core/src/main/java/dev/slimevr/solarxr/provisioning.kt index 2a9e331e5..c8374fd52 100644 --- a/server/core/src/main/java/dev/slimevr/solarxr/provisioning.kt +++ b/server/core/src/main/java/dev/slimevr/solarxr/provisioning.kt @@ -10,6 +10,7 @@ import kotlinx.coroutines.flow.drop import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.onEach +import solarxr_protocol.datatypes.DeviceOrigin import solarxr_protocol.rpc.StartWifiProvisioningRequest import solarxr_protocol.rpc.StartWifiScanRequest import solarxr_protocol.rpc.StopWifiProvisioningRequest @@ -77,6 +78,7 @@ private fun buildUnifiedTrackerList( val onlineMacs = devices.values.mapNotNull { device -> val state = device.context.state.value val mac = state.macAddress?.uppercase() ?: return@mapNotNull null + if (state.origin != DeviceOrigin.UDP) return@mapNotNull null if (!isOnlineStatus(state.status)) return@mapNotNull null mac }.toSet()