SensESP 3.0.1
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
signalk_listener.h
Go to the documentation of this file.
1#ifndef SENSESP_SIGNALK_LISTENER_H_
2#define SENSESP_SIGNALK_LISTENER_H_
3
4#include "sensesp.h"
5
6#include <ArduinoJson.h>
7#include <set>
8
12
13namespace sensesp {
14
22class SKListener : virtual public Observable, public FileSystemSaveable {
23 public:
34 SKListener(const String& sk_path, int listen_delay,
35 const String& config_path = "");
36
42 String& get_sk_path() { return sk_path; }
43
44 int get_listen_delay() { return listen_delay; }
45
46 virtual void parse_value(const JsonObject& json) {}
47
48 static const std::vector<SKListener*>& get_listeners() { return listeners_; }
49
50 static bool take_semaphore(uint64_t timeout_ms = 0);
51 static void release_semaphore();
52
53 protected:
54 String sk_path{};
55
56 private:
57 static std::vector<SKListener*> listeners_;
58 int listen_delay;
59 static SemaphoreHandle_t semaphore_;
60
61 virtual bool to_json(JsonObject& root) override;
62 virtual bool from_json(const JsonObject& config) override;
63
64 void set_sk_path(const String& path);
65};
66
67const String ConfigSchema(const SKListener& obj);
68
69} // namespace sensesp
70
71#endif
A base class which allow observers to attach callbacks to themselves. The callbacks will be called wh...
Definition observable.h:16
An Obervable class that listens for Signal K stream deltas and notifies any observers of value change...
static bool take_semaphore(uint64_t timeout_ms=0)
static void release_semaphore()
virtual void parse_value(const JsonObject &json)
SKListener(const String &sk_path, int listen_delay, const String &config_path="")
static const std::vector< SKListener * > & get_listeners()
const String ConfigSchema(const SmartSwitchController &obj)