This commit is contained in:
Jonathan Swoboda
2026-02-23 15:31:40 -05:00
parent 79e567a3f1
commit f21c69850c
4 changed files with 7 additions and 20 deletions

View File

@@ -152,7 +152,7 @@ void Esp32HostedUpdate::setup() {
void Esp32HostedUpdate::dump_config() {
ESP_LOGCONFIG(TAG,
"ESP32 Hosted Update:\n"
"ESP32 Hostedd Update:\n"
" Host Library Version: %s\n"
" Coprocessor Version: %s\n"
" Latest Version: %s",

View File

@@ -375,7 +375,7 @@ json::SerializationBuffer<> WebServer::get_config_json() {
JsonObject root = builder.root();
root[ESPHOME_F("title")] = App.get_friendly_name().empty() ? App.get_name().c_str() : App.get_friendly_name().c_str();
char comment_buffer[Application::COMMENT_MAX_SIZE];
char comment_buffer[Application::ESPHOME_COMMENT_SIZE_MAX];
App.get_comment_string(comment_buffer);
root[ESPHOME_F("comment")] = comment_buffer;
#if defined(USE_WEBSERVER_OTA_DISABLED) || !defined(USE_WEBSERVER_OTA)

View File

@@ -215,8 +215,7 @@ void Application::loop() {
void Application::process_dump_config_() {
if (this->dump_config_at_ == 0) {
char build_time_str[Application::BUILD_TIME_STR_SIZE];
ESPHOME_strncpy_P(build_time_str, ESPHOME_BUILD_TIME_STR, sizeof(build_time_str));
build_time_str[sizeof(build_time_str) - 1] = '\0';
this->get_build_time_string(build_time_str);
ESP_LOGI(TAG, "ESPHome version " ESPHOME_VERSION " compiled on %s", build_time_str);
#ifdef ESPHOME_PROJECT_NAME
ESP_LOGI(TAG, "Project " ESPHOME_PROJECT_NAME " version " ESPHOME_PROJECT_VERSION);
@@ -750,27 +749,15 @@ void Application::get_build_time_string(std::span<char, BUILD_TIME_STR_SIZE> buf
buffer[buffer.size() - 1] = '\0';
}
void Application::get_comment_string(std::span<char, COMMENT_MAX_SIZE> buffer) {
void Application::get_comment_string(std::span<char, ESPHOME_COMMENT_SIZE_MAX> buffer) {
ESPHOME_strncpy_P(buffer.data(), ESPHOME_COMMENT_STR, buffer.size());
buffer[buffer.size() - 1] = '\0';
}
std::string Application::get_comment() {
char buffer[COMMENT_MAX_SIZE];
this->get_comment_string(buffer);
return std::string(buffer);
}
uint32_t Application::get_config_hash() { return ESPHOME_CONFIG_HASH; }
uint32_t Application::get_config_version_hash() { return fnv1a_hash_extend(ESPHOME_CONFIG_HASH, ESPHOME_VERSION); }
time_t Application::get_build_time() { return ESPHOME_BUILD_TIME; }
std::string Application::get_compilation_time() {
char buf[BUILD_TIME_STR_SIZE];
this->get_build_time_string(buf);
return std::string(buf);
}
} // namespace esphome

View File

@@ -274,14 +274,14 @@ class Application {
}
/// Maximum size of the comment buffer (including null terminator)
static constexpr size_t COMMENT_MAX_SIZE = 256;
static constexpr size_t ESPHOME_COMMENT_SIZE_MAX = 256;
/// Copy the comment string into the provided buffer
void get_comment_string(std::span<char, COMMENT_MAX_SIZE> buffer);
void get_comment_string(std::span<char, ESPHOME_COMMENT_SIZE_MAX> buffer);
/// Get the comment of this Application as a string
std::string get_comment() {
char buffer[COMMENT_MAX_SIZE];
char buffer[ESPHOME_COMMENT_SIZE_MAX];
this->get_comment_string(buffer);
return std::string(buffer);
}