feat: Add ability to request telemetry from a remote node (#4059)

This commit is contained in:
James Rich 2025-12-24 14:11:29 -06:00 committed by GitHub
parent 79fe6416b3
commit b996415ca9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 991 additions and 360 deletions

View file

@ -81,6 +81,7 @@ import org.meshtastic.core.model.MessageStatus
import org.meshtastic.core.model.MyNodeInfo
import org.meshtastic.core.model.NodeInfo
import org.meshtastic.core.model.Position
import org.meshtastic.core.model.TelemetryType
import org.meshtastic.core.model.fullRouteDiscovery
import org.meshtastic.core.model.getFullTracerouteResponse
import org.meshtastic.core.model.util.anonymize
@ -2926,5 +2927,35 @@ class MeshService : Service() {
},
)
}
override fun requestTelemetry(requestId: Int, destNum: Int, type: Int) = toRemoteExceptions {
if (destNum != myNodeNum) {
val telemetryRequest = telemetry {
when (type) {
TelemetryType.ENVIRONMENT.ordinal ->
environmentMetrics = TelemetryProtos.EnvironmentMetrics.getDefaultInstance()
TelemetryType.AIR_QUALITY.ordinal ->
airQualityMetrics = TelemetryProtos.AirQualityMetrics.getDefaultInstance()
TelemetryType.POWER.ordinal ->
powerMetrics = TelemetryProtos.PowerMetrics.getDefaultInstance()
TelemetryType.LOCAL_STATS.ordinal ->
localStats = TelemetryProtos.LocalStats.getDefaultInstance()
TelemetryType.DEVICE.ordinal ->
deviceMetrics = TelemetryProtos.DeviceMetrics.getDefaultInstance()
else -> deviceMetrics = TelemetryProtos.DeviceMetrics.getDefaultInstance()
}
}
packetHandler.sendToRadio(
newMeshPacketTo(destNum).buildMeshPacket(
id = requestId,
channel = nodeDBbyNodeNum[destNum]?.channel ?: 0,
) {
portnumValue = Portnums.PortNum.TELEMETRY_APP_VALUE
payload = telemetryRequest.toByteString()
wantResponse = true
},
)
}
}
}
}