915 MHz MAVLink link
How the mLRS radio firmware is put together, drawn for the Matek mR900-30 pair on the bench. Both ends run the same six layers. Pick a stop, or use the arrow keys, and its part of the diagram lights up.
Both radios run the same stack. The centre column marks each layer as identical (=), nearly identical (≈) or different (≠) between the two ends. Figures are for the 915 MHz FCC band in 31 Hz mode.
Walkthrough 1 of 7 Back Next The trip of one byte A correction byte leaves the site node as MAVLink and enters the dock radio on a serial port. It goes down the stack, crosses the air inside a 91-byte frame, goes up the stack in the aircraft radio, and leaves as MAVLink to the flight controller. Telemetry makes the same trip the other way. Board file One small file for each board says which pin does which job. One table says which power levels exist: for the mR900-30 they are 17, 20, 24, 27 and 30 dBm. This is the only layer that differs between a Matek board and a XIAO board, so the XIAO port is one new file here. mLRS/Common/hal/ · about 60 boards, STM32 and ESP Radio driver Talks to the Semtech radio chip over SPI: set the frequency, send a frame, read a frame. The SX1262 on our boards is one of five chip families it supports. The same code runs at both ends. mLRS/Common/sx-drivers/ · modules/sx12xx-lib Link core The dock end sends a 91-byte frame and the aircraft end answers with one. In 31 Hz mode an exchange takes 32 ms, then both ends hop to the next of 25 channels. The receiver has three states: listen, sync and connected. Binding, retransmission, antenna diversity and link quality counting are also here. fhss.h · frames.h · bind.h · arq.h · diversity.h · lq_counter.h Settings Every parameter is one row in one list: band, mode, power, serial baud rate, bind phrase. Each end keeps its values in flash. When the link is up, the transmitter end can change the receiver's settings over the air, so the aircraft radio needs no cable for a change. setup.h · setup_list.h · setup_types.h Protocols The translators between the link and the devices outside it. MAVLink runs at both ends. Stick commands can come in from a handset as CRSF and leave the receiver as SBUS or CRSF; TerraHawk does not use that path, because ELRS is its RC link. The definitions are shared and each end has its own interface file, so this row is marked ≈. Common/protocols/ · Common/mavlink/ · modules/fastmavlink The two programs Each end is one main loop that the radio's interrupt drives. The receiver program is the smaller one. The transmitter program adds a command line on USB, a display, and Bluetooth and WiFi bridges. On the Matek board the two programs also use the pads differently: MAVLink is on Tx1/Rx1 as a receiver, and on LT1/LR1 or USB as a transmitter. CommonRx/mlrs-rx.cpp (972 lines) · CommonTx/mlrs-tx.cpp (1,243 lines)