13 #ifdef USE_ESP32_FRAMEWORK_ARDUINO 23 #if defined(USE_ESP_IDF) && defined(USE_WIFI_WPA2_EAP) 24 #if (ESP_IDF_VERSION_MAJOR >= 5) && (ESP_IDF_VERSION_MINOR >= 1) 25 #include <esp_eap_client.h> 32 #include <ESP8266WiFi.h> 33 #include <ESP8266WiFiType.h> 35 #if defined(USE_ESP8266) && USE_ARDUINO_VERSION_CODE < VERSION_CODE(2, 4, 0) 37 #include <user_interface.h> 45 #include "cyw43_country.h" 46 #include "pico/cyw43_arch.h" 105 #ifdef USE_WIFI_WPA2_EAP 119 #endif // USE_WIFI_WPA2_EAP 125 void set_ssid(
const std::string &
ssid);
128 void set_password(
const std::string &
password);
129 #ifdef USE_WIFI_WPA2_EAP 131 #endif // USE_WIFI_WPA2_EAP 135 void set_hidden(
bool hidden);
136 const std::string &get_ssid()
const;
138 const std::string &get_password()
const;
139 #ifdef USE_WIFI_WPA2_EAP 141 #endif // USE_WIFI_WPA2_EAP 145 bool get_hidden()
const;
151 #ifdef USE_WIFI_WPA2_EAP 153 #endif // USE_WIFI_WPA2_EAP 164 bool matches(
const WiFiAP &config);
166 bool get_matches()
const;
167 void set_matches(
bool matches);
168 const bssid_t &get_bssid()
const;
169 const std::string &get_ssid()
const;
170 uint8_t get_channel()
const;
171 int8_t get_rssi()
const;
172 bool get_with_auth()
const;
173 bool get_is_hidden()
const;
180 bool matches_{
false};
187 float priority_{0.0f};
211 void set_sta(
const WiFiAP &ap);
212 void add_sta(
const WiFiAP &ap);
223 void set_ap(
const WiFiAP &ap);
225 #endif // USE_WIFI_AP 230 void start_scanning();
231 void check_scanning_finished();
232 void start_connecting(
const WiFiAP &ap,
bool two);
233 void set_fast_connect(
bool fast_connect);
236 void check_connecting_finished();
238 void retry_connect();
240 bool can_proceed()
override;
242 void set_reboot_timeout(uint32_t reboot_timeout);
249 void set_passive_scan(
bool passive);
251 void save_wifi_sta(
const std::string &
ssid,
const std::string &
password);
255 void setup()
override;
257 void dump_config()
override;
259 float get_setup_priority()
const override;
260 float get_loop_priority()
const override;
263 void loop()
override;
265 bool has_sta()
const;
268 #ifdef USE_WIFI_11KV_SUPPORT 269 void set_btm(
bool btm);
270 void set_rrm(
bool rrm);
276 void set_use_address(
const std::string &use_address);
283 for (
auto &it : this->sta_priorities_) {
284 if (it.bssid == bssid)
290 for (
auto &it : this->sta_priorities_) {
291 if (it.bssid == bssid)
297 for (
auto &it : this->sta_priorities_) {
298 if (it.bssid == bssid) {
310 std::string wifi_ssid();
321 static std::string format_mac_addr(
const uint8_t mac[6]);
324 void setup_ap_config_();
325 #endif // USE_WIFI_AP 327 void print_connect_params_();
331 bool wifi_sta_pre_setup_();
332 bool wifi_apply_output_power_(
float output_power);
333 bool wifi_apply_power_save_();
335 bool wifi_apply_hostname_();
336 bool wifi_sta_connect_(
const WiFiAP &ap);
337 void wifi_pre_setup_();
339 bool wifi_scan_start_(
bool passive);
343 bool wifi_start_ap_(
const WiFiAP &ap);
344 #endif // USE_WIFI_AP 346 bool wifi_disconnect_();
347 int32_t wifi_channel_();
352 bool is_captive_portal_active_();
353 bool is_esp32_improv_active_();
355 void load_fast_connect_settings_();
356 void save_fast_connect_settings_();
359 static void wifi_event_callback(System_Event_t *event);
360 void wifi_scan_done_callback_(
void *arg, STATUS
status);
361 static void s_wifi_scan_done_callback(
void *arg, STATUS status);
364 #ifdef USE_ESP32_FRAMEWORK_ARDUINO 365 void wifi_event_callback_(arduino_event_id_t event, arduino_event_info_t info);
366 void wifi_scan_done_callback_();
369 void wifi_process_event_(IDFWiFiEvent *data);
373 static int s_wifi_scan_result(
void *env,
const cyw43_ev_scan_result_t *result);
374 void wifi_scan_result(
void *env,
const cyw43_ev_scan_result_t *result);
378 void wifi_event_callback_(arduino_event_id_t event, arduino_event_info_t info);
379 void wifi_scan_done_callback_();
386 bool fast_connect_{
false};
387 bool retry_hidden_{
false};
392 bool handled_connected_state_{
false};
394 uint8_t num_retried_{0};
395 uint32_t last_connected_{0};
396 uint32_t reboot_timeout_{};
397 uint32_t ap_timeout_{};
399 bool error_from_callback_{
false};
401 bool scan_done_{
false};
402 bool ap_setup_{
false};
404 bool passive_scan_{
false};
407 bool has_saved_wifi_settings_{
false};
408 #ifdef USE_WIFI_11KV_SUPPORT 413 bool got_ipv4_address_{
false};
415 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.