arduino-audio-tools
Loading...
Searching...
No Matches
HttpLineReader.h
Go to the documentation of this file.
1#pragma once
2
3#include "AudioLogger.h"
4
5namespace audio_tools {
6
15 public:
17 HttpLineReader() = default;
18
20 virtual int readlnInternal(Stream& client, uint8_t* str, int len,
21 bool incl_nl = true) {
22 LOGD("HttpLineReader %s", "readlnInternal");
23 // readBytesUntil uses timedRead() which respects setTimeout()
24 int result = client.readBytesUntil('\n', (char*)str, len);
25 // Return -1 if no data was read.
26 if (result == 0) {
27 LOGW("HttpLineReader %s", "readlnInternal->no Data");
28 str[0] = 0;
29 return -1;
30 }
31 if (incl_nl) {
32 // we need to add the new line character since it was removed by readBytesUntil
33 if (result < len) {
34 str[result++] = '\n';
35 }
36 } else {
37 // remove trailing CR
38 if (result > 0 && str[result - 1] == '\r') {
39 result--;
40 }
41 }
42 str[result] = 0;
43 return result;
44 }
45};
46
47} // namespace audio_tools
#define LOGW(...)
Definition AudioLoggerIDF.h:29
#define LOGD(...)
Definition AudioLoggerIDF.h:27
Definition Arduino.h:136
We read a single line. A terminating 0 is added to the string to make it compliant for c string funct...
Definition HttpLineReader.h:14
HttpLineReader()=default
Default constructor.
virtual int readlnInternal(Stream &client, uint8_t *str, int len, bool incl_nl=true)
reads up the the next CR LF - but never more then the indicated len.
Definition HttpLineReader.h:20
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition LMSEchoCancellationStream.h:6