diff --git a/src/custom_robot.cpp b/src/custom_robot.cpp index 6f4101f..b570c6e 100644 --- a/src/custom_robot.cpp +++ b/src/custom_robot.cpp @@ -176,8 +176,8 @@ bool CustomRobot::SetReportFreq(int32_t interval, int32_t duration) { bool CustomRobot::initializeMqtt() { try { - std::string broker = config_->mqtt_broker; - int port = config_->mqtt_port; + std::string broker = config_.mqtt_broker; + int port = config_.mqtt_port; std::string clientId = generateRandomClientId(); mqttClient_ = std::make_unique(broker, port, clientId); @@ -192,7 +192,7 @@ bool CustomRobot::initializeMqtt() { return false; } - std::string controlTopic = config_->topic_prefix + "/" + config_->topic_cmd; + std::string controlTopic = config_.topic_prefix + "/" + config_.topic_cmd; mqttClient_->subscribe(controlTopic, 1); @@ -211,7 +211,7 @@ void CustomRobot::onMqttMessage(const std::string& topic, const std::string& pay // nlohmann::json message = nlohmann::json::parse(payload); - // std::string controlTopic = config_->topic_prefix + "/" + config_->topic_cmd; + // std::string controlTopic = config_.topic_prefix + "/" + config_.topic_cmd; // if (topic == controlTopic) { // if (message.contains("command")) { @@ -225,7 +225,7 @@ void CustomRobot::onMqttMessage(const std::string& topic, const std::string& pay // response["status"] = "executed"; // response["command"] = command; // response["timestamp"] = std::time(nullptr); - // std::string statusTopic = config_->topic_prefix + "/" + config_->topic_state; + // std::string statusTopic = config_.topic_prefix + "/" + config_.topic_state; // mqttClient_->publishJson(statusTopic, response); // // Publish updated status @@ -238,7 +238,7 @@ void CustomRobot::onMqttMessage(const std::string& topic, const std::string& pay // response["status"] = "executed"; // response["command"] = command; // response["timestamp"] = std::time(nullptr); - // std::string statusTopic = config_->topic_prefix + "/" + config_->topic_state; + // std::string statusTopic = config_.topic_prefix + "/" + config_.topic_state; // mqttClient_->publishJson(statusTopic, response); // // Publish updated status @@ -250,7 +250,7 @@ void CustomRobot::onMqttMessage(const std::string& topic, const std::string& pay // response["status"] = "error"; // response["message"] = "Unknown command: " + command; // response["timestamp"] = std::time(nullptr); - // std::string statusTopic = config_->topic_prefix + "/" + config_->topic_state; + // std::string statusTopic = config_.topic_prefix + "/" + config_.topic_state; // mqttClient_->publishJson(statusTopic, response); // // Publish updated status @@ -270,7 +270,7 @@ void CustomRobot::onMqttConnection(bool connected) { nlohmann::json status; status["status"] = "online"; status["timestamp"] = std::time(nullptr); - std::string statusTopic = config_->topic_prefix + "/" + config_->topic_state; + std::string statusTopic = config_.topic_prefix + "/" + config_.topic_state; mqttClient_->publishJson(statusTopic, status, 1, true); publishStatus(); @@ -296,7 +296,7 @@ void CustomRobot::publishStatus() { status["controller_connected"] = controller_->isConnected(); } - std::string statusTopic = config_->topic_prefix + "/" + config_->topic_state; + std::string statusTopic = config_.topic_prefix + "/" + config_.topic_state; mqttClient_->publishJson(statusTopic, status, 1, true); LOG_DEBUG("Published status to topic: " + statusTopic); @@ -307,7 +307,7 @@ void CustomRobot::publishStatus() { } std::string CustomRobot::generateRandomClientId() const { - std::string baseId = config_->mqtt_client_id; + std::string baseId = config_.mqtt_client_id; std::random_device rd; std::mt19937 gen(rd());