Skip to content

Commit 7d988ba

Browse files
committed
GSM: remove begin() retry logic
* Internal retries are handled in mbed cellular state machine. If needed user should implement its own retry logic in the sketch.
1 parent c4065f5 commit 7d988ba

File tree

1 file changed

+10
-19
lines changed

1 file changed

+10
-19
lines changed

libraries/GSM/src/GSM.cpp

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
#include "CellularInterface.h"
2727
#include "GEMALTO_CINTERION_CellularStack.h"
2828

29-
#define MAXRETRY 3
30-
3129
arduino::CMUXClass *arduino::CMUXClass::get_default_instance()
3230
{
3331
static mbed::UnbufferedSerial serial(MBED_CONF_GEMALTO_CINTERION_TX, MBED_CONF_GEMALTO_CINTERION_RX, 115200);
@@ -102,24 +100,17 @@ int arduino::GSMClass::begin(const char* pin, const char* apn, const char* usern
102100
_context->set_band(_band);
103101

104102
int connect_status = NSAPI_ERROR_AUTH_FAILURE;
105-
uint8_t retryCount = 0;
106-
while(connect_status != NSAPI_ERROR_OK && retryCount < MAXRETRY) {
107-
108-
connect_status = _context->connect(pin, apn, username, password);
109-
retryCount++;
110-
111-
if (connect_status == NSAPI_ERROR_AUTH_FAILURE) {
112-
DEBUG_ERROR("Authentication Failure. Exiting application.");
113-
} else if (connect_status == NSAPI_ERROR_OK || connect_status == NSAPI_ERROR_IS_CONNECTED) {
114-
connect_status = NSAPI_ERROR_OK;
115-
DEBUG_INFO("Connection Established.");
116-
} else if (retryCount > 2) {
117-
DEBUG_ERROR("Fatal connection failure: %d", connect_status);
118-
} else {
119-
DEBUG_WARNING("Couldn't connect, will retry...");
120-
continue;
121-
}
122103

104+
DEBUG_INFO("Connecting...");
105+
connect_status = _context->connect(pin, apn, username, password);
106+
107+
if (connect_status == NSAPI_ERROR_AUTH_FAILURE) {
108+
DEBUG_ERROR("Authentication Failure. Exiting application.");
109+
} else if (connect_status == NSAPI_ERROR_OK || connect_status == NSAPI_ERROR_IS_CONNECTED) {
110+
connect_status = NSAPI_ERROR_OK;
111+
DEBUG_INFO("Connection Established.");
112+
} else {
113+
DEBUG_ERROR("Couldn't connect.");
123114
}
124115

125116
return connect_status == NSAPI_ERROR_OK ? 1 : 0;

0 commit comments

Comments
 (0)