This commit is contained in:
@@ -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;
|
TinyGsmBG96* at;
|
||||||
uint8_t mux;
|
uint8_t mux;
|
||||||
uint16_t sock_available;
|
uint16_t sock_available;
|
||||||
bool sock_connected;
|
bool sock_connected;
|
||||||
bool got_data;
|
bool got_data;
|
||||||
RxFifo rx;
|
RxFifo rx;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -161,10 +161,10 @@ public:
|
|||||||
String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED;
|
String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TinyGsmM590* at;
|
TinyGsmM590* at;
|
||||||
uint8_t mux;
|
uint8_t mux;
|
||||||
bool sock_connected;
|
bool sock_connected;
|
||||||
RxFifo rx;
|
RxFifo rx;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -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;
|
TinyGsmM95* at;
|
||||||
uint8_t mux;
|
uint8_t mux;
|
||||||
uint16_t sock_available;
|
uint16_t sock_available;
|
||||||
bool sock_connected;
|
bool sock_connected;
|
||||||
bool got_data;
|
bool got_data;
|
||||||
RxFifo rx;
|
RxFifo rx;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -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;
|
TinyGsmMC60* at;
|
||||||
uint8_t mux;
|
uint8_t mux;
|
||||||
uint16_t sock_available;
|
uint16_t sock_available;
|
||||||
bool sock_connected;
|
bool sock_connected;
|
||||||
bool got_data;
|
bool got_data;
|
||||||
RxFifo rx;
|
RxFifo rx;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -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;
|
uint8_t mux;
|
||||||
uint16_t sock_available;
|
uint16_t sock_available;
|
||||||
uint32_t prev_check;
|
uint32_t prev_check;
|
||||||
bool sock_connected;
|
bool sock_connected;
|
||||||
bool got_data;
|
bool got_data;
|
||||||
RxFifo rx;
|
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();
|
size_t len_requested = stream.readStringUntil(',').toInt();
|
||||||
sockets[mux]->sock_available = stream.readStringUntil('\n').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) {
|
||||||
|
@@ -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;
|
TinyGsmSim800* at;
|
||||||
uint8_t mux;
|
uint8_t mux;
|
||||||
uint16_t sock_available;
|
uint16_t sock_available;
|
||||||
uint32_t prev_check;
|
uint32_t prev_check;
|
||||||
bool sock_connected;
|
bool sock_connected;
|
||||||
bool got_data;
|
bool got_data;
|
||||||
RxFifo rx;
|
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();
|
size_t len_requested = stream.readStringUntil(',').toInt();
|
||||||
sockets[mux]->sock_available = stream.readStringUntil('\n').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) {
|
||||||
|
@@ -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;
|
TinyGsmUBLOX* at;
|
||||||
uint8_t mux;
|
uint8_t mux;
|
||||||
uint16_t sock_available;
|
uint16_t sock_available;
|
||||||
uint32_t prev_check;
|
uint32_t prev_check;
|
||||||
bool sock_connected;
|
bool sock_connected;
|
||||||
bool got_data;
|
bool got_data;
|
||||||
RxFifo rx;
|
RxFifo rx;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -213,10 +213,10 @@ public:
|
|||||||
String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED;
|
String remoteIP() TINY_GSM_ATTR_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TinyGsmXBee* at;
|
TinyGsmXBee* at;
|
||||||
uint8_t mux;
|
uint8_t mux;
|
||||||
bool sock_connected;
|
bool sock_connected;
|
||||||
// RxFifo rx;
|
// RxFifo rx;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user