12 #ifdef USE_ESP32_FRAMEWORK_ARDUINO 23 #include <ESP8266WiFi.h> 24 #include <ESP8266WiFiType.h> 26 #if defined(USE_ESP8266) && USE_ARDUINO_VERSION_CODE < VERSION_CODE(2, 4, 0) 28 #include <user_interface.h> 36 #include "cyw43_country.h" 37 #include "pico/cyw43_arch.h" 96 #ifdef USE_WIFI_WPA2_EAP 106 #endif // USE_WIFI_WPA2_EAP 112 void set_ssid(
const std::string &
ssid);
115 void set_password(
const std::string &
password);
116 #ifdef USE_WIFI_WPA2_EAP 118 #endif // USE_WIFI_WPA2_EAP 122 void set_hidden(
bool hidden);
123 const std::string &get_ssid()
const;
125 const std::string &get_password()
const;
126 #ifdef USE_WIFI_WPA2_EAP 128 #endif // USE_WIFI_WPA2_EAP 132 bool get_hidden()
const;
138 #ifdef USE_WIFI_WPA2_EAP 140 #endif // USE_WIFI_WPA2_EAP 151 bool matches(
const WiFiAP &config);
153 bool get_matches()
const;
154 void set_matches(
bool matches);
155 const bssid_t &get_bssid()
const;
156 const std::string &get_ssid()
const;
157 uint8_t get_channel()
const;
158 int8_t get_rssi()
const;
159 bool get_with_auth()
const;
160 bool get_is_hidden()
const;
167 bool matches_{
false};
174 float priority_{0.0f};
198 void set_sta(
const WiFiAP &ap);
199 void add_sta(
const WiFiAP &ap);
210 void set_ap(
const WiFiAP &ap);
212 #endif // USE_WIFI_AP 217 void start_scanning();
218 void check_scanning_finished();
219 void start_connecting(
const WiFiAP &ap,
bool two);
220 void set_fast_connect(
bool fast_connect);
223 void check_connecting_finished();
225 void retry_connect();
227 bool can_proceed()
override;
229 void set_reboot_timeout(uint32_t reboot_timeout);
236 void set_passive_scan(
bool passive);
238 void save_wifi_sta(
const std::string &
ssid,
const std::string &
password);
242 void setup()
override;
244 void dump_config()
override;
246 float get_setup_priority()
const override;
247 float get_loop_priority()
const override;
250 void loop()
override;
252 bool has_sta()
const;
255 #ifdef USE_WIFI_11KV_SUPPORT 256 void set_btm(
bool btm);
257 void set_rrm(
bool rrm);
263 void set_use_address(
const std::string &use_address);
270 for (
auto &it : this->sta_priorities_) {
271 if (it.bssid == bssid)
277 for (
auto &it : this->sta_priorities_) {
278 if (it.bssid == bssid)
284 for (
auto &it : this->sta_priorities_) {
285 if (it.bssid == bssid) {
297 std::string wifi_ssid();
308 static std::string format_mac_addr(
const uint8_t mac[6]);
311 void setup_ap_config_();
312 #endif // USE_WIFI_AP 314 void print_connect_params_();
318 bool wifi_sta_pre_setup_();
319 bool wifi_apply_output_power_(
float output_power);
320 bool wifi_apply_power_save_();
322 bool wifi_apply_hostname_();
323 bool wifi_sta_connect_(
const WiFiAP &ap);
324 void wifi_pre_setup_();
326 bool wifi_scan_start_(
bool passive);
330 bool wifi_start_ap_(
const WiFiAP &ap);
331 #endif // USE_WIFI_AP 333 bool wifi_disconnect_();
334 int32_t wifi_channel_();
339 bool is_captive_portal_active_();
340 bool is_esp32_improv_active_();
342 void load_fast_connect_settings_();
343 void save_fast_connect_settings_();
346 static void wifi_event_callback(System_Event_t *event);
347 void wifi_scan_done_callback_(
void *arg, STATUS
status);
348 static void s_wifi_scan_done_callback(
void *arg, STATUS status);
351 #ifdef USE_ESP32_FRAMEWORK_ARDUINO 352 void wifi_event_callback_(arduino_event_id_t event, arduino_event_info_t info);
353 void wifi_scan_done_callback_();
356 void wifi_process_event_(IDFWiFiEvent *data);
360 static int s_wifi_scan_result(
void *env,
const cyw43_ev_scan_result_t *result);
361 void wifi_scan_result(
void *env,
const cyw43_ev_scan_result_t *result);
365 void wifi_event_callback_(arduino_event_id_t event, arduino_event_info_t info);
366 void wifi_scan_done_callback_();
373 bool fast_connect_{
false};
374 bool retry_hidden_{
false};
379 bool handled_connected_state_{
false};
381 uint8_t num_retried_{0};
382 uint32_t last_connected_{0};
383 uint32_t reboot_timeout_{};
384 uint32_t ap_timeout_{};
386 bool error_from_callback_{
false};
388 bool scan_done_{
false};
389 bool ap_setup_{
false};
391 bool passive_scan_{
false};
394 bool has_saved_wifi_settings_{
false};
395 #ifdef USE_WIFI_11KV_SUPPORT 400 bool got_ipv4_address_{
false};
402 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_
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
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
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.