apply selected hardware
This commit is contained in:
12
Network.cpp
12
Network.cpp
@@ -32,6 +32,9 @@ void Network::setupDevice()
|
|||||||
int hardwareDetect = _preferences->getInt(preference_network_hardware);
|
int hardwareDetect = _preferences->getInt(preference_network_hardware);
|
||||||
int hardwareDetectGpio = _preferences->getInt(preference_network_hardware_gpio);
|
int hardwareDetectGpio = _preferences->getInt(preference_network_hardware_gpio);
|
||||||
|
|
||||||
|
Log->print("Hardware detect : "); Log->println(hardwareDetect);
|
||||||
|
Log->print("Hardware detect GPIO: "); Log->println(hardwareDetectGpio);
|
||||||
|
|
||||||
if(strcmp(WiFi_fallbackDetect, "wifi_fallback") == 0)
|
if(strcmp(WiFi_fallbackDetect, "wifi_fallback") == 0)
|
||||||
{
|
{
|
||||||
Log->println(F("Switching to WiFi device as fallback."));
|
Log->println(F("Switching to WiFi device as fallback."));
|
||||||
@@ -56,14 +59,19 @@ void Network::setupDevice()
|
|||||||
Log->print(hardwareDetectGpio);
|
Log->print(hardwareDetectGpio);
|
||||||
Log->println(F(" for network device selection"));
|
Log->println(F(" for network device selection"));
|
||||||
|
|
||||||
pinMode(hardwareDetect, INPUT_PULLUP);
|
pinMode(hardwareDetectGpio, INPUT_PULLUP);
|
||||||
_networkDeviceType = digitalRead(hardwareDetect) == HIGH ? NetworkDeviceType::WiFi : NetworkDeviceType::W5500;
|
_networkDeviceType = digitalRead(hardwareDetectGpio) == HIGH ? NetworkDeviceType::WiFi : NetworkDeviceType::W5500;
|
||||||
}
|
}
|
||||||
else if(hardwareDetect == 2)
|
else if(hardwareDetect == 2)
|
||||||
{
|
{
|
||||||
Log->print(F("W5500 on M5Sack Atom POE"));
|
Log->print(F("W5500 on M5Sack Atom POE"));
|
||||||
_networkDeviceType = NetworkDeviceType::W5500;
|
_networkDeviceType = NetworkDeviceType::W5500;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log->println(F("Unknown hardware selected, falling back to Wifi."));
|
||||||
|
_networkDeviceType = NetworkDeviceType::WiFi;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(_networkDeviceType)
|
switch(_networkDeviceType)
|
||||||
|
|||||||
2
Pins.h
2
Pins.h
@@ -1,7 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define ETHERNET_CS_PIN 19
|
|
||||||
#define ETHERNET_RESET_PIN -1
|
|
||||||
#define TRIGGER_LOCK_PIN 32
|
#define TRIGGER_LOCK_PIN 32
|
||||||
#define TRIGGER_UNLOCK_PIN 33
|
#define TRIGGER_UNLOCK_PIN 33
|
||||||
#define TRIGGER_UNLATCH_PIN 27
|
#define TRIGGER_UNLATCH_PIN 27
|
||||||
|
|||||||
@@ -41,10 +41,12 @@ void W5500Device::initialize()
|
|||||||
switch(_variant)
|
switch(_variant)
|
||||||
{
|
{
|
||||||
case W5500Variant::M5StackAtomPoe:
|
case W5500Variant::M5StackAtomPoe:
|
||||||
Ethernet.init(ETHERNET_CS_PIN, 22, 23, 33);
|
_resetPin = -1;
|
||||||
|
Ethernet.init(19, 22, 23, 33);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Ethernet.init(ETHERNET_CS_PIN);
|
_resetPin = -1;
|
||||||
|
Ethernet.init(5);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,14 +134,15 @@ void W5500Device::reconfigure()
|
|||||||
|
|
||||||
void W5500Device::resetDevice()
|
void W5500Device::resetDevice()
|
||||||
{
|
{
|
||||||
if(ETHERNET_RESET_PIN == -1) return;
|
if(_resetPin == -1) return;
|
||||||
|
|
||||||
Log->println(F("Resetting network hardware."));
|
Log->println(F("Resetting network hardware."));
|
||||||
pinMode(ETHERNET_RESET_PIN, OUTPUT);
|
pinMode(_resetPin, OUTPUT);
|
||||||
digitalWrite(ETHERNET_RESET_PIN, HIGH);
|
digitalWrite(_resetPin, HIGH);
|
||||||
delay(250);
|
delay(250);
|
||||||
digitalWrite(ETHERNET_RESET_PIN, LOW);
|
digitalWrite(_resetPin, LOW);
|
||||||
delay(50);
|
delay(50);
|
||||||
digitalWrite(ETHERNET_RESET_PIN, HIGH);
|
digitalWrite(_resetPin, HIGH);
|
||||||
delay(1500);
|
delay(1500);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ private:
|
|||||||
Preferences* _preferences = nullptr;
|
Preferences* _preferences = nullptr;
|
||||||
|
|
||||||
int _maintainResult = 0;
|
int _maintainResult = 0;
|
||||||
|
int _resetPin = -1;
|
||||||
bool _hasDHCPAddress = false;
|
bool _hasDHCPAddress = false;
|
||||||
char* _path;
|
char* _path;
|
||||||
W5500Variant _variant;
|
W5500Variant _variant;
|
||||||
|
|||||||
Reference in New Issue
Block a user