1
0
mirror of https://github.com/esphome/esphome.git synced 2026-02-08 08:41:59 +00:00

[improv_serial] Use stack buffer for RSSI formatting

This commit is contained in:
J. Nick Koston
2025-12-20 10:55:16 -10:00
parent 6c2d255230
commit c0ab783ba2

View File

@@ -263,8 +263,10 @@ bool ImprovSerialComponent::parse_improv_payload_(improv::ImprovCommand &command
if (std::find(networks.begin(), networks.end(), ssid) != networks.end())
continue;
// Send each ssid separately to avoid overflowing the buffer
std::vector<uint8_t> data = improv::build_rpc_response(
improv::GET_WIFI_NETWORKS, {ssid, str_sprintf("%d", scan.get_rssi()), YESNO(scan.get_with_auth())}, false);
char rssi_buf[8]; // RSSI range: -127 to 0
snprintf(rssi_buf, sizeof(rssi_buf), "%d", scan.get_rssi());
std::vector<uint8_t> data =
improv::build_rpc_response(improv::GET_WIFI_NETWORKS, {ssid, rssi_buf, YESNO(scan.get_with_auth())}, false);
this->send_response_(data);
networks.push_back(ssid);
}