SOIL C++
C++ Unified Device Interface
|
MQTT publishing configuration. More...
#include <Configuration.h>
Public Member Functions | |
Configuration () | |
Default constructor. More... | |
Configuration (std::string filename) | |
JSON Constructor. More... | |
~Configuration () | |
Destructor. More... | |
std::string | uri () |
URI Builder. More... | |
Public Attributes | |
std::string | host |
Hostname of the MQTT broker. More... | |
int | port |
Port of the MQTT broker. More... | |
std::string | username |
Username for connecting to the MQTT broker. More... | |
std::string | password |
Password for connecting to the MQTT broker. More... | |
bool | clean_session |
Clean session flag. More... | |
std::string | root |
MQTT root topic. More... | |
int | keep_alive |
Keep alive interval in seconds. More... | |
int | min_delay_ms |
Minimum delay between to messages in milliseconds. More... | |
int | connection_timeout_s |
Connection timeout in seconds. More... | |
bool | ssl |
Use secured connection. More... | |
bool | verify |
Skip SSL verification. More... | |
bool | websocket |
Use websocket protocol. More... | |
std::string | path |
Websocket path. More... | |
std::string | certificate_authority |
Path to CA PEM-file. More... | |
Class acting as enhanced struct to accomodate all configuration options. Therefore all members are public to be directly accessible.
Definition at line 13 of file Configuration.h.
MQTT::Configuration::Configuration | ( | ) |
Default constructor applying the defaults documented.
Definition at line 8 of file Configuration.cpp.
MQTT::Configuration::Configuration | ( | std::string | filename | ) |
Reads the configuration from a JSON-file. See the project assets for an example file.
[in] | filename | Path to JSON-file (absolute or relative). |
Definition at line 27 of file Configuration.cpp.
MQTT::Configuration::~Configuration | ( | ) |
Standard Destructor
Definition at line 49 of file Configuration.cpp.
std::string MQTT::Configuration::uri | ( | ) |
Builds an URI for the underlying Paho-MQTT library.
tcp://127
.0.0.1:1883 . Definition at line 53 of file Configuration.cpp.
std::string MQTT::Configuration::certificate_authority |
Path to a file containing the trusted certificate authorities in PEM-format for OpenSSL. This is mandatory when properly implementing secure MQTT.
Definition at line 133 of file Configuration.h.
bool MQTT::Configuration::clean_session |
Flag whether to start a clean MQTT session. Defaults to true
.
Definition at line 55 of file Configuration.h.
int MQTT::Configuration::connection_timeout_s |
Number of seconds to wait until the connection succeeds. This influence the length of the blocking call during connection. Defaults to 30
.
Definition at line 90 of file Configuration.h.
std::string MQTT::Configuration::host |
Adress or hostname of the MQTT broker. Can be an FQDN or IP address. Defaults to 127.0.0.1
.
Definition at line 22 of file Configuration.h.
int MQTT::Configuration::keep_alive |
Keep alive interval in seconds for the MQTT client. Defaults to 30
.
Definition at line 72 of file Configuration.h.
int MQTT::Configuration::min_delay_ms |
A minimum delay which should be kept between sending two messages, provided in milliseconds. Defaults to 0
.
Definition at line 81 of file Configuration.h.
std::string MQTT::Configuration::password |
Password when connecting to the MQTT broker. Be mindful with passwords when committing to version control! Defaults to guest
.
Definition at line 47 of file Configuration.h.
std::string MQTT::Configuration::path |
Websocket path that forms the last part of the URI, e.g. /mqtt-ws/
. Defaults to ""
.
Definition at line 124 of file Configuration.h.
int MQTT::Configuration::port |
std::string MQTT::Configuration::root |
Root topic that is prepended to any published topic. This is intended for cases where permisions enfore that you publish under a defined root topic. The default is no root topic prefix.
Definition at line 64 of file Configuration.h.
bool MQTT::Configuration::ssl |
Boolean flag whether to use a secured connection (MQTT over TLS or secure websocket). Defaults to false
.
Definition at line 99 of file Configuration.h.
std::string MQTT::Configuration::username |
Username when connecting to the MQTT broker. When using RabbitMQ, make sure to consider the VHOST prefix. Defaults to guest
.
Definition at line 39 of file Configuration.h.
bool MQTT::Configuration::verify |
Boolean flag whether to ignore SSL certificate validation, i.e. for hostname matching and trusted authority. This should only be used for basic development purposes.
Definition at line 107 of file Configuration.h.
bool MQTT::Configuration::websocket |
Boolean flag whether to use the websocket extension of MQTT. Make sure to specify the correct path. Defaults to false
.
Definition at line 116 of file Configuration.h.