9std::vector<SKListener *> SKListener::listeners_;
11StaticSemaphore_t SKListener::semaphore_buffer_;
12SemaphoreHandle_t SKListener::semaphore_ =
13 xSemaphoreCreateRecursiveMutexStatic(&SKListener::semaphore_buffer_);
16 const String &config_path)
19 listen_delay{listen_delay} {
20 listeners_.push_back(
this);
26 listeners_.erase(std::remove(listeners_.begin(), listeners_.end(),
this),
38 if (timeout_ms == 0) {
39 return xSemaphoreTakeRecursive(semaphore_, portMAX_DELAY) == pdTRUE;
41 return xSemaphoreTakeRecursive(semaphore_, timeout_ms) == pdTRUE;
47bool SKListener::to_json(JsonObject &root) {
52bool SKListener::from_json(
const JsonObject &config) {
53 if (!config[
"sk_path"].is<String>()) {
56 this->set_sk_path(config[
"sk_path"].as<String>());
60void SKListener::set_sk_path(
const String &path) {
sk_path = path; }
63 return R
"({"type":"object","properties":{"listen_delay":{"title":"Listen delay","type":"number","description":"The time, in milliseconds, between each read of the input"}} })";
virtual bool load() override
Load and populate the object from a persistent storage.
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()
SKListener(const String &sk_path, int listen_delay, const String &config_path="")
static void clear_registry()
const String ConfigSchema(const SmartSwitchController &obj)