diff --git a/platformio.ini b/platformio.ini index 0d56c5b..11dd0a0 100644 --- a/platformio.ini +++ b/platformio.ini @@ -13,5 +13,5 @@ platform = espressif32_stage board = esp32thing framework = arduino ;lib_deps = +; ESPAsyncWebServer ; FS -; SD_MMC diff --git a/src/wifi.cpp b/src/wifi.cpp index 270b18e..db7900b 100644 --- a/src/wifi.cpp +++ b/src/wifi.cpp @@ -6,9 +6,12 @@ #include "Arduino.h" #include +#include #include #include +// ToDo: check if https://github.com/me-no-dev/ESPAsyncWebServer/ becomes available + #include "hardware.h" #include "wifi.h" @@ -20,18 +23,24 @@ Wifi::Wifi() { } void Wifi::init() { - WiFi.begin(WIFI_SSID, WIFI_PASSWORD); + WiFiMulti wifiMulti; + + wifiMulti.addAP(WIFI_SSID, WIFI_PASSWORD); - // Wait for connection - while (WiFi.status() != WL_CONNECTED) { + Serial.println("Connecting Wifi"); + if(wifiMulti.run() == WL_CONNECTED) { + Serial.println(""); + Serial.println("WiFi connected"); + Serial.println("IP address: "); + Serial.println(WiFi.localIP()); + } + +/* // Wait for connection + for (int i=0; i<20 && WiFi.status() != WL_CONNECTED; i++) { delay(500); Serial.print("."); } - Serial.println(""); - Serial.print("Connected to "); - Serial.println(WIFI_SSID); - Serial.print("IP address: "); - Serial.println(WiFi.localIP()); +*/ // Set up mDNS responder: // - first argument is the domain name, in this example @@ -40,11 +49,9 @@ void Wifi::init() { // we send our IP address on the WiFi network if (!MDNS.begin("soundboard")) { Serial.println("Error setting up MDNS responder!"); - while(1) { - delay(1000); - } + } else { + Serial.println("mDNS responder started"); } - Serial.println("mDNS responder started"); // Start TCP (HTTP) server server.begin();