ESP8266 WebServer server.on() undefined arguments
Posted: Mon Oct 25, 2021 7:04 am
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.
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.
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.
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.