first commit

This commit is contained in:
cxh 2025-09-09 17:19:59 +08:00
parent 49e20e4f17
commit 75addb10ee
2 changed files with 7 additions and 2 deletions

View File

@ -85,7 +85,11 @@ void MQTTClient::publish(const std::string &topic, const std::string &payload, i
try
{
client_->publish(topic, payload.data(), payload.size(), qos, false)->wait_for(std::chrono::milliseconds(500));
LOG_INFO("[MQTT] Published message to topic: " + topic);
// 如果 topic 不包含 "heartbeat",才打印日志
if (topic.find("heartbeat") == std::string::npos)
{
LOG_INFO("[MQTT] Published message to topic: " + topic);
}
}
catch (const mqtt::exception &e)
{

View File

@ -29,7 +29,7 @@ static void send_heartbeat()
msg["type"] = 0;
mqtt_client->publish(g_app_config.mqtt.topics.heartbeat_up, msg.dump());
LOG_INFO("[MQTT] Sent heartbeat: " + msg.dump());
// LOG_INFO("[MQTT] Sent heartbeat: " + msg.dump());
}
// MQTT 回调定义
@ -51,6 +51,7 @@ static void on_mqtt_disconnected()
static void on_mqtt_message_received(const std::string &topic, const std::string &message)
{
LOG_INFO("[MQTT] Received message on topic [" + topic + "], len = " + std::to_string(message.size()));
LOG_INFO("[MQTT] Message content: " + message); // 打印实际内容
try
{