forked from squix78/json-streaming-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArduinoStreamParser.cpp
52 lines (34 loc) · 919 Bytes
/
ArduinoStreamParser.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "ArduinoStreamParser.h"
size_t ArudinoStreamParser::write(const uint8_t *data, size_t size) {
// Trick the Stream Class into thinking it's writing to memory
//Serial.println("ArudinoStreamParser::write(data, size)");
uint8_t char_val = 0x00;
if(size && data)
{
for (size_t idx=0; idx<size; idx++)
{
char_val = *(data + idx);
parse(char_val);
}
return size;
// DEBUGV(":ArudinoStreamParser: OOM (%d->%d)\n", size);
}
return 0;
}
size_t ArudinoStreamParser::write(uint8_t data) {
//Serial.println("ArudinoStreamParser::write(char)");
// Catch the write of the byte/char from the arduino library.
parse(data);
return 1;
}
int ArudinoStreamParser::available() {
return 1;
}
int ArudinoStreamParser::read() {
return -1;
}
int ArudinoStreamParser::peek() {
return -1;
}
void ArudinoStreamParser::flush() {
}