Ver código fonte

send response for all command input

Chris Mullins 8 anos atrás
pai
commit
f38c20d07e
1 arquivos alterados com 8 adições e 0 exclusões
  1. 8 0
      lib/WebServer/MiLightHttpServer.cpp

+ 8 - 0
lib/WebServer/MiLightHttpServer.cpp

@@ -61,6 +61,8 @@ void MiLightHttpServer::handleSystemPost() {
   DynamicJsonBuffer buffer;
   JsonObject& request = buffer.parse(server.arg("plain"));
   
+  bool handled = false;
+  
   if (request.containsKey("command")) {
     if (request["command"] == "restart") {
       Serial.println("Restarting...");
@@ -71,6 +73,12 @@ void MiLightHttpServer::handleSystemPost() {
       ESP.restart();
     }
   }
+  
+  if (handled) {
+    server.send(200, "text/plain", "true");
+  } else {
+    server.send(400, "text/plain", "{\"error\":\"Unhandled command\"}");
+  }
 }
 
 void MiLightHttpServer::handleDownloadUpdate(const UrlTokenBindings* bindings) {