|
@ -22,7 +22,7 @@ class AhoyEthernet : public AhoyWifi { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
public: |
|
|
public: |
|
|
void begin() override { |
|
|
virtual void begin() override { |
|
|
mMode = Mode::WIRELESS; |
|
|
mMode = Mode::WIRELESS; |
|
|
mAp.enable(); |
|
|
mAp.enable(); |
|
|
AhoyWifi::begin(); |
|
|
AhoyWifi::begin(); |
|
@ -34,31 +34,32 @@ class AhoyEthernet : public AhoyWifi { |
|
|
ETH.setHostname(mConfig->sys.deviceName); |
|
|
ETH.setHostname(mConfig->sys.deviceName); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
String getIp(void) { |
|
|
virtual String getIp(void) override { |
|
|
if(Mode::WIRELESS == mMode) |
|
|
if(Mode::WIRELESS == mMode) |
|
|
return AhoyWifi::getIp(); |
|
|
return AhoyWifi::getIp(); |
|
|
else |
|
|
else |
|
|
return ETH.localIP().toString(); |
|
|
return ETH.localIP().toString(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
String getMac(void) { |
|
|
virtual String getMac(void) override { |
|
|
if(Mode::WIRELESS == mMode) |
|
|
if(Mode::WIRELESS == mMode) |
|
|
return AhoyWifi::getMac(); |
|
|
return AhoyWifi::getMac(); |
|
|
else |
|
|
else |
|
|
return ETH.macAddress(); |
|
|
return mEthSpi.macAddress(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bool isWiredConnection() { |
|
|
virtual bool isWiredConnection() override { |
|
|
return (Mode::WIRED == mMode); |
|
|
return (Mode::WIRED == mMode); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private: |
|
|
private: |
|
|
void OnEvent(WiFiEvent_t event) { |
|
|
virtual void OnEvent(WiFiEvent_t event) override { |
|
|
switch(event) { |
|
|
switch(event) { |
|
|
|
|
|
case ARDUINO_EVENT_ETH_CONNECTED: |
|
|
|
|
|
mMode = Mode::WIRED; // needed for static IP
|
|
|
|
|
|
[[fallthrough]]; |
|
|
case SYSTEM_EVENT_STA_CONNECTED: |
|
|
case SYSTEM_EVENT_STA_CONNECTED: |
|
|
mWifiConnecting = false; |
|
|
mWifiConnecting = false; |
|
|
[[fallthrough]]; |
|
|
|
|
|
case ARDUINO_EVENT_ETH_CONNECTED: |
|
|
|
|
|
if(NetworkState::CONNECTED != mStatus) { |
|
|
if(NetworkState::CONNECTED != mStatus) { |
|
|
if(ARDUINO_EVENT_ETH_CONNECTED == event) |
|
|
if(ARDUINO_EVENT_ETH_CONNECTED == event) |
|
|
WiFi.disconnect(); |
|
|
WiFi.disconnect(); |
|
|