Browse Source

Fix typos, tweak to timeout

v_master
Sara Damiano 5 years ago
parent
commit
e35e4afce0
13 changed files with 49 additions and 63 deletions
  1. +3
    -5
      src/TinyGsmClientA6.h
  2. +4
    -7
      src/TinyGsmClientBG96.h
  3. +2
    -4
      src/TinyGsmClientESP8266.h
  4. +3
    -5
      src/TinyGsmClientM590.h
  5. +4
    -7
      src/TinyGsmClientM95.h
  6. +4
    -7
      src/TinyGsmClientMC60.h
  7. +2
    -2
      src/TinyGsmClientSIM7000.h
  8. +2
    -2
      src/TinyGsmClientSIM800.h
  9. +4
    -7
      src/TinyGsmClientSaraR4.h
  10. +3
    -6
      src/TinyGsmClientSequansMonarch.h
  11. +4
    -7
      src/TinyGsmClientUBLOX.h
  12. +1
    -1
      src/TinyGsmClientXBee.h
  13. +13
    -3
      src/TinyGsmCommon.h

+ 3
- 5
src/TinyGsmClientA6.h View File

@ -261,7 +261,7 @@ TINY_GSM_MODEM_GET_REGISTRATION_XREG(CREG)
* Generic network functions
*/
TINY_GSP_MODEM_GET_CSQ()
TINY_GSM_MODEM_GET_CSQ()
bool isNetworkConnected() {
RegStatus s = getRegistrationStatus();
@ -552,7 +552,7 @@ public:
Utilities
*/
TINY_GSP_MODEM_STREAM_UTILITIES()
TINY_GSM_MODEM_STREAM_UTILITIES()
// TODO: Optimize this!
uint8_t waitResponse(uint32_t timeout_ms, String& data,
@ -599,9 +599,7 @@ TINY_GSP_MODEM_STREAM_UTILITIES()
DBG("### Got: ", len, "->", sockets[mux]->rx.free());
}
while (len--) {
startMillis = millis();
while (!stream.available() && (millis() - startMillis < sockets[mux]->_timeout)) { TINY_GSM_YIELD(); }
sockets[mux]->rx.put(stream.read());
TINY_GSM_MODEM_STREAM_TO_MUX_FIFO_WITH_DOUBLE_TIMEOUT
}
if (len_orig > sockets[mux]->available()) { // TODO
DBG("### Fewer characters received than expected: ", sockets[mux]->available(), " vs ", len_orig);


+ 4
- 7
src/TinyGsmClientBG96.h View File

@ -284,7 +284,7 @@ TINY_GSM_MODEM_GET_OPERATOR_COPS()
* Generic network functions
*/
TINY_GSP_MODEM_GET_CSQ()
TINY_GSM_MODEM_GET_CSQ()
bool isNetworkConnected() {
RegStatus s = getRegistrationStatus();
@ -329,7 +329,7 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
return true;
}
TINY_GSP_MODEM_GET_GPRS_IP_CONNECTED()
TINY_GSM_MODEM_GET_GPRS_IP_CONNECTED()
/*
* IP Address functions
@ -517,10 +517,7 @@ protected:
sockets[mux]->sock_available = len;
for (size_t i=0; i<len; i++) {
uint32_t startMillis = millis();
while (!stream.available() && (millis() - startMillis < sockets[mux]->_timeout)) { TINY_GSM_YIELD(); }
char c = stream.read();
sockets[mux]->rx.put(c);
TINY_GSM_MODEM_STREAM_TO_MUX_FIFO_WITH_DOUBLE_TIMEOUT
}
waitResponse();
DBG("### READ:", len, "from", mux);
@ -569,7 +566,7 @@ public:
Utilities
*/
TINY_GSP_MODEM_STREAM_UTILITIES()
TINY_GSM_MODEM_STREAM_UTILITIES()
// TODO: Optimize this!
uint8_t waitResponse(uint32_t timeout_ms, String& data,


+ 2
- 4
src/TinyGsmClientESP8266.h View File

@ -374,7 +374,7 @@ public:
Utilities
*/
TINY_GSP_MODEM_STREAM_UTILITIES()
TINY_GSM_MODEM_STREAM_UTILITIES()
// TODO: Optimize this!
uint8_t waitResponse(uint32_t timeout_ms, String& data,
@ -421,9 +421,7 @@ TINY_GSP_MODEM_STREAM_UTILITIES()
DBG("### Got: ", len, "->", sockets[mux]->rx.free());
}
while (len--) {
startMillis = millis();
while (!stream.available() && (millis() - startMillis < sockets[mux]->_timeout)) { TINY_GSM_YIELD(); }
sockets[mux]->rx.put(stream.read());
TINY_GSM_MODEM_STREAM_TO_MUX_FIFO_WITH_DOUBLE_TIMEOUT
}
if (len_orig > sockets[mux]->available()) { // TODO
DBG("### Fewer characters received than expected: ", sockets[mux]->available(), " vs ", len_orig);


+ 3
- 5
src/TinyGsmClientM590.h View File

@ -246,7 +246,7 @@ TINY_GSM_MODEM_GET_OPERATOR_COPS()
* Generic network functions
*/
TINY_GSP_MODEM_GET_CSQ()
TINY_GSM_MODEM_GET_CSQ()
bool isNetworkConnected() {
RegStatus s = getRegistrationStatus();
@ -473,7 +473,7 @@ public:
Utilities
*/
TINY_GSP_MODEM_STREAM_UTILITIES()
TINY_GSM_MODEM_STREAM_UTILITIES()
// TODO: Optimize this!
uint8_t waitResponse(uint32_t timeout_ms, String& data,
@ -520,9 +520,7 @@ TINY_GSP_MODEM_STREAM_UTILITIES()
DBG("### Got: ", len, "->", sockets[mux]->rx.free());
}
while (len--) {
uint32_t startMillis = millis();
while (!stream.available() && (millis() - startMillis < sockets[mux]->_timeout)) { TINY_GSM_YIELD(); }
sockets[mux]->rx.put(stream.read());
TINY_GSM_MODEM_STREAM_TO_MUX_FIFO_WITH_DOUBLE_TIMEOUT
}
if (len_orig > sockets[mux]->available()) { // TODO
DBG("### Fewer characters received than expected: ", sockets[mux]->available(), " vs ", len_orig);


+ 4
- 7
src/TinyGsmClientM95.h View File

@ -292,7 +292,7 @@ TINY_GSM_MODEM_GET_OPERATOR_COPS()
* Generic network functions
*/
TINY_GSP_MODEM_GET_CSQ()
TINY_GSM_MODEM_GET_CSQ()
bool isNetworkConnected() {
RegStatus s = getRegistrationStatus();
@ -367,7 +367,7 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
return waitResponse(60000L, GF("DEACT OK"), GF("ERROR")) == 1;
}
TINY_GSP_MODEM_GET_GPRS_IP_CONNECTED()
TINY_GSM_MODEM_GET_GPRS_IP_CONNECTED()
/*
* IP Address functions
@ -571,10 +571,7 @@ protected:
sockets[mux]->sock_available = len;
for (size_t i=0; i<len; i++) {
uint32_t startMillis = millis();
while (!stream.available() && (millis() - startMillis < sockets[mux]->_timeout)) { TINY_GSM_YIELD(); }
char c = stream.read();
sockets[mux]->rx.put(c);
TINY_GSM_MODEM_STREAM_TO_MUX_FIFO_WITH_DOUBLE_TIMEOUT
}
waitResponse();
DBG("### READ:", len, "from", mux);
@ -623,7 +620,7 @@ public:
Utilities
*/
TINY_GSP_MODEM_STREAM_UTILITIES()
TINY_GSM_MODEM_STREAM_UTILITIES()
// TODO: Optimize this!
uint8_t waitResponse(uint32_t timeout_ms, String& data,


+ 4
- 7
src/TinyGsmClientMC60.h View File

@ -307,7 +307,7 @@ TINY_GSM_MODEM_GET_OPERATOR_COPS()
* Generic network functions
*/
TINY_GSP_MODEM_GET_CSQ()
TINY_GSM_MODEM_GET_CSQ()
bool isNetworkConnected() {
RegStatus s = getRegistrationStatus();
@ -386,7 +386,7 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
return waitResponse(60000L, GF("DEACT OK"), GF("ERROR")) == 1;
}
TINY_GSP_MODEM_GET_GPRS_IP_CONNECTED()
TINY_GSM_MODEM_GET_GPRS_IP_CONNECTED()
/*
* IP Address functions
@ -591,10 +591,7 @@ protected:
sockets[mux]->sock_available = len;
for (size_t i=0; i<len; i++) {
uint32_t startMillis = millis();
while (!stream.available() && (millis() - startMillis < sockets[mux]->_timeout)) { TINY_GSM_YIELD(); }
char c = stream.read();
sockets[mux]->rx.put(c);
TINY_GSM_MODEM_STREAM_TO_MUX_FIFO_WITH_DOUBLE_TIMEOUT
}
waitResponse();
DBG("### READ:", len, "from", mux);
@ -643,7 +640,7 @@ public:
Utilities
*/
TINY_GSP_MODEM_STREAM_UTILITIES()
TINY_GSM_MODEM_STREAM_UTILITIES()
// TODO: Optimize this!
uint8_t waitResponse(uint32_t timeout_ms, String& data,


+ 2
- 2
src/TinyGsmClientSIM7000.h View File

@ -296,7 +296,7 @@ TINY_GSM_MODEM_GET_OPERATOR_COPS()
* Generic network functions
*/
TINY_GSP_MODEM_GET_CSQ()
TINY_GSM_MODEM_GET_CSQ()
bool isNetworkConnected() {
RegStatus s = getRegistrationStatus();
@ -861,7 +861,7 @@ public:
Utilities
*/
TINY_GSP_MODEM_STREAM_UTILITIES()
TINY_GSM_MODEM_STREAM_UTILITIES()
// TODO: Optimize this!
uint8_t waitResponse(uint32_t timeout_ms, String& data,


+ 2
- 2
src/TinyGsmClientSIM800.h View File

@ -328,7 +328,7 @@ TINY_GSM_MODEM_GET_OPERATOR_COPS()
* Generic network functions
*/
TINY_GSP_MODEM_GET_CSQ()
TINY_GSM_MODEM_GET_CSQ()
bool isNetworkConnected() {
RegStatus s = getRegistrationStatus();
@ -789,7 +789,7 @@ public:
Utilities
*/
TINY_GSP_MODEM_STREAM_UTILITIES()
TINY_GSM_MODEM_STREAM_UTILITIES()
// TODO: Optimize this!
uint8_t waitResponse(uint32_t timeout_ms, String& data,


+ 4
- 7
src/TinyGsmClientSaraR4.h View File

@ -353,7 +353,7 @@ TINY_GSM_MODEM_GET_OPERATOR_COPS()
* Generic network functions
*/
TINY_GSP_MODEM_GET_CSQ()
TINY_GSM_MODEM_GET_CSQ()
bool isNetworkConnected() {
RegStatus s = getRegistrationStatus();
@ -431,7 +431,7 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
return true;
}
TINY_GSP_MODEM_GET_GPRS_IP_CONNECTED()
TINY_GSM_MODEM_GET_GPRS_IP_CONNECTED()
/*
* IP Address functions
@ -601,10 +601,7 @@ protected:
streamSkipUntil('\"');
for (size_t i=0; i<len; i++) {
uint32_t startMillis = millis();
while (!stream.available() && (millis() - startMillis < sockets[mux]->_timeout)) { TINY_GSM_YIELD(); }
char c = stream.read();
sockets[mux]->rx.put(c);
TINY_GSM_MODEM_STREAM_TO_MUX_FIFO_WITH_DOUBLE_TIMEOUT
}
streamSkipUntil('\"');
waitResponse();
@ -661,7 +658,7 @@ public:
Utilities
*/
TINY_GSP_MODEM_STREAM_UTILITIES()
TINY_GSM_MODEM_STREAM_UTILITIES()
// TODO: Optimize this!
uint8_t waitResponse(uint32_t timeout_ms, String& data,


+ 3
- 6
src/TinyGsmClientSequansMonarch.h View File

@ -344,7 +344,7 @@ TINY_GSM_MODEM_GET_OPERATOR_COPS()
* Generic network functions
*/
TINY_GSP_MODEM_GET_CSQ()
TINY_GSM_MODEM_GET_CSQ()
bool isNetworkConnected() {
RegStatus s = getRegistrationStatus();
@ -541,10 +541,7 @@ protected:
streamSkipUntil(','); // Skip mux
size_t len = stream.readStringUntil('\n').toInt();
for (size_t i=0; i<len; i++) {
uint32_t startMillis = millis();
while (!stream.available() && (millis() - startMillis < sockets[mux]->_timeout)) { TINY_GSM_YIELD(); }
char c = stream.read();
sockets[mux]->rx.put(c);
TINY_GSM_MODEM_STREAM_TO_MUX_FIFO_WITH_DOUBLE_TIMEOUT
}
waitResponse();
sockets[mux]->sock_available = modemGetAvailable(mux);
@ -592,7 +589,7 @@ public:
Utilities
*/
TINY_GSP_MODEM_STREAM_UTILITIES()
TINY_GSM_MODEM_STREAM_UTILITIES()
// TODO: Optimize this!
uint8_t waitResponse(uint32_t timeout_ms, String& data,


+ 4
- 7
src/TinyGsmClientUBLOX.h View File

@ -341,7 +341,7 @@ TINY_GSM_MODEM_GET_OPERATOR_COPS()
* Generic network functions
*/
TINY_GSP_MODEM_GET_CSQ()
TINY_GSM_MODEM_GET_CSQ()
bool isNetworkConnected() {
RegStatus s = getRegistrationStatus();
@ -413,7 +413,7 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
return true;
}
TINY_GSP_MODEM_GET_GPRS_IP_CONNECTED()
TINY_GSM_MODEM_GET_GPRS_IP_CONNECTED()
/*
* IP Address functions
@ -587,10 +587,7 @@ protected:
streamSkipUntil('\"');
for (size_t i=0; i<len; i++) {
uint32_t startMillis = millis();
while (!stream.available() && (millis() - startMillis < sockets[mux]->_timeout)) { TINY_GSM_YIELD(); }
char c = stream.read();
sockets[mux]->rx.put(c);
TINY_GSM_MODEM_STREAM_TO_MUX_FIFO_WITH_DOUBLE_TIMEOUT
}
streamSkipUntil('\"');
waitResponse();
@ -647,7 +644,7 @@ public:
Utilities
*/
TINY_GSP_MODEM_STREAM_UTILITIES()
TINY_GSM_MODEM_STREAM_UTILITIES()
// TODO: Optimize this!
uint8_t waitResponse(uint32_t timeout_ms, String& data,


+ 1
- 1
src/TinyGsmClientXBee.h View File

@ -953,7 +953,7 @@ public:
}
}
TINY_GSP_MODEM_STREAM_UTILITIES()
TINY_GSM_MODEM_STREAM_UTILITIES()
// TODO: Optimize this!
// NOTE: This function is used while INSIDE command mode, so we're only


+ 13
- 3
src/TinyGsmCommon.h View File

@ -547,7 +547,7 @@ String TinyGsmDecodeHex16bit(String &instr) {
// Checks if current attached to GPRS/EPS service
#define TINY_GSP_MODEM_GET_GPRS_IP_CONNECTED() \
#define TINY_GSM_MODEM_GET_GPRS_IP_CONNECTED() \
bool isGprsConnected() { \
sendAT(GF("+CGATT?")); \
if (waitResponse(GF(GSM_NL "+CGATT:")) != 1) { \
@ -563,7 +563,7 @@ String TinyGsmDecodeHex16bit(String &instr) {
// Gets signal quality report according to 3GPP TS command AT+CSQ
#define TINY_GSP_MODEM_GET_CSQ() \
#define TINY_GSM_MODEM_GET_CSQ() \
int16_t getSignalQuality() { \
sendAT(GF("+CSQ")); \
if (waitResponse(GF(GSM_NL "+CSQ:")) != 1) { \
@ -575,8 +575,18 @@ String TinyGsmDecodeHex16bit(String &instr) {
}
// Yields up to a time-out period and then reads a character from the stream into the mux FIFO
// TODO: Do we need to wait two _timeout periods for no character return? Will wait once in the first
// "while !stream.available()" and then will wait again in the stream.read() function.
#define TINY_GSM_MODEM_STREAM_TO_MUX_FIFO_WITH_DOUBLE_TIMEOUT \
uint32_t startMillis = millis(); \
while (!stream.available() && (millis() - startMillis < sockets[mux]->_timeout)) { TINY_GSM_YIELD(); } \
char c = stream.read(); \
sockets[mux]->rx.put(c);
// Utility templates for writing/skipping characters on a stream
#define TINY_GSP_MODEM_STREAM_UTILITIES() \
#define TINY_GSM_MODEM_STREAM_UTILITIES() \
template<typename T> \
void streamWrite(T last) { \
stream.print(last); \


Loading…
Cancel
Save