Zigbee Protocol Controller 1.6.0
mqtt_client Struct Reference

#include <mqtt_client.hpp>

Classes

struct  callback_info
 

Public Member Functions

 mqtt_client (const std::string &hostname, const uint32_t port, const std::string &client_id, const std::string &cafile, const std::string &certfile, const std::string &keyfile, std::function< int(const int, void *)> event_sender, std::function< void(const int, const unsigned long)> delayed_event_sender, std::function< int(const int, void *)> event_counter)
 
sl_status_t setup ()
 
sl_status_t teardown ()
 
int file_descriptor ()
 
void poll ()
 
void disconnect ()
 
void event (const int incoming_event)
 
void publish (const std::string &topic, const std::string &message, size_t message_length, bool retain)
 
void unretain (const std::string &prefix_pattern)
 Un-retain previously retained messages. More...
 
void unretain_by_regex (const std::string &regex)
 Un-retain previously retained messages. More...
 
int count_topics (const std::string &prefix_pattern)
 Count the number of topics published. More...
 
void subscribe (const std::string &topic, const callback_info &callback)
 
void resubscribe ()
 
void unsubscribe (const std::string &topic, const callback_info &callback)
 
void on_connect_callback_set (mqtt_connection_callback_t)
 
void on_disconnect_callback_set (mqtt_connection_callback_t)
 
void before_disconnect_callback_set (mqtt_simple_callback_t)
 
void after_connect_callback_set (mqtt_simple_callback_t)
 
void on_connect (int return_code)
 
void on_disconnect (int return_code)
 
void on_message (const std::string &topic, const std::string &message, size_t message_length, int message_qos, bool message_retain)
 
void after_connect_callback_call ()
 
void before_disconnect_callback_call ()
 
const char * get_client_id () const
 
bool is_connected_to_broker () const
 

Public Attributes

std::function< int(const int, void *)> event_sender
 
std::function< void(const int, const unsigned long)> delayed_event_sender
 
std::function< int(const int, void *)> event_counter
 

Private Member Functions

bool publish_messages_waiting ()
 
sl_status_t publish_to_broker (bool flushing=false)
 
bool subscription_messages_waiting ()
 
sl_status_t subscribe_to_topic ()
 
bool unsubscription_messages_waiting ()
 
sl_status_t unsubscribe_from_topic ()
 
void send_event (const int outgoing_event, void *procdata)
 
void send_delayed_event (const int outgoing_event, std::chrono::milliseconds delay_time)
 
void transition (mqtt_client_fsm &new_state)
 
sl_status_t connect ()
 

Private Attributes

const std::string hostname
 
const uint32_t port
 
int socket_file_descriptor
 
std::chrono::milliseconds next_reconnect_backoff
 
std::chrono::milliseconds max_reconnect_backoff
 
std::set< mqtt_connection_callback_ton_connect_callbacks
 
std::set< mqtt_connection_callback_ton_disconnect_callbacks
 
std::set< mqtt_simple_callback_tbefore_disconnect_callbacks
 
std::set< mqtt_simple_callback_tafter_connect_callbacks
 
std::deque< message_queue_element_tpublishing_queue
 
std::queue< std::string > subscription_queue
 
std::queue< std::string > unsubscription_queue
 
std::map< std::string, std::vector< callback_info > > subscription_callbacks
 
std::set< std::string > retained_topics
 
void * mqtt_client_library_instance
 
std::string mqtt_client_id
 
std::string mqtt_cafile
 
std::string mqtt_certfile
 
std::string mqtt_keyfile
 
bool connected_to_broker = false
 
mqtt_client_fsmcurrent_state
 

Friends

class mqtt_client_fsm_disconnected
 
class mqtt_client_fsm_connecting
 
class mqtt_client_fsm_connected
 

Constructor & Destructor Documentation

◆ mqtt_client()

mqtt_client::mqtt_client ( const std::string &  hostname,
const uint32_t  port,
const std::string &  client_id,
const std::string &  cafile,
const std::string &  certfile,
const std::string &  keyfile,
std::function< int(const int, void *)>  event_sender,
std::function< void(const int, const unsigned long)>  delayed_event_sender,
std::function< int(const int, void *)>  event_counter 
)

Member Function Documentation

◆ after_connect_callback_call()

void mqtt_client::after_connect_callback_call ( )

◆ after_connect_callback_set()

void mqtt_client::after_connect_callback_set ( mqtt_simple_callback_t  )

◆ before_disconnect_callback_call()

void mqtt_client::before_disconnect_callback_call ( )

◆ before_disconnect_callback_set()

void mqtt_client::before_disconnect_callback_set ( mqtt_simple_callback_t  )

◆ connect()

sl_status_t mqtt_client::connect ( )
private

◆ count_topics()

int mqtt_client::count_topics ( const std::string &  prefix_pattern)

Count the number of topics published.

This function counts the number of topics which has been published retained matching a pattern prefix.

Parameters
prefix_pattern
Returns
int

◆ disconnect()

void mqtt_client::disconnect ( )

◆ event()

void mqtt_client::event ( const int  incoming_event)

◆ file_descriptor()

int mqtt_client::file_descriptor ( )

◆ get_client_id()

const char * mqtt_client::get_client_id ( ) const

◆ is_connected_to_broker()

bool mqtt_client::is_connected_to_broker ( ) const

◆ on_connect()

void mqtt_client::on_connect ( int  return_code)

◆ on_connect_callback_set()

void mqtt_client::on_connect_callback_set ( mqtt_connection_callback_t  )

◆ on_disconnect()

void mqtt_client::on_disconnect ( int  return_code)

◆ on_disconnect_callback_set()

void mqtt_client::on_disconnect_callback_set ( mqtt_connection_callback_t  )

◆ on_message()

void mqtt_client::on_message ( const std::string &  topic,
const std::string &  message,
size_t  message_length,
int  message_qos,
bool  message_retain 
)

◆ poll()

void mqtt_client::poll ( )

◆ publish()

void mqtt_client::publish ( const std::string &  topic,
const std::string &  message,
size_t  message_length,
bool  retain 
)

◆ publish_messages_waiting()

bool mqtt_client::publish_messages_waiting ( )
private

◆ publish_to_broker()

sl_status_t mqtt_client::publish_to_broker ( bool  flushing = false)
private

◆ resubscribe()

void mqtt_client::resubscribe ( )

◆ send_delayed_event()

void mqtt_client::send_delayed_event ( const int  outgoing_event,
std::chrono::milliseconds  delay_time 
)
private

◆ send_event()

void mqtt_client::send_event ( const int  outgoing_event,
void *  procdata 
)
private

◆ setup()

sl_status_t mqtt_client::setup ( )

◆ subscribe()

void mqtt_client::subscribe ( const std::string &  topic,
const callback_info callback 
)

◆ subscribe_to_topic()

sl_status_t mqtt_client::subscribe_to_topic ( )
private

◆ subscription_messages_waiting()

bool mqtt_client::subscription_messages_waiting ( )
private

◆ teardown()

sl_status_t mqtt_client::teardown ( )

◆ transition()

void mqtt_client::transition ( mqtt_client_fsm new_state)
private

◆ unretain()

void mqtt_client::unretain ( const std::string &  prefix_pattern)

Un-retain previously retained messages.

Any topic which has the prefix will be un-retained

Parameters
prefix_pattern

◆ unretain_by_regex()

void mqtt_client::unretain_by_regex ( const std::string &  regex)

Un-retain previously retained messages.

Any topic matches the regex pattern

Parameters
regex

◆ unsubscribe()

void mqtt_client::unsubscribe ( const std::string &  topic,
const callback_info callback 
)

◆ unsubscribe_from_topic()

sl_status_t mqtt_client::unsubscribe_from_topic ( )
private

◆ unsubscription_messages_waiting()

bool mqtt_client::unsubscription_messages_waiting ( )
private

Friends And Related Function Documentation

◆ mqtt_client_fsm_connected

friend class mqtt_client_fsm_connected
friend

◆ mqtt_client_fsm_connecting

friend class mqtt_client_fsm_connecting
friend

◆ mqtt_client_fsm_disconnected

friend class mqtt_client_fsm_disconnected
friend

Member Data Documentation

◆ after_connect_callbacks

std::set<mqtt_simple_callback_t> mqtt_client::after_connect_callbacks
private

◆ before_disconnect_callbacks

std::set<mqtt_simple_callback_t> mqtt_client::before_disconnect_callbacks
private

◆ connected_to_broker

bool mqtt_client::connected_to_broker = false
private

◆ current_state

mqtt_client_fsm* mqtt_client::current_state
private

◆ delayed_event_sender

std::function<void(const int, const unsigned long)> mqtt_client::delayed_event_sender

◆ event_counter

std::function<int(const int, void *)> mqtt_client::event_counter

◆ event_sender

std::function<int(const int, void *)> mqtt_client::event_sender

◆ hostname

const std::string mqtt_client::hostname
private

◆ max_reconnect_backoff

std::chrono::milliseconds mqtt_client::max_reconnect_backoff
private

◆ mqtt_cafile

std::string mqtt_client::mqtt_cafile
private

◆ mqtt_certfile

std::string mqtt_client::mqtt_certfile
private

◆ mqtt_client_id

std::string mqtt_client::mqtt_client_id
private

◆ mqtt_client_library_instance

void* mqtt_client::mqtt_client_library_instance
private

◆ mqtt_keyfile

std::string mqtt_client::mqtt_keyfile
private

◆ next_reconnect_backoff

std::chrono::milliseconds mqtt_client::next_reconnect_backoff
private

◆ on_connect_callbacks

std::set<mqtt_connection_callback_t> mqtt_client::on_connect_callbacks
private

◆ on_disconnect_callbacks

std::set<mqtt_connection_callback_t> mqtt_client::on_disconnect_callbacks
private

◆ port

const uint32_t mqtt_client::port
private

◆ publishing_queue

std::deque<message_queue_element_t> mqtt_client::publishing_queue
private

◆ retained_topics

std::set<std::string> mqtt_client::retained_topics
private

◆ socket_file_descriptor

int mqtt_client::socket_file_descriptor
private

◆ subscription_callbacks

std::map<std::string, std::vector<callback_info> > mqtt_client::subscription_callbacks
private

◆ subscription_queue

std::queue<std::string> mqtt_client::subscription_queue
private

◆ unsubscription_queue

std::queue<std::string> mqtt_client::unsubscription_queue
private

The documentation for this struct was generated from the following file: