|
TinyRobotics
|
Parses binary TinyRobotics messages from a Stream and dispatches them by type. More...
#include <MessageParser.h>
Public Member Functions | |
| bool | parse (Stream &io, ParsedMessage &result) |
| bool | parse (Stream &io, MessageHandler &handler) |
| Parses a message from the stream and dispatches it to the given handler. | |
| bool | parse (uint8_t *data, size_t len, MessageHandler &handler) |
| Parses a message from a raw buffer and dispatches it to the given handler. | |
Parses binary TinyRobotics messages from a Stream and dispatches them by type.
MessageParser provides two main interfaces:
The parser reads the message header (prefix, size, origin_id), then inspects the content field to determine the value type (float, Coordinate<float>, GPSCoordinate). It then reads the value and remaining fields accordingly.
Usage (manual type inspection):
Usage (automatic dispatch):
|
inline |
Parses a message from the stream and dispatches it to the given handler.
This method parses the message type and calls the appropriate onMessage overload on the provided MessageHandler instance.
| io | The input stream to parse from. |
| handler | The MessageHandler to dispatch the parsed message to. |
|
inline |
Parses a message from a raw buffer and dispatches it to the given handler.
This overload wraps the buffer in a MemoryStream and calls the Stream-based parse.
| data | Pointer to the message buffer. |
| len | Length of the buffer. |
| handler | The MessageHandler to dispatch the parsed message to. |