6#include "TinyRobotics/utils/LoggerClass.h"
7#include "TinyRobotics/vehicles/Vehicle.h"
9namespace tinyrobotics {
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
32 MessageDispatcher() =
default;
33 MessageDispatcher(
MessageHandler& handler) { p_handler = &handler; }
40 if (p_stream ==
nullptr || p_handler ==
nullptr) {
41 TRLogger.error(
"CommMgr: Invalid stream or handler");
48 void end() { is_active =
false; }
53 if (!is_active)
return false;
54 if (!p_stream || !p_handler)
return false;
57 if (!parser.parse(*p_stream, *p_handler)) {
59 TRLogger.error(
"CommMgr: Failed to parse message");
65 void setStream(Stream& io) { p_stream = &io; }
69 Stream* p_stream =
nullptr;
70 bool is_active =
false;
Reads stream and forwards messages to handler.
Definition: MessageDispatcher.h:30
virtual bool run()
Definition: MessageDispatcher.h:52
Interface for handling messages in the TinyRobotics framework.
Definition: MessageHandler.h:18
Parses binary TinyRobotics messages from a Stream and dispatches them by type.
Definition: MessageParser.h:79