From 5233c4e9af05c8ae0488233965ee1626aa79c2e5 Mon Sep 17 00:00:00 2001 From: cxh Date: Thu, 5 Jun 2025 09:38:24 +0800 Subject: [PATCH] temp --- src/main.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index ea68073..f552185 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,6 +5,7 @@ #include #include "SerialPort.h" #include "LedCommand.h" +#include "LedMqttSubscriber.h" using namespace toml; @@ -86,6 +87,19 @@ int main() std::cout << "串口号: " << port << "\n波特率: " << baudrate << std::endl; + // ===== MQTT 测试连接 ===== + MqttClient mqtt("config.toml"); // 构造时自动读取配置并初始化 + if (mqtt.connect()) + { + std::cout << "MQTT 连接成功" << std::endl; + std::this_thread::sleep_for(std::chrono::seconds(2)); + mqtt.disconnect(); + } + else + { + std::cerr << "MQTT 连接失败" << std::endl; + } + SerialPort serial; if (!serial.openPort(port, baudrate)) {