Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

GenericConnectionHandler: uniform functions order and layout#149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
pennam wants to merge1 commit intoarduino-libraries:master
base:master
Choose a base branch
Loading
frompennam:fix-generic-func-order
Open
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 71 additions & 61 deletionssrc/GenericConnectionHandler.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,57 @@
#include "GenericConnectionHandler.h"
#include "Arduino_ConnectionHandler.h"

static inline ConnectionHandler* instantiate_handler(NetworkAdapter adapter);
/******************************************************************************
LOCAL MODULE FUNCTIONS
******************************************************************************/

static inline ConnectionHandler* instantiate_handler(NetworkAdapter adapter) {
switch(adapter) {
#if defined(BOARD_HAS_WIFI)
case NetworkAdapter::WIFI:
return new WiFiConnectionHandler();
break;
#endif

#if defined(BOARD_HAS_ETHERNET)
case NetworkAdapter::ETHERNET:
return new EthernetConnectionHandler();
break;
#endif

#if defined(BOARD_HAS_NB)
case NetworkAdapter::NB:
return new NBConnectionHandler();
break;
#endif

#if defined(BOARD_HAS_GSM)
case NetworkAdapter::GSM:
return new GSMConnectionHandler();
break;
#endif

#if defined(BOARD_HAS_CATM1_NBIOT)
case NetworkAdapter::CATM1:
return new CatM1ConnectionHandler();
break;
#endif

#if defined(BOARD_HAS_CELLULAR)
case NetworkAdapter::CELL:
return new CellularConnectionHandler();
break;
#endif

default:
DEBUG_ERROR("Network adapter not supported by this platform: %d", adapter);
return nullptr;
}
}

/******************************************************************************
PUBLIC MEMBER FUNCTIONS
******************************************************************************/

bool GenericConnectionHandler::updateSetting(const models::NetworkSetting& s) {
if(_ch != nullptr && _ch->_current_net_connection_state != NetworkConnectionState::INIT) {
Expand DownExpand Up@@ -54,30 +104,6 @@ void GenericConnectionHandler::getSetting(models::NetworkSetting& s) {
}
}

NetworkConnectionState GenericConnectionHandler::updateConnectionState() {
return _ch != nullptr ? _ch->updateConnectionState() : NetworkConnectionState::INIT;
}

NetworkConnectionState GenericConnectionHandler::update_handleInit() {
return _ch != nullptr ? _ch->update_handleInit() : NetworkConnectionState::INIT;
}

NetworkConnectionState GenericConnectionHandler::update_handleConnecting() {
return _ch != nullptr ? _ch->update_handleConnecting() : NetworkConnectionState::INIT;
}

NetworkConnectionState GenericConnectionHandler::update_handleConnected() {
return _ch != nullptr ? _ch->update_handleConnected() : NetworkConnectionState::INIT;
}

NetworkConnectionState GenericConnectionHandler::update_handleDisconnecting() {
return _ch != nullptr ? _ch->update_handleDisconnecting() : NetworkConnectionState::INIT;
}

NetworkConnectionState GenericConnectionHandler::update_handleDisconnected() {
return _ch != nullptr ? _ch->update_handleDisconnected() : NetworkConnectionState::INIT;
}

#if not (defined(BOARD_HAS_LORA) or defined(BOARD_HAS_NOTECARD))
unsigned long GenericConnectionHandler::getTime() {
return _ch != nullptr ? _ch->getTime() : 0;
Expand DownExpand Up@@ -115,46 +141,30 @@ void GenericConnectionHandler::setKeepAlive(bool keep_alive) {
}
}

static inline ConnectionHandler* instantiate_handler(NetworkAdapter adapter) {
switch(adapter) {
#if defined(BOARD_HAS_WIFI)
case NetworkAdapter::WIFI:
return new WiFiConnectionHandler();
break;
#endif
/******************************************************************************
PROTECTED MEMBER FUNCTIONS
******************************************************************************/

#if defined(BOARD_HAS_ETHERNET)
case NetworkAdapter::ETHERNET:
return new EthernetConnectionHandler();
break;
#endif
NetworkConnectionState GenericConnectionHandler::updateConnectionState() {
return _ch != nullptr ? _ch->updateConnectionState() : NetworkConnectionState::INIT;
}

#if defined(BOARD_HAS_NB)
case NetworkAdapter::NB:
return new NBConnectionHandler();
break;
#endif
NetworkConnectionState GenericConnectionHandler::update_handleInit() {
return _ch != nullptr ? _ch->update_handleInit() : NetworkConnectionState::INIT;
}

#if defined(BOARD_HAS_GSM)
case NetworkAdapter::GSM:
return new GSMConnectionHandler();
break;
#endif
NetworkConnectionState GenericConnectionHandler::update_handleConnecting() {
return _ch != nullptr ? _ch->update_handleConnecting() : NetworkConnectionState::INIT;
}

#if defined(BOARD_HAS_CATM1_NBIOT)
case NetworkAdapter::CATM1:
return new CatM1ConnectionHandler();
break;
#endif
NetworkConnectionState GenericConnectionHandler::update_handleConnected() {
return _ch != nullptr ? _ch->update_handleConnected() : NetworkConnectionState::INIT;
}

#if defined(BOARD_HAS_CELLULAR)
case NetworkAdapter::CELL:
return new CellularConnectionHandler();
break;
#endif
NetworkConnectionState GenericConnectionHandler::update_handleDisconnecting() {
return _ch != nullptr ? _ch->update_handleDisconnecting() : NetworkConnectionState::INIT;
}

default:
DEBUG_ERROR("Network adapter not supported by this platform: %d", adapter);
return nullptr;
}
NetworkConnectionState GenericConnectionHandler::update_handleDisconnected() {
return _ch != nullptr ? _ch->update_handleDisconnected() : NetworkConnectionState::INIT;
}

[8]ページ先頭

©2009-2025 Movatter.jp