Skip to content

Commit

Permalink
0.8.94
Browse files Browse the repository at this point in the history
* switched AsyncWebServer library
* Ethernet version now uses same AsyncWebServer library as Wifi version
* fix languange of `/history`
* fix RSSI on `/history` #1463
  • Loading branch information
lumapu committed Mar 16, 2024
1 parent 3d2ed81 commit 0499d32
Show file tree
Hide file tree
Showing 11 changed files with 105 additions and 211 deletions.
22 changes: 11 additions & 11 deletions patches/AsyncWeb_Prometheus.patch
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
diff --git a/src/AsyncWebSocket.cpp b/src/AsyncWebSocket.cpp
index 12be5f8..cffeed7 100644
index 6e88da9..09359c3 100644
--- a/src/AsyncWebSocket.cpp
+++ b/src/AsyncWebSocket.cpp
@@ -737,7 +737,7 @@ void AsyncWebSocketClient::binary(const __FlashStringHelper *data, size_t len)
IPAddress AsyncWebSocketClient::remoteIP() const
{
if (!_client)
- return IPAddress(0U);
+ return IPAddress();
@@ -827,7 +827,7 @@ void AsyncWebSocketClient::binary(AsyncWebSocketMessageBuffer * buffer)

IPAddress AsyncWebSocketClient::remoteIP() {
if(!_client) {
- return IPAddress((uint32_t)0);
+ return IPAddress();
}
return _client->remoteIP();
}
diff --git a/src/WebResponses.cpp b/src/WebResponses.cpp
index 22a549f..e0b36b3 100644
index a22e991..babef18 100644
--- a/src/WebResponses.cpp
+++ b/src/WebResponses.cpp
@@ -318,7 +318,7 @@ size_t AsyncAbstractResponse::_ack(AsyncWebServerRequest *request, size_t len, u
@@ -317,7 +317,7 @@ size_t AsyncAbstractResponse::_ack(AsyncWebServerRequest *request, size_t len, u
free(buf);
return 0;
}
- outLen = sprintf_P((char*)buf+headLen, PSTR("%x"), readLen) + headLen;
+ outLen = sprintf_P((char*)buf+headLen, PSTR("%04x"), readLen) + headLen;
- outLen = sprintf((char*)buf+headLen, "%x", readLen) + headLen;
+ outLen = sprintf((char*)buf+headLen, "%04x", readLen) + headLen;
while(outLen < headLen + 4) buf[outLen++] = ' ';
buf[outLen++] = '\r';
buf[outLen++] = '\n';
5 changes: 3 additions & 2 deletions scripts/applyPatches.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ def applyPatch(libName, patchFile):


# list of patches to apply (relative to /src)
if env['PIOENV'][:22] != "opendtufusion-ethernet":
applyPatch("ESP Async WebServer", "../patches/AsyncWeb_Prometheus.patch")
applyPatch("ESPAsyncWebServer-esphome", "../patches/AsyncWeb_Prometheus.patch")

if env['PIOENV'][:13] == "opendtufusion":
applyPatch("GxEPD2", "../patches/GxEPD2_SW_SPI.patch")

if (env['PIOENV'][:13] == "opendtufusion"): # or (env['PIOENV'][:13] == "esp32-wroom32"):
applyPatch("RF24", "../patches/RF24_Hal.patch")
6 changes: 6 additions & 0 deletions src/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Development Changes

## 0.8.94 - 2024-03-16
* switched AsyncWebServer library
* Ethernet version now uses same AsyncWebServer library as Wifi version
* fix languange of `/history`
* fix RSSI on `/history` #1463

## 0.8.93 - 2024-03-14
* improved history graph in WebUI #1491
* merge PR: 1491
Expand Down
2 changes: 1 addition & 1 deletion src/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//-------------------------------------
#define VERSION_MAJOR 0
#define VERSION_MINOR 8
#define VERSION_PATCH 93
#define VERSION_PATCH 94

//-------------------------------------
typedef struct {
Expand Down
182 changes: 45 additions & 137 deletions src/eth/ahoyeth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,7 @@ void ahoyeth::setup(settings_t *config, uint32_t *utcTimestamp, OnNetworkCB onNe
WiFi.onEvent([this](WiFiEvent_t event, arduino_event_info_t info) -> void { this->onEthernetEvent(event, info); });

Serial.flush();
//#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(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) {
IPAddress ip(mConfig->sys.ip.ip);
Expand All @@ -52,11 +47,6 @@ void ahoyeth::setup(settings_t *config, uint32_t *utcTimestamp, OnNetworkCB onNe

//-----------------------------------------------------------------------------
bool ahoyeth::updateNtpTime(void) {
DPRINTLN(DBG_DEBUG, F(__FUNCTION__)); Serial.flush();
Serial.printf("ETH.linkUp()=%s\n", ETH.linkUp() ? "up" : "down");
Serial.print("ETH.localIP()=");
Serial.println(ETH.localIP());
Serial.printf("Go on? %s\n", (!ETH.localIP()) ? "No..." : "Yes...");
if (!ETH.localIP())
return false;

Expand Down Expand Up @@ -134,137 +124,55 @@ void ahoyeth::welcome(String ip, String mode) {
void ahoyeth::onEthernetEvent(WiFiEvent_t event, arduino_event_info_t info) {
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
// Why so strange to define a breaking enum arduino_event_id_t in WiFiGeneric.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
case ARDUINO_EVENT_ETH_START:
DPRINTLN(DBG_INFO, F("\nETH Started"));
//set eth hostname here
if(String(mConfig->sys.deviceName) != "")
ETH.setHostname(mConfig->sys.deviceName);
else
ETH.setHostname("ESP32_W5500");
break;

case ARDUINO_EVENT_ETH_CONNECTED:
DPRINTLN(DBG_INFO, F("ETH Connected"));
break;

case ARDUINO_EVENT_ETH_GOT_IP:
if (!mEthConnected) {
DPRINT(DBG_INFO, F("ETH MAC: "));
#if defined (CONFIG_IDF_TARGET_ESP32S3)
DBGPRINT(mEthSpi.macAddress());
#else
DBGPRINT(ETH.macAddress());
#endif
DBGPRINT(F(", IPv4: "));
DBGPRINTLN(String(ETH.localIP()));

if (ETH.fullDuplex()) {
DPRINTLN(DBG_INFO, F("FULL_DUPLEX, "));
} else {
DPRINTLN(DBG_INFO, F("HALF_DUPLEX, "));
case ARDUINO_EVENT_ETH_START:
DPRINTLN(DBG_VERBOSE, F("ETH Started"));

if(String(mConfig->sys.deviceName) != "")
ETH.setHostname(mConfig->sys.deviceName);
else
ETH.setHostname(F("ESP32_W5500"));
break;

case ARDUINO_EVENT_ETH_CONNECTED:
DPRINTLN(DBG_VERBOSE, F("ETH Connected"));
break;

case ARDUINO_EVENT_ETH_GOT_IP:
if (!mEthConnected) {
/*DPRINT(DBG_INFO, F("ETH MAC: "));
DBGPRINT(mEthSpi.macAddress());*/
welcome(ETH.localIP().toString(), F(" (Station)"));

mEthConnected = true;
mOnNetworkCB(true);
}

DPRINT(DBG_INFO, String(ETH.linkSpeed()));
DBGPRINTLN(F("Mbps"));

mEthConnected = true;
mOnNetworkCB(true);
}
if (!MDNS.begin(mConfig->sys.deviceName)) {
DPRINTLN(DBG_ERROR, F("Error setting up MDNS responder!"));
} else {
DBGPRINT(F("[WiFi] mDNS established: "));
DBGPRINT(mConfig->sys.deviceName);
DBGPRINTLN(F(".local"));
}
break;

case ARDUINO_EVENT_ETH_DISCONNECTED:
DPRINTLN(DBG_INFO, "ETH Disconnected");
mEthConnected = false;
mUdp.close();
mOnNetworkCB(false);
break;

case ARDUINO_EVENT_ETH_STOP:
DPRINTLN(DBG_INFO, "\nETH Stopped");
mEthConnected = false;
mUdp.close();
mOnNetworkCB(false);
break;

#else

// For old core v1.0.6-
// Core v2.0.0 defines a stupid enum arduino_event_id_t, breaking any code for ESP32_W5500 written for previous core
// Why so strange to define a breaking enum arduino_event_id_t in WiFiGeneric.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
case SYSTEM_EVENT_ETH_START:
DPRINTLN(DBG_INFO, F("\nETH Started"));
//set eth hostname here
if(String(mConfig->sys.deviceName) != "")
ETH.setHostname(mConfig->sys.deviceName);
else
ETH.setHostname("ESP32_W5500");
break;

case SYSTEM_EVENT_ETH_CONNECTED:
DPRINTLN(DBG_INFO, F("ETH Connected"));
break;

case SYSTEM_EVENT_ETH_GOT_IP:
if (!ESP32_W5500_eth_connected) {
DPRINT(DBG_INFO, F("ETH MAC: "));
DBGPRINT(ETH.macAddress());
DBGPRINT(F(", IPv4: "));
DBGPRINTLN(ETH.localIP());

if (ETH.fullDuplex()) {
DPRINTLN(DBG_INFO, F("FULL_DUPLEX, "));
if (!MDNS.begin(mConfig->sys.deviceName)) {
DPRINTLN(DBG_ERROR, F("Error setting up MDNS responder!"));
} else {
DPRINTLN(DBG_INFO, F("HALF_DUPLEX, "));
DBGPRINT(F("mDNS established: "));
DBGPRINT(mConfig->sys.deviceName);
DBGPRINTLN(F(".local"));
}

DPRINT(DBG_INFO, ETH.linkSpeed());
DBGPRINTLN(F("Mbps"));

ESP32_W5500_eth_connected = true;
mOnNetworkCB(true);
}
if (!MDNS.begin(mConfig->sys.deviceName)) {
DPRINTLN(DBG_ERROR, F("Error setting up MDNS responder!"));
} else {
DBGPRINT(F("[WiFi] mDNS established: "));
DBGPRINT(mConfig->sys.deviceName);
DBGPRINTLN(F(".local"));
}
break;

case SYSTEM_EVENT_ETH_DISCONNECTED:
DPRINT(DBG_INFO, F("ETH Disconnected"));
ESP32_W5500_eth_connected = false;
mUdp.close();
mOnNetworkCB(false);
break;

case SYSTEM_EVENT_ETH_STOP:
DPRINT(DBG_INFO, F("ETH Stopped"));
ESP32_W5500_eth_connected = false;
mUdp.close();
mOnNetworkCB(false);
break;
#endif

default:

break;
}
break;

case ARDUINO_EVENT_ETH_DISCONNECTED:
DPRINTLN(DBG_INFO, F("ETH Disconnected"));
mEthConnected = false;
mUdp.close();
mOnNetworkCB(false);
break;

case ARDUINO_EVENT_ETH_STOP:
DPRINTLN(DBG_INFO, F("ETH Stopped"));
mEthConnected = false;
mUdp.close();
mOnNetworkCB(false);
break;

default:
break;
}

}

Expand Down
46 changes: 23 additions & 23 deletions src/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extra_scripts =
pre:../scripts/reduceGxEPD2.py

lib_deps =
https://github.com/yubox-node-org/ESPAsyncWebServer
https://github.com/esphome/ESPAsyncWebServer @ ^3.1.0
https://github.com/nRF24/RF24 @ 1.4.8
paulstoffregen/Time @ ^1.6.1
https://github.com/bertmelis/espMqttClient#v1.6.0
Expand Down Expand Up @@ -216,7 +216,7 @@ monitor_filters =
platform = espressif32
board = lolin_d32
build_flags = ${env.build_flags}
-D ETHERNET
-DETHERNET
-DRELEASE
-DUSE_HSPI_FOR_EPD
-DENABLE_MQTT
Expand All @@ -241,7 +241,7 @@ monitor_filters =
platform = espressif32
board = lolin_d32
build_flags = ${env.build_flags}
-D ETHERNET
-DETHERNET
-DRELEASE
-DUSE_HSPI_FOR_EPD
-DLANG_DE
Expand Down Expand Up @@ -436,16 +436,16 @@ monitor_filters =
[env:opendtufusion-ethernet]
platform = [email protected]
board = esp32-s3-devkitc-1
lib_deps =
khoih-prog/AsyncWebServer_ESP32_W5500
khoih-prog/AsyncUDP_ESP32_W5500
https://github.com/nrf24/RF24 @ ^1.4.8
paulstoffregen/Time @ ^1.6.1
https://github.com/bertmelis/espMqttClient#v1.6.0
bblanchon/ArduinoJson @ ^6.21.3
https://github.com/JChristensen/Timezone @ ^1.2.4
olikraus/U8g2 @ ^2.35.9
https://github.com/zinggjm/GxEPD2#1.5.3
#lib_deps =
# khoih-prog/AsyncWebServer_ESP32_W5500
# khoih-prog/AsyncUDP_ESP32_W5500
# https://github.com/nrf24/RF24 @ ^1.4.8
# paulstoffregen/Time @ ^1.6.1
# https://github.com/bertmelis/espMqttClient#v1.6.0
# bblanchon/ArduinoJson @ ^6.21.3
# https://github.com/JChristensen/Timezone @ ^1.2.4
# olikraus/U8g2 @ ^2.35.9
# https://github.com/zinggjm/GxEPD2#1.5.3
upload_protocol = esp-builtin
build_flags = ${env.build_flags}
-DETHERNET
Expand Down Expand Up @@ -481,16 +481,16 @@ monitor_filters =
[env:opendtufusion-ethernet-de]
platform = [email protected]
board = esp32-s3-devkitc-1
lib_deps =
khoih-prog/AsyncWebServer_ESP32_W5500
khoih-prog/AsyncUDP_ESP32_W5500
https://github.com/nrf24/RF24 @ ^1.4.8
paulstoffregen/Time @ ^1.6.1
https://github.com/bertmelis/espMqttClient#v1.6.0
bblanchon/ArduinoJson @ ^6.21.3
https://github.com/JChristensen/Timezone @ ^1.2.4
olikraus/U8g2 @ ^2.35.9
https://github.com/zinggjm/GxEPD2#1.5.3
#lib_deps =
# khoih-prog/AsyncWebServer_ESP32_W5500
# khoih-prog/AsyncUDP_ESP32_W5500
# https://github.com/nrf24/RF24 @ ^1.4.8
# paulstoffregen/Time @ ^1.6.1
# https://github.com/bertmelis/espMqttClient#v1.6.0
# bblanchon/ArduinoJson @ ^6.21.3
# https://github.com/JChristensen/Timezone @ ^1.2.4
# olikraus/U8g2 @ ^2.35.9
# https://github.com/zinggjm/GxEPD2#1.5.3
upload_protocol = esp-builtin
build_flags = ${env.build_flags}
-DETHERNET
Expand Down
Loading

0 comments on commit 0499d32

Please sign in to comment.