From 4d9060fbd928fef456cfeb3178fa0d54ff13070d Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 17 May 2024 15:02:36 -0400 Subject: [PATCH] Make set baud a bool return Signed-off-by: Sara Damiano --- src/TinyGsmClientESP8266.h | 5 +++-- src/TinyGsmClientXBee.h | 3 ++- src/TinyGsmModem.tpp | 10 +++++----- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/TinyGsmClientESP8266.h b/src/TinyGsmClientESP8266.h index b0f5f4d..0e66e92 100644 --- a/src/TinyGsmClientESP8266.h +++ b/src/TinyGsmClientESP8266.h @@ -187,7 +187,7 @@ class TinyGsmESP8266 : public TinyGsmModem, return res; } - void setBaudImpl(uint32_t baud) { + bool setBaudImpl(uint32_t baud) { sendAT(GF("+UART_CUR="), baud, "8,1,0,0"); if (waitResponse() != 1) { sendAT(GF("+UART="), baud, @@ -195,9 +195,10 @@ class TinyGsmESP8266 : public TinyGsmModem, // if (waitResponse() != 1) { // sendAT(GF("+IPR="), baud); // First release firmwares might need // this - waitResponse(); + return waitResponse() == 1; // } } + return false; } bool factoryDefaultImpl() { diff --git a/src/TinyGsmClientXBee.h b/src/TinyGsmClientXBee.h index a8b7088..0a53a63 100644 --- a/src/TinyGsmClientXBee.h +++ b/src/TinyGsmClientXBee.h @@ -401,7 +401,7 @@ class TinyGsmXBee : public TinyGsmModem, return sendATGetString(GF("VR")); } - void setBaudImpl(uint32_t baud) { + bool setBaudImpl(uint32_t baud) { XBEE_COMMAND_START_DECORATOR(5, ) bool changesMade = false; switch (baud) { @@ -424,6 +424,7 @@ class TinyGsmXBee : public TinyGsmModem, } if (changesMade) { writeChanges(); } XBEE_COMMAND_END_DECORATOR + return true; } bool testATImpl(uint32_t timeout_ms = 10000L) { diff --git a/src/TinyGsmModem.tpp b/src/TinyGsmModem.tpp index f73f82d..24d7b50 100644 --- a/src/TinyGsmModem.tpp +++ b/src/TinyGsmModem.tpp @@ -59,8 +59,8 @@ class TinyGsmModem { thisModem().stream.flush(); TINY_GSM_YIELD(); /* DBG("### AT:", cmd...); */ } - void setBaud(uint32_t baud) { - thisModem().setBaudImpl(baud); + bool setBaud(uint32_t baud) { + return thisModem().setBaudImpl(baud); } // Test response to AT commands bool testAT(uint32_t timeout_ms = 10000L) { @@ -172,10 +172,10 @@ class TinyGsmModem { * Basic functions */ protected: - void setBaudImpl(uint32_t baud) { + bool setBaudImpl(uint32_t baud) { thisModem().sendAT(GF("+IPR="), baud); - thisModem().waitResponse(); - } + return thisModem().waitResponse() == 1; + } bool testATImpl(uint32_t timeout_ms = 10000L) { for (uint32_t start = millis(); millis() - start < timeout_ms;) {