From 0004bebf165a0c4063e71edd6b8df797b9f7f5c7 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 13 Sep 2018 17:08:09 -0400 Subject: [PATCH] Moved stream write and stream skip into common --- src/TinyGsmClient.h | 1 - src/TinyGsmClientA6.h | 23 ----------------------- src/TinyGsmClientBG96.h | 23 ----------------------- src/TinyGsmClientESP8266.h | 23 ----------------------- src/TinyGsmClientM590.h | 23 ----------------------- src/TinyGsmClientM95.h | 23 ----------------------- src/TinyGsmClientMC60.h | 23 ----------------------- src/TinyGsmClientSIM800.h | 23 ----------------------- src/TinyGsmClientUBLOX.h | 23 ----------------------- src/TinyGsmClientXBee.h | 11 ----------- src/TinyGsmCommon.h | 27 +++++++++++++++++++++++++++ 11 files changed, 27 insertions(+), 196 deletions(-) diff --git a/src/TinyGsmClient.h b/src/TinyGsmClient.h index da0688b..3f477f1 100644 --- a/src/TinyGsmClient.h +++ b/src/TinyGsmClient.h @@ -66,7 +66,6 @@ #include typedef TinyGsmMC60 TinyGsm; typedef TinyGsmMC60::GsmClient TinyGsmClient; - typedef TinyGsmMC60::GsmClientSecure TinyGsmClientSecure; #elif defined(TINY_GSM_MODEM_ESP8266) #define TINY_GSM_MODEM_HAS_WIFI diff --git a/src/TinyGsmClientA6.h b/src/TinyGsmClientA6.h index d16bbf0..18d502f 100644 --- a/src/TinyGsmClientA6.h +++ b/src/TinyGsmClientA6.h @@ -574,29 +574,6 @@ public: Utilities */ - template - void streamWrite(T last) { - stream.print(last); - } - - template - void streamWrite(T head, Args... tail) { - stream.print(head); - streamWrite(tail...); - } - - bool streamSkipUntil(char c, const unsigned long timeout = 1000L) { - unsigned long startMillis = millis(); - while (millis() - startMillis < timeout) { - while (millis() - startMillis < timeout && !stream.available()) { - TINY_GSM_YIELD(); - } - if (stream.read() == c) - return true; - } - return false; - } - template void sendAT(Args... cmd) { streamWrite("AT", cmd..., GSM_NL); diff --git a/src/TinyGsmClientBG96.h b/src/TinyGsmClientBG96.h index 376fd72..1de0bbe 100644 --- a/src/TinyGsmClientBG96.h +++ b/src/TinyGsmClientBG96.h @@ -656,29 +656,6 @@ public: Utilities */ - template - void streamWrite(T last) { - stream.print(last); - } - - template - void streamWrite(T head, Args... tail) { - stream.print(head); - streamWrite(tail...); - } - - bool streamSkipUntil(char c, const unsigned long timeout = 1000L) { - unsigned long startMillis = millis(); - while (millis() - startMillis < timeout) { - while (millis() - startMillis < timeout && !stream.available()) { - TINY_GSM_YIELD(); - } - if (stream.read() == c) - return true; - } - return false; - } - template void sendAT(Args... cmd) { streamWrite("AT", cmd..., GSM_NL); diff --git a/src/TinyGsmClientESP8266.h b/src/TinyGsmClientESP8266.h index 585a856..eb167b6 100644 --- a/src/TinyGsmClientESP8266.h +++ b/src/TinyGsmClientESP8266.h @@ -432,29 +432,6 @@ public: Utilities */ - template - void streamWrite(T last) { - stream.print(last); - } - - template - void streamWrite(T head, Args... tail) { - stream.print(head); - streamWrite(tail...); - } - - bool streamSkipUntil(char c, const unsigned long timeout = 1000L) { - unsigned long startMillis = millis(); - while (millis() - startMillis < timeout) { - while (millis() - startMillis < timeout && !stream.available()) { - TINY_GSM_YIELD(); - } - if (stream.read() == c) - return true; - } - return false; - } - template void sendAT(Args... cmd) { streamWrite("AT", cmd..., GSM_NL); diff --git a/src/TinyGsmClientM590.h b/src/TinyGsmClientM590.h index 6b524ee..c38873c 100644 --- a/src/TinyGsmClientM590.h +++ b/src/TinyGsmClientM590.h @@ -584,29 +584,6 @@ public: Utilities */ - template - void streamWrite(T last) { - stream.print(last); - } - - template - void streamWrite(T head, Args... tail) { - stream.print(head); - streamWrite(tail...); - } - - bool streamSkipUntil(char c, const unsigned long timeout = 1000L) { - unsigned long startMillis = millis(); - while (millis() - startMillis < timeout) { - while (millis() - startMillis < timeout && !stream.available()) { - TINY_GSM_YIELD(); - } - if (stream.read() == c) - return true; - } - return false; - } - template void sendAT(Args... cmd) { streamWrite("AT", cmd..., GSM_NL); diff --git a/src/TinyGsmClientM95.h b/src/TinyGsmClientM95.h index 90a1e82..16ef2a0 100644 --- a/src/TinyGsmClientM95.h +++ b/src/TinyGsmClientM95.h @@ -736,29 +736,6 @@ public: Utilities */ - template - void streamWrite(T last) { - stream.print(last); - } - - template - void streamWrite(T head, Args... tail) { - stream.print(head); - streamWrite(tail...); - } - - bool streamSkipUntil(char c, const unsigned long timeout = 1000L) { - unsigned long startMillis = millis(); - while (millis() - startMillis < timeout) { - while (millis() - startMillis < timeout && !stream.available()) { - TINY_GSM_YIELD(); - } - if (stream.read() == c) - return true; - } - return false; - } - template void sendAT(Args... cmd) { streamWrite("AT", cmd..., GSM_NL); diff --git a/src/TinyGsmClientMC60.h b/src/TinyGsmClientMC60.h index 20477a9..ed894d2 100644 --- a/src/TinyGsmClientMC60.h +++ b/src/TinyGsmClientMC60.h @@ -771,29 +771,6 @@ public: Utilities */ - template - void streamWrite(T last) { - stream.print(last); - } - - template - void streamWrite(T head, Args... tail) { - stream.print(head); - streamWrite(tail...); - } - - bool streamSkipUntil(char c, const unsigned long timeout = 1000L) { - unsigned long startMillis = millis(); - while (millis() - startMillis < timeout) { - while (millis() - startMillis < timeout && !stream.available()) { - TINY_GSM_YIELD(); - } - if (stream.read() == c) - return true; - } - return false; - } - template void sendAT(Args... cmd) { streamWrite("AT", cmd..., GSM_NL); diff --git a/src/TinyGsmClientSIM800.h b/src/TinyGsmClientSIM800.h index 34843c2..8517337 100644 --- a/src/TinyGsmClientSIM800.h +++ b/src/TinyGsmClientSIM800.h @@ -823,29 +823,6 @@ public: Utilities */ - template - void streamWrite(T last) { - stream.print(last); - } - - template - void streamWrite(T head, Args... tail) { - stream.print(head); - streamWrite(tail...); - } - - bool streamSkipUntil(const char c, const unsigned long timeout = 3000L) { - unsigned long startMillis = millis(); - while (millis() - startMillis < timeout) { - while (millis() - startMillis < timeout && !stream.available()) { - TINY_GSM_YIELD(); - } - if (stream.read() == c) - return true; - } - return false; - } - template void sendAT(Args... cmd) { streamWrite("AT", cmd..., GSM_NL); diff --git a/src/TinyGsmClientUBLOX.h b/src/TinyGsmClientUBLOX.h index 69e68fc..fc51896 100644 --- a/src/TinyGsmClientUBLOX.h +++ b/src/TinyGsmClientUBLOX.h @@ -648,29 +648,6 @@ public: Utilities */ - template - void streamWrite(T last) { - stream.print(last); - } - - template - void streamWrite(T head, Args... tail) { - stream.print(head); - streamWrite(tail...); - } - - bool streamSkipUntil(char c, const unsigned long timeout = 1000L) { - unsigned long startMillis = millis(); - while (millis() - startMillis < timeout) { - while (millis() - startMillis < timeout && !stream.available()) { - TINY_GSM_YIELD(); - } - if (stream.read() == c) - return true; - } - return false; - } - template void sendAT(Args... cmd) { streamWrite("AT", cmd..., GSM_NL); diff --git a/src/TinyGsmClientXBee.h b/src/TinyGsmClientXBee.h index 6696627..948ba86 100644 --- a/src/TinyGsmClientXBee.h +++ b/src/TinyGsmClientXBee.h @@ -729,17 +729,6 @@ public: while (stream.available()) { stream.read(); } } - template - void streamWrite(T last) { - stream.print(last); - } - - template - void streamWrite(T head, Args... tail) { - stream.print(head); - streamWrite(tail...); - } - template void sendAT(Args... cmd) { streamWrite("AT", cmd..., GSM_NL); diff --git a/src/TinyGsmCommon.h b/src/TinyGsmCommon.h index d46ede1..2cd7827 100644 --- a/src/TinyGsmCommon.h +++ b/src/TinyGsmCommon.h @@ -292,6 +292,33 @@ public: return TinyGsmIpFromString(getLocalIP()); } + /* + Utilities + */ + + template + void streamWrite(T last) { + stream.print(last); + } + + template + void streamWrite(T head, Args... tail) { + stream.print(head); + streamWrite(tail...); + } + + bool streamSkipUntil(const char c, const unsigned long timeout = 1000L) { + unsigned long startMillis = millis(); + while (millis() - startMillis < timeout) { + while (millis() - startMillis < timeout && !stream.available()) { + TINY_GSM_YIELD(); + } + if (stream.read() == c) + return true; + } + return false; + } + public: Stream& stream; };