forked from fmueller/esp8266-led-marquee-sign-controller
Add HTTP API endpoint for raw messages
RESTful version of simple socket listener.
This commit is contained in:
parent
4a82fdc7f5
commit
1d23e6cfef
@ -66,6 +66,21 @@ namespace {
|
|||||||
sendTextToSign(text);
|
sendTextToSign(text);
|
||||||
webServer.send(200, "text/plain", "ok");
|
webServer.send(200, "text/plain", "ok");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RESTful API endpoint -- returns a proper status code rather than a redirect
|
||||||
|
void handleRawApiSend() {
|
||||||
|
String toSend = webServer.arg("plain");
|
||||||
|
|
||||||
|
if (toSend.isEmpty()) {
|
||||||
|
webServer.send(404, "text/plain", "empty body");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Serial.println("Raw message sent to device: " + toSend);
|
||||||
|
Serial.println("Hex dump: " + hexDump(toSend));
|
||||||
|
Serial1.print(toSend);
|
||||||
|
webServer.send(200, "text/plain", "ok");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void configureWebServer() {
|
void configureWebServer() {
|
||||||
@ -74,4 +89,5 @@ void configureWebServer() {
|
|||||||
webServer.on("/", HTTPMethod::HTTP_GET, handleIndex);
|
webServer.on("/", HTTPMethod::HTTP_GET, handleIndex);
|
||||||
webServer.on("/", HTTPMethod::HTTP_POST, handleFormSend);
|
webServer.on("/", HTTPMethod::HTTP_POST, handleFormSend);
|
||||||
webServer.on("/send", HTTPMethod::HTTP_POST, handleApiSend);
|
webServer.on("/send", HTTPMethod::HTTP_POST, handleApiSend);
|
||||||
|
webServer.on("/raw", HTTPMethod::HTTP_POST, handleRawApiSend);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user