REDAC HybridController
Firmware for LUCIDAC/REDAC Teensy
|
This class is a responder that handles incoming messages in the JsonLines Protocol language over various inputs, which can be Serial input, a TCP/IP input or even a string input. More...
#include <protocol.h>


Public Member Functions | |
JsonLinesProtocol () | |
void | init (size_t envelope_size) |
Allocates storage. | |
void | handleMessage (net::auth::AuthentificationContext &user_context, Print &output) |
Handles the JSON document currently stored in envelope_in and stores the answer in the envelope_out accordingly. | |
void | process_serial_input (net::auth::AuthentificationContext &user_context) |
bool | process_tcp_input (net::EthernetClient &stream, net::auth::AuthentificationContext &user_context) |
void | process_string_input (const std::string &envelope_in, std::string &envelope_out, net::auth::AuthentificationContext &user_context) |
void | process_out_of_band_handlers (carrier::Carrier &carrier) |
Public Attributes | |
DynamicJsonDocument * | envelope_in |
DynamicJsonDocument * | envelope_out |
utils::PrintMultiplexer | broadcast |
Additional Inherited Members | |
![]() | |
static JsonLinesProtocol & | get () |
Detailed Description
This class is a responder that handles incoming messages in the JsonLines Protocol language over various inputs, which can be Serial input, a TCP/IP input or even a string input.
Handles messages according to the global msg::handler::Registry. TODO: Probably rename this class to sth like "JsonLinesResponder"
Definition at line 36 of file protocol.h.
Constructor & Destructor Documentation
◆ JsonLinesProtocol()
|
inline |
Definition at line 41 of file protocol.h.
References utils::PrintMultiplexer::add_Serial(), and broadcast.
Member Function Documentation
◆ handleMessage()
FLASHMEM void msg::JsonLinesProtocol::handleMessage | ( | net::auth::AuthentificationContext & | user_context, |
Print & | output ) |
Handles the JSON document currently stored in envelope_in
and stores the answer in the envelope_out
accordingly.
Note that some out-of-band messages don't run throught this method, for examle
Definition at line 55 of file protocol.cpp.
References net::auth::AuthentificationContext::can_do(), utils::HeapSingleton< DynamicRegistry >::get(), LOG_ALWAYS, and msg::handlers::MessageHandler::not_implemented.
◆ init()
FLASHMEM void msg::JsonLinesProtocol::init | ( | size_t | envelope_size | ) |
Allocates storage.
Definition at line 50 of file protocol.cpp.
References envelope_in, and envelope_out.
◆ process_out_of_band_handlers()
FLASHMEM void msg::JsonLinesProtocol::process_out_of_band_handlers | ( | carrier::Carrier & | carrier | ) |
Definition at line 186 of file protocol.cpp.
References carrier_, run::RunManager::get(), and run::RunManager::run_next().
◆ process_serial_input()
FLASHMEM void msg::JsonLinesProtocol::process_serial_input | ( | net::auth::AuthentificationContext & | user_context | ) |
Definition at line 133 of file protocol.cpp.
References utils::SerialLineReader::line_available(), LOG4, serial_line_reader, and trim().
◆ process_string_input()
FLASHMEM void msg::JsonLinesProtocol::process_string_input | ( | const std::string & | envelope_in, |
std::string & | envelope_out, | ||
net::auth::AuthentificationContext & | user_context ) |
Definition at line 167 of file protocol.cpp.
References utils::StringPrint::str().
◆ process_tcp_input()
FLASHMEM bool msg::JsonLinesProtocol::process_tcp_input | ( | net::EthernetClient & | stream, |
net::auth::AuthentificationContext & | user_context ) |
Definition at line 150 of file protocol.cpp.
References LOG2.
Referenced by msg::JsonlServer::loop().
Member Data Documentation
◆ broadcast
utils::PrintMultiplexer msg::JsonLinesProtocol::broadcast |
Definition at line 39 of file protocol.h.
Referenced by JsonLinesProtocol(), and msg::JsonlServer::loop().
◆ envelope_in
DynamicJsonDocument* msg::JsonLinesProtocol::envelope_in |
Definition at line 38 of file protocol.h.
Referenced by init().
◆ envelope_out
DynamicJsonDocument * msg::JsonLinesProtocol::envelope_out |
Definition at line 38 of file protocol.h.
Referenced by init().
The documentation for this class was generated from the following files:
- lib/communication/src/protocol/protocol.h
- lib/communication/src/protocol/protocol.cpp