Browse Source

On command mapping fixed

Denis V. Dedkov 1 năm trước cách đây
mục cha
commit
fbddbc020c
1 tập tin đã thay đổi với 2 bổ sung2 xóa
  1. 2 2
      main.cpp

+ 2 - 2
main.cpp

@@ -32,7 +32,7 @@ int main(int argc, char *argv[])
     const std::map< std::string, noolitelib::Command > commands = {
         { "off", noolitelib::Off },
         { "decraseBrightnes", noolitelib::DecraseBrightnes },
-        { "on", noolitelib::DecraseBrightnes },
+        { "on", noolitelib::On },
         { "incraseBrightnes", noolitelib::IncreaseBrightnes },
         { "switch", noolitelib::Switch },
         { "invertBrightnes", noolitelib::InvertBrightnes },
@@ -71,7 +71,7 @@ int main(int argc, char *argv[])
         auto channel = req.path_params.at("channel");
 
         noolitelib::Noolite adapter;
-        if (adapter.sendCommand(std::stoi(channel), noolitelib::Switch)) {
+        if (adapter.sendCommand(std::stoi(channel), commands.at(command))) {
             res.set_content(formatResult(true, command + " " + channel), App::ContentType);
         } else {
             res.set_content(formatResult(false, "Device error"), App::ContentType);