webhook for D1 doorbell
This commit is contained in:
@@ -58,7 +58,7 @@ void setup()
|
|||||||
|
|
||||||
server.begin();
|
server.begin();
|
||||||
delay(500);
|
delay(500);
|
||||||
dfPlayer.play(2); // Play the first mp3
|
dfPlayer.play(2); // Play the second mp3
|
||||||
|
|
||||||
Serial.println("Setup completed");
|
Serial.println("Setup completed");
|
||||||
}
|
}
|
||||||
@@ -91,7 +91,22 @@ void loop() {
|
|||||||
dfPlayer.play(1); // play the first mp3
|
dfPlayer.play(1); // play the first mp3
|
||||||
Serial.println("RING");
|
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;
|
String str1 = header;
|
||||||
str1 = str1.substring(header.indexOf("GET /setvolume/") + 15);
|
str1 = str1.substring(header.indexOf("GET /setvolume/") + 15);
|
||||||
volume = str1.substring(0, str1.indexOf(" ")).toInt();
|
volume = str1.substring(0, str1.indexOf(" ")).toInt();
|
||||||
@@ -104,7 +119,7 @@ void loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dfPlayer.volume(volume);
|
dfPlayer.volume(volume);
|
||||||
Serial.print("volume set to ");
|
Serial.print("Volume set to ");
|
||||||
Serial.println(volume);
|
Serial.println(volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user