|
|
@ -410,25 +410,28 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600, READ_AND_CHECK_SIZE, |
|
|
|
sendAT(GF("+CGNSSINFO")); |
|
|
|
if (waitResponse(GF(GSM_NL "+CGNSSINFO:")) != 1) { return false; } |
|
|
|
|
|
|
|
// stream.readStringUntil(','); // mode |
|
|
|
if (stream.readStringUntil(',').toInt() == 1) fix = true; |
|
|
|
stream.readStringUntil(','); // gps |
|
|
|
stream.readStringUntil(','); // glonass |
|
|
|
stream.readStringUntil(','); // beidu |
|
|
|
*lat = stream.readStringUntil(',').toFloat(); // lat |
|
|
|
stream.readStringUntil(','); // N/S |
|
|
|
*lon = stream.readStringUntil(',').toFloat(); // lon |
|
|
|
stream.readStringUntil(','); // E/W |
|
|
|
stream.readStringUntil(','); // date |
|
|
|
stream.readStringUntil(','); // UTC time |
|
|
|
if (alt != NULL) *alt = stream.readStringUntil(',').toFloat(); // alt |
|
|
|
if (speed != NULL) *speed = stream.readStringUntil(',').toFloat(); // speed |
|
|
|
stream.readStringUntil(','); // course |
|
|
|
stream.readStringUntil(','); // time |
|
|
|
stream.readStringUntil(','); // PDOP |
|
|
|
stream.readStringUntil(','); // HDOP |
|
|
|
stream.readStringUntil(','); // VDOP |
|
|
|
stream.readStringUntil('\n'); |
|
|
|
// streamSkipUntil(','); // mode |
|
|
|
if (streamGetInt(',') == 1) |
|
|
|
fix = true; // TODO(?) Shouldn't this be 2=2D Fix or 3=3DFix? |
|
|
|
streamSkipUntil(','); // GPS satellite valid numbers |
|
|
|
streamSkipUntil(','); // GLONASS satellite valid numbers |
|
|
|
streamSkipUntil(','); // BEIDOU satellite valid numbers |
|
|
|
*lat = streamGetFloat(','); // Latitude |
|
|
|
streamSkipUntil(','); // N/S Indicator, N=north or S=south |
|
|
|
*lon = streamGetFloat(','); // Longitude |
|
|
|
streamSkipUntil(','); // E/W Indicator, E=east or W=west |
|
|
|
streamSkipUntil(','); // Date. Output format is ddmmyy |
|
|
|
streamSkipUntil(','); // UTC Time. Output format is hhmmss.s |
|
|
|
if (alt != NULL) |
|
|
|
*alt = streamGetFloat(','); // MSL Altitude. Unit is meters |
|
|
|
if (speed != NULL) |
|
|
|
*speed = streamGetFloat(','); // Speed Over Ground. Unit is knots. |
|
|
|
streamSkipUntil(','); // Course. Degrees. |
|
|
|
streamSkipUntil(','); // After set, will report GPS every x seconds |
|
|
|
streamSkipUntil(','); // Position Dilution Of Precision |
|
|
|
streamSkipUntil(','); // Horizontal Dilution Of Precision |
|
|
|
streamSkipUntil(','); // Vertical Dilution Of Precision |
|
|
|
streamSkipUntil('\n'); // TODO(?) is one more field reported?? |
|
|
|
|
|
|
|
waitResponse(); |
|
|
|
|
|
|
@ -451,7 +454,7 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600, READ_AND_CHECK_SIZE, |
|
|
|
if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { return 0; } |
|
|
|
|
|
|
|
// get voltage in VOLTS |
|
|
|
float voltage = stream.readStringUntil('\n').toFloat(); |
|
|
|
float voltage = streamGetFloat('\n'); |
|
|
|
// Wait for final OK |
|
|
|
waitResponse(); |
|
|
|
// Return millivolts |
|
|
@ -476,7 +479,7 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600, READ_AND_CHECK_SIZE, |
|
|
|
sendAT(GF("+CPMUTEMP")); |
|
|
|
if (waitResponse(GF(GSM_NL "+CPMUTEMP:")) != 1) { return 0; } |
|
|
|
// return temperature in C |
|
|
|
uint16_t res = stream.readStringUntil('\n').toInt(); |
|
|
|
uint16_t res = streamGetInt('\n'); |
|
|
|
// Wait for final OK |
|
|
|
waitResponse(); |
|
|
|
return res; |
|
|
@ -511,7 +514,7 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600, READ_AND_CHECK_SIZE, |
|
|
|
streamSkipUntil(','); // Skip mux |
|
|
|
streamSkipUntil(','); // Skip requested bytes to send |
|
|
|
// TODO(?): make sure requested and confirmed bytes match |
|
|
|
return stream.readStringUntil('\n').toInt(); |
|
|
|
return streamGetInt('\n'); |
|
|
|
} |
|
|
|
|
|
|
|
size_t modemRead(size_t size, uint8_t mux) { |
|
|
@ -524,9 +527,9 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600, READ_AND_CHECK_SIZE, |
|
|
|
#endif |
|
|
|
streamSkipUntil(','); // Skip Rx mode 2/normal or 3/HEX |
|
|
|
streamSkipUntil(','); // Skip mux/cid (connecion id) |
|
|
|
int len_requested = stream.readStringUntil(',').toInt(); |
|
|
|
int len_requested = streamGetInt(','); |
|
|
|
// ^^ Requested number of data bytes (1-1460 bytes)to be read |
|
|
|
int len_confirmed = stream.readStringUntil('\n').toInt(); |
|
|
|
int len_confirmed = streamGetInt('\n'); |
|
|
|
// ^^ The data length which not read in the buffer |
|
|
|
for (int i = 0; i < len_requested; i++) { |
|
|
|
uint32_t startMillis = millis(); |
|
|
@ -563,7 +566,7 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600, READ_AND_CHECK_SIZE, |
|
|
|
if (waitResponse(GF("+CIPRXGET:")) == 1) { |
|
|
|
streamSkipUntil(','); // Skip mode 4 |
|
|
|
streamSkipUntil(','); // Skip mux |
|
|
|
result = stream.readStringUntil('\n').toInt(); |
|
|
|
result = streamGetInt('\n'); |
|
|
|
waitResponse(); |
|
|
|
} |
|
|
|
DBG("### Available:", result, "on", mux); |
|
|
@ -630,9 +633,9 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600, READ_AND_CHECK_SIZE, |
|
|
|
index = 5; |
|
|
|
goto finish; |
|
|
|
} else if (data.endsWith(GF(GSM_NL "+CIPRXGET:"))) { |
|
|
|
String mode = stream.readStringUntil(','); |
|
|
|
if (mode.toInt() == 1) { |
|
|
|
int mux = stream.readStringUntil('\n').toInt(); |
|
|
|
int mode = streamGetInt(','); |
|
|
|
if (mode == 1) { |
|
|
|
int mux = streamGetInt('\n'); |
|
|
|
if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { |
|
|
|
sockets[mux]->got_data = true; |
|
|
|
} |
|
|
@ -642,8 +645,8 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600, READ_AND_CHECK_SIZE, |
|
|
|
data += mode; |
|
|
|
} |
|
|
|
} else if (data.endsWith(GF(GSM_NL "+RECEIVE:"))) { |
|
|
|
int mux = stream.readStringUntil(',').toInt(); |
|
|
|
int len = stream.readStringUntil('\n').toInt(); |
|
|
|
int mux = streamGetInt(','); |
|
|
|
int len = streamGetInt('\n'); |
|
|
|
if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { |
|
|
|
sockets[mux]->got_data = true; |
|
|
|
sockets[mux]->sock_available = len; |
|
|
@ -651,7 +654,7 @@ class TinyGsmSim7600 : public TinyGsmModem<TinyGsmSim7600, READ_AND_CHECK_SIZE, |
|
|
|
data = ""; |
|
|
|
DBG("### Got Data:", len, "on", mux); |
|
|
|
} else if (data.endsWith(GF("+IPCLOSE:"))) { |
|
|
|
int mux = stream.readStringUntil(',').toInt(); |
|
|
|
int mux = streamGetInt(','); |
|
|
|
streamSkipUntil('\n'); // Skip the reason code |
|
|
|
if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) { |
|
|
|
sockets[mux]->sock_connected = false; |
|
|
|