diff --git a/core/data/src/commonMain/kotlin/org/meshtastic/core/data/radio/SdkRadioController.kt b/core/data/src/commonMain/kotlin/org/meshtastic/core/data/radio/SdkRadioController.kt index 2ce8c5302..219ccc098 100644 --- a/core/data/src/commonMain/kotlin/org/meshtastic/core/data/radio/SdkRadioController.kt +++ b/core/data/src/commonMain/kotlin/org/meshtastic/core/data/radio/SdkRadioController.kt @@ -318,7 +318,7 @@ class SdkRadioController( c.requestNodeInfo(NodeId(destNum)) } - override suspend fun requestTraceroute(requestId: Int, destNum: Int) { + override suspend fun requestTraceroute(destNum: Int) { val c = requireClient() c.routing.traceRoute(NodeId(destNum)) } @@ -338,7 +338,7 @@ class SdkRadioController( } } - override suspend fun requestNeighborInfo(requestId: Int, destNum: Int) { + override suspend fun requestNeighborInfo(destNum: Int) { val c = requireClient() c.routing.requestNeighborInfo(NodeId(destNum)) } @@ -381,7 +381,7 @@ class SdkRadioController( // ── Utility ───────────────────────────────────────────────────────────── - override fun getPacketId(): Int = packetIdCounter.getAndIncrement() + private fun getPacketId(): Int = packetIdCounter.getAndIncrement() override fun startProvideLocation() { // Location provision is managed at the app level; no-op here diff --git a/core/domain/src/commonTest/kotlin/org/meshtastic/core/domain/usecase/settings/RadioConfigUseCaseTest.kt b/core/domain/src/commonTest/kotlin/org/meshtastic/core/domain/usecase/settings/RadioConfigUseCaseTest.kt index d252d1f36..4b05f0595 100644 --- a/core/domain/src/commonTest/kotlin/org/meshtastic/core/domain/usecase/settings/RadioConfigUseCaseTest.kt +++ b/core/domain/src/commonTest/kotlin/org/meshtastic/core/domain/usecase/settings/RadioConfigUseCaseTest.kt @@ -41,8 +41,6 @@ class RadioConfigUseCaseTest { fun `setOwner calls radioController`() = runTest { val user = User(long_name = "New Name") useCase.setOwner(1234, user) - // Verify call implicitly or by adding tracking to FakeRadioController if needed. - // FakeRadioController already has getPacketId returning 1. } @Test diff --git a/core/model/src/commonMain/kotlin/org/meshtastic/core/model/DataRequester.kt b/core/model/src/commonMain/kotlin/org/meshtastic/core/model/DataRequester.kt index 76c693e20..69564bdaa 100644 --- a/core/model/src/commonMain/kotlin/org/meshtastic/core/model/DataRequester.kt +++ b/core/model/src/commonMain/kotlin/org/meshtastic/core/model/DataRequester.kt @@ -20,8 +20,8 @@ package org.meshtastic.core.model interface DataRequester { suspend fun requestPosition(destNum: Int, currentPosition: Position) suspend fun requestUserInfo(destNum: Int) - suspend fun requestTraceroute(requestId: Int, destNum: Int) + suspend fun requestTraceroute(destNum: Int) suspend fun requestTelemetry(destNum: Int, type: TelemetryType) - suspend fun requestNeighborInfo(requestId: Int, destNum: Int) + suspend fun requestNeighborInfo(destNum: Int) suspend fun requestStoreForwardHistory(since: Int? = null, serverNodeNum: Int? = null): Boolean } diff --git a/core/model/src/commonMain/kotlin/org/meshtastic/core/model/MessageSender.kt b/core/model/src/commonMain/kotlin/org/meshtastic/core/model/MessageSender.kt index 1eaf22ce6..b89d07916 100644 --- a/core/model/src/commonMain/kotlin/org/meshtastic/core/model/MessageSender.kt +++ b/core/model/src/commonMain/kotlin/org/meshtastic/core/model/MessageSender.kt @@ -19,5 +19,4 @@ package org.meshtastic.core.model /** Focused interface for sending messages over the mesh. */ interface MessageSender : ConnectionAware { suspend fun sendMessage(packet: DataPacket) - fun getPacketId(): Int } diff --git a/core/testing/src/commonMain/kotlin/org/meshtastic/core/testing/FakeRadioController.kt b/core/testing/src/commonMain/kotlin/org/meshtastic/core/testing/FakeRadioController.kt index 8579fd7ff..c2e689c5b 100644 --- a/core/testing/src/commonMain/kotlin/org/meshtastic/core/testing/FakeRadioController.kt +++ b/core/testing/src/commonMain/kotlin/org/meshtastic/core/testing/FakeRadioController.kt @@ -140,11 +140,11 @@ class FakeRadioController : override suspend fun requestUserInfo(destNum: Int) {} - override suspend fun requestTraceroute(requestId: Int, destNum: Int) {} + override suspend fun requestTraceroute(destNum: Int) {} override suspend fun requestTelemetry(destNum: Int, type: TelemetryType) {} - override suspend fun requestNeighborInfo(requestId: Int, destNum: Int) {} + override suspend fun requestNeighborInfo(destNum: Int) {} override suspend fun requestStoreForwardHistory(since: Int?, serverNodeNum: Int?): Boolean { lastStoreForwardHistoryRequest = since to serverNodeNum @@ -162,8 +162,6 @@ class FakeRadioController : block(edit) } - override fun getPacketId(): Int = 1 - override fun startProvideLocation() { startProvideLocationCalled = true } diff --git a/feature/map/src/commonMain/kotlin/org/meshtastic/feature/map/BaseMapViewModel.kt b/feature/map/src/commonMain/kotlin/org/meshtastic/feature/map/BaseMapViewModel.kt index 153c91a21..07b1c1cb3 100644 --- a/feature/map/src/commonMain/kotlin/org/meshtastic/feature/map/BaseMapViewModel.kt +++ b/feature/map/src/commonMain/kotlin/org/meshtastic/feature/map/BaseMapViewModel.kt @@ -162,7 +162,8 @@ open class BaseMapViewModel( safeLaunch(context = ioDispatcher, tag = "sendDataPacket") { radioController.sendMessage(p) } } - fun generatePacketId(): Int = radioController.getPacketId() + /** Generate a unique ID for a new waypoint. */ + fun generatePacketId(): Int = kotlin.random.Random.nextInt(1, Int.MAX_VALUE) data class MapFilterState( val onlyFavorites: Boolean, diff --git a/feature/node/src/commonMain/kotlin/org/meshtastic/feature/node/detail/CommonNodeRequestActions.kt b/feature/node/src/commonMain/kotlin/org/meshtastic/feature/node/detail/CommonNodeRequestActions.kt index 7a60ac29b..f32ee3b5d 100644 --- a/feature/node/src/commonMain/kotlin/org/meshtastic/feature/node/detail/CommonNodeRequestActions.kt +++ b/feature/node/src/commonMain/kotlin/org/meshtastic/feature/node/detail/CommonNodeRequestActions.kt @@ -27,7 +27,6 @@ import org.koin.core.annotation.Single import org.meshtastic.core.common.util.ioDispatcher import org.meshtastic.core.common.util.nowMillis import org.meshtastic.core.model.DataRequester -import org.meshtastic.core.model.MessageSender import org.meshtastic.core.model.Position import org.meshtastic.core.model.TelemetryType import org.meshtastic.core.resources.Res @@ -50,7 +49,6 @@ import org.meshtastic.core.ui.util.SnackbarManager class CommonNodeRequestActions constructor( private val dataRequester: DataRequester, - private val messageSender: MessageSender, private val snackbarManager: SnackbarManager, ) : NodeRequestActions { @@ -78,8 +76,7 @@ constructor( scope.launch(ioDispatcher) { runCatching { Logger.i { "Requesting NeighborInfo for '$destNum'" } - val packetId = messageSender.getPacketId() - dataRequester.requestNeighborInfo(packetId, destNum) + dataRequester.requestNeighborInfo(destNum) _lastRequestNeighborTimes.update { it + (destNum to nowMillis) } showFeedback(UiText.Resource(Res.string.requesting_from, Res.string.neighbor_info, longName)) }.onFailure { e -> Logger.e(e) { "requestNeighborInfo failed" } } @@ -123,8 +120,7 @@ constructor( scope.launch(ioDispatcher) { runCatching { Logger.i { "Requesting traceroute for '$destNum'" } - val packetId = messageSender.getPacketId() - dataRequester.requestTraceroute(packetId, destNum) + dataRequester.requestTraceroute(destNum) _lastTracerouteTime.value = nowMillis showFeedback(UiText.Resource(Res.string.requesting_from, Res.string.traceroute, longName)) }.onFailure { e -> Logger.e(e) { "requestTraceroute failed" } }