You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -5,26 +5,26 @@ It is designed for embedded and integration-heavy environments such as ESPHome,
5
5
6
6
## Features
7
7
8
-
-**Transport decoding**: `RAW`, `HDLC`, `M-Bus`. Including multi-frame segmentation and General Block Transfer
8
+
-**Transport decoding**: `RAW`, `HDLC`, `M-Bus`. Auto-detects the frame format based on the leading byte. Includes multi-frame segmentation and General Block Transfer
9
9
-**Encryption**: AES-128-GCM decryption and optional authentication tag verification for `General-GLO-Ciphering` and `General-DED-Ciphering` APDUs
10
+
-**Crypto Backends**: Pluggable decryption backends with built-in support for `mbedTLS`, `BearSSL`, and `TF-PSA`
10
11
-**Pattern matching**: DSL-based AXDR descriptor patterns with built-in presets and custom registration
11
-
-**Callback API**: cooked callback delivers OBIS code + scaled value; raw callback gives full capture details
12
+
-**Callback API**: cooked callback delivers OBIS code + scaled value
12
13
-**Embedded-friendly**: no heap allocation during parsing
13
14
-**Portable**: builds on ESP32 (IDF/Arduino), ESP8266, Linux, macOS, Windows
14
15
15
16
## How to use
16
17
17
18
Complete example with the explanation: [test_example.cpp](https://github.com/esphome-libs/dlms_parser/blob/main/tests/test_example.cpp)
18
19
19
-
##How to creating custom patterns to match your meter's telegram structure
20
+
### Creating custom patterns to match your meter's telegram structure
20
21
21
22
The parser starts with no registered AXDR patterns. Load the built-ins first unless you want full control:
22
-
23
-
```cpp
23
+
```c++
24
24
parser.load_default_patterns();
25
25
```
26
26
27
-
Built-in patterns
27
+
**Built-in patterns (available after calling `parser.load_default_patterns()`):**
|`DN`| descend into nested structure | control token |
92
93
|`UP`| return from nested structure | control token |
93
94
95
+
## API Reference
96
+
97
+
### `DlmsParser` Core Methods
98
+
99
+
> **⚠️ Warning:** If you intend to use encryption, you **must** provide a concrete `Aes128GcmDecryptor` backend to the constructor before calling `set_decryption_key` or `set_authentication_key`. Calling these methods on a parser initialized with the default `nullptr` decryptor will cause a null pointer dereference.
|`DlmsParser(Aes128GcmDecryptor* = nullptr)`| Constructor accepting an optional pointer to an AES-128-GCM decryptor backend. |
104
+
|`set_skip_crc_check(bool)`| Skip CRC/checksum validation for HDLC and M-Bus. |
105
+
|`set_decryption_key(const Aes128GcmDecryptionKey&)`| Set AES-128-GCM decryption key (GUEK). **Requires a non-null decryptor.**|
106
+
|`set_authentication_key(const Aes128GcmAuthenticationKey&)`| Set AES-128-GCM authentication key (GAK) for GCM tag verification. **Requires a non-null decryptor.**|
|`ParseResult parse(std::span<uint8_t> buf, const DlmsDataCallback&)`| Parse a complete frame; modifies the buffer in-place and triggers the callback. |
`dlms_parser` includes a built-in logging system that is useful for debugging frame parsing and pattern matching. You can hook into it by providing a custom log function:
0 commit comments