Repository navigation
mavlink_wifi: make UART auto-baud work again - #7
Conversation
mavlink_check_baudrate() compared get_sys_seconds_boot(), in seconds, with last_heartbeat_ms, in milliseconds, ever since last_heartbeat became last_heartbeat_ms in 2017. So auto-baud never ran: the Sonix stayed at 625000, which skyviper-v2450's SERIAL1_BAUD matches, and couldn't find a flight controller set to 115200. Use milliseconds throughout. Rather than switching rate after any 3 seconds without a heartbeat, as before 2017, wait 20 seconds from boot (the flight controller takes about 15 to send its first) before trying each rate in turn for 4 seconds, and once a heartbeat has been heard, only search again after 30 seconds of silence. A flight controller restarting, or a busy link, no longer moves us off the right rate. Each change is shown on the console. Entering MAVLink mode sets 625000 directly; reset the rate index with it, so the next search starts from there.
|
Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting. Reviewed at head No problems found: this one-commit fix makes UART auto-baud in mavlink_wifi.c work again by using milliseconds throughout. The new search timing at mavlink_wifi.c:1886 and the index reset on entering MAVLink mode at mavlink_wifi.c:1839 both checked out. Host simulations of the extracted function matched the commit message: a 20 s hold after boot, 4 s at each rate, a new search only after 30 s without a heartbeat, and no wrap problems. The firmware built at this head with no new warnings. It has not been run on SkyViper hardware. |
Summary
Make the Sonix find the flight controller's baud rate again. Since 2017, auto-baud has never run because of a seconds/milliseconds mix-up, so the Sonix stayed at 625000 and couldn't talk to a flight controller set to 115200.
Description
mavlink_check_baudrate()comparedget_sys_seconds_boot(), in seconds, withlast_heartbeat_ms, in milliseconds, ever sincelast_heartbeatbecamelast_heartbeat_msin 84046b07 (June 2017). The check never passed. This went unnoticed because skyviper-v2450'sSERIAL1_BAUDis 625000, the first rate the Sonix tries.With this change:
Testing
On a SkyViper with
SERIAL1_BAUD625000, built together with #5 and #6:Not exercised on the bench: the search itself, i.e. a flight controller at 115200, or more than 30 s of silence.