Skip to content

Commit 0335907

Browse files
committed
feat(discovery): improve scan metrics, node enrichment, and configuration restoration
- Implement distance tracking using `latLongToMeter` and a new `getMaxDistance` DAO query - Calculate Airtime Rate as a delta over time to align with telemetry specifications - Capture and restore the full `LoRaConfig` instead of just the modem preset after a scan - Persist local radio statistics (Tx/Rx counts, uptime, relay stats) in preset results - Backfill missing node names and positions from the local NodeDB during discovery - Refactor `DiscoveryScanEngine` to use injected `CoroutineDispatchers` and `ApplicationCoroutineScope` - Reduce BLE connection priority request delay in `BleRadioTransport` to 1 second - Improve test reliability by replacing fixed `Thread.sleep` calls with state-based polling and `delay`
1 parent 36fdf04 commit 0335907

4 files changed

Lines changed: 215 additions & 109 deletions

File tree

core/database/src/commonMain/kotlin/org/meshtastic/core/database/dao/DiscoveryDao.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ interface DiscoveryDao {
100100
)
101101
suspend fun getUniqueNodeCount(sessionId: Long): Int
102102

103+
@Query(
104+
"""
105+
SELECT MAX(distance_from_user) FROM discovered_node dn
106+
INNER JOIN discovery_preset_result dpr ON dn.preset_result_id = dpr.id
107+
WHERE dpr.session_id = :sessionId
108+
""",
109+
)
110+
suspend fun getMaxDistance(sessionId: Long): Double?
111+
103112
@Transaction
104113
@Query("SELECT * FROM discovery_session WHERE id = :sessionId")
105114
suspend fun getSessionWithResults(sessionId: Long): DiscoverySessionEntity?

core/network/src/commonMain/kotlin/org/meshtastic/core/network/radio/BleRadioTransport.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ class BleRadioTransport(
358358
Logger.d { "[$address] Requested high BLE connection priority" }
359359
// Wait for the connection parameter update to succeed before starting the heavy traffic
360360
// in onConnect(). Otherwise, the Android BLE stack may disconnect with GATT 147.
361-
delay(2.seconds)
361+
delay(1.seconds)
362362
}
363363

364364
this@BleRadioTransport.callback.onConnect()

0 commit comments

Comments
 (0)