Skip to content

Make MAVLink WiFi mode also emit ESPNOW CRSF GPS frames - #176

Open
MUSTARDTIGERFPV wants to merge 2 commits into
masterfrom
mavlink-wifi-espnow-crsf
Open

Make MAVLink WiFi mode also emit ESPNOW CRSF GPS frames#176
MUSTARDTIGERFPV wants to merge 2 commits into
masterfrom
mavlink-wifi-espnow-crsf

Conversation

@MUSTARDTIGERFPV

Copy link
Copy Markdown
Member

tl;dr: Take MAVLink frames with GPS data in them and also send them as CRSF/MSP/ESPNOW broadcast frames.

This should make antenna trackers (like the MFD stuff) work when in MAVLink mode running WiFi.

@flyingbandit

Copy link
Copy Markdown

This is a really cool idea.

If I remember correctly, the Mfd mini crossbow needs gps and altitude.

If I can get this working for the esp in the Nomad tx, it means I can run one elrs backpack esp32 on the mini crossbow and have the added bonus that Wi-Fi should work at the same time for mavlink to a GCS.

@ExpressLRS ExpressLRS deleted a comment from sonarqubecloud Bot Oct 27, 2025
@pkendall64
pkendall64 force-pushed the mavlink-wifi-espnow-crsf branch 4 times, most recently from 351762e to dba70ff Compare June 29, 2026 06:35
… be enough to make antenna trackers work)

# Conflicts:
#	src/Tx_main.cpp
@pkendall64
pkendall64 force-pushed the mavlink-wifi-espnow-crsf branch from dba70ff to 26ace5e Compare June 29, 2026 06:44
ESP-NOW was only ever initialised in the non-WiFi branch of setup(), but
BACKPACK_TELEM_MODE_WIFI sets StartWiFiOnBoot, so in MAVLink WiFi mode
esp_now_send() ran against an uninitialised stack and returned
ESP_ERR_ESPNOW_NOT_INIT. The return value was discarded, so the whole path
looked healthy while nothing went out on air.

Split the UID resolution out of SetSoftMACAddress() and move ESP-NOW bring-up
into StartEspNow(), called from devWIFI once WiFi has settled -- it cannot run
in setup() because startWiFi() takes the radio down again. Peers are re-bound
if WiFi changes interface, since a station that fails to associate falls back
to AP mode. Bind peers to the live interface on ESP32 (sending on the down STA
interface in AP mode fails with ESP_ERR_ESPNOW_IF) and to the current channel
on ESP8266 rather than a hardcoded 1. Log esp_now_send() failures so this
cannot go silent again.

Also fix the GPS frame itself: frame_size counts the payload plus type and crc,
and crsf_sensor_gps_t was missing PACKED so sizeof() was 16 rather than the 15
bytes on the wire. Between them the crc byte was written over satcnt, which the
AAT uses to decide when home is set. Use CRSF_FRAME_SIZE() and send telemetry
with the 0xC8 sync byte that AatModule::onCrsfPacketIn expects.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants