From 298724933f3353dd42973d6663d917d19d281e7d Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 22 Jan 2026 12:58:23 -1000 Subject: [PATCH 1/4] temp comment --- esphome/components/web_server/web_server.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/esphome/components/web_server/web_server.cpp b/esphome/components/web_server/web_server.cpp index e538a35e8c..5176ce3ab1 100644 --- a/esphome/components/web_server/web_server.cpp +++ b/esphome/components/web_server/web_server.cpp @@ -1,3 +1,4 @@ +// Trigger CI memory impact (uses updated ESPAsyncWebServer from web_server_base) #include "web_server.h" #ifdef USE_WEBSERVER #include "esphome/components/json/json_util.h" From be5bfe24da0198f05f883f391248186b4aa3733f Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 22 Jan 2026 22:05:50 -1000 Subject: [PATCH 2/4] [wifi] Avoid heap allocation when building AP SSID --- esphome/components/wifi/wifi_component.cpp | 26 +++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/esphome/components/wifi/wifi_component.cpp b/esphome/components/wifi/wifi_component.cpp index 52d9b2b442..68da12c251 100644 --- a/esphome/components/wifi/wifi_component.cpp +++ b/esphome/components/wifi/wifi_component.cpp @@ -746,16 +746,32 @@ void WiFiComponent::setup_ap_config_() { return; if (this->ap_.get_ssid().empty()) { - std::string name = App.get_name(); - if (name.length() > 32) { + // Build AP SSID from app name without heap allocation + // WiFi SSID max is 32 bytes, with MAC suffix we keep first 25 + last 7 + static constexpr size_t max_ssid_len = 32; + static constexpr size_t prefix_len = 25; + static constexpr size_t suffix_len = 7; + + const std::string &app_name = App.get_name(); + const char *name_ptr = app_name.c_str(); + size_t name_len = app_name.length(); + + if (name_len <= max_ssid_len) { + // Name fits, use directly + this->ap_.set_ssid(name_ptr); + } else { + // Name too long, need to truncate into stack buffer + char ssid_buf[max_ssid_len + 1]; if (App.is_name_add_mac_suffix_enabled()) { // Keep first 25 chars and last 7 chars (MAC suffix), remove middle - name.erase(25, name.length() - 32); + memcpy(ssid_buf, name_ptr, prefix_len); + memcpy(ssid_buf + prefix_len, name_ptr + name_len - suffix_len, suffix_len); } else { - name.resize(32); + memcpy(ssid_buf, name_ptr, max_ssid_len); } + ssid_buf[max_ssid_len] = '\0'; + this->ap_.set_ssid(ssid_buf); } - this->ap_.set_ssid(name); } this->ap_setup_ = this->wifi_start_ap_(this->ap_); From 425db688e50e1a94d3edb2b438fff25833fd141a Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 22 Jan 2026 22:10:08 -1000 Subject: [PATCH 3/4] [wifi] Avoid heap allocation when building AP SSID --- esphome/components/wifi/wifi_component.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/esphome/components/wifi/wifi_component.cpp b/esphome/components/wifi/wifi_component.cpp index 68da12c251..0e08e1c025 100644 --- a/esphome/components/wifi/wifi_component.cpp +++ b/esphome/components/wifi/wifi_component.cpp @@ -748,28 +748,28 @@ void WiFiComponent::setup_ap_config_() { if (this->ap_.get_ssid().empty()) { // Build AP SSID from app name without heap allocation // WiFi SSID max is 32 bytes, with MAC suffix we keep first 25 + last 7 - static constexpr size_t max_ssid_len = 32; - static constexpr size_t prefix_len = 25; - static constexpr size_t suffix_len = 7; + static constexpr size_t MAX_SSID_LEN = 32; + static constexpr size_t PREFIX_LEN = 25; + static constexpr size_t SUFFIX_LEN = 7; const std::string &app_name = App.get_name(); const char *name_ptr = app_name.c_str(); size_t name_len = app_name.length(); - if (name_len <= max_ssid_len) { + if (name_len <= MAX_SSID_LEN) { // Name fits, use directly this->ap_.set_ssid(name_ptr); } else { // Name too long, need to truncate into stack buffer - char ssid_buf[max_ssid_len + 1]; + char ssid_buf[MAX_SSID_LEN + 1]; if (App.is_name_add_mac_suffix_enabled()) { // Keep first 25 chars and last 7 chars (MAC suffix), remove middle - memcpy(ssid_buf, name_ptr, prefix_len); - memcpy(ssid_buf + prefix_len, name_ptr + name_len - suffix_len, suffix_len); + memcpy(ssid_buf, name_ptr, PREFIX_LEN); + memcpy(ssid_buf + PREFIX_LEN, name_ptr + name_len - SUFFIX_LEN, SUFFIX_LEN); } else { - memcpy(ssid_buf, name_ptr, max_ssid_len); + memcpy(ssid_buf, name_ptr, MAX_SSID_LEN); } - ssid_buf[max_ssid_len] = '\0'; + ssid_buf[MAX_SSID_LEN] = '\0'; this->ap_.set_ssid(ssid_buf); } } From ee3ef85e08c8c657795100079567e1e186c4910a Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 22 Jan 2026 22:22:42 -1000 Subject: [PATCH 4/4] tweak --- esphome/components/wifi/wifi_component.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/esphome/components/wifi/wifi_component.cpp b/esphome/components/wifi/wifi_component.cpp index 864a2c0ce2..e04af78c56 100644 --- a/esphome/components/wifi/wifi_component.cpp +++ b/esphome/components/wifi/wifi_component.cpp @@ -825,28 +825,28 @@ void WiFiComponent::setup_ap_config_() { if (this->ap_.get_ssid().empty()) { // Build AP SSID from app name without heap allocation // WiFi SSID max is 32 bytes, with MAC suffix we keep first 25 + last 7 - static constexpr size_t MAX_SSID_LEN = 32; - static constexpr size_t PREFIX_LEN = 25; - static constexpr size_t SUFFIX_LEN = 7; + static constexpr size_t AP_SSID_MAX_LEN = 32; + static constexpr size_t AP_SSID_PREFIX_LEN = 25; + static constexpr size_t AP_SSID_SUFFIX_LEN = 7; const std::string &app_name = App.get_name(); const char *name_ptr = app_name.c_str(); size_t name_len = app_name.length(); - if (name_len <= MAX_SSID_LEN) { + if (name_len <= AP_SSID_MAX_LEN) { // Name fits, use directly this->ap_.set_ssid(name_ptr); } else { // Name too long, need to truncate into stack buffer - char ssid_buf[MAX_SSID_LEN + 1]; + char ssid_buf[AP_SSID_MAX_LEN + 1]; if (App.is_name_add_mac_suffix_enabled()) { // Keep first 25 chars and last 7 chars (MAC suffix), remove middle - memcpy(ssid_buf, name_ptr, PREFIX_LEN); - memcpy(ssid_buf + PREFIX_LEN, name_ptr + name_len - SUFFIX_LEN, SUFFIX_LEN); + memcpy(ssid_buf, name_ptr, AP_SSID_PREFIX_LEN); + memcpy(ssid_buf + AP_SSID_PREFIX_LEN, name_ptr + name_len - AP_SSID_SUFFIX_LEN, AP_SSID_SUFFIX_LEN); } else { - memcpy(ssid_buf, name_ptr, MAX_SSID_LEN); + memcpy(ssid_buf, name_ptr, AP_SSID_MAX_LEN); } - ssid_buf[MAX_SSID_LEN] = '\0'; + ssid_buf[AP_SSID_MAX_LEN] = '\0'; this->ap_.set_ssid(ssid_buf); } }