From b611be804280621170a4c6ff477a1e262afca13c Mon Sep 17 00:00:00 2001 From: lumapu Date: Sun, 31 Dec 2023 01:30:46 +0100 Subject: [PATCH] compile ok, function not ok --- src/appInterface.h | 4 --- src/eth/ahoyeth.cpp | 56 ++++++++++++++++++++++++----------------- src/eth/ahoyeth.h | 5 ++-- src/platformio.ini | 10 -------- src/publisher/pubMqtt.h | 4 +++ src/web/RestApi.h | 4 --- src/web/web.h | 4 --- 7 files changed, 40 insertions(+), 47 deletions(-) diff --git a/src/appInterface.h b/src/appInterface.h index 34dc5ddc..625f72db 100644 --- a/src/appInterface.h +++ b/src/appInterface.h @@ -8,11 +8,7 @@ #include "defines.h" #include "hm/hmSystem.h" -#if defined(ETHERNET) -#include "AsyncWebServer_ESP32_W5500.h" -#else #include "ESPAsyncWebServer.h" -#endif //#include "hms/hmsRadio.h" #if defined(ESP32) diff --git a/src/eth/ahoyeth.cpp b/src/eth/ahoyeth.cpp index 2226fce6..402abfc2 100644 --- a/src/eth/ahoyeth.cpp +++ b/src/eth/ahoyeth.cpp @@ -25,6 +25,7 @@ void ahoyeth::setup(settings_t *config, uint32_t *utcTimestamp, OnNetworkCB onNe mUtcTimestamp = utcTimestamp; mOnNetworkCB = onNetworkCB; mOnTimeCB = onTimeCB; + mEthConnected = false; Serial.flush(); WiFi.onEvent([this](WiFiEvent_t event, arduino_event_info_t info) -> void { this->onEthernetEvent(event, info); }); @@ -33,7 +34,8 @@ void ahoyeth::setup(settings_t *config, uint32_t *utcTimestamp, OnNetworkCB onNe #if defined(CONFIG_IDF_TARGET_ESP32S3) mEthSpi.begin(DEF_ETH_MISO_PIN, DEF_ETH_MOSI_PIN, DEF_ETH_SCK_PIN, DEF_ETH_CS_PIN, DEF_ETH_IRQ_PIN, DEF_ETH_RST_PIN); #else - ETH.begin(DEF_ETH_MISO_PIN, DEF_ETH_MOSI_PIN, DEF_ETH_SCK_PIN, DEF_ETH_CS_PIN, DEF_ETH_IRQ_PIN, ETH_SPI_CLOCK_MHZ, ETH_SPI_HOST); + //ETH.begin(ETH_PHY_ADDR, ETH_PHY_POWER, ETH_PHY_MDC, ETH_PHY_MDIO, ETH_PHY_TYPE, ETH_CLK_MODE); + ETH.begin(ETH_PHY_ADDR, ETH_PHY_POWER, ETH_PHY_MDC, DEF_ETH_MOSI_PIN, ETH_PHY_TYPE, ETH_CLK_MODE); #endif if(mConfig->sys.ip.ip[0] != 0) { @@ -130,7 +132,7 @@ void ahoyeth::welcome(String ip, String mode) { } void ahoyeth::onEthernetEvent(WiFiEvent_t event, arduino_event_info_t info) { - AWS_LOG(F("[ETH]: Got event...")); + DPRINTLN(DBG_VERBOSE, F("[ETH]: Got event...")); switch (event) { #if ( ( defined(ESP_ARDUINO_VERSION_MAJOR) && (ESP_ARDUINO_VERSION_MAJOR >= 2) ) && ( ARDUINO_ESP32_GIT_VER != 0x46d5afb1 ) ) // For breaking core v2.0.0 @@ -138,7 +140,7 @@ void ahoyeth::onEthernetEvent(WiFiEvent_t event, arduino_event_info_t info) { // compared to the old system_event_id_t, now in tools/sdk/esp32/include/esp_event/include/esp_event_legacy.h // You can preserve the old enum order and just adding new items to do no harm case ARDUINO_EVENT_ETH_START: - AWS_LOG(F("\nETH Started")); + DPRINTLN(DBG_INFO, F("\nETH Started")); //set eth hostname here if(String(mConfig->sys.deviceName) != "") ETH.setHostname(mConfig->sys.deviceName); @@ -147,26 +149,30 @@ void ahoyeth::onEthernetEvent(WiFiEvent_t event, arduino_event_info_t info) { break; case ARDUINO_EVENT_ETH_CONNECTED: - AWS_LOG(F("ETH Connected")); + DPRINTLN(DBG_INFO, F("ETH Connected")); break; case ARDUINO_EVENT_ETH_GOT_IP: - if (!ESP32_W5500_eth_connected) { + if (!mEthConnected) { + DPRINT(DBG_INFO, F("ETH MAC: ")); #if defined (CONFIG_IDF_TARGET_ESP32S3) - AWS_LOG3(F("ETH MAC: "), mEthSpi.macAddress(), F(", IPv4: "), ETH.localIP()); + DBGPRINT(mEthSpi.macAddress()); #else - AWS_LOG3(F("ETH MAC: "), ETH.macAddress(), F(", IPv4: "), ETH.localIP()); + DBGPRINT(ETH.macAddress()); #endif + DBGPRINT(F(", IPv4: ")); + DBGPRINTLN(String(ETH.localIP())); if (ETH.fullDuplex()) { - AWS_LOG0(F("FULL_DUPLEX, ")); + DPRINTLN(DBG_INFO, F("FULL_DUPLEX, ")); } else { - AWS_LOG0(F("HALF_DUPLEX, ")); + DPRINTLN(DBG_INFO, F("HALF_DUPLEX, ")); } - AWS_LOG1(ETH.linkSpeed(), F("Mbps")); + DPRINT(DBG_INFO, String(ETH.linkSpeed())); + DBGPRINTLN(F("Mbps")); - ESP32_W5500_eth_connected = true; + mEthConnected = true; mOnNetworkCB(true); } if (!MDNS.begin(mConfig->sys.deviceName)) { @@ -179,15 +185,15 @@ void ahoyeth::onEthernetEvent(WiFiEvent_t event, arduino_event_info_t info) { break; case ARDUINO_EVENT_ETH_DISCONNECTED: - AWS_LOG("ETH Disconnected"); - ESP32_W5500_eth_connected = false; + DPRINTLN(DBG_INFO, "ETH Disconnected"); + mEthConnected = false; mUdp.close(); mOnNetworkCB(false); break; case ARDUINO_EVENT_ETH_STOP: - AWS_LOG("\nETH Stopped"); - ESP32_W5500_eth_connected = false; + DPRINTLN(DBG_INFO, "\nETH Stopped"); + mEthConnected = false; mUdp.close(); mOnNetworkCB(false); break; @@ -200,7 +206,7 @@ void ahoyeth::onEthernetEvent(WiFiEvent_t event, arduino_event_info_t info) { // compared to the old system_event_id_t, now in tools/sdk/esp32/include/esp_event/include/esp_event_legacy.h // You can preserve the old enum order and just adding new items to do no harm case SYSTEM_EVENT_ETH_START: - AWS_LOG(F("\nETH Started")); + DPRINTLN(DBG_INFO, F("\nETH Started")); //set eth hostname here if(String(mConfig->sys.deviceName) != "") ETH.setHostname(mConfig->sys.deviceName); @@ -209,20 +215,24 @@ void ahoyeth::onEthernetEvent(WiFiEvent_t event, arduino_event_info_t info) { break; case SYSTEM_EVENT_ETH_CONNECTED: - AWS_LOG(F("ETH Connected")); + DPRINTLN(DBG_INFO, F("ETH Connected")); break; case SYSTEM_EVENT_ETH_GOT_IP: if (!ESP32_W5500_eth_connected) { - AWS_LOG3(F("ETH MAC: "), ETH.macAddress(), F(", IPv4: "), ETH.localIP()); + DPRINT(DBG_INFO, F("ETH MAC: ")); + DBGPRINT(ETH.macAddress()); + DBGPRINT(F(", IPv4: ")); + DBGPRINTLN(ETH.localIP()); if (ETH.fullDuplex()) { - AWS_LOG0(F("FULL_DUPLEX, ")); + DPRINTLN(DBG_INFO, F("FULL_DUPLEX, ")); } else { - AWS_LOG0(F("HALF_DUPLEX, ")); + DPRINTLN(DBG_INFO, F("HALF_DUPLEX, ")); } - AWS_LOG1(ETH.linkSpeed(), F("Mbps")); + DPRINT(DBG_INFO, ETH.linkSpeed()); + DBGPRINTLN(F("Mbps")); ESP32_W5500_eth_connected = true; mOnNetworkCB(true); @@ -237,14 +247,14 @@ void ahoyeth::onEthernetEvent(WiFiEvent_t event, arduino_event_info_t info) { break; case SYSTEM_EVENT_ETH_DISCONNECTED: - AWS_LOG("ETH Disconnected"); + DPRINT(DBG_INFO, F("ETH Disconnected")); ESP32_W5500_eth_connected = false; mUdp.close(); mOnNetworkCB(false); break; case SYSTEM_EVENT_ETH_STOP: - AWS_LOG("\nETH Stopped"); + DPRINT(DBG_INFO, F("ETH Stopped")); ESP32_W5500_eth_connected = false; mUdp.close(); mOnNetworkCB(false); diff --git a/src/eth/ahoyeth.h b/src/eth/ahoyeth.h index 157a9c76..2b0f8b62 100644 --- a/src/eth/ahoyeth.h +++ b/src/eth/ahoyeth.h @@ -9,17 +9,17 @@ #include +#include "../utils/dbg.h" #include #include #include #include "ethSpi.h" +#include #include "../utils/dbg.h" #include "../config/config.h" #include "../config/settings.h" -#include "AsyncWebServer_ESP32_W5500.h" - class app; @@ -57,6 +57,7 @@ class ahoyeth { OnNetworkCB mOnNetworkCB; OnTimeCB mOnTimeCB; + bool mEthConnected; }; diff --git a/src/platformio.ini b/src/platformio.ini index 2b4b25cf..e58c6804 100644 --- a/src/platformio.ini +++ b/src/platformio.ini @@ -90,16 +90,6 @@ monitor_filters = [env:esp32-wroom32-ethernet] platform = espressif32 board = esp32dev -lib_deps = - khoih-prog/AsyncWebServer_ESP32_W5500 - khoih-prog/AsyncUDP_ESP32_W5500 - nrf24/RF24 @ ^1.4.8 - paulstoffregen/Time @ ^1.6.1 - https://github.com/bertmelis/espMqttClient#v1.5.0 - bblanchon/ArduinoJson @ ^6.21.3 - https://github.com/JChristensen/Timezone @ ^1.2.4 - olikraus/U8g2 @ ^2.35.7 - zinggjm/GxEPD2 @ ^1.5.2 build_flags = ${env.build_flags} -D ETHERNET -DRELEASE diff --git a/src/publisher/pubMqtt.h b/src/publisher/pubMqtt.h index e062439c..b76b1677 100644 --- a/src/publisher/pubMqtt.h +++ b/src/publisher/pubMqtt.h @@ -14,6 +14,10 @@ #include #endif +#if defined(ETHERNET) +#include "../eth/ahoyeth.h" +#endif + #include "../utils/dbg.h" #include "../config/config.h" #include diff --git a/src/web/RestApi.h b/src/web/RestApi.h index a74f4f14..32975e39 100644 --- a/src/web/RestApi.h +++ b/src/web/RestApi.h @@ -16,11 +16,7 @@ #include "../hm/hmSystem.h" #include "../utils/helper.h" #include "AsyncJson.h" -#if defined(ETHERNET) -#include "AsyncWebServer_ESP32_W5500.h" -#else #include "ESPAsyncWebServer.h" -#endif #if defined(F) && defined(ESP32) #undef F diff --git a/src/web/web.h b/src/web/web.h index 1e87547b..e559264b 100644 --- a/src/web/web.h +++ b/src/web/web.h @@ -16,11 +16,7 @@ #include "../appInterface.h" #include "../hm/hmSystem.h" #include "../utils/helper.h" -#if defined(ETHERNET) -#include "AsyncWebServer_ESP32_W5500.h" -#else /* defined(ETHERNET) */ #include "ESPAsyncWebServer.h" -#endif /* defined(ETHERNET) */ #include "html/h/api_js.h" #include "html/h/colorBright_css.h" #include "html/h/colorDark_css.h"