# mavlink-router

## Introduction

To be able to have several end nodes communicating via mavlink simultaneously we need to set up [mavlink-router](https://github.com/intel/mavlink-router) on the NavQ.\
\
The end nodes can be&#x20;

* A process for onboard control running on NavQ.
* A QGroundControl (QGC) computer the NavQ connects to via a data link such as WiFi.
* Other mavlink enabled peripherals on the vehicle.
* Another program running on the same remote PC as QGC

## Prerequisites

### Set up TELEM2 on the FMU

Connect to your FMU over USB and open QGroundControl. Navigate to Settings -> Parameters -> MAVLink and set these parameters:

![](/files/-MCTMSP9peqSSkPh4LZV)

Also, you'll need to make sure that the settings in Settings -> Parameters -> Serial look like this:

![](/files/-MCTMgOwHPHxcDfqRhd5)

## Installation and compiling mavlink router

To install and compile `mavlink router` follow the steps below (internet access required on your NavQ)

1\) Connect to NavQ console via ssh / serial

2\) Type the following commands

```
~$ mkdir src
~$ cd src
~/src$ git clone https://github.com/intel/mavlink-router.git
~/src$ cd mavlink-router 
~/src/mavlink-router$ git submodule update --init --recursive
~/src/mavlink-router$ ./autogen.sh && ./configure CFLAGS='-g -O2' --sysconfdir=/etc --localstatedir=/var --libdir=/usr/lib --prefix=/usr
~/src/mavlink-router$ make
~/src/mavlink-router$ sudo make install
```

## Mavlink-router configuration

Configuration of `mavlink router` is done via a single configuration file  *`/etc/mavlink-router/main.conf`*\
This file needs to be created from scratch. An example configuration file is available in the mavlink-router sources - <https://github.com/intel/mavlink-router/blob/master/examples/config.sample>&#x20;

{% hint style="danger" %}
As of today the mavlink-router *make install* does not create the /etc/mavlink-router directory and main.conf file.\
Therefore please use the following commands to create the directory and file initially.

\~$ sudo mkdir /etc/mavlink-router

\~$ sudo touch /etc/mavlink-router/main.conf
{% endhint %}

### Setup the config file with minimal configuration&#x20;

```
~$ sudo nano /etc/mavlink-router/main.conf
```

```
#Mavlink router configuration navq
#
[General]
TcpServerPort=5760
ReportStats=false
MavlinkDialect=auto

[UartEndpoint FMUuart]
Device=/dev/ttymxc2
Baud=921600

[UdpEndpoint FMUeth]
Mode = Eavesdropping
Address = 0.0.0.0
Port = 14551

[UdpEndpoint QGConMobile]
Mode = Normal
Address = 192.168.43.1
Port = 14550
```

{% hint style="info" %}
The configuration above assumes that the NavQ gets mavlink data from FMU either via UART3 (/dev/ttymxc2) or UDP.\
If you use UART please set on the FMU the corresponding serial port to 921600Bd.\
For this the SER\_TELx\_BAUD (x = number of telemetry port) parameter needs to be adjusted to 921600 8N.\
If you use lower speed QGroundControl might fail to load parameters.
{% endhint %}

\
You can leave out the unused connection.\
Via the `UdpEndpoint QGConMobile` section the mavlink stream is forwarded to a QGC computer/mobile device assuming it has 192.168.43.1 and NavQ is connected to this network via e.g. WiFi.&#x20;

### Enabling auto-start of mavlink-router

Enable the auto-start of `mavlink-router` via `systemd` and start it&#x20;

```
~$ sudo systemctl enable mavlink-router
~$ sudo systemctl start mavlink-router
```

### Checking status of mavlink-router

You can check the status of mavlink router using the command&#x20;

```
~$ sudo systemctl status mavlink-router
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://nxp.gitbook.io/8mmnavq/user-guide/mavlink-specific-details/installing-mavlink-router.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
