SensESP 3.0.1
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
signalk_value_listener.h
Go to the documentation of this file.
1#ifndef SENSESP_SRC_SENSESP_SIGNALK_SIGNALK_VALUE_LISTENER_H_
2#define SENSESP_SRC_SENSESP_SIGNALK_SIGNALK_VALUE_LISTENER_H_
3
4#include <ArduinoJson.h>
5
8#include "signalk_listener.h"
9
10namespace sensesp {
11
16template <class T>
17class SKValueListener : public SKListener, public ValueProducer<T> {
18 public:
23 SKValueListener(String sk_path, int listen_delay = 1000,
24 String config_path = "")
25 : SKListener(sk_path, listen_delay, config_path) {
26 if (sk_path == "") {
27 ESP_LOGE(__FILENAME__,
28 "SKValueListener: User has provided no sk_path to listen to.");
29 }
30 }
31
32 void parse_value(const JsonObject& json) override {
33 this->emit(json["value"].as<T>());
34 }
35};
36
41
42} // namespace sensesp
43
44#endif
An Obervable class that listens for Signal K stream deltas and notifies any observers of value change...
An ValueProducer that listens to specific Signal K paths and emits its value whenever it changes.
void parse_value(const JsonObject &json) override
SKValueListener(String sk_path, int listen_delay=1000, String config_path="")
A base class for any sensor or piece of code that outputs a value for consumption elsewhere.
void emit(const T &new_value)
SKValueListener< float > FloatSKListener
SKValueListener< String > StringSKListener
SKValueListener< bool > BoolSKListener
SKValueListener< int > IntSKListener