TinyRobotics
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
MessageHandlerPrintJSON Class Reference

Message handler that prints all received messages as JSON to a Print stream. More...

#include <MessageHandlerPrint.h>

Inheritance diagram for MessageHandlerPrintJSON:
Inheritance graph
[legend]
Collaboration diagram for MessageHandlerPrintJSON:
Collaboration graph
[legend]

Public Member Functions

 MessageHandlerPrintJSON (Print &printer)
 
void setOutput (Print &printer)
 
bool onMessage (const Message< float > &msg) override
 Handle an incoming message (pure virtual).
 
bool onMessage (const Message< Coordinate< float > > &msg) override
 
bool onMessage (const Message< GPSCoordinate > &msg) override
 
bool onMessage (const Message< MotionState3D > &msg) override
 
virtual bool onMessage (const Message< float > &msg)=0
 Handle an incoming message (pure virtual).
 
virtual bool onMessage (const Message< Coordinate< float > > &msg)
 
virtual bool onMessage (const Message< GPSCoordinate > &msg)
 
virtual bool onMessage (const Message< MotionState3D > &msg)
 

Protected Attributes

Print & printer_
 

Detailed Description

Message handler that prints all received messages as JSON to a Print stream.

This class implements the MessageHandler interface and outputs the content of all received messages (float, Coordinate<float>, GPSCoordinate) in JSON format to the provided Print object (e.g., Serial, file, etc). It uses the shared string arrays to print the message type, unit, and source as readable text.

Example usage:

MessageHandlerPrintJSON printer(Serial);
source.subscribe(printer);
Message handler that prints all received messages as JSON to a Print stream.
Definition: MessageHandlerPrint.h:350

This is useful for logging, exporting, or integrating message traffic with systems that consume JSON data.

Member Function Documentation

◆ onMessage() [1/4]

bool onMessage ( const Message< Coordinate< float > > &  msg)
inlineoverridevirtual

Reimplemented from MessageHandler.

◆ onMessage() [2/4]

bool onMessage ( const Message< float > &  msg)
inlineoverridevirtual

Handle an incoming message (pure virtual).

This method should be implemented by derived classes to process messages.

Parameters
msgThe message to handle.
Returns
true if the message was handled successfully, false otherwise.

Implements MessageHandler.

◆ onMessage() [3/4]

bool onMessage ( const Message< GPSCoordinate > &  msg)
inlineoverridevirtual

Reimplemented from MessageHandler.

◆ onMessage() [4/4]

bool onMessage ( const Message< MotionState3D > &  msg)
inlineoverridevirtual

Reimplemented from MessageHandler.


The documentation for this class was generated from the following file: