Merge pull request #10 from dawidcieszynski/master

Skip stream timeouts, et al.
This commit is contained in:
Sara Damiano
2018-02-19 11:28:49 -05:00
committed by GitHub
9 changed files with 220 additions and 15 deletions

View File

@@ -413,9 +413,13 @@ public:
streamWrite(tail...);
}
bool streamSkipUntil(char c) { //TODO: timeout
while (true) {
while (!stream.available()) { TINY_GSM_YIELD(); }
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;
}