meshtastic / python

The Python CLI and API for talking to Meshtastic devices
https://meshtastic.org
411 stars 172 forks source link

Bug: --request-telemetry with non-default types prints the wrong telemetry #690

Closed logikal closed 1 month ago

logikal commented 1 month ago

Using the new --request-telemetry from #687 with a specific kind of telemetry prints device metrics, even if unknown.

using git 3eabaf91d0f461945c82dc4659317dfd8afe28b8

❯ uv run meshtastic --version
2.5.3a0

❯ uv run meshtastic --no-nodes --no-time --request-telemetry power --dest '!dc3b65fb'
Connected to radio
Sending power_metrics telemetry request to !dc3b65fb on channelIndex:0 (this could take a while)
Telemetry received:
Battery level: 0.00%
Voltage: 0.00 V
Total channel utilization: 0.00%
Transmit air utilization: 0.00%
Uptime: 0 s

The radio has received the power metrics, though:

> uv run meshtastic --request-telemetry power --dest '!dc3b65fb' --seriallog --wait-to-disconnect 30
...
Connected to radio
Sending power_metrics telemetry request to !dc3b65fb on channelIndex:0 (this could take a while)
...
INFO  | ??:??:?? 143 [SerialConsole] getFromRadio=STATE_SEND_PACKETS
INFO  | ??:??:?? 143 Telling client we have new packets 11
DEBUG | ??:??:?? 144 [RadioIf] Starting low level send (id=0x06591322 fr=0xa9 to=0xfb, WantAck=0, HopLim=4 Ch=0x0 encrypted hopStart=4 priority=70)
DEBUG | ??:??:?? 144 [RadioIf] Packet transmitted : 518ms
DEBUG | ??:??:?? 144 [RadioIf] Completed sending (id=0x06591322 fr=0xa9 to=0xfb, WantAck=0, HopLim=4 Ch=0x0 encrypted hopStart=4 priority=70)
DEBUG | ??:??:?? 145 [Power] Battery: usbPower=1, isCharging=1, batMv=3702, batPct=48
DEBUG | ??:??:?? 145 [RadioIf] Lora RX (id=0xa45d30f3 fr=0xfb to=0xa9, WantAck=0, HopLim=2 Ch=0x0 encrypted rxSNR=6.25 rxRSSI=-32 hopStart=2)
DEBUG | ??:??:?? 145 [RadioIf] Packet received : 804ms
DEBUG | ??:??:?? 145 [Router] Add packet record (id=0xa45d30f3 fr=0xfb to=0xa9, WantAck=0, HopLim=2 Ch=0x0 encrypted rxSNR=6.25 rxRSSI=-32 hopStart=2)
DEBUG | ??:??:?? 145 [Router] Attempting PKI decryption
INFO  | ??:??:?? 145 [Router] Random nonce value: 1056483358
DEBUG | ??:??:?? 145 [Router] Attempting decrypt using nonce:  f3 30 5d a4 1e a8 f8 3e fb 65 3b dc 00
DEBUG | ??:??:?? 145 [Router] Attempting decrypt using shared_key starting with:  e2 2a 9a 9e db 1e a1 63
INFO  | ??:??:?? 145 [Router] PKI Decryption worked!
INFO  | ??:??:?? 145 [Router] Packet decrypted using PKI!
DEBUG | ??:??:?? 145 [Router] decoded message (id=0xa45d30f3 fr=0xfb to=0xa9, WantAck=0, HopLim=2 Ch=0x0 Portnum=67 PKI requestId=6591322 rxSNR=6.25 rxRSSI=-32 hopStart=2)
DEBUG | ??:??:?? 145 [Router] handleReceived(REMOTE) (id=0xa45d30f3 fr=0xfb to=0xa9, WantAck=0, HopLim=2 Ch=0x0 Portnum=67 PKI requestId=6591322 rxSNR=6.25 rxRSSI=-32 hopStart=2)
DEBUG | ??:??:?? 145 [Router] Module 'DeviceTelemetry' wantsPacket=1
INFO  | ??:??:?? 145 [Router] Received DeviceTelemetry from=0xdc3b65fb, id=0xa45d30f3, portnum=67, payloadlen=37
DEBUG | ??:??:?? 145 [Router] Module 'DeviceTelemetry' considered
DEBUG | ??:??:?? 145 [Router] Module 'EnvironmentTelemetry' wantsPacket=1
INFO  | ??:??:?? 145 [Router] Received EnvironmentTelemetry from=0xdc3b65fb, id=0xa45d30f3, portnum=67, payloadlen=37
DEBUG | ??:??:?? 145 [Router] Module 'EnvironmentTelemetry' considered
DEBUG | ??:??:?? 145 [Router] Module 'PowerTelemetry' wantsPacket=1
INFO  | ??:??:?? 145 [Router] Received PowerTelemetry from=0xdc3b65fb, id=0xa45d30f3, portnum=67, payloadlen=37
# !!! This is the expected response!
INFO  | ??:??:?? 145 [Router] (Received from KPB): ch1_voltage=16.1, ch1_current=6.0, ch2_voltage=2.7, ch2_current=17.2, ch3_voltage=0.0, ch3_current=0.0
DEBUG | ??:??:?? 145 [Router] Module 'PowerTelemetry' considered
DEBUG | ??:??:?? 145 [Router] Module 'routing' wantsPacket=1
INFO  | ??:??:?? 145 [Router] Received routing from=0xdc3b65fb, id=0xa45d30f3, portnum=67, payloadlen=37
DEBUG | ??:??:?? 145 [Router] Routing sniffing (id=0xa45d30f3 fr=0xfb to=0xa9, WantAck=0, HopLim=2 Ch=0x0 Portnum=67 PKI requestId=6591322 rxSNR=6.25 rxRSSI=-32 hopStart=2)
DEBUG | ??:??:?? 145 [Router] Received a ACK for 0x6591322, stopping retransmissions
DEBUG | ??:??:?? 145 [Router] Delivering rx packet (id=0xa45d30f3 fr=0xfb to=0xa9, WantAck=0, HopLim=2 Ch=0x0 Portnum=67 PKI requestId=6591322 rxSNR=6.25 rxRSSI=-32 hopStart=2)
DEBUG | ??:??:?? 145 [Router] Update DB node 0xdc3b65fb, rx_time=0
DEBUG | ??:??:?? 146 [Router] Received telemetry response. Skip sending our NodeInfo.
DEBUG | ??:??:?? 146 [Router] Forwarding to phone (id=0xa45d30f3 fr=0xfb to=0xa9, WantAck=0, HopLim=2 Ch=0x0 Portnum=67 PKI requestId=6591322 rxSNR=6.25 rxRSSI=-32 hopStart=2)
DEBUG | ??:??:?? 146 [Router] Module 'routing' considered
INFO  | ??:??:?? 146 Telling client we have new packets 12
INFO  | ??:??:?? 146 [SerialConsole] getFromRadio=STATE_SEND_PACKETS
DEBUG | ??:??:?? 146 [SerialConsole] phone downloaded packet (id=0xa45d30f3 fr=0xfb to=0xa9, WantAck=0, HopLim=2 Ch=0x0 Portnum=67 PKI requestId=6591322 rxSNR=6.25 rxRSSI=-32 hopStart=2)
#!!! This isn't the data we asked for 
Telemetry received:
Battery level: 0.00%
Voltage: 0.00 V
Total channel utilization: 0.00%
Transmit air utilization: 0.00%
Uptime: 0 s