Browse Source

send response for all command input

Chris Mullins 8 years ago
parent
commit
f38c20d07e
1 changed files with 8 additions and 0 deletions
  1. 8 0
      lib/WebServer/MiLightHttpServer.cpp

+ 8 - 0
lib/WebServer/MiLightHttpServer.cpp

@@ -61,6 +61,8 @@ void MiLightHttpServer::handleSystemPost() {
   DynamicJsonBuffer buffer;
   DynamicJsonBuffer buffer;
   JsonObject& request = buffer.parse(server.arg("plain"));
   JsonObject& request = buffer.parse(server.arg("plain"));
   
   
+  bool handled = false;
+  
   if (request.containsKey("command")) {
   if (request.containsKey("command")) {
     if (request["command"] == "restart") {
     if (request["command"] == "restart") {
       Serial.println("Restarting...");
       Serial.println("Restarting...");
@@ -71,6 +73,12 @@ void MiLightHttpServer::handleSystemPost() {
       ESP.restart();
       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) {
 void MiLightHttpServer::handleDownloadUpdate(const UrlTokenBindings* bindings) {