From b8efb21f29cdd01ed30e0424b947ca3a7f84109a Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 13 May 2024 14:03:29 -0400 Subject: [PATCH] Rename GSM_NL to AT_NL Signed-off-by: Sara Damiano --- .../SIM800_SslSetCert/SIM800_SslSetCert.ino | 24 ++++------ src/TinyGsmClientA6.h | 44 +++++++++---------- src/TinyGsmClientBG96.h | 20 ++++----- src/TinyGsmClientESP8266.h | 26 +++++------ src/TinyGsmClientM590.h | 23 +++++----- src/TinyGsmClientM95.h | 28 ++++++------ src/TinyGsmClientMC60.h | 26 +++++------ src/TinyGsmClientSIM5360.h | 40 ++++++++--------- src/TinyGsmClientSIM7000.h | 23 +++++----- src/TinyGsmClientSIM7000SSL.h | 17 ++++--- src/TinyGsmClientSIM7080.h | 15 +++---- src/TinyGsmClientSIM70xx.h | 24 +++++----- src/TinyGsmClientSIM7600.h | 44 +++++++++---------- src/TinyGsmClientSIM800.h | 34 +++++++------- src/TinyGsmClientSIM808.h | 28 ++++++------ src/TinyGsmClientSaraR4.h | 36 +++++++-------- src/TinyGsmClientSequansMonarch.h | 24 +++++----- src/TinyGsmClientUBLOX.h | 34 +++++++------- src/TinyGsmClientXBee.h | 8 ++-- src/TinyGsmModem.tpp | 36 +++++++-------- 20 files changed, 271 insertions(+), 283 deletions(-) diff --git a/examples/more/SIM800_SslSetCert/SIM800_SslSetCert.ino b/examples/more/SIM800_SslSetCert/SIM800_SslSetCert.ino index eef42076..cefb37cc 100644 --- a/examples/more/SIM800_SslSetCert/SIM800_SslSetCert.ino +++ b/examples/more/SIM800_SslSetCert/SIM800_SslSetCert.ino @@ -32,11 +32,11 @@ #ifdef DUMP_AT_COMMANDS - #include - StreamDebugger debugger(SerialAT, SerialMon); - TinyGsm modem(debugger); +#include +StreamDebugger debugger(SerialAT, SerialMon); +TinyGsm modem(debugger); #else - TinyGsm modem(SerialAT); +TinyGsm modem(SerialAT); #endif void setup() { @@ -57,23 +57,21 @@ void setup() { const int cert_size = sizeof(cert); modem.sendAT(GF("+FSWRITE=" CERT_FILE ",0,"), cert_size, GF(",10")); - if (modem.waitResponse(GF(">")) != 1) { - return; - } + if (modem.waitResponse(GF(">")) != 1) { return; } for (int i = 0; i < cert_size; i++) { char c = pgm_read_byte(&cert[i]); modem.stream.write(c); } - modem.stream.write(GSM_NL); + modem.stream.write(AT_NL); modem.stream.flush(); if (modem.waitResponse(2000) != 1) return; modem.sendAT(GF("+SSLSETCERT=\"" CERT_FILE "\"")); if (modem.waitResponse() != 1) return; - if (modem.waitResponse(5000L, GF(GSM_NL "+SSLSETCERT:")) != 1) return; + if (modem.waitResponse(5000L, GF(AT_NL "+SSLSETCERT:")) != 1) return; const int retCode = modem.stream.readStringUntil('\n').toInt(); @@ -86,11 +84,7 @@ void setup() { } void loop() { - if (SerialAT.available()) { - SerialMon.write(SerialAT.read()); - } - if (SerialMon.available()) { - SerialAT.write(SerialMon.read()); - } + if (SerialAT.available()) { SerialMon.write(SerialAT.read()); } + if (SerialMon.available()) { SerialAT.write(SerialMon.read()); } delay(0); } diff --git a/src/TinyGsmClientA6.h b/src/TinyGsmClientA6.h index f617a7ce..4763ecbe 100644 --- a/src/TinyGsmClientA6.h +++ b/src/TinyGsmClientA6.h @@ -14,9 +14,9 @@ #define TINY_GSM_MUX_COUNT 8 #define TINY_GSM_NO_MODEM_BUFFER -#ifdef GSM_NL -#undef GSM_NL -#define GSM_NL "\r\n" // NOTE: define before including TinyGsmModem! +#ifdef AT_NL +#undef AT_NL +#define AT_NL "\r\n" // NOTE: define before including TinyGsmModem! #endif #include "TinyGsmBattery.tpp" @@ -208,8 +208,8 @@ class TinyGsmA6 : public TinyGsmModem, sendAT(GF("+CIFSR")); String res; if (waitResponse(10000L, res) != 1) { return ""; } - res.replace(GSM_NL "OK" GSM_NL, ""); - res.replace(GSM_NL, ""); + res.replace(AT_NL "OK" AT_NL, ""); + res.replace(AT_NL, ""); res.trim(); return res; } @@ -262,7 +262,7 @@ class TinyGsmA6 : public TinyGsmModem, waitResponse(); sendAT(GF("+COPS?")); - if (waitResponse(GF(GSM_NL "+COPS:")) != 1) { return ""; } + if (waitResponse(GF(AT_NL "+COPS:")) != 1) { return ""; } streamSkipUntil('"'); // Skip mode and format String res = stream.readStringUntil('"'); waitResponse(); @@ -275,7 +275,7 @@ class TinyGsmA6 : public TinyGsmModem, protected: String getSimCCIDImpl() { sendAT(GF("+CCID")); - if (waitResponse(GF(GSM_NL "+SCID: SIM Card ID:")) != 1) { return ""; } + if (waitResponse(GF(AT_NL "+SCID: SIM Card ID:")) != 1) { return ""; } String res = stream.readStringUntil('\n'); waitResponse(); res.trim(); @@ -296,16 +296,16 @@ class TinyGsmA6 : public TinyGsmModem, if (waitResponse(5000L) != 1) { return false; } - if (waitResponse(60000L, GF(GSM_NL "+CIEV: \"CALL\",1"), - GF(GSM_NL "+CIEV: \"CALL\",0"), GFP(GSM_ERROR)) != 1) { + if (waitResponse(60000L, GF(AT_NL "+CIEV: \"CALL\",1"), + GF(AT_NL "+CIEV: \"CALL\",0"), GFP(GSM_ERROR)) != 1) { return false; } - int8_t rsp = waitResponse(60000L, GF(GSM_NL "+CIEV: \"SOUNDER\",0"), - GF(GSM_NL "+CIEV: \"CALL\",0")); + int8_t rsp = waitResponse(60000L, GF(AT_NL "+CIEV: \"SOUNDER\",0"), + GF(AT_NL "+CIEV: \"CALL\",0")); - int8_t rsp2 = waitResponse(300L, GF(GSM_NL "BUSY" GSM_NL), - GF(GSM_NL "NO ANSWER" GSM_NL)); + int8_t rsp2 = waitResponse(300L, GF(AT_NL "BUSY" AT_NL), + GF(AT_NL "NO ANSWER" AT_NL)); return rsp == 1 && rsp2 == 0; } @@ -358,7 +358,7 @@ class TinyGsmA6 : public TinyGsmModem, waitResponse(); sendAT(GF("+CUSD=1,\""), code, GF("\",15")); if (waitResponse(10000L) != 1) { return ""; } - if (waitResponse(GF(GSM_NL "+CUSD:")) != 1) { return ""; } + if (waitResponse(GF(AT_NL "+CUSD:")) != 1) { return ""; } streamSkipUntil('"'); String hex = stream.readStringUntil('"'); streamSkipUntil(','); @@ -389,7 +389,7 @@ class TinyGsmA6 : public TinyGsmModem, // Needs a '?' after CBC, unlike most int8_t getBattPercentImpl() { sendAT(GF("+CBC?")); - if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { return false; } + if (waitResponse(GF(AT_NL "+CBC:")) != 1) { return false; } streamSkipUntil(','); // Skip battery charge status // Read battery charge level int8_t res = streamGetIntBefore('\n'); @@ -402,7 +402,7 @@ class TinyGsmA6 : public TinyGsmModem, bool getBattStatsImpl(uint8_t& chargeState, int8_t& percent, uint16_t& milliVolts) { sendAT(GF("+CBC?")); - if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { return false; } + if (waitResponse(GF(AT_NL "+CBC:")) != 1) { return false; } chargeState = streamGetIntBefore(','); percent = streamGetIntBefore('\n'); milliVolts = 0; @@ -421,12 +421,12 @@ class TinyGsmA6 : public TinyGsmModem, uint32_t timeout_ms = ((uint32_t)timeout_s) * 1000; sendAT(GF("+CIPSTART="), GF("\"TCP"), GF("\",\""), host, GF("\","), port); - if (waitResponse(timeout_ms, GF(GSM_NL "+CIPNUM:")) != 1) { return false; } + if (waitResponse(timeout_ms, GF(AT_NL "+CIPNUM:")) != 1) { return false; } int8_t newMux = streamGetIntBefore('\n'); - int8_t rsp = waitResponse( - (timeout_ms - (millis() - startMillis)), GF("CONNECT OK" GSM_NL), - GF("CONNECT FAIL" GSM_NL), GF("ALREADY CONNECT" GSM_NL)); + int8_t rsp = waitResponse((timeout_ms - (millis() - startMillis)), + GF("CONNECT OK" AT_NL), GF("CONNECT FAIL" AT_NL), + GF("ALREADY CONNECT" AT_NL)); if (waitResponse() != 1) { return false; } *mux = newMux; @@ -435,10 +435,10 @@ class TinyGsmA6 : public TinyGsmModem, int16_t modemSend(const void* buff, size_t len, uint8_t mux) { sendAT(GF("+CIPSEND="), mux, ',', (uint16_t)len); - if (waitResponse(2000L, GF(GSM_NL ">")) != 1) { return 0; } + if (waitResponse(2000L, GF(AT_NL ">")) != 1) { return 0; } stream.write(reinterpret_cast(buff), len); stream.flush(); - if (waitResponse(10000L, GFP(GSM_OK), GF(GSM_NL "FAIL")) != 1) { return 0; } + if (waitResponse(10000L, GFP(GSM_OK), GF(AT_NL "FAIL")) != 1) { return 0; } return len; } diff --git a/src/TinyGsmClientBG96.h b/src/TinyGsmClientBG96.h index b6057ec4..70f6a2e6 100644 --- a/src/TinyGsmClientBG96.h +++ b/src/TinyGsmClientBG96.h @@ -14,9 +14,9 @@ #define TINY_GSM_MUX_COUNT 12 #define TINY_GSM_BUFFER_READ_AND_CHECK_SIZE -#ifdef GSM_NL -#undef GSM_NL -#define GSM_NL "\r\n" // NOTE: define before including TinyGsmModem! +#ifdef AT_NL +#undef AT_NL +#define AT_NL "\r\n" // NOTE: define before including TinyGsmModem! #endif #include "TinyGsmBattery.tpp" @@ -289,7 +289,7 @@ class TinyGsmBG96 : public TinyGsmModem, protected: String getSimCCIDImpl() { sendAT(GF("+QCCID")); - if (waitResponse(GF(GSM_NL "+QCCID:")) != 1) { return ""; } + if (waitResponse(GF(AT_NL "+QCCID:")) != 1) { return ""; } String res = stream.readStringUntil('\n'); waitResponse(); res.trim(); @@ -337,7 +337,7 @@ class TinyGsmBG96 : public TinyGsmModem, // get the RAW GPS output String getGPSrawImpl() { sendAT(GF("+QGPSLOC=2")); - if (waitResponse(10000L, GF(GSM_NL "+QGPSLOC:")) != 1) { return ""; } + if (waitResponse(10000L, GF(AT_NL "+QGPSLOC:")) != 1) { return ""; } String res = stream.readStringUntil('\n'); waitResponse(); res.trim(); @@ -350,7 +350,7 @@ class TinyGsmBG96 : public TinyGsmModem, int* year = 0, int* month = 0, int* day = 0, int* hour = 0, int* minute = 0, int* second = 0) { sendAT(GF("+QGPSLOC=2")); - if (waitResponse(10000L, GF(GSM_NL "+QGPSLOC:")) != 1) { + if (waitResponse(10000L, GF(AT_NL "+QGPSLOC:")) != 1) { // NOTE: Will return an error if the position isn't fixed return false; } @@ -510,7 +510,7 @@ class TinyGsmBG96 : public TinyGsmModem, // get temperature in degree celsius uint16_t getTemperatureImpl() { sendAT(GF("+QTEMP")); - if (waitResponse(GF(GSM_NL "+QTEMP:")) != 1) { return 0; } + if (waitResponse(GF(AT_NL "+QTEMP:")) != 1) { return 0; } // return temperature in C uint16_t res = streamGetIntBefore(','); // read PMIC (primary ic) temperature @@ -538,7 +538,7 @@ class TinyGsmBG96 : public TinyGsmModem, GF("\","), port, GF(",0,0")); waitResponse(); - if (waitResponse(timeout_ms, GF(GSM_NL "+QIOPEN:")) != 1) { return false; } + if (waitResponse(timeout_ms, GF(AT_NL "+QIOPEN:")) != 1) { return false; } if (streamGetIntBefore(',') != mux) { return false; } // Read status @@ -550,7 +550,7 @@ class TinyGsmBG96 : public TinyGsmModem, if (waitResponse(GF(">")) != 1) { return 0; } stream.write(reinterpret_cast(buff), len); stream.flush(); - if (waitResponse(GF(GSM_NL "SEND OK")) != 1) { return 0; } + if (waitResponse(GF(AT_NL "SEND OK")) != 1) { return 0; } // TODO(?): Wait for ACK? AT+QISEND=id,0 return len; } @@ -607,7 +607,7 @@ class TinyGsmBG96 : public TinyGsmModem, */ public: bool handleURCs(String& data) { - if (data.endsWith(GF(GSM_NL "+QIURC:"))) { + if (data.endsWith(GF(AT_NL "+QIURC:"))) { streamSkipUntil('\"'); String urc = stream.readStringUntil('\"'); streamSkipUntil(','); diff --git a/src/TinyGsmClientESP8266.h b/src/TinyGsmClientESP8266.h index 590eb8d9..8f8ab523 100644 --- a/src/TinyGsmClientESP8266.h +++ b/src/TinyGsmClientESP8266.h @@ -14,9 +14,9 @@ #define TINY_GSM_MUX_COUNT 5 #define TINY_GSM_NO_MODEM_BUFFER -#ifdef GSM_NL -#undef GSM_NL -#define GSM_NL "\r\n" // NOTE: define before including TinyGsmModem! +#ifdef AT_NL +#undef AT_NL +#define AT_NL "\r\n" // NOTE: define before including TinyGsmModem! #endif #include "TinyGsmModem.tpp" @@ -190,8 +190,8 @@ class TinyGsmESP8266 : public TinyGsmModem, sendAT(GF("+GMR")); String res; if (waitResponse(1000L, res) != 1) { return ""; } - res.replace(GSM_NL "OK" GSM_NL, ""); - res.replace(GSM_NL, " "); + res.replace(AT_NL "OK" AT_NL, ""); + res.replace(AT_NL, " "); res.trim(); return res; } @@ -204,7 +204,7 @@ class TinyGsmESP8266 : public TinyGsmModem, if (!testAT()) { return false; } sendAT(GF("+RST")); if (waitResponse(10000L) != 1) { return false; } - if (waitResponse(10000L, GF(GSM_NL "ready" GSM_NL)) != 1) { return false; } + if (waitResponse(10000L, GF(AT_NL "ready" AT_NL)) != 1) { return false; } delay(500); return init(pin); } @@ -303,9 +303,9 @@ class TinyGsmESP8266 : public TinyGsmModem, // attempt first without than with the 'current' flag used in some firmware // versions sendAT(GF("+CWJAP=\""), ssid, GF("\",\""), pwd, GF("\"")); - if (waitResponse(30000L, GFP(GSM_OK), GF(GSM_NL "FAIL" GSM_NL)) != 1) { + if (waitResponse(30000L, GFP(AT_OK), GF(AT_NL "FAIL" AT_NL)) != 1) { sendAT(GF("+CWJAP_CUR=\""), ssid, GF("\",\""), pwd, GF("\"")); - if (waitResponse(30000L, GFP(GSM_OK), GF(GSM_NL "FAIL" GSM_NL)) != 1) { + if (waitResponse(30000L, GFP(AT_OK), GF(AT_NL "FAIL" AT_NL)) != 1) { return false; } } @@ -335,7 +335,7 @@ class TinyGsmESP8266 : public TinyGsmModem, GF("\",\""), host, GF("\","), port, GF(","), TINY_GSM_TCP_KEEP_ALIVE); // TODO(?): Check mux - int8_t rsp = waitResponse(timeout_ms, GFP(GSM_OK), GFP(GSM_ERROR), + int8_t rsp = waitResponse(timeout_ms, GFP(AT_OK), GFP(GSM_ERROR), GF("ALREADY CONNECT")); // if (rsp == 3) waitResponse(); // May return "ERROR" after the "ALREADY CONNECT" @@ -347,7 +347,7 @@ class TinyGsmESP8266 : public TinyGsmModem, if (waitResponse(GF(">")) != 1) { return 0; } stream.write(reinterpret_cast(buff), len); stream.flush(); - if (waitResponse(10000L, GF(GSM_NL "SEND OK" GSM_NL)) != 1) { return 0; } + if (waitResponse(10000L, GF(AT_NL "SEND OK" AT_NL)) != 1) { return 0; } return len; } @@ -357,7 +357,7 @@ class TinyGsmESP8266 : public TinyGsmModem, // after "STATUS:" it should return the status number (0,1,2,3,4,5), // followed by an OK // Hopefully we'll catch the "3" here, but fall back to the OK or Error - int8_t status = waitResponse(GF("3"), GFP(GSM_OK), GFP(GSM_ERROR)); + int8_t status = waitResponse(GF("3"), GFP(AT_OK), GFP(GSM_ERROR)); // if the status is anything but 3, there are no connections open if (status != 1) { for (int muxNo = 0; muxNo < TINY_GSM_MUX_COUNT; muxNo++) { @@ -367,7 +367,7 @@ class TinyGsmESP8266 : public TinyGsmModem, } bool verified_connections[TINY_GSM_MUX_COUNT] = {0, 0, 0, 0, 0}; for (int muxNo = 0; muxNo < TINY_GSM_MUX_COUNT; muxNo++) { - uint8_t has_status = waitResponse(GF("+CIPSTATUS:"), GFP(GSM_OK), + uint8_t has_status = waitResponse(GF("+CIPSTATUS:"), GFP(AT_OK), GFP(GSM_ERROR)); if (has_status == 1) { int8_t returned_mux = streamGetIntBefore(','); @@ -416,7 +416,7 @@ class TinyGsmESP8266 : public TinyGsmModem, return true; } else if (data.endsWith(GF("CLOSED"))) { int8_t muxStart = TinyGsmMax(0, - data.lastIndexOf(GSM_NL, data.length() - 8)); + data.lastIndexOf(AT_NL, data.length() - 8)); int8_t coma = data.indexOf(',', muxStart); int8_t mux = data.substring(muxStart, coma).toInt(); if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { diff --git a/src/TinyGsmClientM590.h b/src/TinyGsmClientM590.h index fab9debd..558f71b0 100644 --- a/src/TinyGsmClientM590.h +++ b/src/TinyGsmClientM590.h @@ -14,9 +14,9 @@ #define TINY_GSM_MUX_COUNT 2 #define TINY_GSM_NO_MODEM_BUFFER -#ifdef GSM_NL -#undef GSM_NL -#define GSM_NL "\r\n" // NOTE: define before including TinyGsmModem! +#ifdef AT_NL +#undef AT_NL +#define AT_NL "\r\n" // NOTE: define before including TinyGsmModem! #endif #include "TinyGsmGPRS.tpp" @@ -171,7 +171,7 @@ class TinyGsmM590 : public TinyGsmModem, if (!testAT()) { return false; } if (!setPhoneFunctionality(15)) { return false; } // MODEM:STARTUP - waitResponse(60000L, GF(GSM_NL "+PBREADY" GSM_NL)); + waitResponse(60000L, GF(AT_NL "+PBREADY" AT_NL)); return init(pin); } @@ -206,7 +206,7 @@ class TinyGsmM590 : public TinyGsmModem, String getLocalIPImpl() { sendAT(GF("+XIIC?")); - if (waitResponse(GF(GSM_NL "+XIIC:")) != 1) { return ""; } + if (waitResponse(GF(AT_NL "+XIIC:")) != 1) { return ""; } streamSkipUntil(','); String res = stream.readStringUntil('\n'); waitResponse(); @@ -264,7 +264,7 @@ class TinyGsmM590 : public TinyGsmModem, bool isGprsConnectedImpl() { sendAT(GF("+XIIC?")); - if (waitResponse(GF(GSM_NL "+XIIC:")) != 1) { return false; } + if (waitResponse(GF(AT_NL "+XIIC:")) != 1) { return false; } int8_t res = streamGetIntBefore(','); waitResponse(); return res == 1; @@ -300,9 +300,8 @@ class TinyGsmM590 : public TinyGsmModem, String ip = dnsIpQuery(host); sendAT(GF("+TCPSETUP="), mux, GF(","), ip, GF(","), port); - int8_t rsp = waitResponse(timeout_ms, GF(",OK" GSM_NL), - GF(",FAIL" GSM_NL), - GF("+TCPSETUP:Error" GSM_NL)); + int8_t rsp = waitResponse(timeout_ms, GF(",OK" AT_NL), GF(",FAIL" AT_NL), + GF("+TCPSETUP:Error" AT_NL)); if (1 == rsp) { return true; } else if (3 == rsp) { @@ -320,7 +319,7 @@ class TinyGsmM590 : public TinyGsmModem, stream.write(reinterpret_cast(buff), len); stream.write(static_cast(0x0D)); stream.flush(); - if (waitResponse(30000L, GF(GSM_NL "+TCPSEND:")) != 1) { return 0; } + if (waitResponse(30000L, GF(AT_NL "+TCPSEND:")) != 1) { return 0; } streamSkipUntil('\n'); return len; } @@ -335,9 +334,9 @@ class TinyGsmM590 : public TinyGsmModem, String dnsIpQuery(const char* host) { sendAT(GF("+DNS=\""), host, GF("\"")); - if (waitResponse(10000L, GF(GSM_NL "+DNS:")) != 1) { return ""; } + if (waitResponse(10000L, GF(AT_NL "+DNS:")) != 1) { return ""; } String res = stream.readStringUntil('\n'); - waitResponse(GF("+DNS:OK" GSM_NL)); + waitResponse(GF("+DNS:OK" AT_NL)); res.trim(); return res; } diff --git a/src/TinyGsmClientM95.h b/src/TinyGsmClientM95.h index 5ea9d552..fa3212f9 100644 --- a/src/TinyGsmClientM95.h +++ b/src/TinyGsmClientM95.h @@ -15,9 +15,9 @@ #define TINY_GSM_MUX_COUNT 6 #define TINY_GSM_BUFFER_READ_NO_CHECK -#ifdef GSM_NL -#undef GSM_NL -#define GSM_NL "\r\n" // NOTE: define before including TinyGsmModem! +#ifdef AT_NL +#undef AT_NL +#define AT_NL "\r\n" // NOTE: define before including TinyGsmModem! #endif #include "TinyGsmBattery.tpp" @@ -342,7 +342,7 @@ class TinyGsmM95 : public TinyGsmModem, protected: String getSimCCIDImpl() { sendAT(GF("+QCCID")); - if (waitResponse(GF(GSM_NL "+QCCID:")) != 1) { return ""; } + if (waitResponse(GF(AT_NL "+QCCID:")) != 1) { return ""; } String res = stream.readStringUntil('\n'); waitResponse(); res.trim(); @@ -388,7 +388,7 @@ class TinyGsmM95 : public TinyGsmModem, protected: float getTemperatureImpl() { sendAT(GF("+QTEMP?")); - if (waitResponse(GF(GSM_NL "+QTEMP:")) != 1) { + if (waitResponse(GF(AT_NL "+QTEMP:")) != 1) { return static_cast(-9999); } streamSkipUntil(','); // Skip mode @@ -411,9 +411,9 @@ class TinyGsmM95 : public TinyGsmModem, uint32_t timeout_ms = ((uint32_t)timeout_s) * 1000; sendAT(GF("+QIOPEN="), mux, GF(",\""), GF("TCP"), GF("\",\""), host, GF("\","), port); - int8_t rsp = waitResponse(timeout_ms, GF("CONNECT OK" GSM_NL), - GF("CONNECT FAIL" GSM_NL), - GF("ALREADY CONNECT" GSM_NL)); + int8_t rsp = waitResponse(timeout_ms, GF("CONNECT OK" AT_NL), + GF("CONNECT FAIL" AT_NL), + GF("ALREADY CONNECT" AT_NL)); return (1 == rsp); } @@ -422,13 +422,13 @@ class TinyGsmM95 : public TinyGsmModem, if (waitResponse(GF(">")) != 1) { return 0; } stream.write(reinterpret_cast(buff), len); stream.flush(); - if (waitResponse(GF(GSM_NL "SEND OK")) != 1) { return 0; } + if (waitResponse(GF(AT_NL "SEND OK")) != 1) { return 0; } // bool allAcknowledged = false; // // bool failed = false; // while ( !allAcknowledged ) { // sendAT( GF("+QISACK")); - // if (waitResponse(5000L, GF(GSM_NL "+QISACK:")) != 1) { + // if (waitResponse(5000L, GF(AT_NL "+QISACK:")) != 1) { // return -1; // } else { // streamSkipUntil(','); // Skip total length sent on connection @@ -455,7 +455,7 @@ class TinyGsmM95 : public TinyGsmModem, sendAT(GF("+QIRD=0,1,"), mux, ',', (uint16_t)size); // If it replies only OK for the write command, it means there is no // received data in the buffer of the connection. - int8_t res = waitResponse(GF("+QIRD:"), GFP(GSM_OK), GFP(GSM_ERROR)); + int8_t res = waitResponse(GF("+QIRD:"), GFP(AT_OK), GFP(GSM_ERROR)); if (res == 1) { streamSkipUntil(':'); // skip IP address streamSkipUntil(','); // skip port @@ -512,7 +512,7 @@ class TinyGsmM95 : public TinyGsmModem, */ public: bool handleURCs(String& data) { - if (data.endsWith(GF(GSM_NL "+QIRDI:"))) { + if (data.endsWith(GF(AT_NL "+QIRDI:"))) { streamSkipUntil(','); // Skip the context streamSkipUntil(','); // Skip the role int8_t mux = streamGetIntBefore('\n'); @@ -524,8 +524,8 @@ class TinyGsmM95 : public TinyGsmModem, } data = ""; return true; - } else if (data.endsWith(GF("CLOSED" GSM_NL))) { - int8_t nl = data.lastIndexOf(GSM_NL, data.length() - 8); + } else if (data.endsWith(GF("CLOSED" AT_NL))) { + int8_t nl = data.lastIndexOf(AT_NL, data.length() - 8); int8_t coma = data.indexOf(',', nl + 2); int8_t mux = data.substring(nl + 2, coma).toInt(); if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { diff --git a/src/TinyGsmClientMC60.h b/src/TinyGsmClientMC60.h index f6a02dfa..a5400f72 100644 --- a/src/TinyGsmClientMC60.h +++ b/src/TinyGsmClientMC60.h @@ -17,9 +17,9 @@ #define TINY_GSM_MUX_COUNT 6 #define TINY_GSM_BUFFER_READ_NO_CHECK -#ifdef GSM_NL -#undef GSM_NL -#define GSM_NL "\r\n" // NOTE: define before including TinyGsmModem! +#ifdef AT_NL +#undef AT_NL +#define AT_NL "\r\n" // NOTE: define before including TinyGsmModem! #endif #include "TinyGsmBattery.tpp" @@ -312,7 +312,7 @@ class TinyGsmMC60 : public TinyGsmModem, SimStatus getSimStatusImpl(uint32_t timeout_ms = 10000L) { for (uint32_t start = millis(); millis() - start < timeout_ms;) { sendAT(GF("+CPIN?")); - if (waitResponse(GF(GSM_NL "+CPIN:")) != 1) { + if (waitResponse(GF(AT_NL "+CPIN:")) != 1) { delay(1000); continue; } @@ -384,9 +384,9 @@ class TinyGsmMC60 : public TinyGsmModem, uint32_t timeout_ms = ((uint32_t)timeout_s) * 1000; sendAT(GF("+QIOPEN="), mux, GF(",\""), GF("TCP"), GF("\",\""), host, GF("\","), port); - int8_t rsp = waitResponse(timeout_ms, GF("CONNECT OK" GSM_NL), - GF("CONNECT FAIL" GSM_NL), - GF("ALREADY CONNECT" GSM_NL)); + int8_t rsp = waitResponse(timeout_ms, GF("CONNECT OK" AT_NL), + GF("CONNECT FAIL" AT_NL), + GF("ALREADY CONNECT" AT_NL)); return (1 == rsp); } @@ -395,14 +395,14 @@ class TinyGsmMC60 : public TinyGsmModem, if (waitResponse(GF(">")) != 1) { return 0; } stream.write(reinterpret_cast(buff), len); stream.flush(); - if (waitResponse(GF(GSM_NL "SEND OK")) != 1) { return 0; } + if (waitResponse(GF(AT_NL "SEND OK")) != 1) { return 0; } bool allAcknowledged = false; // bool failed = false; while (!allAcknowledged) { sendAT(GF("+QISACK="), mux); // If 'mux' is not specified, MC60 returns // 'ERRROR' (for QIMUX == 1) - if (waitResponse(5000L, GF(GSM_NL "+QISACK:")) != 1) { + if (waitResponse(5000L, GF(AT_NL "+QISACK:")) != 1) { return -1; } else { streamSkipUntil(','); /** Skip total */ @@ -429,7 +429,7 @@ class TinyGsmMC60 : public TinyGsmModem, sendAT(GF("+QIRD=0,1,"), mux, ',', (uint16_t)size); // If it replies only OK for the write command, it means there is no // received data in the buffer of the connection. - int8_t res = waitResponse(GF("+QIRD:"), GFP(GSM_OK), GFP(GSM_ERROR)); + int8_t res = waitResponse(GF("+QIRD:"), GFP(AT_OK), GFP(GSM_ERROR)); if (res == 1) { streamSkipUntil(':'); // skip IP address streamSkipUntil(','); // skip port @@ -485,7 +485,7 @@ class TinyGsmMC60 : public TinyGsmModem, */ public: bool handleURCs(String& data) { - if (data.endsWith(GF(GSM_NL "+QIRDI:"))) { // TODO(?): QIRD? or QIRDI? + if (data.endsWith(GF(AT_NL "+QIRDI:"))) { // TODO(?): QIRD? or QIRDI? // +QIRDI: ,,,,,< tlen> streamSkipUntil(','); // Skip the context streamSkipUntil(','); // Skip the role @@ -505,8 +505,8 @@ class TinyGsmMC60 : public TinyGsmModem, data = ""; // DBG("### Got Data:", len_total, "on", mux); return true; - } else if (data.endsWith(GF("CLOSED" GSM_NL))) { - int8_t nl = data.lastIndexOf(GSM_NL, data.length() - 8); + } else if (data.endsWith(GF("CLOSED" AT_NL))) { + int8_t nl = data.lastIndexOf(AT_NL, data.length() - 8); int8_t coma = data.indexOf(',', nl + 2); int8_t mux = data.substring(nl + 2, coma).toInt(); if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { diff --git a/src/TinyGsmClientSIM5360.h b/src/TinyGsmClientSIM5360.h index 212101e5..4a4b54e1 100644 --- a/src/TinyGsmClientSIM5360.h +++ b/src/TinyGsmClientSIM5360.h @@ -14,9 +14,9 @@ #define TINY_GSM_MUX_COUNT 10 #define TINY_GSM_BUFFER_READ_AND_CHECK_SIZE -#ifdef GSM_NL -#undef GSM_NL -#define GSM_NL "\r\n" // NOTE: define before including TinyGsmModem! +#ifdef AT_NL +#undef AT_NL +#define AT_NL "\r\n" // NOTE: define before including TinyGsmModem! #endif #include "TinyGsmBattery.tpp" @@ -197,7 +197,7 @@ class TinyGsmSim5360 : public TinyGsmModem, sendAT(GF("+CGMM")); String res2; if (waitResponse(1000L, res2) != 1) { return name; } - res2.replace(GSM_NL "OK" GSM_NL, ""); + res2.replace(AT_NL "OK" AT_NL, ""); res2.replace("_", " "); res2.trim(); @@ -221,7 +221,7 @@ class TinyGsmSim5360 : public TinyGsmModem, if (waitResponse(10000L) != 1) { return false; } // After booting, modem sends out messages as each of its // internal modules loads. The final message is "PB DONE". - if (waitResponse(40000L, GF(GSM_NL "PB DONE")) != 1) { return false; } + if (waitResponse(40000L, GF(AT_NL "PB DONE")) != 1) { return false; } return init(pin); } @@ -263,7 +263,7 @@ class TinyGsmSim5360 : public TinyGsmModem, public: String getNetworkModes() { sendAT(GF("+CNMP=?")); - if (waitResponse(GF(GSM_NL "+CNMP:")) != 1) { return ""; } + if (waitResponse(GF(AT_NL "+CNMP:")) != 1) { return ""; } String res = stream.readStringUntil('\n'); waitResponse(); return res; @@ -271,7 +271,7 @@ class TinyGsmSim5360 : public TinyGsmModem, int16_t getNetworkMode() { sendAT(GF("+CNMP?")); - if (waitResponse(GF(GSM_NL "+CNMP:")) != 1) { return false; } + if (waitResponse(GF(AT_NL "+CNMP:")) != 1) { return false; } int16_t mode = streamGetIntBefore('\n'); waitResponse(); return mode; @@ -287,8 +287,8 @@ class TinyGsmSim5360 : public TinyGsmModem, // sendAT(GF("+CGPADDR=1")); // Show PDP address String res; if (waitResponse(10000L, res) != 1) { return ""; } - res.replace(GSM_NL "OK" GSM_NL, ""); - res.replace(GSM_NL, ""); + res.replace(AT_NL "OK" AT_NL, ""); + res.replace(AT_NL, ""); res.trim(); return res; } @@ -372,7 +372,7 @@ class TinyGsmSim5360 : public TinyGsmModem, // We to ignore any immediate response and wait for the // URC to show it's really connected. sendAT(GF("+NETOPEN")); - if (waitResponse(75000L, GF(GSM_NL "+NETOPEN: 0")) != 1) { return false; } + if (waitResponse(75000L, GF(AT_NL "+NETOPEN: 0")) != 1) { return false; } return true; } @@ -388,7 +388,7 @@ class TinyGsmSim5360 : public TinyGsmModem, // Note: all sockets should be closed first - on 3G/4G models the sockets // must be closed manually sendAT(GF("+NETCLOSE")); - if (waitResponse(60000L, GF(GSM_NL "+NETCLOSE: 0")) != 1) { return false; } + if (waitResponse(60000L, GF(AT_NL "+NETCLOSE: 0")) != 1) { return false; } return true; } @@ -396,7 +396,7 @@ class TinyGsmSim5360 : public TinyGsmModem, bool isGprsConnectedImpl() { sendAT(GF("+NETOPEN?")); // May return +NETOPEN: 1, 0. We just confirm that the first number is 1 - if (waitResponse(GF(GSM_NL "+NETOPEN: 1")) != 1) { return false; } + if (waitResponse(GF(AT_NL "+NETOPEN: 1")) != 1) { return false; } waitResponse(); sendAT(GF("+IPADDR")); // Inquire Socket PDP address @@ -413,7 +413,7 @@ class TinyGsmSim5360 : public TinyGsmModem, // Gets the CCID of a sim card via AT+CCID String getSimCCIDImpl() { sendAT(GF("+CICCID")); - if (waitResponse(GF(GSM_NL "+ICCID:")) != 1) { return ""; } + if (waitResponse(GF(AT_NL "+ICCID:")) != 1) { return ""; } String res = stream.readStringUntil('\n'); waitResponse(); res.trim(); @@ -451,7 +451,7 @@ class TinyGsmSim5360 : public TinyGsmModem, // SRGD Note: Returns voltage in VOLTS instead of millivolts uint16_t getBattVoltageImpl() { sendAT(GF("+CBC")); - if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { return 0; } + if (waitResponse(GF(AT_NL "+CBC:")) != 1) { return 0; } streamSkipUntil(','); // Skip battery charge status streamSkipUntil(','); // Skip battery charge level // get voltage in VOLTS @@ -467,7 +467,7 @@ class TinyGsmSim5360 : public TinyGsmModem, bool getBattStatsImpl(uint8_t& chargeState, int8_t& percent, uint16_t& milliVolts) { sendAT(GF("+CBC")); - if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { return false; } + if (waitResponse(GF(AT_NL "+CBC:")) != 1) { return false; } chargeState = streamGetIntBefore(','); percent = streamGetIntBefore(','); // get voltage in VOLTS @@ -489,7 +489,7 @@ class TinyGsmSim5360 : public TinyGsmModem, if (waitResponse() != 1) { return 0; } // Get Temparature Value sendAT(GF("+CMTE?")); - if (waitResponse(GF(GSM_NL "+CMTE:")) != 1) { return false; } + if (waitResponse(GF(AT_NL "+CMTE:")) != 1) { return false; } float res = streamGetFloatBefore('\n'); // Wait for final OK waitResponse(); @@ -512,7 +512,7 @@ class TinyGsmSim5360 : public TinyGsmModem, sendAT(GF("+CIPOPEN="), mux, ',', GF("\"TCP"), GF("\",\""), host, GF("\","), port); // The reply is +CIPOPEN: ## of socket created - if (waitResponse(timeout_ms, GF(GSM_NL "+CIPOPEN:")) != 1) { return false; } + if (waitResponse(timeout_ms, GF(AT_NL "+CIPOPEN:")) != 1) { return false; } return true; } @@ -521,7 +521,7 @@ class TinyGsmSim5360 : public TinyGsmModem, if (waitResponse(GF(">")) != 1) { return 0; } stream.write(reinterpret_cast(buff), len); stream.flush(); - if (waitResponse(GF(GSM_NL "+CIPSEND:")) != 1) { return 0; } + if (waitResponse(GF(AT_NL "+CIPSEND:")) != 1) { return 0; } streamSkipUntil(','); // Skip mux streamSkipUntil(','); // Skip requested bytes to send // TODO(?): make sure requested and confirmed bytes match @@ -606,7 +606,7 @@ class TinyGsmSim5360 : public TinyGsmModem, */ public: bool handleURCs(String& data) { - if (data.endsWith(GF(GSM_NL "+CIPRXGET:"))) { + if (data.endsWith(GF(AT_NL "+CIPRXGET:"))) { int8_t mode = streamGetIntBefore(','); if (mode == 1) { int8_t mux = streamGetIntBefore('\n'); @@ -620,7 +620,7 @@ class TinyGsmSim5360 : public TinyGsmModem, data += mode; return false; } - } else if (data.endsWith(GF(GSM_NL "+RECEIVE:"))) { + } else if (data.endsWith(GF(AT_NL "+RECEIVE:"))) { int8_t mux = streamGetIntBefore(','); int16_t len = streamGetIntBefore('\n'); if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { diff --git a/src/TinyGsmClientSIM7000.h b/src/TinyGsmClientSIM7000.h index a723a1c1..721a3669 100644 --- a/src/TinyGsmClientSIM7000.h +++ b/src/TinyGsmClientSIM7000.h @@ -152,8 +152,8 @@ class TinyGsmSim7000 : public TinyGsmSim70xx, sendAT(GF("+CIFSR;E0")); String res; if (waitResponse(10000L, res) != 1) { return ""; } - res.replace(GSM_NL "OK" GSM_NL, ""); - res.replace(GSM_NL, ""); + res.replace(AT_NL "OK" AT_NL, ""); + res.replace(AT_NL, ""); res.trim(); return res; } @@ -293,10 +293,9 @@ class TinyGsmSim7000 : public TinyGsmSim70xx, sendAT(GF("+CIPSTART="), mux, ',', GF("\"TCP"), GF("\",\""), host, GF("\","), port); return (1 == - waitResponse(timeout_ms, GF("CONNECT OK" GSM_NL), - GF("CONNECT FAIL" GSM_NL), - GF("ALREADY CONNECT" GSM_NL), GF("ERROR" GSM_NL), - GF("CLOSE OK" GSM_NL))); + waitResponse(timeout_ms, GF("CONNECT OK" AT_NL), + GF("CONNECT FAIL" AT_NL), GF("ALREADY CONNECT" AT_NL), + GF("ERROR" AT_NL), GF("CLOSE OK" AT_NL))); } int16_t modemSend(const void* buff, size_t len, uint8_t mux) { @@ -306,7 +305,7 @@ class TinyGsmSim7000 : public TinyGsmSim70xx, stream.write(reinterpret_cast(buff), len); stream.flush(); - if (waitResponse(GF(GSM_NL "DATA ACCEPT:")) != 1) { return 0; } + if (waitResponse(GF(AT_NL "DATA ACCEPT:")) != 1) { return 0; } streamSkipUntil(','); // Skip mux return streamGetIntBefore('\n'); } @@ -391,7 +390,7 @@ class TinyGsmSim7000 : public TinyGsmSim70xx, */ public: bool handleURCs(String& data) { - if (data.endsWith(GF(GSM_NL "+CIPRXGET:"))) { + if (data.endsWith(GF(AT_NL "+CIPRXGET:"))) { int8_t mode = streamGetIntBefore(','); if (mode == 1) { int8_t mux = streamGetIntBefore('\n'); @@ -405,7 +404,7 @@ class TinyGsmSim7000 : public TinyGsmSim70xx, data += mode; return false; } - } else if (data.endsWith(GF(GSM_NL "+RECEIVE:"))) { + } else if (data.endsWith(GF(AT_NL "+RECEIVE:"))) { int8_t mux = streamGetIntBefore(','); int16_t len = streamGetIntBefore('\n'); if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { @@ -415,8 +414,8 @@ class TinyGsmSim7000 : public TinyGsmSim70xx, data = ""; // DBG("### Got Data:", len, "on", mux); return true; - } else if (data.endsWith(GF("CLOSED" GSM_NL))) { - int8_t nl = data.lastIndexOf(GSM_NL, data.length() - 8); + } else if (data.endsWith(GF("CLOSED" AT_NL))) { + int8_t nl = data.lastIndexOf(AT_NL, data.length() - 8); int8_t coma = data.indexOf(',', nl + 2); int8_t mux = data.substring(nl + 2, coma).toInt(); if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { @@ -445,7 +444,7 @@ class TinyGsmSim7000 : public TinyGsmSim70xx, data = ""; DBG("### Daylight savings time state updated."); return true; - } else if (data.endsWith(GF(GSM_NL "SMS Ready" GSM_NL))) { + } else if (data.endsWith(GF(AT_NL "SMS Ready" AT_NL))) { data = ""; DBG("### Unexpected module reset!"); init(); diff --git a/src/TinyGsmClientSIM7000SSL.h b/src/TinyGsmClientSIM7000SSL.h index f9499a37..e6c8c92e 100644 --- a/src/TinyGsmClientSIM7000SSL.h +++ b/src/TinyGsmClientSIM7000SSL.h @@ -194,7 +194,7 @@ class TinyGsmSim7000SSL protected: String getLocalIPImpl() { sendAT(GF("+CNACT?")); - if (waitResponse(GF(GSM_NL "+CNACT:")) != 1) { return ""; } + if (waitResponse(GF(AT_NL "+CNACT:")) != 1) { return ""; } streamSkipUntil('\"'); String res = stream.readStringUntil('\"'); waitResponse(); @@ -265,8 +265,8 @@ class TinyGsmSim7000SSL int ntries = 0; while (!res && ntries < 5) { sendAT(GF("+CNACT=1,\""), apn, GF("\"")); - res = waitResponse(60000L, GF(GSM_NL "+APP PDP: ACTIVE"), - GF(GSM_NL "+APP PDP: DEACTIVE")) == 1; + res = waitResponse(60000L, GF(AT_NL "+APP PDP: ACTIVE"), + GF(AT_NL "+APP PDP: DEACTIVE")) == 1; waitResponse(); ntries++; } @@ -393,7 +393,7 @@ class TinyGsmSim7000SSL // "TCP" or "UDP" // NOTE: the "TCP" can't be included sendAT(GF("+CAOPEN="), mux, GF(",\""), host, GF("\","), port); - if (waitResponse(timeout_ms, GF(GSM_NL "+CAOPEN:")) != 1) { return 0; } + if (waitResponse(timeout_ms, GF(AT_NL "+CAOPEN:")) != 1) { return 0; } // returns OK/r/n/r/n+CAOPEN: , // 0: Success // 1: Socket error @@ -430,7 +430,7 @@ class TinyGsmSim7000SSL // after posting data, module responds with: //+CASEND: ,, - if (waitResponse(GF(GSM_NL "+CASEND:")) != 1) { return 0; } + if (waitResponse(GF(AT_NL "+CASEND:")) != 1) { return 0; } streamSkipUntil(','); // Skip mux if (streamGetIntBefore(',') != 0) { return 0; } // If result != success return streamGetIntBefore('\n'); @@ -496,7 +496,7 @@ class TinyGsmSim7000SSL sendAT(GF("+CARECV?")); for (int muxNo = 0; muxNo < TINY_GSM_MUX_COUNT; muxNo++) { // after the last connection, there's an ok, so we catch it right away - int res = waitResponse(3000, GF("+CARECV:"), GFP(GSM_OK), GFP(GSM_ERROR)); + int res = waitResponse(3000, GF("+CARECV:"), GFP(AT_OK), GFP(GSM_ERROR)); // if we get the +CARECV: response, read the mux number and the number of // characters available if (res == 1) { @@ -543,8 +543,7 @@ class TinyGsmSim7000SSL for (int muxNo = 0; muxNo < TINY_GSM_MUX_COUNT; muxNo++) { // after the last connection, there's an ok, so we catch it right away - int res = waitResponse(3000, GF("+CASTATE:"), GFP(GSM_OK), - GFP(GSM_ERROR)); + int res = waitResponse(3000, GF("+CASTATE:"), GFP(AT_OK), GFP(GSM_ERROR)); // if we get the +CASTATE: response, read the mux number and the status if (res == 1) { int ret_mux = streamGetIntBefore(','); @@ -638,7 +637,7 @@ class TinyGsmSim7000SSL data = ""; DBG("### Daylight savings time state updated."); return true; - } else if (data.endsWith(GF(GSM_NL "SMS Ready" GSM_NL))) { + } else if (data.endsWith(GF(AT_NL "SMS Ready" AT_NL))) { data = ""; DBG("### Unexpected module reset!"); init(); diff --git a/src/TinyGsmClientSIM7080.h b/src/TinyGsmClientSIM7080.h index a0638ada..128d70b0 100644 --- a/src/TinyGsmClientSIM7080.h +++ b/src/TinyGsmClientSIM7080.h @@ -192,7 +192,7 @@ class TinyGsmSim7080 : public TinyGsmSim70xx, protected: String getLocalIPImpl() { sendAT(GF("+CNACT?")); - if (waitResponse(GF(GSM_NL "+CNACT:")) != 1) { return ""; } + if (waitResponse(GF(AT_NL "+CNACT:")) != 1) { return ""; } streamSkipUntil('\"'); String res = stream.readStringUntil('\"'); waitResponse(); @@ -270,8 +270,8 @@ class TinyGsmSim7080 : public TinyGsmSim70xx, int ntries = 0; while (!res && ntries < 5) { sendAT(GF("+CNACT=0,1")); - res = waitResponse(60000L, GF(GSM_NL "+APP PDP: 0,ACTIVE"), - GF(GSM_NL "+APP PDP: 0,DEACTIVE")); + res = waitResponse(60000L, GF(AT_NL "+APP PDP: 0,ACTIVE"), + GF(AT_NL "+APP PDP: 0,DEACTIVE")); waitResponse(); ntries++; } @@ -401,7 +401,7 @@ class TinyGsmSim7080 : public TinyGsmSim70xx, // "recv",,,, // NOTE: including the fails sendAT(GF("+CAOPEN="), mux, GF(",0,\"TCP\",\""), host, GF("\","), port); - if (waitResponse(timeout_ms, GF(GSM_NL "+CAOPEN:")) != 1) { return 0; } + if (waitResponse(timeout_ms, GF(AT_NL "+CAOPEN:")) != 1) { return 0; } // returns OK/r/n/r/n+CAOPEN: , // 0: Success // 1: Socket error @@ -495,7 +495,7 @@ class TinyGsmSim7080 : public TinyGsmSim70xx, sendAT(GF("+CARECV?")); for (int muxNo = 0; muxNo < TINY_GSM_MUX_COUNT; muxNo++) { // after the last connection, there's an ok, so we catch it right away - int res = waitResponse(3000, GF("+CARECV:"), GFP(GSM_OK), GFP(GSM_ERROR)); + int res = waitResponse(3000, GF("+CARECV:"), GFP(AT_OK), GFP(GSM_ERROR)); // if we get the +CARECV: response, read the mux number and the number of // characters available if (res == 1) { @@ -542,8 +542,7 @@ class TinyGsmSim7080 : public TinyGsmSim70xx, for (int muxNo = 0; muxNo < TINY_GSM_MUX_COUNT; muxNo++) { // after the last connection, there's an ok, so we catch it right away - int res = waitResponse(3000, GF("+CASTATE:"), GFP(GSM_OK), - GFP(GSM_ERROR)); + int res = waitResponse(3000, GF("+CASTATE:"), GFP(AT_OK), GFP(GSM_ERROR)); // if we get the +CASTATE: response, read the mux number and the status if (res == 1) { int ret_mux = streamGetIntBefore(','); @@ -637,7 +636,7 @@ class TinyGsmSim7080 : public TinyGsmSim70xx, data = ""; DBG("### Daylight savings time state updated."); return true; - } else if (data.endsWith(GF(GSM_NL "SMS Ready" GSM_NL))) { + } else if (data.endsWith(GF(AT_NL "SMS Ready" AT_NL))) { data = ""; DBG("### Unexpected module reset!"); init(); diff --git a/src/TinyGsmClientSIM70xx.h b/src/TinyGsmClientSIM70xx.h index 7d69df92..3852467a 100644 --- a/src/TinyGsmClientSIM70xx.h +++ b/src/TinyGsmClientSIM70xx.h @@ -11,9 +11,9 @@ // #define TINY_GSM_DEBUG Serial // #define TINY_GSM_USE_HEX -#ifdef GSM_NL -#undef GSM_NL -#define GSM_NL "\r\n" // NOTE: define before including TinyGsmModem! +#ifdef AT_NL +#undef AT_NL +#define AT_NL "\r\n" // NOTE: define before including TinyGsmModem! #endif #include "TinyGsmBattery.tpp" @@ -84,7 +84,7 @@ class TinyGsmSim70xx : public TinyGsmModem>, thisModem().sendAT(GF("+GMM")); String res2; if (thisModem().waitResponse(5000L, res2) != 1) { return name; } - res2.replace(GSM_NL "OK" GSM_NL, ""); + res2.replace(AT_NL "OK" AT_NL, ""); res2.replace("_", " "); res2.trim(); @@ -166,7 +166,7 @@ class TinyGsmSim70xx : public TinyGsmModem>, String getNetworkModes() { // Get the help string, not the setting value thisModem().sendAT(GF("+CNMP=?")); - if (thisModem().waitResponse(GF(GSM_NL "+CNMP:")) != 1) { return ""; } + if (thisModem().waitResponse(GF(AT_NL "+CNMP:")) != 1) { return ""; } String res = stream.readStringUntil('\n'); thisModem().waitResponse(); return res; @@ -174,7 +174,7 @@ class TinyGsmSim70xx : public TinyGsmModem>, int16_t getNetworkMode() { thisModem().sendAT(GF("+CNMP?")); - if (thisModem().waitResponse(GF(GSM_NL "+CNMP:")) != 1) { return false; } + if (thisModem().waitResponse(GF(AT_NL "+CNMP:")) != 1) { return false; } int16_t mode = thisModem().streamGetIntBefore('\n'); thisModem().waitResponse(); return mode; @@ -192,7 +192,7 @@ class TinyGsmSim70xx : public TinyGsmModem>, String getPreferredModes() { // Get the help string, not the setting value thisModem().sendAT(GF("+CMNB=?")); - if (thisModem().waitResponse(GF(GSM_NL "+CMNB:")) != 1) { return ""; } + if (thisModem().waitResponse(GF(AT_NL "+CMNB:")) != 1) { return ""; } String res = stream.readStringUntil('\n'); thisModem().waitResponse(); return res; @@ -200,7 +200,7 @@ class TinyGsmSim70xx : public TinyGsmModem>, int16_t getPreferredMode() { thisModem().sendAT(GF("+CMNB?")); - if (thisModem().waitResponse(GF(GSM_NL "+CMNB:")) != 1) { return false; } + if (thisModem().waitResponse(GF(AT_NL "+CMNB:")) != 1) { return false; } int16_t mode = thisModem().streamGetIntBefore('\n'); thisModem().waitResponse(); return mode; @@ -218,7 +218,7 @@ class TinyGsmSim70xx : public TinyGsmModem>, // n: whether to automatically report the system mode info // stat: the current service. 0 if it not connected thisModem().sendAT(GF("+CNSMOD?")); - if (thisModem().waitResponse(GF(GSM_NL "+CNSMOD:")) != 1) { return false; } + if (thisModem().waitResponse(GF(AT_NL "+CNSMOD:")) != 1) { return false; } n = thisModem().streamGetIntBefore(',') != 0; stat = thisModem().streamGetIntBefore('\n'); thisModem().waitResponse(); @@ -256,7 +256,7 @@ class TinyGsmSim70xx : public TinyGsmModem>, // Doesn't return the "+CCID" before the number String getSimCCIDImpl() { thisModem().sendAT(GF("+CCID")); - if (thisModem().waitResponse(GF(GSM_NL)) != 1) { return ""; } + if (thisModem().waitResponse(GF(AT_NL)) != 1) { return ""; } String res = stream.readStringUntil('\n'); thisModem().waitResponse(); res.trim(); @@ -289,7 +289,7 @@ class TinyGsmSim70xx : public TinyGsmModem>, // get the RAW GPS output String getGPSrawImpl() { thisModem().sendAT(GF("+CGNSINF")); - if (thisModem().waitResponse(10000L, GF(GSM_NL "+CGNSINF:")) != 1) { + if (thisModem().waitResponse(10000L, GF(AT_NL "+CGNSINF:")) != 1) { return ""; } String res = stream.readStringUntil('\n'); @@ -304,7 +304,7 @@ class TinyGsmSim70xx : public TinyGsmModem>, int* year = 0, int* month = 0, int* day = 0, int* hour = 0, int* minute = 0, int* second = 0) { thisModem().sendAT(GF("+CGNSINF")); - if (thisModem().waitResponse(10000L, GF(GSM_NL "+CGNSINF:")) != 1) { + if (thisModem().waitResponse(10000L, GF(AT_NL "+CGNSINF:")) != 1) { return false; } diff --git a/src/TinyGsmClientSIM7600.h b/src/TinyGsmClientSIM7600.h index 558e8ce1..5ead4ed2 100644 --- a/src/TinyGsmClientSIM7600.h +++ b/src/TinyGsmClientSIM7600.h @@ -14,9 +14,9 @@ #define TINY_GSM_MUX_COUNT 10 #define TINY_GSM_BUFFER_READ_AND_CHECK_SIZE -#ifdef GSM_NL -#undef GSM_NL -#define GSM_NL "\r\n" // NOTE: define before including TinyGsmModem! +#ifdef AT_NL +#undef AT_NL +#define AT_NL "\r\n" // NOTE: define before including TinyGsmModem! #endif #include "TinyGsmBattery.tpp" @@ -205,7 +205,7 @@ class TinyGsmSim7600 : public TinyGsmModem, sendAT(GF("+CGMM")); String res2; if (waitResponse(1000L, res2) != 1) { return name; } - res2.replace(GSM_NL "OK" GSM_NL, ""); + res2.replace(AT_NL "OK" AT_NL, ""); res2.replace("_", " "); res2.trim(); @@ -268,7 +268,7 @@ class TinyGsmSim7600 : public TinyGsmModem, public: String getNetworkModes() { sendAT(GF("+CNMP=?")); - if (waitResponse(GF(GSM_NL "+CNMP:")) != 1) { return ""; } + if (waitResponse(GF(AT_NL "+CNMP:")) != 1) { return ""; } String res = stream.readStringUntil('\n'); waitResponse(); return res; @@ -276,7 +276,7 @@ class TinyGsmSim7600 : public TinyGsmModem, int16_t getNetworkMode() { sendAT(GF("+CNMP?")); - if (waitResponse(GF(GSM_NL "+CNMP:")) != 1) { return false; } + if (waitResponse(GF(AT_NL "+CNMP:")) != 1) { return false; } int16_t mode = streamGetIntBefore('\n'); waitResponse(); return mode; @@ -292,8 +292,8 @@ class TinyGsmSim7600 : public TinyGsmModem, // sendAT(GF("+CGPADDR=1")); // Show PDP address String res; if (waitResponse(10000L, res) != 1) { return ""; } - res.replace(GSM_NL "OK" GSM_NL, ""); - res.replace(GSM_NL, ""); + res.replace(AT_NL "OK" AT_NL, ""); + res.replace(AT_NL, ""); res.trim(); return res; } @@ -360,7 +360,7 @@ class TinyGsmSim7600 : public TinyGsmModem, // We to ignore any immediate response and wait for the // URC to show it's really connected. sendAT(GF("+NETOPEN")); - if (waitResponse(75000L, GF(GSM_NL "+NETOPEN: 0")) != 1) { return false; } + if (waitResponse(75000L, GF(AT_NL "+NETOPEN: 0")) != 1) { return false; } return true; } @@ -370,7 +370,7 @@ class TinyGsmSim7600 : public TinyGsmModem, // Note: On the LTE models, this single command closes all sockets and the // service sendAT(GF("+NETCLOSE")); - if (waitResponse(60000L, GF(GSM_NL "+NETCLOSE: 0")) != 1) { return false; } + if (waitResponse(60000L, GF(AT_NL "+NETCLOSE: 0")) != 1) { return false; } return true; } @@ -378,7 +378,7 @@ class TinyGsmSim7600 : public TinyGsmModem, bool isGprsConnectedImpl() { sendAT(GF("+NETOPEN?")); // May return +NETOPEN: 1, 0. We just confirm that the first number is 1 - if (waitResponse(GF(GSM_NL "+NETOPEN: 1")) != 1) { return false; } + if (waitResponse(GF(AT_NL "+NETOPEN: 1")) != 1) { return false; } waitResponse(); sendAT(GF("+IPADDR")); // Inquire Socket PDP address @@ -395,7 +395,7 @@ class TinyGsmSim7600 : public TinyGsmModem, // Gets the CCID of a sim card via AT+CCID String getSimCCIDImpl() { sendAT(GF("+CICCID")); - if (waitResponse(GF(GSM_NL "+ICCID:")) != 1) { return ""; } + if (waitResponse(GF(AT_NL "+ICCID:")) != 1) { return ""; } String res = stream.readStringUntil('\n'); waitResponse(); res.trim(); @@ -443,7 +443,7 @@ class TinyGsmSim7600 : public TinyGsmModem, // get the RAW GPS output String getGPSrawImpl() { sendAT(GF("+CGNSSINFO")); - if (waitResponse(GF(GSM_NL "+CGNSSINFO:")) != 1) { return ""; } + if (waitResponse(GF(AT_NL "+CGNSSINFO:")) != 1) { return ""; } String res = stream.readStringUntil('\n'); waitResponse(); res.trim(); @@ -456,7 +456,7 @@ class TinyGsmSim7600 : public TinyGsmModem, int* year = 0, int* month = 0, int* day = 0, int* hour = 0, int* minute = 0, int* second = 0) { sendAT(GF("+CGNSSINFO")); - if (waitResponse(GF(GSM_NL "+CGNSSINFO:")) != 1) { return false; } + if (waitResponse(GF(AT_NL "+CGNSSINFO:")) != 1) { return false; } uint8_t fixMode = streamGetIntBefore(','); // mode 2=2D Fix or 3=3DFix // TODO(?) Can 1 be returned @@ -547,14 +547,14 @@ class TinyGsmSim7600 : public TinyGsmModem, String res; sendAT(GF("+CGNSSMODE="), mode, ",", dpo); if (waitResponse(10000L, res) != 1) { return ""; } - res.replace(GSM_NL, ""); + res.replace(AT_NL, ""); res.trim(); return res; } uint8_t getGNSSModeImpl() { sendAT(GF("+CGNSSMODE?")); - if (waitResponse(GF(GSM_NL "+CGNSSMODE:")) != 1) { return 0; } + if (waitResponse(GF(AT_NL "+CGNSSMODE:")) != 1) { return 0; } return stream.readStringUntil(',').toInt(); } @@ -577,7 +577,7 @@ class TinyGsmSim7600 : public TinyGsmModem, // returns volts, multiply by 1000 to get mV uint16_t getBattVoltageImpl() { sendAT(GF("+CBC")); - if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { return 0; } + if (waitResponse(GF(AT_NL "+CBC:")) != 1) { return 0; } // get voltage in VOLTS float voltage = streamGetFloatBefore('\n'); @@ -607,7 +607,7 @@ class TinyGsmSim7600 : public TinyGsmModem, // get temperature in degree celsius uint16_t getTemperatureImpl() { sendAT(GF("+CPMUTEMP")); - if (waitResponse(GF(GSM_NL "+CPMUTEMP:")) != 1) { return 0; } + if (waitResponse(GF(AT_NL "+CPMUTEMP:")) != 1) { return 0; } // return temperature in C uint16_t res = streamGetIntBefore('\n'); // Wait for final OK @@ -632,7 +632,7 @@ class TinyGsmSim7600 : public TinyGsmModem, port); // The reply is OK followed by +CIPOPEN: , where // is the mux number and should be 0 if there's no error - if (waitResponse(timeout_ms, GF(GSM_NL "+CIPOPEN:")) != 1) { return false; } + if (waitResponse(timeout_ms, GF(AT_NL "+CIPOPEN:")) != 1) { return false; } uint8_t opened_mux = streamGetIntBefore(','); uint8_t opened_result = streamGetIntBefore('\n'); if (opened_mux != mux || opened_result != 0) return false; @@ -644,7 +644,7 @@ class TinyGsmSim7600 : public TinyGsmModem, if (waitResponse(GF(">")) != 1) { return 0; } stream.write(reinterpret_cast(buff), len); stream.flush(); - if (waitResponse(GF(GSM_NL "+CIPSEND:")) != 1) { return 0; } + if (waitResponse(GF(AT_NL "+CIPSEND:")) != 1) { return 0; } streamSkipUntil(','); // Skip mux streamSkipUntil(','); // Skip requested bytes to send // TODO(?): make sure requested and confirmed bytes match @@ -731,7 +731,7 @@ class TinyGsmSim7600 : public TinyGsmModem, */ public: bool handleURCs(String& data) { - if (data.endsWith(GF(GSM_NL "+CIPRXGET:"))) { + if (data.endsWith(GF(AT_NL "+CIPRXGET:"))) { int8_t mode = streamGetIntBefore(','); if (mode == 1) { int8_t mux = streamGetIntBefore('\n'); @@ -745,7 +745,7 @@ class TinyGsmSim7600 : public TinyGsmModem, data += mode; return false; } - } else if (data.endsWith(GF(GSM_NL "+RECEIVE:"))) { + } else if (data.endsWith(GF(AT_NL "+RECEIVE:"))) { int8_t mux = streamGetIntBefore(','); int16_t len = streamGetIntBefore('\n'); if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { diff --git a/src/TinyGsmClientSIM800.h b/src/TinyGsmClientSIM800.h index 67272099..6ff76a79 100644 --- a/src/TinyGsmClientSIM800.h +++ b/src/TinyGsmClientSIM800.h @@ -15,9 +15,9 @@ #define TINY_GSM_MUX_COUNT 5 #define TINY_GSM_BUFFER_READ_AND_CHECK_SIZE -#ifdef GSM_NL -#undef GSM_NL -#define GSM_NL "\r\n" // NOTE: define before including TinyGsmModem! +#ifdef AT_NL +#undef AT_NL +#define AT_NL "\r\n" // NOTE: define before including TinyGsmModem! #endif #include "TinyGsmBattery.tpp" @@ -209,7 +209,7 @@ class TinyGsmSim800 : public TinyGsmModem, sendAT(GF("+GMM")); String res2; if (waitResponse(1000L, res2) != 1) { return name; } - res2.replace(GSM_NL "OK" GSM_NL, ""); + res2.replace(AT_NL "OK" AT_NL, ""); res2.replace("_", " "); res2.trim(); @@ -239,7 +239,7 @@ class TinyGsmSim800 : public TinyGsmModem, return false; #else sendAT(GF("+CIPSSL=?")); - if (waitResponse(GF(GSM_NL "+CIPSSL:")) != 1) { return false; } + if (waitResponse(GF(AT_NL "+CIPSSL:")) != 1) { return false; } return waitResponse() == 1; #endif } @@ -300,8 +300,8 @@ class TinyGsmSim800 : public TinyGsmModem, sendAT(GF("+CIFSR;E0")); String res; if (waitResponse(10000L, res) != 1) { return ""; } - res.replace(GSM_NL "OK" GSM_NL, ""); - res.replace(GSM_NL, ""); + res.replace(AT_NL "OK" AT_NL, ""); + res.replace(AT_NL, ""); res.trim(); return res; } @@ -403,7 +403,7 @@ class TinyGsmSim800 : public TinyGsmModem, // May not return the "+CCID" before the number String getSimCCIDImpl() { sendAT(GF("+CCID")); - if (waitResponse(GF(GSM_NL)) != 1) { return ""; } + if (waitResponse(GF(AT_NL)) != 1) { return ""; } String res = stream.readStringUntil('\n'); waitResponse(); // Trim out the CCID header in case it is there @@ -454,7 +454,7 @@ class TinyGsmSim800 : public TinyGsmModem, uint8_t getVolume() { // Get speaker volume sendAT(GF("+CLVL?")); - if (waitResponse(GF(GSM_NL)) != 1) { return 0; } + if (waitResponse(GF(AT_NL)) != 1) { return 0; } String res = stream.readStringUntil('\n'); waitResponse(); res.replace("+CLVL:", ""); @@ -530,9 +530,9 @@ class TinyGsmSim800 : public TinyGsmModem, sendAT(GF("+CIPSTART="), mux, ',', GF("\"TCP"), GF("\",\""), host, GF("\","), port); rsp = waitResponse( - timeout_ms, GF("CONNECT OK" GSM_NL), GF("CONNECT FAIL" GSM_NL), - GF("ALREADY CONNECT" GSM_NL), GF("ERROR" GSM_NL), - GF("CLOSE OK" GSM_NL)); // Happens when HTTPS handshake fails + timeout_ms, GF("CONNECT OK" AT_NL), GF("CONNECT FAIL" AT_NL), + GF("ALREADY CONNECT" AT_NL), GF("ERROR" AT_NL), + GF("CLOSE OK" AT_NL)); // Happens when HTTPS handshake fails return (1 == rsp); } @@ -541,7 +541,7 @@ class TinyGsmSim800 : public TinyGsmModem, if (waitResponse(GF(">")) != 1) { return 0; } stream.write(reinterpret_cast(buff), len); stream.flush(); - if (waitResponse(GF(GSM_NL "DATA ACCEPT:")) != 1) { return 0; } + if (waitResponse(GF(AT_NL "DATA ACCEPT:")) != 1) { return 0; } streamSkipUntil(','); // Skip mux return streamGetIntBefore('\n'); } @@ -624,7 +624,7 @@ class TinyGsmSim800 : public TinyGsmModem, */ public: bool handleURCs(String& data) { - if (data.endsWith(GF(GSM_NL "+CIPRXGET:"))) { + if (data.endsWith(GF(AT_NL "+CIPRXGET:"))) { int8_t mode = streamGetIntBefore(','); if (mode == 1) { int8_t mux = streamGetIntBefore('\n'); @@ -638,7 +638,7 @@ class TinyGsmSim800 : public TinyGsmModem, data += mode; return false; } - } else if (data.endsWith(GF(GSM_NL "+RECEIVE:"))) { + } else if (data.endsWith(GF(AT_NL "+RECEIVE:"))) { int8_t mux = streamGetIntBefore(','); int16_t len = streamGetIntBefore('\n'); if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { @@ -648,8 +648,8 @@ class TinyGsmSim800 : public TinyGsmModem, data = ""; // DBG("### Got Data:", len, "on", mux); return true; - } else if (data.endsWith(GF("CLOSED" GSM_NL))) { - int8_t nl = data.lastIndexOf(GSM_NL, data.length() - 8); + } else if (data.endsWith(GF("CLOSED" AT_NL))) { + int8_t nl = data.lastIndexOf(AT_NL, data.length() - 8); int8_t coma = data.indexOf(',', nl + 2); int8_t mux = data.substring(nl + 2, coma).toInt(); if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { diff --git a/src/TinyGsmClientSIM808.h b/src/TinyGsmClientSIM808.h index 7398bfaa..67de0b66 100644 --- a/src/TinyGsmClientSIM808.h +++ b/src/TinyGsmClientSIM808.h @@ -14,7 +14,9 @@ #include "TinyGsmGPS.tpp" #include "TinyGsmBluetooth.tpp" -class TinyGsmSim808 : public TinyGsmSim800, public TinyGsmGPS, public TinyGsmBluetooth { +class TinyGsmSim808 : public TinyGsmSim800, + public TinyGsmGPS, + public TinyGsmBluetooth { friend class TinyGsmGPS; friend class TinyGsmBluetooth; @@ -43,7 +45,7 @@ class TinyGsmSim808 : public TinyGsmSim800, public TinyGsmGPS, pu // works only with ans SIM808 V2 String getGPSrawImpl() { sendAT(GF("+CGNSINF")); - if (waitResponse(10000L, GF(GSM_NL "+CGNSINF:")) != 1) { return ""; } + if (waitResponse(10000L, GF(AT_NL "+CGNSINF:")) != 1) { return ""; } String res = stream.readStringUntil('\n'); waitResponse(); res.trim(); @@ -57,7 +59,7 @@ class TinyGsmSim808 : public TinyGsmSim800, public TinyGsmGPS, pu int* year = 0, int* month = 0, int* day = 0, int* hour = 0, int* minute = 0, int* second = 0) { sendAT(GF("+CGNSINF")); - if (waitResponse(10000L, GF(GSM_NL "+CGNSINF:")) != 1) { return false; } + if (waitResponse(10000L, GF(AT_NL "+CGNSINF:")) != 1) { return false; } streamSkipUntil(','); // GNSS run status if (streamGetIntBefore(',') == 1) { // fix status @@ -129,11 +131,11 @@ class TinyGsmSim808 : public TinyGsmSim800, public TinyGsmGPS, pu waitResponse(); return false; } - - /* + + /* * Bluetooth functions */ - + bool enableBluetoothImpl() { sendAT(GF("+BTPOWER=1")); if (waitResponse() != 1) { return false; } @@ -145,22 +147,18 @@ class TinyGsmSim808 : public TinyGsmSim800, public TinyGsmGPS, pu if (waitResponse() != 1) { return false; } return true; } - + bool setBluetoothVisibilityImpl(bool visible) { sendAT(GF("+BTVIS="), visible); - if (waitResponse() != 1) { - return false; - } - + if (waitResponse() != 1) { return false; } + return true; } bool setBluetoothHostNameImpl(const char* name) { sendAT(GF("+BTHOST="), name); - if (waitResponse() != 1) { - return false; - } - + if (waitResponse() != 1) { return false; } + return true; } }; diff --git a/src/TinyGsmClientSaraR4.h b/src/TinyGsmClientSaraR4.h index 3d3b28de..664f2f5a 100644 --- a/src/TinyGsmClientSaraR4.h +++ b/src/TinyGsmClientSaraR4.h @@ -14,9 +14,9 @@ #define TINY_GSM_MUX_COUNT 7 #define TINY_GSM_BUFFER_READ_AND_CHECK_SIZE -#ifdef GSM_NL -#undef GSM_NL -#define GSM_NL "\r\n" // NOTE: define before including TinyGsmModem! +#ifdef AT_NL +#undef AT_NL +#define AT_NL "\r\n" // NOTE: define before including TinyGsmModem! #endif #include "TinyGsmBattery.tpp" @@ -264,13 +264,13 @@ class TinyGsmSaraR4 : public TinyGsmModem, sendAT(GF("+CGMI")); String res1; if (waitResponse(1000L, res1) != 1) { return "u-blox Cellular Modem"; } - res1.replace(GSM_NL "OK" GSM_NL, ""); + res1.replace(AT_NL "OK" AT_NL, ""); res1.trim(); sendAT(GF("+GMM")); String res2; if (waitResponse(1000L, res2) != 1) { return "u-blox Cellular Modem"; } - res2.replace(GSM_NL "OK" GSM_NL, ""); + res2.replace(AT_NL "OK" AT_NL, ""); res2.trim(); String name = res1 + String(' ') + res2; @@ -406,7 +406,7 @@ class TinyGsmSaraR4 : public TinyGsmModem, // This uses "CGSN" instead of "GSN" String getIMEIImpl() { sendAT(GF("+CGSN")); - if (waitResponse(GF(GSM_NL)) != 1) { return ""; } + if (waitResponse(GF(AT_NL)) != 1) { return ""; } String res = stream.readStringUntil('\n'); waitResponse(); res.trim(); @@ -436,12 +436,12 @@ class TinyGsmSaraR4 : public TinyGsmModem, // - 0: no aiding (default) // - 3: GPS + SBAS (default) sendAT(GF("+UGPS=1,0,3")); - if (waitResponse(10000L, GF(GSM_NL "+UGPS:")) != 1) { return false; } + if (waitResponse(10000L, GF(AT_NL "+UGPS:")) != 1) { return false; } return waitResponse(10000L) == 1; } bool disableGPSImpl() { sendAT(GF("+UGPS=0")); - if (waitResponse(10000L, GF(GSM_NL "+UGPS:")) != 1) { return false; } + if (waitResponse(10000L, GF(AT_NL "+UGPS:")) != 1) { return false; } return waitResponse(10000L) == 1; } String inline getUbloxLocationRaw(int8_t sensor) { @@ -461,7 +461,7 @@ class TinyGsmSaraR4 : public TinyGsmModem, // wait for first "OK" if (waitResponse(10000L) != 1) { return ""; } // wait for the final result - wait full timeout time - if (waitResponse(120000L, GF(GSM_NL "+UULOC:")) != 1) { return ""; } + if (waitResponse(120000L, GF(AT_NL "+UULOC:")) != 1) { return ""; } String res = stream.readStringUntil('\n'); waitResponse(); res.trim(); @@ -496,7 +496,7 @@ class TinyGsmSaraR4 : public TinyGsmModem, // wait for first "OK" if (waitResponse(10000L) != 1) { return false; } // wait for the final result - wait full timeout time - if (waitResponse(120000L, GF(GSM_NL "+UULOC: ")) != 1) { return false; } + if (waitResponse(120000L, GF(AT_NL "+UULOC: ")) != 1) { return false; } // +UULOC: ,