Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By Ervins
#92714 Hello!

I am building a mobile app (MIT app inventor) for my esp8266 project and now I am working on timer function.
User sets wanted delay for the timer on the app, app converts it to seconds and sends it to esp8266 like so.

Image

I am wondering, is it possible for esp8266, using server.on("/StartTimer/...", startTimer); to read "/StartTimer/" part, run the function, and then figure out, what values were sent after "/StartTimer/".

I know server.onNotFound(); could be used to read any url, but I am kinda already using it to get color codes like so...

void setColor() {
String RGBColors = server.uri();
String RGBColorR = RGBColors.substring(RGBColors.indexOf("R"), RGBColors.indexOf("G"));
RGBColorR.remove(0,1);
RGBColorRed = RGBColorR.toInt();
String RGBColorG = RGBColors.substring(RGBColors.indexOf("G"), RGBColors.indexOf("B"));
RGBColorG.remove(0,1);
RGBColorGreen = RGBColorG.toInt();
String RGBColorB = RGBColors.substring(RGBColors.indexOf("B"));
RGBColorB.remove(0,1);
RGBColorBlue = RGBColorB.toInt();
analogWrite(RGBLedR, resolution - RGBColorRed);
analogWrite(RGBLedG, resolution - RGBColorGreen);
analogWrite(RGBLedB, resolution - RGBColorBlue);
displayMode = 0;
}

I have a feeling that this is not the best way, but I can't find info on this topic.
User avatar
By Ervins
#92731 Thanks JurajA!

Did some research and got some basic knowledge of arguments.

server.on("/StartTimer", [](){
if(server.hasArg("Time")){
String recTime = server.arg("Time");
timerTime = recTime.toInt();
Serial.println(timerTime);
}
startTimer();
});

Works like a charm, thanks again!