SensESP 2.7.2
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
system_info.h
Go to the documentation of this file.
1#ifndef _system_info_H_
2#define _system_info_H_
3
4#include <Arduino.h>
5#include <elapsedMillis.h>
6
8#include "sensesp_base_app.h"
9#include "sensor.h"
10
11namespace sensesp {
12
16template <typename T>
18 String name) {
19 auto hostname_obs = SensESPBaseApp::get()->get_hostname_observable();
21 String path = prefix + hostname + "." + name;
22
23 auto* sk_output = new SKOutput<T>(path);
24
25 // connect an observer to hostname to change the output path
26 // if the hostname is changed
28 String path = prefix + hostname_obs->get() + "." + name;
29 sk_output->set_sk_path(path);
30 };
32
34
35 // connect the sensor to the output
37}
38
46class SystemHz : public FloatSensor {
47 public:
49 void start() override final;
50 String get_value_name() { return "systemhz"; }
51
52 private:
53 uint32_t tick_count_ = 0;
54 elapsedMillis elapsed_millis_;
55 float system_hz_;
56 void tick();
57 void update();
58};
59
67class FreeMem : public IntSensor {
68 public:
70 void start() override final;
71 String get_value_name() { return "freemem"; }
72
73 private:
74 void update();
75};
76
85class Uptime : public FloatSensor {
86 public:
87 Uptime() {}
88 void start() override final;
89 String get_value_name() { return "uptime"; }
90
91 private:
92 void update();
93};
94
103class IPAddrDev : public StringSensor {
104 public:
106 void start() override final;
107 String get_value_name() { return "ipaddr"; }
108
109 private:
110 void update();
111};
112
121class WiFiSignal : public FloatSensor {
122 public:
124 void start() override final;
125 String get_value_name() { return "wifisignal"; }
126
127 private:
128 void update();
129};
130
131} // namespace sensesp
132
133#endif
Reports the current amount of unused memory of the ESP.
Definition system_info.h:67
String get_value_name()
Definition system_info.h:71
void start() override final
Reports the IP address of the ESP once it's connected to wifi.
String get_value_name()
void start() override final
Construct a new transform based on a single function.
void attach(std::function< void()> observer)
static SensESPBaseApp * get()
Get the singleton instance of the SensESPBaseApp.
Sensor template class for any sensor producing actual values.
Definition sensor.h:45
Reports the current clock speed of the ESP.
Definition system_info.h:46
String get_value_name()
Definition system_info.h:50
void start() override final
Reports the number of seconds since the last restart of the ESP.
Definition system_info.h:85
String get_value_name()
Definition system_info.h:89
void start() override final
void connect_to(ValueConsumer< T > *consumer, uint8_t input_channel=0)
virtual const T & get() const
Reports the current strength of the wifi signal that the ESP is connected to.
void start() override final
void connect_system_info_sensor(SensorT< T > *sensor, String prefix, String name)
Connect a system information sensor to SKOutput.
Definition system_info.h:17