4 #ifdef USE_ESP32_FRAMEWORK_ARDUINO 11 #ifdef USE_WIFI_WPA2_EAP 14 #include "lwip/apps/sntp.h" 27 static const char *
const TAG =
"wifi_esp32";
29 static esp_netif_t *s_sta_netif =
nullptr;
31 static esp_netif_t *s_ap_netif =
nullptr;
34 static bool s_sta_connecting =
false;
44 WiFi.persistent(
false);
50 wifi_mode_t current_mode = WiFiClass::getMode();
51 bool current_sta = current_mode == WIFI_MODE_STA || current_mode == WIFI_MODE_APSTA;
52 bool current_ap = current_mode == WIFI_MODE_AP || current_mode == WIFI_MODE_APSTA;
58 if (set_sta && set_ap) {
59 set_mode = WIFI_MODE_APSTA;
60 }
else if (set_sta && !set_ap) {
61 set_mode = WIFI_MODE_STA;
62 }
else if (!set_sta && set_ap) {
63 set_mode = WIFI_MODE_AP;
65 set_mode = WIFI_MODE_NULL;
68 if (current_mode == set_mode)
71 if (set_sta && !current_sta) {
72 ESP_LOGV(TAG,
"Enabling STA.");
73 }
else if (!set_sta && current_sta) {
74 ESP_LOGV(TAG,
"Disabling STA.");
76 if (set_ap && !current_ap) {
77 ESP_LOGV(TAG,
"Enabling AP.");
78 }
else if (!set_ap && current_ap) {
79 ESP_LOGV(TAG,
"Disabling AP.");
85 ESP_LOGW(TAG,
"Setting WiFi mode failed!");
95 s_ap_netif = esp_netif_get_handle_from_ifkey(
"WIFI_AP_DEF");
105 WiFi.setAutoReconnect(
false);
111 int8_t
val =
static_cast<int8_t
>(output_power * 4);
112 return esp_wifi_set_max_tx_power(val) == ESP_OK;
116 wifi_ps_type_t power_save;
119 power_save = WIFI_PS_MIN_MODEM;
122 power_save = WIFI_PS_MAX_MODEM;
126 power_save = WIFI_PS_NONE;
129 return esp_wifi_set_ps(power_save) == ESP_OK;
139 memset(&conf, 0,
sizeof(conf));
140 snprintf(reinterpret_cast<char *>(conf.sta.ssid),
sizeof(conf.sta.ssid),
"%s", ap.
get_ssid().c_str());
141 snprintf(reinterpret_cast<char *>(conf.sta.password),
sizeof(conf.sta.password),
"%s", ap.
get_password().c_str());
145 conf.sta.threshold.authmode = WIFI_AUTH_OPEN;
147 conf.sta.threshold.authmode = WIFI_AUTH_WPA_WPA2_PSK;
150 #ifdef USE_WIFI_WPA2_EAP 151 if (ap.
get_eap().has_value()) {
152 conf.sta.threshold.authmode = WIFI_AUTH_WPA2_ENTERPRISE;
157 conf.sta.bssid_set =
true;
158 memcpy(conf.sta.bssid, ap.
get_bssid()->data(), 6);
160 conf.sta.bssid_set =
false;
164 conf.sta.scan_method = WIFI_FAST_SCAN;
166 conf.sta.scan_method = WIFI_ALL_CHANNEL_SCAN;
170 conf.sta.listen_interval = 0;
174 conf.sta.pmf_cfg.capable =
true;
175 conf.sta.pmf_cfg.required =
false;
179 conf.sta.threshold.rssi = -127;
181 conf.sta.threshold.authmode = WIFI_AUTH_OPEN;
183 wifi_config_t current_conf;
185 err = esp_wifi_get_config(WIFI_IF_STA, ¤t_conf);
187 ESP_LOGW(TAG,
"esp_wifi_get_config failed: %s", esp_err_to_name(err));
191 if (memcmp(¤t_conf, &conf,
sizeof(wifi_config_t)) != 0) {
192 err = esp_wifi_disconnect();
194 ESP_LOGV(TAG,
"esp_wifi_disconnect failed: %s", esp_err_to_name(err));
199 err = esp_wifi_set_config(WIFI_IF_STA, &conf);
201 ESP_LOGV(TAG,
"esp_wifi_set_config failed: %s", esp_err_to_name(err));
210 #ifdef USE_WIFI_WPA2_EAP 211 if (ap.
get_eap().has_value()) {
214 err = esp_wifi_sta_wpa2_ent_set_identity((uint8_t *) eap.
identity.c_str(), eap.
identity.length());
216 ESP_LOGV(TAG,
"esp_wifi_sta_wpa2_ent_set_identity failed! %d", err);
218 int ca_cert_len = strlen(eap.
ca_cert);
222 err = esp_wifi_sta_wpa2_ent_set_ca_cert((uint8_t *) eap.
ca_cert, ca_cert_len + 1);
224 ESP_LOGV(TAG,
"esp_wifi_sta_wpa2_ent_set_ca_cert failed! %d", err);
229 if (client_cert_len && client_key_len) {
231 err = esp_wifi_sta_wpa2_ent_set_cert_key((uint8_t *) eap.
client_cert, client_cert_len + 1,
232 (uint8_t *) eap.
client_key, client_key_len + 1,
235 ESP_LOGV(TAG,
"esp_wifi_sta_wpa2_ent_set_cert_key failed! %d", err);
239 err = esp_wifi_sta_wpa2_ent_set_username((uint8_t *) eap.
username.c_str(), eap.
username.length());
241 ESP_LOGV(TAG,
"esp_wifi_sta_wpa2_ent_set_username failed! %d", err);
243 err = esp_wifi_sta_wpa2_ent_set_password((uint8_t *) eap.
password.c_str(), eap.
password.length());
245 ESP_LOGV(TAG,
"esp_wifi_sta_wpa2_ent_set_password failed! %d", err);
248 err = esp_wifi_sta_wpa2_ent_enable();
250 ESP_LOGV(TAG,
"esp_wifi_sta_wpa2_ent_enable failed! %d", err);
253 #endif // USE_WIFI_WPA2_EAP 257 s_sta_connecting =
true;
259 err = esp_wifi_connect();
261 ESP_LOGW(TAG,
"esp_wifi_connect failed: %s", esp_err_to_name(err));
273 esp_netif_dhcp_status_t dhcp_status;
274 esp_err_t err = esp_netif_dhcpc_get_status(s_sta_netif, &dhcp_status);
276 ESP_LOGV(TAG,
"esp_netif_dhcpc_get_status failed: %s", esp_err_to_name(err));
284 sntp_servermode_dhcp(
false);
287 if (dhcp_status != ESP_NETIF_DHCP_STARTED) {
288 err = esp_netif_dhcpc_start(s_sta_netif);
290 ESP_LOGV(TAG,
"Starting DHCP client failed! %d", err);
292 return err == ESP_OK;
297 esp_netif_ip_info_t info;
298 info.ip = manual_ip->static_ip;
299 info.gw = manual_ip->gateway;
300 info.netmask = manual_ip->subnet;
301 err = esp_netif_dhcpc_stop(s_sta_netif);
302 if (err != ESP_OK && err != ESP_ERR_ESP_NETIF_DHCP_ALREADY_STOPPED) {
303 ESP_LOGV(TAG,
"Stopping DHCP client failed! %s", esp_err_to_name(err));
306 err = esp_netif_set_ip_info(s_sta_netif, &info);
308 ESP_LOGV(TAG,
"Setting manual IP info failed! %s", esp_err_to_name(err));
311 esp_netif_dns_info_t dns;
312 if (manual_ip->dns1.is_set()) {
313 dns.ip = manual_ip->dns1;
314 esp_netif_set_dns_info(s_sta_netif, ESP_NETIF_DNS_MAIN, &dns);
316 if (manual_ip->dns2.is_set()) {
317 dns.ip = manual_ip->dns2;
318 esp_netif_set_dns_info(s_sta_netif, ESP_NETIF_DNS_BACKUP, &dns);
328 esp_netif_ip_info_t ip;
329 esp_err_t err = esp_netif_get_ip_info(s_sta_netif, &ip);
331 ESP_LOGV(TAG,
"esp_netif_get_ip_info failed: %s", esp_err_to_name(err));
338 struct esp_ip6_addr if_ip6s[CONFIG_LWIP_IPV6_NUM_ADDRESSES];
340 count = esp_netif_get_all_ip6(s_sta_netif, if_ip6s);
341 assert(count <= CONFIG_LWIP_IPV6_NUM_ADDRESSES);
342 for (
int i = 0; i < count; i++) {
359 case WIFI_AUTH_WPA_PSK:
361 case WIFI_AUTH_WPA2_PSK:
363 case WIFI_AUTH_WPA_WPA2_PSK:
364 return "WPA/WPA2 PSK";
365 case WIFI_AUTH_WPA2_ENTERPRISE:
366 return "WPA2 Enterprise";
367 case WIFI_AUTH_WPA3_PSK:
369 case WIFI_AUTH_WPA2_WPA3_PSK:
370 return "WPA2/WPA3 PSK";
371 case WIFI_AUTH_WAPI_PSK:
382 sprintf(buf,
"%u.%u.%u.%u", uint8_t(ip.addr >> 0), uint8_t(ip.addr >> 8), uint8_t(ip.addr >> 16),
383 uint8_t(ip.addr >> 24));
402 case WIFI_REASON_AUTH_EXPIRE:
403 return "Auth Expired";
404 case WIFI_REASON_AUTH_LEAVE:
406 case WIFI_REASON_ASSOC_EXPIRE:
407 return "Association Expired";
408 case WIFI_REASON_ASSOC_TOOMANY:
409 return "Too Many Associations";
410 case WIFI_REASON_NOT_AUTHED:
411 return "Not Authenticated";
412 case WIFI_REASON_NOT_ASSOCED:
413 return "Not Associated";
414 case WIFI_REASON_ASSOC_LEAVE:
415 return "Association Leave";
416 case WIFI_REASON_ASSOC_NOT_AUTHED:
417 return "Association not Authenticated";
418 case WIFI_REASON_DISASSOC_PWRCAP_BAD:
419 return "Disassociate Power Cap Bad";
420 case WIFI_REASON_DISASSOC_SUPCHAN_BAD:
421 return "Disassociate Supported Channel Bad";
422 case WIFI_REASON_IE_INVALID:
424 case WIFI_REASON_MIC_FAILURE:
425 return "Mic Failure";
426 case WIFI_REASON_4WAY_HANDSHAKE_TIMEOUT:
427 return "4-Way Handshake Timeout";
428 case WIFI_REASON_GROUP_KEY_UPDATE_TIMEOUT:
429 return "Group Key Update Timeout";
430 case WIFI_REASON_IE_IN_4WAY_DIFFERS:
431 return "IE In 4-Way Handshake Differs";
432 case WIFI_REASON_GROUP_CIPHER_INVALID:
433 return "Group Cipher Invalid";
434 case WIFI_REASON_PAIRWISE_CIPHER_INVALID:
435 return "Pairwise Cipher Invalid";
436 case WIFI_REASON_AKMP_INVALID:
437 return "AKMP Invalid";
438 case WIFI_REASON_UNSUPP_RSN_IE_VERSION:
439 return "Unsupported RSN IE version";
440 case WIFI_REASON_INVALID_RSN_IE_CAP:
441 return "Invalid RSN IE Cap";
442 case WIFI_REASON_802_1X_AUTH_FAILED:
443 return "802.1x Authentication Failed";
444 case WIFI_REASON_CIPHER_SUITE_REJECTED:
445 return "Cipher Suite Rejected";
446 case WIFI_REASON_BEACON_TIMEOUT:
447 return "Beacon Timeout";
448 case WIFI_REASON_NO_AP_FOUND:
449 return "AP Not Found";
450 case WIFI_REASON_AUTH_FAIL:
451 return "Authentication Failed";
452 case WIFI_REASON_ASSOC_FAIL:
453 return "Association Failed";
454 case WIFI_REASON_HANDSHAKE_TIMEOUT:
455 return "Handshake Failed";
456 case WIFI_REASON_CONNECTION_FAIL:
457 return "Connection Failed";
458 case WIFI_REASON_ROAMING:
459 return "Station Roaming";
460 case WIFI_REASON_UNSPECIFIED:
462 return "Unspecified";
468 #define ESPHOME_EVENT_ID_WIFI_READY ARDUINO_EVENT_WIFI_READY 469 #define ESPHOME_EVENT_ID_WIFI_SCAN_DONE ARDUINO_EVENT_WIFI_SCAN_DONE 470 #define ESPHOME_EVENT_ID_WIFI_STA_START ARDUINO_EVENT_WIFI_STA_START 471 #define ESPHOME_EVENT_ID_WIFI_STA_STOP ARDUINO_EVENT_WIFI_STA_STOP 472 #define ESPHOME_EVENT_ID_WIFI_STA_CONNECTED ARDUINO_EVENT_WIFI_STA_CONNECTED 473 #define ESPHOME_EVENT_ID_WIFI_STA_DISCONNECTED ARDUINO_EVENT_WIFI_STA_DISCONNECTED 474 #define ESPHOME_EVENT_ID_WIFI_STA_AUTHMODE_CHANGE ARDUINO_EVENT_WIFI_STA_AUTHMODE_CHANGE 475 #define ESPHOME_EVENT_ID_WIFI_STA_GOT_IP ARDUINO_EVENT_WIFI_STA_GOT_IP 476 #define ESPHOME_EVENT_ID_WIFI_STA_GOT_IP6 ARDUINO_EVENT_WIFI_STA_GOT_IP6 477 #define ESPHOME_EVENT_ID_WIFI_STA_LOST_IP ARDUINO_EVENT_WIFI_STA_LOST_IP 478 #define ESPHOME_EVENT_ID_WIFI_AP_START ARDUINO_EVENT_WIFI_AP_START 479 #define ESPHOME_EVENT_ID_WIFI_AP_STOP ARDUINO_EVENT_WIFI_AP_STOP 480 #define ESPHOME_EVENT_ID_WIFI_AP_STACONNECTED ARDUINO_EVENT_WIFI_AP_STACONNECTED 481 #define ESPHOME_EVENT_ID_WIFI_AP_STADISCONNECTED ARDUINO_EVENT_WIFI_AP_STADISCONNECTED 482 #define ESPHOME_EVENT_ID_WIFI_AP_STAIPASSIGNED ARDUINO_EVENT_WIFI_AP_STAIPASSIGNED 483 #define ESPHOME_EVENT_ID_WIFI_AP_PROBEREQRECVED ARDUINO_EVENT_WIFI_AP_PROBEREQRECVED 484 #define ESPHOME_EVENT_ID_WIFI_AP_GOT_IP6 ARDUINO_EVENT_WIFI_AP_GOT_IP6 490 case ESPHOME_EVENT_ID_WIFI_READY: {
491 ESP_LOGV(TAG,
"Event: WiFi ready");
494 case ESPHOME_EVENT_ID_WIFI_SCAN_DONE: {
495 auto it = info.wifi_scan_done;
496 ESP_LOGV(TAG,
"Event: WiFi Scan Done status=%u number=%u scan_id=%u", it.status, it.number, it.scan_id);
501 case ESPHOME_EVENT_ID_WIFI_STA_START: {
502 ESP_LOGV(TAG,
"Event: WiFi STA start");
504 s_sta_netif = esp_netif_get_handle_from_ifkey(
"WIFI_STA_DEF");
505 esp_err_t err = esp_netif_set_hostname(s_sta_netif,
App.
get_name().c_str());
507 ESP_LOGW(TAG,
"esp_netif_set_hostname failed: %s", esp_err_to_name(err));
511 case ESPHOME_EVENT_ID_WIFI_STA_STOP: {
512 ESP_LOGV(TAG,
"Event: WiFi STA stop");
515 case ESPHOME_EVENT_ID_WIFI_STA_CONNECTED: {
516 auto it = info.wifi_sta_connected;
518 memcpy(buf, it.ssid, it.ssid_len);
519 buf[it.ssid_len] =
'\0';
520 ESP_LOGV(TAG,
"Event: Connected ssid='%s' bssid=" LOG_SECRET(
"%s")
" channel=%u, authmode=%s", buf,
528 case ESPHOME_EVENT_ID_WIFI_STA_DISCONNECTED: {
529 auto it = info.wifi_sta_disconnected;
531 memcpy(buf, it.ssid, it.ssid_len);
532 buf[it.ssid_len] =
'\0';
533 if (it.reason == WIFI_REASON_NO_AP_FOUND) {
534 ESP_LOGW(TAG,
"Event: Disconnected ssid='%s' reason='Probe Request Unsuccessful'", buf);
536 ESP_LOGW(TAG,
"Event: Disconnected ssid='%s' bssid=" LOG_SECRET(
"%s")
" reason='%s'", buf,
540 uint8_t reason = it.reason;
541 if (reason == WIFI_REASON_AUTH_EXPIRE || reason == WIFI_REASON_BEACON_TIMEOUT ||
542 reason == WIFI_REASON_NO_AP_FOUND || reason == WIFI_REASON_ASSOC_FAIL ||
543 reason == WIFI_REASON_HANDSHAKE_TIMEOUT) {
544 err_t err = esp_wifi_disconnect();
546 ESP_LOGV(TAG,
"Disconnect failed: %s", esp_err_to_name(err));
551 s_sta_connecting =
false;
554 case ESPHOME_EVENT_ID_WIFI_STA_AUTHMODE_CHANGE: {
555 auto it = info.wifi_sta_authmode_change;
556 ESP_LOGV(TAG,
"Event: Authmode Change old=%s new=%s",
get_auth_mode_str(it.old_mode),
560 if (it.old_mode != WIFI_AUTH_OPEN && it.new_mode == WIFI_AUTH_OPEN) {
561 ESP_LOGW(TAG,
"Potential Authmode downgrade detected, disconnecting...");
564 err_t err = esp_wifi_disconnect();
566 ESP_LOGW(TAG,
"Disconnect failed: %s", esp_err_to_name(err));
572 case ESPHOME_EVENT_ID_WIFI_STA_GOT_IP: {
573 auto it = info.got_ip.ip_info;
574 ESP_LOGV(TAG,
"Event: Got IP static_ip=%s gateway=%s",
format_ip4_addr(it.ip).c_str(),
580 s_sta_connecting =
false;
585 case ESPHOME_EVENT_ID_WIFI_STA_GOT_IP6: {
586 auto it = info.got_ip6.ip6_info;
587 ESP_LOGV(TAG,
"Got IPv6 address=" IPV6STR, IPV62STR(it.ip));
593 case ESPHOME_EVENT_ID_WIFI_STA_LOST_IP: {
594 ESP_LOGV(TAG,
"Event: Lost IP");
598 case ESPHOME_EVENT_ID_WIFI_AP_START: {
599 ESP_LOGV(TAG,
"Event: WiFi AP start");
602 case ESPHOME_EVENT_ID_WIFI_AP_STOP: {
603 ESP_LOGV(TAG,
"Event: WiFi AP stop");
606 case ESPHOME_EVENT_ID_WIFI_AP_STACONNECTED: {
607 auto it = info.wifi_sta_connected;
608 auto &mac = it.bssid;
609 ESP_LOGV(TAG,
"Event: AP client connected MAC=%s",
format_mac_addr(mac).c_str());
612 case ESPHOME_EVENT_ID_WIFI_AP_STADISCONNECTED: {
613 auto it = info.wifi_sta_disconnected;
614 auto &mac = it.bssid;
615 ESP_LOGV(TAG,
"Event: AP client disconnected MAC=%s",
format_mac_addr(mac).c_str());
618 case ESPHOME_EVENT_ID_WIFI_AP_STAIPASSIGNED: {
619 ESP_LOGV(TAG,
"Event: AP client assigned IP");
622 case ESPHOME_EVENT_ID_WIFI_AP_PROBEREQRECVED: {
623 auto it = info.wifi_ap_probereqrecved;
624 ESP_LOGVV(TAG,
"Event: AP receive Probe Request MAC=%s RSSI=%d",
format_mac_addr(it.mac).c_str(), it.rssi);
634 if (
status == WL_CONNECT_FAILED ||
status == WL_CONNECTION_LOST) {
637 if (
status == WL_NO_SSID_AVAIL) {
640 if (s_sta_connecting) {
643 if (
status == WL_CONNECTED) {
654 int16_t err = WiFi.scanNetworks(
true,
true, passive, 200);
655 if (err != WIFI_SCAN_RUNNING) {
656 ESP_LOGV(TAG,
"WiFi.scanNetworks failed! %d", err);
665 int16_t num = WiFi.scanComplete();
669 this->
scan_result_.reserve(static_cast<unsigned int>(num));
670 for (
int i = 0; i < num; i++) {
671 String ssid = WiFi.SSID(i);
672 wifi_auth_mode_t authmode = WiFi.encryptionType(i);
673 int32_t rssi = WiFi.RSSI(i);
674 uint8_t *bssid = WiFi.BSSID(i);
675 int32_t channel = WiFi.channel(i);
677 WiFiScanResult scan({bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5]}, std::string(ssid.c_str()),
678 channel, rssi, authmode != WIFI_AUTH_OPEN, ssid.length() == 0);
693 esp_netif_ip_info_t info;
695 info.ip = manual_ip->static_ip;
696 info.gw = manual_ip->gateway;
697 info.netmask = manual_ip->subnet;
704 err = esp_netif_dhcps_stop(s_ap_netif);
705 if (err != ESP_OK && err != ESP_ERR_ESP_NETIF_DHCP_ALREADY_STOPPED) {
706 ESP_LOGE(TAG,
"esp_netif_dhcps_stop failed: %s", esp_err_to_name(err));
710 err = esp_netif_set_ip_info(s_ap_netif, &info);
712 ESP_LOGE(TAG,
"esp_netif_set_ip_info failed! %d", err);
720 lease.start_ip = start_address;
721 ESP_LOGV(TAG,
"DHCP server IP lease start: %s", start_address.
str().c_str());
723 lease.end_ip = start_address;
724 ESP_LOGV(TAG,
"DHCP server IP lease end: %s", start_address.str().c_str());
725 err = esp_netif_dhcps_option(s_ap_netif, ESP_NETIF_OP_SET, ESP_NETIF_REQUESTED_IP_ADDRESS, &lease,
sizeof(lease));
728 ESP_LOGE(TAG,
"esp_netif_dhcps_option failed! %d", err);
732 err = esp_netif_dhcps_start(s_ap_netif);
735 ESP_LOGE(TAG,
"esp_netif_dhcps_start failed! %d", err);
748 memset(&conf, 0,
sizeof(conf));
749 snprintf(reinterpret_cast<char *>(conf.ap.ssid),
sizeof(conf.ap.ssid),
"%s", ap.
get_ssid().c_str());
751 conf.ap.ssid_hidden = ap.
get_ssid().size();
752 conf.ap.max_connection = 5;
753 conf.ap.beacon_interval = 100;
756 conf.ap.authmode = WIFI_AUTH_OPEN;
757 *conf.ap.password = 0;
759 conf.ap.authmode = WIFI_AUTH_WPA2_PSK;
760 snprintf(reinterpret_cast<char *>(conf.ap.password),
sizeof(conf.ap.password),
"%s", ap.
get_password().c_str());
764 conf.ap.pairwise_cipher = WIFI_CIPHER_TYPE_CCMP;
766 esp_err_t err = esp_wifi_set_config(WIFI_IF_AP, &conf);
768 ESP_LOGV(TAG,
"esp_wifi_set_config failed! %d", err);
775 ESP_LOGV(TAG,
"wifi_ap_ip_config_ failed!");
783 esp_netif_ip_info_t ip;
784 esp_netif_get_ip_info(s_ap_netif, &ip);
787 #endif // USE_WIFI_AP 793 uint8_t *raw_bssid = WiFi.BSSID();
794 if (raw_bssid !=
nullptr) {
795 for (
size_t i = 0; i < bssid.size(); i++)
796 bssid[i] = raw_bssid[i];
810 #endif // USE_ESP32_FRAMEWORK_ARDUINO
WiFiSTAConnectStatus wifi_sta_connect_status_()
std::array< uint8_t, 6 > bssid_t
bool has_custom_mac_address()
Check if a custom MAC address is set (ESP32 & variants)
const optional< EAPAuth > & get_eap() const
static std::string format_mac_addr(const uint8_t mac[6])
const std::string & get_password() const
WiFiPowerSaveMode power_save_
network::IPAddress wifi_dns_ip_(int num)
network::IPAddresses wifi_sta_ip_addresses()
bool wifi_mode_(optional< bool > sta, optional< bool > ap)
const optional< bssid_t > & get_bssid() const
void set_timeout(const std::string &name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a unique name.
bool wifi_apply_output_power_(float output_power)
esp_ip4_addr_t esphome_ip4_addr_t
bool wifi_sta_ip_config_(optional< ManualIP > manual_ip)
network::IPAddress wifi_subnet_mask_()
void set_ap(const WiFiAP &ap)
Setup an Access Point that should be created if no connection to a station can be made...
bool wifi_apply_hostname_()
bool error_from_callback_
const char * get_op_mode_str(uint8_t mode)
std::vector< WiFiScanResult > scan_result_
bool wifi_start_ap_(const WiFiAP &ap)
const optional< ManualIP > & get_manual_ip() const
const optional< uint8_t > & get_channel() const
arduino_event_id_t esphome_wifi_event_id_t
BedjetMode mode
BedJet operating mode.
bool wifi_apply_power_save_()
Application App
Global storage of Application pointer - only one Application can exist.
bool wifi_ap_ip_config_(optional< ManualIP > manual_ip)
void set_mac_address(uint8_t *mac)
Set the MAC address to use from the provided byte array (6 bytes).
const std::string & get_name() const
Get the name of this Application set by pre_setup().
std::array< IPAddress, 5 > IPAddresses
network::IPAddress wifi_soft_ap_ip()
void wifi_event_callback_(arduino_event_id_t event, arduino_event_info_t info)
arduino_event_info_t esphome_wifi_event_info_t
bool wifi_sta_pre_setup_()
const char * get_auth_mode_str(uint8_t mode)
void IRAM_ATTR HOT yield()
network::IPAddress wifi_gateway_ip_()
bool wifi_scan_start_(bool passive)
uint8_t num_ipv6_addresses_
void set_sta(const WiFiAP &ap)
Implementation of SPI Controller mode.
std::string format_ip4_addr(const esphome_ip4_addr_t &ip)
const std::string & get_ssid() const
const char * get_disconnect_reason_str(uint8_t reason)
void wifi_scan_done_callback_()
value_type value_or(U const &v) const
bool wifi_sta_connect_(const WiFiAP &ap)
void IRAM_ATTR HOT delay(uint32_t ms)
void get_mac_address_raw(uint8_t *mac)
Get the device MAC address as raw bytes, written into the provided byte array (6 bytes).