Sara Damiano 5 years ago
parent
commit
e18c5dacbd
8 changed files with 81 additions and 65 deletions
  1. +7
    -7
      src/TinyGsmClientBG96.h
  2. +4
    -4
      src/TinyGsmClientM590.h
  3. +7
    -7
      src/TinyGsmClientM95.h
  4. +7
    -7
      src/TinyGsmClientMC60.h
  5. +20
    -13
      src/TinyGsmClientSIM7000.h
  6. +23
    -14
      src/TinyGsmClientSIM800.h
  7. +9
    -9
      src/TinyGsmClientUBLOX.h
  8. +4
    -4
      src/TinyGsmClientXBee.h

+ 7
- 7
src/TinyGsmClientBG96.h View File

@ -144,7 +144,7 @@ public:
// TODO: Read directly into user buffer? // TODO: Read directly into user buffer?
at->maintain(); at->maintain();
if (sock_available > 0) { if (sock_available > 0) {
sock_available -= at->modemRead(TinyGsmMin((uint16_t)rx.free(), sock_available), mux);
at->modemRead(TinyGsmMin((uint16_t)rx.free(), sock_available), mux);
} else { } else {
break; break;
} }
@ -178,12 +178,12 @@ public:
String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED; String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED;
private: private:
TinyGsmBG96* at;
uint8_t mux;
uint16_t sock_available;
bool sock_connected;
bool got_data;
RxFifo rx;
TinyGsmBG96* at;
uint8_t mux;
uint16_t sock_available;
bool sock_connected;
bool got_data;
RxFifo rx;
}; };


+ 4
- 4
src/TinyGsmClientM590.h View File

@ -161,10 +161,10 @@ public:
String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED; String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED;
private: private:
TinyGsmM590* at;
uint8_t mux;
bool sock_connected;
RxFifo rx;
TinyGsmM590* at;
uint8_t mux;
bool sock_connected;
RxFifo rx;
}; };


+ 7
- 7
src/TinyGsmClientM95.h View File

@ -144,7 +144,7 @@ public:
// TODO: Read directly into user buffer? // TODO: Read directly into user buffer?
at->maintain(); at->maintain();
if (sock_available > 0) { if (sock_available > 0) {
sock_available -= at->modemRead(TinyGsmMin((uint16_t)rx.free(), sock_available), mux);
at->modemRead(TinyGsmMin((uint16_t)rx.free(), sock_available), mux);
} else { } else {
break; break;
} }
@ -178,12 +178,12 @@ public:
String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED; String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED;
private: private:
TinyGsmM95* at;
uint8_t mux;
uint16_t sock_available;
bool sock_connected;
bool got_data;
RxFifo rx;
TinyGsmM95* at;
uint8_t mux;
uint16_t sock_available;
bool sock_connected;
bool got_data;
RxFifo rx;
}; };


+ 7
- 7
src/TinyGsmClientMC60.h View File

@ -148,7 +148,7 @@ public:
// TODO: Read directly into user buffer? // TODO: Read directly into user buffer?
at->maintain(); at->maintain();
if (sock_available > 0) { if (sock_available > 0) {
sock_available -= at->modemRead(TinyGsmMin((uint16_t)rx.free(), sock_available), mux);
at->modemRead(TinyGsmMin((uint16_t)rx.free(), sock_available), mux);
} else { } else {
break; break;
} }
@ -182,12 +182,12 @@ public:
String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED; String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED;
private: private:
TinyGsmMC60* at;
uint8_t mux;
uint16_t sock_available;
bool sock_connected;
bool got_data;
RxFifo rx;
TinyGsmMC60* at;
uint8_t mux;
uint16_t sock_available;
bool sock_connected;
bool got_data;
RxFifo rx;
}; };


+ 20
- 13
src/TinyGsmClientSIM7000.h View File

@ -166,10 +166,10 @@ public:
got_data = true; got_data = true;
prev_check = millis(); prev_check = millis();
} }
at->maintain();
// TODO: Read directly into user buffer? // TODO: Read directly into user buffer?
at->maintain();
if (sock_available > 0) { if (sock_available > 0) {
sock_available -= at->modemRead(TinyGsmMin((uint16_t)rx.free(), sock_available), mux);
at->modemRead(TinyGsmMin((uint16_t)rx.free(), sock_available), mux);
} else { } else {
break; break;
} }
@ -204,12 +204,12 @@ public:
private: private:
TinyGsmSim7000* at; TinyGsmSim7000* at;
uint8_t mux;
uint16_t sock_available;
uint32_t prev_check;
bool sock_connected;
bool got_data;
RxFifo rx;
uint8_t mux;
uint16_t sock_available;
uint32_t prev_check;
bool sock_connected;
bool got_data;
RxFifo rx;
}; };
@ -947,12 +947,19 @@ protected:
return 0; return 0;
} }
#endif #endif
streamSkipUntil(','); // Skip mode 2/3
streamSkipUntil(','); // Skip Rx mode 2/normal or 3/HEX
streamSkipUntil(','); // Skip mux streamSkipUntil(','); // Skip mux
size_t len = stream.readStringUntil(',').toInt();
sockets[mux]->sock_available = stream.readStringUntil('\n').toInt();
size_t len_requested = stream.readStringUntil(',').toInt();
// ^^ Requested number of data bytes (1-1460 bytes)to be read
size_t len_confirmed = stream.readStringUntil('\n').toInt();
if (len_confirmed > len_requested) {
DBG(len_requested - len_confirmed, "fewer bytes confirmed than requested!");
}
sockets[mux]->sock_available = len_confirmed;
// ^^ Confirmed number of data bytes to be read, which may be less than requested.
// 0 indicates that no data can be read.
for (size_t i=0; i<len; i++) {
for (size_t i=0; i<len_confirmed; i++) {
#ifdef TINY_GSM_USE_HEX #ifdef TINY_GSM_USE_HEX
while (stream.available() < 2) { TINY_GSM_YIELD(); } while (stream.available() < 2) { TINY_GSM_YIELD(); }
char buf[4] = { 0, }; char buf[4] = { 0, };
@ -966,7 +973,7 @@ protected:
sockets[mux]->rx.put(c); sockets[mux]->rx.put(c);
} }
waitResponse(); waitResponse();
return len;
return len_confirmed;
} }
size_t modemGetAvailable(uint8_t mux) { size_t modemGetAvailable(uint8_t mux) {


+ 23
- 14
src/TinyGsmClientSIM800.h View File

@ -161,10 +161,10 @@ public:
got_data = true; got_data = true;
prev_check = millis(); prev_check = millis();
} }
at->maintain();
// TODO: Read directly into user buffer? // TODO: Read directly into user buffer?
at->maintain();
if (sock_available > 0) { if (sock_available > 0) {
sock_available -= at->modemRead(TinyGsmMin((uint16_t)rx.free(), sock_available), mux);
at->modemRead(TinyGsmMin((uint16_t)rx.free(), sock_available), mux);
} else { } else {
break; break;
} }
@ -198,13 +198,13 @@ public:
String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED; String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED;
private: private:
TinyGsmSim800* at;
uint8_t mux;
uint16_t sock_available;
uint32_t prev_check;
bool sock_connected;
bool got_data;
RxFifo rx;
TinyGsmSim800* at;
uint8_t mux;
uint16_t sock_available;
uint32_t prev_check;
bool sock_connected;
bool got_data;
RxFifo rx;
}; };
@ -578,6 +578,7 @@ public:
bool gprsDisconnect() { bool gprsDisconnect() {
// Shut the TCP/IP connection // Shut the TCP/IP connection
// CIPSHUT will close *all* open connections
sendAT(GF("+CIPSHUT")); sendAT(GF("+CIPSHUT"));
if (waitResponse(60000L) != 1) if (waitResponse(60000L) != 1)
return false; return false;
@ -791,6 +792,7 @@ public:
/* /*
* Battery functions * Battery functions
*/ */
// Use: float vBatt = modem.getBattVoltage() / 1000.0; // Use: float vBatt = modem.getBattVoltage() / 1000.0;
uint16_t getBattVoltage() { uint16_t getBattVoltage() {
sendAT(GF("+CBC")); sendAT(GF("+CBC"));
@ -868,12 +870,19 @@ protected:
return 0; return 0;
} }
#endif #endif
streamSkipUntil(','); // Skip mode 2/3
streamSkipUntil(','); // Skip Rx mode 2/normal or 3/HEX
streamSkipUntil(','); // Skip mux streamSkipUntil(','); // Skip mux
size_t len = stream.readStringUntil(',').toInt();
sockets[mux]->sock_available = stream.readStringUntil('\n').toInt();
size_t len_requested = stream.readStringUntil(',').toInt();
// ^^ Requested number of data bytes (1-1460 bytes)to be read
size_t len_confirmed = stream.readStringUntil('\n').toInt();
if (len_confirmed > len_requested) {
DBG(len_requested - len_confirmed, "fewer bytes confirmed than requested!");
}
sockets[mux]->sock_available = len_confirmed;
// ^^ Confirmed number of data bytes to be read, which may be less than requested.
// 0 indicates that no data can be read.
for (size_t i=0; i<len; i++) {
for (size_t i=0; i<len_confirmed; i++) {
#ifdef TINY_GSM_USE_HEX #ifdef TINY_GSM_USE_HEX
while (stream.available() < 2) { TINY_GSM_YIELD(); } while (stream.available() < 2) { TINY_GSM_YIELD(); }
char buf[4] = { 0, }; char buf[4] = { 0, };
@ -887,7 +896,7 @@ protected:
sockets[mux]->rx.put(c); sockets[mux]->rx.put(c);
} }
waitResponse(); waitResponse();
return len;
return len_confirmed;
} }
size_t modemGetAvailable(uint8_t mux) { size_t modemGetAvailable(uint8_t mux) {


+ 9
- 9
src/TinyGsmClientUBLOX.h View File

@ -168,10 +168,10 @@ public:
got_data = true; got_data = true;
prev_check = millis(); prev_check = millis();
} }
at->maintain();
// TODO: Read directly into user buffer? // TODO: Read directly into user buffer?
at->maintain();
if (sock_available > 0) { if (sock_available > 0) {
sock_available -= at->modemRead(TinyGsmMin((uint16_t)rx.free(), sock_available), mux);
at->modemRead(TinyGsmMin((uint16_t)rx.free(), sock_available), mux);
} else { } else {
break; break;
} }
@ -205,13 +205,13 @@ public:
String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED; String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED;
private: private:
TinyGsmUBLOX* at;
uint8_t mux;
uint16_t sock_available;
uint32_t prev_check;
bool sock_connected;
bool got_data;
RxFifo rx;
TinyGsmUBLOX* at;
uint8_t mux;
uint16_t sock_available;
uint32_t prev_check;
bool sock_connected;
bool got_data;
RxFifo rx;
}; };


+ 4
- 4
src/TinyGsmClientXBee.h View File

@ -213,10 +213,10 @@ public:
String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED; String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED;
private: private:
TinyGsmXBee* at;
uint8_t mux;
bool sock_connected;
// RxFifo rx;
TinyGsmXBee* at;
uint8_t mux;
bool sock_connected;
// RxFifo rx;
}; };


Loading…
Cancel
Save