Repository navigation
Send telemetry to known GCSes by unicast - #5
peterbarker wants to merge 1 commit into
Conversation
f5f168e to
4f124a8
Compare
Previous review (2026-11-15)Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting. Reviewed at head This works as described and builds cleanly at 4f124a8, with no blocking issues. A few small behaviour and diagnostic points are worth a look. Should fix
Minor (2)
Not fully reviewed: on-hardware WiFi loss and recovery, and real GCS or phone-app interoperability, were not tested. |
4f124a8 to
288eecf
Compare
Previous review (2026-11-15)Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting. Reviewed at head This builds at 288eecf and nothing blocks, but one ordering problem is worth fixing. Should fix
Minor (2)
Not fully reviewed: on-hardware WiFi loss and recovery, the claimed broadcast-loss improvement, and real GCS or phone-app interoperability were not tested. |
Every MAVLink message went to WiFi as a broadcast, which the radio sends once, unacknowledged and at the basic rate. 5-10% of them never reached the GCS, more at higher message rates, while unicast pings over the same link lost none. Note the address of each GCS that sends us MAVLink (up to four, forgotten after 5 seconds of silence) and send each of them its own unicast copy, which WiFi acknowledges and retries. HEARTBEAT is still broadcast, so a GCS that hasn't sent anything yet can find us, and is also sent to any GCS on a port other than 14550, which the broadcast doesn't reach. Everything is broadcast while no GCS is known. While a GCS is known, a program that only listens on 14550 and never sends gets only heartbeats. QGroundControl, MAVProxy and Mission Planner all send heartbeats, so they are unaffected. The mavunicast console command turns this off (0) or on (1) until the next boot, and "mavlink status" lists the GCSes. The FC packet count shown on the web page still counts each message once, however many GCSes it goes to.
288eecf to
5a6f9fb
Compare
|
Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting. Reviewed at head This looks good to merge at 5a6f9fb. It builds, and none of the three review passes found anything new. Not fully reviewed: on-hardware WiFi loss and recovery, the claimed broadcast-loss improvement, and real GCS, phone-app or passive-listener interoperability were not tested. |
Summary
Send telemetry to each GCS that has talked to us by unicast instead of broadcasting every MAVLink message. Broadcasts lost 3-6% of messages over WiFi; unicast loses next to none, so ATTITUDE now reaches the GCS at the rate the flight controller sends it.
Description
Every MAVLink message from the flight controller went to WiFi as its own UDP broadcast to 255.255.255.255:14550. The radio sends a broadcast once, unacknowledged and at the basic rate, so whatever doesn't arrive is gone. The flight controller was sending the full 4 Hz and the Sonix forwarded it promptly; the loss was all on the WiFi hop. Unicast pings over the same link lost nothing.
With this change:
recvfrom(), and the address of each GCS that sends us a MAVLink message is remembered (up to four, forgotten after 5 seconds of silence) as soon as its first message parses, so the reply to a camera command that is its first message reaches it; anything that doesn't parse as MAVLink is ignored, as is our own addressmavunicast 0|1console command turns unicast off and on until the next boot, andmavlink statuslists the GCSesA GCS that only listens and never sends to UDP 14550 gets only heartbeats while another GCS is connected. QGroundControl, MAVProxy and Mission Planner all send heartbeats, so they are unaffected.
Testing
On a SkyViper, measured at the GCS from the flight controller's sequence numbers, switching
mavunicaston the same firmware:No repeated or out-of-order messages in any of these. One combination did show them: a PC's built-in card (MediaTek mt7921e) with WiFi power save on got 16% of unicast messages out of order, up to 2.4 s late; with power save off it was clean. The phone did not show this with QGroundControl in the foreground.
A GCS on another port, with a passive listener on 14550 alongside it:
With one GCS already known, a new GCS whose first packet is
MAV_CMD_REQUEST_CAMERA_INFORMATIONto the camera got theCOMMAND_ACKandCAMERA_INFORMATIONin each of 4 tries.