SensESP 2.7.2
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
signalk_value_listener.h
Go to the documentation of this file.
1#ifndef _sk_value_listener_H
2#define _sk_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,
25 : SKListener(sk_path, listen_delay, config_path) {
26 if (sk_path == "") {
27 debugE("SKValueListener: User has provided no sk_path to listen to.");
28 }
29 }
30
31 void parse_value(const JsonObject& json) override {
32 this->emit(json["value"].as<T>());
33 }
34};
35
40
41} // namespace sensesp
42
43#endif
Construct a new transform based on a single function.
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(T new_value)
#define debugE(fmt,...)
Definition local_debug.h:50
SKValueListener< float > FloatSKListener
SKValueListener< String > StringSKListener
SKValueListener< bool > BoolSKListener
SKValueListener< int > IntSKListener