temp
This commit is contained in:
parent
57d3cfe753
commit
5233c4e9af
14
src/main.cpp
14
src/main.cpp
@ -5,6 +5,7 @@
|
||||
#include <thread>
|
||||
#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))
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user