mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-30 19:29:17 +00:00
use POST URL parameters; fix response status
This commit is contained in:
parent
2f779bfd37
commit
2743b9d310
@ -978,26 +978,14 @@ void handleBlinkLED(HTTPRequest *req, HTTPResponse *res)
|
|||||||
{
|
{
|
||||||
res->setHeader("Content-Type", "application/json");
|
res->setHeader("Content-Type", "application/json");
|
||||||
|
|
||||||
// This can be cleaned up at some point to make it non-blocking and to allow for more configuration.
|
ResourceParameters *params = req->getParams();
|
||||||
std::string contentType = req->getHeader("Content-Type");
|
|
||||||
std::string blink_target;
|
std::string blink_target;
|
||||||
HTTPBodyParser *parser;
|
HTTPBodyParser *parser;
|
||||||
|
|
||||||
|
|
||||||
if (contentType.rfind("multipart/form-data",0) == 0) {
|
if (! params->getQueryParameter("blink_target", blink_target)) {
|
||||||
// If a body was submitted to /blink, then figure out whether the user
|
// if no blink_target was supplied in the URL parameters of the
|
||||||
// watned to blink the LED or the screen
|
// POST request, then assume we should blink the LED
|
||||||
parser = new HTTPMultipartBodyParser(req);
|
|
||||||
while (parser->nextField()) {
|
|
||||||
std::string name = parser->getFieldName();
|
|
||||||
if (name == "blink_target") {
|
|
||||||
char buf[512];
|
|
||||||
size_t readLength = parser->read((byte *)buf, 512);
|
|
||||||
// filename = std::string("/public/") + std::string(buf, readLength);
|
|
||||||
blink_target = std::string(buf, readLength);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
blink_target = "LED";
|
blink_target = "LED";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1017,7 +1005,7 @@ void handleBlinkLED(HTTPRequest *req, HTTPResponse *res)
|
|||||||
}
|
}
|
||||||
|
|
||||||
res->println("{");
|
res->println("{");
|
||||||
res->println("\"status\": \"Blink completed: LED\"");
|
res->println("\"status\": \"ok\"");
|
||||||
res->println("}");
|
res->println("}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user