From 3be8766408575adf5fb3177771cb43c097007c37 Mon Sep 17 00:00:00 2001 From: Nathan Seidle Date: Tue, 28 Dec 2021 14:49:23 -0700 Subject: [PATCH] Do not rebegin serial port if user assigned it before lib begin. Add end() to beginSerial to allow ESP32 software serial. --- src/SparkFun_u-blox_SARA-R5_Arduino_Library.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/SparkFun_u-blox_SARA-R5_Arduino_Library.cpp b/src/SparkFun_u-blox_SARA-R5_Arduino_Library.cpp index 1cd973a..7bc3c06 100644 --- a/src/SparkFun_u-blox_SARA-R5_Arduino_Library.cpp +++ b/src/SparkFun_u-blox_SARA-R5_Arduino_Library.cpp @@ -3044,7 +3044,8 @@ SARA_R5_error_t SARA_R5::init(unsigned long baud, if (_printDebug == true) _debugPort->println(F("Begin module init.")); - beginSerial(baud); // Begin serial + if(hwAvailable() == -1) + beginSerial(baud); // If port is null, begin serial if (initType == SARA_R5_INIT_AUTOBAUD) { @@ -3594,6 +3595,7 @@ void SARA_R5::beginSerial(unsigned long baud) #ifdef SARA_R5_SOFTWARE_SERIAL_ENABLED else if (_softSerial != NULL) { + _softSerial->end(); _softSerial->begin(baud); } #endif