16#ifdef USE_BINARY_SENSOR
20#include <dlms_parser/dlms_parser.h>
28#if __has_include(<psa/crypto.h>)
29#include <dlms_parser/decryption/aes_128_gcm_decryptor_tfpsa.h>
30#elif !defined(USE_ESP8266) && __has_include(<mbedtls/gcm.h>)
31#if __has_include(<mbedtls/esp_config.h>)
32#include <mbedtls/esp_config.h>
34#include <dlms_parser/decryption/aes_128_gcm_decryptor_mbedtls.h>
35#elif __has_include(<bearssl/bearssl.h>)
36#include <dlms_parser/decryption/aes_128_gcm_decryptor_bearssl.h>
38#define DLMS_METER_NO_CRYPTO
41#ifndef DLMS_MAX_SENSORS
42static constexpr uint8_t DLMS_MAX_SENSORS = 0;
44#ifndef DLMS_MAX_TEXT_SENSORS
45static constexpr uint8_t DLMS_MAX_TEXT_SENSORS = 0;
47#ifndef DLMS_MAX_BINARY_SENSORS
48static constexpr uint8_t DLMS_MAX_BINARY_SENSORS = 0;
53#ifdef DLMS_METER_NO_CRYPTO
58 bool decrypt_in_place(std::span<const uint8_t> iv, std::span<uint8_t> ciphertext_and_plaintext,
59 std::span<const uint8_t> aad, std::span<const uint8_t>
tag)
override {
65#if __has_include(<psa/crypto.h>)
67#elif !defined(USE_ESP8266) && __has_include(<mbedtls/gcm.h>)
69#elif __has_include(<bearssl/bearssl.h>)
87#ifdef USE_BINARY_SENSOR
96 std::optional<std::string>
name;
104 std::optional<std::array<uint8_t, 16>> decryption_key,
105 std::optional<std::array<uint8_t, 16>> authentication_key,
106 std::vector<CustomPattern> custom_patterns);
108 void setup()
override;
110 void loop()
override;
115#ifdef USE_TEXT_SENSOR
118#ifdef USE_BINARY_SENSOR
126 void on_data_(
const char *obis_code,
float float_val,
const char *str_val,
bool is_numeric);
143#ifdef USE_TEXT_SENSOR
146#ifdef USE_BINARY_SENSOR
Minimal static vector - saves memory by avoiding std::vector overhead.
Base class for all binary_sensor-type classes.
bool decrypt_in_place(std::span< const uint8_t > iv, std::span< uint8_t > ciphertext_and_plaintext, std::span< const uint8_t > aad, std::span< const uint8_t > tag) override
void set_decryption_key(const dlms_parser::Aes128GcmDecryptionKey &key) override
StaticVector< SensorItem, DLMS_MAX_SENSORS > sensors_
std::vector< CustomPattern > custom_patterns_
void register_sensor(const std::string &obis_code, sensor::Sensor *sensor)
std::array< uint8_t, 2048 > rx_buffer_
void register_binary_sensor(const std::string &obis_code, binary_sensor::BinarySensor *sensor)
void dump_config() override
uint32_t receive_timeout_ms_
StaticVector< TextSensorItem, DLMS_MAX_TEXT_SENSORS > text_sensors_
StaticVector< BinarySensorItem, DLMS_MAX_BINARY_SENSORS > binary_sensors_
void on_data_(const char *obis_code, float float_val, const char *str_val, bool is_numeric)
size_t bytes_accumulated_
void register_text_sensor(const std::string &obis_code, text_sensor::TextSensor *sensor)
dlms_parser::DlmsParser parser_
Aes128GcmDecryptorImpl decryptor_
uint32_t last_rx_char_time_
DlmsMeterComponent(uint32_t receive_timeout_ms, bool skip_crc_check, std::optional< std::array< uint8_t, 16 > > decryption_key, std::optional< std::array< uint8_t, 16 > > authentication_key, std::vector< CustomPattern > custom_patterns)
Base-class for all sensors.
dlms_parser::Aes128GcmDecryptorTfPsa Aes128GcmDecryptorImpl
binary_sensor::BinarySensor * sensor
std::optional< std::array< uint8_t, 6 > > default_obis
std::optional< std::string > name
text_sensor::TextSensor * sensor