mirror of
https://github.com/esphome/esphome.git
synced 2025-11-17 15:26:01 +00:00
[wifi] Pass ManualIP by const reference to reduce stack usage
This commit is contained in:
@@ -118,10 +118,10 @@ struct IPAddress {
|
|||||||
operator arduino_ns::IPAddress() const { return ip_addr_get_ip4_u32(&ip_addr_); }
|
operator arduino_ns::IPAddress() const { return ip_addr_get_ip4_u32(&ip_addr_); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool is_set() { return !ip_addr_isany(&ip_addr_); } // NOLINT(readability-simplify-boolean-expr)
|
bool is_set() const { return !ip_addr_isany(&ip_addr_); } // NOLINT(readability-simplify-boolean-expr)
|
||||||
bool is_ip4() { return IP_IS_V4(&ip_addr_); }
|
bool is_ip4() const { return IP_IS_V4(&ip_addr_); }
|
||||||
bool is_ip6() { return IP_IS_V6(&ip_addr_); }
|
bool is_ip6() const { return IP_IS_V6(&ip_addr_); }
|
||||||
bool is_multicast() { return ip_addr_ismulticast(&ip_addr_); }
|
bool is_multicast() const { return ip_addr_ismulticast(&ip_addr_); }
|
||||||
std::string str() const { return str_lower_case(ipaddr_ntoa(&ip_addr_)); }
|
std::string str() const { return str_lower_case(ipaddr_ntoa(&ip_addr_)); }
|
||||||
bool operator==(const IPAddress &other) const { return ip_addr_cmp(&ip_addr_, &other.ip_addr_); }
|
bool operator==(const IPAddress &other) const { return ip_addr_cmp(&ip_addr_, &other.ip_addr_); }
|
||||||
bool operator!=(const IPAddress &other) const { return !ip_addr_cmp(&ip_addr_, &other.ip_addr_); }
|
bool operator!=(const IPAddress &other) const { return !ip_addr_cmp(&ip_addr_, &other.ip_addr_); }
|
||||||
|
|||||||
@@ -426,7 +426,7 @@ class WiFiComponent : public Component {
|
|||||||
bool wifi_sta_pre_setup_();
|
bool wifi_sta_pre_setup_();
|
||||||
bool wifi_apply_output_power_(float output_power);
|
bool wifi_apply_output_power_(float output_power);
|
||||||
bool wifi_apply_power_save_();
|
bool wifi_apply_power_save_();
|
||||||
bool wifi_sta_ip_config_(optional<ManualIP> manual_ip);
|
bool wifi_sta_ip_config_(const optional<ManualIP> &manual_ip);
|
||||||
bool wifi_apply_hostname_();
|
bool wifi_apply_hostname_();
|
||||||
bool wifi_sta_connect_(const WiFiAP &ap);
|
bool wifi_sta_connect_(const WiFiAP &ap);
|
||||||
void wifi_pre_setup_();
|
void wifi_pre_setup_();
|
||||||
@@ -434,7 +434,7 @@ class WiFiComponent : public Component {
|
|||||||
bool wifi_scan_start_(bool passive);
|
bool wifi_scan_start_(bool passive);
|
||||||
|
|
||||||
#ifdef USE_WIFI_AP
|
#ifdef USE_WIFI_AP
|
||||||
bool wifi_ap_ip_config_(optional<ManualIP> manual_ip);
|
bool wifi_ap_ip_config_(const optional<ManualIP> &manual_ip);
|
||||||
bool wifi_start_ap_(const WiFiAP &ap);
|
bool wifi_start_ap_(const WiFiAP &ap);
|
||||||
#endif // USE_WIFI_AP
|
#endif // USE_WIFI_AP
|
||||||
|
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ void netif_set_addr(struct netif *netif, const ip4_addr_t *ip, const ip4_addr_t
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool WiFiComponent::wifi_sta_ip_config_(optional<ManualIP> manual_ip) {
|
bool WiFiComponent::wifi_sta_ip_config_(const optional<ManualIP> &manual_ip) {
|
||||||
// enable STA
|
// enable STA
|
||||||
if (!this->wifi_mode_(true, {}))
|
if (!this->wifi_mode_(true, {}))
|
||||||
return false;
|
return false;
|
||||||
@@ -730,7 +730,7 @@ void WiFiComponent::wifi_scan_done_callback_(void *arg, STATUS status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_WIFI_AP
|
#ifdef USE_WIFI_AP
|
||||||
bool WiFiComponent::wifi_ap_ip_config_(optional<ManualIP> manual_ip) {
|
bool WiFiComponent::wifi_ap_ip_config_(const optional<ManualIP> &manual_ip) {
|
||||||
// enable AP
|
// enable AP
|
||||||
if (!this->wifi_mode_({}, true))
|
if (!this->wifi_mode_({}, true))
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -487,7 +487,7 @@ bool WiFiComponent::wifi_sta_connect_(const WiFiAP &ap) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WiFiComponent::wifi_sta_ip_config_(optional<ManualIP> manual_ip) {
|
bool WiFiComponent::wifi_sta_ip_config_(const optional<ManualIP> &manual_ip) {
|
||||||
// enable STA
|
// enable STA
|
||||||
if (!this->wifi_mode_(true, {}))
|
if (!this->wifi_mode_(true, {}))
|
||||||
return false;
|
return false;
|
||||||
@@ -884,7 +884,7 @@ bool WiFiComponent::wifi_scan_start_(bool passive) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_WIFI_AP
|
#ifdef USE_WIFI_AP
|
||||||
bool WiFiComponent::wifi_ap_ip_config_(optional<ManualIP> manual_ip) {
|
bool WiFiComponent::wifi_ap_ip_config_(const optional<ManualIP> &manual_ip) {
|
||||||
esp_err_t err;
|
esp_err_t err;
|
||||||
|
|
||||||
// enable AP
|
// enable AP
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ bool WiFiComponent::wifi_sta_pre_setup_() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool WiFiComponent::wifi_apply_power_save_() { return WiFi.setSleep(this->power_save_ != WIFI_POWER_SAVE_NONE); }
|
bool WiFiComponent::wifi_apply_power_save_() { return WiFi.setSleep(this->power_save_ != WIFI_POWER_SAVE_NONE); }
|
||||||
bool WiFiComponent::wifi_sta_ip_config_(optional<ManualIP> manual_ip) {
|
bool WiFiComponent::wifi_sta_ip_config_(const optional<ManualIP> &manual_ip) {
|
||||||
// enable STA
|
// enable STA
|
||||||
if (!this->wifi_mode_(true, {}))
|
if (!this->wifi_mode_(true, {}))
|
||||||
return false;
|
return false;
|
||||||
@@ -434,7 +434,7 @@ void WiFiComponent::wifi_scan_done_callback_() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_WIFI_AP
|
#ifdef USE_WIFI_AP
|
||||||
bool WiFiComponent::wifi_ap_ip_config_(optional<ManualIP> manual_ip) {
|
bool WiFiComponent::wifi_ap_ip_config_(const optional<ManualIP> &manual_ip) {
|
||||||
// enable AP
|
// enable AP
|
||||||
if (!this->wifi_mode_({}, true))
|
if (!this->wifi_mode_({}, true))
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ bool WiFiComponent::wifi_sta_connect_(const WiFiAP &ap) {
|
|||||||
|
|
||||||
bool WiFiComponent::wifi_sta_pre_setup_() { return this->wifi_mode_(true, {}); }
|
bool WiFiComponent::wifi_sta_pre_setup_() { return this->wifi_mode_(true, {}); }
|
||||||
|
|
||||||
bool WiFiComponent::wifi_sta_ip_config_(optional<ManualIP> manual_ip) {
|
bool WiFiComponent::wifi_sta_ip_config_(const optional<ManualIP> &manual_ip) {
|
||||||
if (!manual_ip.has_value()) {
|
if (!manual_ip.has_value()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -146,7 +146,7 @@ bool WiFiComponent::wifi_scan_start_(bool passive) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_WIFI_AP
|
#ifdef USE_WIFI_AP
|
||||||
bool WiFiComponent::wifi_ap_ip_config_(optional<ManualIP> manual_ip) {
|
bool WiFiComponent::wifi_ap_ip_config_(const optional<ManualIP> &manual_ip) {
|
||||||
esphome::network::IPAddress ip_address, gateway, subnet, dns;
|
esphome::network::IPAddress ip_address, gateway, subnet, dns;
|
||||||
if (manual_ip.has_value()) {
|
if (manual_ip.has_value()) {
|
||||||
ip_address = manual_ip->static_ip;
|
ip_address = manual_ip->static_ip;
|
||||||
|
|||||||
Reference in New Issue
Block a user