7std::vector<SKListener *> SKListener::listeners_;
9SemaphoreHandle_t SKListener::semaphore_ = xSemaphoreCreateRecursiveMutex();
12 const String &config_path)
15 listen_delay{listen_delay} {
16 listeners_.push_back(
this);
21 if (timeout_ms == 0) {
22 return xSemaphoreTakeRecursive(semaphore_, portMAX_DELAY) == pdTRUE;
24 return xSemaphoreTakeRecursive(semaphore_, timeout_ms) == pdTRUE;
30bool SKListener::to_json(JsonObject &root) {
35bool SKListener::from_json(
const JsonObject &config) {
36 if (!config[
"sk_path"].is<String>()) {
39 this->set_sk_path(config[
"sk_path"].as<String>());
43void SKListener::set_sk_path(
const String &path) {
sk_path = path; }
46 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="")
const String ConfigSchema(const SmartSwitchController &obj)