-
Notifications
You must be signed in to change notification settings - Fork 48
WiFi Client Settings
The WiFi functionality in the Mav2PassThru converter supports both TCP/IP and UDP protocols, and two modes of connection.
Consider the situation where we have a remote terminal, for example QGroundControl running on a tablet.
Access Point (AP) Mode
Find these lined in the source code and change them like this:
// Choose one only of these GCS-side I/O channels
// How does Mavlink telemetry leave the converter?
// These are optional, and in addition to the S.Port telemetry output
//#define GCS_Mavlink_IO 9 // NONE (default)
//#define GCS_Mavlink_IO 0 // Serial Port
//#define GCS_Mavlink_IO 1 // BlueTooth Classic - ESP32 only
#define GCS_Mavlink_IO 2 // WiFi - ESP32 only
// Choose one - for ESP32 only
#define WiFi_Protocol 1 // TCP/IP
//#define WiFi_Protocol 2 // UDP - not supported in AP mode - use for WiFiBroadcast
// Choose one - AP means advertise as an access point (hotspot). STA means connect to a known host
#define WiFi_Mode 1 //AP - not allowed for UDP protocol
//#define WiFi_Mode 2 // STA
In this mode the pilot at the remote terminal scans for the access point (hotspot) name (SSID) “Mav2Passthru”, selects it and enters the password to achieve connection. The password should be changed in the source code before compiling. In the Arduino IDE use Edit/Find IDE “ssid” to locate the lines below, and change the password.
const char *APssid = "Mav2Passthru"; // The AP SSID that we advertise ====>
const char *APpw = "password"; // Change me!
Once the table or laptop is connected, launch QGroundControl, touch the Q in the top left hand corner, and touch Comm Links. My page looks like this:
Click on Add at the bottom of the page:
and add the information for a TCP/IP access point link. The default IP address of the ESP32 converter is 192.168.4.1, and the default port is 5760.
Click OK, and then Connect. You will immediately see the parameter bar runs out to the right as the parameters are downloaded from the flight controller to QGC:
Station (Sta) Mode
Find and change these #define options in the code:
// Choose one - AP means advertise as an access point (hotspot). STA means connect to a known host
//#define WiFi_Mode 1 //AP - not allowed for UDP protocol
#define WiFi_Mode 2 // STA
Also find and change the SSID and password of the access point to which you wish to connect.
#if (WiFi_Mode == 2) // STA
const char *STAssid = "TargetAPName"; // Target AP to connect to <====
const char *STApw = "targetPw"; // Change me!
Now compile and flash;
In this mode, the ESP32 converter board is the terminal, and it will be able to connect to any hotspot (AP), for example, to your home router or access point on a LAN. The router/AP will proved the IP address for the ESP32, and display it for the pilot to see. Then if your tablet connects to the same LAN, it will also be granted and IP in the same subnet range, and the two will be able to communicate. Let’s assume that the AP provided IP address 192.168.1.197 to the ESP32 converter board.
Open QGroundControl, touch the Q on the top left-hand side, and touch Comm Links, and ADD. Enter the fields as seen below:
Click Ok, and Connect. Voila!
Station Mode – UDP Protocol
The ESP32 converter board can also accept WiFi Mavlink telemetry input for decoding. For example, you may have an EZ-WiFibroadcast or similar HD video/telemetry link from the aircraft, with a Raspberry Pi board processing telemetry and video on the ground. That ground RPi can have its WiFi adapter activated and present as an access point with the SSID “EZ-WifiBroadcast”. EZ-WiFibroadcast employs the UDP protocol, as the “fire and forget” nature of UDP better suits the application. To setup the ESP32 board for UDP, remain in STA mode, and find and make the following changes for the UDP protocol:
// Choose one - for ESP32 only
#define WiFi_Protocol 1 // TCP/IP
//#define WiFi_Protocol 2 // UDP - not supported in AP mode - use for WiFiBroadcast
const char *STAssid = "EZ-WifiBroadcast"; // Target AP to connect to <====
const char *STApw = "wifibroadcast";