diff --git a/src/controller.cpp b/src/controller.cpp index af52c6a..c686d5f 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -175,7 +175,14 @@ bool Controller::Hello() { bool Controller::SwitchSet(bool enable) { try { - return oac_ && oac_->SwitchSet(enable) == 0; + if (!oac_) { + LOG_ERROR("ObstaclesAvoidClient not initialized"); + return false; + } + + int32_t result = oac_->SwitchSet(enable); + LOG_INFO("SwitchSet API returned: " + std::to_string(result)); + return result == 0; } catch (const std::exception& e) { LOG_ERROR("Switch set failed: " + std::string(e.what())); return false; @@ -184,7 +191,15 @@ bool Controller::SwitchSet(bool enable) { bool Controller::SwitchGet(bool& enable) { try { - return oac_ && oac_->SwitchGet(enable) == 0; + if (!oac_) { + LOG_ERROR("ObstaclesAvoidClient not initialized"); + return false; + } + + int32_t result = oac_->SwitchGet(enable); + LOG_INFO("SwitchGet API returned: " + std::to_string(result) + + ", enable: " + std::string(enable ? "true" : "false")); + return result == 0; } catch (const std::exception& e) { LOG_ERROR("Switch get failed: " + std::string(e.what())); return false;