|
|
@ -6,9 +6,12 @@ |
|
|
|
#include "Arduino.h" |
|
|
|
|
|
|
|
#include <WiFi.h> |
|
|
|
#include <WiFiMulti.h> |
|
|
|
#include <ESPmDNS.h> |
|
|
|
#include <WiFiClient.h> |
|
|
|
|
|
|
|
// 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); |
|
|
|
|
|
|
|
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
|
|
|
|
while (WiFi.status() != WL_CONNECTED) { |
|
|
|
/* // 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"); |
|
|
|
} |
|
|
|
|
|
|
|
// Start TCP (HTTP) server
|
|
|
|
server.begin(); |
|
|
|