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 if (ap.
get_ssid().size() >
sizeof(conf.sta.ssid)) {
141 ESP_LOGE(TAG,
"SSID is too long");
144 if (ap.
get_password().size() >
sizeof(conf.sta.password)) {
145 ESP_LOGE(TAG,
"password is too long");
148 memcpy(reinterpret_cast<char *>(conf.sta.ssid), ap.
get_ssid().c_str(), ap.
get_ssid().size());
153 conf.sta.threshold.authmode = WIFI_AUTH_OPEN;
155 conf.sta.threshold.authmode = WIFI_AUTH_WPA_WPA2_PSK;
158 #ifdef USE_WIFI_WPA2_EAP 159 if (ap.
get_eap().has_value()) {
160 conf.sta.threshold.authmode = WIFI_AUTH_WPA2_ENTERPRISE;
165 conf.sta.bssid_set =
true;
166 memcpy(conf.sta.bssid, ap.
get_bssid()->data(), 6);
168 conf.sta.bssid_set =
false;
172 conf.sta.scan_method = WIFI_FAST_SCAN;
174 conf.sta.scan_method = WIFI_ALL_CHANNEL_SCAN;
178 conf.sta.listen_interval = 0;
182 conf.sta.pmf_cfg.capable =
true;
183 conf.sta.pmf_cfg.required =
false;
187 conf.sta.threshold.rssi = -127;
189 conf.sta.threshold.authmode = WIFI_AUTH_OPEN;
191 wifi_config_t current_conf;
193 err = esp_wifi_get_config(WIFI_IF_STA, ¤t_conf);
195 ESP_LOGW(TAG,
"esp_wifi_get_config failed: %s", esp_err_to_name(err));
199 if (memcmp(¤t_conf, &conf,
sizeof(wifi_config_t)) != 0) {
200 err = esp_wifi_disconnect();
202 ESP_LOGV(TAG,
"esp_wifi_disconnect failed: %s", esp_err_to_name(err));
207 err = esp_wifi_set_config(WIFI_IF_STA, &conf);
209 ESP_LOGV(TAG,
"esp_wifi_set_config failed: %s", esp_err_to_name(err));
218 #ifdef USE_WIFI_WPA2_EAP 219 if (ap.
get_eap().has_value()) {
222 err = esp_wifi_sta_wpa2_ent_set_identity((uint8_t *) eap.
identity.c_str(), eap.
identity.length());
224 ESP_LOGV(TAG,
"esp_wifi_sta_wpa2_ent_set_identity failed! %d", err);
226 int ca_cert_len = strlen(eap.
ca_cert);
230 err = esp_wifi_sta_wpa2_ent_set_ca_cert((uint8_t *) eap.
ca_cert, ca_cert_len + 1);
232 ESP_LOGV(TAG,
"esp_wifi_sta_wpa2_ent_set_ca_cert failed! %d", err);
237 if (client_cert_len && client_key_len) {
239 err = esp_wifi_sta_wpa2_ent_set_cert_key((uint8_t *) eap.
client_cert, client_cert_len + 1,
240 (uint8_t *) eap.
client_key, client_key_len + 1,
243 ESP_LOGV(TAG,
"esp_wifi_sta_wpa2_ent_set_cert_key failed! %d", err);
247 err = esp_wifi_sta_wpa2_ent_set_username((uint8_t *) eap.
username.c_str(), eap.
username.length());
249 ESP_LOGV(TAG,
"esp_wifi_sta_wpa2_ent_set_username failed! %d", err);
251 err = esp_wifi_sta_wpa2_ent_set_password((uint8_t *) eap.
password.c_str(), eap.
password.length());
253 ESP_LOGV(TAG,
"esp_wifi_sta_wpa2_ent_set_password failed! %d", err);
256 err = esp_wifi_sta_wpa2_ent_enable();
258 ESP_LOGV(TAG,
"esp_wifi_sta_wpa2_ent_enable failed! %d", err);
261 #endif // USE_WIFI_WPA2_EAP 265 s_sta_connecting =
true;
267 err = esp_wifi_connect();
269 ESP_LOGW(TAG,
"esp_wifi_connect failed: %s", esp_err_to_name(err));
281 esp_netif_dhcp_status_t dhcp_status;
282 esp_err_t err = esp_netif_dhcpc_get_status(s_sta_netif, &dhcp_status);
284 ESP_LOGV(TAG,
"esp_netif_dhcpc_get_status failed: %s", esp_err_to_name(err));
292 sntp_servermode_dhcp(
false);
295 if (dhcp_status != ESP_NETIF_DHCP_STARTED) {
296 err = esp_netif_dhcpc_start(s_sta_netif);
298 ESP_LOGV(TAG,
"Starting DHCP client failed! %d", err);
300 return err == ESP_OK;
305 esp_netif_ip_info_t info;
306 info.ip = manual_ip->static_ip;
307 info.gw = manual_ip->gateway;
308 info.netmask = manual_ip->subnet;
309 err = esp_netif_dhcpc_stop(s_sta_netif);
310 if (err != ESP_OK && err != ESP_ERR_ESP_NETIF_DHCP_ALREADY_STOPPED) {
311 ESP_LOGV(TAG,
"Stopping DHCP client failed! %s", esp_err_to_name(err));
314 err = esp_netif_set_ip_info(s_sta_netif, &info);
316 ESP_LOGV(TAG,
"Setting manual IP info failed! %s", esp_err_to_name(err));
319 esp_netif_dns_info_t dns;
320 if (manual_ip->dns1.is_set()) {
321 dns.ip = manual_ip->dns1;
322 esp_netif_set_dns_info(s_sta_netif, ESP_NETIF_DNS_MAIN, &dns);
324 if (manual_ip->dns2.is_set()) {
325 dns.ip = manual_ip->dns2;
326 esp_netif_set_dns_info(s_sta_netif, ESP_NETIF_DNS_BACKUP, &dns);
336 esp_netif_ip_info_t ip;
337 esp_err_t err = esp_netif_get_ip_info(s_sta_netif, &ip);
339 ESP_LOGV(TAG,
"esp_netif_get_ip_info failed: %s", esp_err_to_name(err));
346 struct esp_ip6_addr if_ip6s[CONFIG_LWIP_IPV6_NUM_ADDRESSES];
348 count = esp_netif_get_all_ip6(s_sta_netif, if_ip6s);
349 assert(count <= CONFIG_LWIP_IPV6_NUM_ADDRESSES);
350 for (
int i = 0; i < count; i++) {
367 case WIFI_AUTH_WPA_PSK:
369 case WIFI_AUTH_WPA2_PSK:
371 case WIFI_AUTH_WPA_WPA2_PSK:
372 return "WPA/WPA2 PSK";
373 case WIFI_AUTH_WPA2_ENTERPRISE:
374 return "WPA2 Enterprise";
375 case WIFI_AUTH_WPA3_PSK:
377 case WIFI_AUTH_WPA2_WPA3_PSK:
378 return "WPA2/WPA3 PSK";
379 case WIFI_AUTH_WAPI_PSK:
390 sprintf(buf,
"%u.%u.%u.%u", uint8_t(ip.addr >> 0), uint8_t(ip.addr >> 8), uint8_t(ip.addr >> 16),
391 uint8_t(ip.addr >> 24));
410 case WIFI_REASON_AUTH_EXPIRE:
411 return "Auth Expired";
412 case WIFI_REASON_AUTH_LEAVE:
414 case WIFI_REASON_ASSOC_EXPIRE:
415 return "Association Expired";
416 case WIFI_REASON_ASSOC_TOOMANY:
417 return "Too Many Associations";
418 case WIFI_REASON_NOT_AUTHED:
419 return "Not Authenticated";
420 case WIFI_REASON_NOT_ASSOCED:
421 return "Not Associated";
422 case WIFI_REASON_ASSOC_LEAVE:
423 return "Association Leave";
424 case WIFI_REASON_ASSOC_NOT_AUTHED:
425 return "Association not Authenticated";
426 case WIFI_REASON_DISASSOC_PWRCAP_BAD:
427 return "Disassociate Power Cap Bad";
428 case WIFI_REASON_DISASSOC_SUPCHAN_BAD:
429 return "Disassociate Supported Channel Bad";
430 case WIFI_REASON_IE_INVALID:
432 case WIFI_REASON_MIC_FAILURE:
433 return "Mic Failure";
434 case WIFI_REASON_4WAY_HANDSHAKE_TIMEOUT:
435 return "4-Way Handshake Timeout";
436 case WIFI_REASON_GROUP_KEY_UPDATE_TIMEOUT:
437 return "Group Key Update Timeout";
438 case WIFI_REASON_IE_IN_4WAY_DIFFERS:
439 return "IE In 4-Way Handshake Differs";
440 case WIFI_REASON_GROUP_CIPHER_INVALID:
441 return "Group Cipher Invalid";
442 case WIFI_REASON_PAIRWISE_CIPHER_INVALID:
443 return "Pairwise Cipher Invalid";
444 case WIFI_REASON_AKMP_INVALID:
445 return "AKMP Invalid";
446 case WIFI_REASON_UNSUPP_RSN_IE_VERSION:
447 return "Unsupported RSN IE version";
448 case WIFI_REASON_INVALID_RSN_IE_CAP:
449 return "Invalid RSN IE Cap";
450 case WIFI_REASON_802_1X_AUTH_FAILED:
451 return "802.1x Authentication Failed";
452 case WIFI_REASON_CIPHER_SUITE_REJECTED:
453 return "Cipher Suite Rejected";
454 case WIFI_REASON_BEACON_TIMEOUT:
455 return "Beacon Timeout";
456 case WIFI_REASON_NO_AP_FOUND:
457 return "AP Not Found";
458 case WIFI_REASON_AUTH_FAIL:
459 return "Authentication Failed";
460 case WIFI_REASON_ASSOC_FAIL:
461 return "Association Failed";
462 case WIFI_REASON_HANDSHAKE_TIMEOUT:
463 return "Handshake Failed";
464 case WIFI_REASON_CONNECTION_FAIL:
465 return "Connection Failed";
466 case WIFI_REASON_ROAMING:
467 return "Station Roaming";
468 case WIFI_REASON_UNSPECIFIED:
470 return "Unspecified";
476 #define ESPHOME_EVENT_ID_WIFI_READY ARDUINO_EVENT_WIFI_READY 477 #define ESPHOME_EVENT_ID_WIFI_SCAN_DONE ARDUINO_EVENT_WIFI_SCAN_DONE 478 #define ESPHOME_EVENT_ID_WIFI_STA_START ARDUINO_EVENT_WIFI_STA_START 479 #define ESPHOME_EVENT_ID_WIFI_STA_STOP ARDUINO_EVENT_WIFI_STA_STOP 480 #define ESPHOME_EVENT_ID_WIFI_STA_CONNECTED ARDUINO_EVENT_WIFI_STA_CONNECTED 481 #define ESPHOME_EVENT_ID_WIFI_STA_DISCONNECTED ARDUINO_EVENT_WIFI_STA_DISCONNECTED 482 #define ESPHOME_EVENT_ID_WIFI_STA_AUTHMODE_CHANGE ARDUINO_EVENT_WIFI_STA_AUTHMODE_CHANGE 483 #define ESPHOME_EVENT_ID_WIFI_STA_GOT_IP ARDUINO_EVENT_WIFI_STA_GOT_IP 484 #define ESPHOME_EVENT_ID_WIFI_STA_GOT_IP6 ARDUINO_EVENT_WIFI_STA_GOT_IP6 485 #define ESPHOME_EVENT_ID_WIFI_STA_LOST_IP ARDUINO_EVENT_WIFI_STA_LOST_IP 486 #define ESPHOME_EVENT_ID_WIFI_AP_START ARDUINO_EVENT_WIFI_AP_START 487 #define ESPHOME_EVENT_ID_WIFI_AP_STOP ARDUINO_EVENT_WIFI_AP_STOP 488 #define ESPHOME_EVENT_ID_WIFI_AP_STACONNECTED ARDUINO_EVENT_WIFI_AP_STACONNECTED 489 #define ESPHOME_EVENT_ID_WIFI_AP_STADISCONNECTED ARDUINO_EVENT_WIFI_AP_STADISCONNECTED 490 #define ESPHOME_EVENT_ID_WIFI_AP_STAIPASSIGNED ARDUINO_EVENT_WIFI_AP_STAIPASSIGNED 491 #define ESPHOME_EVENT_ID_WIFI_AP_PROBEREQRECVED ARDUINO_EVENT_WIFI_AP_PROBEREQRECVED 492 #define ESPHOME_EVENT_ID_WIFI_AP_GOT_IP6 ARDUINO_EVENT_WIFI_AP_GOT_IP6 498 case ESPHOME_EVENT_ID_WIFI_READY: {
499 ESP_LOGV(TAG,
"Event: WiFi ready");
502 case ESPHOME_EVENT_ID_WIFI_SCAN_DONE: {
503 auto it = info.wifi_scan_done;
504 ESP_LOGV(TAG,
"Event: WiFi Scan Done status=%u number=%u scan_id=%u", it.status, it.number, it.scan_id);
509 case ESPHOME_EVENT_ID_WIFI_STA_START: {
510 ESP_LOGV(TAG,
"Event: WiFi STA start");
512 s_sta_netif = esp_netif_get_handle_from_ifkey(
"WIFI_STA_DEF");
513 esp_err_t err = esp_netif_set_hostname(s_sta_netif,
App.
get_name().c_str());
515 ESP_LOGW(TAG,
"esp_netif_set_hostname failed: %s", esp_err_to_name(err));
519 case ESPHOME_EVENT_ID_WIFI_STA_STOP: {
520 ESP_LOGV(TAG,
"Event: WiFi STA stop");
523 case ESPHOME_EVENT_ID_WIFI_STA_CONNECTED: {
524 auto it = info.wifi_sta_connected;
526 memcpy(buf, it.ssid, it.ssid_len);
527 buf[it.ssid_len] =
'\0';
528 ESP_LOGV(TAG,
"Event: Connected ssid='%s' bssid=" LOG_SECRET(
"%s")
" channel=%u, authmode=%s", buf,
536 case ESPHOME_EVENT_ID_WIFI_STA_DISCONNECTED: {
537 auto it = info.wifi_sta_disconnected;
539 memcpy(buf, it.ssid, it.ssid_len);
540 buf[it.ssid_len] =
'\0';
541 if (it.reason == WIFI_REASON_NO_AP_FOUND) {
542 ESP_LOGW(TAG,
"Event: Disconnected ssid='%s' reason='Probe Request Unsuccessful'", buf);
544 ESP_LOGW(TAG,
"Event: Disconnected ssid='%s' bssid=" LOG_SECRET(
"%s")
" reason='%s'", buf,
548 uint8_t reason = it.reason;
549 if (reason == WIFI_REASON_AUTH_EXPIRE || reason == WIFI_REASON_BEACON_TIMEOUT ||
550 reason == WIFI_REASON_NO_AP_FOUND || reason == WIFI_REASON_ASSOC_FAIL ||
551 reason == WIFI_REASON_HANDSHAKE_TIMEOUT) {
552 err_t err = esp_wifi_disconnect();
554 ESP_LOGV(TAG,
"Disconnect failed: %s", esp_err_to_name(err));
559 s_sta_connecting =
false;
562 case ESPHOME_EVENT_ID_WIFI_STA_AUTHMODE_CHANGE: {
563 auto it = info.wifi_sta_authmode_change;
564 ESP_LOGV(TAG,
"Event: Authmode Change old=%s new=%s",
get_auth_mode_str(it.old_mode),
568 if (it.old_mode != WIFI_AUTH_OPEN && it.new_mode == WIFI_AUTH_OPEN) {
569 ESP_LOGW(TAG,
"Potential Authmode downgrade detected, disconnecting...");
572 err_t err = esp_wifi_disconnect();
574 ESP_LOGW(TAG,
"Disconnect failed: %s", esp_err_to_name(err));
580 case ESPHOME_EVENT_ID_WIFI_STA_GOT_IP: {
581 auto it = info.got_ip.ip_info;
582 ESP_LOGV(TAG,
"Event: Got IP static_ip=%s gateway=%s",
format_ip4_addr(it.ip).c_str(),
588 s_sta_connecting =
false;
593 case ESPHOME_EVENT_ID_WIFI_STA_GOT_IP6: {
594 auto it = info.got_ip6.ip6_info;
595 ESP_LOGV(TAG,
"Got IPv6 address=" IPV6STR, IPV62STR(it.ip));
601 case ESPHOME_EVENT_ID_WIFI_STA_LOST_IP: {
602 ESP_LOGV(TAG,
"Event: Lost IP");
606 case ESPHOME_EVENT_ID_WIFI_AP_START: {
607 ESP_LOGV(TAG,
"Event: WiFi AP start");
610 case ESPHOME_EVENT_ID_WIFI_AP_STOP: {
611 ESP_LOGV(TAG,
"Event: WiFi AP stop");
614 case ESPHOME_EVENT_ID_WIFI_AP_STACONNECTED: {
615 auto it = info.wifi_sta_connected;
616 auto &mac = it.bssid;
617 ESP_LOGV(TAG,
"Event: AP client connected MAC=%s",
format_mac_addr(mac).c_str());
620 case ESPHOME_EVENT_ID_WIFI_AP_STADISCONNECTED: {
621 auto it = info.wifi_sta_disconnected;
622 auto &mac = it.bssid;
623 ESP_LOGV(TAG,
"Event: AP client disconnected MAC=%s",
format_mac_addr(mac).c_str());
626 case ESPHOME_EVENT_ID_WIFI_AP_STAIPASSIGNED: {
627 ESP_LOGV(TAG,
"Event: AP client assigned IP");
630 case ESPHOME_EVENT_ID_WIFI_AP_PROBEREQRECVED: {
631 auto it = info.wifi_ap_probereqrecved;
632 ESP_LOGVV(TAG,
"Event: AP receive Probe Request MAC=%s RSSI=%d",
format_mac_addr(it.mac).c_str(), it.rssi);
642 if (
status == WL_CONNECT_FAILED ||
status == WL_CONNECTION_LOST) {
645 if (
status == WL_NO_SSID_AVAIL) {
648 if (s_sta_connecting) {
651 if (
status == WL_CONNECTED) {
662 int16_t err = WiFi.scanNetworks(
true,
true, passive, 200);
663 if (err != WIFI_SCAN_RUNNING) {
664 ESP_LOGV(TAG,
"WiFi.scanNetworks failed! %d", err);
673 int16_t num = WiFi.scanComplete();
677 this->
scan_result_.reserve(static_cast<unsigned int>(num));
678 for (
int i = 0; i < num; i++) {
679 String ssid = WiFi.SSID(i);
680 wifi_auth_mode_t authmode = WiFi.encryptionType(i);
681 int32_t rssi = WiFi.RSSI(i);
682 uint8_t *bssid = WiFi.BSSID(i);
683 int32_t channel = WiFi.channel(i);
685 WiFiScanResult scan({bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5]}, std::string(ssid.c_str()),
686 channel, rssi, authmode != WIFI_AUTH_OPEN, ssid.length() == 0);
701 esp_netif_ip_info_t info;
703 info.ip = manual_ip->static_ip;
704 info.gw = manual_ip->gateway;
705 info.netmask = manual_ip->subnet;
712 err = esp_netif_dhcps_stop(s_ap_netif);
713 if (err != ESP_OK && err != ESP_ERR_ESP_NETIF_DHCP_ALREADY_STOPPED) {
714 ESP_LOGE(TAG,
"esp_netif_dhcps_stop failed: %s", esp_err_to_name(err));
718 err = esp_netif_set_ip_info(s_ap_netif, &info);
720 ESP_LOGE(TAG,
"esp_netif_set_ip_info failed! %d", err);
728 lease.start_ip = start_address;
729 ESP_LOGV(TAG,
"DHCP server IP lease start: %s", start_address.
str().c_str());
731 lease.end_ip = start_address;
732 ESP_LOGV(TAG,
"DHCP server IP lease end: %s", start_address.str().c_str());
733 err = esp_netif_dhcps_option(s_ap_netif, ESP_NETIF_OP_SET, ESP_NETIF_REQUESTED_IP_ADDRESS, &lease,
sizeof(lease));
736 ESP_LOGE(TAG,
"esp_netif_dhcps_option failed! %d", err);
740 err = esp_netif_dhcps_start(s_ap_netif);
743 ESP_LOGE(TAG,
"esp_netif_dhcps_start failed! %d", err);
756 memset(&conf, 0,
sizeof(conf));
757 if (ap.
get_ssid().size() >
sizeof(conf.ap.ssid)) {
758 ESP_LOGE(TAG,
"AP SSID is too long");
761 memcpy(reinterpret_cast<char *>(conf.ap.ssid), ap.
get_ssid().c_str(), ap.
get_ssid().size());
763 conf.ap.ssid_hidden = ap.
get_ssid().size();
764 conf.ap.max_connection = 5;
765 conf.ap.beacon_interval = 100;
768 conf.ap.authmode = WIFI_AUTH_OPEN;
769 *conf.ap.password = 0;
771 conf.ap.authmode = WIFI_AUTH_WPA2_PSK;
772 if (ap.
get_password().size() >
sizeof(conf.ap.password)) {
773 ESP_LOGE(TAG,
"AP password is too long");
780 conf.ap.pairwise_cipher = WIFI_CIPHER_TYPE_CCMP;
782 esp_err_t err = esp_wifi_set_config(WIFI_IF_AP, &conf);
784 ESP_LOGV(TAG,
"esp_wifi_set_config failed! %d", err);
791 ESP_LOGV(TAG,
"wifi_ap_ip_config_ failed!");
799 esp_netif_ip_info_t ip;
800 esp_netif_get_ip_info(s_ap_netif, &ip);
803 #endif // USE_WIFI_AP 809 uint8_t *raw_bssid = WiFi.BSSID();
810 if (raw_bssid !=
nullptr) {
811 for (
size_t i = 0; i < bssid.size(); i++)
812 bssid[i] = raw_bssid[i];
826 #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)
int32_t get_wifi_channel()
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).