From 52aaa4d926711119660624471f54806950dba354 Mon Sep 17 00:00:00 2001 From: James Rich Date: Wed, 6 May 2026 13:52:20 -0500 Subject: [PATCH] feat: handle AdminResult.RateLimited from SDK, update MeshTopology API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add AdminException.RateLimited to domain exception hierarchy - Handle AdminResult.RateLimited in SdkRadioController.unwrap() - Update MeshTopologyService for SDK's new suspend API: topology.nodes → topology.nodes(), topology.edgeCount → edgeCount() Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../org/meshtastic/core/data/radio/MeshTopologyService.kt | 4 ++-- .../org/meshtastic/core/data/radio/SdkRadioController.kt | 1 + .../kotlin/org/meshtastic/core/model/AdminException.kt | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/core/data/src/commonMain/kotlin/org/meshtastic/core/data/radio/MeshTopologyService.kt b/core/data/src/commonMain/kotlin/org/meshtastic/core/data/radio/MeshTopologyService.kt index 6554a57d6..a9d72dcda 100644 --- a/core/data/src/commonMain/kotlin/org/meshtastic/core/data/radio/MeshTopologyService.kt +++ b/core/data/src/commonMain/kotlin/org/meshtastic/core/data/radio/MeshTopologyService.kt @@ -56,7 +56,7 @@ class MeshTopologyService { mutex.withLock { topology.addNeighborInfo(info) _edges.value = topology.allEdges() - _nodeCount.value = topology.nodes.size + _nodeCount.value = topology.nodes().size } Logger.d { "[Topology] Ingested neighbors from ${info.nodeId}: ${info.neighbors.size} edges" } } @@ -66,7 +66,7 @@ class MeshTopologyService { mutex.withLock { topology.removeNode(nodeId) _edges.value = topology.allEdges() - _nodeCount.value = topology.nodes.size + _nodeCount.value = topology.nodes().size } } 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 219ccc098..fb32e0af7 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 @@ -405,6 +405,7 @@ class SdkRadioController( is AdminResult.Unauthorized -> throw AdminException.Unauthorized() is AdminResult.NodeUnreachable -> throw AdminException.NodeUnreachable() is AdminResult.SessionKeyExpired -> throw AdminException.SessionKeyExpired() + is AdminResult.RateLimited -> throw AdminException.RateLimited() is AdminResult.Failed -> throw AdminException.RoutingError(routingError.name) } } diff --git a/core/model/src/commonMain/kotlin/org/meshtastic/core/model/AdminException.kt b/core/model/src/commonMain/kotlin/org/meshtastic/core/model/AdminException.kt index 431989480..0d188d84f 100644 --- a/core/model/src/commonMain/kotlin/org/meshtastic/core/model/AdminException.kt +++ b/core/model/src/commonMain/kotlin/org/meshtastic/core/model/AdminException.kt @@ -39,4 +39,7 @@ sealed class AdminException(message: String) : Exception(message) { /** Device reported a routing error not covered by the other subtypes. */ class RoutingError(val errorName: String) : AdminException("Routing error: $errorName") + + /** Device rate-limited the request; back off before retrying. */ + class RateLimited : AdminException("Rate limit exceeded") }