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

@@ -201,6 +201,14 @@ object StatusColors {
}
}
@Suppress("MagicNumber")
object DiscoveryMapColors {
val DirectNode = Color(0xFF4CAF50)
val MeshNode = Color(0xFF2196F3)
val UserPosition = Color(0xFFFF9800)
val DirectLine = Color(0x804CAF50)
}
object MessageItemColors {
val Red = Color(0x4DFF0000)
}

View File

@@ -0,0 +1,46 @@
/*
* 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.ui.util
/** Neighbor type classification for discovery map markers. */
enum class DiscoveryNeighborType {
DIRECT,
MESH,
}
/**
* Platform-neutral representation of a discovered node for map rendering. Contains only the data needed to place and
* style a marker — no Room entities or platform types leak into the map provider API.
*/
data class DiscoveryMapNode(
val latitude: Double,
val longitude: Double,
val shortName: String?,
val longName: String?,
val neighborType: DiscoveryNeighborType,
val snr: Float = 0f,
val rssi: Int = 0,
val messageCount: Int = 0,
val sensorPacketCount: Int = 0,
) {
/**
* FR-011: Map icon classification. If environment packets > text messages, return true (sensor). Otherwise return
* false (social/chat).
*/
val isSensorNode: Boolean
get() = sensorPacketCount > messageCount
}

View File

@@ -0,0 +1,48 @@
/*
* 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.ui.util
import androidx.compose.runtime.Composable
import androidx.compose.runtime.compositionLocalOf
import androidx.compose.ui.Modifier
import org.meshtastic.core.ui.component.PlaceholderScreen
/**
* Provides an embeddable discovery map composable that renders discovered node markers and topology polylines for a
* Local Mesh Discovery scan session. Unlike [LocalMapViewProvider], this does **not** include node clustering,
* waypoints, location tracking, or any main-map features — it is designed to be embedded inside the discovery summary
* scaffold.
*
* Parameters:
* - `userLatitude` / `userLongitude`: The scanner's position at scan time (orange marker).
* - `nodes`: Platform-neutral [DiscoveryMapNode] list for marker placement and styling.
* - `modifier`: Compose modifier for the map.
*
* On Desktop/JVM targets where native maps are not yet available, it falls back to a [PlaceholderScreen].
*/
@Suppress("Wrapping", "CompositionLocalAllowlist")
val LocalDiscoveryMapProvider =
compositionLocalOf<
@Composable (
userLatitude: Double,
userLongitude: Double,
nodes: List<DiscoveryMapNode>,
modifier: Modifier,
) -> Unit,
> {
{ _, _, _, _ -> PlaceholderScreen("Discovery Map") }
}