mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
feat: Add ability to request telemetry from a remote node (#4059)
This commit is contained in:
parent
79fe6416b3
commit
b996415ca9
16 changed files with 991 additions and 360 deletions
|
|
@ -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
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue