diff --git a/library.properties b/library.properties index 3592a568..9c0b81d3 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Arduino_ConnectionHandler -version=1.1.0 +version=1.1.1 author=Ubi de Feo, Cristian Maglie, Andrea Catozzi, Alexander Entinger et al. maintainer=Arduino sentence=Arduino Library for network connection management (WiFi, GSM, NB, [Ethernet], Notecard) diff --git a/src/CatM1ConnectionHandler.cpp b/src/CatM1ConnectionHandler.cpp index 2a63dea0..c8bd7fcd 100644 --- a/src/CatM1ConnectionHandler.cpp +++ b/src/CatM1ConnectionHandler.cpp @@ -37,12 +37,15 @@ CatM1ConnectionHandler::CatM1ConnectionHandler( : ConnectionHandler{keep_alive, NetworkAdapter::CATM1} { _settings.type = NetworkAdapter::CATM1; + // To keep the backward compatibility, the user can call enableCheckInternetAvailability(false) for disabling the check + _check_internet_availability = true; strncpy(_settings.catm1.pin, pin, sizeof(_settings.catm1.pin)-1); strncpy(_settings.catm1.apn, apn, sizeof(_settings.catm1.apn)-1); strncpy(_settings.catm1.login, login, sizeof(_settings.catm1.login)-1); strncpy(_settings.catm1.pass, pass, sizeof(_settings.catm1.pass)-1); _settings.catm1.rat = static_cast(rat); _settings.catm1.band = band; + _reset = false; } /****************************************************************************** @@ -51,7 +54,10 @@ CatM1ConnectionHandler::CatM1ConnectionHandler( unsigned long CatM1ConnectionHandler::getTime() { - return GSM.getTime(); + /* It is not safe to call GSM.getTime() since we don't know if modem internal + * RTC is in sync with current time. + */ + return 0; } /****************************************************************************** @@ -61,6 +67,7 @@ unsigned long CatM1ConnectionHandler::getTime() NetworkConnectionState CatM1ConnectionHandler::update_handleInit() { #if defined (ARDUINO_EDGE_CONTROL) + /* Power on module */ pinMode(ON_MKR2, OUTPUT); digitalWrite(ON_MKR2, HIGH); #endif @@ -71,11 +78,14 @@ NetworkConnectionState CatM1ConnectionHandler::update_handleInit() _settings.catm1.login, _settings.catm1.pass, static_cast(_settings.catm1.rat) , - _settings.catm1.band)) + _settings.catm1.band, + _reset)) { Debug.print(DBG_ERROR, F("The board was not able to register to the network...")); - return NetworkConnectionState::ERROR; + _reset = true; + return NetworkConnectionState::DISCONNECTED; } + _reset = false; return NetworkConnectionState::CONNECTING; } @@ -83,19 +93,21 @@ NetworkConnectionState CatM1ConnectionHandler::update_handleConnecting() { if (!GSM.isConnected()) { - return NetworkConnectionState::INIT; + Debug.print(DBG_ERROR, F("GSM connection not alive... disconnecting")); + return NetworkConnectionState::DISCONNECTED; } if(!_check_internet_availability){ return NetworkConnectionState::CONNECTED; } - int ping_result = GSM.ping("time.arduino.cc"); + Debug.print(DBG_INFO, F("Sending PING to outer space...")); + int const ping_result = GSM.ping("time.arduino.cc"); Debug.print(DBG_INFO, F("GSM.ping(): %d"), ping_result); if (ping_result < 0) { Debug.print(DBG_ERROR, F("Internet check failed")); - Debug.print(DBG_INFO, F("Retrying in \"%d\" milliseconds"), CHECK_INTERVAL_TABLE[static_cast(NetworkConnectionState::CONNECTING)]); + Debug.print(DBG_INFO, F("Retrying in \"%d\" milliseconds"), 2 * CHECK_INTERVAL_TABLE[static_cast(NetworkConnectionState::CONNECTING)]); return NetworkConnectionState::CONNECTING; } else @@ -110,6 +122,7 @@ NetworkConnectionState CatM1ConnectionHandler::update_handleConnected() int const is_gsm_access_alive = GSM.isConnected(); if (is_gsm_access_alive != 1) { + Debug.print(DBG_ERROR, F("GSM connection not alive... disconnecting")); return NetworkConnectionState::DISCONNECTED; } return NetworkConnectionState::CONNECTED; @@ -123,6 +136,7 @@ NetworkConnectionState CatM1ConnectionHandler::update_handleDisconnecting() NetworkConnectionState CatM1ConnectionHandler::update_handleDisconnected() { + GSM.end(); if (_keep_alive) { return NetworkConnectionState::INIT; diff --git a/src/CatM1ConnectionHandler.h b/src/CatM1ConnectionHandler.h index 67f317b7..37c92058 100644 --- a/src/CatM1ConnectionHandler.h +++ b/src/CatM1ConnectionHandler.h @@ -60,6 +60,8 @@ class CatM1ConnectionHandler : public ConnectionHandler private: + bool _reset; + GSMUDP _gsm_udp; GSMClient _gsm_client; }; 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