12 #ifdef USE_ESP32_FRAMEWORK_ARDUINO 19 #include <ESP8266WiFi.h> 20 #include <ESP8266WiFiType.h> 22 #if defined(USE_ESP8266) && USE_ARDUINO_VERSION_CODE < VERSION_CODE(2, 4, 0) 24 #include <user_interface.h> 32 #include "cyw43_country.h" 33 #include "pico/cyw43_arch.h" 85 #ifdef USE_WIFI_WPA2_EAP 95 #endif // USE_WIFI_WPA2_EAP 101 void set_ssid(
const std::string &
ssid);
104 void set_password(
const std::string &
password);
105 #ifdef USE_WIFI_WPA2_EAP 107 #endif // USE_WIFI_WPA2_EAP 111 void set_hidden(
bool hidden);
112 const std::string &get_ssid()
const;
114 const std::string &get_password()
const;
115 #ifdef USE_WIFI_WPA2_EAP 117 #endif // USE_WIFI_WPA2_EAP 121 bool get_hidden()
const;
127 #ifdef USE_WIFI_WPA2_EAP 129 #endif // USE_WIFI_WPA2_EAP 140 bool matches(
const WiFiAP &config);
142 bool get_matches()
const;
143 void set_matches(
bool matches);
144 const bssid_t &get_bssid()
const;
145 const std::string &get_ssid()
const;
146 uint8_t get_channel()
const;
147 int8_t get_rssi()
const;
148 bool get_with_auth()
const;
149 bool get_is_hidden()
const;
156 bool matches_{
false};
163 float priority_{0.0f};
187 void set_sta(
const WiFiAP &ap);
188 void add_sta(
const WiFiAP &ap);
198 void set_ap(
const WiFiAP &ap);
201 void start_scanning();
202 void check_scanning_finished();
203 void start_connecting(
const WiFiAP &ap,
bool two);
204 void set_fast_connect(
bool fast_connect);
207 void check_connecting_finished();
209 void retry_connect();
211 bool can_proceed()
override;
213 void set_reboot_timeout(uint32_t reboot_timeout);
220 void set_passive_scan(
bool passive);
222 void save_wifi_sta(
const std::string &
ssid,
const std::string &
password);
226 void setup()
override;
227 void dump_config()
override;
229 float get_setup_priority()
const override;
230 float get_loop_priority()
const override;
233 void loop()
override;
235 bool has_sta()
const;
238 #ifdef USE_WIFI_11KV_SUPPORT 239 void set_btm(
bool btm);
240 void set_rrm(
bool rrm);
245 void set_use_address(
const std::string &use_address);
252 for (
auto &it : this->sta_priorities_) {
253 if (it.bssid == bssid)
259 for (
auto &it : this->sta_priorities_) {
260 if (it.bssid == bssid)
266 for (
auto &it : this->sta_priorities_) {
267 if (it.bssid == bssid) {
279 std::string wifi_ssid();
285 static std::string format_mac_addr(
const uint8_t mac[6]);
286 void setup_ap_config_();
287 void print_connect_params_();
291 bool wifi_sta_pre_setup_();
292 bool wifi_apply_output_power_(
float output_power);
293 bool wifi_apply_power_save_();
295 bool wifi_apply_hostname_();
296 bool wifi_sta_connect_(
const WiFiAP &ap);
297 void wifi_pre_setup_();
299 bool wifi_scan_start_(
bool passive);
301 bool wifi_start_ap_(
const WiFiAP &ap);
302 bool wifi_disconnect_();
303 int32_t wifi_channel_();
308 bool is_captive_portal_active_();
309 bool is_esp32_improv_active_();
312 static void wifi_event_callback(System_Event_t *event);
313 void wifi_scan_done_callback_(
void *arg, STATUS
status);
314 static void s_wifi_scan_done_callback(
void *arg, STATUS status);
317 #ifdef USE_ESP32_FRAMEWORK_ARDUINO 318 #if ESP_IDF_VERSION_MAJOR >= 4 319 void wifi_event_callback_(arduino_event_id_t event, arduino_event_info_t info);
321 void wifi_event_callback_(system_event_id_t event, system_event_info_t info);
323 void wifi_scan_done_callback_();
326 void wifi_process_event_(IDFWiFiEvent *data);
330 static int s_wifi_scan_result(
void *env,
const cyw43_ev_scan_result_t *result);
331 void wifi_scan_result(
void *env,
const cyw43_ev_scan_result_t *result);
338 bool fast_connect_{
false};
344 uint8_t num_retried_{0};
345 uint32_t last_connected_{0};
346 uint32_t reboot_timeout_{};
347 uint32_t ap_timeout_{};
349 bool error_from_callback_{
false};
351 bool scan_done_{
false};
352 bool ap_setup_{
false};
354 bool passive_scan_{
false};
356 bool has_saved_wifi_settings_{
false};
357 #ifdef USE_WIFI_11KV_SUPPORT 367 bool check(Ts... x)
override;
Nothing has been initialized yet.
This component is responsible for managing the ESP WiFi interface.
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)
const std::vector< WiFiScanResult > & get_scan_result() const
void set_sta_priority(const bssid_t bssid, float priority)
optional< ManualIP > manual_ip_
struct esphome::wifi::SavedWifiSettings PACKED
WiFi is in STA(+AP) mode and currently connecting to an AP a second time.
WiFi is in STA(+AP) mode and successfully connected.
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.
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_
WiFiComponent * global_wifi_component
optional< uint8_t > channel_
float get_priority() const
ESPPreferenceObject pref_
network::IPAddress dns2
The second DNS server. 0.0.0.0 for default.
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
bool check(Ts... x) override
float get_sta_priority(const bssid_t bssid)
WiFi is in AP-only mode and internal AP is already enabled.
network::IPAddress get_ip_address()