From d4bf7b0d7ecc70434abde315ae4b61381c6e8fb7 Mon Sep 17 00:00:00 2001 From: technyon Date: Fri, 3 Feb 2023 21:06:14 +0100 Subject: [PATCH] default network hardware to detect w5000 --- Network.cpp | 23 ++++++++++++++--------- WebCfgServer.cpp | 6 +++--- networkDevices/W5500Device.h | 4 ++-- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Network.cpp b/Network.cpp index 5c9d5db..8403ce0 100644 --- a/Network.cpp +++ b/Network.cpp @@ -35,6 +35,17 @@ void Network::setupDevice() Log->print("Hardware detect : "); Log->println(hardwareDetect); Log->print("Hardware detect GPIO: "); Log->println(hardwareDetectGpio); + if(hardwareDetect == 0) + { + hardwareDetect = 2; + _preferences->putInt(preference_network_hardware_gpio, hardwareDetect); + } + if(hardwareDetectGpio == 0) + { + hardwareDetectGpio = 26; + _preferences->putInt(preference_network_hardware_gpio, hardwareDetectGpio); + } + if(strcmp(WiFi_fallbackDetect, "wifi_fallback") == 0) { Log->println(F("Switching to WiFi device as fallback.")); @@ -42,18 +53,12 @@ void Network::setupDevice() } else { - if(hardwareDetectGpio == 0) - { - hardwareDetectGpio = 26; - _preferences->putInt(preference_network_hardware_gpio, hardwareDetectGpio); - } - - if(hardwareDetect == 0) + if(hardwareDetect == 1) { Log->println(F("W5500 hardware is disabled, using Wifi.")); _networkDeviceType = NetworkDeviceType::WiFi; } - else if(hardwareDetect == 1) + else if(hardwareDetect == 2) { Log->print(F("Using PIN ")); Log->print(hardwareDetectGpio); @@ -62,7 +67,7 @@ void Network::setupDevice() pinMode(hardwareDetectGpio, INPUT_PULLUP); _networkDeviceType = digitalRead(hardwareDetectGpio) == HIGH ? NetworkDeviceType::WiFi : NetworkDeviceType::W5500; } - else if(hardwareDetect == 2) + else if(hardwareDetect == 3) { Log->print(F("W5500 on M5Sack Atom POE")); _networkDeviceType = NetworkDeviceType::W5500; diff --git a/WebCfgServer.cpp b/WebCfgServer.cpp index 3a0f22d..a7af4a9 100644 --- a/WebCfgServer.cpp +++ b/WebCfgServer.cpp @@ -962,9 +962,9 @@ const std::vector> WebCfgServer::getNetworkDetectionOp { std::vector> options; - options.push_back(std::make_pair("0", "Disable W5500 (Wifi only)")); - options.push_back(std::make_pair("1", "W5500 (GPIO CS=5; SCK=18; MISO=19; MOSI=23; RST=33)")); - options.push_back(std::make_pair("2", "M5Stack Atom POE (W5500)")); + options.push_back(std::make_pair("1", "Disable W5500 (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("3", "M5Stack Atom POE (W5500)")); return options; } diff --git a/networkDevices/W5500Device.h b/networkDevices/W5500Device.h index 98dddb8..a86fb06 100644 --- a/networkDevices/W5500Device.h +++ b/networkDevices/W5500Device.h @@ -8,8 +8,8 @@ enum class W5500Variant { - Generic = 1, - M5StackAtomPoe = 2 + Generic = 2, + M5StackAtomPoe = 3 }; class W5500Device : public NetworkDevice