SensESP 2.7.2
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
signalk_listener.cpp
Go to the documentation of this file.
1#include "signalk_listener.h"
2
3namespace sensesp {
4
5std::vector<SKListener *> SKListener::listeners;
6
7SemaphoreHandle_t SKListener::semaphore_ = xSemaphoreCreateRecursiveMutex();
8
10 : Configurable(config_path), sk_path{sk_path}, listen_delay{listen_delay} {
11 listeners.push_back(this);
12 this->load_configuration();
13}
14
15bool SKListener::take_semaphore(unsigned long int timeout_ms) {
16 if (timeout_ms == 0) {
17 return xSemaphoreTakeRecursive(semaphore_, portMAX_DELAY) == pdTRUE;
18 } else {
19 return xSemaphoreTakeRecursive(semaphore_, timeout_ms) == pdTRUE;
20 }
21}
22
24
25String SKListener::get_config_schema() { return FPSTR(SIGNALKINPUT_SCHEMA); }
26
27void SKListener::get_configuration(JsonObject &root) {
28 root["sk_path"] = this->get_sk_path();
29}
30
31bool SKListener::set_configuration(const JsonObject &config) {
32 if (!config.containsKey("sk_path")) {
33 return false;
34 }
35 this->set_sk_path(config["sk_path"].as<String>());
36 return true;
37}
38
39void SKListener::set_sk_path(const String &path) { sk_path = path; }
40
41} // namespace sensesp
An object that is capable of having configuration data that can be set remotely using a RESTful API,...
virtual void load_configuration()
Construct a new transform based on a single function.
SKListener(String sk_path, int listen_delay, String config_path="")
static void release_semaphore()
static bool take_semaphore(unsigned long int timeout_ms=0)