mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
refactor(service): harden KMP service layer — database init, connection reliability, handler decomposition (#4992)
This commit is contained in:
parent
e111b61e4e
commit
6af3ad6f0c
62 changed files with 3808 additions and 735 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue