mirror of
https://github.com/bleackstorm/SteamFrame-FPV-Control-Center.git
synced 2026-12-03 07:31:57 +01:00
feat(nomad): add editable network target, 50Hz manual mock, MAVLink protocol & ELRS Backpack UDP MSPv2 patch
This commit is contained in:
1 parent
7bee072e21
commit
e859d0e21c
7 files changed
+860
-57
No files matched your search
@@ -0,0 +1,93 @@
|
||||
diff --git a/lib/WIFI/devWIFI.cpp b/lib/WIFI/devWIFI.cpp
|
||||
index 26b4013..77dd0fa 100644
|
||||
--- a/lib/WIFI/devWIFI.cpp
|
||||
+++ b/lib/WIFI/devWIFI.cpp
|
||||
@@ -119,6 +119,32 @@ IPAddress gcsIP;
|
||||
bool gcsIPSet = false;
|
||||
#endif
|
||||
|
||||
+static WiFiUDP ptrUDP;
|
||||
+static uint32_t ptrPacketsCount = 0;
|
||||
+
|
||||
+static bool forwardMspPtrIfValid(const uint8_t *buf, uint16_t len)
|
||||
+{
|
||||
+ if (len == 15 && buf[0] == '$' && buf[1] == 'X' && buf[2] == '<' && buf[4] == 0x83 && buf[5] == 0x03)
|
||||
+ {
|
||||
+ uint8_t crc = 0;
|
||||
+ for (uint8_t i = 3; i < 14; i++)
|
||||
+ {
|
||||
+ crc ^= buf[i];
|
||||
+ for (uint8_t b = 0; b < 8; b++)
|
||||
+ {
|
||||
+ crc = (crc & 0x80) ? ((crc << 1) ^ 0xD5) : (crc << 1);
|
||||
+ }
|
||||
+ }
|
||||
+ if (crc == buf[14])
|
||||
+ {
|
||||
+ Serial.write(buf, 15);
|
||||
+ ptrPacketsCount++;
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
#if defined(TARGET_TX_BACKPACK)
|
||||
bool SendTxBackpackTelemetryViaUDP(const uint8_t *data, uint16_t size)
|
||||
{
|
||||
@@ -577,6 +603,7 @@ static void WebMAVLinkHandler(AsyncWebServerRequest *request)
|
||||
json["counters"]["packets_up"] = stats->packets_uplink;
|
||||
json["counters"]["drops_down"] = stats->drops_downlink;
|
||||
json["counters"]["overflows_down"] = stats->overflows_downlink;
|
||||
+ json["counters"]["ptr_packets"] = ptrPacketsCount;
|
||||
json["ports"]["listen"] = config.GetMavlinkListenPort();
|
||||
json["ports"]["send"] = config.GetMavlinkSendPort();
|
||||
if (gcsIPSet) {
|
||||
@@ -792,6 +819,7 @@ static void startServices()
|
||||
#if defined(MAVLINK_ENABLED)
|
||||
mavlinkUDP.begin(config.GetMavlinkListenPort());
|
||||
#endif
|
||||
+ ptrUDP.begin(14550);
|
||||
|
||||
servicesStarted = true;
|
||||
DBGLN("HTTPUpdateServer ready! Open http://%s.local in your browser", myHostname);
|
||||
@@ -923,7 +951,7 @@ static void HandleWebUpdate()
|
||||
last_mavlink_to_gcs_dump = millis();
|
||||
}
|
||||
|
||||
- // Check if we have MAVLink UDP data to send over UART
|
||||
+ // Check if we have MAVLink UDP data (or MSPv2 SET_PTR 0x0383) to send over UART
|
||||
if (wifiService == WIFI_SERVICE_MAVLINK_TX)
|
||||
{
|
||||
uint16_t packetSize = mavlinkUDP.parsePacket();
|
||||
@@ -932,13 +960,28 @@ static void HandleWebUpdate()
|
||||
gcsIP = mavlinkUDP.remoteIP(); // store the IP of the GCS so we can send to it directly
|
||||
gcsIPSet = true;
|
||||
uint8_t buf[MAVLINK_MAX_PACKET_LEN];
|
||||
- mavlinkUDP.read(buf, packetSize);
|
||||
- mavlink.ProcessMAVLinkFromGCS(buf, packetSize);
|
||||
+ uint16_t readLen = (packetSize <= MAVLINK_MAX_PACKET_LEN) ? packetSize : MAVLINK_MAX_PACKET_LEN;
|
||||
+ mavlinkUDP.read(buf, readLen);
|
||||
+ if (!forwardMspPtrIfValid(buf, readLen))
|
||||
+ {
|
||||
+ mavlink.ProcessMAVLinkFromGCS(buf, readLen);
|
||||
+ }
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
+ {
|
||||
+ uint16_t ptrPacketSize = ptrUDP.parsePacket();
|
||||
+ if (ptrPacketSize)
|
||||
+ {
|
||||
+ uint8_t buf[32];
|
||||
+ uint16_t readLen = (ptrPacketSize <= sizeof(buf)) ? ptrPacketSize : sizeof(buf);
|
||||
+ ptrUDP.read(buf, readLen);
|
||||
+ forwardMspPtrIfValid(buf, readLen);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
dnsServer.processNextRequest();
|
||||
#if defined(PLATFORM_ESP8266)
|
||||
MDNS.update();
|
||||
Reference in new issue
Block a user