1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-29 22:24:26 +00:00
This commit is contained in:
J. Nick Koston
2025-10-11 15:34:31 -10:00
10 changed files with 30 additions and 17 deletions

View File

@@ -325,8 +325,8 @@ def _is_framework_url(source: str) -> str:
# - https://github.com/espressif/arduino-esp32/releases
ARDUINO_FRAMEWORK_VERSION_LOOKUP = {
"recommended": cv.Version(3, 2, 1),
"latest": cv.Version(3, 3, 1),
"dev": cv.Version(3, 3, 1),
"latest": cv.Version(3, 3, 2),
"dev": cv.Version(3, 3, 2),
}
ARDUINO_PLATFORM_VERSION_LOOKUP = {
cv.Version(3, 3, 2): cv.Version(55, 3, 31, "1"),

View File

@@ -217,7 +217,11 @@ bool ESP32BLE::ble_setup_() {
if (this->name_.has_value()) {
name = this->name_.value();
if (App.is_name_add_mac_suffix_enabled()) {
name = make_name_with_suffix(name, '-', get_mac_address().substr(6));
// MAC address suffix length (last 6 characters of 12-char MAC address string)
constexpr size_t MAC_ADDRESS_SUFFIX_LEN = 6;
const std::string mac_addr = get_mac_address();
const char *mac_suffix_ptr = mac_addr.c_str() + MAC_ADDRESS_SUFFIX_LEN;
name = make_name_with_suffix(name, '-', mac_suffix_ptr, MAC_ADDRESS_SUFFIX_LEN);
}
} else {
name = App.get_name();

View File

@@ -691,7 +691,9 @@ void EthernetComponent::set_manual_ip(const ManualIP &manual_ip) { this->manual_
std::string EthernetComponent::get_use_address() const {
if (this->use_address_.empty()) {
return make_name_with_suffix(App.get_name(), '.', "local");
// ".local" suffix length for mDNS hostnames
constexpr size_t MDNS_LOCAL_SUFFIX_LEN = 5;
return make_name_with_suffix(App.get_name(), '.', "local", MDNS_LOCAL_SUFFIX_LEN);
}
return this->use_address_;
}

View File

@@ -29,7 +29,8 @@ static const char *const TAG = "mqtt";
MQTTClientComponent::MQTTClientComponent() {
global_mqtt_client = this;
this->credentials_.client_id = make_name_with_suffix(App.get_name(), '-', get_mac_address());
const std::string mac_addr = get_mac_address();
this->credentials_.client_id = make_name_with_suffix(App.get_name(), '-', mac_addr.c_str(), mac_addr.size());
}
// Connection

View File

@@ -267,7 +267,9 @@ network::IPAddress WiFiComponent::get_dns_address(int num) {
}
std::string WiFiComponent::get_use_address() const {
if (this->use_address_.empty()) {
return make_name_with_suffix(App.get_name(), '.', "local");
// ".local" suffix length for mDNS hostnames
constexpr size_t MDNS_LOCAL_SUFFIX_LEN = 5;
return make_name_with_suffix(App.get_name(), '.', "local", MDNS_LOCAL_SUFFIX_LEN);
}
return this->use_address_;
}