diff --git a/doorbell/wifi-klingel-wemos/wifi-klingel-wemos.ino b/doorbell/wifi-klingel-wemos/wifi-klingel-wemos.ino index d2eeb19..f91040c 100644 --- a/doorbell/wifi-klingel-wemos/wifi-klingel-wemos.ino +++ b/doorbell/wifi-klingel-wemos/wifi-klingel-wemos.ino @@ -58,7 +58,7 @@ void setup() server.begin(); delay(500); - dfPlayer.play(2); // Play the first mp3 + dfPlayer.play(2); // Play the second mp3 Serial.println("Setup completed"); } @@ -91,7 +91,22 @@ void loop() { dfPlayer.play(1); // play the first mp3 Serial.println("RING"); } - else if (header.indexOf("GET /setvolume/") >= 0) { // yes, I know this is not RESTful + else if (header.indexOf("GET /play/") >= 0) { // yes, I know this is not RESTful + String str1 = header; + str1 = str1.substring(header.indexOf("GET /play/") + 10); + int fileNo = str1.substring(0, str1.indexOf(" ")).toInt(); + + Serial.print("Play file "); + Serial.println(fileNo); + + if (fileNo <= 1) { + dfPlayer.play(1); + } + else { + dfPlayer.play(fileNo); + } + } + else if (header.indexOf("GET /setvolume/") >= 0) { String str1 = header; str1 = str1.substring(header.indexOf("GET /setvolume/") + 15); volume = str1.substring(0, str1.indexOf(" ")).toInt(); @@ -104,7 +119,7 @@ void loop() { } dfPlayer.volume(volume); - Serial.print("volume set to "); + Serial.print("Volume set to "); Serial.println(volume); }