1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-02 19:32:19 +01:00

wifi: Don't build SoftAP/DHCPS support unless 'ap' is in config. (#5649)

This commit is contained in:
Kevin P. Fleming
2023-11-19 22:32:46 -05:00
committed by GitHub
parent 2aaee81313
commit e367ab26e1
9 changed files with 79 additions and 12 deletions

View File

@@ -82,6 +82,7 @@ void WiFiComponent::start() {
} else {
this->start_scanning();
}
#ifdef USE_WIFI_AP
} else if (this->has_ap()) {
this->setup_ap_config_();
if (this->output_power_.has_value() && !this->wifi_apply_output_power_(*this->output_power_)) {
@@ -94,6 +95,7 @@ void WiFiComponent::start() {
captive_portal::global_captive_portal->start();
}
#endif
#endif // USE_WIFI_AP
}
#ifdef USE_IMPROV
if (!this->has_sta() && esp32_improv::global_improv_component != nullptr) {
@@ -160,6 +162,7 @@ void WiFiComponent::loop() {
return;
}
#ifdef USE_WIFI_AP
if (this->has_ap() && !this->ap_setup_) {
if (now - this->last_connected_ > this->ap_timeout_) {
ESP_LOGI(TAG, "Starting fallback AP!");
@@ -170,6 +173,7 @@ void WiFiComponent::loop() {
#endif
}
}
#endif // USE_WIFI_AP
#ifdef USE_IMPROV
if (esp32_improv::global_improv_component != nullptr && !esp32_improv::global_improv_component->is_active()) {
@@ -199,11 +203,16 @@ void WiFiComponent::set_fast_connect(bool fast_connect) { this->fast_connect_ =
void WiFiComponent::set_btm(bool btm) { this->btm_ = btm; }
void WiFiComponent::set_rrm(bool rrm) { this->rrm_ = rrm; }
#endif
network::IPAddress WiFiComponent::get_ip_address() {
if (this->has_sta())
return this->wifi_sta_ip();
#ifdef USE_WIFI_AP
if (this->has_ap())
return this->wifi_soft_ap_ip();
#endif // USE_WIFI_AP
return {};
}
network::IPAddress WiFiComponent::get_dns_address(int num) {
@@ -218,6 +227,8 @@ std::string WiFiComponent::get_use_address() const {
return this->use_address_;
}
void WiFiComponent::set_use_address(const std::string &use_address) { this->use_address_ = use_address; }
#ifdef USE_WIFI_AP
void WiFiComponent::setup_ap_config_() {
this->wifi_mode_({}, true);
@@ -255,13 +266,16 @@ void WiFiComponent::setup_ap_config_() {
}
}
float WiFiComponent::get_loop_priority() const {
return 10.0f; // before other loop components
}
void WiFiComponent::set_ap(const WiFiAP &ap) {
this->ap_ = ap;
this->has_ap_ = true;
}
#endif // USE_WIFI_AP
float WiFiComponent::get_loop_priority() const {
return 10.0f; // before other loop components
}
void WiFiComponent::add_sta(const WiFiAP &ap) { this->sta_.push_back(ap); }
void WiFiComponent::set_sta(const WiFiAP &ap) {
this->clear_sta();