ESPHome 2025.5.0
Loading...
Searching...
No Matches
teleinfo.h
Go to the documentation of this file.
1#pragma once
2
5
6#include <vector>
7
8namespace esphome {
9namespace teleinfo {
10/*
11 * 198 bytes should be enough to contain a full session in historical mode with
12 * three phases. But go with 1024 just to be sure.
13 */
14static const uint8_t MAX_TAG_SIZE = 64;
15static const uint16_t MAX_VAL_SIZE = 256;
16static const uint16_t MAX_BUF_SIZE = 2048;
17static const uint16_t MAX_TIMESTAMP_SIZE = 14;
18
20 public:
21 std::string tag;
22 virtual void publish_val(const std::string &val){};
23};
25 public:
26 TeleInfo(bool historical_mode);
28 void loop() override;
29 void setup() override;
30 void update() override;
31 void dump_config() override;
32 std::vector<TeleInfoListener *> teleinfo_listeners_{};
33
34 protected:
35 uint32_t baud_rate_;
38 char buf_[MAX_BUF_SIZE];
39 uint32_t buf_index_{0};
40 char tag_[MAX_TAG_SIZE];
41 char val_[MAX_VAL_SIZE];
42 char timestamp_[MAX_TIMESTAMP_SIZE];
49 bool read_chars_until_(bool drop, uint8_t c);
50 bool check_crc_(const char *grp, const char *grp_end);
51 void publish_value_(const std::string &tag, const std::string &val);
52};
53} // namespace teleinfo
54} // namespace esphome
This class simplifies creating components that periodically check a state.
Definition component.h:301
void publish_value_(const std::string &tag, const std::string &val)
Definition teleinfo.cpp:181
char timestamp_[MAX_TIMESTAMP_SIZE]
Definition teleinfo.h:42
char buf_[MAX_BUF_SIZE]
Definition teleinfo.h:38
TeleInfo(bool historical_mode)
Definition teleinfo.cpp:192
char val_[MAX_VAL_SIZE]
Definition teleinfo.h:41
void register_teleinfo_listener(TeleInfoListener *listener)
Definition teleinfo.cpp:206
bool check_crc_(const char *grp, const char *grp_end)
Definition teleinfo.cpp:26
enum esphome::teleinfo::TeleInfo::State OFF
std::vector< TeleInfoListener * > teleinfo_listeners_
Definition teleinfo.h:32
char tag_[MAX_TAG_SIZE]
Definition teleinfo.h:40
void dump_config() override
Definition teleinfo.cpp:188
bool read_chars_until_(bool drop, uint8_t c)
Definition teleinfo.cpp:44
virtual void publish_val(const std::string &val)
Definition teleinfo.h:22
mopeka_std_values val[4]
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7