format task node
This commit is contained in:
parent
a8ed715631
commit
347f980794
@ -359,32 +359,39 @@ int handleMqttMessage(char* topicName, int topicLen, MQTTClient_message* message
|
|||||||
|
|
||||||
void try_subscribe_task_topic()
|
void try_subscribe_task_topic()
|
||||||
{
|
{
|
||||||
if (!identity_ready.load()) {
|
if (!identity_ready.load())
|
||||||
|
{
|
||||||
LOG_DEBUG("[TASK] Identity not ready, skipping subscribe");
|
LOG_DEBUG("[TASK] Identity not ready, skipping subscribe");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mqtt_topic_sub_task.empty()) {
|
if (mqtt_topic_sub_task.empty())
|
||||||
|
{
|
||||||
LOG_DEBUG("[TASK] MQTT topic not configured, skipping subscribe");
|
LOG_DEBUG("[TASK] MQTT topic not configured, skipping subscribe");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mqtt_manager.isConnected()) {
|
if (!mqtt_manager.isConnected())
|
||||||
|
{
|
||||||
LOG_DEBUG("[TASK] MQTT not connected, skipping subscribe");
|
LOG_DEBUG("[TASK] MQTT not connected, skipping subscribe");
|
||||||
subscribed.store(false); // 确保下次可以重试
|
subscribed.store(false); // 确保下次可以重试
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subscribed.load()) {
|
if (subscribed.load())
|
||||||
|
{
|
||||||
LOG_DEBUG("[TASK] Already subscribed, skipping");
|
LOG_DEBUG("[TASK] Already subscribed, skipping");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_INFO("[TASK] subscribe MQTT topic: %s", mqtt_topic_sub_task.c_str());
|
LOG_INFO("[TASK] subscribe MQTT topic: %s", mqtt_topic_sub_task.c_str());
|
||||||
bool success = mqtt_manager.subscribe(mqtt_topic_sub_task, 0);
|
bool success = mqtt_manager.subscribe(mqtt_topic_sub_task, 0);
|
||||||
if (success) {
|
if (success)
|
||||||
|
{
|
||||||
subscribed.store(true);
|
subscribed.store(true);
|
||||||
LOG_INFO("[TASK] Subscribe successful");
|
LOG_INFO("[TASK] Subscribe successful");
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
LOG_ERROR("[TASK] Subscribe failed, will retry later");
|
LOG_ERROR("[TASK] Subscribe failed, will retry later");
|
||||||
subscribed.store(false); // 订阅失败,允许重试
|
subscribed.store(false); // 订阅失败,允许重试
|
||||||
}
|
}
|
||||||
@ -442,7 +449,8 @@ class TaskManagerNode : public rclcpp::Node
|
|||||||
vid = msg->vid;
|
vid = msg->vid;
|
||||||
identity_ready.store(!vid.empty());
|
identity_ready.store(!vid.empty());
|
||||||
|
|
||||||
if (!identity_ready.load()) {
|
if (!identity_ready.load())
|
||||||
|
{
|
||||||
LOG_WARN("[TASK] Invalid VID received: %s", msg->vid.c_str());
|
LOG_WARN("[TASK] Invalid VID received: %s", msg->vid.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user