Fix typos, tweak to timeout
This commit is contained in:
@@ -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);
|
||||
|
@@ -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,
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
@@ -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,
|
||||
|
@@ -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,
|
||||
|
@@ -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,
|
||||
|
@@ -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,
|
||||
|
@@ -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,
|
||||
|
@@ -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,
|
||||
|
@@ -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,
|
||||
|
@@ -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
|
||||
|
@@ -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); \
|
||||
|
Reference in New Issue
Block a user