This commit is contained in:
Sara Damiano
2019-05-20 12:38:37 -04:00
parent 9201cbde86
commit db456b5345
7 changed files with 22 additions and 15 deletions

View File

@@ -71,7 +71,7 @@ public:
TINY_GSM_YIELD();
rx.clear();
uint8_t newMux = -1;
sock_connected = at->modemConnect(host, port, &newMux, timeout_s)
sock_connected = at->modemConnect(host, port, &newMux, timeout_s);
if (sock_connected) {
mux = newMux;
at->sockets[mux] = this;

View File

@@ -374,7 +374,7 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
}
// Check that we have a local IP address
if (localIP() != 0) {
if (localIP() != IPAddress(0,0,0,0)) {
return true;
}

View File

@@ -814,26 +814,37 @@ protected:
// ^^ Confirmed number of data bytes to be read, which may be less than requested.
// 0 indicates that no data can be read.
size_t len_read = 0;
for (size_t i=0; i<TinyGsmMin(len_confirmed, len_requested) ; i++) {
#ifdef TINY_GSM_USE_HEX
while (stream.available() < 2) { TINY_GSM_YIELD(); }
char buf[4] = { 0, };
buf[0] = stream.read();
len_read++;
buf[1] = stream.read();
char c = strtol(buf, NULL, 16);
len_read++;
#else
while (!stream.available()) { TINY_GSM_YIELD(); }
char c = stream.read();
len_read++;
#endif
sockets[mux]->rx.put(c);
}
waitResponse();
DBG("### READ:", len_read, "from", mux);
return len_read;
return TinyGsmMin(len_confirmed, len_requested);
}
size_t modemGetAvailable(uint8_t mux) {
sendAT(GF("+CIPRXGET=4,"), mux);
size_t result = 0;
if (waitResponse(GF("+CIPRXGET:")) == 1) {
streamSkipUntil(','); // Skip mode 4
streamSkipUntil(','); // Skip mux
result = stream.readStringUntil('\n').toInt();
waitResponse();
}
if (!result) {
sockets[mux]->sock_connected = modemGetConnected(mux);
}
return result;
}
bool modemGetConnected(uint8_t mux) {

View File

@@ -742,26 +742,22 @@ protected:
// ^^ Confirmed number of data bytes to be read, which may be less than requested.
// 0 indicates that no data can be read.
size_t len_read = 0;
for (size_t i=0; i<TinyGsmMin(len_confirmed, len_requested) ; i++) {
#ifdef TINY_GSM_USE_HEX
while (stream.available() < 2) { TINY_GSM_YIELD(); }
char buf[4] = { 0, };
buf[0] = stream.read();
len_read++;
buf[1] = stream.read();
char c = strtol(buf, NULL, 16);
len_read++;
#else
while (!stream.available()) { TINY_GSM_YIELD(); }
char c = stream.read();
len_read++;
#endif
sockets[mux]->rx.put(c);
}
waitResponse();
DBG("### READ:", len_read, "from", mux);
return len_read;
return TinyGsmMin(len_confirmed, len_requested);
}
size_t modemGetAvailable(uint8_t mux) {

View File

@@ -10,7 +10,7 @@
#define TinyGsmCommon_h
// The current library version number
#define TINYGSM_VERSION "0.7.1"
#define TINYGSM_VERSION "0.7.3"
#if defined(SPARK) || defined(PARTICLE)
#include "Particle.h"