SensESP 3.3.0
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
signalk_delta_queue.h
Go to the documentation of this file.
1#ifndef SENSESP_SIGNALK_DELTA_QUEUE_H_
2#define SENSESP_SIGNALK_DELTA_QUEUE_H_
3
4#include <ArduinoJson.h>
5#include <list>
6#include <map>
7#include <vector>
8
9namespace sensesp {
10
19 public:
20 SKDeltaQueue(unsigned int max_buffer_size = 20);
21 void append(const String& val);
22 bool data_available();
23 void get_delta(String& output);
24 void get_deltas(std::vector<String>& output);
25
26 void connect_emitters();
27
32 this->meta_sent_ = false;
34 }
35
36 bool take_semaphore(uint64_t timeout_ms = 0);
37 void release_semaphore();
38
39 private:
40 unsigned int max_buffer_size;
41 std::list<String> buffer{};
42 bool meta_sent_;
43
44 unsigned int get_doc_size_estimate();
45 unsigned int get_metadata_size_estimate();
46
47 std::size_t get_buffer_size() {
48 std::size_t size;
50 size = buffer.size();
52 return size;
53 }
54
55 // Adds Signal K meta data to the specified document
56 void add_metadata(JsonArray updates);
57
58 StaticSemaphore_t semaphore_buffer_;
59 SemaphoreHandle_t semaphore_ = NULL;
60};
61
62} // namespace sensesp
63
64#endif
SKDeltaQueue(unsigned int max_buffer_size=20)
void get_delta(String &output)
void get_deltas(std::vector< String > &output)
bool take_semaphore(uint64_t timeout_ms=0)
void append(const String &val)