[core] Add format_hex_pretty_to buffer helper and reduce code duplication (#12687)

This commit is contained in:
J. Nick Koston
2025-12-30 11:51:51 -10:00
committed by GitHub
parent dae7ba604a
commit bd3ecad3a1
7 changed files with 96 additions and 68 deletions
@@ -123,10 +123,11 @@ void ZWaveProxy::process_uart_() {
}
void ZWaveProxy::dump_config() {
char hex_buf[format_hex_pretty_size(ZWAVE_HOME_ID_SIZE)];
ESP_LOGCONFIG(TAG,
"Z-Wave Proxy:\n"
" Home ID: %s",
format_hex_pretty(this->home_id_.data(), this->home_id_.size(), ':', false).c_str());
format_hex_pretty_to(hex_buf, this->home_id_.data(), this->home_id_.size()));
}
void ZWaveProxy::api_connection_authenticated(api::APIConnection *conn) {
@@ -167,7 +168,8 @@ bool ZWaveProxy::set_home_id(const uint8_t *new_home_id) {
return false; // No change
}
std::memcpy(this->home_id_.data(), new_home_id, this->home_id_.size());
ESP_LOGI(TAG, "Home ID: %s", format_hex_pretty(this->home_id_.data(), this->home_id_.size(), ':', false).c_str());
char hex_buf[format_hex_pretty_size(ZWAVE_HOME_ID_SIZE)];
ESP_LOGI(TAG, "Home ID: %s", format_hex_pretty_to(hex_buf, this->home_id_.data(), this->home_id_.size()));
this->home_id_ready_ = true;
return true; // Home ID was changed
}