Fixed SIM800 issue
This commit is contained in:
@@ -308,7 +308,7 @@ TINY_GSM_MODEM_GET_IMEI_GSN()
|
|||||||
delay(1000);
|
delay(1000);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int status = waitResponse(GF("READY"), GF("SIM PIN"), GF("SIM PUK"), GF("NOT INSERTED"));
|
int status = waitResponse(GF("READY"), GF("SIM PIN"), GF("SIM PUK"), GF("NOT INSERTED"), GF("NOT READY"));
|
||||||
waitResponse();
|
waitResponse();
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case 2:
|
case 2:
|
||||||
@@ -767,12 +767,10 @@ protected:
|
|||||||
size_t len_confirmed = stream.readStringUntil('\n').toInt();
|
size_t len_confirmed = stream.readStringUntil('\n').toInt();
|
||||||
// ^^ Confirmed number of data bytes to be read, which may be less than requested.
|
// ^^ Confirmed number of data bytes to be read, which may be less than requested.
|
||||||
// 0 indicates that no data can be read.
|
// 0 indicates that no data can be read.
|
||||||
if (len_confirmed < len_requested) {
|
// This is actually be the number of bytes that will be remaining after the read
|
||||||
DBG("WARNING:", len_requested - len_confirmed, "fewer bytes confirmed readable than requested!");
|
size_t len_read = 0;
|
||||||
}
|
// Attempt to read the full amount we requested, even if that quantity was not confirmed
|
||||||
sockets[mux]->sock_available = len_confirmed;
|
for (size_t i=0; i<len_requested; i++) {
|
||||||
|
|
||||||
for (size_t i=0; i<TinyGsmMin(len_confirmed, len_requested) ; i++) {
|
|
||||||
uint32_t startMillis = millis();
|
uint32_t startMillis = millis();
|
||||||
#ifdef TINY_GSM_USE_HEX
|
#ifdef TINY_GSM_USE_HEX
|
||||||
while (stream.available() < 2 && (millis() - startMillis < sockets[mux]->_timeout)) { TINY_GSM_YIELD(); }
|
while (stream.available() < 2 && (millis() - startMillis < sockets[mux]->_timeout)) { TINY_GSM_YIELD(); }
|
||||||
@@ -784,13 +782,16 @@ protected:
|
|||||||
while (!stream.available() && (millis() - startMillis < sockets[mux]->_timeout)) { TINY_GSM_YIELD(); }
|
while (!stream.available() && (millis() - startMillis < sockets[mux]->_timeout)) { TINY_GSM_YIELD(); }
|
||||||
char c = stream.read();
|
char c = stream.read();
|
||||||
#endif
|
#endif
|
||||||
sockets[mux]->rx.put(c);
|
if (c > 0) {
|
||||||
sockets[mux]->sock_available--;
|
sockets[mux]->rx.put(c);
|
||||||
// ^^ One less character available after moving from modem's FIFO to our FIFO
|
len_read++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
DBG("### READ:", len_read, "from", mux);
|
||||||
|
// sockets[mux]->sock_available = modemGetAvailable(mux);
|
||||||
|
sockets[mux]->sock_available = len_confirmed;
|
||||||
waitResponse();
|
waitResponse();
|
||||||
DBG("### READ:", TinyGsmMin(len_confirmed, len_requested), "from", mux);
|
return len_read;
|
||||||
return TinyGsmMin(len_confirmed, len_requested);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t modemGetAvailable(uint8_t mux) {
|
size_t modemGetAvailable(uint8_t mux) {
|
||||||
@@ -811,7 +812,9 @@ protected:
|
|||||||
|
|
||||||
bool modemGetConnected(uint8_t mux) {
|
bool modemGetConnected(uint8_t mux) {
|
||||||
sendAT(GF("+CIPSTATUS="), mux);
|
sendAT(GF("+CIPSTATUS="), mux);
|
||||||
int res = waitResponse(GF(",\"CONNECTED\""), GF(",\"CLOSED\""), GF(",\"CLOSING\""), GF(",\"INITIAL\""));
|
waitResponse(GF("+CIPSTATUS"));
|
||||||
|
int res = waitResponse(GF(",\"CONNECTED\""), GF(",\"CLOSED\""), GF(",\"CLOSING\""),
|
||||||
|
GF(",\"REMOTE CLOSING\""), GF(",\"INITIAL\""));
|
||||||
waitResponse();
|
waitResponse();
|
||||||
return 1 == res;
|
return 1 == res;
|
||||||
}
|
}
|
||||||
|
@@ -249,7 +249,7 @@ String TinyGsmDecodeHex16bit(String &instr) {
|
|||||||
/* Workaround: sometimes module forgets to notify about data arrival.
|
/* Workaround: sometimes module forgets to notify about data arrival.
|
||||||
TODO: Currently we ping the module periodically,
|
TODO: Currently we ping the module periodically,
|
||||||
but maybe there's a better indicator that we need to poll */ \
|
but maybe there's a better indicator that we need to poll */ \
|
||||||
if (millis() - prev_check > 250) { \
|
if (millis() - prev_check > 500) { \
|
||||||
got_data = true; \
|
got_data = true; \
|
||||||
prev_check = millis(); \
|
prev_check = millis(); \
|
||||||
} \
|
} \
|
||||||
@@ -311,7 +311,7 @@ String TinyGsmDecodeHex16bit(String &instr) {
|
|||||||
/* Workaround: sometimes module forgets to notify about data arrival.
|
/* Workaround: sometimes module forgets to notify about data arrival.
|
||||||
TODO: Currently we ping the module periodically,
|
TODO: Currently we ping the module periodically,
|
||||||
but maybe there's a better indicator that we need to poll */ \
|
but maybe there's a better indicator that we need to poll */ \
|
||||||
if (millis() - prev_check > 250) { \
|
if (millis() - prev_check > 500) { \
|
||||||
got_data = true; \
|
got_data = true; \
|
||||||
prev_check = millis(); \
|
prev_check = millis(); \
|
||||||
} \
|
} \
|
||||||
|
Reference in New Issue
Block a user