@@ -55,6 +55,7 @@ class Stream : public Print
5555// parsing methods
5656
5757 void setTimeout (unsigned long timeout); // sets maximum milliseconds to wait for stream data, default is 1 second
58+ unsigned long getTimeout (void ) { return _timeout; }
5859
5960 bool find (char *target); // reads data from the stream until the target string is found
6061 bool find (uint8_t *target) { return find ((char *)target); }
@@ -64,6 +65,8 @@ class Stream : public Print
6465 bool find (uint8_t *target, size_t length) { return find ((char *)target, length); }
6566 // returns true if target string is found, false if timed out
6667
68+ bool find (char target) { return find (&target, 1 ); }
69+
6770 bool findUntil (char *target, char *terminator); // as find but search ends if the terminator string is found
6871 bool findUntil (uint8_t *target, char *terminator) { return findUntil ((char *)target, terminator); }
6972
@@ -97,6 +100,16 @@ class Stream : public Print
97100 // this allows format characters (typically commas) in values to be ignored
98101
99102 float parseFloat (char skipChar); // as above but the given skipChar is ignored
103+
104+ struct MultiTarget {
105+ const char *str; // string you're searching for
106+ size_t len; // length of string you're searching for
107+ size_t index; // index used by the search routine.
108+ };
109+
110+ // This allows you to search for an arbitrary number of strings.
111+ // Returns index of the target that is found first or -1 if timeout occurs.
112+ int findMulti (struct MultiTarget *targets, int tCount);
100113};
101114
102115#endif
0 commit comments