2#include <nlohmann/json.hpp>
10 std::string
host =
"127.0.0.1";
22 std::string
path =
"";
29 std::ifstream infile(filename);
32 host = j.value(
"host",
"127.0.0.1");
33 port = j.value(
"port", 1883);
34 username = j.value(
"username",
"guest");
35 password = j.value(
"password",
"guest");
36 clean_session = j.value(
"clean",
true);
37 root = j.value(
"root",
"");
38 keep_alive = j.value(
"keep_alive", 30);
39 min_delay_ms = j.value(
"min_delay", 0);
40 connection_timeout_s = j.value(
"connection_timeout", 30);
41 ssl = j.value(
"ssl",
false);
42 verify = j.value(
"verify",
true);
43 websocket = j.value(
"websocket",
false);
44 path = j.value(
"path",
"");
45 certificate_authority = j.value(
"certificate_authority",
"");
68 if (path.at(0) !=
'/')
87 return prefix +
"://" + host +
":" + std::to_string(port) + path;
Configuration()
Default constructor.
std::string root
MQTT root topic.
std::string host
Hostname of the MQTT broker.
int min_delay_ms
Minimum delay between to messages in milliseconds.
int keep_alive
Keep alive interval in seconds.
bool ssl
Use secured connection.
bool clean_session
Clean session flag.
int port
Port of the MQTT broker.
std::string password
Password for connecting to the MQTT broker.
std::string certificate_authority
Path to CA PEM-file.
bool verify
Skip SSL verification.
bool websocket
Use websocket protocol.
std::string uri()
URI Builder.
int connection_timeout_s
Connection timeout in seconds.
std::string path
Websocket path.
std::string username
Username for connecting to the MQTT broker.
~Configuration()
Destructor.