Skip to content

Commit 36af566

Browse files
fabik111andreagilardoni
authored andcommitted
override check method on GenericConnectionHandler
1 parent 32e8124 commit 36af566

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/ConnectionHandlerInterface.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class ConnectionHandler {
5151

5252
virtual ~ConnectionHandler() {}
5353

54-
NetworkConnectionState check();
54+
virtual NetworkConnectionState check();
5555

5656
#if not defined(BOARD_HAS_LORA)
5757
virtual unsigned long getTime() = 0;

src/GenericConnectionHandler.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
static inline ConnectionHandler* instantiate_handler(NetworkAdapter adapter);
2323

2424
bool GenericConnectionHandler::updateSetting(const models::NetworkSetting& s) {
25-
if(_ch != nullptr && _current_net_connection_state != NetworkConnectionState::INIT) {
25+
if(_ch != nullptr && _ch->_current_net_connection_state != NetworkConnectionState::INIT) {
2626
// If the internal connection handler is already being used and not in INIT phase we cannot update the settings
2727
return false;
28-
} else if(_ch != nullptr && _current_net_connection_state == NetworkConnectionState::INIT && _interface != s.type) {
28+
} else if(_ch != nullptr && _ch->_current_net_connection_state == NetworkConnectionState::INIT && _interface != s.type) {
2929
// If the internal connection handler is already being used and in INIT phase and the interface type is being changed
3030
// -> we need to deallocate the previously allocated handler
3131

@@ -49,6 +49,11 @@ bool GenericConnectionHandler::updateSetting(const models::NetworkSetting& s) {
4949
}
5050
}
5151

52+
NetworkConnectionState GenericConnectionHandler::check()
53+
{
54+
return _ch != nullptr ? _ch->check() : NetworkConnectionState::INIT;
55+
}
56+
5257
NetworkConnectionState GenericConnectionHandler::update_handleInit() {
5358
return _ch != nullptr ? _ch->update_handleInit() : NetworkConnectionState::INIT;
5459
}

src/GenericConnectionHandler.h

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ class GenericConnectionHandler : public ConnectionHandler
3838

3939
GenericConnectionHandler(bool const keep_alive=true): ConnectionHandler(keep_alive), _ch(nullptr) {}
4040

41+
NetworkConnectionState check() override;
42+
4143
#if defined(BOARD_HAS_NOTECARD) || defined(BOARD_HAS_LORA)
4244
virtual bool available() = 0;
4345
virtual int read() = 0;

0 commit comments

Comments
 (0)