From 315b031317bec4b11ab4a76a4fcfa6d30baac74d Mon Sep 17 00:00:00 2001 From: Fabio C Date: Fri, 18 Jul 2025 11:44:25 +0200 Subject: [PATCH 1/2] Use timeout duration of connection attempt according to connection type (#17) --- src/Arduino_NetworkConfigurator.cpp | 59 +++++++++++++++++++++++++++-- src/Arduino_NetworkConfigurator.h | 3 ++ 2 files changed, 59 insertions(+), 3 deletions(-) diff --git a/src/Arduino_NetworkConfigurator.cpp b/src/Arduino_NetworkConfigurator.cpp index ee7d3cc..e4e2bfd 100644 --- a/src/Arduino_NetworkConfigurator.cpp +++ b/src/Arduino_NetworkConfigurator.cpp @@ -76,7 +76,6 @@ bool NetworkConfiguratorClass::begin() { DEBUG_ERROR("NetworkConfiguratorClass::%s Failed to initialize the AgentsManagerClass", __FUNCTION__); } - _connectionTimeout.begin(NC_CONNECTION_TIMEOUT_ms); _connectionRetryTimer.begin(NC_CONNECTION_RETRY_TIMER_ms); _resetInput->begin(); @@ -102,7 +101,7 @@ NetworkConfiguratorStates NetworkConfiguratorClass::update() { if(_state != nextState){ if(nextState == NetworkConfiguratorStates::CONNECTING){ - _connectionTimeout.reload(); + setConnectionTimeoutTimer(); } _state = nextState; } @@ -385,6 +384,60 @@ bool NetworkConfiguratorClass::handleConnectRequest() { return true; } +void NetworkConfiguratorClass::setConnectionTimeoutTimer() { + uint32_t timeout = 0; + switch (_networkSetting.type) { +#if defined(BOARD_HAS_WIFI) + case NetworkAdapter::WIFI: + timeout = NC_CONNECTION_TIMEOUT_ms; // 15 seconds + break; +#endif + +#if defined(BOARD_HAS_ETHERNET) + case NetworkAdapter::ETHERNET: + timeout = NC_CONNECTION_TIMEOUT_ms; // 15 seconds + break; +#endif + +#if defined(BOARD_HAS_NB) + case NetworkAdapter::NB: + timeout = 2 * NC_CONNECTION_TIMEOUT_ms; // 30 seconds + break; +#endif + +#if defined(BOARD_HAS_GSM) + case NetworkAdapter::GSM: + timeout = 2 * NC_CONNECTION_TIMEOUT_ms; // 30 seconds + break; +#endif + +#if defined(BOARD_HAS_CATM1_NBIOT) + case NetworkAdapter::CATM1: + timeout = 2 * NC_CONNECTION_TIMEOUT_ms; // 30 seconds + break; +#endif + +#if defined(BOARD_HAS_CELLULAR) + case NetworkAdapter::CELL: + timeout = 2 * NC_CONNECTION_TIMEOUT_ms; // 30 seconds + break; +#endif + +#if defined(BOARD_HAS_LORA) + case NetworkAdapter::LORA: + timeout = NC_CONNECTION_TIMEOUT_ms; // 15 seconds + break; +#endif + default: + timeout = NC_CONNECTION_TIMEOUT_ms; // Default to 15 seconds for other adapters + break; + } + + _connectionTimeout.begin(timeout); + _connectionTimeout.reload(); + return; +} + String NetworkConfiguratorClass::decodeConnectionErrorMessage(NetworkConnectionState err, StatusMessage *errorCode) { switch (err) { case NetworkConnectionState::ERROR: @@ -452,7 +505,7 @@ NetworkConfiguratorStates NetworkConfiguratorClass::handleZeroTouchConfig() { return NetworkConfiguratorStates::WAITING_FOR_CONFIG; } _connectionHandlerIstantiated = true; - _connectionTimeout.reload(); + setConnectionTimeoutTimer(); } StatusMessage err; diff --git a/src/Arduino_NetworkConfigurator.h b/src/Arduino_NetworkConfigurator.h index fafe125..207e5ea 100644 --- a/src/Arduino_NetworkConfigurator.h +++ b/src/Arduino_NetworkConfigurator.h @@ -207,6 +207,9 @@ class NetworkConfiguratorClass { void startReconfigureProcedure(); + // Returns the connection timeout in milliseconds according to the set network type + void setConnectionTimeoutTimer(); + String decodeConnectionErrorMessage(NetworkConnectionState err, StatusMessage *errorCode); ConnectionResult connectToNetwork(StatusMessage *err); ConnectionResult disconnectFromNetwork(); From 1b4ad0ff12feccf1e327ae21f845276e105c4da2 Mon Sep 17 00:00:00 2001 From: fabik111 Date: Fri, 18 Jul 2025 12:01:22 +0200 Subject: [PATCH 2/2] Release version 0.3.1 --- library.properties | 2 +- src/ANetworkConfigurator_Config.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library.properties b/library.properties index 2605e46..8e8e484 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Arduino_NetworkConfigurator -version=0.3.0 +version=0.3.1 author=Arduino maintainer=Arduino sentence=This library allows to configure and update the network settings of a ConnectionHandler instance. diff --git a/src/ANetworkConfigurator_Config.h b/src/ANetworkConfigurator_Config.h index 979e5ef..db539f2 100644 --- a/src/ANetworkConfigurator_Config.h +++ b/src/ANetworkConfigurator_Config.h @@ -7,7 +7,7 @@ */ #pragma once -#define ANetworkConfigurator_LIB_VERSION "0.3.0" +#define ANetworkConfigurator_LIB_VERSION "0.3.1" #if defined(ARDUINO_SAMD_MKRWIFI1010) #define NETWORK_CONFIGURATOR_COMPATIBLE 1 pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy