Fixed indentation error

This commit is contained in:
SRGDamia1
2017-06-08 13:16:22 -04:00
parent c52869c6b1
commit b5dace330b
2 changed files with 88 additions and 88 deletions

View File

@@ -508,94 +508,94 @@ private:
GsmConstStr r1=GFP(GSM_OK), GsmConstStr r2=GFP(GSM_ERROR), GsmConstStr r1=GFP(GSM_OK), GsmConstStr r2=GFP(GSM_ERROR),
GsmConstStr r3=NULL, GsmConstStr r4=NULL, GsmConstStr r5=NULL) GsmConstStr r3=NULL, GsmConstStr r4=NULL, GsmConstStr r5=NULL)
{ {
/*String r1s(r1); r1s.trim(); /*String r1s(r1); r1s.trim();
String r2s(r2); r2s.trim(); String r2s(r2); r2s.trim();
String r3s(r3); r3s.trim(); String r3s(r3); r3s.trim();
String r4s(r4); r4s.trim(); String r4s(r4); r4s.trim();
String r5s(r5); r5s.trim(); String r5s(r5); r5s.trim();
DBG("### ..:", r1s, ",", r2s, ",", r3s, ",", r4s, ",", r5s);*/ DBG("### ..:", r1s, ",", r2s, ",", r3s, ",", r4s, ",", r5s);*/
data.reserve(64); data.reserve(64);
bool gotData = false; bool gotData = false;
int mux = -1; int mux = -1;
int len = 0; int len = 0;
int index = 0; int index = 0;
unsigned long startMillis = millis(); unsigned long startMillis = millis();
do { do {
TINY_GSM_YIELD(); TINY_GSM_YIELD();
while (stream.available() > 0) { while (stream.available() > 0) {
int a = streamRead(); int a = streamRead();
if (a <= 0) continue; // Skip 0x00 bytes, just in case if (a <= 0) continue; // Skip 0x00 bytes, just in case
data += (char)a; data += (char)a;
if (r1 && data.endsWith(r1)) { if (r1 && data.endsWith(r1)) {
index = 1; index = 1;
goto finish; goto finish;
} else if (r2 && data.endsWith(r2)) { } else if (r2 && data.endsWith(r2)) {
index = 2; index = 2;
goto finish; goto finish;
} else if (r3 && data.endsWith(r3)) { } else if (r3 && data.endsWith(r3)) {
index = 3; index = 3;
goto finish; goto finish;
} else if (r4 && data.endsWith(r4)) { } else if (r4 && data.endsWith(r4)) {
index = 4; index = 4;
goto finish; goto finish;
} else if (r5 && data.endsWith(r5)) { } else if (r5 && data.endsWith(r5)) {
index = 5; index = 5;
goto finish; goto finish;
} else if (data.endsWith(GF("+CIPRCV:"))) { } else if (data.endsWith(GF("+CIPRCV:"))) {
mux = stream.readStringUntil(',').toInt(); mux = stream.readStringUntil(',').toInt();
data += mux; data += mux;
data += (','); data += (',');
len = stream.readStringUntil(',').toInt(); len = stream.readStringUntil(',').toInt();
data += len; data += len;
data += (','); data += (',');
gotData = true; gotData = true;
index = 6; index = 6;
goto finish; goto finish;
} else if (data.endsWith(GF("+TCPCLOSED:"))) { } else if (data.endsWith(GF("+TCPCLOSED:"))) {
mux = stream.readStringUntil(',').toInt(); mux = stream.readStringUntil(',').toInt();
data += mux; data += mux;
data += (','); data += (',');
String concl = stream.readStringUntil('\n'); String concl = stream.readStringUntil('\n');
data += concl; data += concl;
sockets[mux]->sock_connected = false; sockets[mux]->sock_connected = false;
index = 7; index = 7;
goto finish; goto finish;
} }
} }
} while (millis() - startMillis < timeout); } while (millis() - startMillis < timeout);
finish: finish:
if (!index) { if (!index) {
data.trim(); data.trim();
if (data.length()) { if (data.length()) {
DBG(GSM_NL, "### Unhandled:", data); DBG(GSM_NL, "### Unhandled:", data);
} }
} }
else { else {
data.trim(); data.trim();
data.replace(GSM_NL GSM_NL, GSM_NL); data.replace(GSM_NL GSM_NL, GSM_NL);
data.replace(GSM_NL, GSM_NL " "); data.replace(GSM_NL, GSM_NL " ");
if (data.length()) { if (data.length()) {
DBG(GSM_NL, "<<< ", data); DBG(GSM_NL, "<<< ", data);
} }
} }
if (gotData) { if (gotData) {
int len_orig = len; int len_orig = len;
if (len > sockets[mux]->rx.free()) { if (len > sockets[mux]->rx.free()) {
DBG(GSM_NL, "### Buffer overflow: ", len, "->", sockets[mux]->rx.free()); DBG(GSM_NL, "### Buffer overflow: ", len, "->", sockets[mux]->rx.free());
} else { } else {
DBG(GSM_NL, "### Got: ", len, "->", sockets[mux]->rx.free()); DBG(GSM_NL, "### Got: ", len, "->", sockets[mux]->rx.free());
} }
while (len--) { while (len--) {
TINY_GSM_YIELD(); TINY_GSM_YIELD();
int r = stream.read(); int r = stream.read();
if (r <= 0) continue; // Skip 0x00 bytes, just in case if (r <= 0) continue; // Skip 0x00 bytes, just in case
sockets[mux]->rx.put((char)r); sockets[mux]->rx.put((char)r);
} }
if (len_orig > sockets[mux]->available()) { if (len_orig > sockets[mux]->available()) {
DBG(GSM_NL, "### Fewer characters received than expected: ", sockets[mux]->available(), " vs ", len_orig); DBG(GSM_NL, "### Fewer characters received than expected: ", sockets[mux]->available(), " vs ", len_orig);
} }
} }
return index; return index;
} }
uint8_t waitResponse(uint32_t timeout, uint8_t waitResponse(uint32_t timeout,

View File

@@ -4,7 +4,7 @@
* *
**************************************************************/ **************************************************************/
#define TINY_GSM_MODEM_SIM800 // #define TINY_GSM_MODEM_SIM800
//#define TINY_GSM_MODEM_A6 //#define TINY_GSM_MODEM_A6
//#define TINY_GSM_MODEM_M590 //#define TINY_GSM_MODEM_M590
//#define TINY_GSM_MODEM_ESP8266 //#define TINY_GSM_MODEM_ESP8266