RUI3 (RAK Unified Interface 3) - RAK4631
Stream.h
Go to the documentation of this file.
1 
11 #ifndef __STREAM_H__
12 #define __STREAM_H__
13 
14 #include "WString.h"
15 
16 #include "Print.h"
17 
18 using namespace std;
19 class Stream : public Print
20 {
21  protected:
22  unsigned long timeOut;
23  unsigned long startTime;
24 
25  int timedRead();
26 
27  struct MultiTarget {
28  const char *str;
29  size_t len;
30  size_t index;
31  };
32 
33  int findMulti(struct MultiTarget *targets, int tCount);
34  public:
35  virtual void flush() = 0;
36  virtual int peek() = 0;
39  virtual int available() = 0;
40 
43  virtual int read() = 0;
44 
67  void setTimeout(unsigned long timeout);
68 
69 
91  unsigned long getTimeout(void);
92 
134  size_t readBytes( char *buffer, size_t length);
135  size_t readBytes( uint8_t *buffer, size_t length) { return readBytes((char *)buffer, length); }
136 
180  size_t readBytesUntil( char terminator, char *buffer, size_t length);
181  size_t readBytesUntil( char terminator, uint8_t *buffer, size_t length) { return readBytesUntil(terminator, (char *)buffer, length); }
182 
218  String readString();
219 
254  String readStringUntil(char terminator);
255 
256  bool find(const char *target);
257  bool find(const uint8_t *target);
258  bool find(const char *target, size_t length);
259  bool find(const uint8_t *target, size_t length);
260  bool find(char target);
261 
262  bool findUntil(const char *target, const char *terminator);
263  bool findUntil(const uint8_t *target, const char *terminator);
264  bool findUntil(const char *target, size_t targetLen, const char *terminate, size_t termLen);
265  bool findUntil(const uint8_t *target, size_t targetLen, const char *terminate, size_t termLen);
266 };
267 
268 #endif
size_t index
Definition: Stream.h:30
unsigned long timeOut
Definition: Stream.h:22
const char * str
Definition: Stream.h:28
unsigned long startTime
Definition: Stream.h:23
Definition: WString.h:22
Definition: Print.h:22
size_t readBytesUntil(char terminator, uint8_t *buffer, size_t length)
Definition: Stream.h:181
uint16_t length
Definition: RAKProtocol.h:71
size_t readBytes(uint8_t *buffer, size_t length)
Definition: Stream.h:135
Definition: Stream.h:27
size_t len
Definition: Stream.h:29
Definition: Stream.h:19