From 7f6f8910b838ae39d535e74352823e5c9db400da Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Thu, 7 Feb 2019 17:52:50 +0100 Subject: [PATCH 1/2] ESP8266 Arduino 2.5.0 Compatability --- src/esphomelib/ethernet_component.cpp | 2 ++ src/esphomelib/util.cpp | 3 +++ src/esphomelib/util.h | 1 + src/esphomelib/wifi_component.cpp | 12 ++++++++++++ 4 files changed, 18 insertions(+) diff --git a/src/esphomelib/ethernet_component.cpp b/src/esphomelib/ethernet_component.cpp index d02ded7e..54ba05cf 100644 --- a/src/esphomelib/ethernet_component.cpp +++ b/src/esphomelib/ethernet_component.cpp @@ -62,6 +62,8 @@ void EthernetComponent::loop() { } this->last_connected_ = this->connected_; + + network_tick_mdns(); } void EthernetComponent::dump_config() { ESP_LOGCONFIG(TAG, "Ethernet:"); diff --git a/src/esphomelib/util.cpp b/src/esphomelib/util.cpp index eb070eea..079b089c 100644 --- a/src/esphomelib/util.cpp +++ b/src/esphomelib/util.cpp @@ -92,6 +92,9 @@ void network_setup_mdns(const std::string &hostname) { } #endif } +void network_tick_mdns() { + MDNS.update(); +} IPAddress network_get_address() { #ifdef USE_ETHERNET diff --git a/src/esphomelib/util.h b/src/esphomelib/util.h index fae6387b..8a37b043 100644 --- a/src/esphomelib/util.h +++ b/src/esphomelib/util.h @@ -17,6 +17,7 @@ IPAddress network_get_address(); void network_setup(); void network_tick(); void network_setup_mdns(const std::string &hostname); +void network_tick_mdns(); ESPHOMELIB_NAMESPACE_END diff --git a/src/esphomelib/wifi_component.cpp b/src/esphomelib/wifi_component.cpp index 3e4071cf..9f91dde5 100644 --- a/src/esphomelib/wifi_component.cpp +++ b/src/esphomelib/wifi_component.cpp @@ -106,6 +106,8 @@ void WiFiComponent::loop() { } } } + + network_tick_mdns(); } WiFiComponent::WiFiComponent() { @@ -468,6 +470,9 @@ bool WiFiComponent::wifi_mode_(optional sta, optional ap) { ESP_LOGV(TAG, "Enabling STA."); } else if (!sta_ && current_sta) { ESP_LOGV(TAG, "Disabling STA."); + // Stop DHCP client when disabling STA + // See https://github.com/esp8266/Arduino/pull/5703 + wifi_station_dhcpc_stop(); } if (ap_ && !current_ap) { ESP_LOGV(TAG, "Enabling AP."); @@ -608,6 +613,13 @@ bool WiFiComponent::wifi_sta_connect_(WiFiAP ap) { conf.bssid_set = 0; } + if (ap.get_ssid().empty()) { + conf.threshold.authmode = AUTH_OPEN; + } else { + conf.threshold.authmode = AUTH_WPA_PSK; + } + conf.threshold.rssi = -127; + ETS_UART_INTR_DISABLE(); bool ret = wifi_station_set_config_current(&conf); ETS_UART_INTR_ENABLE(); From 126102f2e8d14547e5bfdff6baa174f8685c7b12 Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Sun, 10 Feb 2019 16:18:06 +0100 Subject: [PATCH 2/2] Fix --- src/esphomelib/util.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/esphomelib/util.cpp b/src/esphomelib/util.cpp index 079b089c..55c6ec92 100644 --- a/src/esphomelib/util.cpp +++ b/src/esphomelib/util.cpp @@ -93,7 +93,9 @@ void network_setup_mdns(const std::string &hostname) { #endif } void network_tick_mdns() { +#ifdef ARDUINO_ARCH_ESP8266 MDNS.update(); +#endif } IPAddress network_get_address() {