bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
bitsim::network::MqttPublisher Class Reference

#include <mqtt_publisher.h>

Public Member Functions

 MqttPublisher (const std::string &server, const std::string &topic)
 ~MqttPublisher ()
std::string topic () const noexcept
bool is_connected () const noexcept
void connect ()
void publish (const std::string &payload, int_t qos=0, bool retained=false)
void publish (const nlohmann::json &payload, int_t qos=0, bool retained=false)

Detailed Description

A thin wrapper over mqtt::async_client that only publishes to one topic. Unlike MqttSubscriber it does not subscribe, so it does not receive its own messages back

Constructor & Destructor Documentation

◆ MqttPublisher()

bitsim::network::MqttPublisher::MqttPublisher ( const std::string & server,
const std::string & topic )

◆ ~MqttPublisher()

bitsim::network::MqttPublisher::~MqttPublisher ( )

Member Function Documentation

◆ connect()

void bitsim::network::MqttPublisher::connect ( )

◆ is_connected()

bool bitsim::network::MqttPublisher::is_connected ( ) const
inlinenoexcept

◆ publish() [1/2]

void bitsim::network::MqttPublisher::publish ( const nlohmann::json & payload,
int_t qos = 0,
bool retained = false )

Publish the JSON payload

Parameters
payload
qos
retained

◆ publish() [2/2]

void bitsim::network::MqttPublisher::publish ( const std::string & payload,
int_t qos = 0,
bool retained = false )

Publish the payload to the topic

Parameters
payload
qos
retained

◆ topic()

std::string bitsim::network::MqttPublisher::topic ( ) const
inlinenoexcept

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