diff --git a/src/custom_robot.cpp b/src/custom_robot.cpp index 5426ab7..b651f81 100644 --- a/src/custom_robot.cpp +++ b/src/custom_robot.cpp @@ -525,25 +525,12 @@ bool CustomRobot::processOacCmd(const std::string& cmd, const nlohmann::json& me try { if (cmd == "SwitchSet") { - // get current state - bool currentEnable = false; - if (!controller_->SwitchGet(currentEnable)) { - LOG_ERROR("Failed to get current switch state"); + if (message.find("param") == message.end() || message["param"].find("enable") == message["param"].end()) { + LOG_ERROR("Missing 'enable' parameter for Switch command"); return false; } - LOG_INFO("Current switch state: " + std::string(currentEnable ? "true" : "false")); - // switch to opposite state - bool enable = !currentEnable; + bool enable = message["param"]["enable"]; return controller_->SwitchSet(enable); - - } else if (cmd == "SwitchGet") { - bool enable = false; - bool result = controller_->SwitchGet(enable); - if (result) { - LOG_INFO("SwitchGet result: enable=" + std::string(enable ? "true" : "false")); - } - return result; - } else if (cmd == "Move") { if (!message.contains("param")) { LOG_ERROR("Move cmd missing 'param'");