[opentherm] Fix out of memory errors on ESP8266 (#7835)

This commit is contained in:
Oleg Tarasov
2024-11-26 10:47:01 +13:00
committed by GitHub
parent cf835d1580
commit 89ecfc2004
5 changed files with 39 additions and 37 deletions
+12
View File
@@ -397,6 +397,18 @@ std::string format_hex_pretty(const uint16_t *data, size_t length) {
}
std::string format_hex_pretty(const std::vector<uint16_t> &data) { return format_hex_pretty(data.data(), data.size()); }
std::string format_bin(const uint8_t *data, size_t length) {
std::string result;
result.resize(length * 8);
for (size_t byte_idx = 0; byte_idx < length; byte_idx++) {
for (size_t bit_idx = 0; bit_idx < 8; bit_idx++) {
result[byte_idx * 8 + bit_idx] = ((data[byte_idx] >> (7 - bit_idx)) & 1) + '0';
}
}
return result;
}
ParseOnOffState parse_on_off(const char *str, const char *on, const char *off) {
if (on == nullptr && strcasecmp(str, "on") == 0)
return PARSE_ON;