diff --git a/src/ConnectionHandlerInterface.h b/src/ConnectionHandlerInterface.h index 6af40d47..251a1570 100644 --- a/src/ConnectionHandlerInterface.h +++ b/src/ConnectionHandlerInterface.h @@ -101,6 +101,11 @@ class ConnectionHandler { return false; } + virtual void getSetting(models::NetworkSetting& s) { + memcpy(&s, &_settings, sizeof(s)); + return; + } + virtual void setKeepAlive(bool keep_alive=true) { this->_keep_alive = keep_alive; } protected: diff --git a/src/EthernetConnectionHandler.cpp b/src/EthernetConnectionHandler.cpp index 6e730381..2cc1d51b 100644 --- a/src/EthernetConnectionHandler.cpp +++ b/src/EthernetConnectionHandler.cpp @@ -41,6 +41,7 @@ EthernetConnectionHandler::EthernetConnectionHandler( bool const keep_alive) : ConnectionHandler{keep_alive, NetworkAdapter::ETHERNET} { + _settings.type = NetworkAdapter::ETHERNET; memset(_settings.eth.ip.dword, 0, sizeof(_settings.eth.ip.dword)); memset(_settings.eth.dns.dword, 0, sizeof(_settings.eth.dns.dword)); memset(_settings.eth.gateway.dword, 0, sizeof(_settings.eth.gateway.dword)); @@ -54,6 +55,7 @@ EthernetConnectionHandler::EthernetConnectionHandler( unsigned long const timeout, unsigned long const responseTimeout, bool const keep_alive) : ConnectionHandler{keep_alive, NetworkAdapter::ETHERNET} { + _settings.type = NetworkAdapter::ETHERNET; fromIPAddress(ip, _settings.eth.ip); fromIPAddress(dns, _settings.eth.dns); fromIPAddress(gateway, _settings.eth.gateway); diff --git a/src/GenericConnectionHandler.cpp b/src/GenericConnectionHandler.cpp index ce6c198c..87435302 100644 --- a/src/GenericConnectionHandler.cpp +++ b/src/GenericConnectionHandler.cpp @@ -46,6 +46,12 @@ bool GenericConnectionHandler::updateSetting(const models::NetworkSetting& s) { } } +void GenericConnectionHandler::getSetting(models::NetworkSetting& s) { + if(_ch != nullptr) { + _ch->getSetting(s); + } +} + NetworkConnectionState GenericConnectionHandler::updateConnectionState() { return _ch != nullptr ? _ch->updateConnectionState() : NetworkConnectionState::INIT; } diff --git a/src/GenericConnectionHandler.h b/src/GenericConnectionHandler.h index e1b315e4..5468e438 100644 --- a/src/GenericConnectionHandler.h +++ b/src/GenericConnectionHandler.h @@ -49,6 +49,7 @@ class GenericConnectionHandler : public ConnectionHandler #endif bool updateSetting(const models::NetworkSetting& s) override; + void getSetting(models::NetworkSetting& s) override; void connect() override; void disconnect() override;