refactor(service): harden KMP service layer — database init, connection reliability, handler decomposition (#4992)

This commit is contained in:
James Rich 2026-04-04 13:07:44 -05:00 committed by GitHub
parent e111b61e4e
commit 6af3ad6f0c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
62 changed files with 3808 additions and 735 deletions

View file

@ -56,11 +56,15 @@ interface RadioController {
suspend fun favoriteNode(nodeNum: Int)
/**
* Sends our shared contact information (identity and public key) to a remote node.
* Sends our shared contact information (identity and public key) to the firmware's NodeDB.
*
* This ensures the firmware has the correct public key for the destination node before a PKI-encrypted direct
* message is sent. The method suspends until the radio acknowledges the admin packet.
*
* @param nodeNum The destination node number.
* @return `true` if the radio accepted the contact, `false` on timeout or failure.
*/
suspend fun sendSharedContact(nodeNum: Int)
suspend fun sendSharedContact(nodeNum: Int): Boolean
/**
* Updates the local radio configuration.

View file

@ -16,6 +16,7 @@
*/
package org.meshtastic.core.model.service
import kotlinx.coroutines.CompletableDeferred
import org.meshtastic.core.model.Node
import org.meshtastic.proto.SharedContact
@ -32,5 +33,17 @@ sealed class ServiceAction {
data class ImportContact(val contact: SharedContact) : ServiceAction()
data class SendContact(val contact: SharedContact) : ServiceAction()
/**
* Sends a shared contact (identity + public key) to the firmware's NodeDB.
*
* The [result] deferred is completed with `true` when the radio acknowledges the admin packet, or `false` on
* timeout/failure. Callers that need to guarantee the contact is stored before sending a subsequent DM should
* `await()` this deferred.
*
* Not a data class: [result] is a [CompletableDeferred] with identity-based equality that would break data class
* equals/hashCode/copy semantics.
*/
class SendContact(val contact: SharedContact) : ServiceAction() {
val result: CompletableDeferred<Boolean> = CompletableDeferred()
}
}