bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
mqtt_publisher.h
Go to the documentation of this file.
1#ifndef BITSIM_NETWORK_MQTT_PUBLISHER_H
2#define BITSIM_NETWORK_MQTT_PUBLISHER_H
3
5#include "bitsim/extern/nlohmann/json/json.hpp"
6
7#include <mqtt/async_client.h>
8#include <string>
9
10namespace bitsim
11{
12namespace network
13{
20{
21 public:
22 MqttPublisher(const std::string &server, const std::string &topic);
24
25 std::string topic() const noexcept { return topic_; }
26
27 bool is_connected() const noexcept { return cli_.is_connected(); }
28
29 void connect();
30
36 void publish(const std::string &payload, int_t qos = 0, bool retained = false);
37
42 void publish(const nlohmann::json &payload, int_t qos = 0, bool retained = false);
43
44 private:
45 const std::string server_;
46 const std::string topic_;
47
48 mqtt::async_client cli_;
49};
50} // namespace network
51} // namespace bitsim
52
53#endif // BITSIM_NETWORK_MQTT_PUBLISHER_H
The basic types of bitsim. Code outside this file names Eigen's matrix and vector types only through ...
std::string topic() const noexcept
Definition mqtt_publisher.h:25
~MqttPublisher()
Definition mqtt_publisher.cpp:16
void publish(const std::string &payload, int_t qos=0, bool retained=false)
Definition mqtt_publisher.cpp:34
void connect()
Definition mqtt_publisher.cpp:27
bool is_connected() const noexcept
Definition mqtt_publisher.h:27
MqttPublisher(const std::string &server, const std::string &topic)
Definition mqtt_publisher.cpp:11
Definition mqtt_publisher.cpp:9
Definition dc_motor_backend_base.h:9
int int_t
integer type
Definition bitsim_types.h:30