mirror of
				https://github.com/KevinMidboe/TinyGSM.git
				synced 2025-10-29 18:00:18 +00:00 
			
		
		
		
	Rename so *I* don't screw them up
Signed-off-by: Sara Damiano <sdamiano@stroudcenter.org>
This commit is contained in:
		| @@ -55,7 +55,7 @@ class TinyGsmBattery { | |||||||
|     thisModem().streamSkipUntil(',');  // Skip battery charge status |     thisModem().streamSkipUntil(',');  // Skip battery charge status | ||||||
|     thisModem().streamSkipUntil(',');  // Skip battery charge level |     thisModem().streamSkipUntil(',');  // Skip battery charge level | ||||||
|     // return voltage in mV |     // return voltage in mV | ||||||
|     uint16_t res = thisModem().streamGetInt(','); |     uint16_t res = thisModem().streamGetIntBefore(','); | ||||||
|     // Wait for final OK |     // Wait for final OK | ||||||
|     thisModem().waitResponse(); |     thisModem().waitResponse(); | ||||||
|     return res; |     return res; | ||||||
| @@ -66,7 +66,7 @@ class TinyGsmBattery { | |||||||
|     if (thisModem().waitResponse(GF("+CBC:")) != 1) { return false; } |     if (thisModem().waitResponse(GF("+CBC:")) != 1) { return false; } | ||||||
|     thisModem().streamSkipUntil(',');  // Skip battery charge status |     thisModem().streamSkipUntil(',');  // Skip battery charge status | ||||||
|     // Read battery charge level |     // Read battery charge level | ||||||
|     int8_t res = thisModem().streamGetInt(','); |     int8_t res = thisModem().streamGetIntBefore(','); | ||||||
|     // Wait for final OK |     // Wait for final OK | ||||||
|     thisModem().waitResponse(); |     thisModem().waitResponse(); | ||||||
|     return res; |     return res; | ||||||
| @@ -76,7 +76,7 @@ class TinyGsmBattery { | |||||||
|     thisModem().sendAT(GF("+CBC")); |     thisModem().sendAT(GF("+CBC")); | ||||||
|     if (thisModem().waitResponse(GF("+CBC:")) != 1) { return false; } |     if (thisModem().waitResponse(GF("+CBC:")) != 1) { return false; } | ||||||
|     // Read battery charge status |     // Read battery charge status | ||||||
|     int8_t res = thisModem().streamGetInt(','); |     int8_t res = thisModem().streamGetIntBefore(','); | ||||||
|     // Wait for final OK |     // Wait for final OK | ||||||
|     thisModem().waitResponse(); |     thisModem().waitResponse(); | ||||||
|     return res; |     return res; | ||||||
| @@ -86,9 +86,9 @@ class TinyGsmBattery { | |||||||
|                         uint16_t& milliVolts) { |                         uint16_t& milliVolts) { | ||||||
|     thisModem().sendAT(GF("+CBC")); |     thisModem().sendAT(GF("+CBC")); | ||||||
|     if (thisModem().waitResponse(GF("+CBC:")) != 1) { return false; } |     if (thisModem().waitResponse(GF("+CBC:")) != 1) { return false; } | ||||||
|     chargeState = thisModem().streamGetInt(','); |     chargeState = thisModem().streamGetIntBefore(','); | ||||||
|     percent     = thisModem().streamGetInt(','); |     percent     = thisModem().streamGetIntBefore(','); | ||||||
|     milliVolts  = thisModem().streamGetInt('\n'); |     milliVolts  = thisModem().streamGetIntBefore('\n'); | ||||||
|     // Wait for final OK |     // Wait for final OK | ||||||
|     thisModem().waitResponse(); |     thisModem().waitResponse(); | ||||||
|     return true; |     return true; | ||||||
|   | |||||||
| @@ -359,7 +359,7 @@ class TinyGsmA6 | |||||||
|     streamSkipUntil('"'); |     streamSkipUntil('"'); | ||||||
|     String hex = stream.readStringUntil('"'); |     String hex = stream.readStringUntil('"'); | ||||||
|     streamSkipUntil(','); |     streamSkipUntil(','); | ||||||
|     int8_t dcs = streamGetInt('\n'); |     int8_t dcs = streamGetIntBefore('\n'); | ||||||
|  |  | ||||||
|     if (dcs == 15) { |     if (dcs == 15) { | ||||||
|       return TinyGsmDecodeHex7bit(hex); |       return TinyGsmDecodeHex7bit(hex); | ||||||
| @@ -389,7 +389,7 @@ class TinyGsmA6 | |||||||
|     if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { return false; } |     if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { return false; } | ||||||
|     streamSkipUntil(',');  // Skip battery charge status |     streamSkipUntil(',');  // Skip battery charge status | ||||||
|     // Read battery charge level |     // Read battery charge level | ||||||
|     int8_t res = streamGetInt('\n'); |     int8_t res = streamGetIntBefore('\n'); | ||||||
|     // Wait for final OK |     // Wait for final OK | ||||||
|     waitResponse(); |     waitResponse(); | ||||||
|     return res; |     return res; | ||||||
| @@ -400,8 +400,8 @@ class TinyGsmA6 | |||||||
|                         uint16_t& milliVolts) { |                         uint16_t& milliVolts) { | ||||||
|     sendAT(GF("+CBC?")); |     sendAT(GF("+CBC?")); | ||||||
|     if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { return false; } |     if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { return false; } | ||||||
|     chargeState = streamGetInt(','); |     chargeState = streamGetIntBefore(','); | ||||||
|     percent     = streamGetInt('\n'); |     percent     = streamGetIntBefore('\n'); | ||||||
|     milliVolts  = 0; |     milliVolts  = 0; | ||||||
|     // Wait for final OK |     // Wait for final OK | ||||||
|     waitResponse(); |     waitResponse(); | ||||||
| @@ -419,7 +419,7 @@ class TinyGsmA6 | |||||||
|  |  | ||||||
|     sendAT(GF("+CIPSTART="), GF("\"TCP"), GF("\",\""), host, GF("\","), port); |     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(GSM_NL "+CIPNUM:")) != 1) { return false; } | ||||||
|     int8_t newMux = streamGetInt('\n'); |     int8_t newMux = streamGetIntBefore('\n'); | ||||||
|  |  | ||||||
|     int8_t rsp = waitResponse( |     int8_t rsp = waitResponse( | ||||||
|         (timeout_ms - (millis() - startMillis)), GF("CONNECT OK" GSM_NL), |         (timeout_ms - (millis() - startMillis)), GF("CONNECT OK" GSM_NL), | ||||||
| @@ -499,8 +499,8 @@ class TinyGsmA6 | |||||||
|           index = 5; |           index = 5; | ||||||
|           goto finish; |           goto finish; | ||||||
|         } else if (data.endsWith(GF("+CIPRCV:"))) { |         } else if (data.endsWith(GF("+CIPRCV:"))) { | ||||||
|           int8_t  mux      = streamGetInt(','); |           int8_t  mux      = streamGetIntBefore(','); | ||||||
|           int16_t len      = streamGetInt(','); |           int16_t len      = streamGetIntBefore(','); | ||||||
|           int16_t len_orig = len; |           int16_t len_orig = len; | ||||||
|           if (len > sockets[mux]->rx.free()) { |           if (len > sockets[mux]->rx.free()) { | ||||||
|             DBG("### Buffer overflow: ", len, "->", sockets[mux]->rx.free()); |             DBG("### Buffer overflow: ", len, "->", sockets[mux]->rx.free()); | ||||||
| @@ -515,7 +515,7 @@ class TinyGsmA6 | |||||||
|           } |           } | ||||||
|           data = ""; |           data = ""; | ||||||
|         } else if (data.endsWith(GF("+TCPCLOSED:"))) { |         } else if (data.endsWith(GF("+TCPCLOSED:"))) { | ||||||
|           int8_t mux = streamGetInt('\n'); |           int8_t mux = streamGetIntBefore('\n'); | ||||||
|           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT) { |           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT) { | ||||||
|             sockets[mux]->sock_connected = false; |             sockets[mux]->sock_connected = false; | ||||||
|           } |           } | ||||||
|   | |||||||
| @@ -306,9 +306,9 @@ class TinyGsmBG96 | |||||||
|  |  | ||||||
|     if (waitResponse(timeout_ms, GF(GSM_NL "+QIOPEN:")) != 1) { return false; } |     if (waitResponse(timeout_ms, GF(GSM_NL "+QIOPEN:")) != 1) { return false; } | ||||||
|  |  | ||||||
|     if (streamGetInt(',') != mux) { return false; } |     if (streamGetIntBefore(',') != mux) { return false; } | ||||||
|     // Read status |     // Read status | ||||||
|     return (0 == streamGetInt('\n')); |     return (0 == streamGetIntBefore('\n')); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   int16_t modemSend(const void* buff, size_t len, uint8_t mux) { |   int16_t modemSend(const void* buff, size_t len, uint8_t mux) { | ||||||
| @@ -324,7 +324,7 @@ class TinyGsmBG96 | |||||||
|   size_t modemRead(size_t size, uint8_t mux) { |   size_t modemRead(size_t size, uint8_t mux) { | ||||||
|     sendAT(GF("+QIRD="), mux, ',', (uint16_t)size); |     sendAT(GF("+QIRD="), mux, ',', (uint16_t)size); | ||||||
|     if (waitResponse(GF("+QIRD:")) != 1) { return 0; } |     if (waitResponse(GF("+QIRD:")) != 1) { return 0; } | ||||||
|     int16_t len = streamGetInt('\n'); |     int16_t len = streamGetIntBefore('\n'); | ||||||
|  |  | ||||||
|     for (int i = 0; i < len; i++) { moveCharFromStreamToFifo(mux); } |     for (int i = 0; i < len; i++) { moveCharFromStreamToFifo(mux); } | ||||||
|     waitResponse(); |     waitResponse(); | ||||||
| @@ -339,7 +339,7 @@ class TinyGsmBG96 | |||||||
|     if (waitResponse(GF("+QIRD:")) == 1) { |     if (waitResponse(GF("+QIRD:")) == 1) { | ||||||
|       streamSkipUntil(',');  // Skip total received |       streamSkipUntil(',');  // Skip total received | ||||||
|       streamSkipUntil(',');  // Skip have read |       streamSkipUntil(',');  // Skip have read | ||||||
|       result = streamGetInt('\n'); |       result = streamGetIntBefore('\n'); | ||||||
|       if (result) { DBG("### DATA AVAILABLE:", result, "on", mux); } |       if (result) { DBG("### DATA AVAILABLE:", result, "on", mux); } | ||||||
|       waitResponse(); |       waitResponse(); | ||||||
|     } |     } | ||||||
| @@ -353,12 +353,12 @@ class TinyGsmBG96 | |||||||
|  |  | ||||||
|     if (waitResponse(GF("+QISTATE:")) != 1) { return false; } |     if (waitResponse(GF("+QISTATE:")) != 1) { return false; } | ||||||
|  |  | ||||||
|     streamSkipUntil(',');            // Skip mux |     streamSkipUntil(',');                  // Skip mux | ||||||
|     streamSkipUntil(',');            // Skip socket type |     streamSkipUntil(',');                  // Skip socket type | ||||||
|     streamSkipUntil(',');            // Skip remote ip |     streamSkipUntil(',');                  // Skip remote ip | ||||||
|     streamSkipUntil(',');            // Skip remote port |     streamSkipUntil(',');                  // Skip remote port | ||||||
|     streamSkipUntil(',');            // Skip local port |     streamSkipUntil(',');                  // Skip local port | ||||||
|     int8_t res = streamGetInt(',');  // socket state |     int8_t res = streamGetIntBefore(',');  // socket state | ||||||
|  |  | ||||||
|     waitResponse(); |     waitResponse(); | ||||||
|  |  | ||||||
| @@ -415,13 +415,13 @@ class TinyGsmBG96 | |||||||
|           String urc = stream.readStringUntil('\"'); |           String urc = stream.readStringUntil('\"'); | ||||||
|           streamSkipUntil(','); |           streamSkipUntil(','); | ||||||
|           if (urc == "recv") { |           if (urc == "recv") { | ||||||
|             int8_t mux = streamGetInt('\n'); |             int8_t mux = streamGetIntBefore('\n'); | ||||||
|             DBG("### URC RECV:", mux); |             DBG("### URC RECV:", mux); | ||||||
|             if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { |             if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { | ||||||
|               sockets[mux]->got_data = true; |               sockets[mux]->got_data = true; | ||||||
|             } |             } | ||||||
|           } else if (urc == "closed") { |           } else if (urc == "closed") { | ||||||
|             int8_t mux = streamGetInt('\n'); |             int8_t mux = streamGetIntBefore('\n'); | ||||||
|             DBG("### URC CLOSE:", mux); |             DBG("### URC CLOSE:", mux); | ||||||
|             if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { |             if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { | ||||||
|               sockets[mux]->sock_connected = false; |               sockets[mux]->sock_connected = false; | ||||||
|   | |||||||
| @@ -326,7 +326,7 @@ class TinyGsmESP8266 | |||||||
|       uint8_t has_status = waitResponse(GF("+CIPSTATUS:"), GFP(GSM_OK), |       uint8_t has_status = waitResponse(GF("+CIPSTATUS:"), GFP(GSM_OK), | ||||||
|                                         GFP(GSM_ERROR)); |                                         GFP(GSM_ERROR)); | ||||||
|       if (has_status == 1) { |       if (has_status == 1) { | ||||||
|         int8_t returned_mux = streamGetInt(','); |         int8_t returned_mux = streamGetIntBefore(','); | ||||||
|         streamSkipUntil(',');   // Skip mux |         streamSkipUntil(',');   // Skip mux | ||||||
|         streamSkipUntil(',');   // Skip type |         streamSkipUntil(',');   // Skip type | ||||||
|         streamSkipUntil(',');   // Skip remote IP |         streamSkipUntil(',');   // Skip remote IP | ||||||
| @@ -384,8 +384,8 @@ class TinyGsmESP8266 | |||||||
|           index = 5; |           index = 5; | ||||||
|           goto finish; |           goto finish; | ||||||
|         } else if (data.endsWith(GF("+IPD,"))) { |         } else if (data.endsWith(GF("+IPD,"))) { | ||||||
|           int8_t  mux      = streamGetInt(','); |           int8_t  mux      = streamGetIntBefore(','); | ||||||
|           int16_t len      = streamGetInt(':'); |           int16_t len      = streamGetIntBefore(':'); | ||||||
|           int16_t len_orig = len; |           int16_t len_orig = len; | ||||||
|           if (len > sockets[mux]->rx.free()) { |           if (len > sockets[mux]->rx.free()) { | ||||||
|             DBG("### Buffer overflow: ", len, "received vs", |             DBG("### Buffer overflow: ", len, "received vs", | ||||||
|   | |||||||
| @@ -257,7 +257,7 @@ class TinyGsmM590 | |||||||
|   bool isGprsConnectedImpl() { |   bool isGprsConnectedImpl() { | ||||||
|     sendAT(GF("+XIIC?")); |     sendAT(GF("+XIIC?")); | ||||||
|     if (waitResponse(GF(GSM_NL "+XIIC:")) != 1) { return false; } |     if (waitResponse(GF(GSM_NL "+XIIC:")) != 1) { return false; } | ||||||
|     int8_t res = streamGetInt(','); |     int8_t res = streamGetIntBefore(','); | ||||||
|     waitResponse(); |     waitResponse(); | ||||||
|     return res == 1; |     return res == 1; | ||||||
|   } |   } | ||||||
| @@ -386,8 +386,8 @@ class TinyGsmM590 | |||||||
|           index = 5; |           index = 5; | ||||||
|           goto finish; |           goto finish; | ||||||
|         } else if (data.endsWith(GF("+TCPRECV:"))) { |         } else if (data.endsWith(GF("+TCPRECV:"))) { | ||||||
|           int8_t  mux      = streamGetInt(','); |           int8_t  mux      = streamGetIntBefore(','); | ||||||
|           int16_t len      = streamGetInt(','); |           int16_t len      = streamGetIntBefore(','); | ||||||
|           int16_t len_orig = len; |           int16_t len_orig = len; | ||||||
|           if (len > sockets[mux]->rx.free()) { |           if (len > sockets[mux]->rx.free()) { | ||||||
|             DBG("### Buffer overflow: ", len, "->", sockets[mux]->rx.free()); |             DBG("### Buffer overflow: ", len, "->", sockets[mux]->rx.free()); | ||||||
| @@ -402,7 +402,7 @@ class TinyGsmM590 | |||||||
|           } |           } | ||||||
|           data = ""; |           data = ""; | ||||||
|         } else if (data.endsWith(GF("+TCPCLOSE:"))) { |         } else if (data.endsWith(GF("+TCPCLOSE:"))) { | ||||||
|           int8_t mux = streamGetInt(','); |           int8_t mux = streamGetIntBefore(','); | ||||||
|           streamSkipUntil('\n'); |           streamSkipUntil('\n'); | ||||||
|           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT) { |           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT) { | ||||||
|             sockets[mux]->sock_connected = false; |             sockets[mux]->sock_connected = false; | ||||||
|   | |||||||
| @@ -386,9 +386,9 @@ class TinyGsmM95 | |||||||
|     } |     } | ||||||
|     streamSkipUntil(',');  // Skip mode |     streamSkipUntil(',');  // Skip mode | ||||||
|     // Read charge of thermistor |     // Read charge of thermistor | ||||||
|     // milliVolts = streamGetInt(','); |     // milliVolts = streamGetIntBefore(','); | ||||||
|     streamSkipUntil(',');  // Skip thermistor charge |     streamSkipUntil(',');  // Skip thermistor charge | ||||||
|     float temp = streamGetFloat('\n'); |     float temp = streamGetFloatBefore('\n'); | ||||||
|     // Wait for final OK |     // Wait for final OK | ||||||
|     waitResponse(); |     waitResponse(); | ||||||
|     return temp; |     return temp; | ||||||
| @@ -427,7 +427,7 @@ class TinyGsmM95 | |||||||
|     //     streamSkipUntil(',');  // Skip total length sent on connection |     //     streamSkipUntil(',');  // Skip total length sent on connection | ||||||
|     //     streamSkipUntil(',');  // Skip length already acknowledged by remote |     //     streamSkipUntil(',');  // Skip length already acknowledged by remote | ||||||
|     //     // Make sure the total length un-acknowledged is 0 |     //     // Make sure the total length un-acknowledged is 0 | ||||||
|     //     if ( streamGetInt('\n') == 0 ) { |     //     if ( streamGetIntBefore('\n') == 0 ) { | ||||||
|     //       allAcknowledged = true; |     //       allAcknowledged = true; | ||||||
|     //     } |     //     } | ||||||
|     //   } |     //   } | ||||||
| @@ -453,7 +453,7 @@ class TinyGsmM95 | |||||||
|       streamSkipUntil(',');  // skip port |       streamSkipUntil(',');  // skip port | ||||||
|       streamSkipUntil(',');  // skip connection type (TCP/UDP) |       streamSkipUntil(',');  // skip connection type (TCP/UDP) | ||||||
|       // read the real length of the retrieved data |       // read the real length of the retrieved data | ||||||
|       uint16_t len = streamGetInt('\n'); |       uint16_t len = streamGetIntBefore('\n'); | ||||||
|       // We have no way of knowing in advance how much data will be in the |       // We have no way of knowing in advance how much data will be in the | ||||||
|       // buffer so when data is received we always assume the buffer is |       // buffer so when data is received we always assume the buffer is | ||||||
|       // completely full. Chances are, this is not true and there's really not |       // completely full. Chances are, this is not true and there's really not | ||||||
| @@ -485,12 +485,12 @@ class TinyGsmM95 | |||||||
|  |  | ||||||
|     if (waitResponse(GF("+QISTATE:")) != 1) { return false; } |     if (waitResponse(GF("+QISTATE:")) != 1) { return false; } | ||||||
|  |  | ||||||
|     streamSkipUntil(',');            // Skip mux |     streamSkipUntil(',');                  // Skip mux | ||||||
|     streamSkipUntil(',');            // Skip socket type |     streamSkipUntil(',');                  // Skip socket type | ||||||
|     streamSkipUntil(',');            // Skip remote ip |     streamSkipUntil(',');                  // Skip remote ip | ||||||
|     streamSkipUntil(',');            // Skip remote port |     streamSkipUntil(',');                  // Skip remote port | ||||||
|     streamSkipUntil(',');            // Skip local port |     streamSkipUntil(',');                  // Skip local port | ||||||
|     int8_t res = streamGetInt(',');  // socket state |     int8_t res = streamGetIntBefore(',');  // socket state | ||||||
|  |  | ||||||
|     waitResponse(); |     waitResponse(); | ||||||
|  |  | ||||||
| @@ -545,7 +545,7 @@ class TinyGsmM95 | |||||||
|         } else if (data.endsWith(GF(GSM_NL "+QIRDI:"))) { |         } else if (data.endsWith(GF(GSM_NL "+QIRDI:"))) { | ||||||
|           streamSkipUntil(',');  // Skip the context |           streamSkipUntil(',');  // Skip the context | ||||||
|           streamSkipUntil(',');  // Skip the role |           streamSkipUntil(',');  // Skip the role | ||||||
|           int8_t mux = streamGetInt('\n'); |           int8_t mux = streamGetIntBefore('\n'); | ||||||
|           DBG("### Got Data:", mux); |           DBG("### Got Data:", mux); | ||||||
|           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { |           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { | ||||||
|             // We have no way of knowing how much data actually came in, so |             // We have no way of knowing how much data actually came in, so | ||||||
|   | |||||||
| @@ -386,13 +386,13 @@ class TinyGsmMC60 | |||||||
|       } else { |       } else { | ||||||
|         streamSkipUntil(','); /** Skip total */ |         streamSkipUntil(','); /** Skip total */ | ||||||
|         streamSkipUntil(','); /** Skip acknowledged data size */ |         streamSkipUntil(','); /** Skip acknowledged data size */ | ||||||
|         if (streamGetInt('\n') == 0) { allAcknowledged = true; } |         if (streamGetIntBefore('\n') == 0) { allAcknowledged = true; } | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|     waitResponse(5000L); |     waitResponse(5000L); | ||||||
|  |  | ||||||
|     // streamSkipUntil(','); // Skip mux |     // streamSkipUntil(','); // Skip mux | ||||||
|     // return streamGetInt('\n'); |     // return streamGetIntBefore('\n'); | ||||||
|  |  | ||||||
|     return len;  // TODO(?): verify len/ack |     return len;  // TODO(?): verify len/ack | ||||||
|   } |   } | ||||||
| @@ -413,7 +413,7 @@ class TinyGsmMC60 | |||||||
|       streamSkipUntil(',');  // skip port |       streamSkipUntil(',');  // skip port | ||||||
|       streamSkipUntil(',');  // skip connection type (TCP/UDP) |       streamSkipUntil(',');  // skip connection type (TCP/UDP) | ||||||
|       // read the real length of the retrieved data |       // read the real length of the retrieved data | ||||||
|       uint16_t len = streamGetInt('\n'); |       uint16_t len = streamGetIntBefore('\n'); | ||||||
|       // It's possible that the real length available is less than expected |       // It's possible that the real length available is less than expected | ||||||
|       // This is quite likely if the buffer is broken into packets - which may |       // This is quite likely if the buffer is broken into packets - which may | ||||||
|       // be different sizes. |       // be different sizes. | ||||||
| @@ -444,12 +444,12 @@ class TinyGsmMC60 | |||||||
|  |  | ||||||
|     if (waitResponse(GF("+QISTATE:")) != 1) { return false; } |     if (waitResponse(GF("+QISTATE:")) != 1) { return false; } | ||||||
|  |  | ||||||
|     streamSkipUntil(',');            // Skip mux |     streamSkipUntil(',');                  // Skip mux | ||||||
|     streamSkipUntil(',');            // Skip socket type |     streamSkipUntil(',');                  // Skip socket type | ||||||
|     streamSkipUntil(',');            // Skip remote ip |     streamSkipUntil(',');                  // Skip remote ip | ||||||
|     streamSkipUntil(',');            // Skip remote port |     streamSkipUntil(',');                  // Skip remote port | ||||||
|     streamSkipUntil(',');            // Skip local port |     streamSkipUntil(',');                  // Skip local port | ||||||
|     int8_t res = streamGetInt(',');  // socket state |     int8_t res = streamGetIntBefore(',');  // socket state | ||||||
|  |  | ||||||
|     waitResponse(); |     waitResponse(); | ||||||
|  |  | ||||||
| @@ -512,11 +512,11 @@ class TinyGsmMC60 | |||||||
|           streamSkipUntil(',');  // Skip the context |           streamSkipUntil(',');  // Skip the context | ||||||
|           streamSkipUntil(',');  // Skip the role |           streamSkipUntil(',');  // Skip the role | ||||||
|           // read the connection id |           // read the connection id | ||||||
|           int8_t mux = streamGetInt(','); |           int8_t mux = streamGetIntBefore(','); | ||||||
|           // read the number of packets in the buffer |           // read the number of packets in the buffer | ||||||
|           int8_t num_packets = streamGetInt(','); |           int8_t num_packets = streamGetIntBefore(','); | ||||||
|           // read the length of the current packet |           // read the length of the current packet | ||||||
|           int16_t len_packet = streamGetInt('\n'); |           int16_t len_packet = streamGetIntBefore('\n'); | ||||||
|           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { |           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { | ||||||
|             sockets[mux]->sock_available = len_packet * num_packets; |             sockets[mux]->sock_available = len_packet * num_packets; | ||||||
|           } |           } | ||||||
|   | |||||||
| @@ -428,7 +428,7 @@ class TinyGsmSim5360 : public TinyGsmModem<TinyGsmSim5360>, | |||||||
|     streamSkipUntil(',');  // Skip battery charge status |     streamSkipUntil(',');  // Skip battery charge status | ||||||
|     streamSkipUntil(',');  // Skip battery charge level |     streamSkipUntil(',');  // Skip battery charge level | ||||||
|     // get voltage in VOLTS |     // get voltage in VOLTS | ||||||
|     float voltage = streamGetFloat('\n'); |     float voltage = streamGetFloatBefore('\n'); | ||||||
|     // Wait for final OK |     // Wait for final OK | ||||||
|     waitResponse(); |     waitResponse(); | ||||||
|     // Return millivolts |     // Return millivolts | ||||||
| @@ -441,10 +441,10 @@ class TinyGsmSim5360 : public TinyGsmModem<TinyGsmSim5360>, | |||||||
|                         uint16_t& milliVolts) { |                         uint16_t& milliVolts) { | ||||||
|     sendAT(GF("+CBC")); |     sendAT(GF("+CBC")); | ||||||
|     if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { return false; } |     if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { return false; } | ||||||
|     chargeState = streamGetInt(','); |     chargeState = streamGetIntBefore(','); | ||||||
|     percent     = streamGetInt(','); |     percent     = streamGetIntBefore(','); | ||||||
|     // get voltage in VOLTS |     // get voltage in VOLTS | ||||||
|     float voltage = streamGetFloat('\n'); |     float voltage = streamGetFloatBefore('\n'); | ||||||
|     milliVolts    = voltage * 1000; |     milliVolts    = voltage * 1000; | ||||||
|     // Wait for final OK |     // Wait for final OK | ||||||
|     waitResponse(); |     waitResponse(); | ||||||
| @@ -463,7 +463,7 @@ class TinyGsmSim5360 : public TinyGsmModem<TinyGsmSim5360>, | |||||||
|     // Get Temparature Value |     // Get Temparature Value | ||||||
|     sendAT(GF("+CMTE?")); |     sendAT(GF("+CMTE?")); | ||||||
|     if (waitResponse(GF(GSM_NL "+CMTE:")) != 1) { return false; } |     if (waitResponse(GF(GSM_NL "+CMTE:")) != 1) { return false; } | ||||||
|     float res = streamGetFloat('\n'); |     float res = streamGetFloatBefore('\n'); | ||||||
|     // Wait for final OK |     // Wait for final OK | ||||||
|     waitResponse(); |     waitResponse(); | ||||||
|     return res; |     return res; | ||||||
| @@ -498,7 +498,7 @@ class TinyGsmSim5360 : public TinyGsmModem<TinyGsmSim5360>, | |||||||
|     streamSkipUntil(',');  // Skip mux |     streamSkipUntil(',');  // Skip mux | ||||||
|     streamSkipUntil(',');  // Skip requested bytes to send |     streamSkipUntil(',');  // Skip requested bytes to send | ||||||
|     // TODO(?):  make sure requested and confirmed bytes match |     // TODO(?):  make sure requested and confirmed bytes match | ||||||
|     return streamGetInt('\n'); |     return streamGetIntBefore('\n'); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   size_t modemRead(size_t size, uint8_t mux) { |   size_t modemRead(size_t size, uint8_t mux) { | ||||||
| @@ -511,9 +511,9 @@ class TinyGsmSim5360 : public TinyGsmModem<TinyGsmSim5360>, | |||||||
| #endif | #endif | ||||||
|     streamSkipUntil(',');  // Skip Rx mode 2/normal or 3/HEX |     streamSkipUntil(',');  // Skip Rx mode 2/normal or 3/HEX | ||||||
|     streamSkipUntil(',');  // Skip mux/cid (connecion id) |     streamSkipUntil(',');  // Skip mux/cid (connecion id) | ||||||
|     int16_t len_requested = streamGetInt(','); |     int16_t len_requested = streamGetIntBefore(','); | ||||||
|     //  ^^ Requested number of data bytes (1-1460 bytes)to be read |     //  ^^ Requested number of data bytes (1-1460 bytes)to be read | ||||||
|     int16_t len_confirmed = streamGetInt('\n'); |     int16_t len_confirmed = streamGetIntBefore('\n'); | ||||||
|     // ^^ The data length which not read in the buffer |     // ^^ The data length which not read in the buffer | ||||||
|     for (int i = 0; i < len_requested; i++) { |     for (int i = 0; i < len_requested; i++) { | ||||||
|       uint32_t startMillis = millis(); |       uint32_t startMillis = millis(); | ||||||
| @@ -550,7 +550,7 @@ class TinyGsmSim5360 : public TinyGsmModem<TinyGsmSim5360>, | |||||||
|     if (waitResponse(GF("+CIPRXGET:")) == 1) { |     if (waitResponse(GF("+CIPRXGET:")) == 1) { | ||||||
|       streamSkipUntil(',');  // Skip mode 4 |       streamSkipUntil(',');  // Skip mode 4 | ||||||
|       streamSkipUntil(',');  // Skip mux |       streamSkipUntil(',');  // Skip mux | ||||||
|       result = streamGetInt('\n'); |       result = streamGetIntBefore('\n'); | ||||||
|       waitResponse(); |       waitResponse(); | ||||||
|     } |     } | ||||||
|     DBG("### Available:", result, "on", mux); |     DBG("### Available:", result, "on", mux); | ||||||
| @@ -615,9 +615,9 @@ class TinyGsmSim5360 : public TinyGsmModem<TinyGsmSim5360>, | |||||||
|           index = 5; |           index = 5; | ||||||
|           goto finish; |           goto finish; | ||||||
|         } else if (data.endsWith(GF(GSM_NL "+CIPRXGET:"))) { |         } else if (data.endsWith(GF(GSM_NL "+CIPRXGET:"))) { | ||||||
|           int8_t mode = streamGetInt(','); |           int8_t mode = streamGetIntBefore(','); | ||||||
|           if (mode == 1) { |           if (mode == 1) { | ||||||
|             int8_t mux = streamGetInt('\n'); |             int8_t mux = streamGetIntBefore('\n'); | ||||||
|             if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { |             if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { | ||||||
|               sockets[mux]->got_data = true; |               sockets[mux]->got_data = true; | ||||||
|             } |             } | ||||||
| @@ -627,8 +627,8 @@ class TinyGsmSim5360 : public TinyGsmModem<TinyGsmSim5360>, | |||||||
|             data += mode; |             data += mode; | ||||||
|           } |           } | ||||||
|         } else if (data.endsWith(GF(GSM_NL "+RECEIVE:"))) { |         } else if (data.endsWith(GF(GSM_NL "+RECEIVE:"))) { | ||||||
|           int8_t  mux = streamGetInt(','); |           int8_t  mux = streamGetIntBefore(','); | ||||||
|           int16_t len = streamGetInt('\n'); |           int16_t len = streamGetIntBefore('\n'); | ||||||
|           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { |           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { | ||||||
|             sockets[mux]->got_data       = true; |             sockets[mux]->got_data       = true; | ||||||
|             sockets[mux]->sock_available = len; |             sockets[mux]->sock_available = len; | ||||||
| @@ -636,7 +636,7 @@ class TinyGsmSim5360 : public TinyGsmModem<TinyGsmSim5360>, | |||||||
|           data = ""; |           data = ""; | ||||||
|           DBG("### Got Data:", len, "on", mux); |           DBG("### Got Data:", len, "on", mux); | ||||||
|         } else if (data.endsWith(GF("+IPCLOSE:"))) { |         } else if (data.endsWith(GF("+IPCLOSE:"))) { | ||||||
|           int8_t mux = streamGetInt(','); |           int8_t mux = streamGetIntBefore(','); | ||||||
|           streamSkipUntil('\n');  // Skip the reason code |           streamSkipUntil('\n');  // Skip the reason code | ||||||
|           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { |           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { | ||||||
|             sockets[mux]->sock_connected = false; |             sockets[mux]->sock_connected = false; | ||||||
|   | |||||||
| @@ -425,8 +425,8 @@ class TinyGsmSim7000 : public TinyGsmModem<TinyGsmSim7000>, | |||||||
|     sendAT(GF("+CGNSINF")); |     sendAT(GF("+CGNSINF")); | ||||||
|     if (waitResponse(10000L, GF(GSM_NL "+CGNSINF:")) != 1) { return false; } |     if (waitResponse(10000L, GF(GSM_NL "+CGNSINF:")) != 1) { return false; } | ||||||
|  |  | ||||||
|     streamSkipUntil(',');          // GNSS run status |     streamSkipUntil(',');                // GNSS run status | ||||||
|     if (streamGetInt(',') == 1) {  // fix status |     if (streamGetIntBefore(',') == 1) {  // fix status | ||||||
|       // init variables |       // init variables | ||||||
|       float ilat         = 0; |       float ilat         = 0; | ||||||
|       float ilon         = 0; |       float ilon         = 0; | ||||||
| @@ -443,31 +443,32 @@ class TinyGsmSim7000 : public TinyGsmModem<TinyGsmSim7000>, | |||||||
|       float secondWithSS = 0; |       float secondWithSS = 0; | ||||||
|  |  | ||||||
|       // UTC date & Time |       // UTC date & Time | ||||||
|       iyear        = streamGetInt(static_cast<int8_t>(4));  // Four digit year |       iyear  = streamGetIntLength(4);  // Four digit year | ||||||
|       imonth       = streamGetInt(static_cast<int8_t>(2));  // Two digit month |       imonth = streamGetIntLength(2);  // Two digit month | ||||||
|       iday         = streamGetInt(static_cast<int8_t>(2));  // Two digit day |       iday   = streamGetIntLength(2);  // Two digit day | ||||||
|       ihour        = streamGetInt(static_cast<int8_t>(2));  // Two digit hour |       ihour  = streamGetIntLength(2);  // Two digit hour | ||||||
|       imin         = streamGetInt(static_cast<int8_t>(2));  // Two digit minute |       imin   = streamGetIntLength(2);  // Two digit minute | ||||||
|       secondWithSS = streamGetFloat(',');  // 6 digit second with subseconds |       secondWithSS = | ||||||
|  |           streamGetFloatBefore(',');  // 6 digit second with subseconds | ||||||
|  |  | ||||||
|       ilat   = streamGetFloat(',');     // Latitude |       ilat   = streamGetFloatBefore(',');  // Latitude | ||||||
|       ilon   = streamGetFloat(',');     // Longitude |       ilon   = streamGetFloatBefore(',');  // Longitude | ||||||
|       ialt   = streamGetFloat(',');     // MSL Altitude. Unit is meters |       ialt   = streamGetFloatBefore(',');  // MSL Altitude. Unit is meters | ||||||
|       ispeed = streamGetFloat(',');     // Speed Over Ground. Unit is knots. |       ispeed = streamGetFloatBefore(',');  // Speed Over Ground. Unit is knots. | ||||||
|       streamSkipUntil(',');             // Course Over Ground. Degrees. |       streamSkipUntil(',');                // Course Over Ground. Degrees. | ||||||
|       streamSkipUntil(',');             // Fix Mode |       streamSkipUntil(',');                // Fix Mode | ||||||
|       streamSkipUntil(',');             // Reserved1 |       streamSkipUntil(',');                // Reserved1 | ||||||
|       streamSkipUntil(',');             // Horizontal Dilution Of Precision |       streamSkipUntil(',');                // Horizontal Dilution Of Precision | ||||||
|       iaccuracy = streamGetFloat(',');  // Position Dilution Of Precision |       iaccuracy = streamGetFloatBefore(',');  // Position Dilution Of Precision | ||||||
|       streamSkipUntil(',');             // Vertical Dilution Of Precision |       streamSkipUntil(',');                   // Vertical Dilution Of Precision | ||||||
|       streamSkipUntil(',');             // Reserved2 |       streamSkipUntil(',');                   // Reserved2 | ||||||
|       ivsat = streamGetInt(',');        // GNSS Satellites in View |       ivsat = streamGetIntBefore(',');        // GNSS Satellites in View | ||||||
|       iusat = streamGetInt(',');        // GNSS Satellites Used |       iusat = streamGetIntBefore(',');        // GNSS Satellites Used | ||||||
|       streamSkipUntil(',');             // GLONASS Satellites Used |       streamSkipUntil(',');                   // GLONASS Satellites Used | ||||||
|       streamSkipUntil(',');             // Reserved3 |       streamSkipUntil(',');                   // Reserved3 | ||||||
|       streamSkipUntil(',');             // C/N0 max |       streamSkipUntil(',');                   // C/N0 max | ||||||
|       streamSkipUntil(',');             // HPA |       streamSkipUntil(',');                   // HPA | ||||||
|       streamSkipUntil('\n');            // VPA |       streamSkipUntil('\n');                  // VPA | ||||||
|  |  | ||||||
|       // Set pointers |       // Set pointers | ||||||
|       if (lat != NULL) *lat = ilat; |       if (lat != NULL) *lat = ilat; | ||||||
| @@ -530,7 +531,7 @@ class TinyGsmSim7000 : public TinyGsmModem<TinyGsmSim7000>, | |||||||
|     stream.flush(); |     stream.flush(); | ||||||
|     if (waitResponse(GF(GSM_NL "DATA ACCEPT:")) != 1) { return 0; } |     if (waitResponse(GF(GSM_NL "DATA ACCEPT:")) != 1) { return 0; } | ||||||
|     streamSkipUntil(',');  // Skip mux |     streamSkipUntil(',');  // Skip mux | ||||||
|     return streamGetInt('\n'); |     return streamGetIntBefore('\n'); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   size_t modemRead(size_t size, uint8_t mux) { |   size_t modemRead(size_t size, uint8_t mux) { | ||||||
| @@ -543,9 +544,9 @@ class TinyGsmSim7000 : public TinyGsmModem<TinyGsmSim7000>, | |||||||
| #endif | #endif | ||||||
|     streamSkipUntil(',');  // Skip Rx mode 2/normal or 3/HEX |     streamSkipUntil(',');  // Skip Rx mode 2/normal or 3/HEX | ||||||
|     streamSkipUntil(',');  // Skip mux |     streamSkipUntil(',');  // Skip mux | ||||||
|     int16_t len_requested = streamGetInt(','); |     int16_t len_requested = streamGetIntBefore(','); | ||||||
|     //  ^^ Requested number of data bytes (1-1460 bytes)to be read |     //  ^^ Requested number of data bytes (1-1460 bytes)to be read | ||||||
|     int16_t len_confirmed = streamGetInt('\n'); |     int16_t len_confirmed = streamGetIntBefore('\n'); | ||||||
|     // ^^ Confirmed number of data bytes to be read, which may be less than |     // ^^ 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 |     // requested. 0 indicates that no data can be read. This is actually be the | ||||||
|     // number of bytes that will be remaining after the read |     // number of bytes that will be remaining after the read | ||||||
| @@ -584,7 +585,7 @@ class TinyGsmSim7000 : public TinyGsmModem<TinyGsmSim7000>, | |||||||
|     if (waitResponse(GF("+CIPRXGET:")) == 1) { |     if (waitResponse(GF("+CIPRXGET:")) == 1) { | ||||||
|       streamSkipUntil(',');  // Skip mode 4 |       streamSkipUntil(',');  // Skip mode 4 | ||||||
|       streamSkipUntil(',');  // Skip mux |       streamSkipUntil(',');  // Skip mux | ||||||
|       result = streamGetInt('\n'); |       result = streamGetIntBefore('\n'); | ||||||
|       waitResponse(); |       waitResponse(); | ||||||
|     } |     } | ||||||
|     DBG("### Available:", result, "on", mux); |     DBG("### Available:", result, "on", mux); | ||||||
| @@ -645,9 +646,9 @@ class TinyGsmSim7000 : public TinyGsmModem<TinyGsmSim7000>, | |||||||
|           index = 5; |           index = 5; | ||||||
|           goto finish; |           goto finish; | ||||||
|         } else if (data.endsWith(GF(GSM_NL "+CIPRXGET:"))) { |         } else if (data.endsWith(GF(GSM_NL "+CIPRXGET:"))) { | ||||||
|           int8_t mode = streamGetInt(','); |           int8_t mode = streamGetIntBefore(','); | ||||||
|           if (mode == 1) { |           if (mode == 1) { | ||||||
|             int8_t mux = streamGetInt('\n'); |             int8_t mux = streamGetIntBefore('\n'); | ||||||
|             if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { |             if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { | ||||||
|               sockets[mux]->got_data = true; |               sockets[mux]->got_data = true; | ||||||
|             } |             } | ||||||
| @@ -657,8 +658,8 @@ class TinyGsmSim7000 : public TinyGsmModem<TinyGsmSim7000>, | |||||||
|             data += mode; |             data += mode; | ||||||
|           } |           } | ||||||
|         } else if (data.endsWith(GF(GSM_NL "+RECEIVE:"))) { |         } else if (data.endsWith(GF(GSM_NL "+RECEIVE:"))) { | ||||||
|           int8_t  mux = streamGetInt(','); |           int8_t  mux = streamGetIntBefore(','); | ||||||
|           int16_t len = streamGetInt('\n'); |           int16_t len = streamGetIntBefore('\n'); | ||||||
|           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { |           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { | ||||||
|             sockets[mux]->got_data       = true; |             sockets[mux]->got_data       = true; | ||||||
|             sockets[mux]->sock_available = len; |             sockets[mux]->sock_available = len; | ||||||
|   | |||||||
| @@ -436,8 +436,8 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600>, | |||||||
|     sendAT(GF("+CGNSSINFO")); |     sendAT(GF("+CGNSSINFO")); | ||||||
|     if (waitResponse(GF(GSM_NL "+CGNSSINFO:")) != 1) { return false; } |     if (waitResponse(GF(GSM_NL "+CGNSSINFO:")) != 1) { return false; } | ||||||
|  |  | ||||||
|     uint8_t fixMode = streamGetInt(',');  // mode 2=2D Fix or 3=3DFix |     uint8_t fixMode = streamGetIntBefore(',');  // mode 2=2D Fix or 3=3DFix | ||||||
|                                           // TODO(?) Can 1 be returned |                                                 // TODO(?) Can 1 be returned | ||||||
|     if (fixMode == 1 || fixMode == 2 || fixMode == 3) { |     if (fixMode == 1 || fixMode == 2 || fixMode == 3) { | ||||||
|       // init variables |       // init variables | ||||||
|       float ilat         = 0; |       float ilat         = 0; | ||||||
| @@ -454,32 +454,33 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600>, | |||||||
|       int   imin         = 0; |       int   imin         = 0; | ||||||
|       float secondWithSS = 0; |       float secondWithSS = 0; | ||||||
|  |  | ||||||
|       streamSkipUntil(',');        // GPS satellite valid numbers |       streamSkipUntil(',');              // GPS satellite valid numbers | ||||||
|       streamSkipUntil(',');        // GLONASS satellite valid numbers |       streamSkipUntil(',');              // GLONASS satellite valid numbers | ||||||
|       streamSkipUntil(',');        // BEIDOU satellite valid numbers |       streamSkipUntil(',');              // BEIDOU satellite valid numbers | ||||||
|       ilat = streamGetFloat(',');  // Latitude |       ilat = streamGetFloatBefore(',');  // Latitude | ||||||
|       streamSkipUntil(',');        // N/S Indicator, N=north or S=south |       streamSkipUntil(',');              // N/S Indicator, N=north or S=south | ||||||
|       ilon = streamGetFloat(',');  // Longitude |       ilon = streamGetFloatBefore(',');  // Longitude | ||||||
|       streamSkipUntil(',');        // E/W Indicator, E=east or W=west |       streamSkipUntil(',');              // E/W Indicator, E=east or W=west | ||||||
|  |  | ||||||
|       // Date. Output format is ddmmyy |       // Date. Output format is ddmmyy | ||||||
|       iday   = streamGetInt(static_cast<int8_t>(2));  // Two digit day |       iday   = streamGetIntLength(2);    // Two digit day | ||||||
|       imonth = streamGetInt(static_cast<int8_t>(2));  // Two digit month |       imonth = streamGetIntLength(2);    // Two digit month | ||||||
|       iyear  = streamGetInt(',');                     // Two digit year |       iyear  = streamGetIntBefore(',');  // Two digit year | ||||||
|  |  | ||||||
|       // UTC Time. Output format is hhmmss.s |       // UTC Time. Output format is hhmmss.s | ||||||
|       ihour        = streamGetInt(static_cast<int8_t>(2));  // Two digit hour |       ihour = streamGetIntLength(2);  // Two digit hour | ||||||
|       imin         = streamGetInt(static_cast<int8_t>(2));  // Two digit minute |       imin  = streamGetIntLength(2);  // Two digit minute | ||||||
|       secondWithSS = streamGetFloat(',');  // 4 digit second with subseconds |       secondWithSS = | ||||||
|  |           streamGetFloatBefore(',');  // 4 digit second with subseconds | ||||||
|  |  | ||||||
|       ialt   = streamGetFloat(',');  // MSL Altitude. Unit is meters |       ialt   = streamGetFloatBefore(',');  // MSL Altitude. Unit is meters | ||||||
|       ispeed = streamGetFloat(',');  // Speed Over Ground. Unit is knots. |       ispeed = streamGetFloatBefore(',');  // Speed Over Ground. Unit is knots. | ||||||
|       streamSkipUntil(',');          // Course Over Ground. Degrees. |       streamSkipUntil(',');                // Course Over Ground. Degrees. | ||||||
|       streamSkipUntil(',');  // After set, will report GPS every x seconds |       streamSkipUntil(',');  // After set, will report GPS every x seconds | ||||||
|       iaccuracy = streamGetFloat(',');  // Position Dilution Of Precision |       iaccuracy = streamGetFloatBefore(',');  // Position Dilution Of Precision | ||||||
|       streamSkipUntil(',');             // Horizontal Dilution Of Precision |       streamSkipUntil(',');   // Horizontal Dilution Of Precision | ||||||
|       streamSkipUntil(',');             // Vertical Dilution Of Precision |       streamSkipUntil(',');   // Vertical Dilution Of Precision | ||||||
|       streamSkipUntil('\n');            // TODO(?) is one more field reported?? |       streamSkipUntil('\n');  // TODO(?) is one more field reported?? | ||||||
|  |  | ||||||
|       // Set pointers |       // Set pointers | ||||||
|       if (lat != NULL) *lat = ilat; |       if (lat != NULL) *lat = ilat; | ||||||
| @@ -521,7 +522,7 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600>, | |||||||
|     if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { return 0; } |     if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { return 0; } | ||||||
|  |  | ||||||
|     // get voltage in VOLTS |     // get voltage in VOLTS | ||||||
|     float voltage = streamGetFloat('\n'); |     float voltage = streamGetFloatBefore('\n'); | ||||||
|     // Wait for final OK |     // Wait for final OK | ||||||
|     waitResponse(); |     waitResponse(); | ||||||
|     // Return millivolts |     // Return millivolts | ||||||
| @@ -550,7 +551,7 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600>, | |||||||
|     sendAT(GF("+CPMUTEMP")); |     sendAT(GF("+CPMUTEMP")); | ||||||
|     if (waitResponse(GF(GSM_NL "+CPMUTEMP:")) != 1) { return 0; } |     if (waitResponse(GF(GSM_NL "+CPMUTEMP:")) != 1) { return 0; } | ||||||
|     // return temperature in C |     // return temperature in C | ||||||
|     uint16_t res = streamGetInt('\n'); |     uint16_t res = streamGetIntBefore('\n'); | ||||||
|     // Wait for final OK |     // Wait for final OK | ||||||
|     waitResponse(); |     waitResponse(); | ||||||
|     return res; |     return res; | ||||||
| @@ -585,7 +586,7 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600>, | |||||||
|     streamSkipUntil(',');  // Skip mux |     streamSkipUntil(',');  // Skip mux | ||||||
|     streamSkipUntil(',');  // Skip requested bytes to send |     streamSkipUntil(',');  // Skip requested bytes to send | ||||||
|     // TODO(?):  make sure requested and confirmed bytes match |     // TODO(?):  make sure requested and confirmed bytes match | ||||||
|     return streamGetInt('\n'); |     return streamGetIntBefore('\n'); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   size_t modemRead(size_t size, uint8_t mux) { |   size_t modemRead(size_t size, uint8_t mux) { | ||||||
| @@ -598,9 +599,9 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600>, | |||||||
| #endif | #endif | ||||||
|     streamSkipUntil(',');  // Skip Rx mode 2/normal or 3/HEX |     streamSkipUntil(',');  // Skip Rx mode 2/normal or 3/HEX | ||||||
|     streamSkipUntil(',');  // Skip mux/cid (connecion id) |     streamSkipUntil(',');  // Skip mux/cid (connecion id) | ||||||
|     int16_t len_requested = streamGetInt(','); |     int16_t len_requested = streamGetIntBefore(','); | ||||||
|     //  ^^ Requested number of data bytes (1-1460 bytes)to be read |     //  ^^ Requested number of data bytes (1-1460 bytes)to be read | ||||||
|     int16_t len_confirmed = streamGetInt('\n'); |     int16_t len_confirmed = streamGetIntBefore('\n'); | ||||||
|     // ^^ The data length which not read in the buffer |     // ^^ The data length which not read in the buffer | ||||||
|     for (int i = 0; i < len_requested; i++) { |     for (int i = 0; i < len_requested; i++) { | ||||||
|       uint32_t startMillis = millis(); |       uint32_t startMillis = millis(); | ||||||
| @@ -637,7 +638,7 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600>, | |||||||
|     if (waitResponse(GF("+CIPRXGET:")) == 1) { |     if (waitResponse(GF("+CIPRXGET:")) == 1) { | ||||||
|       streamSkipUntil(',');  // Skip mode 4 |       streamSkipUntil(',');  // Skip mode 4 | ||||||
|       streamSkipUntil(',');  // Skip mux |       streamSkipUntil(',');  // Skip mux | ||||||
|       result = streamGetInt('\n'); |       result = streamGetIntBefore('\n'); | ||||||
|       waitResponse(); |       waitResponse(); | ||||||
|     } |     } | ||||||
|     DBG("### Available:", result, "on", mux); |     DBG("### Available:", result, "on", mux); | ||||||
| @@ -704,9 +705,9 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600>, | |||||||
|           index = 5; |           index = 5; | ||||||
|           goto finish; |           goto finish; | ||||||
|         } else if (data.endsWith(GF(GSM_NL "+CIPRXGET:"))) { |         } else if (data.endsWith(GF(GSM_NL "+CIPRXGET:"))) { | ||||||
|           int8_t mode = streamGetInt(','); |           int8_t mode = streamGetIntBefore(','); | ||||||
|           if (mode == 1) { |           if (mode == 1) { | ||||||
|             int8_t mux = streamGetInt('\n'); |             int8_t mux = streamGetIntBefore('\n'); | ||||||
|             if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { |             if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { | ||||||
|               sockets[mux]->got_data = true; |               sockets[mux]->got_data = true; | ||||||
|             } |             } | ||||||
| @@ -716,8 +717,8 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600>, | |||||||
|             data += mode; |             data += mode; | ||||||
|           } |           } | ||||||
|         } else if (data.endsWith(GF(GSM_NL "+RECEIVE:"))) { |         } else if (data.endsWith(GF(GSM_NL "+RECEIVE:"))) { | ||||||
|           int8_t  mux = streamGetInt(','); |           int8_t  mux = streamGetIntBefore(','); | ||||||
|           int16_t len = streamGetInt('\n'); |           int16_t len = streamGetIntBefore('\n'); | ||||||
|           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { |           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { | ||||||
|             sockets[mux]->got_data       = true; |             sockets[mux]->got_data       = true; | ||||||
|             sockets[mux]->sock_available = len; |             sockets[mux]->sock_available = len; | ||||||
| @@ -725,7 +726,7 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600>, | |||||||
|           data = ""; |           data = ""; | ||||||
|           DBG("### Got Data:", len, "on", mux); |           DBG("### Got Data:", len, "on", mux); | ||||||
|         } else if (data.endsWith(GF("+IPCLOSE:"))) { |         } else if (data.endsWith(GF("+IPCLOSE:"))) { | ||||||
|           int8_t mux = streamGetInt(','); |           int8_t mux = streamGetIntBefore(','); | ||||||
|           streamSkipUntil('\n');  // Skip the reason code |           streamSkipUntil('\n');  // Skip the reason code | ||||||
|           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { |           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { | ||||||
|             sockets[mux]->sock_connected = false; |             sockets[mux]->sock_connected = false; | ||||||
|   | |||||||
| @@ -503,7 +503,7 @@ class TinyGsmSim800 | |||||||
|     stream.flush(); |     stream.flush(); | ||||||
|     if (waitResponse(GF(GSM_NL "DATA ACCEPT:")) != 1) { return 0; } |     if (waitResponse(GF(GSM_NL "DATA ACCEPT:")) != 1) { return 0; } | ||||||
|     streamSkipUntil(',');  // Skip mux |     streamSkipUntil(',');  // Skip mux | ||||||
|     return streamGetInt('\n'); |     return streamGetIntBefore('\n'); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   size_t modemRead(size_t size, uint8_t mux) { |   size_t modemRead(size_t size, uint8_t mux) { | ||||||
| @@ -516,9 +516,9 @@ class TinyGsmSim800 | |||||||
| #endif | #endif | ||||||
|     streamSkipUntil(',');  // Skip Rx mode 2/normal or 3/HEX |     streamSkipUntil(',');  // Skip Rx mode 2/normal or 3/HEX | ||||||
|     streamSkipUntil(',');  // Skip mux |     streamSkipUntil(',');  // Skip mux | ||||||
|     int16_t len_requested = streamGetInt(','); |     int16_t len_requested = streamGetIntBefore(','); | ||||||
|     //  ^^ Requested number of data bytes (1-1460 bytes)to be read |     //  ^^ Requested number of data bytes (1-1460 bytes)to be read | ||||||
|     int16_t len_confirmed = streamGetInt('\n'); |     int16_t len_confirmed = streamGetIntBefore('\n'); | ||||||
|     // ^^ Confirmed number of data bytes to be read, which may be less than |     // ^^ 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 |     // requested. 0 indicates that no data can be read. This is actually be the | ||||||
|     // number of bytes that will be remaining after the read |     // number of bytes that will be remaining after the read | ||||||
| @@ -557,7 +557,7 @@ class TinyGsmSim800 | |||||||
|     if (waitResponse(GF("+CIPRXGET:")) == 1) { |     if (waitResponse(GF("+CIPRXGET:")) == 1) { | ||||||
|       streamSkipUntil(',');  // Skip mode 4 |       streamSkipUntil(',');  // Skip mode 4 | ||||||
|       streamSkipUntil(',');  // Skip mux |       streamSkipUntil(',');  // Skip mux | ||||||
|       result = streamGetInt('\n'); |       result = streamGetIntBefore('\n'); | ||||||
|       waitResponse(); |       waitResponse(); | ||||||
|     } |     } | ||||||
|     DBG("### Available:", result, "on", mux); |     DBG("### Available:", result, "on", mux); | ||||||
| @@ -620,9 +620,9 @@ class TinyGsmSim800 | |||||||
|           index = 5; |           index = 5; | ||||||
|           goto finish; |           goto finish; | ||||||
|         } else if (data.endsWith(GF(GSM_NL "+CIPRXGET:"))) { |         } else if (data.endsWith(GF(GSM_NL "+CIPRXGET:"))) { | ||||||
|           int8_t mode = streamGetInt(','); |           int8_t mode = streamGetIntBefore(','); | ||||||
|           if (mode == 1) { |           if (mode == 1) { | ||||||
|             int8_t mux = streamGetInt('\n'); |             int8_t mux = streamGetIntBefore('\n'); | ||||||
|             if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { |             if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { | ||||||
|               sockets[mux]->got_data = true; |               sockets[mux]->got_data = true; | ||||||
|             } |             } | ||||||
| @@ -632,8 +632,8 @@ class TinyGsmSim800 | |||||||
|             data += mode; |             data += mode; | ||||||
|           } |           } | ||||||
|         } else if (data.endsWith(GF(GSM_NL "+RECEIVE:"))) { |         } else if (data.endsWith(GF(GSM_NL "+RECEIVE:"))) { | ||||||
|           int8_t  mux = streamGetInt(','); |           int8_t  mux = streamGetIntBefore(','); | ||||||
|           int16_t len = streamGetInt('\n'); |           int16_t len = streamGetIntBefore('\n'); | ||||||
|           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { |           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { | ||||||
|             sockets[mux]->got_data       = true; |             sockets[mux]->got_data       = true; | ||||||
|             sockets[mux]->sock_available = len; |             sockets[mux]->sock_available = len; | ||||||
|   | |||||||
| @@ -57,8 +57,8 @@ class TinyGsmSim808 : public TinyGsmSim800, public TinyGsmGPS<TinyGsmSim808> { | |||||||
|     sendAT(GF("+CGNSINF")); |     sendAT(GF("+CGNSINF")); | ||||||
|     if (waitResponse(10000L, GF(GSM_NL "+CGNSINF:")) != 1) { return false; } |     if (waitResponse(10000L, GF(GSM_NL "+CGNSINF:")) != 1) { return false; } | ||||||
|  |  | ||||||
|     streamSkipUntil(',');          // GNSS run status |     streamSkipUntil(',');                // GNSS run status | ||||||
|     if (streamGetInt(',') == 1) {  // fix status |     if (streamGetIntBefore(',') == 1) {  // fix status | ||||||
|       // init variables |       // init variables | ||||||
|       float ilat         = 0; |       float ilat         = 0; | ||||||
|       float ilon         = 0; |       float ilon         = 0; | ||||||
| @@ -75,31 +75,32 @@ class TinyGsmSim808 : public TinyGsmSim800, public TinyGsmGPS<TinyGsmSim808> { | |||||||
|       float secondWithSS = 0; |       float secondWithSS = 0; | ||||||
|  |  | ||||||
|       // UTC date & Time |       // UTC date & Time | ||||||
|       iyear        = streamGetInt(static_cast<int8_t>(4));  // Four digit year |       iyear  = streamGetIntLength(4);  // Four digit year | ||||||
|       imonth       = streamGetInt(static_cast<int8_t>(2));  // Two digit month |       imonth = streamGetIntLength(2);  // Two digit month | ||||||
|       iday         = streamGetInt(static_cast<int8_t>(2));  // Two digit day |       iday   = streamGetIntLength(2);  // Two digit day | ||||||
|       ihour        = streamGetInt(static_cast<int8_t>(2));  // Two digit hour |       ihour  = streamGetIntLength(2);  // Two digit hour | ||||||
|       imin         = streamGetInt(static_cast<int8_t>(2));  // Two digit minute |       imin   = streamGetIntLength(2);  // Two digit minute | ||||||
|       secondWithSS = streamGetFloat(',');  // 6 digit second with subseconds |       secondWithSS = | ||||||
|  |           streamGetFloatBefore(',');  // 6 digit second with subseconds | ||||||
|  |  | ||||||
|       ilat   = streamGetFloat(',');     // Latitude |       ilat   = streamGetFloatBefore(',');  // Latitude | ||||||
|       ilon   = streamGetFloat(',');     // Longitude |       ilon   = streamGetFloatBefore(',');  // Longitude | ||||||
|       ialt   = streamGetFloat(',');     // MSL Altitude. Unit is meters |       ialt   = streamGetFloatBefore(',');  // MSL Altitude. Unit is meters | ||||||
|       ispeed = streamGetFloat(',');     // Speed Over Ground. Unit is knots. |       ispeed = streamGetFloatBefore(',');  // Speed Over Ground. Unit is knots. | ||||||
|       streamSkipUntil(',');             // Course Over Ground. Degrees. |       streamSkipUntil(',');                // Course Over Ground. Degrees. | ||||||
|       streamSkipUntil(',');             // Fix Mode |       streamSkipUntil(',');                // Fix Mode | ||||||
|       streamSkipUntil(',');             // Reserved1 |       streamSkipUntil(',');                // Reserved1 | ||||||
|       streamSkipUntil(',');             // Horizontal Dilution Of Precision |       streamSkipUntil(',');                // Horizontal Dilution Of Precision | ||||||
|       iaccuracy = streamGetFloat(',');  // Position Dilution Of Precision |       iaccuracy = streamGetFloatBefore(',');  // Position Dilution Of Precision | ||||||
|       streamSkipUntil(',');             // Vertical Dilution Of Precision |       streamSkipUntil(',');                   // Vertical Dilution Of Precision | ||||||
|       streamSkipUntil(',');             // Reserved2 |       streamSkipUntil(',');                   // Reserved2 | ||||||
|       ivsat = streamGetInt(',');        // GNSS Satellites in View |       ivsat = streamGetIntBefore(',');        // GNSS Satellites in View | ||||||
|       iusat = streamGetInt(',');        // GNSS Satellites Used |       iusat = streamGetIntBefore(',');        // GNSS Satellites Used | ||||||
|       streamSkipUntil(',');             // GLONASS Satellites Used |       streamSkipUntil(',');                   // GLONASS Satellites Used | ||||||
|       streamSkipUntil(',');             // Reserved3 |       streamSkipUntil(',');                   // Reserved3 | ||||||
|       streamSkipUntil(',');             // C/N0 max |       streamSkipUntil(',');                   // C/N0 max | ||||||
|       streamSkipUntil(',');             // HPA |       streamSkipUntil(',');                   // HPA | ||||||
|       streamSkipUntil('\n');            // VPA |       streamSkipUntil('\n');                  // VPA | ||||||
|  |  | ||||||
|       // Set pointers |       // Set pointers | ||||||
|       if (lat != NULL) *lat = ilat; |       if (lat != NULL) *lat = ilat; | ||||||
|   | |||||||
| @@ -314,7 +314,7 @@ class TinyGsmSaraR4 | |||||||
|     sendAT(GF("+CEREG?")); |     sendAT(GF("+CEREG?")); | ||||||
|     if (waitResponse(GF(GSM_NL "+CEREG:")) != 1) { return REG_UNKNOWN; } |     if (waitResponse(GF(GSM_NL "+CEREG:")) != 1) { return REG_UNKNOWN; } | ||||||
|     streamSkipUntil(','); /* Skip format (0) */ |     streamSkipUntil(','); /* Skip format (0) */ | ||||||
|     int status = streamGetInt('\n'); |     int status = streamGetIntBefore('\n'); | ||||||
|     waitResponse(); |     waitResponse(); | ||||||
|  |  | ||||||
|     // If we're connected on EPS, great! |     // If we're connected on EPS, great! | ||||||
| @@ -326,7 +326,7 @@ class TinyGsmSaraR4 | |||||||
|       sendAT(GF("+CREG?")); |       sendAT(GF("+CREG?")); | ||||||
|       if (waitResponse(GF(GSM_NL "+CREG:")) != 1) { return REG_UNKNOWN; } |       if (waitResponse(GF(GSM_NL "+CREG:")) != 1) { return REG_UNKNOWN; } | ||||||
|       streamSkipUntil(','); /* Skip format (0) */ |       streamSkipUntil(','); /* Skip format (0) */ | ||||||
|       status = streamGetInt('\n'); |       status = streamGetIntBefore('\n'); | ||||||
|       waitResponse(); |       waitResponse(); | ||||||
|       return (RegStatus)status; |       return (RegStatus)status; | ||||||
|     } |     } | ||||||
| @@ -520,28 +520,31 @@ class TinyGsmSaraR4 | |||||||
|     float secondWithSS = 0; |     float secondWithSS = 0; | ||||||
|  |  | ||||||
|     // Date & Time |     // Date & Time | ||||||
|     iday         = streamGetInt('/');    // Two digit day |     iday         = streamGetIntBefore('/');    // Two digit day | ||||||
|     imonth       = streamGetInt('/');    // Two digit month |     imonth       = streamGetIntBefore('/');    // Two digit month | ||||||
|     iyear        = streamGetInt(',');    // Four digit year |     iyear        = streamGetIntBefore(',');    // Four digit year | ||||||
|     ihour        = streamGetInt(':');    // Two digit hour |     ihour        = streamGetIntBefore(':');    // Two digit hour | ||||||
|     imin         = streamGetInt(':');    // Two digit minute |     imin         = streamGetIntBefore(':');    // Two digit minute | ||||||
|     secondWithSS = streamGetFloat(',');  // 6 digit second with subseconds |     secondWithSS = streamGetFloatBefore(',');  // 6 digit second with subseconds | ||||||
|  |  | ||||||
|     ilat = streamGetFloat(',');  // Estimated latitude, in degrees |     ilat = streamGetFloatBefore(',');  // Estimated latitude, in degrees | ||||||
|     ilon = streamGetFloat(',');  // Estimated longitude, in degrees |     ilon = streamGetFloatBefore(',');  // Estimated longitude, in degrees | ||||||
|     ialt = streamGetFloat(',');  // Estimated altitude, in meters - only forGNSS |     ialt = streamGetFloatBefore( | ||||||
|                                  // positioning, 0 in case of CellLocate |         ',');         // Estimated altitude, in meters - only forGNSS | ||||||
|     if (ialt != 0) {             // values not returned for CellLocate |                       // positioning, 0 in case of CellLocate | ||||||
|       iaccuracy = streamGetFloat(',');  // Maximum possible error, in meters |     if (ialt != 0) {  // values not returned for CellLocate | ||||||
|       ispeed    = streamGetFloat(',');  // Speed over ground m/s3 |       iaccuracy = | ||||||
|  |           streamGetFloatBefore(',');       // Maximum possible error, in meters | ||||||
|  |       ispeed = streamGetFloatBefore(',');  // Speed over ground m/s3 | ||||||
|       streamSkipUntil(',');  // Course over ground in degree (0 deg - 360 deg) |       streamSkipUntil(',');  // Course over ground in degree (0 deg - 360 deg) | ||||||
|       streamSkipUntil(',');  // Vertical accuracy, in meters |       streamSkipUntil(',');  // Vertical accuracy, in meters | ||||||
|       streamSkipUntil(',');  // Sensor used for the position calculation |       streamSkipUntil(',');  // Sensor used for the position calculation | ||||||
|       iusat = streamGetInt(',');  // Number of satellite used |       iusat = streamGetIntBefore(',');  // Number of satellite used | ||||||
|       streamSkipUntil(',');       // Antenna status |       streamSkipUntil(',');             // Antenna status | ||||||
|       streamSkipUntil('\n');      // Jamming status |       streamSkipUntil('\n');            // Jamming status | ||||||
|     } else { |     } else { | ||||||
|       iaccuracy = streamGetFloat('\n');  // Maximum possible error, in meters |       iaccuracy = | ||||||
|  |           streamGetFloatBefore('\n');  // Maximum possible error, in meters | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     // Set pointers |     // Set pointers | ||||||
| @@ -594,7 +597,7 @@ class TinyGsmSaraR4 | |||||||
|     sendAT(GF("+CIND?")); |     sendAT(GF("+CIND?")); | ||||||
|     if (waitResponse(GF(GSM_NL "+CIND:")) != 1) { return 0; } |     if (waitResponse(GF(GSM_NL "+CIND:")) != 1) { return 0; } | ||||||
|  |  | ||||||
|     int8_t res     = streamGetInt(','); |     int8_t res     = streamGetIntBefore(','); | ||||||
|     int8_t percent = res * 20;  // return is 0-5 |     int8_t percent = res * 20;  // return is 0-5 | ||||||
|     // Wait for final OK |     // Wait for final OK | ||||||
|     waitResponse(); |     waitResponse(); | ||||||
| @@ -623,7 +626,7 @@ class TinyGsmSaraR4 | |||||||
|     if (waitResponse(GF(GSM_NL "+UTEMP:")) != 1) { |     if (waitResponse(GF(GSM_NL "+UTEMP:")) != 1) { | ||||||
|       return static_cast<float>(-9999); |       return static_cast<float>(-9999); | ||||||
|     } |     } | ||||||
|     int16_t res  = streamGetInt('\n'); |     int16_t res  = streamGetIntBefore('\n'); | ||||||
|     float   temp = -9999; |     float   temp = -9999; | ||||||
|     if (res != -1) { temp = (static_cast<float>(res)) / 10; } |     if (res != -1) { temp = (static_cast<float>(res)) / 10; } | ||||||
|     return temp; |     return temp; | ||||||
| @@ -642,7 +645,7 @@ class TinyGsmSaraR4 | |||||||
|     sendAT(GF("+USOCR=6")); |     sendAT(GF("+USOCR=6")); | ||||||
|     // reply is +USOCR: ## of socket created |     // reply is +USOCR: ## of socket created | ||||||
|     if (waitResponse(GF(GSM_NL "+USOCR:")) != 1) { return false; } |     if (waitResponse(GF(GSM_NL "+USOCR:")) != 1) { return false; } | ||||||
|     *mux = streamGetInt('\n'); |     *mux = streamGetIntBefore('\n'); | ||||||
|     waitResponse(); |     waitResponse(); | ||||||
|  |  | ||||||
|     if (ssl) { |     if (ssl) { | ||||||
| @@ -676,8 +679,8 @@ class TinyGsmSaraR4 | |||||||
|       sendAT(GF("+USOCO="), *mux, ",\"", host, "\",", port, ",1"); |       sendAT(GF("+USOCO="), *mux, ",\"", host, "\",", port, ",1"); | ||||||
|       if (waitResponse(timeout_ms - (millis() - startMillis), |       if (waitResponse(timeout_ms - (millis() - startMillis), | ||||||
|                        GF(GSM_NL "+UUSOCO:")) == 1) { |                        GF(GSM_NL "+UUSOCO:")) == 1) { | ||||||
|         streamGetInt(',');  // skip repeated mux |         streamGetIntBefore(',');  // skip repeated mux | ||||||
|         int8_t connection_status = streamGetInt('\n'); |         int8_t connection_status = streamGetIntBefore('\n'); | ||||||
|         DBG("### Waited", millis() - startMillis, "ms for socket to open"); |         DBG("### Waited", millis() - startMillis, "ms for socket to open"); | ||||||
|         return (0 == connection_status); |         return (0 == connection_status); | ||||||
|       } else { |       } else { | ||||||
| @@ -702,7 +705,7 @@ class TinyGsmSaraR4 | |||||||
|     stream.flush(); |     stream.flush(); | ||||||
|     if (waitResponse(GF(GSM_NL "+USOWR:")) != 1) { return 0; } |     if (waitResponse(GF(GSM_NL "+USOWR:")) != 1) { return 0; } | ||||||
|     streamSkipUntil(',');  // Skip mux |     streamSkipUntil(',');  // Skip mux | ||||||
|     int16_t sent = streamGetInt('\n'); |     int16_t sent = streamGetIntBefore('\n'); | ||||||
|     waitResponse();  // sends back OK after the confirmation of number sent |     waitResponse();  // sends back OK after the confirmation of number sent | ||||||
|     return sent; |     return sent; | ||||||
|   } |   } | ||||||
| @@ -711,7 +714,7 @@ class TinyGsmSaraR4 | |||||||
|     sendAT(GF("+USORD="), mux, ',', (uint16_t)size); |     sendAT(GF("+USORD="), mux, ',', (uint16_t)size); | ||||||
|     if (waitResponse(GF(GSM_NL "+USORD:")) != 1) { return 0; } |     if (waitResponse(GF(GSM_NL "+USORD:")) != 1) { return 0; } | ||||||
|     streamSkipUntil(',');  // Skip mux |     streamSkipUntil(',');  // Skip mux | ||||||
|     int16_t len = streamGetInt(','); |     int16_t len = streamGetIntBefore(','); | ||||||
|     streamSkipUntil('\"'); |     streamSkipUntil('\"'); | ||||||
|  |  | ||||||
|     for (int i = 0; i < len; i++) { moveCharFromStreamToFifo(mux); } |     for (int i = 0; i < len; i++) { moveCharFromStreamToFifo(mux); } | ||||||
| @@ -731,7 +734,7 @@ class TinyGsmSaraR4 | |||||||
|     // that you have already told to close |     // that you have already told to close | ||||||
|     if (res == 1) { |     if (res == 1) { | ||||||
|       streamSkipUntil(',');  // Skip mux |       streamSkipUntil(',');  // Skip mux | ||||||
|       result = streamGetInt('\n'); |       result = streamGetIntBefore('\n'); | ||||||
|       // if (result) DBG("### DATA AVAILABLE:", result, "on", mux); |       // if (result) DBG("### DATA AVAILABLE:", result, "on", mux); | ||||||
|       waitResponse(); |       waitResponse(); | ||||||
|     } |     } | ||||||
| @@ -748,7 +751,7 @@ class TinyGsmSaraR4 | |||||||
|  |  | ||||||
|     streamSkipUntil(',');  // Skip mux |     streamSkipUntil(',');  // Skip mux | ||||||
|     streamSkipUntil(',');  // Skip type |     streamSkipUntil(',');  // Skip type | ||||||
|     int8_t result = streamGetInt('\n'); |     int8_t result = streamGetIntBefore('\n'); | ||||||
|     // 0: the socket is in INACTIVE status (it corresponds to CLOSED status |     // 0: the socket is in INACTIVE status (it corresponds to CLOSED status | ||||||
|     // defined in RFC793 "TCP Protocol Specification" [112]) |     // defined in RFC793 "TCP Protocol Specification" [112]) | ||||||
|     // 1: the socket is in LISTEN status |     // 1: the socket is in LISTEN status | ||||||
| @@ -810,8 +813,8 @@ class TinyGsmSaraR4 | |||||||
|           index = 5; |           index = 5; | ||||||
|           goto finish; |           goto finish; | ||||||
|         } else if (data.endsWith(GF("+UUSORD:"))) { |         } else if (data.endsWith(GF("+UUSORD:"))) { | ||||||
|           int8_t  mux = streamGetInt(','); |           int8_t  mux = streamGetIntBefore(','); | ||||||
|           int16_t len = streamGetInt('\n'); |           int16_t len = streamGetIntBefore('\n'); | ||||||
|           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { |           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { | ||||||
|             sockets[mux]->got_data       = true; |             sockets[mux]->got_data       = true; | ||||||
|             sockets[mux]->sock_available = len; |             sockets[mux]->sock_available = len; | ||||||
| @@ -819,15 +822,15 @@ class TinyGsmSaraR4 | |||||||
|           data = ""; |           data = ""; | ||||||
|           DBG("### URC Data Received:", len, "on", mux); |           DBG("### URC Data Received:", len, "on", mux); | ||||||
|         } else if (data.endsWith(GF("+UUSOCL:"))) { |         } else if (data.endsWith(GF("+UUSOCL:"))) { | ||||||
|           int8_t mux = streamGetInt('\n'); |           int8_t mux = streamGetIntBefore('\n'); | ||||||
|           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { |           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { | ||||||
|             sockets[mux]->sock_connected = false; |             sockets[mux]->sock_connected = false; | ||||||
|           } |           } | ||||||
|           data = ""; |           data = ""; | ||||||
|           DBG("### URC Sock Closed: ", mux); |           DBG("### URC Sock Closed: ", mux); | ||||||
|         } else if (data.endsWith(GF("+UUSOCO:"))) { |         } else if (data.endsWith(GF("+UUSOCO:"))) { | ||||||
|           int8_t mux          = streamGetInt('\n'); |           int8_t mux          = streamGetIntBefore('\n'); | ||||||
|           int8_t socket_error = streamGetInt('\n'); |           int8_t socket_error = streamGetIntBefore('\n'); | ||||||
|           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux] && |           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux] && | ||||||
|               socket_error == 0) { |               socket_error == 0) { | ||||||
|             sockets[mux]->sock_connected = true; |             sockets[mux]->sock_connected = true; | ||||||
|   | |||||||
| @@ -496,7 +496,7 @@ class TinyGsmSequansMonarch | |||||||
|     sendAT(GF("+SQNSRECV="), mux, ',', (uint16_t)size); |     sendAT(GF("+SQNSRECV="), mux, ',', (uint16_t)size); | ||||||
|     if (waitResponse(GF("+SQNSRECV: ")) != 1) { return 0; } |     if (waitResponse(GF("+SQNSRECV: ")) != 1) { return 0; } | ||||||
|     streamSkipUntil(',');  // Skip mux |     streamSkipUntil(',');  // Skip mux | ||||||
|     int16_t len = streamGetInt('\n'); |     int16_t len = streamGetIntBefore('\n'); | ||||||
|     for (int i = 0; i < len; i++) { |     for (int i = 0; i < len; i++) { | ||||||
|       uint32_t startMillis = millis(); |       uint32_t startMillis = millis(); | ||||||
|       while (!stream.available() && |       while (!stream.available() && | ||||||
| @@ -517,10 +517,10 @@ class TinyGsmSequansMonarch | |||||||
|     sendAT(GF("+SQNSI="), mux); |     sendAT(GF("+SQNSI="), mux); | ||||||
|     size_t result = 0; |     size_t result = 0; | ||||||
|     if (waitResponse(GF("+SQNSI:")) == 1) { |     if (waitResponse(GF("+SQNSI:")) == 1) { | ||||||
|       streamSkipUntil(',');        // Skip mux |       streamSkipUntil(',');              // Skip mux | ||||||
|       streamSkipUntil(',');        // Skip total sent |       streamSkipUntil(',');              // Skip total sent | ||||||
|       streamSkipUntil(',');        // Skip total received |       streamSkipUntil(',');              // Skip total received | ||||||
|       result = streamGetInt(',');  // keep data not yet read |       result = streamGetIntBefore(',');  // keep data not yet read | ||||||
|       waitResponse(); |       waitResponse(); | ||||||
|     } |     } | ||||||
|     DBG("### Available:", result, "on", mux); |     DBG("### Available:", result, "on", mux); | ||||||
| @@ -534,7 +534,7 @@ class TinyGsmSequansMonarch | |||||||
|     for (int muxNo = 1; muxNo <= TINY_GSM_MUX_COUNT; muxNo++) { |     for (int muxNo = 1; muxNo <= TINY_GSM_MUX_COUNT; muxNo++) { | ||||||
|       if (waitResponse(GFP(GSM_OK), GF(GSM_NL "+SQNSS: ")) != 2) { break; } |       if (waitResponse(GFP(GSM_OK), GF(GSM_NL "+SQNSS: ")) != 2) { break; } | ||||||
|       uint8_t status = 0; |       uint8_t status = 0; | ||||||
|       // if (streamGetInt(',') != muxNo) { // check the mux no |       // if (streamGetIntBefore(',') != muxNo) { // check the mux no | ||||||
|       //   DBG("### Warning: misaligned mux numbers!"); |       //   DBG("### Warning: misaligned mux numbers!"); | ||||||
|       // } |       // } | ||||||
|       streamSkipUntil(',');        // skip mux [use muxNo] |       streamSkipUntil(',');        // skip mux [use muxNo] | ||||||
| @@ -602,8 +602,8 @@ class TinyGsmSequansMonarch | |||||||
|           index = 5; |           index = 5; | ||||||
|           goto finish; |           goto finish; | ||||||
|         } else if (data.endsWith(GF(GSM_NL "+SQNSRING:"))) { |         } else if (data.endsWith(GF(GSM_NL "+SQNSRING:"))) { | ||||||
|           int8_t  mux = streamGetInt(','); |           int8_t  mux = streamGetIntBefore(','); | ||||||
|           int16_t len = streamGetInt('\n'); |           int16_t len = streamGetIntBefore('\n'); | ||||||
|           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && |           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && | ||||||
|               sockets[mux % TINY_GSM_MUX_COUNT]) { |               sockets[mux % TINY_GSM_MUX_COUNT]) { | ||||||
|             sockets[mux % TINY_GSM_MUX_COUNT]->got_data       = true; |             sockets[mux % TINY_GSM_MUX_COUNT]->got_data       = true; | ||||||
| @@ -612,7 +612,7 @@ class TinyGsmSequansMonarch | |||||||
|           data = ""; |           data = ""; | ||||||
|           DBG("### URC Data Received:", len, "on", mux); |           DBG("### URC Data Received:", len, "on", mux); | ||||||
|         } else if (data.endsWith(GF("SQNSH: "))) { |         } else if (data.endsWith(GF("SQNSH: "))) { | ||||||
|           int8_t mux = streamGetInt('\n'); |           int8_t mux = streamGetIntBefore('\n'); | ||||||
|           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && |           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && | ||||||
|               sockets[mux % TINY_GSM_MUX_COUNT]) { |               sockets[mux % TINY_GSM_MUX_COUNT]) { | ||||||
|             sockets[mux % TINY_GSM_MUX_COUNT]->sock_connected = false; |             sockets[mux % TINY_GSM_MUX_COUNT]->sock_connected = false; | ||||||
|   | |||||||
| @@ -487,28 +487,31 @@ class TinyGsmUBLOX | |||||||
|     float secondWithSS = 0; |     float secondWithSS = 0; | ||||||
|  |  | ||||||
|     // Date & Time |     // Date & Time | ||||||
|     iday         = streamGetInt('/');    // Two digit day |     iday         = streamGetIntBefore('/');    // Two digit day | ||||||
|     imonth       = streamGetInt('/');    // Two digit month |     imonth       = streamGetIntBefore('/');    // Two digit month | ||||||
|     iyear        = streamGetInt(',');    // Four digit year |     iyear        = streamGetIntBefore(',');    // Four digit year | ||||||
|     ihour        = streamGetInt(':');    // Two digit hour |     ihour        = streamGetIntBefore(':');    // Two digit hour | ||||||
|     imin         = streamGetInt(':');    // Two digit minute |     imin         = streamGetIntBefore(':');    // Two digit minute | ||||||
|     secondWithSS = streamGetFloat(',');  // 6 digit second with subseconds |     secondWithSS = streamGetFloatBefore(',');  // 6 digit second with subseconds | ||||||
|  |  | ||||||
|     ilat = streamGetFloat(',');  // Estimated latitude, in degrees |     ilat = streamGetFloatBefore(',');  // Estimated latitude, in degrees | ||||||
|     ilon = streamGetFloat(',');  // Estimated longitude, in degrees |     ilon = streamGetFloatBefore(',');  // Estimated longitude, in degrees | ||||||
|     ialt = streamGetFloat(',');  // Estimated altitude, in meters - only forGNSS |     ialt = streamGetFloatBefore( | ||||||
|                                  // positioning, 0 in case of CellLocate |         ',');         // Estimated altitude, in meters - only forGNSS | ||||||
|     if (ialt != 0) {             // values not returned for CellLocate |                       // positioning, 0 in case of CellLocate | ||||||
|       iaccuracy = streamGetFloat(',');  // Maximum possible error, in meters |     if (ialt != 0) {  // values not returned for CellLocate | ||||||
|       ispeed    = streamGetFloat(',');  // Speed over ground m/s3 |       iaccuracy = | ||||||
|  |           streamGetFloatBefore(',');       // Maximum possible error, in meters | ||||||
|  |       ispeed = streamGetFloatBefore(',');  // Speed over ground m/s3 | ||||||
|       streamSkipUntil(',');  // Course over ground in degree (0 deg - 360 deg) |       streamSkipUntil(',');  // Course over ground in degree (0 deg - 360 deg) | ||||||
|       streamSkipUntil(',');  // Vertical accuracy, in meters |       streamSkipUntil(',');  // Vertical accuracy, in meters | ||||||
|       streamSkipUntil(',');  // Sensor used for the position calculation |       streamSkipUntil(',');  // Sensor used for the position calculation | ||||||
|       iusat = streamGetInt(',');  // Number of satellite used |       iusat = streamGetIntBefore(',');  // Number of satellite used | ||||||
|       streamSkipUntil(',');       // Antenna status |       streamSkipUntil(',');             // Antenna status | ||||||
|       streamSkipUntil('\n');      // Jamming status |       streamSkipUntil('\n');            // Jamming status | ||||||
|     } else { |     } else { | ||||||
|       iaccuracy = streamGetFloat('\n');  // Maximum possible error, in meters |       iaccuracy = | ||||||
|  |           streamGetFloatBefore('\n');  // Maximum possible error, in meters | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     // Set pointers |     // Set pointers | ||||||
| @@ -561,7 +564,7 @@ class TinyGsmUBLOX | |||||||
|     sendAT(GF("+CIND?")); |     sendAT(GF("+CIND?")); | ||||||
|     if (waitResponse(GF(GSM_NL "+CIND:")) != 1) { return 0; } |     if (waitResponse(GF(GSM_NL "+CIND:")) != 1) { return 0; } | ||||||
|  |  | ||||||
|     int8_t res     = streamGetInt(','); |     int8_t res     = streamGetIntBefore(','); | ||||||
|     int8_t percent = res * 20;  // return is 0-5 |     int8_t percent = res * 20;  // return is 0-5 | ||||||
|     // Wait for final OK |     // Wait for final OK | ||||||
|     waitResponse(); |     waitResponse(); | ||||||
| @@ -599,7 +602,7 @@ class TinyGsmUBLOX | |||||||
|     sendAT(GF("+USOCR=6")); |     sendAT(GF("+USOCR=6")); | ||||||
|     // reply is +USOCR: ## of socket created |     // reply is +USOCR: ## of socket created | ||||||
|     if (waitResponse(GF(GSM_NL "+USOCR:")) != 1) { return false; } |     if (waitResponse(GF(GSM_NL "+USOCR:")) != 1) { return false; } | ||||||
|     *mux = streamGetInt('\n'); |     *mux = streamGetIntBefore('\n'); | ||||||
|     waitResponse(); |     waitResponse(); | ||||||
|  |  | ||||||
|     if (ssl) { |     if (ssl) { | ||||||
| @@ -634,7 +637,7 @@ class TinyGsmUBLOX | |||||||
|     stream.flush(); |     stream.flush(); | ||||||
|     if (waitResponse(GF(GSM_NL "+USOWR:")) != 1) { return 0; } |     if (waitResponse(GF(GSM_NL "+USOWR:")) != 1) { return 0; } | ||||||
|     streamSkipUntil(',');  // Skip mux |     streamSkipUntil(',');  // Skip mux | ||||||
|     int16_t sent = streamGetInt('\n'); |     int16_t sent = streamGetIntBefore('\n'); | ||||||
|     waitResponse();  // sends back OK after the confirmation of number sent |     waitResponse();  // sends back OK after the confirmation of number sent | ||||||
|     return sent; |     return sent; | ||||||
|   } |   } | ||||||
| @@ -643,7 +646,7 @@ class TinyGsmUBLOX | |||||||
|     sendAT(GF("+USORD="), mux, ',', (uint16_t)size); |     sendAT(GF("+USORD="), mux, ',', (uint16_t)size); | ||||||
|     if (waitResponse(GF(GSM_NL "+USORD:")) != 1) { return 0; } |     if (waitResponse(GF(GSM_NL "+USORD:")) != 1) { return 0; } | ||||||
|     streamSkipUntil(',');  // Skip mux |     streamSkipUntil(',');  // Skip mux | ||||||
|     int16_t len = streamGetInt(','); |     int16_t len = streamGetIntBefore(','); | ||||||
|     streamSkipUntil('\"'); |     streamSkipUntil('\"'); | ||||||
|  |  | ||||||
|     for (int i = 0; i < len; i++) { moveCharFromStreamToFifo(mux); } |     for (int i = 0; i < len; i++) { moveCharFromStreamToFifo(mux); } | ||||||
| @@ -663,7 +666,7 @@ class TinyGsmUBLOX | |||||||
|     // that you have already told to close |     // that you have already told to close | ||||||
|     if (res == 1) { |     if (res == 1) { | ||||||
|       streamSkipUntil(',');  // Skip mux |       streamSkipUntil(',');  // Skip mux | ||||||
|       result = streamGetInt('\n'); |       result = streamGetIntBefore('\n'); | ||||||
|       // if (result) DBG("### DATA AVAILABLE:", result, "on", mux); |       // if (result) DBG("### DATA AVAILABLE:", result, "on", mux); | ||||||
|       waitResponse(); |       waitResponse(); | ||||||
|     } |     } | ||||||
| @@ -680,7 +683,7 @@ class TinyGsmUBLOX | |||||||
|  |  | ||||||
|     streamSkipUntil(',');  // Skip mux |     streamSkipUntil(',');  // Skip mux | ||||||
|     streamSkipUntil(',');  // Skip type |     streamSkipUntil(',');  // Skip type | ||||||
|     int8_t result = streamGetInt('\n'); |     int8_t result = streamGetIntBefore('\n'); | ||||||
|     // 0: the socket is in INACTIVE status (it corresponds to CLOSED status |     // 0: the socket is in INACTIVE status (it corresponds to CLOSED status | ||||||
|     // defined in RFC793 "TCP Protocol Specification" [112]) |     // defined in RFC793 "TCP Protocol Specification" [112]) | ||||||
|     // 1: the socket is in LISTEN status |     // 1: the socket is in LISTEN status | ||||||
| @@ -742,8 +745,8 @@ class TinyGsmUBLOX | |||||||
|           index = 5; |           index = 5; | ||||||
|           goto finish; |           goto finish; | ||||||
|         } else if (data.endsWith(GF("+UUSORD:"))) { |         } else if (data.endsWith(GF("+UUSORD:"))) { | ||||||
|           int8_t  mux = streamGetInt(','); |           int8_t  mux = streamGetIntBefore(','); | ||||||
|           int16_t len = streamGetInt('\n'); |           int16_t len = streamGetIntBefore('\n'); | ||||||
|           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { |           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { | ||||||
|             sockets[mux]->got_data       = true; |             sockets[mux]->got_data       = true; | ||||||
|             sockets[mux]->sock_available = len; |             sockets[mux]->sock_available = len; | ||||||
| @@ -751,7 +754,7 @@ class TinyGsmUBLOX | |||||||
|           data = ""; |           data = ""; | ||||||
|           DBG("### URC Data Received:", len, "on", mux); |           DBG("### URC Data Received:", len, "on", mux); | ||||||
|         } else if (data.endsWith(GF("+UUSOCL:"))) { |         } else if (data.endsWith(GF("+UUSOCL:"))) { | ||||||
|           int8_t mux = streamGetInt('\n'); |           int8_t mux = streamGetIntBefore('\n'); | ||||||
|           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { |           if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { | ||||||
|             sockets[mux]->sock_connected = false; |             sockets[mux]->sock_connected = false; | ||||||
|           } |           } | ||||||
|   | |||||||
| @@ -153,7 +153,7 @@ class TinyGsmGPRS { | |||||||
|   bool isGprsConnectedImpl() { |   bool isGprsConnectedImpl() { | ||||||
|     thisModem().sendAT(GF("+CGATT?")); |     thisModem().sendAT(GF("+CGATT?")); | ||||||
|     if (thisModem().waitResponse(GF("+CGATT:")) != 1) { return false; } |     if (thisModem().waitResponse(GF("+CGATT:")) != 1) { return false; } | ||||||
|     int8_t res = thisModem().streamGetInt('\n'); |     int8_t res = thisModem().streamGetIntBefore('\n'); | ||||||
|     thisModem().waitResponse(); |     thisModem().waitResponse(); | ||||||
|     if (res != 1) { return false; } |     if (res != 1) { return false; } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -105,17 +105,17 @@ class TinyGsmGSMLocation { | |||||||
|     int   imin      = 0; |     int   imin      = 0; | ||||||
|     int   isec      = 0; |     int   isec      = 0; | ||||||
|  |  | ||||||
|     ilat      = thisModem().streamGetFloat(',');  // Latitude |     ilat      = thisModem().streamGetFloatBefore(',');  // Latitude | ||||||
|     ilon      = thisModem().streamGetFloat(',');  // Longitude |     ilon      = thisModem().streamGetFloatBefore(',');  // Longitude | ||||||
|     iaccuracy = thisModem().streamGetInt(',');    // Positioning accuracy |     iaccuracy = thisModem().streamGetIntBefore(',');    // Positioning accuracy | ||||||
|  |  | ||||||
|     // Date & Time |     // Date & Time | ||||||
|     iyear  = thisModem().streamGetInt('/'); |     iyear  = thisModem().streamGetIntBefore('/'); | ||||||
|     imonth = thisModem().streamGetInt('/'); |     imonth = thisModem().streamGetIntBefore('/'); | ||||||
|     iday   = thisModem().streamGetInt(','); |     iday   = thisModem().streamGetIntBefore(','); | ||||||
|     ihour  = thisModem().streamGetInt(':'); |     ihour  = thisModem().streamGetIntBefore(':'); | ||||||
|     imin   = thisModem().streamGetInt(':'); |     imin   = thisModem().streamGetIntBefore(':'); | ||||||
|     isec   = thisModem().streamGetInt('\n'); |     isec   = thisModem().streamGetIntBefore('\n'); | ||||||
|  |  | ||||||
|     // Set pointers |     // Set pointers | ||||||
|     if (lat != NULL) *lat = ilat; |     if (lat != NULL) *lat = ilat; | ||||||
|   | |||||||
| @@ -187,7 +187,7 @@ class TinyGsmModem { | |||||||
|                                            GF("+CEREG:")); |                                            GF("+CEREG:")); | ||||||
|     if (resp != 1 && resp != 2 && resp != 3) { return -1; } |     if (resp != 1 && resp != 2 && resp != 3) { return -1; } | ||||||
|     thisModem().streamSkipUntil(','); /* Skip format (0) */ |     thisModem().streamSkipUntil(','); /* Skip format (0) */ | ||||||
|     int status = thisModem().streamGetInt('\n'); |     int status = thisModem().streamGetIntBefore('\n'); | ||||||
|     thisModem().waitResponse(); |     thisModem().waitResponse(); | ||||||
|     return status; |     return status; | ||||||
|   } |   } | ||||||
| @@ -204,7 +204,7 @@ class TinyGsmModem { | |||||||
|   int8_t getSignalQualityImpl() { |   int8_t getSignalQualityImpl() { | ||||||
|     thisModem().sendAT(GF("+CSQ")); |     thisModem().sendAT(GF("+CSQ")); | ||||||
|     if (thisModem().waitResponse(GF("+CSQ:")) != 1) { return 99; } |     if (thisModem().waitResponse(GF("+CSQ:")) != 1) { return 99; } | ||||||
|     int8_t res = thisModem().streamGetInt(','); |     int8_t res = thisModem().streamGetIntBefore(','); | ||||||
|     thisModem().waitResponse(); |     thisModem().waitResponse(); | ||||||
|     return res; |     return res; | ||||||
|   } |   } | ||||||
| @@ -255,7 +255,7 @@ class TinyGsmModem { | |||||||
|     thisModem().streamWrite(tail...); |     thisModem().streamWrite(tail...); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   inline int16_t streamGetInt(int8_t numChars) { |   inline int16_t streamGetIntLength(int8_t numChars) { | ||||||
|     char   buf[6]; |     char   buf[6]; | ||||||
|     size_t bytesRead = thisModem().stream.readBytes(buf, numChars); |     size_t bytesRead = thisModem().stream.readBytes(buf, numChars); | ||||||
|     if (bytesRead) { |     if (bytesRead) { | ||||||
| @@ -267,9 +267,7 @@ class TinyGsmModem { | |||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <class T> |   inline int16_t streamGetIntBefore(char lastChar) { | ||||||
|   // calling with template only to prevent promotion of char to int |  | ||||||
|   inline int16_t streamGetInt(T lastChar) { |  | ||||||
|     char   buf[6]; |     char   buf[6]; | ||||||
|     size_t bytesRead = thisModem().stream.readBytesUntil( |     size_t bytesRead = thisModem().stream.readBytesUntil( | ||||||
|         lastChar, buf, static_cast<size_t>(6)); |         lastChar, buf, static_cast<size_t>(6)); | ||||||
| @@ -282,7 +280,7 @@ class TinyGsmModem { | |||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   inline float streamGetFloat(int8_t numChars) { |   inline float streamGetFloatLength(int8_t numChars) { | ||||||
|     char   buf[16]; |     char   buf[16]; | ||||||
|     size_t bytesRead = thisModem().stream.readBytes(buf, numChars); |     size_t bytesRead = thisModem().stream.readBytes(buf, numChars); | ||||||
|     DBG("### bytesRead:", bytesRead); |     DBG("### bytesRead:", bytesRead); | ||||||
| @@ -295,9 +293,7 @@ class TinyGsmModem { | |||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <class T> |   inline float streamGetFloatBefore(char lastChar) { | ||||||
|   // calling with template only to prevent promotion of char to int |  | ||||||
|   inline float streamGetFloat(T lastChar) { |  | ||||||
|     char   buf[16]; |     char   buf[16]; | ||||||
|     size_t bytesRead = thisModem().stream.readBytesUntil( |     size_t bytesRead = thisModem().stream.readBytesUntil( | ||||||
|         lastChar, buf, static_cast<size_t>(16)); |         lastChar, buf, static_cast<size_t>(16)); | ||||||
|   | |||||||
| @@ -125,7 +125,7 @@ class TinyGsmSMS { | |||||||
|     thisModem().stream.readStringUntil('"'); |     thisModem().stream.readStringUntil('"'); | ||||||
|     String hex = thisModem().stream.readStringUntil('"'); |     String hex = thisModem().stream.readStringUntil('"'); | ||||||
|     thisModem().stream.readStringUntil(','); |     thisModem().stream.readStringUntil(','); | ||||||
|     int8_t dcs = thisModem().streamGetInt('\n'); |     int8_t dcs = thisModem().streamGetIntBefore('\n'); | ||||||
|  |  | ||||||
|     if (dcs == 15) { |     if (dcs == 15) { | ||||||
|       return TinyGsmDecodeHex8bit(hex); |       return TinyGsmDecodeHex8bit(hex); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user