From 0bca667355cee172ed380dcf70b198bea218e017 Mon Sep 17 00:00:00 2001 From: fabik111 Date: Fri, 30 May 2025 17:46:16 +0200 Subject: [PATCH 1/2] add get setting --- src/ConnectionHandlerInterface.h | 5 +++++ src/GenericConnectionHandler.cpp | 6 ++++++ src/GenericConnectionHandler.h | 1 + 3 files changed, 12 insertions(+) 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/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; From 077b6411de6aaffeff9edbd12d0e63e843c92968 Mon Sep 17 00:00:00 2001 From: fabik111 Date: Tue, 3 Jun 2025 11:31:28 +0200 Subject: [PATCH 2/2] set connection type for EthernetConnectionHandler --- src/EthernetConnectionHandler.cpp | 2 ++ 1 file changed, 2 insertions(+) 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);