led_ctrl/include/LedMqttSubscriber.h
2025-06-05 09:24:58 +08:00

30 lines
554 B
C++

#pragma once
#include <string>
#include <mqtt/async_client.h>
class MqttClient
{
public:
MqttClient(const std::string &configPath);
bool start();
private:
std::string broker;
std::string clientId;
std::string username;
std::string password;
std::string topic;
int qos;
class Callback : public virtual mqtt::callback
{
public:
void message_arrived(mqtt::const_message_ptr msg) override;
};
mqtt::async_client *client = nullptr;
mqtt::connect_options connOpts;
Callback callback;
};