mirror of
https://github.com/lumapu/ahoy.git
synced 2025-07-13 14:37:16 +02:00
compile ok, function not ok
This commit is contained in:
parent
f5b0bacbe6
commit
b611be8042
7 changed files with 40 additions and 47 deletions
|
@ -8,11 +8,7 @@
|
||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "hm/hmSystem.h"
|
#include "hm/hmSystem.h"
|
||||||
#if defined(ETHERNET)
|
|
||||||
#include "AsyncWebServer_ESP32_W5500.h"
|
|
||||||
#else
|
|
||||||
#include "ESPAsyncWebServer.h"
|
#include "ESPAsyncWebServer.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
//#include "hms/hmsRadio.h"
|
//#include "hms/hmsRadio.h"
|
||||||
#if defined(ESP32)
|
#if defined(ESP32)
|
||||||
|
|
|
@ -25,6 +25,7 @@ void ahoyeth::setup(settings_t *config, uint32_t *utcTimestamp, OnNetworkCB onNe
|
||||||
mUtcTimestamp = utcTimestamp;
|
mUtcTimestamp = utcTimestamp;
|
||||||
mOnNetworkCB = onNetworkCB;
|
mOnNetworkCB = onNetworkCB;
|
||||||
mOnTimeCB = onTimeCB;
|
mOnTimeCB = onTimeCB;
|
||||||
|
mEthConnected = false;
|
||||||
|
|
||||||
Serial.flush();
|
Serial.flush();
|
||||||
WiFi.onEvent([this](WiFiEvent_t event, arduino_event_info_t info) -> void { this->onEthernetEvent(event, info); });
|
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)
|
#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);
|
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
|
#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
|
#endif
|
||||||
|
|
||||||
if(mConfig->sys.ip.ip[0] != 0) {
|
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) {
|
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) {
|
switch (event) {
|
||||||
#if ( ( defined(ESP_ARDUINO_VERSION_MAJOR) && (ESP_ARDUINO_VERSION_MAJOR >= 2) ) && ( ARDUINO_ESP32_GIT_VER != 0x46d5afb1 ) )
|
#if ( ( defined(ESP_ARDUINO_VERSION_MAJOR) && (ESP_ARDUINO_VERSION_MAJOR >= 2) ) && ( ARDUINO_ESP32_GIT_VER != 0x46d5afb1 ) )
|
||||||
// For breaking core v2.0.0
|
// 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
|
// 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
|
// You can preserve the old enum order and just adding new items to do no harm
|
||||||
case ARDUINO_EVENT_ETH_START:
|
case ARDUINO_EVENT_ETH_START:
|
||||||
AWS_LOG(F("\nETH Started"));
|
DPRINTLN(DBG_INFO, F("\nETH Started"));
|
||||||
//set eth hostname here
|
//set eth hostname here
|
||||||
if(String(mConfig->sys.deviceName) != "")
|
if(String(mConfig->sys.deviceName) != "")
|
||||||
ETH.setHostname(mConfig->sys.deviceName);
|
ETH.setHostname(mConfig->sys.deviceName);
|
||||||
|
@ -147,26 +149,30 @@ void ahoyeth::onEthernetEvent(WiFiEvent_t event, arduino_event_info_t info) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ARDUINO_EVENT_ETH_CONNECTED:
|
case ARDUINO_EVENT_ETH_CONNECTED:
|
||||||
AWS_LOG(F("ETH Connected"));
|
DPRINTLN(DBG_INFO, F("ETH Connected"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ARDUINO_EVENT_ETH_GOT_IP:
|
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)
|
#if defined (CONFIG_IDF_TARGET_ESP32S3)
|
||||||
AWS_LOG3(F("ETH MAC: "), mEthSpi.macAddress(), F(", IPv4: "), ETH.localIP());
|
DBGPRINT(mEthSpi.macAddress());
|
||||||
#else
|
#else
|
||||||
AWS_LOG3(F("ETH MAC: "), ETH.macAddress(), F(", IPv4: "), ETH.localIP());
|
DBGPRINT(ETH.macAddress());
|
||||||
#endif
|
#endif
|
||||||
|
DBGPRINT(F(", IPv4: "));
|
||||||
|
DBGPRINTLN(String(ETH.localIP()));
|
||||||
|
|
||||||
if (ETH.fullDuplex()) {
|
if (ETH.fullDuplex()) {
|
||||||
AWS_LOG0(F("FULL_DUPLEX, "));
|
DPRINTLN(DBG_INFO, F("FULL_DUPLEX, "));
|
||||||
} else {
|
} 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);
|
mOnNetworkCB(true);
|
||||||
}
|
}
|
||||||
if (!MDNS.begin(mConfig->sys.deviceName)) {
|
if (!MDNS.begin(mConfig->sys.deviceName)) {
|
||||||
|
@ -179,15 +185,15 @@ void ahoyeth::onEthernetEvent(WiFiEvent_t event, arduino_event_info_t info) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ARDUINO_EVENT_ETH_DISCONNECTED:
|
case ARDUINO_EVENT_ETH_DISCONNECTED:
|
||||||
AWS_LOG("ETH Disconnected");
|
DPRINTLN(DBG_INFO, "ETH Disconnected");
|
||||||
ESP32_W5500_eth_connected = false;
|
mEthConnected = false;
|
||||||
mUdp.close();
|
mUdp.close();
|
||||||
mOnNetworkCB(false);
|
mOnNetworkCB(false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ARDUINO_EVENT_ETH_STOP:
|
case ARDUINO_EVENT_ETH_STOP:
|
||||||
AWS_LOG("\nETH Stopped");
|
DPRINTLN(DBG_INFO, "\nETH Stopped");
|
||||||
ESP32_W5500_eth_connected = false;
|
mEthConnected = false;
|
||||||
mUdp.close();
|
mUdp.close();
|
||||||
mOnNetworkCB(false);
|
mOnNetworkCB(false);
|
||||||
break;
|
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
|
// 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
|
// You can preserve the old enum order and just adding new items to do no harm
|
||||||
case SYSTEM_EVENT_ETH_START:
|
case SYSTEM_EVENT_ETH_START:
|
||||||
AWS_LOG(F("\nETH Started"));
|
DPRINTLN(DBG_INFO, F("\nETH Started"));
|
||||||
//set eth hostname here
|
//set eth hostname here
|
||||||
if(String(mConfig->sys.deviceName) != "")
|
if(String(mConfig->sys.deviceName) != "")
|
||||||
ETH.setHostname(mConfig->sys.deviceName);
|
ETH.setHostname(mConfig->sys.deviceName);
|
||||||
|
@ -209,20 +215,24 @@ void ahoyeth::onEthernetEvent(WiFiEvent_t event, arduino_event_info_t info) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SYSTEM_EVENT_ETH_CONNECTED:
|
case SYSTEM_EVENT_ETH_CONNECTED:
|
||||||
AWS_LOG(F("ETH Connected"));
|
DPRINTLN(DBG_INFO, F("ETH Connected"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SYSTEM_EVENT_ETH_GOT_IP:
|
case SYSTEM_EVENT_ETH_GOT_IP:
|
||||||
if (!ESP32_W5500_eth_connected) {
|
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()) {
|
if (ETH.fullDuplex()) {
|
||||||
AWS_LOG0(F("FULL_DUPLEX, "));
|
DPRINTLN(DBG_INFO, F("FULL_DUPLEX, "));
|
||||||
} else {
|
} 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;
|
ESP32_W5500_eth_connected = true;
|
||||||
mOnNetworkCB(true);
|
mOnNetworkCB(true);
|
||||||
|
@ -237,14 +247,14 @@ void ahoyeth::onEthernetEvent(WiFiEvent_t event, arduino_event_info_t info) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SYSTEM_EVENT_ETH_DISCONNECTED:
|
case SYSTEM_EVENT_ETH_DISCONNECTED:
|
||||||
AWS_LOG("ETH Disconnected");
|
DPRINT(DBG_INFO, F("ETH Disconnected"));
|
||||||
ESP32_W5500_eth_connected = false;
|
ESP32_W5500_eth_connected = false;
|
||||||
mUdp.close();
|
mUdp.close();
|
||||||
mOnNetworkCB(false);
|
mOnNetworkCB(false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SYSTEM_EVENT_ETH_STOP:
|
case SYSTEM_EVENT_ETH_STOP:
|
||||||
AWS_LOG("\nETH Stopped");
|
DPRINT(DBG_INFO, F("ETH Stopped"));
|
||||||
ESP32_W5500_eth_connected = false;
|
ESP32_W5500_eth_connected = false;
|
||||||
mUdp.close();
|
mUdp.close();
|
||||||
mOnNetworkCB(false);
|
mOnNetworkCB(false);
|
||||||
|
|
|
@ -9,17 +9,17 @@
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
|
#include "../utils/dbg.h"
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <AsyncUDP.h>
|
#include <AsyncUDP.h>
|
||||||
#include <DNSServer.h>
|
#include <DNSServer.h>
|
||||||
|
|
||||||
#include "ethSpi.h"
|
#include "ethSpi.h"
|
||||||
|
#include <ETH.h>
|
||||||
#include "../utils/dbg.h"
|
#include "../utils/dbg.h"
|
||||||
#include "../config/config.h"
|
#include "../config/config.h"
|
||||||
#include "../config/settings.h"
|
#include "../config/settings.h"
|
||||||
|
|
||||||
#include "AsyncWebServer_ESP32_W5500.h"
|
|
||||||
|
|
||||||
|
|
||||||
class app;
|
class app;
|
||||||
|
|
||||||
|
@ -57,6 +57,7 @@ class ahoyeth {
|
||||||
|
|
||||||
OnNetworkCB mOnNetworkCB;
|
OnNetworkCB mOnNetworkCB;
|
||||||
OnTimeCB mOnTimeCB;
|
OnTimeCB mOnTimeCB;
|
||||||
|
bool mEthConnected;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -90,16 +90,6 @@ monitor_filters =
|
||||||
[env:esp32-wroom32-ethernet]
|
[env:esp32-wroom32-ethernet]
|
||||||
platform = espressif32
|
platform = espressif32
|
||||||
board = esp32dev
|
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}
|
build_flags = ${env.build_flags}
|
||||||
-D ETHERNET
|
-D ETHERNET
|
||||||
-DRELEASE
|
-DRELEASE
|
||||||
|
|
|
@ -14,6 +14,10 @@
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(ETHERNET)
|
||||||
|
#include "../eth/ahoyeth.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "../utils/dbg.h"
|
#include "../utils/dbg.h"
|
||||||
#include "../config/config.h"
|
#include "../config/config.h"
|
||||||
#include <espMqttClient.h>
|
#include <espMqttClient.h>
|
||||||
|
|
|
@ -16,11 +16,7 @@
|
||||||
#include "../hm/hmSystem.h"
|
#include "../hm/hmSystem.h"
|
||||||
#include "../utils/helper.h"
|
#include "../utils/helper.h"
|
||||||
#include "AsyncJson.h"
|
#include "AsyncJson.h"
|
||||||
#if defined(ETHERNET)
|
|
||||||
#include "AsyncWebServer_ESP32_W5500.h"
|
|
||||||
#else
|
|
||||||
#include "ESPAsyncWebServer.h"
|
#include "ESPAsyncWebServer.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(F) && defined(ESP32)
|
#if defined(F) && defined(ESP32)
|
||||||
#undef F
|
#undef F
|
||||||
|
|
|
@ -16,11 +16,7 @@
|
||||||
#include "../appInterface.h"
|
#include "../appInterface.h"
|
||||||
#include "../hm/hmSystem.h"
|
#include "../hm/hmSystem.h"
|
||||||
#include "../utils/helper.h"
|
#include "../utils/helper.h"
|
||||||
#if defined(ETHERNET)
|
|
||||||
#include "AsyncWebServer_ESP32_W5500.h"
|
|
||||||
#else /* defined(ETHERNET) */
|
|
||||||
#include "ESPAsyncWebServer.h"
|
#include "ESPAsyncWebServer.h"
|
||||||
#endif /* defined(ETHERNET) */
|
|
||||||
#include "html/h/api_js.h"
|
#include "html/h/api_js.h"
|
||||||
#include "html/h/colorBright_css.h"
|
#include "html/h/colorBright_css.h"
|
||||||
#include "html/h/colorDark_css.h"
|
#include "html/h/colorDark_css.h"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue