Skip to content
Prev Previous commit
Next Next commit
GSM: limit the number of internal state machine retries to 6
  • Loading branch information
pennam committed Nov 21, 2023
commit c4065f5171d00dc8e679d608d1323f664d5b9b2c
1 change: 1 addition & 0 deletions libraries/GSM/src/GSM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ int arduino::GSMClass::begin(const char* pin, const char* apn, const char* usern

_context->set_sim_pin(pin);

_device->set_retry_timeout_array(_retry_timeout, sizeof(_retry_timeout) / sizeof(_retry_timeout[0]));
#if GSM_DEBUG_ENABLE
_device->attach(mbed::callback(this, &GSMClass::onStatusChange));
#endif
Expand Down
5 changes: 5 additions & 0 deletions libraries/GSM/src/GSM.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ class GSMClass : public MbedSocketClass {
mbed::CellularDevice* _device = nullptr;
bool _at_debug = false;

/* Internal cellular state machine retries. Values are in seconds.
* This array also defines the maximum number of retries to 6
*/
const uint16_t _retry_timeout[6] = {1, 2, 4, 8, 16, 32};

#if GSM_DEBUG_ENABLE
static constexpr int RSSI_UNKNOWN = 99;
static const char * const sim_state_str[];
Expand Down