Skip to content

GSM: allow retry if connection fails #975

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
GSM: add setTimeout function
  • Loading branch information
pennam committed Nov 14, 2024
commit c539025a4312e9b70d3c16c4d64989046ba2c96b
5 changes: 5 additions & 0 deletions libraries/GSM/src/GSM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ int arduino::GSMClass::begin(const char* pin, const char* apn, const char* usern

_device->set_cmux_status_flag(_cmuxGSMenable);
_device->set_retry_timeout_array(_retry_timeout, sizeof(_retry_timeout) / sizeof(_retry_timeout[0]));
_device->set_timeout(_timeout);
_device->attach(mbed::callback(this, &GSMClass::onStatusChange));
_device->init();

Expand Down Expand Up @@ -101,6 +102,10 @@ int arduino::GSMClass::begin(const char* pin, const char* apn, const char* usern
return connect_status == NSAPI_ERROR_OK ? 1 : 0;
}

void arduino::GSMClass::setTimeout(unsigned long timeout) {
_timeout = timeout;
}

void arduino::GSMClass::enableCmux() {
_cmuxGSMenable = true;
}
Expand Down
7 changes: 6 additions & 1 deletion libraries/GSM/src/GSM.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,12 @@ class GSMClass : public MbedSocketClass {
*/
void end(void);

unsigned long getTime();
/*
* Change cellular state timeouts. Needs to be called before GSM.begin()
*/
void setTimeout(unsigned long timeout);

unsigned long getTime();
unsigned long getLocalTime();

bool setTime(unsigned long const epoch, int const timezone = 0);
Expand Down Expand Up @@ -133,6 +137,7 @@ class GSMClass : public MbedSocketClass {
mbed::CellularContext* _context = nullptr;
mbed::CellularDevice* _device = nullptr;
bool _at_debug = false;
unsigned long _timeout = 1000;

/* Internal cellular state machine retries. Values are in seconds.
* This array also defines the maximum number of retries to CELLULAR_RETRY_ARRAY_SIZE
Expand Down