1
0
mirror of https://github.com/esphome/esphome.git synced 2025-11-06 10:01:51 +00:00

Compare commits

...

1 Commits

Author SHA1 Message Date
J. Nick Koston
358296a57e [remote_base] Eliminate substr() allocations in Pronto dump logging 2025-11-04 22:32:20 -06:00

View File

@@ -71,6 +71,7 @@ static const uint16_t FALLBACK_FREQUENCY = 64767U; // To use with frequency = 0
static const uint32_t MICROSECONDS_IN_SECONDS = 1000000UL;
static const uint16_t PRONTO_DEFAULT_GAP = 45000;
static const uint16_t MARK_EXCESS_MICROS = 20;
static constexpr size_t PRONTO_LOG_CHUNK_SIZE = 230;
static uint16_t to_frequency_k_hz(uint16_t code) {
if (code == 0)
@@ -225,18 +226,17 @@ optional<ProntoData> ProntoProtocol::decode(RemoteReceiveData src) {
}
void ProntoProtocol::dump(const ProntoData &data) {
std::string rest;
rest = data.data;
std::string rest = data.data;
ESP_LOGI(TAG, "Received Pronto: data=");
while (true) {
ESP_LOGI(TAG, "%s", rest.substr(0, 230).c_str());
if (rest.size() > 230) {
rest = rest.substr(230);
do {
size_t chunk_size = rest.size() > PRONTO_LOG_CHUNK_SIZE ? PRONTO_LOG_CHUNK_SIZE : rest.size();
ESP_LOGI(TAG, "%.*s", (int) chunk_size, rest.c_str());
if (rest.size() > PRONTO_LOG_CHUNK_SIZE) {
rest.erase(0, PRONTO_LOG_CHUNK_SIZE);
} else {
break;
}
}
} while (true);
}
} // namespace remote_base