ESPHome  2024.10.2
sml_parser.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <cstdint>
4 #include <cstdio>
5 #include <string>
6 #include <vector>
7 #include "constants.h"
8 
9 namespace esphome {
10 namespace sml {
11 
12 using bytes = std::vector<uint8_t>;
13 
14 class SmlNode {
15  public:
16  uint8_t type;
18  std::vector<SmlNode> nodes;
19 };
20 
21 class ObisInfo {
22  public:
23  ObisInfo(bytes server_id, SmlNode val_list_entry);
27  char unit;
28  char scaler;
30  uint16_t value_type;
31  std::string code_repr() const;
32 };
33 
34 class SmlFile {
35  public:
36  SmlFile(bytes buffer);
37  bool setup_node(SmlNode *node);
38  std::vector<SmlNode> messages;
39  std::vector<ObisInfo> get_obis_info();
40 
41  protected:
42  const bytes buffer_;
43  size_t pos_;
44 };
45 
46 std::string bytes_repr(const bytes &buffer);
47 
48 uint64_t bytes_to_uint(const bytes &buffer);
49 
50 int64_t bytes_to_int(const bytes &buffer);
51 
52 std::string bytes_to_string(const bytes &buffer);
53 } // namespace sml
54 } // namespace esphome
std::string bytes_repr(const bytes &buffer)
Definition: sml_parser.cpp:106
int64_t bytes_to_int(const bytes &buffer)
Definition: sml_parser.cpp:122
uint64_t bytes_to_uint(const bytes &buffer)
Definition: sml_parser.cpp:114
std::string bytes_to_string(const bytes &buffer)
Definition: sml_parser.cpp:138
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
std::vector< uint8_t > bytes
Definition: sml_parser.h:12
const bytes buffer_
Definition: sml_parser.h:42
std::vector< SmlNode > messages
Definition: sml_parser.h:38
std::vector< SmlNode > nodes
Definition: sml_parser.h:18