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()
|
||||
{
|
||||
if (!identity_ready.load()) {
|
||||
if (!identity_ready.load())
|
||||
{
|
||||
LOG_DEBUG("[TASK] Identity not ready, skipping subscribe");
|
||||
return;
|
||||
}
|
||||
if (mqtt_topic_sub_task.empty()) {
|
||||
if (mqtt_topic_sub_task.empty())
|
||||
{
|
||||
LOG_DEBUG("[TASK] MQTT topic not configured, skipping subscribe");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mqtt_manager.isConnected()) {
|
||||
if (!mqtt_manager.isConnected())
|
||||
{
|
||||
LOG_DEBUG("[TASK] MQTT not connected, skipping subscribe");
|
||||
subscribed.store(false); // 确保下次可以重试
|
||||
return;
|
||||
}
|
||||
|
||||
if (subscribed.load()) {
|
||||
if (subscribed.load())
|
||||
{
|
||||
LOG_DEBUG("[TASK] Already subscribed, skipping");
|
||||
return;
|
||||
}
|
||||
|
||||
LOG_INFO("[TASK] subscribe MQTT topic: %s", mqtt_topic_sub_task.c_str());
|
||||
bool success = mqtt_manager.subscribe(mqtt_topic_sub_task, 0);
|
||||
if (success) {
|
||||
if (success)
|
||||
{
|
||||
subscribed.store(true);
|
||||
LOG_INFO("[TASK] Subscribe successful");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR("[TASK] Subscribe failed, will retry later");
|
||||
subscribed.store(false); // 订阅失败,允许重试
|
||||
}
|
||||
@ -442,7 +449,8 @@ class TaskManagerNode : public rclcpp::Node
|
||||
vid = msg->vid;
|
||||
identity_ready.store(!vid.empty());
|
||||
|
||||
if (!identity_ready.load()) {
|
||||
if (!identity_ready.load())
|
||||
{
|
||||
LOG_WARN("[TASK] Invalid VID received: %s", msg->vid.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user