From f30a182b202decabca76523cfdb405ba8f8c5ca0 Mon Sep 17 00:00:00 2001 From: Oleg Kalachev Date: Sat, 8 Aug 2026 01:04:20 +0300 Subject: [PATCH] Add parameter WIFI_BROADCAST for always broadcasting mode May be used in some cases, like multiple gcs --- flix/parameters.ino | 3 ++- flix/wifi.ino | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/flix/parameters.ino b/flix/parameters.ino index 6cf9070..baeed52 100644 --- a/flix/parameters.ino +++ b/flix/parameters.ino @@ -9,7 +9,7 @@ extern int channelZero[16], channelMax[16]; extern int rollChannel, pitchChannel, throttleChannel, yawChannel, armedChannel, modeChannel; extern int rcRxPin, voltagePin; -extern int wifiMode, wifiLongRange, udpLocalPort, udpRemotePort, espnowChannel; +extern int wifiMode, wifiLongRange, wifiBroadcast, udpLocalPort, udpRemotePort, espnowChannel; extern float rcLossTimeout, descendTime, disarmTilt; extern float voltageScale; extern LowPassFilter voltageFilter; @@ -121,6 +121,7 @@ Parameter parameters[] = { {"WIFI_PORT_LOC", &udpLocalPort}, {"WIFI_PORT_REM", &udpRemotePort}, {"WIFI_LONG_RANGE", &wifiLongRange}, + {"WIFI_BROADCAST", &wifiBroadcast}, // espnow {"ESPNOW_CHANNEL", &espnowChannel}, // mavlink diff --git a/flix/wifi.ino b/flix/wifi.ino index 253a1a0..778e422 100644 --- a/flix/wifi.ino +++ b/flix/wifi.ino @@ -17,6 +17,7 @@ const int W_DISABLED = 0, W_AP = 1, W_STA = 2, W_ESPNOW = 3; int wifiMode = W_AP; int wifiLongRange = 0; +int wifiBroadcast = 0; // 0 - broadcast until connected, 1 - always broadcast int udpLocalPort = 14550; int udpRemotePort = 14550; IPAddress udpRemoteIP = "255.255.255.255"; @@ -64,7 +65,8 @@ void sendWiFi(const uint8_t *buf, int len) { if (WiFi.softAPgetStationNum() == 0 && !WiFi.isConnected()) return; - udp.beginPacket(t - mavlinkTime < 5 ? udpRemoteIP : IPAddress(255, 255, 255, 255), udpRemotePort); // broadcast if lost connection + bool broadcast = wifiBroadcast || !(t - mavlinkTime < 5); // broadcast if lost connection + udp.beginPacket(broadcast ? IPAddress(255, 255, 255, 255) : udpRemoteIP, udpRemotePort); udp.write(buf, len); udp.endPacket(); }