21 #ifndef MassageParser_h 22 #define MassageParser_h 24 #if defined(ARDUINO) && ARDUINO >= 100 30 #ifndef MASSAGE_PARSER_BUFFERSIZE 35 #define MASSAGE_PARSER_BUFFERSIZE 256 43 typedef void (*callbackFunction)(void);
58 [[deprecated(
"Please us parseStream() instead")]]
59 virtual bool parse(
int data, callbackFunction callback = 0)
67 if ( _decode(data) ) {
85 virtual bool parseStream(Stream* stream, callbackFunction callback = 0) {
86 while ( stream->available() ) {
87 if (
parse( stream->read() , callback ) ) {
104 bool matches = (strcmp((
const char*) _buffer, address) == 0);
112 virtual bool dispatch(
const char* address, callbackFunction callback) {
122 virtual int8_t
nextByte(
bool* error=0) = 0;
125 virtual int16_t
nextInt(
bool* error=0) = 0;
128 virtual int32_t
nextLong(
bool* error=0) = 0;
131 virtual float nextFloat(
bool* error=0) = 0;
134 virtual int nextString(
char* receivedString,
int bufferLength) = 0;
138 virtual bool _decode(
int serialByte) = 0;
151 bool _store(uint8_t value)
153 if (_messageSize >= MASSAGE_PARSER_BUFFERSIZE)
156 _buffer[_messageSize++] = value;
167 uint8_t _buffer[MASSAGE_PARSER_BUFFERSIZE];
virtual int8_t nextByte(bool *error=0)=0
Reads next byte.
virtual int16_t nextInt(bool *error=0)=0
Reads next int.
virtual int nextString(char *receivedString, int bufferLength)=0
Reads next string.
virtual bool parse(int data, callbackFunction callback=0)
Definition: MassageParser.h:59
Main MassageParser abstract class.
Definition: MassageParser.h:40
virtual void flush()
Flushes current message in buffer (if any).
Definition: MassageParser.h:95
virtual int32_t nextLong(bool *error=0)=0
Reads next long.
MassageParser()
Constructor.
Definition: MassageParser.h:46
virtual bool dispatch(const char *address, callbackFunction callback)
Definition: MassageParser.h:112
virtual bool fullMatch(const char *address)
Return true if current message matches "address".
Definition: MassageParser.h:101
virtual float nextFloat(bool *error=0)=0
Reads next float.
virtual bool parseStream(Stream *stream, callbackFunction callback=0)
Definition: MassageParser.h:85