diff --git a/src/wifi.cpp b/src/wifi.cpp index db7900b..ebfe861 100644 --- a/src/wifi.cpp +++ b/src/wifi.cpp @@ -13,6 +13,7 @@ // ToDo: check if https://github.com/me-no-dev/ESPAsyncWebServer/ becomes available #include "hardware.h" +#include "sound.h" #include "wifi.h" @@ -93,17 +94,42 @@ void Wifi::loop() { client.flush(); String s; - if (req == "/") - { + if (req == "/") { IPAddress ip = WiFi.localIP(); String ipStr = String(ip[0]) + '.' + String(ip[1]) + '.' + String(ip[2]) + '.' + String(ip[3]); - s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n\r\nHello from ESP32 at "; - s += ipStr; - s += "\r\n\r\n"; + s = "HTTP/1.1 200 OK\r\n" + "Content-Type: text/html\r\n" + "\r\n" + "\r\n" + "\r\n"; + s += "

Hello from ESP32 at " + ipStr + "

\r\n"; + s += "

" + "" + "

" + "

" + "" + "

" + "

" + "" + "

" + "\r\n" + "\r\n"; Serial.println("Sending 200"); - } - else - { + } else if (req == "/test") { + Serial.println("/test"); + s = "HTTP/1.1 200 OK\r\n\r\n"; + } else if (req.startsWith("/sound/")) { + Serial.print("/sound/"); + int n = req.substring(7).toInt(); + Serial.println(n); + if (0<=n<=9) { + Sound* sound = Sound::getInstance(); + char filename[25]; + sprintf(filename, "/T%d.wav", n); + if (sound != NULL) sound->play(filename); + } + s = "HTTP/1.1 200 OK\r\n\r\n"; + } else { s = "HTTP/1.1 404 Not Found\r\n\r\n"; Serial.println("Sending 404"); }