mirror of
				https://github.com/KevinMidboe/TinyGSM.git
				synced 2025-10-29 18:00:18 +00:00 
			
		
		
		
	Size a few more things
Signed-off-by: Sara Damiano <sdamiano@stroudcenter.org>
This commit is contained in:
		| @@ -18,7 +18,9 @@ | ||||
| #define TINY_GSM_MODEM_SIM800 | ||||
|  | ||||
| // Increase RX buffer if needed | ||||
| // #define TINY_GSM_RX_BUFFER 512 | ||||
| #if !defined(TINY_GSM_RX_BUFFER) | ||||
| #define TINY_GSM_RX_BUFFER 512 | ||||
| #endif | ||||
|  | ||||
| #include <TinyGsmClient.h> | ||||
| #include <ArduinoHttpClient.h> | ||||
|   | ||||
| @@ -66,7 +66,7 @@ class TinyGsmBattery { | ||||
|     if (thisModem().waitResponse(GF("+CBC:")) != 1) { return false; } | ||||
|     thisModem().streamSkipUntil(',');  // Skip battery charge status | ||||
|     // Read battery charge level | ||||
|     int res = thisModem().streamGetInt(','); | ||||
|     int8_t res = thisModem().streamGetInt(','); | ||||
|     // Wait for final OK | ||||
|     thisModem().waitResponse(); | ||||
|     return res; | ||||
| @@ -76,7 +76,7 @@ class TinyGsmBattery { | ||||
|     thisModem().sendAT(GF("+CBC")); | ||||
|     if (thisModem().waitResponse(GF("+CBC:")) != 1) { return false; } | ||||
|     // Read battery charge status | ||||
|     int res = thisModem().streamGetInt(','); | ||||
|     int8_t res = thisModem().streamGetInt(','); | ||||
|     // Wait for final OK | ||||
|     thisModem().waitResponse(); | ||||
|     return res; | ||||
|   | ||||
| @@ -59,7 +59,7 @@ class TinyGsmCalling { | ||||
|     } else { | ||||
|       thisModem().sendAT(GF("D"), number, ";"); | ||||
|     } | ||||
|     int status = thisModem().waitResponse(60000L, GF("OK"), GF("BUSY"), | ||||
|     int8_t status = thisModem().waitResponse(60000L, GF("OK"), GF("BUSY"), | ||||
|                                              GF("NO ANSWER"), GF("NO CARRIER")); | ||||
|     switch (status) { | ||||
|       case 1: return true; | ||||
|   | ||||
| @@ -149,7 +149,7 @@ class TinyGsmA6 | ||||
|  | ||||
|     DBG(GF("### Modem:"), getModemName()); | ||||
|  | ||||
|     int ret = getSimStatus(); | ||||
|     SimStatus ret = getSimStatus(); | ||||
|     // if the sim isn't ready and a pin has been provided, try to unlock the sim | ||||
|     if (ret != SIM_READY && pin != NULL && strlen(pin) > 0) { | ||||
|       simUnlock(pin); | ||||
| @@ -298,10 +298,10 @@ class TinyGsmA6 | ||||
|       return false; | ||||
|     } | ||||
|  | ||||
|     int rsp = waitResponse(60000L, GF(GSM_NL "+CIEV: \"SOUNDER\",0"), | ||||
|     int8_t rsp = waitResponse(60000L, GF(GSM_NL "+CIEV: \"SOUNDER\",0"), | ||||
|                               GF(GSM_NL "+CIEV: \"CALL\",0")); | ||||
|  | ||||
|     int rsp2 = waitResponse(300L, GF(GSM_NL "BUSY" GSM_NL), | ||||
|     int8_t rsp2 = waitResponse(300L, GF(GSM_NL "BUSY" GSM_NL), | ||||
|                                GF(GSM_NL "NO ANSWER" GSM_NL)); | ||||
|  | ||||
|     return rsp == 1 && rsp2 == 0; | ||||
| @@ -359,7 +359,7 @@ class TinyGsmA6 | ||||
|     streamSkipUntil('"'); | ||||
|     String hex = stream.readStringUntil('"'); | ||||
|     streamSkipUntil(','); | ||||
|     int dcs = streamGetInt('\n'); | ||||
|     int8_t dcs = streamGetInt('\n'); | ||||
|  | ||||
|     if (dcs == 15) { | ||||
|       return TinyGsmDecodeHex7bit(hex); | ||||
| @@ -389,7 +389,7 @@ class TinyGsmA6 | ||||
|     if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { return false; } | ||||
|     streamSkipUntil(',');  // Skip battery charge status | ||||
|     // Read battery charge level | ||||
|     int res = streamGetInt('\n'); | ||||
|     int8_t res = streamGetInt('\n'); | ||||
|     // Wait for final OK | ||||
|     waitResponse(); | ||||
|     return res; | ||||
| @@ -419,11 +419,11 @@ class TinyGsmA6 | ||||
|  | ||||
|     sendAT(GF("+CIPSTART="), GF("\"TCP"), GF("\",\""), host, GF("\","), port); | ||||
|     if (waitResponse(timeout_ms, GF(GSM_NL "+CIPNUM:")) != 1) { return false; } | ||||
|     int newMux = streamGetInt('\n'); | ||||
|     int8_t newMux = streamGetInt('\n'); | ||||
|  | ||||
|     int 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" GSM_NL), | ||||
|         GF("CONNECT FAIL" GSM_NL), GF("ALREADY CONNECT" GSM_NL)); | ||||
|     if (waitResponse() != 1) { return false; } | ||||
|     *mux = newMux; | ||||
|  | ||||
| @@ -448,7 +448,7 @@ class TinyGsmA6 | ||||
|  | ||||
|   bool modemGetConnected(uint8_t) { | ||||
|     sendAT(GF("+CIPSTATUS"));  // TODO(?) mux? | ||||
|     int res = waitResponse(GF(",\"CONNECTED\""), GF(",\"CLOSED\""), | ||||
|     int8_t res = waitResponse(GF(",\"CONNECTED\""), GF(",\"CLOSED\""), | ||||
|                               GF(",\"CLOSING\""), GF(",\"INITIAL\"")); | ||||
|     waitResponse(); | ||||
|     return 1 == res; | ||||
| @@ -459,7 +459,7 @@ class TinyGsmA6 | ||||
|    */ | ||||
|  public: | ||||
|   // TODO(vshymanskyy): Optimize this! | ||||
|   uint8_t waitResponse(uint32_t timeout_ms, String& data, | ||||
|   int8_t waitResponse(uint32_t timeout_ms, String& data, | ||||
|                       GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), | ||||
|                       GsmConstStr r3 = GFP(GSM_CME_ERROR), | ||||
| @@ -477,7 +477,7 @@ class TinyGsmA6 | ||||
|       TINY_GSM_YIELD(); | ||||
|       while (stream.available() > 0) { | ||||
|         TINY_GSM_YIELD(); | ||||
|         int a = stream.read(); | ||||
|         int8_t a = stream.read(); | ||||
|         if (a <= 0) continue;  // Skip 0x00 bytes, just in case | ||||
|         data += static_cast<char>(a); | ||||
|         if (r1 && data.endsWith(r1)) { | ||||
| @@ -499,9 +499,9 @@ class TinyGsmA6 | ||||
|           index = 5; | ||||
|           goto finish; | ||||
|         } else if (data.endsWith(GF("+CIPRCV:"))) { | ||||
|           int mux      = streamGetInt(','); | ||||
|           int len      = streamGetInt(','); | ||||
|           int len_orig = len; | ||||
|           int8_t  mux      = streamGetInt(','); | ||||
|           int16_t len      = streamGetInt(','); | ||||
|           int16_t len_orig = len; | ||||
|           if (len > sockets[mux]->rx.free()) { | ||||
|             DBG("### Buffer overflow: ", len, "->", sockets[mux]->rx.free()); | ||||
|           } else { | ||||
| @@ -515,7 +515,7 @@ class TinyGsmA6 | ||||
|           } | ||||
|           data = ""; | ||||
|         } else if (data.endsWith(GF("+TCPCLOSED:"))) { | ||||
|           int mux = streamGetInt('\n'); | ||||
|           int8_t mux = streamGetInt('\n'); | ||||
|           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT) { | ||||
|             sockets[mux]->sock_connected = false; | ||||
|           } | ||||
| @@ -535,7 +535,7 @@ class TinyGsmA6 | ||||
|     return index; | ||||
|   } | ||||
|  | ||||
|   uint8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), | ||||
|   int8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), | ||||
|                       GsmConstStr r3 = GFP(GSM_CME_ERROR), | ||||
|                       GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { | ||||
| @@ -543,7 +543,7 @@ class TinyGsmA6 | ||||
|     return waitResponse(timeout_ms, data, r1, r2, r3, r4, r5); | ||||
|   } | ||||
|  | ||||
|   uint8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), | ||||
|   int8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), | ||||
|                       GsmConstStr r3 = GFP(GSM_CME_ERROR), | ||||
|                       GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { | ||||
|   | ||||
| @@ -167,7 +167,7 @@ class TinyGsmBG96 | ||||
|     sendAT(GF("+CTZU=1")); | ||||
|     if (waitResponse(10000L) != 1) { return false; } | ||||
|  | ||||
|     int ret = getSimStatus(); | ||||
|     SimStatus ret = getSimStatus(); | ||||
|     // if the sim isn't ready and a pin has been provided, try to unlock the sim | ||||
|     if (ret != SIM_READY && pin != NULL && strlen(pin) > 0) { | ||||
|       simUnlock(pin); | ||||
| @@ -294,7 +294,7 @@ class TinyGsmBG96 | ||||
|   bool modemConnect(const char* host, uint16_t port, uint8_t mux, | ||||
|                     bool ssl = false, int timeout_s = 20) { | ||||
|     if (ssl) { DBG("SSL not yet supported on this module!"); } | ||||
|     int      rsp; | ||||
|  | ||||
|     uint32_t timeout_ms = ((uint32_t)timeout_s) * 1000; | ||||
|  | ||||
|     // <PDPcontextID>(1-16), <connectID>(0-11), | ||||
| @@ -308,9 +308,7 @@ class TinyGsmBG96 | ||||
|  | ||||
|     if (streamGetInt(',') != mux) { return false; } | ||||
|     // Read status | ||||
|     rsp = streamGetInt('\n'); | ||||
|  | ||||
|     return (0 == rsp); | ||||
|     return (0 == streamGetInt('\n')); | ||||
|   } | ||||
|  | ||||
|   int16_t modemSend(const void* buff, size_t len, uint8_t mux) { | ||||
| @@ -326,7 +324,7 @@ class TinyGsmBG96 | ||||
|   size_t modemRead(size_t size, uint8_t mux) { | ||||
|     sendAT(GF("+QIRD="), mux, ',', (uint16_t)size); | ||||
|     if (waitResponse(GF("+QIRD:")) != 1) { return 0; } | ||||
|     int len = streamGetInt('\n'); | ||||
|     int16_t len = streamGetInt('\n'); | ||||
|  | ||||
|     for (int i = 0; i < len; i++) { moveCharFromStreamToFifo(mux); } | ||||
|     waitResponse(); | ||||
| @@ -360,7 +358,7 @@ class TinyGsmBG96 | ||||
|     streamSkipUntil(',');            // Skip remote ip | ||||
|     streamSkipUntil(',');            // Skip remote port | ||||
|     streamSkipUntil(',');            // Skip local port | ||||
|     int res = streamGetInt(',');  // socket state | ||||
|     int8_t res = streamGetInt(',');  // socket state | ||||
|  | ||||
|     waitResponse(); | ||||
|  | ||||
| @@ -373,7 +371,7 @@ class TinyGsmBG96 | ||||
|    */ | ||||
|  public: | ||||
|   // TODO(vshymanskyy): Optimize this! | ||||
|   uint8_t waitResponse(uint32_t timeout_ms, String& data, | ||||
|   int8_t waitResponse(uint32_t timeout_ms, String& data, | ||||
|                       GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), | ||||
|                       GsmConstStr r3 = GFP(GSM_CME_ERROR), | ||||
| @@ -391,7 +389,7 @@ class TinyGsmBG96 | ||||
|       TINY_GSM_YIELD(); | ||||
|       while (stream.available() > 0) { | ||||
|         TINY_GSM_YIELD(); | ||||
|         int a = stream.read(); | ||||
|         int8_t a = stream.read(); | ||||
|         if (a <= 0) continue;  // Skip 0x00 bytes, just in case | ||||
|         data += static_cast<char>(a); | ||||
|         if (r1 && data.endsWith(r1)) { | ||||
| @@ -417,13 +415,13 @@ class TinyGsmBG96 | ||||
|           String urc = stream.readStringUntil('\"'); | ||||
|           streamSkipUntil(','); | ||||
|           if (urc == "recv") { | ||||
|             int mux = streamGetInt('\n'); | ||||
|             int8_t mux = streamGetInt('\n'); | ||||
|             DBG("### URC RECV:", mux); | ||||
|             if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { | ||||
|               sockets[mux]->got_data = true; | ||||
|             } | ||||
|           } else if (urc == "closed") { | ||||
|             int mux = streamGetInt('\n'); | ||||
|             int8_t mux = streamGetInt('\n'); | ||||
|             DBG("### URC CLOSE:", mux); | ||||
|             if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { | ||||
|               sockets[mux]->sock_connected = false; | ||||
| @@ -446,7 +444,7 @@ class TinyGsmBG96 | ||||
|     return index; | ||||
|   } | ||||
|  | ||||
|   uint8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), | ||||
|   int8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), | ||||
|                       GsmConstStr r3 = GFP(GSM_CME_ERROR), | ||||
|                       GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { | ||||
| @@ -454,7 +452,7 @@ class TinyGsmBG96 | ||||
|     return waitResponse(timeout_ms, data, r1, r2, r3, r4, r5); | ||||
|   } | ||||
|  | ||||
|   uint8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), | ||||
|   int8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), | ||||
|                       GsmConstStr r3 = GFP(GSM_CME_ERROR), | ||||
|                       GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { | ||||
|   | ||||
| @@ -202,16 +202,16 @@ class TinyGsmESP8266 | ||||
|   RegStatus getRegistrationStatus() { | ||||
|     sendAT(GF("+CIPSTATUS")); | ||||
|     if (waitResponse(3000, GF("STATUS:")) != 1) return REG_UNKNOWN; | ||||
|     int status = waitResponse(GFP(GSM_ERROR), GF("2"), GF("3"), GF("4"), | ||||
|     int8_t status = waitResponse(GFP(GSM_ERROR), GF("2"), GF("3"), GF("4"), | ||||
|                                  GF("5")); | ||||
|     waitResponse();  // Returns an OK after the status | ||||
|     return (RegStatus)status; | ||||
|   } | ||||
|  | ||||
|  protected: | ||||
|   int16_t getSignalQualityImpl() { | ||||
|   int8_t getSignalQualityImpl() { | ||||
|     sendAT(GF("+CWJAP_CUR?")); | ||||
|     int res1 = waitResponse(GF("No AP"), GF("+CWJAP_CUR:")); | ||||
|     int8_t res1 = waitResponse(GF("No AP"), GF("+CWJAP_CUR:")); | ||||
|     if (res1 != 2) { | ||||
|       waitResponse(); | ||||
|       return 0; | ||||
| @@ -219,7 +219,7 @@ class TinyGsmESP8266 | ||||
|     streamSkipUntil(',');             // Skip SSID | ||||
|     streamSkipUntil(',');             // Skip BSSID/MAC address | ||||
|     streamSkipUntil(',');             // Skip Chanel number | ||||
|     int res2 = stream.parseInt();  // Read RSSI | ||||
|     int8_t res2 = stream.parseInt();  // Read RSSI | ||||
|     waitResponse();                   // Returns an OK after the value | ||||
|     return res2; | ||||
|   } | ||||
| @@ -243,7 +243,7 @@ class TinyGsmESP8266 | ||||
|  | ||||
|   String getLocalIPImpl() { | ||||
|     sendAT(GF("+CIPSTA_CUR?")); | ||||
|     int res1 = waitResponse(GF("ERROR"), GF("+CWJAP_CUR:")); | ||||
|     int8_t res1 = waitResponse(GF("ERROR"), GF("+CWJAP_CUR:")); | ||||
|     if (res1 != 2) { return ""; } | ||||
|     String res2 = stream.readStringUntil('"'); | ||||
|     waitResponse(); | ||||
| @@ -285,7 +285,7 @@ class TinyGsmESP8266 | ||||
|            GF("\",\""), host, GF("\","), port, GF(","), | ||||
|            TINY_GSM_TCP_KEEP_ALIVE); | ||||
|     // TODO(?): Check mux | ||||
|     int rsp = waitResponse(timeout_ms, GFP(GSM_OK), GFP(GSM_ERROR), | ||||
|     int8_t rsp = waitResponse(timeout_ms, GFP(GSM_OK), GFP(GSM_ERROR), | ||||
|                               GF("ALREADY CONNECT")); | ||||
|     // if (rsp == 3) waitResponse(); | ||||
|     // May return "ERROR" after the "ALREADY CONNECT" | ||||
| @@ -311,7 +311,7 @@ class TinyGsmESP8266 | ||||
|   bool modemGetConnected(uint8_t mux) { | ||||
|     sendAT(GF("+CIPSTATUS")); | ||||
|     if (waitResponse(3000, GF("STATUS:")) != 1) { return false; } | ||||
|     int status = waitResponse(GFP(GSM_ERROR), GF("2"), GF("3"), GF("4"), | ||||
|     int8_t status = waitResponse(GFP(GSM_ERROR), GF("2"), GF("3"), GF("4"), | ||||
|                                  GF("5")); | ||||
|     if (status != 3) { | ||||
|       // if the status is anything but 3, there are no connections open | ||||
| @@ -326,7 +326,7 @@ class TinyGsmESP8266 | ||||
|       uint8_t has_status = waitResponse(GF("+CIPSTATUS:"), GFP(GSM_OK), | ||||
|                                         GFP(GSM_ERROR)); | ||||
|       if (has_status == 1) { | ||||
|         int returned_mux = streamGetInt(','); | ||||
|         int8_t returned_mux = streamGetInt(','); | ||||
|         streamSkipUntil(',');   // Skip mux | ||||
|         streamSkipUntil(',');   // Skip type | ||||
|         streamSkipUntil(',');   // Skip remote IP | ||||
| @@ -348,7 +348,7 @@ class TinyGsmESP8266 | ||||
|    */ | ||||
|  public: | ||||
|   // TODO(vshymanskyy): Optimize this! | ||||
|   uint8_t waitResponse(uint32_t timeout_ms, String& data, | ||||
|   int8_t waitResponse(uint32_t timeout_ms, String& data, | ||||
|                       GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), GsmConstStr r3 = NULL, | ||||
|                       GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { | ||||
| @@ -365,7 +365,7 @@ class TinyGsmESP8266 | ||||
|       TINY_GSM_YIELD(); | ||||
|       while (stream.available() > 0) { | ||||
|         TINY_GSM_YIELD(); | ||||
|         int a = stream.read(); | ||||
|         int8_t a = stream.read(); | ||||
|         if (a <= 0) continue;  // Skip 0x00 bytes, just in case | ||||
|         data += static_cast<char>(a); | ||||
|         if (r1 && data.endsWith(r1)) { | ||||
| @@ -384,9 +384,9 @@ class TinyGsmESP8266 | ||||
|           index = 5; | ||||
|           goto finish; | ||||
|         } else if (data.endsWith(GF("+IPD,"))) { | ||||
|           int mux      = streamGetInt(','); | ||||
|           int len      = streamGetInt(':'); | ||||
|           int len_orig = len; | ||||
|           int8_t  mux      = streamGetInt(','); | ||||
|           int16_t len      = streamGetInt(':'); | ||||
|           int16_t len_orig = len; | ||||
|           if (len > sockets[mux]->rx.free()) { | ||||
|             DBG("### Buffer overflow: ", len, "received vs", | ||||
|                 sockets[mux]->rx.free(), "available"); | ||||
| @@ -401,10 +401,10 @@ class TinyGsmESP8266 | ||||
|           } | ||||
|           data = ""; | ||||
|         } else if (data.endsWith(GF("CLOSED"))) { | ||||
|           int muxStart = | ||||
|           int8_t muxStart = | ||||
|               TinyGsmMax(0, data.lastIndexOf(GSM_NL, data.length() - 8)); | ||||
|           int coma = data.indexOf(',', muxStart); | ||||
|           int mux  = data.substring(muxStart, coma).toInt(); | ||||
|           int8_t coma = data.indexOf(',', muxStart); | ||||
|           int8_t mux  = data.substring(muxStart, coma).toInt(); | ||||
|           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { | ||||
|             sockets[mux]->sock_connected = false; | ||||
|           } | ||||
| @@ -424,14 +424,14 @@ class TinyGsmESP8266 | ||||
|     return index; | ||||
|   } | ||||
|  | ||||
|   uint8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), | ||||
|   int8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), GsmConstStr r3 = NULL, | ||||
|                       GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { | ||||
|     String data; | ||||
|     return waitResponse(timeout_ms, data, r1, r2, r3, r4, r5); | ||||
|   } | ||||
|  | ||||
|   uint8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), | ||||
|   int8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), GsmConstStr r3 = NULL, | ||||
|                       GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { | ||||
|     return waitResponse(1000, r1, r2, r3, r4, r5); | ||||
|   | ||||
| @@ -128,7 +128,7 @@ class TinyGsmM590 | ||||
|  | ||||
|     DBG(GF("### Modem:"), getModemName()); | ||||
|  | ||||
|     int ret = getSimStatus(); | ||||
|     SimStatus ret = getSimStatus(); | ||||
|     // if the sim isn't ready and a pin has been provided, try to unlock the sim | ||||
|     if (ret != SIM_READY && pin != NULL && strlen(pin) > 0) { | ||||
|       simUnlock(pin); | ||||
| @@ -257,7 +257,7 @@ class TinyGsmM590 | ||||
|   bool isGprsConnectedImpl() { | ||||
|     sendAT(GF("+XIIC?")); | ||||
|     if (waitResponse(GF(GSM_NL "+XIIC:")) != 1) { return false; } | ||||
|     int res = streamGetInt(','); | ||||
|     int8_t res = streamGetInt(','); | ||||
|     waitResponse(); | ||||
|     return res == 1; | ||||
|   } | ||||
| @@ -292,7 +292,8 @@ class TinyGsmM590 | ||||
|       String ip = dnsIpQuery(host); | ||||
|  | ||||
|       sendAT(GF("+TCPSETUP="), mux, GF(","), ip, GF(","), port); | ||||
|       int rsp = waitResponse(timeout_ms, GF(",OK" GSM_NL), GF(",FAIL" GSM_NL), | ||||
|       int8_t rsp = waitResponse(timeout_ms, GF(",OK" GSM_NL), | ||||
|                                 GF(",FAIL" GSM_NL), | ||||
|                                 GF("+TCPSETUP:Error" GSM_NL)); | ||||
|       if (1 == rsp) { | ||||
|         return true; | ||||
| @@ -325,7 +326,7 @@ class TinyGsmM590 | ||||
|  | ||||
|   bool modemGetConnected(uint8_t mux) { | ||||
|     sendAT(GF("+CIPSTATUS="), mux); | ||||
|     int res = waitResponse(GF(",\"CONNECTED\""), GF(",\"CLOSED\""), | ||||
|     int8_t res = waitResponse(GF(",\"CONNECTED\""), GF(",\"CLOSED\""), | ||||
|                               GF(",\"CLOSING\""), GF(",\"INITIAL\"")); | ||||
|     waitResponse(); | ||||
|     return 1 == res; | ||||
| @@ -345,7 +346,7 @@ class TinyGsmM590 | ||||
|    */ | ||||
|  public: | ||||
|   // TODO(vshymanskyy): Optimize this! | ||||
|   uint8_t waitResponse(uint32_t timeout_ms, String& data, | ||||
|   int8_t waitResponse(uint32_t timeout_ms, String& data, | ||||
|                       GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), | ||||
|                       GsmConstStr r3 = GFP(GSM_CME_ERROR), | ||||
| @@ -363,7 +364,7 @@ class TinyGsmM590 | ||||
|       TINY_GSM_YIELD(); | ||||
|       while (stream.available() > 0) { | ||||
|         TINY_GSM_YIELD(); | ||||
|         int a = stream.read(); | ||||
|         int8_t a = stream.read(); | ||||
|         if (a <= 0) continue;  // Skip 0x00 bytes, just in case | ||||
|         data += static_cast<char>(a); | ||||
|         if (r1 && data.endsWith(r1)) { | ||||
| @@ -385,9 +386,9 @@ class TinyGsmM590 | ||||
|           index = 5; | ||||
|           goto finish; | ||||
|         } else if (data.endsWith(GF("+TCPRECV:"))) { | ||||
|           int mux      = streamGetInt(','); | ||||
|           int len      = streamGetInt(','); | ||||
|           int len_orig = len; | ||||
|           int8_t  mux      = streamGetInt(','); | ||||
|           int16_t len      = streamGetInt(','); | ||||
|           int16_t len_orig = len; | ||||
|           if (len > sockets[mux]->rx.free()) { | ||||
|             DBG("### Buffer overflow: ", len, "->", sockets[mux]->rx.free()); | ||||
|           } else { | ||||
| @@ -401,7 +402,7 @@ class TinyGsmM590 | ||||
|           } | ||||
|           data = ""; | ||||
|         } else if (data.endsWith(GF("+TCPCLOSE:"))) { | ||||
|           int mux = streamGetInt(','); | ||||
|           int8_t mux = streamGetInt(','); | ||||
|           streamSkipUntil('\n'); | ||||
|           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT) { | ||||
|             sockets[mux]->sock_connected = false; | ||||
| @@ -422,7 +423,7 @@ class TinyGsmM590 | ||||
|     return index; | ||||
|   } | ||||
|  | ||||
|   uint8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), | ||||
|   int8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), | ||||
|                       GsmConstStr r3 = GFP(GSM_CME_ERROR), | ||||
|                       GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { | ||||
| @@ -430,7 +431,7 @@ class TinyGsmM590 | ||||
|     return waitResponse(timeout_ms, data, r1, r2, r3, r4, r5); | ||||
|   } | ||||
|  | ||||
|   uint8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), | ||||
|   int8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), | ||||
|                       GsmConstStr r3 = GFP(GSM_CME_ERROR), | ||||
|                       GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { | ||||
|   | ||||
| @@ -174,7 +174,7 @@ class TinyGsmM95 | ||||
|     sendAT(GF("+QNITZ=1")); | ||||
|     if (waitResponse(10000L) != 1) { return false; } | ||||
|  | ||||
|     int ret = getSimStatus(); | ||||
|     SimStatus ret = getSimStatus(); | ||||
|     // if the sim isn't ready and a pin has been provided, try to unlock the sim | ||||
|     if (ret != SIM_READY && pin != NULL && strlen(pin) > 0) { | ||||
|       simUnlock(pin); | ||||
| @@ -404,7 +404,7 @@ class TinyGsmM95 | ||||
|     uint32_t timeout_ms = ((uint32_t)timeout_s) * 1000; | ||||
|     sendAT(GF("+QIOPEN="), mux, GF(",\""), GF("TCP"), GF("\",\""), host, | ||||
|            GF("\","), port); | ||||
|     int rsp = waitResponse(timeout_ms, GF("CONNECT OK" GSM_NL), | ||||
|     int8_t rsp = waitResponse(timeout_ms, GF("CONNECT OK" GSM_NL), | ||||
|                               GF("CONNECT FAIL" GSM_NL), | ||||
|                               GF("ALREADY CONNECT" GSM_NL)); | ||||
|     return (1 == rsp); | ||||
| @@ -447,7 +447,7 @@ class TinyGsmM95 | ||||
|     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. | ||||
|     int res = waitResponse(GF("+QIRD:"), GFP(GSM_OK), GFP(GSM_ERROR)); | ||||
|     int8_t res = waitResponse(GF("+QIRD:"), GFP(GSM_OK), GFP(GSM_ERROR)); | ||||
|     if (res == 1) { | ||||
|       streamSkipUntil(':');  // skip IP address | ||||
|       streamSkipUntil(',');  // skip port | ||||
| @@ -490,7 +490,7 @@ class TinyGsmM95 | ||||
|     streamSkipUntil(',');            // Skip remote ip | ||||
|     streamSkipUntil(',');            // Skip remote port | ||||
|     streamSkipUntil(',');            // Skip local port | ||||
|     int res = streamGetInt(',');  // socket state | ||||
|     int8_t res = streamGetInt(',');  // socket state | ||||
|  | ||||
|     waitResponse(); | ||||
|  | ||||
| @@ -503,7 +503,7 @@ class TinyGsmM95 | ||||
|    */ | ||||
|  public: | ||||
|   // TODO(vshymanskyy): Optimize this! | ||||
|   uint8_t waitResponse(uint32_t timeout_ms, String& data, | ||||
|   int8_t waitResponse(uint32_t timeout_ms, String& data, | ||||
|                       GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), | ||||
|                       GsmConstStr r3 = GFP(GSM_CME_ERROR), | ||||
| @@ -521,7 +521,7 @@ class TinyGsmM95 | ||||
|       TINY_GSM_YIELD(); | ||||
|       while (stream.available() > 0) { | ||||
|         TINY_GSM_YIELD(); | ||||
|         int a = stream.read(); | ||||
|         int8_t a = stream.read(); | ||||
|         if (a <= 0) continue;  // Skip 0x00 bytes, just in case | ||||
|         data += static_cast<char>(a); | ||||
|         if (r1 && data.endsWith(r1)) { | ||||
| @@ -545,7 +545,7 @@ class TinyGsmM95 | ||||
|         } else if (data.endsWith(GF(GSM_NL "+QIRDI:"))) { | ||||
|           streamSkipUntil(',');  // Skip the context | ||||
|           streamSkipUntil(',');  // Skip the role | ||||
|           int mux = streamGetInt('\n'); | ||||
|           int8_t mux = streamGetInt('\n'); | ||||
|           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 | ||||
| @@ -554,9 +554,9 @@ class TinyGsmM95 | ||||
|           } | ||||
|           data = ""; | ||||
|         } else if (data.endsWith(GF("CLOSED" GSM_NL))) { | ||||
|           int nl   = data.lastIndexOf(GSM_NL, data.length() - 8); | ||||
|           int coma = data.indexOf(',', nl + 2); | ||||
|           int mux  = data.substring(nl + 2, coma).toInt(); | ||||
|           int8_t nl   = data.lastIndexOf(GSM_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]) { | ||||
|             sockets[mux]->sock_connected = false; | ||||
|           } | ||||
| @@ -576,7 +576,7 @@ class TinyGsmM95 | ||||
|     return index; | ||||
|   } | ||||
|  | ||||
|   uint8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), | ||||
|   int8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), | ||||
|                       GsmConstStr r3 = GFP(GSM_CME_ERROR), | ||||
|                       GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { | ||||
| @@ -584,7 +584,7 @@ class TinyGsmM95 | ||||
|     return waitResponse(timeout_ms, data, r1, r2, r3, r4, r5); | ||||
|   } | ||||
|  | ||||
|   uint8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), | ||||
|   int8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), | ||||
|                       GsmConstStr r3 = GFP(GSM_CME_ERROR), | ||||
|                       GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { | ||||
|   | ||||
| @@ -173,7 +173,7 @@ class TinyGsmMC60 | ||||
|     sendAT(GF("+QNITZ=1")); | ||||
|     if (waitResponse(10000L) != 1) { return false; } | ||||
|  | ||||
|     int ret = getSimStatus(); | ||||
|     SimStatus ret = getSimStatus(); | ||||
|     // if the sim isn't ready and a pin has been provided, try to unlock the sim | ||||
|     if (ret != SIM_READY && pin != NULL && strlen(pin) > 0) { | ||||
|       simUnlock(pin); | ||||
| @@ -305,7 +305,7 @@ class TinyGsmMC60 | ||||
|         delay(1000); | ||||
|         continue; | ||||
|       } | ||||
|       int status = waitResponse(GF("READY"), GF("SIM PIN"), GF("SIM PUK"), | ||||
|       int8_t status = waitResponse(GF("READY"), GF("SIM PIN"), GF("SIM PUK"), | ||||
|                                    GF("NOT INSERTED"), GF("PH_SIM PIN"), | ||||
|                                    GF("PH_SIM PUK")); | ||||
|       waitResponse(); | ||||
| @@ -364,7 +364,7 @@ class TinyGsmMC60 | ||||
|     uint32_t timeout_ms = ((uint32_t)timeout_s) * 1000; | ||||
|     sendAT(GF("+QIOPEN="), mux, GF(",\""), GF("TCP"), GF("\",\""), host, | ||||
|            GF("\","), port); | ||||
|     int rsp = waitResponse(timeout_ms, GF("CONNECT OK" GSM_NL), | ||||
|     int8_t rsp = waitResponse(timeout_ms, GF("CONNECT OK" GSM_NL), | ||||
|                               GF("CONNECT FAIL" GSM_NL), | ||||
|                               GF("ALREADY CONNECT" GSM_NL)); | ||||
|     return (1 == rsp); | ||||
| @@ -407,7 +407,7 @@ class TinyGsmMC60 | ||||
|     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. | ||||
|     int res = waitResponse(GF("+QIRD:"), GFP(GSM_OK), GFP(GSM_ERROR)); | ||||
|     int8_t res = waitResponse(GF("+QIRD:"), GFP(GSM_OK), GFP(GSM_ERROR)); | ||||
|     if (res == 1) { | ||||
|       streamSkipUntil(':');  // skip IP address | ||||
|       streamSkipUntil(',');  // skip port | ||||
| @@ -449,7 +449,7 @@ class TinyGsmMC60 | ||||
|     streamSkipUntil(',');            // Skip remote ip | ||||
|     streamSkipUntil(',');            // Skip remote port | ||||
|     streamSkipUntil(',');            // Skip local port | ||||
|     int res = streamGetInt(',');  // socket state | ||||
|     int8_t res = streamGetInt(',');  // socket state | ||||
|  | ||||
|     waitResponse(); | ||||
|  | ||||
| @@ -462,7 +462,7 @@ class TinyGsmMC60 | ||||
|    */ | ||||
|  public: | ||||
|   // TODO(vshymanskyy): Optimize this! | ||||
|   uint8_t waitResponse(uint32_t timeout_ms, String& data, | ||||
|   int8_t waitResponse(uint32_t timeout_ms, String& data, | ||||
|                       GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), | ||||
|                       GsmConstStr r3 = GFP(GSM_CME_ERROR), | ||||
| @@ -482,7 +482,7 @@ class TinyGsmMC60 | ||||
|       TINY_GSM_YIELD(); | ||||
|       while (stream.available() > 0) { | ||||
|         TINY_GSM_YIELD(); | ||||
|         int a = stream.read(); | ||||
|         int8_t a = stream.read(); | ||||
|         if (a <= 0) continue;  // Skip 0x00 bytes, just in case | ||||
|         data += static_cast<char>(a); | ||||
|         if (r1 && data.endsWith(r1)) { | ||||
| @@ -512,20 +512,20 @@ class TinyGsmMC60 | ||||
|           streamSkipUntil(',');  // Skip the context | ||||
|           streamSkipUntil(',');  // Skip the role | ||||
|           // read the connection id | ||||
|           int mux = streamGetInt(','); | ||||
|           int8_t mux = streamGetInt(','); | ||||
|           // read the number of packets in the buffer | ||||
|           int num_packets = streamGetInt(','); | ||||
|           int8_t num_packets = streamGetInt(','); | ||||
|           // read the length of the current packet | ||||
|           int len_packet = streamGetInt('\n'); | ||||
|           int16_t len_packet = streamGetInt('\n'); | ||||
|           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { | ||||
|             sockets[mux]->sock_available = len_packet * num_packets; | ||||
|           } | ||||
|           data = ""; | ||||
|           DBG("### Got Data:", len_packet * num_packets, "on", mux); | ||||
|         } else if (data.endsWith(GF("CLOSED" GSM_NL))) { | ||||
|           int nl   = data.lastIndexOf(GSM_NL, data.length() - 8); | ||||
|           int coma = data.indexOf(',', nl + 2); | ||||
|           int mux  = data.substring(nl + 2, coma).toInt(); | ||||
|           int8_t nl   = data.lastIndexOf(GSM_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]) { | ||||
|             sockets[mux]->sock_connected = false; | ||||
|           } | ||||
| @@ -545,7 +545,7 @@ class TinyGsmMC60 | ||||
|     return index; | ||||
|   } | ||||
|  | ||||
|   uint8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), | ||||
|   int8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), | ||||
|                       GsmConstStr r3 = GFP(GSM_CME_ERROR), | ||||
|                       GsmConstStr r4 = NULL, GsmConstStr r5 = NULL, | ||||
| @@ -554,7 +554,7 @@ class TinyGsmMC60 | ||||
|     return waitResponse(timeout_ms, data, r1, r2, r3, r4, r5, r6); | ||||
|   } | ||||
|  | ||||
|   uint8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), | ||||
|   int8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), | ||||
|                       GsmConstStr r3 = GFP(GSM_CME_ERROR), | ||||
|                       GsmConstStr r4 = NULL, GsmConstStr r5 = NULL, | ||||
|   | ||||
| @@ -169,7 +169,7 @@ class TinyGsmSim5360 : public TinyGsmModem<TinyGsmSim5360>, | ||||
|     sendAT(GF("+CTZU=1")); | ||||
|     if (waitResponse(10000L) != 1) { return false; } | ||||
|  | ||||
|     int ret = getSimStatus(); | ||||
|     SimStatus ret = getSimStatus(); | ||||
|     // if the sim isn't ready and a pin has been provided, try to unlock the sim | ||||
|     if (ret != SIM_READY && pin != NULL && strlen(pin) > 0) { | ||||
|       simUnlock(pin); | ||||
| @@ -511,9 +511,9 @@ class TinyGsmSim5360 : public TinyGsmModem<TinyGsmSim5360>, | ||||
| #endif | ||||
|     streamSkipUntil(',');  // Skip Rx mode 2/normal or 3/HEX | ||||
|     streamSkipUntil(',');  // Skip mux/cid (connecion id) | ||||
|     int len_requested = streamGetInt(','); | ||||
|     int16_t len_requested = streamGetInt(','); | ||||
|     //  ^^ Requested number of data bytes (1-1460 bytes)to be read | ||||
|     int len_confirmed = streamGetInt('\n'); | ||||
|     int16_t len_confirmed = streamGetInt('\n'); | ||||
|     // ^^ The data length which not read in the buffer | ||||
|     for (int i = 0; i < len_requested; i++) { | ||||
|       uint32_t startMillis = millis(); | ||||
| @@ -575,7 +575,7 @@ class TinyGsmSim5360 : public TinyGsmModem<TinyGsmSim5360>, | ||||
|    */ | ||||
|  public: | ||||
|   // TODO(vshymanskyy): Optimize this! | ||||
|   uint8_t waitResponse(uint32_t timeout_ms, String& data, | ||||
|   int8_t waitResponse(uint32_t timeout_ms, String& data, | ||||
|                       GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), | ||||
|                       GsmConstStr r3 = GFP(GSM_CME_ERROR), | ||||
| @@ -593,7 +593,7 @@ class TinyGsmSim5360 : public TinyGsmModem<TinyGsmSim5360>, | ||||
|       TINY_GSM_YIELD(); | ||||
|       while (stream.available() > 0) { | ||||
|         TINY_GSM_YIELD(); | ||||
|         int a = stream.read(); | ||||
|         int8_t a = stream.read(); | ||||
|         if (a <= 0) continue;  // Skip 0x00 bytes, just in case | ||||
|         data += static_cast<char>(a); | ||||
|         if (r1 && data.endsWith(r1)) { | ||||
| @@ -615,9 +615,9 @@ class TinyGsmSim5360 : public TinyGsmModem<TinyGsmSim5360>, | ||||
|           index = 5; | ||||
|           goto finish; | ||||
|         } else if (data.endsWith(GF(GSM_NL "+CIPRXGET:"))) { | ||||
|           int mode = streamGetInt(','); | ||||
|           int8_t mode = streamGetInt(','); | ||||
|           if (mode == 1) { | ||||
|             int mux = streamGetInt('\n'); | ||||
|             int8_t mux = streamGetInt('\n'); | ||||
|             if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { | ||||
|               sockets[mux]->got_data = true; | ||||
|             } | ||||
| @@ -627,8 +627,8 @@ class TinyGsmSim5360 : public TinyGsmModem<TinyGsmSim5360>, | ||||
|             data += mode; | ||||
|           } | ||||
|         } else if (data.endsWith(GF(GSM_NL "+RECEIVE:"))) { | ||||
|           int mux = streamGetInt(','); | ||||
|           int len = streamGetInt('\n'); | ||||
|           int8_t  mux = streamGetInt(','); | ||||
|           int16_t len = streamGetInt('\n'); | ||||
|           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { | ||||
|             sockets[mux]->got_data       = true; | ||||
|             sockets[mux]->sock_available = len; | ||||
| @@ -636,7 +636,7 @@ class TinyGsmSim5360 : public TinyGsmModem<TinyGsmSim5360>, | ||||
|           data = ""; | ||||
|           DBG("### Got Data:", len, "on", mux); | ||||
|         } else if (data.endsWith(GF("+IPCLOSE:"))) { | ||||
|           int mux = streamGetInt(','); | ||||
|           int8_t mux = streamGetInt(','); | ||||
|           streamSkipUntil('\n');  // Skip the reason code | ||||
|           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { | ||||
|             sockets[mux]->sock_connected = false; | ||||
| @@ -663,7 +663,7 @@ class TinyGsmSim5360 : public TinyGsmModem<TinyGsmSim5360>, | ||||
|     return index; | ||||
|   } | ||||
|  | ||||
|   uint8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), | ||||
|   int8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), | ||||
|                       GsmConstStr r3 = GFP(GSM_CME_ERROR), | ||||
|                       GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { | ||||
| @@ -671,7 +671,7 @@ class TinyGsmSim5360 : public TinyGsmModem<TinyGsmSim5360>, | ||||
|     return waitResponse(timeout_ms, data, r1, r2, r3, r4, r5); | ||||
|   } | ||||
|  | ||||
|   uint8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), | ||||
|   int8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), | ||||
|                       GsmConstStr r3 = GFP(GSM_CME_ERROR), | ||||
|                       GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { | ||||
|   | ||||
| @@ -171,7 +171,7 @@ class TinyGsmSim7000 : public TinyGsmModem<TinyGsmSim7000>, | ||||
|     sendAT(GF("+CBATCHK=1")); | ||||
|     if (waitResponse() != 1) { return false; } | ||||
|  | ||||
|     int ret = getSimStatus(); | ||||
|     SimStatus ret = getSimStatus(); | ||||
|     // if the sim isn't ready and a pin has been provided, try to unlock the sim | ||||
|     if (ret != SIM_READY && pin != NULL && strlen(pin) > 0) { | ||||
|       simUnlock(pin); | ||||
| @@ -513,15 +513,14 @@ class TinyGsmSim7000 : public TinyGsmModem<TinyGsmSim7000>, | ||||
|                     bool ssl = false, int timeout_s = 75) { | ||||
|     if (ssl) { DBG("SSL not yet supported on this module!"); } | ||||
|  | ||||
|     int      rsp; | ||||
|     uint32_t timeout_ms = ((uint32_t)timeout_s) * 1000; | ||||
|     sendAT(GF("+CIPSTART="), mux, ',', GF("\"TCP"), GF("\",\""), host, | ||||
|            GF("\","), port); | ||||
|     rsp = waitResponse( | ||||
|         timeout_ms, GF("CONNECT OK" GSM_NL), GF("CONNECT FAIL" GSM_NL), | ||||
|     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));  // Happens when HTTPS handshake fails | ||||
|     return (1 == rsp); | ||||
|                          GF("CLOSE OK" GSM_NL))); | ||||
|   } | ||||
|  | ||||
|   int16_t modemSend(const void* buff, size_t len, uint8_t mux) { | ||||
| @@ -544,9 +543,9 @@ class TinyGsmSim7000 : public TinyGsmModem<TinyGsmSim7000>, | ||||
| #endif | ||||
|     streamSkipUntil(',');  // Skip Rx mode 2/normal or 3/HEX | ||||
|     streamSkipUntil(',');  // Skip mux | ||||
|     int len_requested = streamGetInt(','); | ||||
|     int16_t len_requested = streamGetInt(','); | ||||
|     //  ^^ Requested number of data bytes (1-1460 bytes)to be read | ||||
|     int len_confirmed = streamGetInt('\n'); | ||||
|     int16_t len_confirmed = streamGetInt('\n'); | ||||
|     // ^^ Confirmed number of data bytes to be read, which may be less than | ||||
|     // requested. 0 indicates that no data can be read. This is actually be the | ||||
|     // number of bytes that will be remaining after the read | ||||
| @@ -595,7 +594,7 @@ class TinyGsmSim7000 : public TinyGsmModem<TinyGsmSim7000>, | ||||
|  | ||||
|   bool modemGetConnected(uint8_t mux) { | ||||
|     sendAT(GF("+CIPSTATUS="), mux); | ||||
|     int res = waitResponse(GF(",\"CONNECTED\""), GF(",\"CLOSED\""), | ||||
|     int8_t res = waitResponse(GF(",\"CONNECTED\""), GF(",\"CLOSED\""), | ||||
|                               GF(",\"CLOSING\""), GF(",\"INITIAL\"")); | ||||
|     waitResponse(); | ||||
|     return 1 == res; | ||||
| @@ -606,7 +605,7 @@ class TinyGsmSim7000 : public TinyGsmModem<TinyGsmSim7000>, | ||||
|    */ | ||||
|  public: | ||||
|   // TODO(vshymanskyy): Optimize this! | ||||
|   uint8_t waitResponse(uint32_t timeout_ms, String& data, | ||||
|   int8_t waitResponse(uint32_t timeout_ms, String& data, | ||||
|                       GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), | ||||
|                       GsmConstStr r3 = GFP(GSM_CME_ERROR), | ||||
| @@ -624,7 +623,7 @@ class TinyGsmSim7000 : public TinyGsmModem<TinyGsmSim7000>, | ||||
|       TINY_GSM_YIELD(); | ||||
|       while (stream.available() > 0) { | ||||
|         TINY_GSM_YIELD(); | ||||
|         int a = stream.read(); | ||||
|         int8_t a = stream.read(); | ||||
|         if (a <= 0) continue;  // Skip 0x00 bytes, just in case | ||||
|         data += static_cast<char>(a); | ||||
|         if (r1 && data.endsWith(r1)) { | ||||
| @@ -646,9 +645,9 @@ class TinyGsmSim7000 : public TinyGsmModem<TinyGsmSim7000>, | ||||
|           index = 5; | ||||
|           goto finish; | ||||
|         } else if (data.endsWith(GF(GSM_NL "+CIPRXGET:"))) { | ||||
|           int mode = streamGetInt(','); | ||||
|           int8_t mode = streamGetInt(','); | ||||
|           if (mode == 1) { | ||||
|             int mux = streamGetInt('\n'); | ||||
|             int8_t mux = streamGetInt('\n'); | ||||
|             if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { | ||||
|               sockets[mux]->got_data = true; | ||||
|             } | ||||
| @@ -658,8 +657,8 @@ class TinyGsmSim7000 : public TinyGsmModem<TinyGsmSim7000>, | ||||
|             data += mode; | ||||
|           } | ||||
|         } else if (data.endsWith(GF(GSM_NL "+RECEIVE:"))) { | ||||
|           int mux = streamGetInt(','); | ||||
|           int len = streamGetInt('\n'); | ||||
|           int8_t  mux = streamGetInt(','); | ||||
|           int16_t len = streamGetInt('\n'); | ||||
|           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { | ||||
|             sockets[mux]->got_data       = true; | ||||
|             sockets[mux]->sock_available = len; | ||||
| @@ -667,9 +666,9 @@ class TinyGsmSim7000 : public TinyGsmModem<TinyGsmSim7000>, | ||||
|           data = ""; | ||||
|           DBG("### Got Data:", len, "on", mux); | ||||
|         } else if (data.endsWith(GF("CLOSED" GSM_NL))) { | ||||
|           int nl   = data.lastIndexOf(GSM_NL, data.length() - 8); | ||||
|           int coma = data.indexOf(',', nl + 2); | ||||
|           int mux  = data.substring(nl + 2, coma).toInt(); | ||||
|           int8_t nl   = data.lastIndexOf(GSM_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]) { | ||||
|             sockets[mux]->sock_connected = false; | ||||
|           } | ||||
| @@ -689,7 +688,7 @@ class TinyGsmSim7000 : public TinyGsmModem<TinyGsmSim7000>, | ||||
|     return index; | ||||
|   } | ||||
|  | ||||
|   uint8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), | ||||
|   int8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), | ||||
|                       GsmConstStr r3 = GFP(GSM_CME_ERROR), | ||||
|                       GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { | ||||
| @@ -697,7 +696,7 @@ class TinyGsmSim7000 : public TinyGsmModem<TinyGsmSim7000>, | ||||
|     return waitResponse(timeout_ms, data, r1, r2, r3, r4, r5); | ||||
|   } | ||||
|  | ||||
|   uint8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), | ||||
|   int8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), | ||||
|                       GsmConstStr r3 = GFP(GSM_CME_ERROR), | ||||
|                       GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { | ||||
|   | ||||
| @@ -173,7 +173,7 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600>, | ||||
|     sendAT(GF("+CTZU=1")); | ||||
|     if (waitResponse(10000L) != 1) { return false; } | ||||
|  | ||||
|     int ret = getSimStatus(); | ||||
|     SimStatus ret = getSimStatus(); | ||||
|     // if the sim isn't ready and a pin has been provided, try to unlock the sim | ||||
|     if (ret != SIM_READY && pin != NULL && strlen(pin) > 0) { | ||||
|       simUnlock(pin); | ||||
| @@ -598,9 +598,9 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600>, | ||||
| #endif | ||||
|     streamSkipUntil(',');  // Skip Rx mode 2/normal or 3/HEX | ||||
|     streamSkipUntil(',');  // Skip mux/cid (connecion id) | ||||
|     int len_requested = streamGetInt(','); | ||||
|     int16_t len_requested = streamGetInt(','); | ||||
|     //  ^^ Requested number of data bytes (1-1460 bytes)to be read | ||||
|     int len_confirmed = streamGetInt('\n'); | ||||
|     int16_t len_confirmed = streamGetInt('\n'); | ||||
|     // ^^ The data length which not read in the buffer | ||||
|     for (int i = 0; i < len_requested; i++) { | ||||
|       uint32_t startMillis = millis(); | ||||
| @@ -664,7 +664,7 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600>, | ||||
|    */ | ||||
|  public: | ||||
|   // TODO(vshymanskyy): Optimize this! | ||||
|   uint8_t waitResponse(uint32_t timeout_ms, String& data, | ||||
|   int8_t waitResponse(uint32_t timeout_ms, String& data, | ||||
|                       GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), | ||||
|                       GsmConstStr r3 = GFP(GSM_CME_ERROR), | ||||
| @@ -682,7 +682,7 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600>, | ||||
|       TINY_GSM_YIELD(); | ||||
|       while (stream.available() > 0) { | ||||
|         TINY_GSM_YIELD(); | ||||
|         int a = stream.read(); | ||||
|         int8_t a = stream.read(); | ||||
|         if (a <= 0) continue;  // Skip 0x00 bytes, just in case | ||||
|         data += static_cast<char>(a); | ||||
|         if (r1 && data.endsWith(r1)) { | ||||
| @@ -704,9 +704,9 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600>, | ||||
|           index = 5; | ||||
|           goto finish; | ||||
|         } else if (data.endsWith(GF(GSM_NL "+CIPRXGET:"))) { | ||||
|           int mode = streamGetInt(','); | ||||
|           int8_t mode = streamGetInt(','); | ||||
|           if (mode == 1) { | ||||
|             int mux = streamGetInt('\n'); | ||||
|             int8_t mux = streamGetInt('\n'); | ||||
|             if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { | ||||
|               sockets[mux]->got_data = true; | ||||
|             } | ||||
| @@ -716,8 +716,8 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600>, | ||||
|             data += mode; | ||||
|           } | ||||
|         } else if (data.endsWith(GF(GSM_NL "+RECEIVE:"))) { | ||||
|           int mux = streamGetInt(','); | ||||
|           int len = streamGetInt('\n'); | ||||
|           int8_t  mux = streamGetInt(','); | ||||
|           int16_t len = streamGetInt('\n'); | ||||
|           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { | ||||
|             sockets[mux]->got_data       = true; | ||||
|             sockets[mux]->sock_available = len; | ||||
| @@ -725,7 +725,7 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600>, | ||||
|           data = ""; | ||||
|           DBG("### Got Data:", len, "on", mux); | ||||
|         } else if (data.endsWith(GF("+IPCLOSE:"))) { | ||||
|           int mux = streamGetInt(','); | ||||
|           int8_t mux = streamGetInt(','); | ||||
|           streamSkipUntil('\n');  // Skip the reason code | ||||
|           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { | ||||
|             sockets[mux]->sock_connected = false; | ||||
| @@ -752,7 +752,7 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600>, | ||||
|     return index; | ||||
|   } | ||||
|  | ||||
|   uint8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), | ||||
|   int8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), | ||||
|                       GsmConstStr r3 = GFP(GSM_CME_ERROR), | ||||
|                       GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { | ||||
| @@ -760,7 +760,7 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600>, | ||||
|     return waitResponse(timeout_ms, data, r1, r2, r3, r4, r5); | ||||
|   } | ||||
|  | ||||
|   uint8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), | ||||
|   int8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), | ||||
|                       GsmConstStr r3 = GFP(GSM_CME_ERROR), | ||||
|                       GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { | ||||
|   | ||||
| @@ -176,7 +176,7 @@ class TinyGsmSim800 | ||||
|     sendAT(GF("+CBATCHK=1")); | ||||
|     waitResponse(); | ||||
|  | ||||
|     int ret = getSimStatus(); | ||||
|     SimStatus ret = getSimStatus(); | ||||
|     // if the sim isn't ready and a pin has been provided, try to unlock the sim | ||||
|     if (ret != SIM_READY && pin != NULL && strlen(pin) > 0) { | ||||
|       simUnlock(pin); | ||||
| @@ -480,7 +480,7 @@ class TinyGsmSim800 | ||||
|  protected: | ||||
|   bool modemConnect(const char* host, uint16_t port, uint8_t mux, | ||||
|                     bool ssl = false, int timeout_s = 75) { | ||||
|     int      rsp; | ||||
|     int8_t   rsp; | ||||
|     uint32_t timeout_ms = ((uint32_t)timeout_s) * 1000; | ||||
| #if !defined(TINY_GSM_MODEM_SIM900) | ||||
|     sendAT(GF("+CIPSSL="), ssl); | ||||
| @@ -516,9 +516,9 @@ class TinyGsmSim800 | ||||
| #endif | ||||
|     streamSkipUntil(',');  // Skip Rx mode 2/normal or 3/HEX | ||||
|     streamSkipUntil(',');  // Skip mux | ||||
|     int len_requested = streamGetInt(','); | ||||
|     int16_t len_requested = streamGetInt(','); | ||||
|     //  ^^ Requested number of data bytes (1-1460 bytes)to be read | ||||
|     int len_confirmed = streamGetInt('\n'); | ||||
|     int16_t len_confirmed = streamGetInt('\n'); | ||||
|     // ^^ Confirmed number of data bytes to be read, which may be less than | ||||
|     // requested. 0 indicates that no data can be read. This is actually be the | ||||
|     // number of bytes that will be remaining after the read | ||||
| @@ -568,7 +568,7 @@ class TinyGsmSim800 | ||||
|   bool modemGetConnected(uint8_t mux) { | ||||
|     sendAT(GF("+CIPSTATUS="), mux); | ||||
|     waitResponse(GF("+CIPSTATUS")); | ||||
|     int res = waitResponse(GF(",\"CONNECTED\""), GF(",\"CLOSED\""), | ||||
|     int8_t res = waitResponse(GF(",\"CONNECTED\""), GF(",\"CLOSED\""), | ||||
|                               GF(",\"CLOSING\""), GF(",\"REMOTE CLOSING\""), | ||||
|                               GF(",\"INITIAL\"")); | ||||
|     waitResponse(); | ||||
| @@ -580,7 +580,7 @@ class TinyGsmSim800 | ||||
|    */ | ||||
|  public: | ||||
|   // TODO(vshymanskyy): Optimize this! | ||||
|   uint8_t waitResponse(uint32_t timeout_ms, String& data, | ||||
|   int8_t waitResponse(uint32_t timeout_ms, String& data, | ||||
|                       GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), | ||||
|                       GsmConstStr r3 = GFP(GSM_CME_ERROR), | ||||
| @@ -598,7 +598,7 @@ class TinyGsmSim800 | ||||
|       TINY_GSM_YIELD(); | ||||
|       while (stream.available() > 0) { | ||||
|         TINY_GSM_YIELD(); | ||||
|         int a = stream.read(); | ||||
|         int8_t a = stream.read(); | ||||
|         if (a <= 0) continue;  // Skip 0x00 bytes, just in case | ||||
|         data += static_cast<char>(a); | ||||
|         if (r1 && data.endsWith(r1)) { | ||||
| @@ -620,9 +620,9 @@ class TinyGsmSim800 | ||||
|           index = 5; | ||||
|           goto finish; | ||||
|         } else if (data.endsWith(GF(GSM_NL "+CIPRXGET:"))) { | ||||
|           int mode = streamGetInt(','); | ||||
|           int8_t mode = streamGetInt(','); | ||||
|           if (mode == 1) { | ||||
|             int mux = streamGetInt('\n'); | ||||
|             int8_t mux = streamGetInt('\n'); | ||||
|             if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { | ||||
|               sockets[mux]->got_data = true; | ||||
|             } | ||||
| @@ -632,8 +632,8 @@ class TinyGsmSim800 | ||||
|             data += mode; | ||||
|           } | ||||
|         } else if (data.endsWith(GF(GSM_NL "+RECEIVE:"))) { | ||||
|           int mux = streamGetInt(','); | ||||
|           int len = streamGetInt('\n'); | ||||
|           int8_t  mux = streamGetInt(','); | ||||
|           int16_t len = streamGetInt('\n'); | ||||
|           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { | ||||
|             sockets[mux]->got_data       = true; | ||||
|             sockets[mux]->sock_available = len; | ||||
| @@ -641,9 +641,9 @@ class TinyGsmSim800 | ||||
|           data = ""; | ||||
|           DBG("### Got Data:", len, "on", mux); | ||||
|         } else if (data.endsWith(GF("CLOSED" GSM_NL))) { | ||||
|           int nl   = data.lastIndexOf(GSM_NL, data.length() - 8); | ||||
|           int coma = data.indexOf(',', nl + 2); | ||||
|           int mux  = data.substring(nl + 2, coma).toInt(); | ||||
|           int8_t nl   = data.lastIndexOf(GSM_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]) { | ||||
|             sockets[mux]->sock_connected = false; | ||||
|           } | ||||
| @@ -663,7 +663,7 @@ class TinyGsmSim800 | ||||
|     return index; | ||||
|   } | ||||
|  | ||||
|   uint8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), | ||||
|   int8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), | ||||
|                       GsmConstStr r3 = GFP(GSM_CME_ERROR), | ||||
|                       GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { | ||||
| @@ -671,7 +671,7 @@ class TinyGsmSim800 | ||||
|     return waitResponse(timeout_ms, data, r1, r2, r3, r4, r5); | ||||
|   } | ||||
|  | ||||
|   uint8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), | ||||
|   int8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), | ||||
|                       GsmConstStr r3 = GFP(GSM_CME_ERROR), | ||||
|                       GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { | ||||
|   | ||||
| @@ -244,7 +244,7 @@ class TinyGsmSaraR4 | ||||
|     sendAT(GF("+CTZU=1")); | ||||
|     if (waitResponse(10000L) != 1) { return false; } | ||||
|  | ||||
|     int ret = getSimStatus(); | ||||
|     SimStatus ret = getSimStatus(); | ||||
|     // if the sim isn't ready and a pin has been provided, try to unlock the sim | ||||
|     if (ret != SIM_READY && pin != NULL && strlen(pin) > 0) { | ||||
|       simUnlock(pin); | ||||
| @@ -477,7 +477,7 @@ class TinyGsmSaraR4 | ||||
|     return getUbloxLocationRaw(1); | ||||
|   } | ||||
|  | ||||
|   bool inline getUbloxLocation(int8_t sensor, float* lat, float* lon, | ||||
|   inline bool getUbloxLocation(int8_t sensor, float* lat, float* lon, | ||||
|                                float* speed = 0, int* alt = 0, int* vsat = 0, | ||||
|                                int* usat = 0, float* accuracy = 0, | ||||
|                                int* year = 0, int* month = 0, int* day = 0, | ||||
| @@ -594,7 +594,7 @@ class TinyGsmSaraR4 | ||||
|     sendAT(GF("+CIND?")); | ||||
|     if (waitResponse(GF(GSM_NL "+CIND:")) != 1) { return 0; } | ||||
|  | ||||
|     int    res     = streamGetInt(','); | ||||
|     int8_t res     = streamGetInt(','); | ||||
|     int8_t percent = res * 20;  // return is 0-5 | ||||
|     // Wait for final OK | ||||
|     waitResponse(); | ||||
| @@ -677,7 +677,7 @@ class TinyGsmSaraR4 | ||||
|       if (waitResponse(timeout_ms - (millis() - startMillis), | ||||
|                        GF(GSM_NL "+UUSOCO:")) == 1) { | ||||
|         streamGetInt(',');  // skip repeated mux | ||||
|         int connection_status = streamGetInt('\n'); | ||||
|         int8_t connection_status = streamGetInt('\n'); | ||||
|         DBG("### Waited", millis() - startMillis, "ms for socket to open"); | ||||
|         return (0 == connection_status); | ||||
|       } else { | ||||
| @@ -688,7 +688,7 @@ class TinyGsmSaraR4 | ||||
|     } else { | ||||
|       // use synchronous open | ||||
|       sendAT(GF("+USOCO="), *mux, ",\"", host, "\",", port); | ||||
|       int rsp = waitResponse(timeout_ms - (millis() - startMillis)); | ||||
|       int8_t rsp = waitResponse(timeout_ms - (millis() - startMillis)); | ||||
|       return (1 == rsp); | ||||
|     } | ||||
|   } | ||||
| @@ -702,7 +702,7 @@ class TinyGsmSaraR4 | ||||
|     stream.flush(); | ||||
|     if (waitResponse(GF(GSM_NL "+USOWR:")) != 1) { return 0; } | ||||
|     streamSkipUntil(',');  // Skip mux | ||||
|     int sent = streamGetInt('\n'); | ||||
|     int16_t sent = streamGetInt('\n'); | ||||
|     waitResponse();  // sends back OK after the confirmation of number sent | ||||
|     return sent; | ||||
|   } | ||||
| @@ -711,7 +711,7 @@ class TinyGsmSaraR4 | ||||
|     sendAT(GF("+USORD="), mux, ',', (uint16_t)size); | ||||
|     if (waitResponse(GF(GSM_NL "+USORD:")) != 1) { return 0; } | ||||
|     streamSkipUntil(',');  // Skip mux | ||||
|     int len = streamGetInt(','); | ||||
|     int16_t len = streamGetInt(','); | ||||
|     streamSkipUntil('\"'); | ||||
|  | ||||
|     for (int i = 0; i < len; i++) { moveCharFromStreamToFifo(mux); } | ||||
| @@ -748,7 +748,7 @@ class TinyGsmSaraR4 | ||||
|  | ||||
|     streamSkipUntil(',');  // Skip mux | ||||
|     streamSkipUntil(',');  // Skip type | ||||
|     int result = streamGetInt('\n'); | ||||
|     int8_t result = streamGetInt('\n'); | ||||
|     // 0: the socket is in INACTIVE status (it corresponds to CLOSED status | ||||
|     // defined in RFC793 "TCP Protocol Specification" [112]) | ||||
|     // 1: the socket is in LISTEN status | ||||
| @@ -770,7 +770,7 @@ class TinyGsmSaraR4 | ||||
|    */ | ||||
|  public: | ||||
|   // TODO(vshymanskyy): Optimize this! | ||||
|   uint8_t waitResponse(uint32_t timeout_ms, String& data, | ||||
|   int8_t waitResponse(uint32_t timeout_ms, String& data, | ||||
|                       GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), | ||||
|                       GsmConstStr r3 = GFP(GSM_CME_ERROR), | ||||
| @@ -788,7 +788,7 @@ class TinyGsmSaraR4 | ||||
|       TINY_GSM_YIELD(); | ||||
|       while (stream.available() > 0) { | ||||
|         TINY_GSM_YIELD(); | ||||
|         int a = stream.read(); | ||||
|         int8_t a = stream.read(); | ||||
|         if (a <= 0) continue;  // Skip 0x00 bytes, just in case | ||||
|         data += static_cast<char>(a); | ||||
|         if (r1 && data.endsWith(r1)) { | ||||
| @@ -810,8 +810,8 @@ class TinyGsmSaraR4 | ||||
|           index = 5; | ||||
|           goto finish; | ||||
|         } else if (data.endsWith(GF("+UUSORD:"))) { | ||||
|           int mux = streamGetInt(','); | ||||
|           int len = streamGetInt('\n'); | ||||
|           int8_t  mux = streamGetInt(','); | ||||
|           int16_t len = streamGetInt('\n'); | ||||
|           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { | ||||
|             sockets[mux]->got_data       = true; | ||||
|             sockets[mux]->sock_available = len; | ||||
| @@ -819,15 +819,15 @@ class TinyGsmSaraR4 | ||||
|           data = ""; | ||||
|           DBG("### URC Data Received:", len, "on", mux); | ||||
|         } else if (data.endsWith(GF("+UUSOCL:"))) { | ||||
|           int mux = streamGetInt('\n'); | ||||
|           int8_t mux = streamGetInt('\n'); | ||||
|           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { | ||||
|             sockets[mux]->sock_connected = false; | ||||
|           } | ||||
|           data = ""; | ||||
|           DBG("### URC Sock Closed: ", mux); | ||||
|         } else if (data.endsWith(GF("+UUSOCO:"))) { | ||||
|           int mux          = streamGetInt('\n'); | ||||
|           int socket_error = streamGetInt('\n'); | ||||
|           int8_t mux          = streamGetInt('\n'); | ||||
|           int8_t socket_error = streamGetInt('\n'); | ||||
|           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux] && | ||||
|               socket_error == 0) { | ||||
|             sockets[mux]->sock_connected = true; | ||||
| @@ -848,7 +848,7 @@ class TinyGsmSaraR4 | ||||
|     return index; | ||||
|   } | ||||
|  | ||||
|   uint8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), | ||||
|   int8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), | ||||
|                       GsmConstStr r3 = GFP(GSM_CME_ERROR), | ||||
|                       GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { | ||||
| @@ -856,7 +856,7 @@ class TinyGsmSaraR4 | ||||
|     return waitResponse(timeout_ms, data, r1, r2, r3, r4, r5); | ||||
|   } | ||||
|  | ||||
|   uint8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), | ||||
|   int8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), | ||||
|                       GsmConstStr r3 = GFP(GSM_CME_ERROR), | ||||
|                       GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { | ||||
|   | ||||
| @@ -214,7 +214,7 @@ class TinyGsmSequansMonarch | ||||
|     sendAT(GF("+CTZU=1")); | ||||
|     if (waitResponse(10000L) != 1) { return false; } | ||||
|  | ||||
|     int ret = getSimStatus(); | ||||
|     SimStatus ret = getSimStatus(); | ||||
|     // if the sim isn't ready and a pin has been provided, try to unlock the sim | ||||
|     if (ret != SIM_READY && pin != NULL && strlen(pin) > 0) { | ||||
|       simUnlock(pin); | ||||
| @@ -247,7 +247,7 @@ class TinyGsmSequansMonarch | ||||
|     if (!testAT()) { return false; } | ||||
|  | ||||
|     sendAT(GF("+CFUN=0")); | ||||
|     int res = waitResponse(20000L, GFP(GSM_OK), GFP(GSM_ERROR), | ||||
|     int8_t res = waitResponse(20000L, GFP(GSM_OK), GFP(GSM_ERROR), | ||||
|                               GF("+SYSSTART")); | ||||
|     if (res != 1 && res != 3) { return false; } | ||||
|  | ||||
| @@ -384,7 +384,7 @@ class TinyGsmSequansMonarch | ||||
|  protected: | ||||
|   bool modemConnect(const char* host, uint16_t port, uint8_t mux, | ||||
|                     bool ssl = false, int timeout_s = 75) { | ||||
|     int      rsp; | ||||
|     int8_t   rsp; | ||||
|     uint32_t startMillis = millis(); | ||||
|     uint32_t timeout_ms  = ((uint32_t)timeout_s) * 1000; | ||||
|  | ||||
| @@ -496,7 +496,7 @@ class TinyGsmSequansMonarch | ||||
|     sendAT(GF("+SQNSRECV="), mux, ',', (uint16_t)size); | ||||
|     if (waitResponse(GF("+SQNSRECV: ")) != 1) { return 0; } | ||||
|     streamSkipUntil(',');  // Skip mux | ||||
|     int len = streamGetInt('\n'); | ||||
|     int16_t len = streamGetInt('\n'); | ||||
|     for (int i = 0; i < len; i++) { | ||||
|       uint32_t startMillis = millis(); | ||||
|       while (!stream.available() && | ||||
| @@ -562,7 +562,7 @@ class TinyGsmSequansMonarch | ||||
|    */ | ||||
|  public: | ||||
|   // TODO(vshymanskyy): Optimize this! | ||||
|   uint8_t waitResponse(uint32_t timeout_ms, String& data, | ||||
|   int8_t waitResponse(uint32_t timeout_ms, String& data, | ||||
|                       GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), | ||||
|                       GsmConstStr r3 = GFP(GSM_CME_ERROR), | ||||
| @@ -580,7 +580,7 @@ class TinyGsmSequansMonarch | ||||
|       TINY_GSM_YIELD(); | ||||
|       while (stream.available() > 0) { | ||||
|         TINY_GSM_YIELD(); | ||||
|         int a = stream.read(); | ||||
|         int8_t a = stream.read(); | ||||
|         if (a <= 0) continue;  // Skip 0x00 bytes, just in case | ||||
|         data += static_cast<char>(a); | ||||
|         if (r1 && data.endsWith(r1)) { | ||||
| @@ -602,8 +602,8 @@ class TinyGsmSequansMonarch | ||||
|           index = 5; | ||||
|           goto finish; | ||||
|         } else if (data.endsWith(GF(GSM_NL "+SQNSRING:"))) { | ||||
|           int mux = streamGetInt(','); | ||||
|           int len = streamGetInt('\n'); | ||||
|           int8_t  mux = streamGetInt(','); | ||||
|           int16_t len = streamGetInt('\n'); | ||||
|           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && | ||||
|               sockets[mux % TINY_GSM_MUX_COUNT]) { | ||||
|             sockets[mux % TINY_GSM_MUX_COUNT]->got_data       = true; | ||||
| @@ -612,7 +612,7 @@ class TinyGsmSequansMonarch | ||||
|           data = ""; | ||||
|           DBG("### URC Data Received:", len, "on", mux); | ||||
|         } else if (data.endsWith(GF("SQNSH: "))) { | ||||
|           int mux = streamGetInt('\n'); | ||||
|           int8_t mux = streamGetInt('\n'); | ||||
|           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && | ||||
|               sockets[mux % TINY_GSM_MUX_COUNT]) { | ||||
|             sockets[mux % TINY_GSM_MUX_COUNT]->sock_connected = false; | ||||
| @@ -633,7 +633,7 @@ class TinyGsmSequansMonarch | ||||
|     return index; | ||||
|   } | ||||
|  | ||||
|   uint8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), | ||||
|   int8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), | ||||
|                       GsmConstStr r3 = GFP(GSM_CME_ERROR), | ||||
|                       GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { | ||||
| @@ -641,7 +641,7 @@ class TinyGsmSequansMonarch | ||||
|     return waitResponse(timeout_ms, data, r1, r2, r3, r4, r5); | ||||
|   } | ||||
|  | ||||
|   uint8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), | ||||
|   int8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), | ||||
|                       GsmConstStr r3 = GFP(GSM_CME_ERROR), | ||||
|                       GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { | ||||
|   | ||||
| @@ -188,7 +188,7 @@ class TinyGsmUBLOX | ||||
|     sendAT(GF("+CTZU=1")); | ||||
|     if (waitResponse(10000L) != 1) { return false; } | ||||
|  | ||||
|     int ret = getSimStatus(); | ||||
|     SimStatus ret = getSimStatus(); | ||||
|     // if the sim isn't ready and a pin has been provided, try to unlock the sim | ||||
|     if (ret != SIM_READY && pin != NULL && strlen(pin) > 0) { | ||||
|       simUnlock(pin); | ||||
| @@ -338,7 +338,7 @@ class TinyGsmUBLOX | ||||
|     // param_tag = 8: PSD profile status: if the profile is active the return | ||||
|     // value is 1, 0 otherwise | ||||
|     sendAT(GF("+UPSND=0,8"));  // Check if PSD profile 0 is now active | ||||
|     int res = waitResponse(GF(",8,1"), GF(",8,0")); | ||||
|     int8_t res = waitResponse(GF(",8,1"), GF(",8,0")); | ||||
|     waitResponse();  // Should return another OK | ||||
|     if (res == 1) { | ||||
|       return true;          // It's now active | ||||
| @@ -444,7 +444,7 @@ class TinyGsmUBLOX | ||||
|     return getUbloxLocationRaw(1); | ||||
|   } | ||||
|  | ||||
|   bool inline getUbloxLocation(int8_t sensor, float* lat, float* lon, | ||||
|   inline bool getUbloxLocation(int8_t sensor, float* lat, float* lon, | ||||
|                                float* speed = 0, int* alt = 0, int* vsat = 0, | ||||
|                                int* usat = 0, float* accuracy = 0, | ||||
|                                int* year = 0, int* month = 0, int* day = 0, | ||||
| @@ -561,7 +561,7 @@ class TinyGsmUBLOX | ||||
|     sendAT(GF("+CIND?")); | ||||
|     if (waitResponse(GF(GSM_NL "+CIND:")) != 1) { return 0; } | ||||
|  | ||||
|     int    res     = streamGetInt(','); | ||||
|     int8_t res     = streamGetInt(','); | ||||
|     int8_t percent = res * 20;  // return is 0-5 | ||||
|     // Wait for final OK | ||||
|     waitResponse(); | ||||
| @@ -621,7 +621,7 @@ class TinyGsmUBLOX | ||||
|  | ||||
|     // connect on the allocated socket | ||||
|     sendAT(GF("+USOCO="), *mux, ",\"", host, "\",", port); | ||||
|     int rsp = waitResponse(timeout_ms - (millis() - startMillis)); | ||||
|     int8_t rsp = waitResponse(timeout_ms - (millis() - startMillis)); | ||||
|     return (1 == rsp); | ||||
|   } | ||||
|  | ||||
| @@ -634,7 +634,7 @@ class TinyGsmUBLOX | ||||
|     stream.flush(); | ||||
|     if (waitResponse(GF(GSM_NL "+USOWR:")) != 1) { return 0; } | ||||
|     streamSkipUntil(',');  // Skip mux | ||||
|     int sent = streamGetInt('\n'); | ||||
|     int16_t sent = streamGetInt('\n'); | ||||
|     waitResponse();  // sends back OK after the confirmation of number sent | ||||
|     return sent; | ||||
|   } | ||||
| @@ -643,7 +643,7 @@ class TinyGsmUBLOX | ||||
|     sendAT(GF("+USORD="), mux, ',', (uint16_t)size); | ||||
|     if (waitResponse(GF(GSM_NL "+USORD:")) != 1) { return 0; } | ||||
|     streamSkipUntil(',');  // Skip mux | ||||
|     int len = streamGetInt(','); | ||||
|     int16_t len = streamGetInt(','); | ||||
|     streamSkipUntil('\"'); | ||||
|  | ||||
|     for (int i = 0; i < len; i++) { moveCharFromStreamToFifo(mux); } | ||||
| @@ -680,7 +680,7 @@ class TinyGsmUBLOX | ||||
|  | ||||
|     streamSkipUntil(',');  // Skip mux | ||||
|     streamSkipUntil(',');  // Skip type | ||||
|     int result = streamGetInt('\n'); | ||||
|     int8_t result = streamGetInt('\n'); | ||||
|     // 0: the socket is in INACTIVE status (it corresponds to CLOSED status | ||||
|     // defined in RFC793 "TCP Protocol Specification" [112]) | ||||
|     // 1: the socket is in LISTEN status | ||||
| @@ -702,7 +702,7 @@ class TinyGsmUBLOX | ||||
|    */ | ||||
|  public: | ||||
|   // TODO(vshymanskyy): Optimize this! | ||||
|   uint8_t waitResponse(uint32_t timeout_ms, String& data, | ||||
|   int8_t waitResponse(uint32_t timeout_ms, String& data, | ||||
|                       GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), | ||||
|                       GsmConstStr r3 = GFP(GSM_CME_ERROR), | ||||
| @@ -720,7 +720,7 @@ class TinyGsmUBLOX | ||||
|       TINY_GSM_YIELD(); | ||||
|       while (stream.available() > 0) { | ||||
|         TINY_GSM_YIELD(); | ||||
|         int a = stream.read(); | ||||
|         int8_t a = stream.read(); | ||||
|         if (a <= 0) continue;  // Skip 0x00 bytes, just in case | ||||
|         data += static_cast<char>(a); | ||||
|         if (r1 && data.endsWith(r1)) { | ||||
| @@ -742,8 +742,8 @@ class TinyGsmUBLOX | ||||
|           index = 5; | ||||
|           goto finish; | ||||
|         } else if (data.endsWith(GF("+UUSORD:"))) { | ||||
|           int mux = streamGetInt(','); | ||||
|           int len = streamGetInt('\n'); | ||||
|           int8_t  mux = streamGetInt(','); | ||||
|           int16_t len = streamGetInt('\n'); | ||||
|           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { | ||||
|             sockets[mux]->got_data       = true; | ||||
|             sockets[mux]->sock_available = len; | ||||
| @@ -751,7 +751,7 @@ class TinyGsmUBLOX | ||||
|           data = ""; | ||||
|           DBG("### URC Data Received:", len, "on", mux); | ||||
|         } else if (data.endsWith(GF("+UUSOCL:"))) { | ||||
|           int mux = streamGetInt('\n'); | ||||
|           int8_t mux = streamGetInt('\n'); | ||||
|           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { | ||||
|             sockets[mux]->sock_connected = false; | ||||
|           } | ||||
| @@ -771,7 +771,7 @@ class TinyGsmUBLOX | ||||
|     return index; | ||||
|   } | ||||
|  | ||||
|   uint8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), | ||||
|   int8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), | ||||
|                       GsmConstStr r3 = GFP(GSM_CME_ERROR), | ||||
|                       GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { | ||||
| @@ -779,7 +779,7 @@ class TinyGsmUBLOX | ||||
|     return waitResponse(timeout_ms, data, r1, r2, r3, r4, r5); | ||||
|   } | ||||
|  | ||||
|   uint8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), | ||||
|   int8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), | ||||
|                       GsmConstStr r3 = GFP(GSM_CME_ERROR), | ||||
|                       GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { | ||||
|   | ||||
| @@ -665,7 +665,7 @@ class TinyGsmXBee | ||||
|   } | ||||
|  | ||||
|  protected: | ||||
|   int16_t getSignalQualityImpl() { | ||||
|   int8_t getSignalQualityImpl() { | ||||
|     XBEE_COMMAND_START_DECORATOR(5, 0); | ||||
|  | ||||
|     if (beeType == XBEE_UNKNOWN) | ||||
| @@ -1270,7 +1270,7 @@ class TinyGsmXBee | ||||
|   // NOTE:  This function is used while INSIDE command mode, so we're only | ||||
|   // waiting for requested responses.  The XBee has no unsoliliced responses | ||||
|   // (URC's) when in command mode. | ||||
|   uint8_t waitResponse(uint32_t timeout_ms, String& data, | ||||
|   int8_t waitResponse(uint32_t timeout_ms, String& data, | ||||
|                       GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), GsmConstStr r3 = NULL, | ||||
|                       GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { | ||||
| @@ -1287,7 +1287,7 @@ class TinyGsmXBee | ||||
|       TINY_GSM_YIELD(); | ||||
|       while (stream.available() > 0) { | ||||
|         TINY_GSM_YIELD(); | ||||
|         int a = stream.read(); | ||||
|         int8_t a = stream.read(); | ||||
|         if (a <= 0) continue;  // Skip 0x00 bytes, just in case | ||||
|         data += static_cast<char>(a); | ||||
|         if (r1 && data.endsWith(r1)) { | ||||
| @@ -1328,14 +1328,14 @@ class TinyGsmXBee | ||||
|     return index; | ||||
|   } | ||||
|  | ||||
|   uint8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), | ||||
|   int8_t waitResponse(uint32_t timeout_ms, GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), GsmConstStr r3 = NULL, | ||||
|                       GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { | ||||
|     String data; | ||||
|     return waitResponse(timeout_ms, data, r1, r2, r3, r4, r5); | ||||
|   } | ||||
|  | ||||
|   uint8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), | ||||
|   int8_t waitResponse(GsmConstStr r1 = GFP(GSM_OK), | ||||
|                       GsmConstStr r2 = GFP(GSM_ERROR), GsmConstStr r3 = NULL, | ||||
|                       GsmConstStr r4 = NULL, GsmConstStr r5 = NULL) { | ||||
|     return waitResponse(1000, r1, r2, r3, r4, r5); | ||||
| @@ -1356,7 +1356,7 @@ class TinyGsmXBee | ||||
|       // Default guard time is 1s, but the init fxn decreases it to 100 ms | ||||
|       delay(guardTime + 10); | ||||
|       streamWrite(GF("+++"));  // enter command mode | ||||
|       int res = waitResponse(guardTime * 2); | ||||
|       int8_t res = waitResponse(guardTime * 2); | ||||
|       success    = (1 == res); | ||||
|       if (0 == res) { | ||||
|         triesUntilReset--; | ||||
|   | ||||
| @@ -128,9 +128,9 @@ class TinyGsmGPRS { | ||||
|         delay(1000); | ||||
|         continue; | ||||
|       } | ||||
|       int status = thisModem().waitResponse(GF("READY"), GF("SIM PIN"), | ||||
|                                             GF("SIM PUK"), GF("NOT INSERTED"), | ||||
|                                             GF("NOT READY")); | ||||
|       int8_t status = | ||||
|           thisModem().waitResponse(GF("READY"), GF("SIM PIN"), GF("SIM PUK"), | ||||
|                                    GF("NOT INSERTED"), GF("NOT READY")); | ||||
|       thisModem().waitResponse(); | ||||
|       switch (status) { | ||||
|         case 2: | ||||
| @@ -153,7 +153,7 @@ class TinyGsmGPRS { | ||||
|   bool isGprsConnectedImpl() { | ||||
|     thisModem().sendAT(GF("+CGATT?")); | ||||
|     if (thisModem().waitResponse(GF("+CGATT:")) != 1) { return false; } | ||||
|     int res = thisModem().streamGetInt('\n'); | ||||
|     int8_t res = thisModem().streamGetInt('\n'); | ||||
|     thisModem().waitResponse(); | ||||
|     if (res != 1) { return false; } | ||||
|  | ||||
|   | ||||
| @@ -24,7 +24,7 @@ class TinyGsmModem { | ||||
|     return thisModem().initImpl(pin); | ||||
|   } | ||||
|   template <typename... Args> | ||||
|   void sendAT(Args... cmd) { | ||||
|   inline void sendAT(Args... cmd) { | ||||
|     thisModem().streamWrite("AT", cmd..., thisModem().gsmNL); | ||||
|     thisModem().stream.flush(); | ||||
|     TINY_GSM_YIELD(); /* DBG("### AT:", cmd...); */ | ||||
| @@ -180,10 +180,10 @@ class TinyGsmModem { | ||||
|   // CREG = Generic network registration | ||||
|   // CGREG = GPRS service registration | ||||
|   // CEREG = EPS registration for LTE modules | ||||
|   int getRegistrationStatusXREG(const char* regCommand) { | ||||
|   int8_t getRegistrationStatusXREG(const char* regCommand) { | ||||
|     thisModem().sendAT('+', regCommand, '?'); | ||||
|     // check for any of the three for simplicity | ||||
|     int resp = thisModem().waitResponse(GF("+CREG:"), GF("+CGREG:"), | ||||
|     int8_t resp = thisModem().waitResponse(GF("+CREG:"), GF("+CGREG:"), | ||||
|                                            GF("+CEREG:")); | ||||
|     if (resp != 1 && resp != 2 && resp != 3) { return -1; } | ||||
|     thisModem().streamSkipUntil(','); /* Skip format (0) */ | ||||
| @@ -201,10 +201,10 @@ class TinyGsmModem { | ||||
|   } | ||||
|  | ||||
|   // Gets signal quality report according to 3GPP TS command AT+CSQ | ||||
|   int16_t getSignalQualityImpl() { | ||||
|   int8_t getSignalQualityImpl() { | ||||
|     thisModem().sendAT(GF("+CSQ")); | ||||
|     if (thisModem().waitResponse(GF("+CSQ:")) != 1) { return 99; } | ||||
|     int res = thisModem().streamGetInt(','); | ||||
|     int8_t res = thisModem().streamGetInt(','); | ||||
|     thisModem().waitResponse(); | ||||
|     return res; | ||||
|   } | ||||
| @@ -218,7 +218,7 @@ class TinyGsmModem { | ||||
|     return res; | ||||
|   } | ||||
|  | ||||
|   static IPAddress TinyGsmIpFromString(const String& strIP) { | ||||
|   static inline IPAddress TinyGsmIpFromString(const String& strIP) { | ||||
|     int Parts[4] = { | ||||
|         0, | ||||
|     }; | ||||
| @@ -245,17 +245,17 @@ class TinyGsmModem { | ||||
|  protected: | ||||
|   // Utility templates for writing/skipping characters on a stream | ||||
|   template <typename T> | ||||
|   void inline streamWrite(T last) { | ||||
|   inline void streamWrite(T last) { | ||||
|     thisModem().stream.print(last); | ||||
|   } | ||||
|  | ||||
|   template <typename T, typename... Args> | ||||
|   void inline streamWrite(T head, Args... tail) { | ||||
|   inline void streamWrite(T head, Args... tail) { | ||||
|     thisModem().stream.print(head); | ||||
|     thisModem().streamWrite(tail...); | ||||
|   } | ||||
|  | ||||
|   int16_t inline streamGetInt(int8_t numChars) { | ||||
|   inline int16_t streamGetInt(int8_t numChars) { | ||||
|     char   buf[6]; | ||||
|     size_t bytesRead = thisModem().stream.readBytes(buf, numChars); | ||||
|     if (bytesRead) { | ||||
| @@ -269,7 +269,7 @@ class TinyGsmModem { | ||||
|  | ||||
|   template <class T> | ||||
|   // calling with template only to prevent promotion of char to int | ||||
|   int16_t inline streamGetInt(T lastChar) { | ||||
|   inline int16_t streamGetInt(T lastChar) { | ||||
|     char   buf[6]; | ||||
|     size_t bytesRead = thisModem().stream.readBytesUntil( | ||||
|         lastChar, buf, static_cast<size_t>(6)); | ||||
| @@ -282,7 +282,7 @@ class TinyGsmModem { | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   float inline streamGetFloat(int8_t numChars) { | ||||
|   inline float streamGetFloat(int8_t numChars) { | ||||
|     char   buf[16]; | ||||
|     size_t bytesRead = thisModem().stream.readBytes(buf, numChars); | ||||
|     DBG("### bytesRead:", bytesRead); | ||||
| @@ -297,7 +297,7 @@ class TinyGsmModem { | ||||
|  | ||||
|   template <class T> | ||||
|   // calling with template only to prevent promotion of char to int | ||||
|   float inline streamGetFloat(T lastChar) { | ||||
|   inline float streamGetFloat(T lastChar) { | ||||
|     char   buf[16]; | ||||
|     size_t bytesRead = thisModem().stream.readBytesUntil( | ||||
|         lastChar, buf, static_cast<size_t>(16)); | ||||
| @@ -310,7 +310,7 @@ class TinyGsmModem { | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   bool inline streamSkipUntil(const char c, const uint32_t timeout_ms = 1000L) { | ||||
|   inline bool streamSkipUntil(const char c, const uint32_t timeout_ms = 1000L) { | ||||
|     uint32_t startMillis = millis(); | ||||
|     while (millis() - startMillis < timeout_ms) { | ||||
|       while (millis() - startMillis < timeout_ms && | ||||
| @@ -322,7 +322,7 @@ class TinyGsmModem { | ||||
|     return false; | ||||
|   } | ||||
|  | ||||
|   void inline streamClear() { | ||||
|   inline void streamClear() { | ||||
|     while (thisModem().stream.available()) { | ||||
|       thisModem().waitResponse(50, NULL, NULL); | ||||
|     } | ||||
|   | ||||
| @@ -47,7 +47,7 @@ class TinyGsmSMS { | ||||
|   static inline String TinyGsmDecodeHex7bit(String& instr) { | ||||
|     String result; | ||||
|     byte   reminder = 0; | ||||
|     int    bitstate = 7; | ||||
|     int8_t bitstate = 7; | ||||
|     for (uint8_t i = 0; i < instr.length(); i += 2) { | ||||
|       char buf[4] = { | ||||
|           0, | ||||
| @@ -125,7 +125,7 @@ class TinyGsmSMS { | ||||
|     thisModem().stream.readStringUntil('"'); | ||||
|     String hex = thisModem().stream.readStringUntil('"'); | ||||
|     thisModem().stream.readStringUntil(','); | ||||
|     int dcs = thisModem().streamGetInt('\n'); | ||||
|     int8_t dcs = thisModem().streamGetInt('\n'); | ||||
|  | ||||
|     if (dcs == 15) { | ||||
|       return TinyGsmDecodeHex8bit(hex); | ||||
|   | ||||
| @@ -263,7 +263,7 @@ class TinyGsmTCP { | ||||
|     // closes until all data is read from the buffer. | ||||
|     // Doing it this way allows the external mcu to find and get all of the | ||||
|     // data that it wants from the socket even if it was closed externally. | ||||
|     void inline dumpModemBuffer(uint32_t maxWaitMs) { | ||||
|     inline void dumpModemBuffer(uint32_t maxWaitMs) { | ||||
|       TINY_GSM_YIELD(); | ||||
|       rx.clear(); | ||||
|       at->maintain(); | ||||
| @@ -317,7 +317,7 @@ class TinyGsmTCP { | ||||
|   // character return?  Will wait once in the first "while | ||||
|   // !stream.available()" and then will wait again in the stream.read() | ||||
|   // function. | ||||
|   void inline moveCharFromStreamToFifo(uint8_t mux) { | ||||
|   inline void moveCharFromStreamToFifo(uint8_t mux) { | ||||
|     uint32_t startMillis = millis(); | ||||
|     while (!thisModem().stream.available() && | ||||
|            (millis() - startMillis < thisModem().sockets[mux]->_timeout)) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user