Add parameter WIFI_BROADCAST for always broadcasting mode

May be used in some cases, like multiple gcs
This commit is contained in:
Oleg Kalachev
2026-08-08 01:04:43 +03:00
parent aee43c6548
commit 070eb8a0de
2 changed files with 5 additions and 2 deletions
+2 -1
View File
@@ -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<float> voltageFilter;
@@ -112,6 +112,7 @@ Parameter parameters[] = {
{"WIFI_PORT_LOC", &udpLocalPort},
{"WIFI_PORT_REM", &udpRemotePort},
{"WIFI_LONG_RANGE", &wifiLongRange},
{"WIFI_BROADCAST", &wifiBroadcast},
// espnow
{"ESPNOW_CHANNEL", &espnowChannel},
// mavlink
+3 -1
View File
@@ -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();
}