7#include <user_interface.h>
11#ifdef USE_WIFI_WPA2_EAP
12#include <wpa2_enterprise.h>
20#include "lwip/apps/sntp.h"
21#include "lwip/netif.h"
23#if USE_ARDUINO_VERSION_CODE >= VERSION_CODE(3, 0, 0)
24#include "LwipDhcpServer.h"
25#if USE_ARDUINO_VERSION_CODE < VERSION_CODE(3, 1, 0)
26#include <ESP8266WiFi.h>
27#include "ESP8266WiFiAP.h"
28#define wifi_softap_set_dhcps_lease(lease) dhcpSoftAP.set_dhcps_lease(lease)
29#define wifi_softap_set_dhcps_lease_time(time) dhcpSoftAP.set_dhcps_lease_time(time)
30#define wifi_softap_set_dhcps_offer_option(offer, mode) dhcpSoftAP.set_dhcps_offer_option(offer, mode)
44static const char *
const TAG =
"wifi_esp8266";
46static bool s_sta_connected =
false;
47static bool s_sta_got_ip =
false;
48static bool s_sta_connect_not_found =
false;
49static bool s_sta_connect_error =
false;
50static bool s_sta_connecting =
false;
53 uint8_t current_mode = wifi_get_opmode();
54 bool current_sta = current_mode & 0b01;
55 bool current_ap = current_mode & 0b10;
56 bool target_sta = sta.
value_or(current_sta);
57 bool target_ap = ap.
value_or(current_ap);
58 if (current_sta == target_sta && current_ap == target_ap)
61 if (target_sta && !current_sta) {
62 ESP_LOGV(TAG,
"Enabling STA");
63 }
else if (!target_sta && current_sta) {
64 ESP_LOGV(TAG,
"Disabling STA");
67 wifi_station_dhcpc_stop();
69 if (target_ap && !current_ap) {
70 ESP_LOGV(TAG,
"Enabling AP");
71 }
else if (!target_ap && current_ap) {
72 ESP_LOGV(TAG,
"Disabling AP");
75 ETS_UART_INTR_DISABLE();
81 bool ret = wifi_set_opmode_current(
mode);
82 ETS_UART_INTR_ENABLE();
85 ESP_LOGW(TAG,
"Set mode failed");
94 sleep_type_t power_save;
97 power_save = LIGHT_SLEEP_T;
100 power_save = MODEM_SLEEP_T;
104 power_save = NONE_SLEEP_T;
107 wifi_fpm_auto_sleep_set_in_null_mode(1);
108 bool success = wifi_set_sleep_type(power_save);
109#ifdef USE_WIFI_POWER_SAVE_LISTENERS
119#if LWIP_VERSION_MAJOR != 1
136 enum dhcp_status dhcp_status = wifi_station_dhcpc_status();
141 sntp_servermode_dhcp(
false);
144 if (dhcp_status != DHCP_STARTED) {
145 bool ret = wifi_station_dhcpc_start();
147 ESP_LOGV(TAG,
"Starting DHCP client failed");
156#if LWIP_VERSION_MAJOR != 1
160 wifi_get_ip_info(STATION_IF, &previp);
163 struct ip_info info {};
164 info.ip = manual_ip->static_ip;
165 info.gw = manual_ip->gateway;
166 info.netmask = manual_ip->subnet;
168 if (dhcp_status == DHCP_STARTED) {
169 bool dhcp_stop_ret = wifi_station_dhcpc_stop();
170 if (!dhcp_stop_ret) {
171 ESP_LOGV(TAG,
"Stopping DHCP client failed");
175 bool wifi_set_info_ret = wifi_set_ip_info(STATION_IF, &info);
176 if (!wifi_set_info_ret) {
177 ESP_LOGV(TAG,
"Set manual IP info failed");
182 if (manual_ip->dns1.is_set()) {
183 dns = manual_ip->dns1;
184 dns_setserver(0, &dns);
186 if (manual_ip->dns2.is_set()) {
187 dns = manual_ip->dns2;
188 dns_setserver(1, &dns);
191#if LWIP_VERSION_MAJOR != 1
194 if (previp.ip.addr != 0 && previp.ip.addr != info.ip.addr) {
196 reinterpret_cast<const ip4_addr_t *
>(&info.netmask),
reinterpret_cast<const ip4_addr_t *
>(&info.gw));
207 for (
auto &addr : addrList) {
208 addresses[index++] = addr.ipFromNetifNum();
214 bool ret = wifi_station_set_hostname(
const_cast<char *
>(hostname.c_str()));
216 ESP_LOGV(TAG,
"Set hostname failed");
223 for (netif *intf = netif_list; intf; intf = intf->next) {
224#if LWIP_VERSION_MAJOR == 1
225 intf->hostname = (
char *) wifi_station_get_hostname();
227 intf->hostname = wifi_station_get_hostname();
241 struct station_config conf {};
242 memset(&conf, 0,
sizeof(conf));
243 if (ap.
ssid_.
size() >
sizeof(conf.ssid)) {
244 ESP_LOGE(TAG,
"SSID too long");
248 ESP_LOGE(TAG,
"Password too long");
256 memcpy(conf.bssid, ap.
get_bssid().data(), 6);
261#if USE_ARDUINO_VERSION_CODE >= VERSION_CODE(2, 4, 0)
263 conf.threshold.authmode = AUTH_OPEN;
269 conf.threshold.authmode = AUTH_WPA_PSK;
273 conf.threshold.authmode = AUTH_WPA2_PSK;
277 conf.threshold.rssi = -127;
280 ETS_UART_INTR_DISABLE();
281 bool ret = wifi_station_set_config_current(&conf);
282 ETS_UART_INTR_ENABLE();
285 ESP_LOGV(TAG,
"Set Station config failed");
289#ifdef USE_WIFI_MANUAL_IP
300#ifdef USE_WIFI_WPA2_EAP
301 if (ap.
get_eap().has_value()) {
304 ret = wifi_station_set_enterprise_identity((uint8_t *) eap.
identity.c_str(), eap.
identity.length());
306 ESP_LOGV(TAG,
"esp_wifi_sta_wpa2_ent_set_identity failed: %d", ret);
308 int ca_cert_len = strlen(eap.
ca_cert);
312 ret = wifi_station_set_enterprise_ca_cert((uint8_t *) eap.
ca_cert, ca_cert_len + 1);
314 ESP_LOGV(TAG,
"esp_wifi_sta_wpa2_ent_set_ca_cert failed: %d", ret);
319 if (client_cert_len && client_key_len) {
321 ret = wifi_station_set_enterprise_cert_key((uint8_t *) eap.
client_cert, client_cert_len + 1,
322 (uint8_t *) eap.
client_key, client_key_len + 1,
325 ESP_LOGV(TAG,
"esp_wifi_sta_wpa2_ent_set_cert_key failed: %d", ret);
329 ret = wifi_station_set_enterprise_username((uint8_t *) eap.
username.c_str(), eap.
username.length());
331 ESP_LOGV(TAG,
"esp_wifi_sta_wpa2_ent_set_username failed: %d", ret);
333 ret = wifi_station_set_enterprise_password((uint8_t *) eap.
password.c_str(), eap.
password.length());
335 ESP_LOGV(TAG,
"esp_wifi_sta_wpa2_ent_set_password failed: %d", ret);
338 ret = wifi_station_set_wpa2_enterprise_auth(
true);
340 ESP_LOGV(TAG,
"esp_wifi_sta_wpa2_ent_enable failed: %d", ret);
349 s_sta_connecting =
true;
350 s_sta_connected =
false;
351 s_sta_got_ip =
false;
352 s_sta_connect_error =
false;
353 s_sta_connect_not_found =
false;
355 ETS_UART_INTR_DISABLE();
356 ret = wifi_station_connect();
357 ETS_UART_INTR_ENABLE();
359 ESP_LOGV(TAG,
"wifi_station_connect failed");
364 bool connected =
false;
366 uint8_t ipv6_addr_count = 0;
367 for (
auto addr : addrList) {
368 char ip_buf[network::IP_ADDRESS_BUFFER_SIZE];
369 ESP_LOGV(TAG,
"Address %s",
network::IPAddress(addr.ipFromNetifNum()).str_to(ip_buf));
375 connected = (ipv6_addr_count >= USE_NETWORK_MIN_IPV6_ADDR_COUNT);
382 ESP_LOGV(TAG,
"wifi_set_channel failed");
390class WiFiMockClass :
public ESP8266WiFiGenericClass {
392 static void _event_callback(
void *event) { ESP8266WiFiGenericClass::_eventCallback(event); }
397static_assert(AUTH_OPEN == 0 && AUTH_WEP == 1 && AUTH_WPA_PSK == 2 && AUTH_WPA2_PSK == 3 && AUTH_WPA_WPA2_PSK == 4,
398 "AUTH_* constants are not contiguous");
402 return AuthModeStrings::get_log_str(
mode, AuthModeStrings::LAST_INDEX);
406static_assert(WIFI_OFF == 0 && WIFI_STA == 1 && WIFI_AP == 2 && WIFI_AP_STA == 3,
407 "WIFI_* op mode constants are not contiguous");
416 if (reason == REASON_AUTH_EXPIRE)
417 return LOG_STR(
"Auth Expired");
418 if (reason == REASON_AUTH_LEAVE)
419 return LOG_STR(
"Auth Leave");
420 if (reason == REASON_ASSOC_EXPIRE)
421 return LOG_STR(
"Association Expired");
422 if (reason == REASON_ASSOC_TOOMANY)
423 return LOG_STR(
"Too Many Associations");
424 if (reason == REASON_NOT_AUTHED)
425 return LOG_STR(
"Not Authenticated");
426 if (reason == REASON_NOT_ASSOCED)
427 return LOG_STR(
"Not Associated");
428 if (reason == REASON_ASSOC_LEAVE)
429 return LOG_STR(
"Association Leave");
430 if (reason == REASON_ASSOC_NOT_AUTHED)
431 return LOG_STR(
"Association not Authenticated");
432 if (reason == REASON_DISASSOC_PWRCAP_BAD)
433 return LOG_STR(
"Disassociate Power Cap Bad");
434 if (reason == REASON_DISASSOC_SUPCHAN_BAD)
435 return LOG_STR(
"Disassociate Supported Channel Bad");
436 if (reason == REASON_IE_INVALID)
437 return LOG_STR(
"IE Invalid");
438 if (reason == REASON_MIC_FAILURE)
439 return LOG_STR(
"Mic Failure");
440 if (reason == REASON_4WAY_HANDSHAKE_TIMEOUT)
441 return LOG_STR(
"4-Way Handshake Timeout");
442 if (reason == REASON_GROUP_KEY_UPDATE_TIMEOUT)
443 return LOG_STR(
"Group Key Update Timeout");
444 if (reason == REASON_IE_IN_4WAY_DIFFERS)
445 return LOG_STR(
"IE In 4-Way Handshake Differs");
446 if (reason == REASON_GROUP_CIPHER_INVALID)
447 return LOG_STR(
"Group Cipher Invalid");
448 if (reason == REASON_PAIRWISE_CIPHER_INVALID)
449 return LOG_STR(
"Pairwise Cipher Invalid");
450 if (reason == REASON_AKMP_INVALID)
451 return LOG_STR(
"AKMP Invalid");
452 if (reason == REASON_UNSUPP_RSN_IE_VERSION)
453 return LOG_STR(
"Unsupported RSN IE version");
454 if (reason == REASON_INVALID_RSN_IE_CAP)
455 return LOG_STR(
"Invalid RSN IE Cap");
456 if (reason == REASON_802_1X_AUTH_FAILED)
457 return LOG_STR(
"802.1x Authentication Failed");
458 if (reason == REASON_CIPHER_SUITE_REJECTED)
459 return LOG_STR(
"Cipher Suite Rejected");
460 if (reason == REASON_BEACON_TIMEOUT)
461 return LOG_STR(
"Beacon Timeout");
462 if (reason == REASON_NO_AP_FOUND)
463 return LOG_STR(
"AP Not Found");
464 if (reason == REASON_AUTH_FAIL)
465 return LOG_STR(
"Authentication Failed");
466 if (reason == REASON_ASSOC_FAIL)
467 return LOG_STR(
"Association Failed");
468 if (reason == REASON_HANDSHAKE_TIMEOUT)
469 return LOG_STR(
"Handshake Failed");
470 return LOG_STR(
"Unspecified");
474 switch (event->event) {
475 case EVENT_STAMODE_CONNECTED: {
476 auto it =
event->event_info.connected;
477#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE
478 char bssid_buf[MAC_ADDRESS_PRETTY_BUFFER_SIZE];
480 ESP_LOGV(TAG,
"Connected ssid='%.*s' bssid=%s channel=%u", it.ssid_len, (
const char *) it.ssid, bssid_buf,
483 s_sta_connected =
true;
484#ifdef USE_WIFI_CONNECT_STATE_LISTENERS
491 case EVENT_STAMODE_DISCONNECTED: {
492 auto it =
event->event_info.disconnected;
493 if (it.reason == REASON_NO_AP_FOUND) {
494 ESP_LOGW(TAG,
"Disconnected ssid='%.*s' reason='Probe Request Unsuccessful'", it.ssid_len,
495 (
const char *) it.ssid);
496 s_sta_connect_not_found =
true;
500 ESP_LOGW(TAG,
"Disconnected ssid='%.*s' bssid=" LOG_SECRET(
"%s")
" reason='%s'", it.ssid_len,
502 s_sta_connect_error =
true;
504 s_sta_connected =
false;
505 s_sta_connecting =
false;
507#ifdef USE_WIFI_CONNECT_STATE_LISTENERS
512 case EVENT_STAMODE_AUTHMODE_CHANGE: {
513 auto it =
event->event_info.auth_change;
514 ESP_LOGV(TAG,
"Changed Authmode old=%s new=%s", LOG_STR_ARG(
get_auth_mode_str(it.old_mode)),
518 if (it.old_mode != AUTH_OPEN && it.new_mode == AUTH_OPEN) {
519 ESP_LOGW(TAG,
"Potential Authmode downgrade detected, disconnecting");
520 wifi_station_disconnect();
525 case EVENT_STAMODE_GOT_IP: {
526 auto it =
event->event_info.got_ip;
527 char ip_buf[network::IP_ADDRESS_BUFFER_SIZE], gw_buf[network::IP_ADDRESS_BUFFER_SIZE],
528 mask_buf[network::IP_ADDRESS_BUFFER_SIZE];
529 ESP_LOGV(TAG,
"static_ip=%s gateway=%s netmask=%s",
network::IPAddress(&it.ip).str_to(ip_buf),
532#ifdef USE_WIFI_IP_STATE_LISTENERS
538 case EVENT_STAMODE_DHCP_TIMEOUT: {
539 ESP_LOGW(TAG,
"DHCP request timeout");
542 case EVENT_SOFTAPMODE_STACONNECTED: {
543#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE
544 auto it =
event->event_info.sta_connected;
545 char mac_buf[MAC_ADDRESS_PRETTY_BUFFER_SIZE];
547 ESP_LOGV(TAG,
"AP client connected MAC=%s aid=%u", mac_buf, it.aid);
551 case EVENT_SOFTAPMODE_STADISCONNECTED: {
552#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE
553 auto it =
event->event_info.sta_disconnected;
554 char mac_buf[MAC_ADDRESS_PRETTY_BUFFER_SIZE];
556 ESP_LOGV(TAG,
"AP client disconnected MAC=%s aid=%u", mac_buf, it.aid);
560 case EVENT_SOFTAPMODE_PROBEREQRECVED: {
561#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERY_VERBOSE
562 auto it =
event->event_info.ap_probereqrecved;
563 char mac_buf[MAC_ADDRESS_PRETTY_BUFFER_SIZE];
565 ESP_LOGVV(TAG,
"AP receive Probe Request MAC=%s RSSI=%d", mac_buf, it.rssi);
569#if USE_ARDUINO_VERSION_CODE >= VERSION_CODE(2, 4, 0)
570 case EVENT_OPMODE_CHANGED: {
571 auto it =
event->event_info.opmode_changed;
572 ESP_LOGV(TAG,
"Changed Mode old=%s new=%s", LOG_STR_ARG(
get_op_mode_str(it.old_opmode)),
576 case EVENT_SOFTAPMODE_DISTRIBUTE_STA_IP: {
577#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE
578 auto it =
event->event_info.distribute_sta_ip;
579 char mac_buf[MAC_ADDRESS_PRETTY_BUFFER_SIZE];
580 char ip_buf[network::IP_ADDRESS_BUFFER_SIZE];
582 ESP_LOGV(TAG,
"AP Distribute Station IP MAC=%s IP=%s aid=%u", mac_buf,
network::IPAddress(&it.ip).str_to(ip_buf),
592 WiFiMockClass::_event_callback(event);
596 uint8_t
val =
static_cast<uint8_t
>(output_power * 4);
597 system_phy_set_max_tpw(
val);
605 ETS_UART_INTR_DISABLE();
606 ret1 = wifi_station_set_auto_connect(0);
607 ret2 = wifi_station_set_reconnect_policy(
false);
608 ETS_UART_INTR_ENABLE();
610 if (!ret1 || !ret2) {
611 ESP_LOGV(TAG,
"Disabling Auto-Connect failed");
626 station_status_t
status = wifi_station_get_connect_status();
627 if (
status == STATION_GOT_IP)
629 if (
status == STATION_NO_AP_FOUND)
631 if (
status == STATION_CONNECT_FAIL ||
status == STATION_WRONG_PASSWORD)
633 if (
status == STATION_CONNECTING)
638 static bool first_scan =
false;
648 struct scan_config config {};
649 memset(&config, 0,
sizeof(config));
650 config.ssid =
nullptr;
651 config.bssid =
nullptr;
653 config.show_hidden = 1;
654#if USE_ARDUINO_VERSION_CODE >= VERSION_CODE(2, 4, 0)
655 config.scan_type = passive ? WIFI_SCAN_TYPE_PASSIVE : WIFI_SCAN_TYPE_ACTIVE;
658 config.scan_time.passive = 200;
660 config.scan_time.active.min = 100;
661 config.scan_time.active.max = 200;
665 config.scan_time.passive = 500;
667 config.scan_time.active.min = 400;
668 config.scan_time.active.max = 500;
675 ESP_LOGV(TAG,
"wifi_station_scan failed");
684 if (wifi_get_opmode() & WIFI_STA)
685 ret = wifi_station_disconnect();
686 station_config conf{};
687 memset(&conf, 0,
sizeof(conf));
688 ETS_UART_INTR_DISABLE();
689 wifi_station_set_config_current(&conf);
690 ETS_UART_INTR_ENABLE();
701 ESP_LOGV(TAG,
"Scan failed: %d",
status);
709 auto *head =
reinterpret_cast<bss_info *
>(arg);
715 for (bss_info *it = head; it !=
nullptr; it = STAILQ_NEXT(it, next)) {
717 const char *ssid_cstr =
reinterpret_cast<const char *
>(it->ssid);
726 for (bss_info *it = head; it !=
nullptr; it = STAILQ_NEXT(it, next)) {
727 const char *ssid_cstr =
reinterpret_cast<const char *
>(it->ssid);
730 bssid_t{it->bssid[0], it->bssid[1], it->bssid[2], it->bssid[3], it->bssid[4], it->bssid[5]}, ssid_cstr,
731 it->ssid_len, it->channel, it->rssi, it->authmode != AUTH_OPEN, it->is_hidden != 0);
736 ESP_LOGV(TAG,
"Scan complete: %zu found, %zu stored%s", total, this->
scan_result_.size(),
737 needs_full ?
"" :
" (filtered)");
739#ifdef USE_WIFI_SCAN_RESULTS_LISTENERS
740 this->
pending_.scan_complete =
true;
750 struct ip_info info {};
752 info.ip = manual_ip->static_ip;
753 info.gw = manual_ip->gateway;
754 info.netmask = manual_ip->subnet;
761 if (wifi_softap_dhcps_status() == DHCP_STARTED) {
762 if (!wifi_softap_dhcps_stop()) {
763 ESP_LOGW(TAG,
"Stopping DHCP server failed");
767 if (!wifi_set_ip_info(SOFTAP_IF, &info)) {
768 ESP_LOGE(TAG,
"Set SoftAP info failed");
772#if USE_ARDUINO_VERSION_CODE >= VERSION_CODE(3, 0, 0) && USE_ARDUINO_VERSION_CODE < VERSION_CODE(3, 1, 0)
773 dhcpSoftAP.begin(&info);
776 struct dhcps_lease lease {};
780 lease.start_ip = start_address;
781#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE
782 char ip_buf[network::IP_ADDRESS_BUFFER_SIZE];
784 ESP_LOGV(TAG,
"DHCP server IP lease start: %s", start_address.str_to(ip_buf));
786 lease.end_ip = start_address;
787 ESP_LOGV(TAG,
"DHCP server IP lease end: %s", start_address.str_to(ip_buf));
788 if (!wifi_softap_set_dhcps_lease(&lease)) {
789 ESP_LOGE(TAG,
"Set SoftAP DHCP lease failed");
794 if (!wifi_softap_set_dhcps_lease_time(1440)) {
795 ESP_LOGE(TAG,
"Set SoftAP DHCP lease time failed");
799#if USE_ARDUINO_VERSION_CODE >= VERSION_CODE(3, 1, 0)
800 ESP8266WiFiClass::softAPDhcpServer().setRouter(
true);
804 if (!wifi_softap_set_dhcps_offer_option(OFFER_ROUTER, &
mode)) {
805 ESP_LOGE(TAG,
"wifi_softap_set_dhcps_offer_option failed");
810 if (!wifi_softap_dhcps_start()) {
811 ESP_LOGE(TAG,
"Starting SoftAP DHCPS failed");
823 struct softap_config conf {};
824 if (ap.
ssid_.
size() >
sizeof(conf.ssid)) {
825 ESP_LOGE(TAG,
"AP SSID too long");
829 conf.ssid_len =
static_cast<uint8
>(ap.
ssid_.
size());
832 conf.max_connection = 5;
833 conf.beacon_interval = 100;
836 conf.authmode = AUTH_OPEN;
839 conf.authmode = AUTH_WPA2_PSK;
841 ESP_LOGE(TAG,
"AP password too long");
847 ETS_UART_INTR_DISABLE();
848 bool ret = wifi_softap_set_config_current(&conf);
849 ETS_UART_INTR_ENABLE();
852 ESP_LOGV(TAG,
"wifi_softap_set_config_current failed");
856#ifdef USE_WIFI_MANUAL_IP
858 ESP_LOGV(TAG,
"wifi_ap_ip_config_ failed");
863 ESP_LOGV(TAG,
"wifi_ap_ip_config_ failed");
872 struct ip_info ip {};
873 wifi_get_ip_info(SOFTAP_IF, &ip);
880 struct station_config conf {};
881 if (wifi_station_get_config(&conf)) {
882 std::copy_n(conf.bssid, bssid.size(), bssid.begin());
886std::string WiFiComponent::wifi_ssid() {
887 struct station_config conf {};
888 if (!wifi_station_get_config(&conf)) {
892 auto *ssid_s =
reinterpret_cast<const char *
>(conf.ssid);
893 size_t len = strnlen(ssid_s,
sizeof(conf.ssid));
894 return {ssid_s,
len};
897 struct station_config conf {};
898 if (!wifi_station_get_config(&conf)) {
900 return buffer.data();
903 size_t len = strnlen(
reinterpret_cast<const char *
>(conf.ssid),
sizeof(conf.ssid));
904 memcpy(buffer.data(), conf.ssid,
len);
906 return buffer.data();
909 if (wifi_station_get_connect_status() != STATION_GOT_IP)
910 return WIFI_RSSI_DISCONNECTED;
911 sint8 rssi = wifi_station_get_rssi();
913 return rssi >= 31 ? WIFI_RSSI_DISCONNECTED : rssi;
917 struct ip_info ip {};
918 wifi_get_ip_info(STATION_IF, &ip);
922 struct ip_info ip {};
923 wifi_get_ip_info(STATION_IF, &ip);
934#ifdef USE_WIFI_CONNECT_STATE_LISTENERS
941#ifdef USE_WIFI_IP_STATE_LISTENERS
948#ifdef USE_WIFI_SCAN_RESULTS_LISTENERS
950 this->
pending_.scan_complete =
false;
BedjetMode mode
BedJet operating mode.
const std::string & get_name() const
Get the name of this Application set by pre_setup().
value_type value_or(U const &v) const
const char * c_str() const
uint8_t get_channel() const
const optional< EAPAuth > & get_eap() const
const optional< ManualIP > & get_manual_ip() const
const bssid_t & get_bssid() const
void wifi_scan_done_callback_(void *arg, STATUS status)
void notify_scan_results_listeners_()
Notify scan results listeners with current scan results.
bool error_from_callback_
bool wifi_apply_power_save_()
WiFiPowerSaveMode power_save_
WiFiSTAConnectStatus wifi_sta_connect_status_() const
struct esphome::wifi::WiFiComponent::@175 pending_
wifi_scan_vector_t< WiFiScanResult > scan_result_
void notify_ip_state_listeners_()
Notify IP state listeners with current addresses.
bool wifi_sta_ip_config_(const optional< ManualIP > &manual_ip)
static void wifi_event_callback(System_Event_t *event)
void notify_disconnect_state_listeners_()
Notify connect state listeners of disconnection.
bool wifi_start_ap_(const WiFiAP &ap)
void log_discarded_scan_result_(const char *ssid, const uint8_t *bssid, int8_t rssi, uint8_t channel)
Log a discarded scan result at VERBOSE level (skipped during roaming scans to avoid log overflow)
int32_t get_wifi_channel()
ESPDEPRECATED("Use wifi_ssid_to() instead. Removed in 2026.9.0", "2026.3.0") std const char * wifi_ssid_to(std::span< char, SSID_BUFFER_SIZE > buffer)
Write SSID to buffer without heap allocation.
network::IPAddress wifi_subnet_mask_()
network::IPAddress wifi_soft_ap_ip()
network::IPAddress wifi_gateway_ip_()
static void s_wifi_scan_done_callback(void *arg, STATUS status)
network::IPAddress wifi_dns_ip_(int num)
bool wifi_apply_hostname_()
bool wifi_sta_pre_setup_()
bool matches_configured_network_(const char *ssid, const uint8_t *bssid) const
Check if network matches any configured network (for scan result filtering) Matches by SSID when conf...
bool wifi_ap_ip_config_(const optional< ManualIP > &manual_ip)
bool needs_full_scan_results_() const
Check if full scan results are needed (captive portal active, improv, listeners)
StaticVector< WiFiPowerSaveListener *, ESPHOME_WIFI_POWER_SAVE_LISTENERS > power_save_listeners_
WifiMinAuthMode min_auth_mode_
bool wifi_apply_output_power_(float output_power)
bool wifi_sta_connect_(const WiFiAP &ap)
bool wifi_mode_(optional< bool > sta, optional< bool > ap)
network::IPAddresses wifi_sta_ip_addresses()
bool wifi_scan_start_(bool passive)
void wifi_scan_done_callback_()
void process_pending_callbacks_()
std::array< IPAddress, 5 > IPAddresses
std::array< uint8_t, 6 > bssid_t
const LogString * get_auth_mode_str(uint8_t mode)
const LogString * get_disconnect_reason_str(uint8_t reason)
@ WIFI_MIN_AUTH_MODE_WPA2
@ WIFI_MIN_AUTH_MODE_WPA3
struct netif * eagle_lwip_getif(int netif_index)
@ ERROR_NETWORK_NOT_FOUND
void netif_set_addr(struct netif *netif, const ip4_addr_t *ip, const ip4_addr_t *netmask, const ip4_addr_t *gw)
WiFiComponent * global_wifi_component
PROGMEM_STRING_TABLE(AuthModeStrings, "OPEN", "WEP", "WPA PSK", "WPA2 PSK", "WPA/WPA2 PSK", "UNKNOWN")
const LogString * get_op_mode_str(uint8_t mode)
void HOT delay(uint32_t ms)
Application App
Global storage of Application pointer - only one Application can exist.
char * format_mac_addr_upper(const uint8_t *mac, char *output)
Format MAC address as XX:XX:XX:XX:XX:XX (uppercase, colon separators)