Public Types | Signals | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
MQTTClient Class Reference

#include <mqtt_client.h>

Inheritance diagram for MQTTClient:
Inheritance graph
[legend]

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 MosquittoConfigconfig () 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
 

Detailed Description

Definition at line 14 of file mqtt_client.h.

Member Typedef Documentation

◆ Ptr

using MQTTClient::Ptr = std::shared_ptr<MQTTClient>

Definition at line 19 of file mqtt_client.h.

◆ TopicCallback

using MQTTClient::TopicCallback = std::function<void(const mosquitto_message*)>

Definition at line 30 of file mqtt_client.h.

Constructor & Destructor Documentation

◆ MQTTClient()

MQTTClient::MQTTClient ( )

Definition at line 81 of file mqtt_client.cpp.

◆ ~MQTTClient()

MQTTClient::~MQTTClient ( )

Definition at line 92 of file mqtt_client.cpp.

Member Function Documentation

◆ addMessageCallback()

void MQTTClient::addMessageCallback ( const std::string &  topic,
MQTTClient::TopicCallback  callback 
)

Definition at line 259 of file mqtt_client.cpp.

◆ config()

const MosquittoConfig & MQTTClient::config ( ) const

Definition at line 279 of file mqtt_client.cpp.

◆ configureMosquitto()

bool MQTTClient::configureMosquitto ( const MosquittoConfig config)
private

Definition at line 125 of file mqtt_client.cpp.

◆ connect()

bool MQTTClient::connect ( const MosquittoConfig config)

Definition at line 101 of file mqtt_client.cpp.

◆ disconnect()

void MQTTClient::disconnect ( )

Definition at line 236 of file mqtt_client.cpp.

◆ disconnected

void MQTTClient::disconnected ( )
signal

◆ getTopicList()

std::unordered_set< std::string > MQTTClient::getTopicList ( )

Definition at line 284 of file mqtt_client.cpp.

◆ isConnected()

bool MQTTClient::isConnected ( ) const

Definition at line 254 of file mqtt_client.cpp.

◆ onMessageReceived()

void MQTTClient::onMessageReceived ( const mosquitto_message *  message)

Definition at line 266 of file mqtt_client.cpp.

◆ subscribe()

void MQTTClient::subscribe ( const std::string &  topic,
int  qos 
)

Definition at line 290 of file mqtt_client.cpp.

◆ unsubscribe()

void MQTTClient::unsubscribe ( const std::string &  topic)

Definition at line 298 of file mqtt_client.cpp.

Member Data Documentation

◆ _config

MosquittoConfig MQTTClient::_config
private

Definition at line 56 of file mqtt_client.h.

◆ _connected

bool MQTTClient::_connected = false

Definition at line 33 of file mqtt_client.h.

◆ _message_callbacks

std::unordered_map<std::string, TopicCallback> MQTTClient::_message_callbacks
private

Definition at line 53 of file mqtt_client.h.

◆ _mosq

mosquitto* MQTTClient::_mosq = nullptr
private

Definition at line 52 of file mqtt_client.h.

◆ _mutex

std::mutex MQTTClient::_mutex
private

Definition at line 55 of file mqtt_client.h.

◆ _thread

std::thread MQTTClient::_thread
private

Definition at line 57 of file mqtt_client.h.

◆ _topics_set

std::unordered_set<std::string> MQTTClient::_topics_set
private

Definition at line 54 of file mqtt_client.h.


The documentation for this class was generated from the following files:


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:50