From 812661547dc8d930b61e5f878a63bdae8c8715eb Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Fri, 28 Feb 2025 12:55:20 +0100 Subject: [PATCH] Uno R4 Wifi support --- Arduino/ArduinoUtils.cpp | 12 +++++++++++- Arduino/Participant.cpp | 19 ++++++++++++++++--- README.md | 3 +++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/Arduino/ArduinoUtils.cpp b/Arduino/ArduinoUtils.cpp index 06e8ff8..dfc197b 100644 --- a/Arduino/ArduinoUtils.cpp +++ b/Arduino/ArduinoUtils.cpp @@ -3,14 +3,20 @@ #if defined(ARDUINO) #include -#include #if defined(ARDUINO_ARCH_ESP8266) #include #include +#include + #elif defined(ESP32) +#include #include #include + +#elif defined(UNO_R4) +#include + #endif const char* hotspotSSID = "Roboid"; @@ -139,6 +145,9 @@ bool StartWifi(const char* wifiSsid, const char* wifiPassword, bool hotspotFallb } void CheckFirmware(String url, String FIRMWARE_NAME, int FIRMWARE_VERSION) { +#if defined(UNO_R4) // Uno R4 Wifi does not support this kind of firmware update (as far as I know) + return; +#else Serial.println("Checking for firmware updates."); WiFiClient client; @@ -188,5 +197,6 @@ void CheckFirmware(String url, String FIRMWARE_NAME, int FIRMWARE_VERSION) { Serial.print("Http Error: "); Serial.println(httpCode); } +#endif } #endif \ No newline at end of file diff --git a/Arduino/Participant.cpp b/Arduino/Participant.cpp index db22528..0b98876 100644 --- a/Arduino/Participant.cpp +++ b/Arduino/Participant.cpp @@ -7,6 +7,12 @@ #elif defined(ESP32) #include +#elif defined(UNO_R4) +#include + +#elif defined(ARDUINO_ARCH_RP2040) // not functional, for future use +#include + #endif #endif @@ -19,10 +25,17 @@ void Participant::Setup(int localPort, const char* remoteIpAddress, int remotePo this->remotePort = remotePort; GetBroadcastAddress(); +#if defined(UNO_R4) + if (WiFi.status() == WL_NO_MODULE) { + std::cout << "No network available!\n"; + return; + } +#else if (WiFi.isConnected() == false) { std::cout << "No network available!\n"; return; } +#endif udp.begin(localPort); std::cout << "Wifi sync started to port " << this->remotePort << "\n"; @@ -70,10 +83,10 @@ void Participant::Receive() { bool Participant::Send(RemoteParticipant* remoteParticipant, int bufferSize) { #if defined(ARDUINO) -// std::cout << "Sending to:\n " << remoteParticipant->ipAddress << ":" -// << remoteParticipant->port << "\n"; + // std::cout << "Sending to:\n " << remoteParticipant->ipAddress << ":" + // << remoteParticipant->port << "\n"; -int n = 0; + int n = 0; do { if (n > 0) { std::cout << "Retry sending\n"; diff --git a/README.md b/README.md index f5cabcc..c9b893e 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,9 @@ Supporting: - MacOS - Linux - Arduino (using PlatformIO) + - ESP8266 + - ESP32 + - UNO R4 WiFi # Basic components