make network hardware selectable
This commit is contained in:
@@ -6,9 +6,10 @@
|
||||
#include "../Logger.h"
|
||||
#include "../MqttTopics.h"
|
||||
|
||||
W5500Device::W5500Device(const String &hostname, Preferences* preferences)
|
||||
W5500Device::W5500Device(const String &hostname, Preferences* preferences, int variant)
|
||||
: NetworkDevice(hostname),
|
||||
_preferences(preferences)
|
||||
_preferences(preferences),
|
||||
_variant((W5500Variant)variant)
|
||||
{
|
||||
initializeMacAddress(_mac);
|
||||
|
||||
@@ -37,7 +38,15 @@ void W5500Device::initialize()
|
||||
|
||||
resetDevice();
|
||||
|
||||
Ethernet.init(ETHERNET_CS_PIN, ETHERNET_SCK_PIN, ETHERNET_MISO_PIN, ETHERNET_MOSI_PIN);
|
||||
switch(_variant)
|
||||
{
|
||||
case W5500Variant::M5StackAtomPoe:
|
||||
Ethernet.init(ETHERNET_CS_PIN, 22, 23, 33);
|
||||
break;
|
||||
default:
|
||||
Ethernet.init(ETHERNET_CS_PIN);
|
||||
break;
|
||||
}
|
||||
|
||||
if(_preferences->getBool(preference_mqtt_log_enabled))
|
||||
{
|
||||
|
||||
@@ -6,10 +6,16 @@
|
||||
#include <Ethernet.h>
|
||||
#include <Preferences.h>
|
||||
|
||||
enum class W5500Variant
|
||||
{
|
||||
Generic = 1,
|
||||
M5StackAtomPoe = 2
|
||||
};
|
||||
|
||||
class W5500Device : public NetworkDevice
|
||||
{
|
||||
public:
|
||||
explicit W5500Device(const String& hostname, Preferences* _preferences);
|
||||
explicit W5500Device(const String& hostname, Preferences* _preferences, int variant);
|
||||
~W5500Device();
|
||||
|
||||
virtual void initialize();
|
||||
@@ -61,6 +67,7 @@ private:
|
||||
int _maintainResult = 0;
|
||||
bool _hasDHCPAddress = false;
|
||||
char* _path;
|
||||
W5500Variant _variant;
|
||||
|
||||
byte _mac[6];
|
||||
};
|
||||
Reference in New Issue
Block a user