From c2ce5a151dcabab881221a843079182b87370bfa Mon Sep 17 00:00:00 2001 From: technyon Date: Fri, 7 Apr 2023 19:03:20 +0200 Subject: [PATCH] make wifi default network device, remove W5500 GPIO detection --- Gpio.cpp | 7 ------- Network.cpp | 17 +++-------------- PreferencesKeys.h | 3 +-- README.md | 5 ++--- WebCfgServer.cpp | 22 +--------------------- WebCfgServer.h | 1 - 6 files changed, 7 insertions(+), 48 deletions(-) diff --git a/Gpio.cpp b/Gpio.cpp index df2099d..90e961c 100644 --- a/Gpio.cpp +++ b/Gpio.cpp @@ -129,13 +129,6 @@ void Gpio::savePinConfiguration(const std::vector &pinConfiguration) } } - for(int8_t v : serialized) - { - Serial.print((int)v); - Serial.print(" "); - } - Serial.println(); - _preferences->putBytes(preference_gpio_configuration, serialized, sizeof(serialized)); } diff --git a/Network.cpp b/Network.cpp index 690ee56..4156a88 100644 --- a/Network.cpp +++ b/Network.cpp @@ -46,21 +46,14 @@ void Network::setupDevice() _ipConfiguration = new IPConfiguration(_preferences); int hardwareDetect = _preferences->getInt(preference_network_hardware); - int hardwareDetectGpio = _preferences->getInt(preference_network_hardware_gpio); Log->print(F("Hardware detect : ")); Log->println(hardwareDetect); - Log->print(F("Hardware detect GPIO: ")); Log->println(hardwareDetectGpio); if(hardwareDetect == 0) { - hardwareDetect = 2; + hardwareDetect = 1; _preferences->putInt(preference_network_hardware, hardwareDetect); } - if(hardwareDetectGpio == 0) - { - hardwareDetectGpio = 26; - _preferences->putInt(preference_network_hardware_gpio, hardwareDetectGpio); - } if(strcmp(WiFi_fallbackDetect, "wifi_fallback") == 0) { @@ -77,12 +70,8 @@ void Network::setupDevice() _networkDeviceType = NetworkDeviceType::WiFi; break; case 2: - Log->print(F("Using PIN ")); - Log->print(hardwareDetectGpio); - Log->println(F(" for network device selection")); - - pinMode(hardwareDetectGpio, INPUT_PULLUP); - _networkDeviceType = digitalRead(hardwareDetectGpio) == HIGH ? NetworkDeviceType::WiFi : NetworkDeviceType::W5500; + Log->print(F("Generic W5500")); + _networkDeviceType = NetworkDeviceType::W5500; break; case 3: Log->println(F("W5500 on M5Stack Atom POE")); diff --git a/PreferencesKeys.h b/PreferencesKeys.h index ca6c3aa..81009e1 100644 --- a/PreferencesKeys.h +++ b/PreferencesKeys.h @@ -25,7 +25,6 @@ #define preference_ip_gateway "ipgtw" #define preference_ip_dns_server "dnssrv" #define preference_network_hardware "nwhw" -#define preference_network_hardware_gpio "nwhwdt" #define preference_rssi_publish_interval "rssipb" #define preference_hostname "hostname" #define preference_network_timeout "nettmout" @@ -63,7 +62,7 @@ private: preference_lock_max_keypad_code_count, preference_opener_max_keypad_code_count, preference_mqtt_ca, preference_mqtt_crt, preference_mqtt_key, preference_mqtt_hass_discovery, preference_ip_dhcp_enabled, preference_ip_address, preference_ip_subnet, preference_ip_gateway, preference_ip_dns_server, - preference_network_hardware, preference_network_hardware_gpio, preference_rssi_publish_interval, + preference_network_hardware, preference_rssi_publish_interval, preference_hostname, preference_network_timeout, preference_restart_on_disconnect, preference_restart_timer, preference_restart_ble_beacon_lost, preference_query_interval_lockstate, preference_query_interval_configuration, preference_query_interval_battery, preference_query_interval_keypad, diff --git a/README.md b/README.md index 58b1506..9b411d2 100644 --- a/README.md +++ b/README.md @@ -198,11 +198,10 @@ W5x00 SCK to GPIO18
W5x00 MISO to GPIOGPIO19
W5x00 MOSI to GPIO23
W5x00 CS/SS to GPIO5 -- Additionally connect:
+- Optionally connect:
W5x00 reset to GPIO33 -- Last but not least, on the ESP32 bridge GPIO26 and GND. This let's the firmware know that a LAN Module is connected -Wifi is now disabled, and the module doesn't boot into WifiManager anymore.
+Now connect via Wifi and change the network hardware to "Generic W5500". If the W5500 hwardware isn't detected, Wifi is used as a fallback.
Note: Encrypted MQTT is only available for Wifi and LAN8720 modules, W5x00 modules don't support encryption (that leaves Olimex, WT32-ETH01 and M5Stack PoESP32 Unit if encryption is desired). If encryption is needed, Olimex is the easiest option, since it has USB for flashing onboard. diff --git a/WebCfgServer.cpp b/WebCfgServer.cpp index 044f7c9..0e14c58 100644 --- a/WebCfgServer.cpp +++ b/WebCfgServer.cpp @@ -324,11 +324,6 @@ bool WebCfgServer::processArgs(String& message) _preferences->putInt(preference_network_hardware, value.toInt()); configChanged = true; } - else if(key == "NWHWDT") - { - _preferences->putInt(preference_network_hardware_gpio, value.toInt()); - configChanged = true; - } else if(key == "RSSI") { _preferences->putInt(preference_rssi_publish_interval, value.toInt()); @@ -763,7 +758,6 @@ void WebCfgServer::buildMqttConfigHtml(String &response) printTextarea(response, "MQTTCRT", "MQTT SSL Client Certificate (*, optional)", _preferences->getString(preference_mqtt_crt).c_str(), TLS_CERT_MAX_SIZE, _network->encryptionSupported(), true); printTextarea(response, "MQTTKEY", "MQTT SSL Client Key (*, optional)", _preferences->getString(preference_mqtt_key).c_str(), TLS_KEY_MAX_SIZE, _network->encryptionSupported(), true); printDropDown(response, "NWHW", "Network hardware", String(_preferences->getInt(preference_network_hardware)), getNetworkDetectionOptions()); - printDropDown(response, "NWHWDT", "Network hardware detection", String(_preferences->getInt(preference_network_hardware_gpio)), getNetworkGpioOptions()); printInputField(response, "RSSI", "RSSI Publish interval (seconds; -1 to disable)", _preferences->getInt(preference_rssi_publish_interval), 6); printInputField(response, "NETTIMEOUT", "Network Timeout until restart (seconds; -1 to disable)", _preferences->getInt(preference_network_timeout), 5); printCheckBox(response, "RSTDISC", "Restart on disconnect", _preferences->getBool(preference_restart_on_disconnect)); @@ -1275,7 +1269,7 @@ const std::vector> WebCfgServer::getNetworkDetectionOp std::vector> options; options.push_back(std::make_pair("1", "Wifi only")); - options.push_back(std::make_pair("2", "Detect W5500 (GPIO CS=5; SCK=18; MISO=19; MOSI=23; RST=33)")); + options.push_back(std::make_pair("2", "Generic W5500")); options.push_back(std::make_pair("3", "M5Stack Atom POE (W5500)")); options.push_back(std::make_pair("4", "Olimex ESP32-POE / ESP-POE-ISO")); options.push_back(std::make_pair("5", "WT32-ETH01")); @@ -1285,20 +1279,6 @@ const std::vector> WebCfgServer::getNetworkDetectionOp return options; } -const std::vector> WebCfgServer::getNetworkGpioOptions() const -{ - std::vector> options; - - for(int i=16; i <= 33; i++) - { - String txt = "Detect W5500 via GPIO "; - txt.concat(i); - options.push_back(std::make_pair(String(i), txt)); - } - - return options; -} - const std::vector> WebCfgServer::getGpioOptions() const { std::vector> options; diff --git a/WebCfgServer.h b/WebCfgServer.h index a7ad107..4a3b5d7 100644 --- a/WebCfgServer.h +++ b/WebCfgServer.h @@ -59,7 +59,6 @@ private: void buildNavigationButton(String& response, const char* caption, const char* targetPath, const char* labelText = ""); const std::vector> getNetworkDetectionOptions() const; - const std::vector> getNetworkGpioOptions() const; const std::vector> getGpioOptions() const; String getPreselectionForGpio(const uint8_t& pin);