Skip to content
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

GSM: allow retry if connection fails #975

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from
Draft
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: cleanup power on sequence and add comments
  • Loading branch information
pennam committed Nov 14, 2024
commit 4422d75827829a604937c374b55532b3861a8378
28 changes: 24 additions & 4 deletions libraries/GSM/src/GSM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,26 @@ mbed::CellularDevice *mbed::CellularDevice::get_default_instance()

int arduino::GSMClass::begin(const char* pin, const char* apn, const char* username, const char* password, RadioAccessTechnologyType rat, uint32_t band, bool restart) {

/* Assume module is powered ON. Uncomment this line is you are using
* Edge Control without Arduino_ConnectionHandler
* #if defined (ARDUINO_EDGE_CONTROL)
* pinMode(ON_MKR2, OUTPUT);
* digitalWrite(ON_MKR2, HIGH);
* #endif
*/

/* Ensure module is not under reset */
pinMode(MBED_CONF_GEMALTO_CINTERION_RST, OUTPUT);
digitalWrite(MBED_CONF_GEMALTO_CINTERION_RST, LOW);

/* Reset module if needed */
if (restart || isCmuxEnable()) {
reset();
}

/* Create rising edge on pin ON */
on();

if (!_context) {
_context = mbed::CellularContext::get_default_instance();
}
Expand All @@ -59,9 +75,10 @@ int arduino::GSMClass::begin(const char* pin, const char* apn, const char* usern
return 0;
}

pinMode(MBED_CONF_GEMALTO_CINTERION_ON, INPUT_PULLDOWN);

#if defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4)
/* This is needed to wakeup module if hw flow control is enabled */
static mbed::DigitalOut rts(MBED_CONF_GEMALTO_CINTERION_RTS, 0);
#endif

_device = _context->get_device();
_device->modem_debug_on(_at_debug);
Expand Down Expand Up @@ -159,10 +176,15 @@ NetworkInterface* arduino::GSMClass::getNetwork() {
}

void arduino::GSMClass::reset() {
/* Reset logic is inverted */
pinMode(MBED_CONF_GEMALTO_CINTERION_RST, OUTPUT);
digitalWrite(MBED_CONF_GEMALTO_CINTERION_RST, HIGH);
delay(800);
digitalWrite(MBED_CONF_GEMALTO_CINTERION_RST, LOW);
}

void arduino::GSMClass::on() {
/* Module needs a rising edge to power on */
pinMode(MBED_CONF_GEMALTO_CINTERION_ON, OUTPUT);
digitalWrite(MBED_CONF_GEMALTO_CINTERION_ON, LOW);
delay(1);
Expand All @@ -171,6 +193,4 @@ void arduino::GSMClass::reset() {
}




arduino::GSMClass GSM;
1 change: 1 addition & 0 deletions libraries/GSM/src/GSM.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ class GSMClass : public MbedSocketClass {
void onStatusChange(nsapi_event_t ev, intptr_t in);

void reset();
void on();
};

}
Expand Down