#include <mqtt_client.h>
Public Types | |
using | Ptr = std::shared_ptr< MQTTClient > |
using | TopicCallback = std::function< void(const mosquitto_message *)> |
Signals | |
void | disconnected () |
Public Member Functions | |
void | addMessageCallback (const std::string &topic, TopicCallback callback) |
const MosquittoConfig & | config () const |
bool | connect (const MosquittoConfig &config) |
void | disconnect () |
std::unordered_set< std::string > | getTopicList () |
bool | isConnected () const |
MQTTClient () | |
void | onMessageReceived (const mosquitto_message *message) |
void | subscribe (const std::string &topic, int qos) |
void | unsubscribe (const std::string &topic) |
~MQTTClient () | |
Public Attributes | |
bool | _connected = false |
Private Member Functions | |
bool | configureMosquitto (const MosquittoConfig &config) |
Private Attributes | |
MosquittoConfig | _config |
std::unordered_map< std::string, TopicCallback > | _message_callbacks |
mosquitto * | _mosq = nullptr |
std::mutex | _mutex |
std::thread | _thread |
std::unordered_set< std::string > | _topics_set |
Definition at line 14 of file mqtt_client.h.
using MQTTClient::Ptr = std::shared_ptr<MQTTClient> |
Definition at line 19 of file mqtt_client.h.
using MQTTClient::TopicCallback = std::function<void(const mosquitto_message*)> |
Definition at line 30 of file mqtt_client.h.
MQTTClient::MQTTClient | ( | ) |
Definition at line 81 of file mqtt_client.cpp.
MQTTClient::~MQTTClient | ( | ) |
Definition at line 92 of file mqtt_client.cpp.
void MQTTClient::addMessageCallback | ( | const std::string & | topic, |
MQTTClient::TopicCallback | callback | ||
) |
Definition at line 259 of file mqtt_client.cpp.
const MosquittoConfig & MQTTClient::config | ( | ) | const |
Definition at line 279 of file mqtt_client.cpp.
|
private |
Definition at line 125 of file mqtt_client.cpp.
bool MQTTClient::connect | ( | const MosquittoConfig & | config | ) |
Definition at line 101 of file mqtt_client.cpp.
void MQTTClient::disconnect | ( | ) |
Definition at line 236 of file mqtt_client.cpp.
|
signal |
std::unordered_set< std::string > MQTTClient::getTopicList | ( | ) |
Definition at line 284 of file mqtt_client.cpp.
bool MQTTClient::isConnected | ( | ) | const |
Definition at line 254 of file mqtt_client.cpp.
void MQTTClient::onMessageReceived | ( | const mosquitto_message * | message | ) |
Definition at line 266 of file mqtt_client.cpp.
void MQTTClient::subscribe | ( | const std::string & | topic, |
int | qos | ||
) |
Definition at line 290 of file mqtt_client.cpp.
void MQTTClient::unsubscribe | ( | const std::string & | topic | ) |
Definition at line 298 of file mqtt_client.cpp.
|
private |
Definition at line 56 of file mqtt_client.h.
bool MQTTClient::_connected = false |
Definition at line 33 of file mqtt_client.h.
|
private |
Definition at line 53 of file mqtt_client.h.
|
private |
Definition at line 52 of file mqtt_client.h.
|
private |
Definition at line 55 of file mqtt_client.h.
|
private |
Definition at line 57 of file mqtt_client.h.
|
private |
Definition at line 54 of file mqtt_client.h.