feat(discovery): mesh network discovery (#5275)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
James Rich
2026-06-05 04:51:37 -05:00
committed by James Rich
parent 285206a78d
commit a23e073003
90 changed files with 10848 additions and 55 deletions

View File

@@ -0,0 +1,26 @@
/*
* Copyright (c) 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.data.manager
import org.koin.core.annotation.Single
import org.meshtastic.core.repository.DiscoveryPacketCollector
import org.meshtastic.core.repository.DiscoveryPacketCollectorRegistry
@Single
class DiscoveryPacketCollectorRegistryImpl : DiscoveryPacketCollectorRegistry {
override var collector: DiscoveryPacketCollector? = null
}

View File

@@ -42,6 +42,7 @@ import org.meshtastic.core.model.util.decodeOrNull
import org.meshtastic.core.model.util.toOneLiner
import org.meshtastic.core.repository.AdminPacketHandler
import org.meshtastic.core.repository.DataPair
import org.meshtastic.core.repository.DiscoveryPacketCollectorRegistry
import org.meshtastic.core.repository.MeshDataHandler
import org.meshtastic.core.repository.MeshNotificationManager
import org.meshtastic.core.repository.MessageFilter
@@ -99,6 +100,7 @@ class MeshDataHandlerImpl(
private val storeForwardHandler: StoreForwardPacketHandler,
private val telemetryHandler: TelemetryPacketHandler,
private val adminPacketHandler: AdminPacketHandler,
private val collectorRegistry: DiscoveryPacketCollectorRegistry,
@Named("ServiceScope") private val scope: CoroutineScope,
) : MeshDataHandler {
@@ -118,6 +120,13 @@ class MeshDataHandlerImpl(
handleDataPacket(packet, dataPacket, myNodeNum, fromUs, logUuid, logInsertJob)
analytics.track("num_data_receive", DataPair("num_data_receive", 1))
// Forward to discovery scan collector if active
collectorRegistry.collector?.let { collector ->
if (collector.isActive) {
scope.handledLaunch { collector.onPacketReceived(packet, dataPacket) }
}
}
}
private fun handleDataPacket(

View File

@@ -106,6 +106,7 @@ class MeshDataHandlerTest {
storeForwardHandler = storeForwardHandler,
telemetryHandler = telemetryHandler,
adminPacketHandler = adminPacketHandler,
collectorRegistry = mock(MockMode.autofill),
scope = testScope,
)