mirror of
https://github.com/esphome/esphome.git
synced 2025-10-29 06:04:01 +00:00
preen
This commit is contained in:
@@ -218,10 +218,10 @@ bool ESP32BLE::ble_setup_() {
|
|||||||
name = this->name_.value();
|
name = this->name_.value();
|
||||||
if (App.is_name_add_mac_suffix_enabled()) {
|
if (App.is_name_add_mac_suffix_enabled()) {
|
||||||
// MAC address suffix length (last 6 characters of 12-char MAC address string)
|
// MAC address suffix length (last 6 characters of 12-char MAC address string)
|
||||||
constexpr size_t MAC_ADDRESS_SUFFIX_LEN = 6;
|
constexpr size_t mac_address_suffix_len = 6;
|
||||||
const std::string mac_addr = get_mac_address();
|
const std::string mac_addr = get_mac_address();
|
||||||
const char *mac_suffix_ptr = mac_addr.c_str() + MAC_ADDRESS_SUFFIX_LEN;
|
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);
|
name = make_name_with_suffix(name, '-', mac_suffix_ptr, mac_address_suffix_len);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
name = App.get_name();
|
name = App.get_name();
|
||||||
|
|||||||
@@ -692,8 +692,8 @@ void EthernetComponent::set_manual_ip(const ManualIP &manual_ip) { this->manual_
|
|||||||
std::string EthernetComponent::get_use_address() const {
|
std::string EthernetComponent::get_use_address() const {
|
||||||
if (this->use_address_.empty()) {
|
if (this->use_address_.empty()) {
|
||||||
// ".local" suffix length for mDNS hostnames
|
// ".local" suffix length for mDNS hostnames
|
||||||
constexpr size_t MDNS_LOCAL_SUFFIX_LEN = 5;
|
constexpr size_t mdns_local_suffix_len = 5;
|
||||||
return make_name_with_suffix(App.get_name(), '.', "local", MDNS_LOCAL_SUFFIX_LEN);
|
return make_name_with_suffix(App.get_name(), '.', "local", mdns_local_suffix_len);
|
||||||
}
|
}
|
||||||
return this->use_address_;
|
return this->use_address_;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -268,8 +268,8 @@ network::IPAddress WiFiComponent::get_dns_address(int num) {
|
|||||||
std::string WiFiComponent::get_use_address() const {
|
std::string WiFiComponent::get_use_address() const {
|
||||||
if (this->use_address_.empty()) {
|
if (this->use_address_.empty()) {
|
||||||
// ".local" suffix length for mDNS hostnames
|
// ".local" suffix length for mDNS hostnames
|
||||||
constexpr size_t MDNS_LOCAL_SUFFIX_LEN = 5;
|
constexpr size_t mdns_local_suffix_len = 5;
|
||||||
return make_name_with_suffix(App.get_name(), '.', "local", MDNS_LOCAL_SUFFIX_LEN);
|
return make_name_with_suffix(App.get_name(), '.', "local", mdns_local_suffix_len);
|
||||||
}
|
}
|
||||||
return this->use_address_;
|
return this->use_address_;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,13 +103,13 @@ class Application {
|
|||||||
this->name_add_mac_suffix_ = name_add_mac_suffix;
|
this->name_add_mac_suffix_ = name_add_mac_suffix;
|
||||||
if (name_add_mac_suffix) {
|
if (name_add_mac_suffix) {
|
||||||
// MAC address suffix length (last 6 characters of 12-char MAC address string)
|
// MAC address suffix length (last 6 characters of 12-char MAC address string)
|
||||||
constexpr size_t MAC_ADDRESS_SUFFIX_LEN = 6;
|
constexpr size_t mac_address_suffix_len = 6;
|
||||||
const std::string mac_addr = get_mac_address();
|
const std::string mac_addr = get_mac_address();
|
||||||
// Use pointer + offset to avoid substr() allocation
|
// Use pointer + offset to avoid substr() allocation
|
||||||
const char *mac_suffix_ptr = mac_addr.c_str() + MAC_ADDRESS_SUFFIX_LEN;
|
const char *mac_suffix_ptr = mac_addr.c_str() + mac_address_suffix_len;
|
||||||
this->name_ = make_name_with_suffix(name, '-', mac_suffix_ptr, MAC_ADDRESS_SUFFIX_LEN);
|
this->name_ = make_name_with_suffix(name, '-', mac_suffix_ptr, mac_address_suffix_len);
|
||||||
if (!friendly_name.empty()) {
|
if (!friendly_name.empty()) {
|
||||||
this->friendly_name_ = make_name_with_suffix(friendly_name, ' ', mac_suffix_ptr, MAC_ADDRESS_SUFFIX_LEN);
|
this->friendly_name_ = make_name_with_suffix(friendly_name, ' ', mac_suffix_ptr, mac_address_suffix_len);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this->name_ = name;
|
this->name_ = name;
|
||||||
|
|||||||
Reference in New Issue
Block a user