5#ifndef ASTARTE_MQTT_CONFIG_H
6#define ASTARTE_MQTT_CONFIG_H
18#include <spdlog/spdlog.h>
34using namespace std::chrono_literals;
91 std::string_view credential,
99 [[nodiscard]]
auto realm() -> std::string_view {
return realm_; }
105 [[nodiscard]]
auto device_id() -> std::string_view {
return device_id_; }
111 [[nodiscard]]
auto pairing_url() -> std::string_view {
return pairing_url_; }
129 [[nodiscard]]
auto store_dir() -> std::string_view {
return store_dir_; }
138 this->keepalive_ = duration;
147 this->ignore_ssl_ =
true;
158 this->conn_timeout_ = duration;
169 this->disconn_timeout_ = duration;
177 [[nodiscard]]
auto keepalive() const -> uint32_t {
return keepalive_; }
190 return disconn_timeout_;
206 Config(std::string_view
realm, std::string_view
device_id, std::unique_ptr<Credential> credential,
210 std::string device_id_;
211 std::string pairing_url_;
212 std::unique_ptr<Credential> credential_;
213 std::string store_dir_;
214 bool ignore_ssl_{
false};
216 uint32_t conn_timeout_;
217 std::chrono::milliseconds disconn_timeout_;
auto ignore_ssl_errors() -> Config &
Configures the client to ignore TLS/SSL certificate validation errors.
Definition config.hpp:146
auto operator=(const Config &) -> Config &=delete
Config is non-copyable.
Config(const Config &)=delete
Config is non-copyable.
auto connection_timeout(uint32_t duration) -> Config &
Sets the MQTT connection timeout.
Definition config.hpp:157
auto disconnection_timeout(std::chrono::milliseconds duration) -> Config &
Sets the MQTT disconnection timeout.
Definition config.hpp:168
auto cred_is_credential_secret() -> bool
Checks if the credential is of type credential secret.
auto keepalive() const -> uint32_t
Gets the MQTT keep-alive interval.
Definition config.hpp:177
auto pairing_url() -> std::string_view
Gets the configured Pairing API URL.
Definition config.hpp:111
auto device_id() -> std::string_view
Gets the configured device ID.
Definition config.hpp:105
auto store_dir() -> std::string_view
Gets the configured store directory.
Definition config.hpp:129
auto operator=(Config &&other) noexcept -> Config &
Move assignment operator.
auto connection_timeout() const -> uint32_t
Gets the MQTT connection timeout.
Definition config.hpp:183
auto realm() -> std::string_view
Gets the configured realm.
Definition config.hpp:99
auto credential_secret() -> std::optional< std::string >
Retrieves the credential value.
static auto with_credential_secret(std::string_view realm, std::string_view device_id, std::string_view credential, std::string_view pairing_url, std::string_view store_dir) -> Config
Creates a new Config instance using a credential secret.
auto disconnection_timeout() const -> std::chrono::milliseconds
Gets the MQTT disconnection timeout.
Definition config.hpp:189
Config(Config &&other) noexcept
Move constructor.
auto keepalive(uint32_t duration) -> Config &
Sets the MQTT keep-alive interval.
Definition config.hpp:137
specific error definitions for the Astarte device SDK.
Namespace for Astarte device functionality using the MQTT transport protocol.
Definition errors.hpp:57
constexpr uint32_t DEFAULT_KEEP_ALIVE
Default keep alive interval in seconds for the MQTT connection.
Definition config.hpp:41
constexpr auto DEFAULT_DISCONNECTION_TIMEOUT
Default disconnection timeout in seconds for the MQTT connection.
Definition config.hpp:47
constexpr uint32_t DEFAULT_CONNECTION_TIMEOUT
Default connection timeout in seconds for the MQTT connection.
Definition config.hpp:44
Astarte pairing API and utilities.