Added support for ESP32-EVB and Ethernet

This commit is contained in:
Thomas Kolb 2022-05-06 23:58:16 +02:00
parent 6ff81845ed
commit b932a10ca1
2 changed files with 59 additions and 1 deletions

View file

@ -19,4 +19,17 @@ lib_deps =
ESP32 Digital RGB LED Drivers ESP32 Digital RGB LED Drivers
esp32_https_server esp32_https_server
build_flags = -std=c++11 build_flags = -std=c++11
[env:esp32-evb]
platform = espressif32
board = esp32-evb
framework = arduino
monitor_speed = 115200
lib_deps =
ESP32 Digital RGB LED Drivers
esp32_https_server@0.3.0
build_flags = -std=c++11

View file

@ -6,6 +6,8 @@
#include <WiFiMulti.h> #include <WiFiMulti.h>
#include <SPIFFS.h> #include <SPIFFS.h>
#include <ETH.h>
#include <FreeRTOS.h> #include <FreeRTOS.h>
#include <freertos/semphr.h> #include <freertos/semphr.h>
@ -49,6 +51,45 @@ UpdateServer *updateServer;
AnimationController animController(&ledFader); AnimationController animController(&ledFader);
static bool eth_connected = false;
void WiFiEvent(WiFiEvent_t event)
{
switch (event) {
case SYSTEM_EVENT_ETH_START:
Serial.println("ETH Started");
//set eth hostname here
ETH.setHostname("zamusiclight");
break;
case SYSTEM_EVENT_ETH_CONNECTED:
Serial.println("ETH Connected");
break;
case SYSTEM_EVENT_ETH_GOT_IP:
Serial.print("ETH MAC: ");
Serial.print(ETH.macAddress());
Serial.print(", IPv4: ");
Serial.print(ETH.localIP());
if (ETH.fullDuplex()) {
Serial.print(", FULL_DUPLEX");
}
Serial.print(", ");
Serial.print(ETH.linkSpeed());
Serial.println("Mbps");
eth_connected = true;
break;
case SYSTEM_EVENT_ETH_DISCONNECTED:
Serial.println("ETH Disconnected");
eth_connected = false;
break;
case SYSTEM_EVENT_ETH_STOP:
Serial.println("ETH Stopped");
eth_connected = false;
break;
default:
break;
}
}
bool initLEDs() bool initLEDs()
{ {
/**************************************************************************** /****************************************************************************
@ -431,6 +472,8 @@ void setup()
NULL, /* Task handle to keep track of created task */ NULL, /* Task handle to keep track of created task */
CORE_ID_LED); CORE_ID_LED);
WiFi.onEvent(WiFiEvent);
// Connect the WiFi network (or start an AP if that doesn't work) // Connect the WiFi network (or start an AP if that doesn't work)
for (auto &net : Config::instance().getWLANList()) for (auto &net : Config::instance().getWLANList())
{ {
@ -441,6 +484,8 @@ void setup()
wifi_setup(); wifi_setup();
ETH.begin();
// start the UDP server // start the UDP server
udpProto.start(2703); udpProto.start(2703);