Remove old and modified libs, switch to ESPAsyncWebserver, add support for ESP32-H2 and multiple Ethernet modules (#455)

* Asyncwebserver

* Squashed commit of the following:

commit 575ef02f593918ec6654c87407a4d11fc17071b8
Author: technyon <j.o.schuemann@gmx.de>
Date:   Mon Aug 12 17:56:11 2024 +0200

    merge master

commit 35e5adf4ecd80f9829e8801181f35dd2c1d94759
Merge: a2cc7be2 21adca01
Author: technyon <j.o.schuemann@gmx.de>
Date:   Mon Aug 12 17:41:04 2024 +0200

    Merge branch 'master' of github.com:technyon/nuki_hub into DM9051

commit a2cc7be2954cbd8767ab8186296c0b14134d1d0b
Author: technyon <j.o.schuemann@gmx.de>
Date:   Mon Aug 12 10:51:50 2024 +0200

    update nuki ble

commit 20c809f3dca28b29b219d1ff3a183f1981316de5
Author: technyon <j.o.schuemann@gmx.de>
Date:   Mon Aug 12 10:44:46 2024 +0200

    backup

commit dd41c218efb5270f5efeb734e64dff695920db16
Merge: 153000b5 e84b944a
Author: technyon <j.o.schuemann@gmx.de>
Date:   Mon Aug 12 10:40:03 2024 +0200

    Merge branch 'master' of github.com:technyon/nuki_hub into DM9051

commit 153000b5b1af7df1fbeb5263df94eb26f689cc0a
Author: technyon <j.o.schuemann@gmx.de>
Date:   Mon Aug 12 10:23:07 2024 +0200

    fix linker error

commit a93bbfbfc4301e46ff3696a763dd13c6c89efefb
Author: technyon <j.o.schuemann@gmx.de>
Date:   Sun Aug 11 11:27:07 2024 +0200

    backup

commit f611c75ce8c35f829bcad6cf7e86188f4b3ec331
Merge: f1964917 063fbab6
Author: technyon <j.o.schuemann@gmx.de>
Date:   Sun Aug 11 11:24:47 2024 +0200

    merge master

commit f1964917b4dade3920f1ecdb699c58630199e6da
Author: technyon <j.o.schuemann@gmx.de>
Date:   Sat Aug 10 15:17:45 2024 +0200

    update platformio.ini

commit f448e5e8a7e93be38e09e2ab0b622199a3721af6
Author: technyon <j.o.schuemann@gmx.de>
Date:   Sat Aug 10 11:28:09 2024 +0200

    add SPIClass instance for DM9051

commit 1f190e9aa08033535a2eb442a92e6e20409bbda1
Author: technyon <j.o.schuemann@gmx.de>
Date:   Sat Aug 10 11:22:26 2024 +0200

    add definitions and constructor for DM9051

commit 726b3602ae91594ee1210ad5b6714f75cc5e42a7
Merge: 50a2eb13 4af90cbc
Author: technyon <j.o.schuemann@gmx.de>
Date:   Sat Aug 10 10:19:34 2024 +0200

    merge master

commit 50a2eb136d75d90921f1c6974f18bc107bddc123
Author: technyon <j.o.schuemann@gmx.de>
Date:   Fri Aug 9 11:52:09 2024 +0200

    add comment

commit 9437e485cae169efdf8e5a7bf188a1c7e792d1e5
Author: technyon <j.o.schuemann@gmx.de>
Date:   Sun Aug 4 08:29:21 2024 +0200

    move LAN8720 definitions to seperate file

* Remove Core 2 Ethernet library

* Custom Ethernet

* GPIO and Preferences

* H2
This commit is contained in:
iranl
2024-08-16 13:02:37 +02:00
committed by GitHub
parent 346c5c65d1
commit 9a896a7ab1
206 changed files with 4055 additions and 20829 deletions

View File

@@ -1,8 +1,11 @@
#pragma once
#include <Preferences.h>
#include <WebServer.h>
#include "Ota.h"
#include <AsyncTCP.h>
#include <DNSServer.h>
#include <ESPAsyncWebServer.h>
#include "esp_ota_ops.h"
#include "Config.h"
#ifndef NUKI_HUB_UPDATER
#include "NukiWrapper.h"
@@ -34,72 +37,82 @@ class WebCfgServer
{
public:
#ifndef NUKI_HUB_UPDATER
WebCfgServer(NukiWrapper* nuki, NukiOpenerWrapper* nukiOpener, NukiNetwork* network, Gpio* gpio, EthServer* ethServer, Preferences* preferences, bool allowRestartToPortal, uint8_t partitionType);
WebCfgServer(NukiWrapper* nuki, NukiOpenerWrapper* nukiOpener, NukiNetwork* network, Gpio* gpio, Preferences* preferences, bool allowRestartToPortal, uint8_t partitionType, AsyncWebServer* asyncServer);
#else
WebCfgServer(NukiNetwork* network, EthServer* ethServer, Preferences* preferences, bool allowRestartToPortal, uint8_t partitionType);
WebCfgServer(NukiNetwork* network, Preferences* preferences, bool allowRestartToPortal, uint8_t partitionType, AsyncWebServer* asyncServer);
#endif
~WebCfgServer() = default;
void initialize();
void update();
private:
#ifndef NUKI_HUB_UPDATER
void sendSettings();
bool processArgs(String& message);
bool processImport(String& message);
void processGpioArgs();
void buildHtml();
void buildAccLvlHtml();
void buildCredHtml();
void buildImportExportHtml();
void buildMqttConfigHtml();
void buildStatusHtml();
void buildAdvancedConfigHtml();
void buildNukiConfigHtml();
void buildGpioConfigHtml();
void buildConfigureWifiHtml();
void buildInfoHtml();
void processUnpair(bool opener);
void processUpdate();
void processFactoryReset();
void printInputField(const char* token, const char* description, const char* value, const size_t& maxLength, const char* id, const bool& isPassword = false, const bool& showLengthRestriction = false);
void printInputField(const char* token, const char* description, const int value, size_t maxLength, const char* id);
void printCheckBox(const char* token, const char* description, const bool value, const char* htmlClass);
void printTextarea(const char *token, const char *description, const char *value, const size_t& maxLength, const bool& enabled = true, const bool& showLengthRestriction = false);
void printDropDown(const char *token, const char *description, const String preselectedValue, std::vector<std::pair<String, String>> options);
void buildNavigationButton(const char* caption, const char* targetPath, const char* labelText = "");
void buildNavigationMenuEntry(const char *title, const char *targetPath, const char* warningMessage = "");
void sendSettings(AsyncWebServerRequest *request);
bool processArgs(AsyncWebServerRequest *request, String& message);
bool processImport(AsyncWebServerRequest *request, String& message);
void processGpioArgs(AsyncWebServerRequest *request);
void buildHtml(AsyncWebServerRequest *request);
void buildAccLvlHtml(AsyncWebServerRequest *request, int aclPart = 0);
void buildCredHtml(AsyncWebServerRequest *request);
void buildImportExportHtml(AsyncWebServerRequest *request);
void buildMqttConfigHtml(AsyncWebServerRequest *request);
void buildStatusHtml(AsyncWebServerRequest *request);
void buildAdvancedConfigHtml(AsyncWebServerRequest *request);
void buildNukiConfigHtml(AsyncWebServerRequest *request);
void buildGpioConfigHtml(AsyncWebServerRequest *request);
#ifndef CONFIG_IDF_TARGET_ESP32H2
void buildConfigureWifiHtml(AsyncWebServerRequest *request);
#endif
void buildInfoHtml(AsyncWebServerRequest *request);
void buildCustomNetworkConfigHtml(AsyncWebServerRequest *request);
void processUnpair(AsyncWebServerRequest *request, bool opener);
void processUpdate(AsyncWebServerRequest *request);
void processFactoryReset(AsyncWebServerRequest *request);
void printInputField(AsyncResponseStream *response, const char* token, const char* description, const char* value, const size_t& maxLength, const char* id, const bool& isPassword = false, const bool& showLengthRestriction = false);
void printInputField(AsyncResponseStream *response, const char* token, const char* description, const int value, size_t maxLength, const char* id);
void printCheckBox(AsyncResponseStream *response, const char* token, const char* description, const bool value, const char* htmlClass);
void printCheckBox(String &partString, const char* token, const char* description, const bool value, const char* htmlClass);
void printTextarea(AsyncResponseStream *response, const char *token, const char *description, const char *value, const size_t& maxLength, const bool& enabled = true, const bool& showLengthRestriction = false);
void printDropDown(AsyncResponseStream *response, const char *token, const char *description, const String preselectedValue, std::vector<std::pair<String, String>> options, const String className);
void buildNavigationButton(AsyncResponseStream *response, const char* caption, const char* targetPath, const char* labelText = "");
void buildNavigationMenuEntry(AsyncResponseStream *response, const char *title, const char *targetPath, const char* warningMessage = "");
void partAccLvlHtml(String &partString, int aclPart);
const std::vector<std::pair<String, String>> getNetworkDetectionOptions() const;
const std::vector<std::pair<String, String>> getGpioOptions() const;
const std::vector<std::pair<String, String>> getNetworkCustomPHYOptions() const;
#if defined(CONFIG_IDF_TARGET_ESP32)
const std::vector<std::pair<String, String>> getNetworkCustomCLKOptions() const;
#endif
String getPreselectionForGpio(const uint8_t& pin);
String pinStateToString(uint8_t value);
void printParameter(const char* description, const char* value, const char *link = "", const char *id = "");
void printParameter(AsyncResponseStream *response, const char* description, const char* value, const char *link = "", const char *id = "");
NukiWrapper* _nuki = nullptr;
NukiOpenerWrapper* _nukiOpener = nullptr;
Gpio* _gpio = nullptr;
bool _pinsConfigured = false;
bool _brokerConfigured = false;
bool _rebootRequired = false;
#endif
String generateConfirmCode();
String _confirmCode = "----";
void buildConfirmHtml(const String &message, uint32_t redirectDelay = 5, bool redirect = false);
void buildOtaHtml(bool errored, bool debug = false);
void buildOtaCompletedHtml();
void sendCss();
void sendFavicon();
void buildHtmlHeader(String additionalHeader = "");
void buildConfirmHtml(AsyncWebServerRequest *request, const String &message, uint32_t redirectDelay = 5, bool redirect = false);
void buildOtaHtml(AsyncWebServerRequest *request, bool debug = false);
void buildOtaCompletedHtml(AsyncWebServerRequest *request);
void sendCss(AsyncWebServerRequest *request);
void sendFavicon(AsyncWebServerRequest *request);
void buildHtmlHeader(AsyncResponseStream *response, String additionalHeader = "");
void waitAndProcess(const bool blocking, const uint32_t duration);
void handleOtaUpload();
WebServer _server;
void handleOtaUpload(AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final);
void printProgress(size_t prg, size_t sz);
AsyncWebServer* _asyncServer = nullptr;
NukiNetwork* _network = nullptr;
Preferences* _preferences = nullptr;
Ota _ota;
bool _hasCredentials = false;
char _credUser[31] = {0};
@@ -108,7 +121,7 @@ private:
uint8_t _partitionType = 0;
uint32_t _transferredSize = 0;
int64_t _otaStartTs = 0;
size_t _otaContentLen = 0;
String _hostname;
String _response;
bool _enabled = true;
};