REDAC HybridController
Firmware for LUCIDAC/REDAC Teensy
Loading...
Searching...
No Matches
protocol.h
Go to the documentation of this file.
1// Copyright (c) 2023 anabrid GmbH
2// Contact: https://www.anabrid.com/licensing/
3// SPDX-License-Identifier: MIT OR GPL-2.0-or-later
4
5#pragma once
6
7#ifdef ARDUINO
8
9#include <ArduinoJson.h>
10#include <Print.h>
11#include <list>
12
13#include "net/auth.h"
14#include "net/ethernet.h"
15#include "protocol/handler.h"
16#include "utils/durations.h"
18#include "utils/singleton.h"
19
20namespace carrier {
21class Carrier;
22}
23
24namespace msg {
25
36class JsonLinesProtocol : public utils::HeapSingleton<JsonLinesProtocol> {
37public:
38 DynamicJsonDocument *envelope_in, *envelope_out;
40
42
43 void init(size_t envelope_size);
44
52 void handleMessage(net::auth::AuthentificationContext &user_context, Print &output);
53
55 bool process_tcp_input(net::EthernetClient &stream, net::auth::AuthentificationContext &user_context);
56 void process_string_input(const std::string &envelope_in, std::string &envelope_out,
58
60};
61
62} // namespace msg
63
64#endif // ARDUINO
Top-level hierarchy controlled by a single microcontroller.
Definition carrier.h:38
This class is a responder that handles incoming messages in the JsonLines Protocol language over vari...
Definition protocol.h:36
void process_serial_input(net::auth::AuthentificationContext &user_context)
Definition protocol.cpp:133
void process_out_of_band_handlers(carrier::Carrier &carrier)
Definition protocol.cpp:186
void init(size_t envelope_size)
Allocates storage.
Definition protocol.cpp:50
void process_string_input(const std::string &envelope_in, std::string &envelope_out, net::auth::AuthentificationContext &user_context)
Definition protocol.cpp:167
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 a...
Definition protocol.cpp:55
DynamicJsonDocument * envelope_in
Definition protocol.h:38
utils::PrintMultiplexer broadcast
Definition protocol.h:39
DynamicJsonDocument * envelope_out
Definition protocol.h:38
bool process_tcp_input(net::EthernetClient &stream, net::auth::AuthentificationContext &user_context)
Definition protocol.cpp:150
A thin wrapper around the username.
Definition auth.h:231
Define singletons which are not static-space allocated (and thus consume valuable ICTM space).
Definition singleton.h:46
A "multiplexer" for Print targets.
Definition carrier.h:12