57#define PUBLISHER_TYPE 0
58#define SUBSCRIBER_TYPE 1
62#define MAX_BUFFER_CAPACITY 100
64template <
typename T,
int MaxLen,
typename Container=std::deque<T>>
67 void push(
const T& value)
69 if (this->size() == MaxLen)
73 std::queue<T, Container>::push(value);
90 TxStream(uint8_t stream_type, std::string stream_name, uint8_t stream_identifier);
196 *this << static_cast<const uint32_t>(v.size());
214 for (
size_t i = 0; i < size; ++i)
226 uint8_t _stream_type;
227 std::string _stream_name;
228 uint8_t _stream_identifier;
235 void handle_overrun(ERROR result);
237 std::string toUTF8(
const std::u16string source);
251 RxStream(uint8_t stream_type, std::string stream_name, uint8_t stream_identifier);
377 for (
size_t i = 0; i < size; ++i)
410 void push_packet(std::vector<std::pair<void *, int>> packet);
425 uint8_t _stream_type;
426 std::string _stream_name;
427 uint8_t _stream_identifier;
429 size_t _buffered_iterator;
432 std::vector<std::pair<void *, int>> _buffered_packet;
435 static const std::map<int, int> _stream_type_match_map;
436 static std::vector<RxStream *> _listening_streams;
447 uint8_t str_copy[128];
450 static std::mutex _rx_mutex;
452 static std::pair<void *, int> interpret_field(ITEM * items,
size_t i,
union _cbor_value & val);
453 static void destroy_interpreted_field(std::pair<void *, int>& field);
454 std::u16string toUTF16(
const std::string source);
Class used to send and receive data from the DESERT socket.
Class used to store configurations.
Definition CBorStream.h:65
Definition CBorStream.h:242
~RxStream()
Destroy the reception stream.
Definition LibMcuCBorStream.cpp:226
std::string get_name() const
Get the topic name of a specific instance.
Definition LibMcuCBorStream.cpp:433
RxStream & operator>>(std::vector< T > &v)
Decode vector.
Definition CBorStream.h:354
static void interpret_packets()
Interpret raw packets and splits them into different communication types.
Definition LibMcuCBorStream.cpp:448
void clear_buffer()
Clear the currently buffered packet.
Definition LibMcuCBorStream.cpp:283
RxStream(uint8_t stream_type, std::string stream_name, uint8_t stream_identifier)
Create a reception stream.
Definition LibMcuCBorStream.cpp:218
bool data_available(int64_t sequence_id=0)
Check if there are data.
Definition LibMcuCBorStream.cpp:243
uint8_t get_identifier() const
Get the stream identifier of a specific instance.
Definition LibMcuCBorStream.cpp:438
uint8_t get_type() const
Get the stream type of a specific instance.
Definition LibMcuCBorStream.cpp:428
void push_packet(std::vector< std::pair< void *, int > > packet)
Add a packet to _received_packets.
Definition LibMcuCBorStream.cpp:443
RxStream & deserialize_sequence(T *items, size_t size)
Deserialize a sequence of uniform elements.
Definition CBorStream.h:375
RxStream & operator>>(uint64_t &n)
Decode uint64.
Definition LibMcuCBorStream.cpp:288
Definition CBorStream.h:81
TxStream & operator<<(const uint64_t n)
Encode uint64.
Definition LibMcuCBorStream.cpp:84
TxStream & serialize_sequence(const T *items, size_t size)
Serialize a sequence of uniform elements.
Definition CBorStream.h:212
TxStream(uint8_t stream_type, std::string stream_name, uint8_t stream_identifier)
Create a transmission stream.
Definition LibMcuCBorStream.cpp:25
TxStream & operator<<(const std::vector< T > v)
Encode vector.
Definition CBorStream.h:194
void end_transmission()
Tell the stream to send down the packet.
Definition LibMcuCBorStream.cpp:62
void start_transmission()
Tell the stream to create a new packet.
Definition LibMcuCBorStream.cpp:52