From a483b288b6783b65738602dc53d647c6c7891652 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 17 Feb 2020 14:37:12 -0500 Subject: [PATCH] Only use CME_Error if debug Signed-off-by: Sara Damiano --- src/TinyGsmClientA6.h | 20 ++++++++++++++++++-- src/TinyGsmClientBG96.h | 22 +++++++++++++++++++--- src/TinyGsmClientESP8266.h | 2 +- src/TinyGsmClientM590.h | 20 ++++++++++++++++++-- src/TinyGsmClientM95.h | 24 ++++++++++++++++++++---- src/TinyGsmClientMC60.h | 24 ++++++++++++++++++++---- src/TinyGsmClientSIM5360.h | 28 ++++++++++++++++++++++------ src/TinyGsmClientSIM7000.h | 28 ++++++++++++++++++++++------ src/TinyGsmClientSIM7600.h | 28 ++++++++++++++++++++++------ src/TinyGsmClientSIM800.h | 28 ++++++++++++++++++++++------ src/TinyGsmClientSaraR4.h | 24 ++++++++++++++++++++---- src/TinyGsmClientSequansMonarch.h | 24 ++++++++++++++++++++---- src/TinyGsmClientUBLOX.h | 24 ++++++++++++++++++++---- 13 files changed, 244 insertions(+), 52 deletions(-) diff --git a/src/TinyGsmClientA6.h b/src/TinyGsmClientA6.h index 6c032a9..b07142c 100644 --- a/src/TinyGsmClientA6.h +++ b/src/TinyGsmClientA6.h @@ -24,9 +24,11 @@ #include "TinyGsmTime.tpp" #define GSM_NL "\r\n" -static const char GSM_OK[] TINY_GSM_PROGMEM = "OK" GSM_NL; -static const char GSM_ERROR[] TINY_GSM_PROGMEM = "ERROR" GSM_NL; +static const char GSM_OK[] TINY_GSM_PROGMEM = "OK" GSM_NL; +static const char GSM_ERROR[] TINY_GSM_PROGMEM = "ERROR" GSM_NL; +#if defined TINY_GSM_DEBUG static const char GSM_CME_ERROR[] TINY_GSM_PROGMEM = GSM_NL "+CME ERROR:"; +#endif enum RegStatus { REG_NO_RESULT = -1, @@ -455,7 +457,11 @@ class TinyGsmA6 : public TinyGsmModem, int8_t waitResponse(uint32_t timeout_ms, String& data, GsmConstStr r1 = GFP(GSM_OK), GsmConstStr r2 = GFP(GSM_ERROR), +#if defined TINY_GSM_DEBUG GsmConstStr r3 = GFP(GSM_CME_ERROR), +#else + GsmConstStr r3 = NULL, +#endif GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { /*String r1s(r1); r1s.trim(); String r2s(r2); r2s.trim(); @@ -480,9 +486,11 @@ class TinyGsmA6 : public TinyGsmModem, index = 2; goto finish; } else if (r3 && data.endsWith(r3)) { +#if defined TINY_GSM_DEBUG if (r3 == GFP(GSM_CME_ERROR)) { streamSkipUntil('\n'); // Read out the error } +#endif index = 3; goto finish; } else if (r4 && data.endsWith(r4)) { @@ -530,7 +538,11 @@ class TinyGsmA6 : public TinyGsmModem, int8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), GsmConstStr r2 = GFP(GSM_ERROR), +#if defined TINY_GSM_DEBUG GsmConstStr r3 = GFP(GSM_CME_ERROR), +#else + GsmConstStr r3 = NULL, +#endif GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { String data; return waitResponse(timeout_ms, data, r1, r2, r3, r4, r5); @@ -538,7 +550,11 @@ class TinyGsmA6 : public TinyGsmModem, int8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), GsmConstStr r2 = GFP(GSM_ERROR), +#if defined TINY_GSM_DEBUG GsmConstStr r3 = GFP(GSM_CME_ERROR), +#else + GsmConstStr r3 = NULL, +#endif GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { return waitResponse(1000, r1, r2, r3, r4, r5); } diff --git a/src/TinyGsmClientBG96.h b/src/TinyGsmClientBG96.h index 3ec90de..c41791b 100644 --- a/src/TinyGsmClientBG96.h +++ b/src/TinyGsmClientBG96.h @@ -24,9 +24,11 @@ #include "TinyGsmTime.tpp" #define GSM_NL "\r\n" -static const char GSM_OK[] TINY_GSM_PROGMEM = "OK" GSM_NL; -static const char GSM_ERROR[] TINY_GSM_PROGMEM = "ERROR" GSM_NL; +static const char GSM_OK[] TINY_GSM_PROGMEM = "OK" GSM_NL; +static const char GSM_ERROR[] TINY_GSM_PROGMEM = "ERROR" GSM_NL; +#if defined TINY_GSM_DEBUG static const char GSM_CME_ERROR[] TINY_GSM_PROGMEM = GSM_NL "+CME ERROR:"; +#endif enum RegStatus { REG_NO_RESULT = -1, @@ -328,7 +330,7 @@ class TinyGsmBG96 : public TinyGsmModem, for (int i = 0; i < len; i++) { moveCharFromStreamToFifo(mux); } waitResponse(); - DBG("### READ:", len, "from", mux); + // DBG("### READ:", len, "from", mux); sockets[mux]->sock_available = modemGetAvailable(mux); return len; } @@ -374,7 +376,11 @@ class TinyGsmBG96 : public TinyGsmModem, int8_t waitResponse(uint32_t timeout_ms, String& data, GsmConstStr r1 = GFP(GSM_OK), GsmConstStr r2 = GFP(GSM_ERROR), +#if defined TINY_GSM_DEBUG GsmConstStr r3 = GFP(GSM_CME_ERROR), +#else + GsmConstStr r3 = NULL, +#endif GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { /*String r1s(r1); r1s.trim(); String r2s(r2); r2s.trim(); @@ -399,9 +405,11 @@ class TinyGsmBG96 : public TinyGsmModem, index = 2; goto finish; } else if (r3 && data.endsWith(r3)) { +#if defined TINY_GSM_DEBUG if (r3 == GFP(GSM_CME_ERROR)) { streamSkipUntil('\n'); // Read out the error } +#endif index = 3; goto finish; } else if (r4 && data.endsWith(r4)) { @@ -446,7 +454,11 @@ class TinyGsmBG96 : public TinyGsmModem, int8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), GsmConstStr r2 = GFP(GSM_ERROR), +#if defined TINY_GSM_DEBUG GsmConstStr r3 = GFP(GSM_CME_ERROR), +#else + GsmConstStr r3 = NULL, +#endif GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { String data; return waitResponse(timeout_ms, data, r1, r2, r3, r4, r5); @@ -454,7 +466,11 @@ class TinyGsmBG96 : public TinyGsmModem, int8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), GsmConstStr r2 = GFP(GSM_ERROR), +#if defined TINY_GSM_DEBUG GsmConstStr r3 = GFP(GSM_CME_ERROR), +#else + GsmConstStr r3 = NULL, +#endif GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { return waitResponse(1000, r1, r2, r3, r4, r5); } diff --git a/src/TinyGsmClientESP8266.h b/src/TinyGsmClientESP8266.h index 4f9e4b3..934e294 100644 --- a/src/TinyGsmClientESP8266.h +++ b/src/TinyGsmClientESP8266.h @@ -384,7 +384,7 @@ class TinyGsmESP8266 : public TinyGsmModem, DBG("### Buffer overflow: ", len, "received vs", sockets[mux]->rx.free(), "available"); } else { - DBG("### Got Data: ", len, "on", mux); + // DBG("### Got Data: ", len, "on", mux); } while (len--) { moveCharFromStreamToFifo(mux); } // TODO(SRGDamia1): deal with buffer overflow/missed characters diff --git a/src/TinyGsmClientM590.h b/src/TinyGsmClientM590.h index 137629e..531d573 100644 --- a/src/TinyGsmClientM590.h +++ b/src/TinyGsmClientM590.h @@ -22,9 +22,11 @@ #include "TinyGsmTime.tpp" #define GSM_NL "\r\n" -static const char GSM_OK[] TINY_GSM_PROGMEM = "OK" GSM_NL; -static const char GSM_ERROR[] TINY_GSM_PROGMEM = "ERROR" GSM_NL; +static const char GSM_OK[] TINY_GSM_PROGMEM = "OK" GSM_NL; +static const char GSM_ERROR[] TINY_GSM_PROGMEM = "ERROR" GSM_NL; +#if defined TINY_GSM_DEBUG static const char GSM_CME_ERROR[] TINY_GSM_PROGMEM = GSM_NL "+CME ERROR:"; +#endif enum RegStatus { REG_NO_RESULT = -1, @@ -342,7 +344,11 @@ class TinyGsmM590 : public TinyGsmModem, int8_t waitResponse(uint32_t timeout_ms, String& data, GsmConstStr r1 = GFP(GSM_OK), GsmConstStr r2 = GFP(GSM_ERROR), +#if defined TINY_GSM_DEBUG GsmConstStr r3 = GFP(GSM_CME_ERROR), +#else + GsmConstStr r3 = NULL, +#endif GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { /*String r1s(r1); r1s.trim(); String r2s(r2); r2s.trim(); @@ -367,9 +373,11 @@ class TinyGsmM590 : public TinyGsmModem, index = 2; goto finish; } else if (r3 && data.endsWith(r3)) { +#if defined TINY_GSM_DEBUG if (r3 == GFP(GSM_CME_ERROR)) { streamSkipUntil('\n'); // Read out the error } +#endif index = 3; goto finish; } else if (r4 && data.endsWith(r4)) { @@ -418,7 +426,11 @@ class TinyGsmM590 : public TinyGsmModem, int8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), GsmConstStr r2 = GFP(GSM_ERROR), +#if defined TINY_GSM_DEBUG GsmConstStr r3 = GFP(GSM_CME_ERROR), +#else + GsmConstStr r3 = NULL, +#endif GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { String data; return waitResponse(timeout_ms, data, r1, r2, r3, r4, r5); @@ -426,7 +438,11 @@ class TinyGsmM590 : public TinyGsmModem, int8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), GsmConstStr r2 = GFP(GSM_ERROR), +#if defined TINY_GSM_DEBUG GsmConstStr r3 = GFP(GSM_CME_ERROR), +#else + GsmConstStr r3 = NULL, +#endif GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { return waitResponse(1000, r1, r2, r3, r4, r5); } diff --git a/src/TinyGsmClientM95.h b/src/TinyGsmClientM95.h index c7256a4..bf7b1bd 100644 --- a/src/TinyGsmClientM95.h +++ b/src/TinyGsmClientM95.h @@ -26,9 +26,11 @@ #include "TinyGsmTime.tpp" #define GSM_NL "\r\n" -static const char GSM_OK[] TINY_GSM_PROGMEM = "OK" GSM_NL; -static const char GSM_ERROR[] TINY_GSM_PROGMEM = "ERROR" GSM_NL; +static const char GSM_OK[] TINY_GSM_PROGMEM = "OK" GSM_NL; +static const char GSM_ERROR[] TINY_GSM_PROGMEM = "ERROR" GSM_NL; +#if defined TINY_GSM_DEBUG static const char GSM_CME_ERROR[] TINY_GSM_PROGMEM = GSM_NL "+CME ERROR:"; +#endif enum RegStatus { REG_NO_RESULT = -1, @@ -467,7 +469,7 @@ class TinyGsmM95 : public TinyGsmModem, // FIFO } waitResponse(); // ends with an OK - DBG("### READ:", len, "from", mux); + // DBG("### READ:", len, "from", mux); return len; } else { sockets[mux]->sock_available = 0; @@ -506,7 +508,11 @@ class TinyGsmM95 : public TinyGsmModem, int8_t waitResponse(uint32_t timeout_ms, String& data, GsmConstStr r1 = GFP(GSM_OK), GsmConstStr r2 = GFP(GSM_ERROR), +#if defined TINY_GSM_DEBUG GsmConstStr r3 = GFP(GSM_CME_ERROR), +#else + GsmConstStr r3 = NULL, +#endif GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { /*String r1s(r1); r1s.trim(); String r2s(r2); r2s.trim(); @@ -531,9 +537,11 @@ class TinyGsmM95 : public TinyGsmModem, index = 2; goto finish; } else if (r3 && data.endsWith(r3)) { +#if defined TINY_GSM_DEBUG if (r3 == GFP(GSM_CME_ERROR)) { streamSkipUntil('\n'); // Read out the error } +#endif index = 3; goto finish; } else if (r4 && data.endsWith(r4)) { @@ -546,7 +554,7 @@ class TinyGsmM95 : public TinyGsmModem, streamSkipUntil(','); // Skip the context streamSkipUntil(','); // Skip the role int8_t mux = streamGetIntBefore('\n'); - DBG("### Got Data:", mux); + // DBG("### Got Data:", mux); if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { // We have no way of knowing how much data actually came in, so // we set the value to 1500, the maximum possible size. @@ -578,7 +586,11 @@ class TinyGsmM95 : public TinyGsmModem, int8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), GsmConstStr r2 = GFP(GSM_ERROR), +#if defined TINY_GSM_DEBUG GsmConstStr r3 = GFP(GSM_CME_ERROR), +#else + GsmConstStr r3 = NULL, +#endif GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { String data; return waitResponse(timeout_ms, data, r1, r2, r3, r4, r5); @@ -586,7 +598,11 @@ class TinyGsmM95 : public TinyGsmModem, int8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), GsmConstStr r2 = GFP(GSM_ERROR), +#if defined TINY_GSM_DEBUG GsmConstStr r3 = GFP(GSM_CME_ERROR), +#else + GsmConstStr r3 = NULL, +#endif GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { return waitResponse(1000, r1, r2, r3, r4, r5); } diff --git a/src/TinyGsmClientMC60.h b/src/TinyGsmClientMC60.h index d6e5eb5..4b0daec 100644 --- a/src/TinyGsmClientMC60.h +++ b/src/TinyGsmClientMC60.h @@ -27,9 +27,11 @@ #include "TinyGsmTime.tpp" #define GSM_NL "\r\n" -static const char GSM_OK[] TINY_GSM_PROGMEM = "OK" GSM_NL; -static const char GSM_ERROR[] TINY_GSM_PROGMEM = "ERROR" GSM_NL; +static const char GSM_OK[] TINY_GSM_PROGMEM = "OK" GSM_NL; +static const char GSM_ERROR[] TINY_GSM_PROGMEM = "ERROR" GSM_NL; +#if defined TINY_GSM_DEBUG static const char GSM_CME_ERROR[] TINY_GSM_PROGMEM = GSM_NL "+CME ERROR:"; +#endif enum RegStatus { REG_NO_RESULT = -1, @@ -426,7 +428,7 @@ class TinyGsmMC60 : public TinyGsmModem, // FIFO } waitResponse(); // ends with an OK - DBG("### READ:", len, "from", mux); + // DBG("### READ:", len, "from", mux); return len; } else { sockets[mux]->sock_available = 0; @@ -465,7 +467,11 @@ class TinyGsmMC60 : public TinyGsmModem, int8_t waitResponse(uint32_t timeout_ms, String& data, GsmConstStr r1 = GFP(GSM_OK), GsmConstStr r2 = GFP(GSM_ERROR), +#if defined TINY_GSM_DEBUG GsmConstStr r3 = GFP(GSM_CME_ERROR), +#else + GsmConstStr r3 = NULL, +#endif GsmConstStr r4 = NULL, GsmConstStr r5 = NULL, GsmConstStr r6 = NULL) { /*String r1s(r1); r1s.trim(); @@ -492,9 +498,11 @@ class TinyGsmMC60 : public TinyGsmModem, index = 2; goto finish; } else if (r3 && data.endsWith(r3)) { +#if defined TINY_GSM_DEBUG if (r3 == GFP(GSM_CME_ERROR)) { streamSkipUntil('\n'); // Read out the error } +#endif index = 3; goto finish; } else if (r4 && data.endsWith(r4)) { @@ -521,7 +529,7 @@ class TinyGsmMC60 : public TinyGsmModem, sockets[mux]->sock_available = len_packet * num_packets; } data = ""; - DBG("### Got Data:", len_packet * num_packets, "on", mux); + // DBG("### Got Data:", len_packet * num_packets, "on", mux); } else if (data.endsWith(GF("CLOSED" GSM_NL))) { int8_t nl = data.lastIndexOf(GSM_NL, data.length() - 8); int8_t coma = data.indexOf(',', nl + 2); @@ -547,7 +555,11 @@ class TinyGsmMC60 : public TinyGsmModem, int8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), GsmConstStr r2 = GFP(GSM_ERROR), +#if defined TINY_GSM_DEBUG GsmConstStr r3 = GFP(GSM_CME_ERROR), +#else + GsmConstStr r3 = NULL, +#endif GsmConstStr r4 = NULL, GsmConstStr r5 = NULL, GsmConstStr r6 = NULL) { String data; @@ -556,7 +568,11 @@ class TinyGsmMC60 : public TinyGsmModem, int8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), GsmConstStr r2 = GFP(GSM_ERROR), +#if defined TINY_GSM_DEBUG GsmConstStr r3 = GFP(GSM_CME_ERROR), +#else + GsmConstStr r3 = NULL, +#endif GsmConstStr r4 = NULL, GsmConstStr r5 = NULL, GsmConstStr r6 = NULL) { return waitResponse(1000, r1, r2, r3, r4, r5, r6); diff --git a/src/TinyGsmClientSIM5360.h b/src/TinyGsmClientSIM5360.h index 139e9ca..12fb879 100644 --- a/src/TinyGsmClientSIM5360.h +++ b/src/TinyGsmClientSIM5360.h @@ -25,9 +25,11 @@ #include "TinyGsmTime.tpp" #define GSM_NL "\r\n" -static const char GSM_OK[] TINY_GSM_PROGMEM = "OK" GSM_NL; -static const char GSM_ERROR[] TINY_GSM_PROGMEM = "ERROR" GSM_NL; +static const char GSM_OK[] TINY_GSM_PROGMEM = "OK" GSM_NL; +static const char GSM_ERROR[] TINY_GSM_PROGMEM = "ERROR" GSM_NL; +#if defined TINY_GSM_DEBUG static const char GSM_CME_ERROR[] TINY_GSM_PROGMEM = GSM_NL "+CME ERROR:"; +#endif enum RegStatus { REG_NO_RESULT = -1, @@ -536,7 +538,7 @@ class TinyGsmSim5360 : public TinyGsmModem, #endif sockets[mux]->rx.put(c); } - DBG("### READ:", len_requested, "from", mux); + // DBG("### READ:", len_requested, "from", mux); // sockets[mux]->sock_available = modemGetAvailable(mux); sockets[mux]->sock_available = len_confirmed; waitResponse(); @@ -552,7 +554,7 @@ class TinyGsmSim5360 : public TinyGsmModem, result = streamGetIntBefore('\n'); waitResponse(); } - DBG("### Available:", result, "on", mux); + // DBG("### Available:", result, "on", mux); if (!result) { sockets[mux]->sock_connected = modemGetConnected(mux); } return result; } @@ -577,7 +579,11 @@ class TinyGsmSim5360 : public TinyGsmModem, int8_t waitResponse(uint32_t timeout_ms, String& data, GsmConstStr r1 = GFP(GSM_OK), GsmConstStr r2 = GFP(GSM_ERROR), +#if defined TINY_GSM_DEBUG GsmConstStr r3 = GFP(GSM_CME_ERROR), +#else + GsmConstStr r3 = NULL, +#endif GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { /*String r1s(r1); r1s.trim(); String r2s(r2); r2s.trim(); @@ -602,9 +608,11 @@ class TinyGsmSim5360 : public TinyGsmModem, index = 2; goto finish; } else if (r3 && data.endsWith(r3)) { +#if defined TINY_GSM_DEBUG if (r3 == GFP(GSM_CME_ERROR)) { streamSkipUntil('\n'); // Read out the error } +#endif index = 3; goto finish; } else if (r4 && data.endsWith(r4)) { @@ -621,7 +629,7 @@ class TinyGsmSim5360 : public TinyGsmModem, sockets[mux]->got_data = true; } data = ""; - DBG("### Got Data:", mux); + // DBG("### Got Data:", mux); } else { data += mode; } @@ -633,7 +641,7 @@ class TinyGsmSim5360 : public TinyGsmModem, sockets[mux]->sock_available = len; } data = ""; - DBG("### Got Data:", len, "on", mux); + // DBG("### Got Data:", len, "on", mux); } else if (data.endsWith(GF("+IPCLOSE:"))) { int8_t mux = streamGetIntBefore(','); streamSkipUntil('\n'); // Skip the reason code @@ -664,7 +672,11 @@ class TinyGsmSim5360 : public TinyGsmModem, int8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), GsmConstStr r2 = GFP(GSM_ERROR), +#if defined TINY_GSM_DEBUG GsmConstStr r3 = GFP(GSM_CME_ERROR), +#else + GsmConstStr r3 = NULL, +#endif GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { String data; return waitResponse(timeout_ms, data, r1, r2, r3, r4, r5); @@ -672,7 +684,11 @@ class TinyGsmSim5360 : public TinyGsmModem, int8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), GsmConstStr r2 = GFP(GSM_ERROR), +#if defined TINY_GSM_DEBUG GsmConstStr r3 = GFP(GSM_CME_ERROR), +#else + GsmConstStr r3 = NULL, +#endif GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { return waitResponse(1000, r1, r2, r3, r4, r5); } diff --git a/src/TinyGsmClientSIM7000.h b/src/TinyGsmClientSIM7000.h index 3f2df28..5c3ee2b 100644 --- a/src/TinyGsmClientSIM7000.h +++ b/src/TinyGsmClientSIM7000.h @@ -24,9 +24,11 @@ #include "TinyGsmTime.tpp" #define GSM_NL "\r\n" -static const char GSM_OK[] TINY_GSM_PROGMEM = "OK" GSM_NL; -static const char GSM_ERROR[] TINY_GSM_PROGMEM = "ERROR" GSM_NL; +static const char GSM_OK[] TINY_GSM_PROGMEM = "OK" GSM_NL; +static const char GSM_ERROR[] TINY_GSM_PROGMEM = "ERROR" GSM_NL; +#if defined TINY_GSM_DEBUG static const char GSM_CME_ERROR[] TINY_GSM_PROGMEM = GSM_NL "+CME ERROR:"; +#endif enum RegStatus { REG_NO_RESULT = -1, @@ -573,7 +575,7 @@ class TinyGsmSim7000 : public TinyGsmModem, #endif sockets[mux]->rx.put(c); } - DBG("### READ:", len_requested, "from", mux); + // DBG("### READ:", len_requested, "from", mux); // sockets[mux]->sock_available = modemGetAvailable(mux); sockets[mux]->sock_available = len_confirmed; waitResponse(); @@ -589,7 +591,7 @@ class TinyGsmSim7000 : public TinyGsmModem, result = streamGetIntBefore('\n'); waitResponse(); } - DBG("### Available:", result, "on", mux); + // DBG("### Available:", result, "on", mux); if (!result) { sockets[mux]->sock_connected = modemGetConnected(mux); } return result; } @@ -610,7 +612,11 @@ class TinyGsmSim7000 : public TinyGsmModem, int8_t waitResponse(uint32_t timeout_ms, String& data, GsmConstStr r1 = GFP(GSM_OK), GsmConstStr r2 = GFP(GSM_ERROR), +#if defined TINY_GSM_DEBUG GsmConstStr r3 = GFP(GSM_CME_ERROR), +#else + GsmConstStr r3 = NULL, +#endif GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { /*String r1s(r1); r1s.trim(); String r2s(r2); r2s.trim(); @@ -635,9 +641,11 @@ class TinyGsmSim7000 : public TinyGsmModem, index = 2; goto finish; } else if (r3 && data.endsWith(r3)) { +#if defined TINY_GSM_DEBUG if (r3 == GFP(GSM_CME_ERROR)) { streamSkipUntil('\n'); // Read out the error } +#endif index = 3; goto finish; } else if (r4 && data.endsWith(r4)) { @@ -654,7 +662,7 @@ class TinyGsmSim7000 : public TinyGsmModem, sockets[mux]->got_data = true; } data = ""; - DBG("### Got Data:", mux); + // DBG("### Got Data:", mux); } else { data += mode; } @@ -666,7 +674,7 @@ class TinyGsmSim7000 : public TinyGsmModem, sockets[mux]->sock_available = len; } data = ""; - DBG("### Got Data:", len, "on", mux); + // DBG("### Got Data:", len, "on", mux); } else if (data.endsWith(GF("CLOSED" GSM_NL))) { int8_t nl = data.lastIndexOf(GSM_NL, data.length() - 8); int8_t coma = data.indexOf(',', nl + 2); @@ -692,7 +700,11 @@ class TinyGsmSim7000 : public TinyGsmModem, int8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), GsmConstStr r2 = GFP(GSM_ERROR), +#if defined TINY_GSM_DEBUG GsmConstStr r3 = GFP(GSM_CME_ERROR), +#else + GsmConstStr r3 = NULL, +#endif GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { String data; return waitResponse(timeout_ms, data, r1, r2, r3, r4, r5); @@ -700,7 +712,11 @@ class TinyGsmSim7000 : public TinyGsmModem, int8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), GsmConstStr r2 = GFP(GSM_ERROR), +#if defined TINY_GSM_DEBUG GsmConstStr r3 = GFP(GSM_CME_ERROR), +#else + GsmConstStr r3 = NULL, +#endif GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { return waitResponse(1000, r1, r2, r3, r4, r5); } diff --git a/src/TinyGsmClientSIM7600.h b/src/TinyGsmClientSIM7600.h index 6b8e8b3..576f342 100644 --- a/src/TinyGsmClientSIM7600.h +++ b/src/TinyGsmClientSIM7600.h @@ -26,9 +26,11 @@ #include "TinyGsmTime.tpp" #define GSM_NL "\r\n" -static const char GSM_OK[] TINY_GSM_PROGMEM = "OK" GSM_NL; -static const char GSM_ERROR[] TINY_GSM_PROGMEM = "ERROR" GSM_NL; +static const char GSM_OK[] TINY_GSM_PROGMEM = "OK" GSM_NL; +static const char GSM_ERROR[] TINY_GSM_PROGMEM = "ERROR" GSM_NL; +#if defined TINY_GSM_DEBUG static const char GSM_CME_ERROR[] TINY_GSM_PROGMEM = GSM_NL "+CME ERROR:"; +#endif enum RegStatus { REG_NO_RESULT = -1, @@ -624,7 +626,7 @@ class TinyGsmSim7600 : public TinyGsmModem, #endif sockets[mux]->rx.put(c); } - DBG("### READ:", len_requested, "from", mux); + // DBG("### READ:", len_requested, "from", mux); // sockets[mux]->sock_available = modemGetAvailable(mux); sockets[mux]->sock_available = len_confirmed; waitResponse(); @@ -640,7 +642,7 @@ class TinyGsmSim7600 : public TinyGsmModem, result = streamGetIntBefore('\n'); waitResponse(); } - DBG("### Available:", result, "on", mux); + // DBG("### Available:", result, "on", mux); if (!result) { sockets[mux]->sock_connected = modemGetConnected(mux); } return result; } @@ -667,7 +669,11 @@ class TinyGsmSim7600 : public TinyGsmModem, int8_t waitResponse(uint32_t timeout_ms, String& data, GsmConstStr r1 = GFP(GSM_OK), GsmConstStr r2 = GFP(GSM_ERROR), +#if defined TINY_GSM_DEBUG GsmConstStr r3 = GFP(GSM_CME_ERROR), +#else + GsmConstStr r3 = NULL, +#endif GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { /*String r1s(r1); r1s.trim(); String r2s(r2); r2s.trim(); @@ -692,9 +698,11 @@ class TinyGsmSim7600 : public TinyGsmModem, index = 2; goto finish; } else if (r3 && data.endsWith(r3)) { +#if defined TINY_GSM_DEBUG if (r3 == GFP(GSM_CME_ERROR)) { streamSkipUntil('\n'); // Read out the error } +#endif index = 3; goto finish; } else if (r4 && data.endsWith(r4)) { @@ -711,7 +719,7 @@ class TinyGsmSim7600 : public TinyGsmModem, sockets[mux]->got_data = true; } data = ""; - DBG("### Got Data:", mux); + // DBG("### Got Data:", mux); } else { data += mode; } @@ -723,7 +731,7 @@ class TinyGsmSim7600 : public TinyGsmModem, sockets[mux]->sock_available = len; } data = ""; - DBG("### Got Data:", len, "on", mux); + // DBG("### Got Data:", len, "on", mux); } else if (data.endsWith(GF("+IPCLOSE:"))) { int8_t mux = streamGetIntBefore(','); streamSkipUntil('\n'); // Skip the reason code @@ -754,7 +762,11 @@ class TinyGsmSim7600 : public TinyGsmModem, int8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), GsmConstStr r2 = GFP(GSM_ERROR), +#if defined TINY_GSM_DEBUG GsmConstStr r3 = GFP(GSM_CME_ERROR), +#else + GsmConstStr r3 = NULL, +#endif GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { String data; return waitResponse(timeout_ms, data, r1, r2, r3, r4, r5); @@ -762,7 +774,11 @@ class TinyGsmSim7600 : public TinyGsmModem, int8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), GsmConstStr r2 = GFP(GSM_ERROR), +#if defined TINY_GSM_DEBUG GsmConstStr r3 = GFP(GSM_CME_ERROR), +#else + GsmConstStr r3 = NULL, +#endif GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { return waitResponse(1000, r1, r2, r3, r4, r5); } diff --git a/src/TinyGsmClientSIM800.h b/src/TinyGsmClientSIM800.h index be9ba5a..a0b599f 100644 --- a/src/TinyGsmClientSIM800.h +++ b/src/TinyGsmClientSIM800.h @@ -27,9 +27,11 @@ #include "TinyGsmTime.tpp" #define GSM_NL "\r\n" -static const char GSM_OK[] TINY_GSM_PROGMEM = "OK" GSM_NL; -static const char GSM_ERROR[] TINY_GSM_PROGMEM = "ERROR" GSM_NL; +static const char GSM_OK[] TINY_GSM_PROGMEM = "OK" GSM_NL; +static const char GSM_ERROR[] TINY_GSM_PROGMEM = "ERROR" GSM_NL; +#if defined TINY_GSM_DEBUG static const char GSM_CME_ERROR[] TINY_GSM_PROGMEM = GSM_NL "+CME ERROR:"; +#endif enum RegStatus { REG_NO_RESULT = -1, @@ -548,7 +550,7 @@ class TinyGsmSim800 : public TinyGsmModem, #endif sockets[mux]->rx.put(c); } - DBG("### READ:", len_requested, "from", mux); + // DBG("### READ:", len_requested, "from", mux); // sockets[mux]->sock_available = modemGetAvailable(mux); sockets[mux]->sock_available = len_confirmed; waitResponse(); @@ -564,7 +566,7 @@ class TinyGsmSim800 : public TinyGsmModem, result = streamGetIntBefore('\n'); waitResponse(); } - DBG("### Available:", result, "on", mux); + // DBG("### Available:", result, "on", mux); if (!result) { sockets[mux]->sock_connected = modemGetConnected(mux); } return result; } @@ -587,7 +589,11 @@ class TinyGsmSim800 : public TinyGsmModem, int8_t waitResponse(uint32_t timeout_ms, String& data, GsmConstStr r1 = GFP(GSM_OK), GsmConstStr r2 = GFP(GSM_ERROR), +#if defined TINY_GSM_DEBUG GsmConstStr r3 = GFP(GSM_CME_ERROR), +#else + GsmConstStr r3 = NULL, +#endif GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { /*String r1s(r1); r1s.trim(); String r2s(r2); r2s.trim(); @@ -612,9 +618,11 @@ class TinyGsmSim800 : public TinyGsmModem, index = 2; goto finish; } else if (r3 && data.endsWith(r3)) { +#if defined TINY_GSM_DEBUG if (r3 == GFP(GSM_CME_ERROR)) { streamSkipUntil('\n'); // Read out the error } +#endif index = 3; goto finish; } else if (r4 && data.endsWith(r4)) { @@ -631,7 +639,7 @@ class TinyGsmSim800 : public TinyGsmModem, sockets[mux]->got_data = true; } data = ""; - DBG("### Got Data:", mux); + // DBG("### Got Data:", mux); } else { data += mode; } @@ -643,7 +651,7 @@ class TinyGsmSim800 : public TinyGsmModem, sockets[mux]->sock_available = len; } data = ""; - DBG("### Got Data:", len, "on", mux); + // DBG("### Got Data:", len, "on", mux); } else if (data.endsWith(GF("CLOSED" GSM_NL))) { int8_t nl = data.lastIndexOf(GSM_NL, data.length() - 8); int8_t coma = data.indexOf(',', nl + 2); @@ -669,7 +677,11 @@ class TinyGsmSim800 : public TinyGsmModem, int8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), GsmConstStr r2 = GFP(GSM_ERROR), +#if defined TINY_GSM_DEBUG GsmConstStr r3 = GFP(GSM_CME_ERROR), +#else + GsmConstStr r3 = NULL, +#endif GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { String data; return waitResponse(timeout_ms, data, r1, r2, r3, r4, r5); @@ -677,7 +689,11 @@ class TinyGsmSim800 : public TinyGsmModem, int8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), GsmConstStr r2 = GFP(GSM_ERROR), +#if defined TINY_GSM_DEBUG GsmConstStr r3 = GFP(GSM_CME_ERROR), +#else + GsmConstStr r3 = NULL, +#endif GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { return waitResponse(1000, r1, r2, r3, r4, r5); } diff --git a/src/TinyGsmClientSaraR4.h b/src/TinyGsmClientSaraR4.h index dbb6084..9edc74c 100644 --- a/src/TinyGsmClientSaraR4.h +++ b/src/TinyGsmClientSaraR4.h @@ -27,9 +27,11 @@ #include "TinyGsmTime.tpp" #define GSM_NL "\r\n" -static const char GSM_OK[] TINY_GSM_PROGMEM = "OK" GSM_NL; -static const char GSM_ERROR[] TINY_GSM_PROGMEM = "ERROR" GSM_NL; +static const char GSM_OK[] TINY_GSM_PROGMEM = "OK" GSM_NL; +static const char GSM_ERROR[] TINY_GSM_PROGMEM = "ERROR" GSM_NL; +#if defined TINY_GSM_DEBUG static const char GSM_CME_ERROR[] TINY_GSM_PROGMEM = GSM_NL "+CME ERROR:"; +#endif enum RegStatus { REG_NO_RESULT = -1, @@ -719,7 +721,7 @@ class TinyGsmSaraR4 : public TinyGsmModem, for (int i = 0; i < len; i++) { moveCharFromStreamToFifo(mux); } streamSkipUntil('\"'); waitResponse(); - DBG("### READ:", len, "from", mux); + // DBG("### READ:", len, "from", mux); sockets[mux]->sock_available = modemGetAvailable(mux); return len; } @@ -738,7 +740,7 @@ class TinyGsmSaraR4 : public TinyGsmModem, waitResponse(); } if (!result) { sockets[mux]->sock_connected = modemGetConnected(mux); } - DBG("### AVAILABLE:", result, "on", mux); + // DBG("### AvailablE:", result, "on", mux); return result; } @@ -775,7 +777,11 @@ class TinyGsmSaraR4 : public TinyGsmModem, int8_t waitResponse(uint32_t timeout_ms, String& data, GsmConstStr r1 = GFP(GSM_OK), GsmConstStr r2 = GFP(GSM_ERROR), +#if defined TINY_GSM_DEBUG GsmConstStr r3 = GFP(GSM_CME_ERROR), +#else + GsmConstStr r3 = NULL, +#endif GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { /*String r1s(r1); r1s.trim(); String r2s(r2); r2s.trim(); @@ -800,9 +806,11 @@ class TinyGsmSaraR4 : public TinyGsmModem, index = 2; goto finish; } else if (r3 && data.endsWith(r3)) { +#if defined TINY_GSM_DEBUG if (r3 == GFP(GSM_CME_ERROR)) { streamSkipUntil('\n'); // Read out the error } +#endif index = 3; goto finish; } else if (r4 && data.endsWith(r4)) { @@ -852,7 +860,11 @@ class TinyGsmSaraR4 : public TinyGsmModem, int8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), GsmConstStr r2 = GFP(GSM_ERROR), +#if defined TINY_GSM_DEBUG GsmConstStr r3 = GFP(GSM_CME_ERROR), +#else + GsmConstStr r3 = NULL, +#endif GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { String data; return waitResponse(timeout_ms, data, r1, r2, r3, r4, r5); @@ -860,7 +872,11 @@ class TinyGsmSaraR4 : public TinyGsmModem, int8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), GsmConstStr r2 = GFP(GSM_ERROR), +#if defined TINY_GSM_DEBUG GsmConstStr r3 = GFP(GSM_CME_ERROR), +#else + GsmConstStr r3 = NULL, +#endif GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { return waitResponse(1000, r1, r2, r3, r4, r5); } diff --git a/src/TinyGsmClientSequansMonarch.h b/src/TinyGsmClientSequansMonarch.h index d47abaf..b97766a 100644 --- a/src/TinyGsmClientSequansMonarch.h +++ b/src/TinyGsmClientSequansMonarch.h @@ -24,9 +24,11 @@ #include "TinyGsmTime.tpp" #define GSM_NL "\r\n" -static const char GSM_OK[] TINY_GSM_PROGMEM = "OK" GSM_NL; -static const char GSM_ERROR[] TINY_GSM_PROGMEM = "ERROR" GSM_NL; +static const char GSM_OK[] TINY_GSM_PROGMEM = "OK" GSM_NL; +static const char GSM_ERROR[] TINY_GSM_PROGMEM = "ERROR" GSM_NL; +#if defined TINY_GSM_DEBUG static const char GSM_CME_ERROR[] TINY_GSM_PROGMEM = GSM_NL "+CME ERROR:"; +#endif enum RegStatus { REG_NO_RESULT = -1, @@ -506,7 +508,7 @@ class TinyGsmSequansMonarch char c = stream.read(); sockets[mux % TINY_GSM_MUX_COUNT]->rx.put(c); } - DBG("### Read:", len, "from", mux); + // DBG("### READ:", len, "from", mux); waitResponse(); sockets[mux % TINY_GSM_MUX_COUNT]->sock_available = modemGetAvailable(mux); return len; @@ -522,7 +524,7 @@ class TinyGsmSequansMonarch result = streamGetIntBefore(','); // keep data not yet read waitResponse(); } - DBG("### Available:", result, "on", mux); + // DBG("### Available:", result, "on", mux); return result; } @@ -564,7 +566,11 @@ class TinyGsmSequansMonarch int8_t waitResponse(uint32_t timeout_ms, String& data, GsmConstStr r1 = GFP(GSM_OK), GsmConstStr r2 = GFP(GSM_ERROR), +#if defined TINY_GSM_DEBUG GsmConstStr r3 = GFP(GSM_CME_ERROR), +#else + GsmConstStr r3 = NULL, +#endif GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { /*String r1s(r1); r1s.trim(); String r2s(r2); r2s.trim(); @@ -589,9 +595,11 @@ class TinyGsmSequansMonarch index = 2; goto finish; } else if (r3 && data.endsWith(r3)) { +#if defined TINY_GSM_DEBUG if (r3 == GFP(GSM_CME_ERROR)) { streamSkipUntil('\n'); // Read out the error } +#endif index = 3; goto finish; } else if (r4 && data.endsWith(r4)) { @@ -634,7 +642,11 @@ class TinyGsmSequansMonarch int8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), GsmConstStr r2 = GFP(GSM_ERROR), +#if defined TINY_GSM_DEBUG GsmConstStr r3 = GFP(GSM_CME_ERROR), +#else + GsmConstStr r3 = NULL, +#endif GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { String data; return waitResponse(timeout_ms, data, r1, r2, r3, r4, r5); @@ -642,7 +654,11 @@ class TinyGsmSequansMonarch int8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), GsmConstStr r2 = GFP(GSM_ERROR), +#if defined TINY_GSM_DEBUG GsmConstStr r3 = GFP(GSM_CME_ERROR), +#else + GsmConstStr r3 = NULL, +#endif GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { return waitResponse(1000, r1, r2, r3, r4, r5); } diff --git a/src/TinyGsmClientUBLOX.h b/src/TinyGsmClientUBLOX.h index cddb756..ec94ff4 100644 --- a/src/TinyGsmClientUBLOX.h +++ b/src/TinyGsmClientUBLOX.h @@ -27,9 +27,11 @@ #include "TinyGsmTime.tpp" #define GSM_NL "\r\n" -static const char GSM_OK[] TINY_GSM_PROGMEM = "OK" GSM_NL; -static const char GSM_ERROR[] TINY_GSM_PROGMEM = "ERROR" GSM_NL; +static const char GSM_OK[] TINY_GSM_PROGMEM = "OK" GSM_NL; +static const char GSM_ERROR[] TINY_GSM_PROGMEM = "ERROR" GSM_NL; +#if defined TINY_GSM_DEBUG static const char GSM_CME_ERROR[] TINY_GSM_PROGMEM = GSM_NL "+CME ERROR:"; +#endif enum RegStatus { REG_NO_RESULT = -1, @@ -651,7 +653,7 @@ class TinyGsmUBLOX : public TinyGsmModem, for (int i = 0; i < len; i++) { moveCharFromStreamToFifo(mux); } streamSkipUntil('\"'); waitResponse(); - DBG("### READ:", len, "from", mux); + // DBG("### READ:", len, "from", mux); sockets[mux]->sock_available = modemGetAvailable(mux); return len; } @@ -670,7 +672,7 @@ class TinyGsmUBLOX : public TinyGsmModem, waitResponse(); } if (!result) { sockets[mux]->sock_connected = modemGetConnected(mux); } - DBG("### AVAILABLE:", result, "on", mux); + // DBG("### AvailablE:", result, "on", mux); return result; } @@ -707,7 +709,11 @@ class TinyGsmUBLOX : public TinyGsmModem, int8_t waitResponse(uint32_t timeout_ms, String& data, GsmConstStr r1 = GFP(GSM_OK), GsmConstStr r2 = GFP(GSM_ERROR), +#if defined TINY_GSM_DEBUG GsmConstStr r3 = GFP(GSM_CME_ERROR), +#else + GsmConstStr r3 = NULL, +#endif GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { /*String r1s(r1); r1s.trim(); String r2s(r2); r2s.trim(); @@ -732,9 +738,11 @@ class TinyGsmUBLOX : public TinyGsmModem, index = 2; goto finish; } else if (r3 && data.endsWith(r3)) { +#if defined TINY_GSM_DEBUG if (r3 == GFP(GSM_CME_ERROR)) { streamSkipUntil('\n'); // Read out the error } +#endif index = 3; goto finish; } else if (r4 && data.endsWith(r4)) { @@ -775,7 +783,11 @@ class TinyGsmUBLOX : public TinyGsmModem, int8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), GsmConstStr r2 = GFP(GSM_ERROR), +#if defined TINY_GSM_DEBUG GsmConstStr r3 = GFP(GSM_CME_ERROR), +#else + GsmConstStr r3 = NULL, +#endif GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { String data; return waitResponse(timeout_ms, data, r1, r2, r3, r4, r5); @@ -783,7 +795,11 @@ class TinyGsmUBLOX : public TinyGsmModem, int8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), GsmConstStr r2 = GFP(GSM_ERROR), +#if defined TINY_GSM_DEBUG GsmConstStr r3 = GFP(GSM_CME_ERROR), +#else + GsmConstStr r3 = NULL, +#endif GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { return waitResponse(1000, r1, r2, r3, r4, r5); }