Uno R4 Wifi support

This commit is contained in:
Pascal Serrarens 2025-02-28 12:55:20 +01:00
parent 7a9df4aec5
commit 812661547d
3 changed files with 30 additions and 4 deletions

View File

@ -3,14 +3,20 @@
#if defined(ARDUINO) #if defined(ARDUINO)
#include <Arduino.h> #include <Arduino.h>
#include <HTTPClient.h>
#if defined(ARDUINO_ARCH_ESP8266) #if defined(ARDUINO_ARCH_ESP8266)
#include <ESP8266WiFi.h> #include <ESP8266WiFi.h>
#include <ESP8266httpUpdate.h> #include <ESP8266httpUpdate.h>
#include <HTTPClient.h>
#elif defined(ESP32) #elif defined(ESP32)
#include <HTTPClient.h>
#include <HTTPUpdate.h> #include <HTTPUpdate.h>
#include <WiFi.h> #include <WiFi.h>
#elif defined(UNO_R4)
#include <WiFi.h>
#endif #endif
const char* hotspotSSID = "Roboid"; 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) { 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."); Serial.println("Checking for firmware updates.");
WiFiClient client; WiFiClient client;
@ -188,5 +197,6 @@ void CheckFirmware(String url, String FIRMWARE_NAME, int FIRMWARE_VERSION) {
Serial.print("Http Error: "); Serial.print("Http Error: ");
Serial.println(httpCode); Serial.println(httpCode);
} }
#endif
} }
#endif #endif

View File

@ -7,6 +7,12 @@
#elif defined(ESP32) #elif defined(ESP32)
#include <WiFi.h> #include <WiFi.h>
#elif defined(UNO_R4)
#include <WiFi.h>
#elif defined(ARDUINO_ARCH_RP2040) // not functional, for future use
#include <WifiNINA.h>
#endif #endif
#endif #endif
@ -19,10 +25,17 @@ void Participant::Setup(int localPort, const char* remoteIpAddress, int remotePo
this->remotePort = remotePort; this->remotePort = remotePort;
GetBroadcastAddress(); GetBroadcastAddress();
#if defined(UNO_R4)
if (WiFi.status() == WL_NO_MODULE) {
std::cout << "No network available!\n";
return;
}
#else
if (WiFi.isConnected() == false) { if (WiFi.isConnected() == false) {
std::cout << "No network available!\n"; std::cout << "No network available!\n";
return; return;
} }
#endif
udp.begin(localPort); udp.begin(localPort);
std::cout << "Wifi sync started to port " << this->remotePort << "\n"; std::cout << "Wifi sync started to port " << this->remotePort << "\n";
@ -70,10 +83,10 @@ void Participant::Receive() {
bool Participant::Send(RemoteParticipant* remoteParticipant, int bufferSize) { bool Participant::Send(RemoteParticipant* remoteParticipant, int bufferSize) {
#if defined(ARDUINO) #if defined(ARDUINO)
// std::cout << "Sending to:\n " << remoteParticipant->ipAddress << ":" // std::cout << "Sending to:\n " << remoteParticipant->ipAddress << ":"
// << remoteParticipant->port << "\n"; // << remoteParticipant->port << "\n";
int n = 0; int n = 0;
do { do {
if (n > 0) { if (n > 0) {
std::cout << "Retry sending\n"; std::cout << "Retry sending\n";

View File

@ -6,6 +6,9 @@ Supporting:
- MacOS - MacOS
- Linux - Linux
- Arduino (using PlatformIO) - Arduino (using PlatformIO)
- ESP8266
- ESP32
- UNO R4 WiFi
# Basic components # Basic components