diff --git a/platformio.ini b/platformio.ini index cc8d280..c69909b 100644 --- a/platformio.ini +++ b/platformio.ini @@ -19,4 +19,17 @@ lib_deps = ESP32 Digital RGB LED Drivers esp32_https_server -build_flags = -std=c++11 \ No newline at end of file +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 diff --git a/src/main.cpp b/src/main.cpp index 5d87673..8079b76 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6,6 +6,8 @@ #include #include +#include + #include #include @@ -49,6 +51,45 @@ UpdateServer *updateServer; 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() { /**************************************************************************** @@ -431,6 +472,8 @@ void setup() NULL, /* Task handle to keep track of created task */ CORE_ID_LED); + WiFi.onEvent(WiFiEvent); + // Connect the WiFi network (or start an AP if that doesn't work) for (auto &net : Config::instance().getWLANList()) { @@ -441,6 +484,8 @@ void setup() wifi_setup(); + ETH.begin(); + // start the UDP server udpProto.start(2703);