mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
Refactor command handling, enhance tests, and improve discovery logic (#4878)
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
parent
d136b162a4
commit
c38bfc64de
76 changed files with 2220 additions and 1277 deletions
|
|
@ -23,7 +23,6 @@ import org.meshtastic.core.model.Position
|
|||
import org.meshtastic.proto.AdminMessage
|
||||
import org.meshtastic.proto.ChannelSet
|
||||
import org.meshtastic.proto.LocalConfig
|
||||
import org.meshtastic.proto.NeighborInfo
|
||||
|
||||
/** Interface for sending commands and packets to the mesh network. */
|
||||
@Suppress("TooManyFunctions")
|
||||
|
|
@ -43,15 +42,6 @@ interface CommandSender {
|
|||
/** Generates a new unique packet ID. */
|
||||
fun generatePacketId(): Int
|
||||
|
||||
/** The latest neighbor info received from the connected radio. */
|
||||
var lastNeighborInfo: NeighborInfo?
|
||||
|
||||
/** Start times of traceroute requests for duration calculation. */
|
||||
val tracerouteStartTimes: MutableMap<Int, Long>
|
||||
|
||||
/** Start times of neighbor info requests for duration calculation. */
|
||||
val neighborInfoStartTimes: MutableMap<Int, Long>
|
||||
|
||||
/** Sets the session passkey for admin messages. */
|
||||
fun setSessionPasskey(key: ByteString)
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright (c) 2025-2026 Meshtastic LLC
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.meshtastic.core.repository
|
||||
|
||||
/**
|
||||
* Shared constants for the two-stage mesh handshake protocol.
|
||||
*
|
||||
* Stage 1 (`CONFIG_NONCE`): requests device config, module config, and channels. Stage 2 (`NODE_INFO_NONCE`): requests
|
||||
* the full node database.
|
||||
*
|
||||
* Both [MeshConfigFlowManager] (consumer) and [MeshConnectionManager] (sender) reference these.
|
||||
*/
|
||||
object HandshakeConstants {
|
||||
/** Nonce sent in `want_config_id` to request config-only (Stage 1). */
|
||||
const val CONFIG_NONCE = 69420
|
||||
|
||||
/** Nonce sent in `want_config_id` to request node info only (Stage 2). */
|
||||
const val NODE_INFO_NONCE = 69421
|
||||
}
|
||||
|
|
@ -18,12 +18,19 @@ package org.meshtastic.core.repository
|
|||
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import org.meshtastic.proto.MeshPacket
|
||||
import org.meshtastic.proto.NeighborInfo
|
||||
|
||||
/** Interface for handling neighbor info responses from the mesh. */
|
||||
interface NeighborInfoHandler {
|
||||
/** Starts the neighbor info handler with the given coroutine scope. */
|
||||
fun start(scope: CoroutineScope)
|
||||
|
||||
/** Records the start time for a neighbor info request. */
|
||||
fun recordStartTime(requestId: Int)
|
||||
|
||||
/** The latest neighbor info received from the connected radio. */
|
||||
var lastNeighborInfo: NeighborInfo?
|
||||
|
||||
/**
|
||||
* Processes a neighbor info packet.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright (c) 2025-2026 Meshtastic LLC
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.meshtastic.core.repository
|
||||
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import org.meshtastic.core.model.DataPacket
|
||||
import org.meshtastic.proto.MeshPacket
|
||||
|
||||
/** Interface for handling Store & Forward (legacy) and SF++ packets. */
|
||||
interface StoreForwardPacketHandler {
|
||||
/** Starts the handler with the given coroutine scope. */
|
||||
fun start(scope: CoroutineScope)
|
||||
|
||||
/**
|
||||
* Handles a legacy Store & Forward packet.
|
||||
*
|
||||
* @param packet The received mesh packet.
|
||||
* @param dataPacket The decoded data packet.
|
||||
* @param myNodeNum The local node number.
|
||||
*/
|
||||
fun handleStoreAndForward(packet: MeshPacket, dataPacket: DataPacket, myNodeNum: Int)
|
||||
|
||||
/**
|
||||
* Handles a Store Forward++ packet.
|
||||
*
|
||||
* @param packet The received mesh packet.
|
||||
*/
|
||||
fun handleStoreForwardPlusPlus(packet: MeshPacket)
|
||||
}
|
||||
|
|
@ -25,6 +25,9 @@ interface TracerouteHandler {
|
|||
/** Starts the traceroute handler with the given coroutine scope. */
|
||||
fun start(scope: CoroutineScope)
|
||||
|
||||
/** Records the start time for a traceroute request. */
|
||||
fun recordStartTime(requestId: Int)
|
||||
|
||||
/**
|
||||
* Processes a traceroute packet.
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue