Make DLMS string helpers write to buffer
Change DlmsParser::data_to_string_ and obis_to_string_ signatures to return void and write into the provided caller buffer instead of returning std::string (avoids allocations and clarifies ownership). Also add #include "esphome/core/application.h" in dlms_push.cpp for required declarations.main
parent
8fc10fb496
commit
789611a611
|
|
@ -113,8 +113,8 @@ class DlmsParser {
|
||||||
void emit_object_(const AxdrDescriptorPattern &pat, const AxdrCaptures &c);
|
void emit_object_(const AxdrDescriptorPattern &pat, const AxdrCaptures &c);
|
||||||
|
|
||||||
float data_as_float_(DlmsDataType value_type, const uint8_t *ptr, uint8_t len);
|
float data_as_float_(DlmsDataType value_type, const uint8_t *ptr, uint8_t len);
|
||||||
std::string data_to_string_(DlmsDataType value_type, const uint8_t *ptr, uint8_t len, char *buffer, size_t max_len);
|
void data_to_string_(DlmsDataType value_type, const uint8_t *ptr, uint8_t len, char *buffer, size_t max_len);
|
||||||
std::string obis_to_string_(const uint8_t *obis, char *buffer, size_t max_len);
|
void obis_to_string_(const uint8_t *obis, char *buffer, size_t max_len);
|
||||||
const char *dlms_data_type_to_string_(DlmsDataType vt);
|
const char *dlms_data_type_to_string_(DlmsDataType vt);
|
||||||
|
|
||||||
const uint8_t *buffer_{nullptr};
|
const uint8_t *buffer_{nullptr};
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
#include "dlms_parser.h"
|
#include "dlms_parser.h"
|
||||||
|
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
|
#include "esphome/core/application.h"
|
||||||
#include "esphome/core/helpers.h"
|
#include "esphome/core/helpers.h"
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue