12 #ifdef USE_ESP32_FRAMEWORK_ARDUINO 22 #if defined(USE_ESP_IDF) && defined(USE_WIFI_WPA2_EAP) 27 #include <ESP8266WiFi.h> 28 #include <ESP8266WiFiType.h> 30 #if defined(USE_ESP8266) && USE_ARDUINO_VERSION_CODE < VERSION_CODE(2, 4, 0) 32 #include <user_interface.h> 40 #include "cyw43_country.h" 41 #include "pico/cyw43_arch.h" 100 #ifdef USE_WIFI_WPA2_EAP 114 #endif // USE_WIFI_WPA2_EAP 120 void set_ssid(
const std::string &
ssid);
123 void set_password(
const std::string &
password);
124 #ifdef USE_WIFI_WPA2_EAP 126 #endif // USE_WIFI_WPA2_EAP 130 void set_hidden(
bool hidden);
131 const std::string &get_ssid()
const;
133 const std::string &get_password()
const;
134 #ifdef USE_WIFI_WPA2_EAP 136 #endif // USE_WIFI_WPA2_EAP 140 bool get_hidden()
const;
146 #ifdef USE_WIFI_WPA2_EAP 148 #endif // USE_WIFI_WPA2_EAP 159 bool matches(
const WiFiAP &config);
161 bool get_matches()
const;
162 void set_matches(
bool matches);
163 const bssid_t &get_bssid()
const;
164 const std::string &get_ssid()
const;
165 uint8_t get_channel()
const;
166 int8_t get_rssi()
const;
167 bool get_with_auth()
const;
168 bool get_is_hidden()
const;
175 bool matches_{
false};
182 float priority_{0.0f};
206 void set_sta(
const WiFiAP &ap);
207 void add_sta(
const WiFiAP &ap);
218 void set_ap(
const WiFiAP &ap);
220 #endif // USE_WIFI_AP 225 void start_scanning();
226 void check_scanning_finished();
227 void start_connecting(
const WiFiAP &ap,
bool two);
228 void set_fast_connect(
bool fast_connect);
231 void check_connecting_finished();
233 void retry_connect();
235 bool can_proceed()
override;
237 void set_reboot_timeout(uint32_t reboot_timeout);
244 void set_passive_scan(
bool passive);
246 void save_wifi_sta(
const std::string &
ssid,
const std::string &
password);
250 void setup()
override;
252 void dump_config()
override;
254 float get_setup_priority()
const override;
255 float get_loop_priority()
const override;
258 void loop()
override;
260 bool has_sta()
const;
263 #ifdef USE_WIFI_11KV_SUPPORT 264 void set_btm(
bool btm);
265 void set_rrm(
bool rrm);
271 void set_use_address(
const std::string &use_address);
278 for (
auto &it : this->sta_priorities_) {
279 if (it.bssid == bssid)
285 for (
auto &it : this->sta_priorities_) {
286 if (it.bssid == bssid)
292 for (
auto &it : this->sta_priorities_) {
293 if (it.bssid == bssid) {
305 std::string wifi_ssid();
316 static std::string format_mac_addr(
const uint8_t mac[6]);
319 void setup_ap_config_();
320 #endif // USE_WIFI_AP 322 void print_connect_params_();
326 bool wifi_sta_pre_setup_();
327 bool wifi_apply_output_power_(
float output_power);
328 bool wifi_apply_power_save_();
330 bool wifi_apply_hostname_();
331 bool wifi_sta_connect_(
const WiFiAP &ap);
332 void wifi_pre_setup_();
334 bool wifi_scan_start_(
bool passive);
338 bool wifi_start_ap_(
const WiFiAP &ap);
339 #endif // USE_WIFI_AP 341 bool wifi_disconnect_();
342 int32_t wifi_channel_();
347 bool is_captive_portal_active_();
348 bool is_esp32_improv_active_();
350 void load_fast_connect_settings_();
351 void save_fast_connect_settings_();
354 static void wifi_event_callback(System_Event_t *event);
355 void wifi_scan_done_callback_(
void *arg, STATUS
status);
356 static void s_wifi_scan_done_callback(
void *arg, STATUS status);
359 #ifdef USE_ESP32_FRAMEWORK_ARDUINO 360 void wifi_event_callback_(arduino_event_id_t event, arduino_event_info_t info);
361 void wifi_scan_done_callback_();
364 void wifi_process_event_(IDFWiFiEvent *data);
368 static int s_wifi_scan_result(
void *env,
const cyw43_ev_scan_result_t *result);
369 void wifi_scan_result(
void *env,
const cyw43_ev_scan_result_t *result);
373 void wifi_event_callback_(arduino_event_id_t event, arduino_event_info_t info);
374 void wifi_scan_done_callback_();
381 bool fast_connect_{
false};
382 bool retry_hidden_{
false};
387 bool handled_connected_state_{
false};
389 uint8_t num_retried_{0};
390 uint32_t last_connected_{0};
391 uint32_t reboot_timeout_{};
392 uint32_t ap_timeout_{};
394 bool error_from_callback_{
false};
396 bool scan_done_{
false};
397 bool ap_setup_{
false};
399 bool passive_scan_{
false};
402 bool has_saved_wifi_settings_{
false};
403 #ifdef USE_WIFI_11KV_SUPPORT 408 bool got_ipv4_address_{
false};
410 uint8_t num_ipv6_addresses_{0};
Nothing has been initialized yet.
This component is responsible for managing the ESP WiFi interface.
void set_enable_on_boot(bool enable_on_boot)
void set_priority(float priority)
std::array< uint8_t, 6 > bssid_t
std::string get_use_address()
Get the active network hostname.
float get_priority() const
void set_output_power(float output_power)
Trigger * get_disconnect_trigger() const
const std::vector< WiFiScanResult > & get_scan_result() const
void set_sta_priority(const bssid_t bssid, float priority)
optional< ManualIP > manual_ip_
WiFi is in STA(+AP) mode and currently connecting to an AP a second time.
void play(Ts... x) override
WiFi is in STA(+AP) mode and successfully connected.
bool check(Ts... x) override
void set_priority(float priority)
network::IPAddress static_ip
bool is_connected()
Return whether the node is connected to the network (through wifi, eth, ...)
network::IPAddress gateway
void set_ap_timeout(uint32_t ap_timeout)
std::vector< WiFiScanResult > scan_result_
WiFi is in STA-only mode and currently scanning for APs.
network::IPAddresses get_ip_addresses()
Struct for setting static IPs in WiFiComponent.
network::IPAddress dns1
The first DNS server. 0.0.0.0 for default.
Base class for all automation conditions.
WiFi is in STA(+AP) mode and currently connecting to an AP.
bool has_sta_priority(const bssid_t &bssid)
WiFi is in cooldown mode because something went wrong, scanning will begin after a short period of ti...
optional< bssid_t > bssid_
esp_eap_ttls_phase2_types ttls_phase_2
Trigger * get_connect_trigger() const
WiFiComponent * global_wifi_component
std::array< IPAddress, 5 > IPAddresses
optional< uint8_t > channel_
float get_priority() const
ESPPreferenceObject pref_
bool is_disabled()
Return whether the network is disabled (only wifi for now)
network::IPAddress dns2
The second DNS server. 0.0.0.0 for default.
struct esphome::wifi::SavedWifiSettings PACKED
std::vector< WiFiSTAPriority > sta_priorities_
bool operator==(optional< T > const &x, optional< U > const &y)
std::vector< WiFiAP > sta_
optional< float > output_power_
network::IPAddress subnet
Implementation of SPI Controller mode.
ESPPreferenceObject fast_connect_pref_
bool check(Ts... x) override
void play(Ts... x) override
float get_sta_priority(const bssid_t bssid)
WiFi is in AP-only mode and internal AP is already enabled.