7std::vector<SKListener *> SKListener::listeners_;
9StaticSemaphore_t SKListener::semaphore_buffer_;
10SemaphoreHandle_t SKListener::semaphore_ =
11 xSemaphoreCreateRecursiveMutexStatic(&SKListener::semaphore_buffer_);
14 const String &config_path)
17 listen_delay{listen_delay} {
18 listeners_.push_back(
this);
23 if (timeout_ms == 0) {
24 return xSemaphoreTakeRecursive(semaphore_, portMAX_DELAY) == pdTRUE;
26 return xSemaphoreTakeRecursive(semaphore_, timeout_ms) == pdTRUE;
32bool SKListener::to_json(JsonObject &root) {
37bool SKListener::from_json(
const JsonObject &config) {
38 if (!config[
"sk_path"].is<String>()) {
41 this->set_sk_path(config[
"sk_path"].as<String>());
45void SKListener::set_sk_path(
const String &path) {
sk_path = path; }
48 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.
FileSystemSaveable(const String &config_path)
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)