Various fixes for ESP32 (#14102)
This commit is contained in:
committed by
Scott Lahteine
parent
e1bf34bdc9
commit
bc5a1fe562
@@ -22,6 +22,7 @@
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
|
||||
#include "../../core/serial.h"
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if ENABLED(WIFISUPPORT)
|
||||
@@ -38,20 +39,28 @@ AsyncWebServer server(80);
|
||||
#endif
|
||||
|
||||
void wifi_init() {
|
||||
|
||||
SERIAL_ECHO_MSG("Starting WiFi...");
|
||||
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.begin(WIFI_SSID, WIFI_PWD);
|
||||
|
||||
while (WiFi.waitForConnectResult() != WL_CONNECTED) {
|
||||
SERIAL_ERROR_MSG("Unable to connect to WiFi with SSID '" WIFI_SSID "', restarting.");
|
||||
delay(5000);
|
||||
ESP.restart();
|
||||
}
|
||||
|
||||
delay(10);
|
||||
|
||||
// Loop forever (watchdog kill) on failure
|
||||
if (!MDNS.begin(WIFI_HOSTNAME)) for(;;) delay(5000);
|
||||
if (!MDNS.begin(WIFI_HOSTNAME)) {
|
||||
SERIAL_ERROR_MSG("Unable to start mDNS with hostname '" WIFI_HOSTNAME "', restarting.");
|
||||
delay(5000);
|
||||
ESP.restart();
|
||||
}
|
||||
|
||||
MDNS.addService("http", "tcp", 80);
|
||||
|
||||
SERIAL_ECHOLNPAIR("Successfully connected to WiFi with SSID '" WIFI_SSID "', hostname: '" WIFI_HOSTNAME "', IP address: ", WiFi.localIP().toString().c_str());
|
||||
}
|
||||
|
||||
#endif // WIFISUPPORT
|
||||
|
||||
Reference in New Issue
Block a user