File tree Expand file tree Collapse file tree 2 files changed +24
-12
lines changed
Expand file tree Collapse file tree 2 files changed +24
-12
lines changed Original file line number Diff line number Diff line change @@ -252,18 +252,23 @@ bool LteClass::begin(const bool print_messages) {
252252}
253253
254254void LteClass::end (void ) {
255- is_connected = false ;
256- got_timezone = false ;
257255
258- SequansController.unregisterCallback (CEREG_CALLBACK);
259- SequansController.unregisterCallback (TIMEZONE_CALLBACK);
260- SequansController.writeCommand (AT_DISCONNECT);
256+ if (SequansController.isInitialized ()) {
261257
262- // Wait for the CEREG URC after disconnect so that the modem doesn't have
263- // any pending URCs and won't prevent going to sleep
264- SequansController.waitForURC (CEREG_CALLBACK);
258+ SequansController.unregisterCallback (TIMEZONE_CALLBACK);
259+ SequansController.writeCommand (AT_DISCONNECT);
260+
261+ // Wait for the CEREG URC after disconnect so that the modem doesn't
262+ // have any pending URCs and won't prevent going to sleep
263+ uint32_t start = millis ();
264+ while (isConnected () && millis () - start < 2000 ) {}
265+ SequansController.unregisterCallback (CEREG_CALLBACK);
265266
266- SequansController.end ();
267+ SequansController.end ();
268+ }
269+
270+ got_timezone = false ;
271+ is_connected = false ;
267272}
268273
269274String LteClass::getOperator (void ) {
Original file line number Diff line number Diff line change @@ -538,15 +538,22 @@ void SequansControllerClass::end(void) {
538538 USART1.CTRLB = 0 ;
539539 USART1.CTRLC = 0 ;
540540
541- pinConfigure (CTS_PIN, PIN_ISC_DISABLE );
541+ pinConfigure (RESET_PIN, PIN_INPUT_DISABLE | PIN_DIR_INPUT );
542542
543- // Set RTS high to halt the modem
544- pinConfigure (RTS_PIN, PIN_DIR_OUTPUT);
543+ // Set RTS high to halt the modem. Has external pull-up, so is just set to
544+ // input afterwards
545545 digitalWrite (RTS_PIN, HIGH);
546+ pinConfigure (RTS_PIN, PIN_DIR_INPUT | PIN_INPUT_DISABLE);
546547
548+ pinConfigure (RING_PIN, PIN_DIR_INPUT | PIN_INPUT_DISABLE);
547549 detachInterrupt (RING_PIN);
550+
551+ pinConfigure (CTS_PIN, PIN_DIR_INPUT | PIN_INPUT_DISABLE);
548552 detachInterrupt (CTS_PIN);
549553
554+ pinConfigure (TX_PIN, PIN_DIR_INPUT | PIN_PULLUP_ON | PIN_INPUT_DISABLE);
555+ pinConfigure (RX_PIN, PIN_DIR_INPUT | PIN_PULLUP_ON | PIN_INPUT_DISABLE);
556+
550557 initialized = false ;
551558}
552559
You can’t perform that action at this time.
0 commit comments