7#include <user_interface.h>
12#ifdef USE_WIFI_WPA2_EAP
13#include <wpa2_enterprise.h>
21#include "lwip/apps/sntp.h"
22#include "lwip/netif.h"
24#if USE_ARDUINO_VERSION_CODE >= VERSION_CODE(3, 0, 0)
25#include "LwipDhcpServer.h"
26#if USE_ARDUINO_VERSION_CODE < VERSION_CODE(3, 1, 0)
27#include <ESP8266WiFi.h>
28#include "ESP8266WiFiAP.h"
29#define wifi_softap_set_dhcps_lease(lease) dhcpSoftAP.set_dhcps_lease(lease)
30#define wifi_softap_set_dhcps_lease_time(time) dhcpSoftAP.set_dhcps_lease_time(time)
31#define wifi_softap_set_dhcps_offer_option(offer, mode) dhcpSoftAP.set_dhcps_offer_option(offer, mode)
45static const char *
const TAG =
"wifi_esp8266";
57 uint8_t current_mode = wifi_get_opmode();
58 bool current_sta = current_mode & 0b01;
59 bool current_ap = current_mode & 0b10;
60 bool target_sta = sta.value_or(current_sta);
61 bool target_ap = ap.value_or(current_ap);
62 if (current_sta == target_sta && current_ap == target_ap)
65 if (target_sta && !current_sta) {
66 ESP_LOGV(TAG,
"Enabling STA");
67 }
else if (!target_sta && current_sta) {
68 ESP_LOGV(TAG,
"Disabling STA");
71 wifi_station_dhcpc_stop();
73 if (target_ap && !current_ap) {
74 ESP_LOGV(TAG,
"Enabling AP");
75 }
else if (!target_ap && current_ap) {
76 ESP_LOGV(TAG,
"Disabling AP");
79 ETS_UART_INTR_DISABLE();
85 bool ret = wifi_set_opmode_current(
mode);
86 ETS_UART_INTR_ENABLE();
89 ESP_LOGW(TAG,
"Set mode failed");
103 sleep_type_t power_save;
108 power_save = MODEM_SLEEP_T;
114 power_save = LIGHT_SLEEP_T;
118 power_save = NONE_SLEEP_T;
121 wifi_fpm_auto_sleep_set_in_null_mode(1);
122 bool success = wifi_set_sleep_type(power_save);
123#ifdef USE_WIFI_POWER_SAVE_LISTENERS
133#if LWIP_VERSION_MAJOR != 1
150 enum dhcp_status dhcp_status = wifi_station_dhcpc_status();
151 if (!manual_ip.has_value()) {
155 sntp_servermode_dhcp(
false);
158 if (dhcp_status != DHCP_STARTED) {
159 bool ret = wifi_station_dhcpc_start();
161 ESP_LOGV(TAG,
"Starting DHCP client failed");
170#if LWIP_VERSION_MAJOR != 1
174 wifi_get_ip_info(STATION_IF, &previp);
177 struct ip_info info {};
178 info.ip = manual_ip->static_ip;
179 info.gw = manual_ip->gateway;
180 info.netmask = manual_ip->subnet;
182 if (dhcp_status == DHCP_STARTED) {
183 bool dhcp_stop_ret = wifi_station_dhcpc_stop();
184 if (!dhcp_stop_ret) {
185 ESP_LOGV(TAG,
"Stopping DHCP client failed");
189 bool wifi_set_info_ret = wifi_set_ip_info(STATION_IF, &info);
190 if (!wifi_set_info_ret) {
191 ESP_LOGV(TAG,
"Set manual IP info failed");
196 if (manual_ip->dns1.is_set()) {
197 dns = manual_ip->dns1;
198 dns_setserver(0, &dns);
200 if (manual_ip->dns2.is_set()) {
201 dns = manual_ip->dns2;
202 dns_setserver(1, &dns);
205#if LWIP_VERSION_MAJOR != 1
208 if (previp.ip.addr != 0 && previp.ip.addr != info.ip.addr) {
210 reinterpret_cast<const ip4_addr_t *
>(&info.netmask),
reinterpret_cast<const ip4_addr_t *
>(&info.gw));
223 struct ip_info ap_ip {};
224 wifi_get_ip_info(SOFTAP_IF, &ap_ip);
226 bool filter_ap = ap_address.
is_set();
227 for (
auto &addr : addrList) {
229 if (filter_ap && ip == ap_address)
231 assert(index < addresses.size());
232 addresses[index++] = ip;
238 bool ret = wifi_station_set_hostname(
const_cast<char *
>(hostname.c_str()));
240 ESP_LOGV(TAG,
"Set hostname failed");
247 for (netif *intf = netif_list; intf; intf = intf->next) {
248#if LWIP_VERSION_MAJOR == 1
249 intf->hostname = (
char *) wifi_station_get_hostname();
251 intf->hostname = wifi_station_get_hostname();
265 struct station_config conf {};
266 memset(&conf, 0,
sizeof(conf));
267 if (ap.
ssid_.
size() >
sizeof(conf.ssid)) {
268 ESP_LOGE(TAG,
"SSID too long");
272 ESP_LOGE(TAG,
"Password too long");
280 memcpy(conf.bssid, ap.
get_bssid().data(), 6);
285#if USE_ARDUINO_VERSION_CODE >= VERSION_CODE(2, 4, 0)
287 conf.threshold.authmode = AUTH_OPEN;
293 conf.threshold.authmode = AUTH_WPA_PSK;
297 conf.threshold.authmode = AUTH_WPA2_PSK;
301 conf.threshold.rssi = -127;
304 ETS_UART_INTR_DISABLE();
305 bool ret = wifi_station_set_config_current(&conf);
306 ETS_UART_INTR_ENABLE();
309 ESP_LOGV(TAG,
"Set Station config failed");
313#ifdef USE_WIFI_MANUAL_IP
324#ifdef USE_WIFI_WPA2_EAP
325 const auto &eap_opt = ap.
get_eap();
326 if (eap_opt.has_value()) {
329 ret = wifi_station_set_enterprise_identity((uint8_t *) eap.
identity.c_str(), eap.
identity.length());
331 ESP_LOGV(TAG,
"esp_wifi_sta_wpa2_ent_set_identity failed: %d", ret);
333 int ca_cert_len = strlen(eap.
ca_cert);
337 ret = wifi_station_set_enterprise_ca_cert((uint8_t *) eap.
ca_cert, ca_cert_len + 1);
339 ESP_LOGV(TAG,
"esp_wifi_sta_wpa2_ent_set_ca_cert failed: %d", ret);
344 if (client_cert_len && client_key_len) {
346 ret = wifi_station_set_enterprise_cert_key((uint8_t *) eap.
client_cert, client_cert_len + 1,
347 (uint8_t *) eap.
client_key, client_key_len + 1,
350 ESP_LOGV(TAG,
"esp_wifi_sta_wpa2_ent_set_cert_key failed: %d", ret);
354 ret = wifi_station_set_enterprise_username((uint8_t *) eap.
username.c_str(), eap.
username.length());
356 ESP_LOGV(TAG,
"esp_wifi_sta_wpa2_ent_set_username failed: %d", ret);
358 ret = wifi_station_set_enterprise_password((uint8_t *) eap.
password.c_str(), eap.
password.length());
360 ESP_LOGV(TAG,
"esp_wifi_sta_wpa2_ent_set_password failed: %d", ret);
363 ret = wifi_station_set_wpa2_enterprise_auth(
true);
365 ESP_LOGV(TAG,
"esp_wifi_sta_wpa2_ent_enable failed: %d", ret);
376 ETS_UART_INTR_DISABLE();
377 ret = wifi_station_connect();
378 ETS_UART_INTR_ENABLE();
380 ESP_LOGV(TAG,
"wifi_station_connect failed");
385 bool connected =
false;
387 uint8_t ipv6_addr_count = 0;
388 for (
auto addr : addrList) {
389 char ip_buf[network::IP_ADDRESS_BUFFER_SIZE];
390 ESP_LOGV(TAG,
"Address %s",
network::IPAddress(addr.ipFromNetifNum()).str_to(ip_buf));
396 connected = (ipv6_addr_count >= USE_NETWORK_MIN_IPV6_ADDR_COUNT);
403 ESP_LOGV(TAG,
"wifi_set_channel failed");
411class WiFiMockClass :
public ESP8266WiFiGenericClass {
413 static void _event_callback(
void *event) { ESP8266WiFiGenericClass::_eventCallback(event); }
418static_assert(AUTH_OPEN == 0 && AUTH_WEP == 1 && AUTH_WPA_PSK == 2 && AUTH_WPA2_PSK == 3 && AUTH_WPA_WPA2_PSK == 4,
419 "AUTH_* constants are not contiguous");
423 return AuthModeStrings::get_log_str(
mode, AuthModeStrings::LAST_INDEX);
427static_assert(WIFI_OFF == 0 && WIFI_STA == 1 && WIFI_AP == 2 && WIFI_AP_STA == 3,
428 "WIFI_* op mode constants are not contiguous");
437 if (reason == REASON_AUTH_EXPIRE)
438 return LOG_STR(
"Auth Expired");
439 if (reason == REASON_AUTH_LEAVE)
440 return LOG_STR(
"Auth Leave");
441 if (reason == REASON_ASSOC_EXPIRE)
442 return LOG_STR(
"Association Expired");
443 if (reason == REASON_ASSOC_TOOMANY)
444 return LOG_STR(
"Too Many Associations");
445 if (reason == REASON_NOT_AUTHED)
446 return LOG_STR(
"Not Authenticated");
447 if (reason == REASON_NOT_ASSOCED)
448 return LOG_STR(
"Not Associated");
449 if (reason == REASON_ASSOC_LEAVE)
450 return LOG_STR(
"Association Leave");
451 if (reason == REASON_ASSOC_NOT_AUTHED)
452 return LOG_STR(
"Association not Authenticated");
453 if (reason == REASON_DISASSOC_PWRCAP_BAD)
454 return LOG_STR(
"Disassociate Power Cap Bad");
455 if (reason == REASON_DISASSOC_SUPCHAN_BAD)
456 return LOG_STR(
"Disassociate Supported Channel Bad");
457 if (reason == REASON_IE_INVALID)
458 return LOG_STR(
"IE Invalid");
459 if (reason == REASON_MIC_FAILURE)
460 return LOG_STR(
"Mic Failure");
461 if (reason == REASON_4WAY_HANDSHAKE_TIMEOUT)
462 return LOG_STR(
"4-Way Handshake Timeout");
463 if (reason == REASON_GROUP_KEY_UPDATE_TIMEOUT)
464 return LOG_STR(
"Group Key Update Timeout");
465 if (reason == REASON_IE_IN_4WAY_DIFFERS)
466 return LOG_STR(
"IE In 4-Way Handshake Differs");
467 if (reason == REASON_GROUP_CIPHER_INVALID)
468 return LOG_STR(
"Group Cipher Invalid");
469 if (reason == REASON_PAIRWISE_CIPHER_INVALID)
470 return LOG_STR(
"Pairwise Cipher Invalid");
471 if (reason == REASON_AKMP_INVALID)
472 return LOG_STR(
"AKMP Invalid");
473 if (reason == REASON_UNSUPP_RSN_IE_VERSION)
474 return LOG_STR(
"Unsupported RSN IE version");
475 if (reason == REASON_INVALID_RSN_IE_CAP)
476 return LOG_STR(
"Invalid RSN IE Cap");
477 if (reason == REASON_802_1X_AUTH_FAILED)
478 return LOG_STR(
"802.1x Authentication Failed");
479 if (reason == REASON_CIPHER_SUITE_REJECTED)
480 return LOG_STR(
"Cipher Suite Rejected");
481 if (reason == REASON_BEACON_TIMEOUT)
482 return LOG_STR(
"Beacon Timeout");
483 if (reason == REASON_NO_AP_FOUND)
484 return LOG_STR(
"AP Not Found");
485 if (reason == REASON_AUTH_FAIL)
486 return LOG_STR(
"Authentication Failed");
487 if (reason == REASON_ASSOC_FAIL)
488 return LOG_STR(
"Association Failed");
489 if (reason == REASON_HANDSHAKE_TIMEOUT)
490 return LOG_STR(
"Handshake Failed");
491 return LOG_STR(
"Unspecified");
495 switch (event->event) {
496 case EVENT_STAMODE_CONNECTED: {
497 auto it =
event->event_info.connected;
498#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE
499 char bssid_buf[MAC_ADDRESS_PRETTY_BUFFER_SIZE];
501 ESP_LOGV(TAG,
"Connected ssid='%.*s' bssid=%s channel=%u", it.ssid_len, (
const char *) it.ssid, bssid_buf,
505#ifdef USE_WIFI_CONNECT_STATE_LISTENERS
512 case EVENT_STAMODE_DISCONNECTED: {
513 auto it =
event->event_info.disconnected;
514 if (it.reason == REASON_NO_AP_FOUND) {
515 ESP_LOGW(TAG,
"Disconnected ssid='%.*s' reason='Probe Request Unsuccessful'", it.ssid_len,
516 (
const char *) it.ssid);
521 ESP_LOGW(TAG,
"Disconnected ssid='%.*s' bssid=" LOG_SECRET(
"%s")
" reason='%s'", it.ssid_len,
526#ifdef USE_WIFI_CONNECT_STATE_LISTENERS
531 case EVENT_STAMODE_AUTHMODE_CHANGE: {
532 auto it =
event->event_info.auth_change;
533 ESP_LOGV(TAG,
"Changed Authmode old=%s new=%s", LOG_STR_ARG(
get_auth_mode_str(it.old_mode)),
537 if (it.old_mode != AUTH_OPEN && it.new_mode == AUTH_OPEN) {
538 ESP_LOGW(TAG,
"Potential Authmode downgrade detected, disconnecting");
539 wifi_station_disconnect();
544 case EVENT_STAMODE_GOT_IP: {
545 auto it =
event->event_info.got_ip;
546 char ip_buf[network::IP_ADDRESS_BUFFER_SIZE], gw_buf[network::IP_ADDRESS_BUFFER_SIZE],
547 mask_buf[network::IP_ADDRESS_BUFFER_SIZE];
548 ESP_LOGV(TAG,
"static_ip=%s gateway=%s netmask=%s",
network::IPAddress(&it.ip).str_to(ip_buf),
551#ifdef USE_WIFI_IP_STATE_LISTENERS
557 case EVENT_STAMODE_DHCP_TIMEOUT: {
558 ESP_LOGW(TAG,
"DHCP request timeout");
561 case EVENT_SOFTAPMODE_STACONNECTED: {
562#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE
563 auto it =
event->event_info.sta_connected;
564 char mac_buf[MAC_ADDRESS_PRETTY_BUFFER_SIZE];
566 ESP_LOGV(TAG,
"AP client connected MAC=%s aid=%u", mac_buf, it.aid);
570 case EVENT_SOFTAPMODE_STADISCONNECTED: {
571#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE
572 auto it =
event->event_info.sta_disconnected;
573 char mac_buf[MAC_ADDRESS_PRETTY_BUFFER_SIZE];
575 ESP_LOGV(TAG,
"AP client disconnected MAC=%s aid=%u", mac_buf, it.aid);
579 case EVENT_SOFTAPMODE_PROBEREQRECVED: {
580#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERY_VERBOSE
581 auto it =
event->event_info.ap_probereqrecved;
582 char mac_buf[MAC_ADDRESS_PRETTY_BUFFER_SIZE];
584 ESP_LOGVV(TAG,
"AP receive Probe Request MAC=%s RSSI=%d", mac_buf, it.rssi);
588#if USE_ARDUINO_VERSION_CODE >= VERSION_CODE(2, 4, 0)
589 case EVENT_OPMODE_CHANGED: {
590 auto it =
event->event_info.opmode_changed;
591 ESP_LOGV(TAG,
"Changed Mode old=%s new=%s", LOG_STR_ARG(
get_op_mode_str(it.old_opmode)),
595 case EVENT_SOFTAPMODE_DISTRIBUTE_STA_IP: {
596#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE
597 auto it =
event->event_info.distribute_sta_ip;
598 char mac_buf[MAC_ADDRESS_PRETTY_BUFFER_SIZE];
599 char ip_buf[network::IP_ADDRESS_BUFFER_SIZE];
601 ESP_LOGV(TAG,
"AP Distribute Station IP MAC=%s IP=%s aid=%u", mac_buf,
network::IPAddress(&it.ip).str_to(ip_buf),
611 WiFiMockClass::_event_callback(event);
615 uint8_t
val =
static_cast<uint8_t
>(output_power * 4);
616 system_phy_set_max_tpw(
val);
624 ETS_UART_INTR_DISABLE();
625 ret1 = wifi_station_set_auto_connect(0);
626 ret2 = wifi_station_set_reconnect_policy(
false);
627 ETS_UART_INTR_ENABLE();
629 if (!ret1 || !ret2) {
630 ESP_LOGV(TAG,
"Disabling Auto-Connect failed");
633#ifdef USE_WIFI_PHY_MODE
635 ESP_LOGV(TAG,
"Setting PHY Mode failed");
643#ifdef USE_WIFI_PHY_MODE
648 return wifi_set_phy_mode(
static_cast<phy_mode_t
>(this->
phy_mode_));
685 struct scan_config config {};
686 memset(&config, 0,
sizeof(config));
687 config.ssid =
nullptr;
688 config.bssid =
nullptr;
690 config.show_hidden = 1;
691#if USE_ARDUINO_VERSION_CODE >= VERSION_CODE(2, 4, 0)
692 config.scan_type = passive ? WIFI_SCAN_TYPE_PASSIVE : WIFI_SCAN_TYPE_ACTIVE;
697 static constexpr uint32_t SCAN_PASSIVE_DEFAULT_MS = 500;
698 static constexpr uint32_t SCAN_PASSIVE_ROAMING_MS = 300;
699 static constexpr uint32_t SCAN_ACTIVE_MIN_DEFAULT_MS = 400;
700 static constexpr uint32_t SCAN_ACTIVE_MAX_DEFAULT_MS = 500;
701 static constexpr uint32_t SCAN_ACTIVE_MIN_ROAMING_MS = 100;
702 static constexpr uint32_t SCAN_ACTIVE_MAX_ROAMING_MS = 300;
705 config.scan_time.passive = roaming ? SCAN_PASSIVE_ROAMING_MS : SCAN_PASSIVE_DEFAULT_MS;
707 config.scan_time.active.min = roaming ? SCAN_ACTIVE_MIN_ROAMING_MS : SCAN_ACTIVE_MIN_DEFAULT_MS;
708 config.scan_time.active.max = roaming ? SCAN_ACTIVE_MAX_ROAMING_MS : SCAN_ACTIVE_MAX_DEFAULT_MS;
713 ESP_LOGV(TAG,
"wifi_station_scan failed");
722 if (wifi_get_opmode() & WIFI_STA)
723 ret = wifi_station_disconnect();
724 station_config conf{};
725 memset(&conf, 0,
sizeof(conf));
726 ETS_UART_INTR_DISABLE();
727 wifi_station_set_config_current(&conf);
728 ETS_UART_INTR_ENABLE();
739 ESP_LOGV(TAG,
"Scan failed: %d",
status);
747 auto *head =
reinterpret_cast<bss_info *
>(arg);
753 for (bss_info *it = head; it !=
nullptr; it = STAILQ_NEXT(it, next)) {
755 const char *ssid_cstr =
reinterpret_cast<const char *
>(it->ssid);
764 for (bss_info *it = head; it !=
nullptr; it = STAILQ_NEXT(it, next)) {
765 const char *ssid_cstr =
reinterpret_cast<const char *
>(it->ssid);
768 bssid_t{it->bssid[0], it->bssid[1], it->bssid[2], it->bssid[3], it->bssid[4], it->bssid[5]}, ssid_cstr,
769 it->ssid_len, it->channel, it->rssi, it->authmode != AUTH_OPEN, it->is_hidden != 0);
774 ESP_LOGV(TAG,
"Scan complete: %zu found, %zu stored%s", total, this->
scan_result_.size(),
775 needs_full ? LOG_STR_LITERAL(
"") : LOG_STR_LITERAL(
" (filtered)"));
777#ifdef USE_WIFI_SCAN_RESULTS_LISTENERS
778 this->
pending_.scan_complete =
true;
788 struct ip_info info {};
789 if (manual_ip.has_value()) {
790 info.ip = manual_ip->static_ip;
791 info.gw = manual_ip->gateway;
792 info.netmask = manual_ip->subnet;
799 if (wifi_softap_dhcps_status() == DHCP_STARTED) {
800 if (!wifi_softap_dhcps_stop()) {
801 ESP_LOGW(TAG,
"Stopping DHCP server failed");
805 if (!wifi_set_ip_info(SOFTAP_IF, &info)) {
806 ESP_LOGE(TAG,
"Set SoftAP info failed");
810#if USE_ARDUINO_VERSION_CODE >= VERSION_CODE(3, 0, 0) && USE_ARDUINO_VERSION_CODE < VERSION_CODE(3, 1, 0)
811 dhcpSoftAP.begin(&info);
814 struct dhcps_lease lease {};
818 lease.start_ip = start_address;
819#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE
820 char ip_buf[network::IP_ADDRESS_BUFFER_SIZE];
822 ESP_LOGV(TAG,
"DHCP server IP lease start: %s", start_address.str_to(ip_buf));
824 lease.end_ip = start_address;
825 ESP_LOGV(TAG,
"DHCP server IP lease end: %s", start_address.str_to(ip_buf));
826 if (!wifi_softap_set_dhcps_lease(&lease)) {
827 ESP_LOGE(TAG,
"Set SoftAP DHCP lease failed");
832 if (!wifi_softap_set_dhcps_lease_time(1440)) {
833 ESP_LOGE(TAG,
"Set SoftAP DHCP lease time failed");
837#if USE_ARDUINO_VERSION_CODE >= VERSION_CODE(3, 1, 0)
838 ESP8266WiFiClass::softAPDhcpServer().setRouter(
true);
842 if (!wifi_softap_set_dhcps_offer_option(OFFER_ROUTER, &
mode)) {
843 ESP_LOGE(TAG,
"wifi_softap_set_dhcps_offer_option failed");
848 if (!wifi_softap_dhcps_start()) {
849 ESP_LOGE(TAG,
"Starting SoftAP DHCPS failed");
861 struct softap_config conf {};
862 if (ap.
ssid_.
size() >
sizeof(conf.ssid)) {
863 ESP_LOGE(TAG,
"AP SSID too long");
867 conf.ssid_len =
static_cast<uint8
>(ap.
ssid_.
size());
870 conf.max_connection = 5;
871 conf.beacon_interval = 100;
874 conf.authmode = AUTH_OPEN;
877 conf.authmode = AUTH_WPA2_PSK;
879 ESP_LOGE(TAG,
"AP password too long");
885 ETS_UART_INTR_DISABLE();
886 bool ret = wifi_softap_set_config_current(&conf);
887 ETS_UART_INTR_ENABLE();
890 ESP_LOGV(TAG,
"wifi_softap_set_config_current failed");
894#ifdef USE_WIFI_MANUAL_IP
896 ESP_LOGV(TAG,
"wifi_ap_ip_config_ failed");
901 ESP_LOGV(TAG,
"wifi_ap_ip_config_ failed");
910 struct ip_info ip {};
911 wifi_get_ip_info(SOFTAP_IF, &ip);
918 struct station_config conf {};
919 if (wifi_station_get_config(&conf)) {
920 std::copy_n(conf.bssid, bssid.size(), bssid.begin());
924std::string WiFiComponent::wifi_ssid() {
925 struct station_config conf {};
926 if (!wifi_station_get_config(&conf)) {
930 auto *ssid_s =
reinterpret_cast<const char *
>(conf.ssid);
931 size_t len = strnlen(ssid_s,
sizeof(conf.ssid));
932 return {ssid_s,
len};
935 struct station_config conf {};
936 if (!wifi_station_get_config(&conf)) {
938 return buffer.data();
941 size_t len = strnlen(
reinterpret_cast<const char *
>(conf.ssid),
sizeof(conf.ssid));
942 memcpy(buffer.data(), conf.ssid,
len);
944 return buffer.data();
947 if (wifi_station_get_connect_status() != STATION_GOT_IP)
948 return WIFI_RSSI_DISCONNECTED;
949 sint8 rssi = wifi_station_get_rssi();
951 return rssi >= 31 ? WIFI_RSSI_DISCONNECTED : rssi;
955 struct ip_info ip {};
956 wifi_get_ip_info(STATION_IF, &ip);
960 struct ip_info ip {};
961 wifi_get_ip_info(STATION_IF, &ip);
975#ifdef USE_WIFI_CONNECT_STATE_LISTENERS
984#ifdef USE_WIFI_IP_STATE_LISTENERS
991#ifdef USE_WIFI_SCAN_RESULTS_LISTENERS
993 this->
pending_.scan_complete =
false;
BedjetMode mode
BedJet operating mode.
const StringRef & get_name() const
Get the name of this Application set by pre_setup().
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
WiFi8266PhyMode phy_mode_
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)
RoamingState roaming_state_
static void wifi_event_callback(System_Event_t *event)
struct esphome::wifi::WiFiComponent::@191 pending_
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)
void update_connected_state_()
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)
bool wifi_apply_phy_mode_()
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)
@ WIFI_8266_PHY_MODE_AUTO
WiFiComponent * global_wifi_component
PROGMEM_STRING_TABLE(AuthModeStrings, "OPEN", "WEP", "WPA PSK", "WPA2 PSK", "WPA/WPA2 PSK", "UNKNOWN")
@ SCANNING
Scanning for better AP.
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)