Astarte device API for C++ 0.8.1
Astarte device SDK for C++
Loading...
Searching...
No Matches
astarte::device::mqtt::Config Class Reference

Configuration for the Astarte MQTT connection. More...

#include <config.hpp>

Public Member Functions

 Config (Config &&other) noexcept
 Move constructor.
 
auto operator= (Config &&other) noexcept -> Config &
 Move assignment operator.
 
 Config (const Config &)=delete
 Config is non-copyable.
 
auto operator= (const Config &) -> Config &=delete
 Config is non-copyable.
 
 ~Config ()
 Destructor.
 
auto realm () -> std::string_view
 Gets the configured realm.
 
auto device_id () -> std::string_view
 Gets the configured device ID.
 
auto pairing_url () -> std::string_view
 Gets the configured Pairing API URL.
 
auto cred_is_credential_secret () -> bool
 Checks if the credential is of type credential secret.
 
auto credential_secret () -> std::optional< std::string >
 Retrieves the credential value.
 
auto store_dir () -> std::string_view
 Gets the configured store directory.
 
auto keepalive (uint32_t duration) -> Config &
 Sets the MQTT keep-alive interval.
 
auto ignore_ssl_errors () -> Config &
 Configures the client to ignore TLS/SSL certificate validation errors.
 
auto connection_timeout (uint32_t duration) -> Config &
 Sets the MQTT connection timeout.
 
auto disconnection_timeout (std::chrono::milliseconds duration) -> Config &
 Sets the MQTT disconnection timeout.
 
auto keepalive () const -> uint32_t
 Gets the MQTT keep-alive interval.
 
auto connection_timeout () const -> uint32_t
 Gets the MQTT connection timeout.
 
auto disconnection_timeout () const -> std::chrono::milliseconds
 Gets the MQTT disconnection timeout.
 

Static Public Member Functions

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.
 

Detailed Description

Configuration for the Astarte MQTT connection.

This class holds all necessary settings for connecting a device to Astarte via MQTT. It uses a builder pattern, allowing for fluent and readable configuration.

Constructor & Destructor Documentation

◆ Config() [1/2]

astarte::device::mqtt::Config::Config ( Config && other)
noexcept

Move constructor.

Parameters
[in,out]otherThe config instance to move data from.

◆ Config() [2/2]

astarte::device::mqtt::Config::Config ( const Config & )
delete

Config is non-copyable.

◆ ~Config()

astarte::device::mqtt::Config::~Config ( )

Destructor.

Member Function Documentation

◆ connection_timeout() [1/2]

auto astarte::device::mqtt::Config::connection_timeout ( ) const -> uint32_t
inlinenodiscard

Gets the MQTT connection timeout.

Returns
The connection timeout value.

◆ connection_timeout() [2/2]

auto astarte::device::mqtt::Config::connection_timeout ( uint32_t duration) -> Config&
inline

Sets the MQTT connection timeout.

Parameters
[in]durationThe timeout duration in seconds.
Returns
A reference to the Config object for chaining.

◆ cred_is_credential_secret()

auto astarte::device::mqtt::Config::cred_is_credential_secret ( ) -> bool
nodiscard

Checks if the credential is of type credential secret.

Returns
True if the stored credential is a credential secret, false otherwise.

◆ credential_secret()

auto astarte::device::mqtt::Config::credential_secret ( ) -> std::optional< std::string >
nodiscard

Retrieves the credential value.

Returns
An optional string containing the credential value if available.

◆ device_id()

auto astarte::device::mqtt::Config::device_id ( ) -> std::string_view
inlinenodiscard

Gets the configured device ID.

Returns
A string view containing the device ID.

◆ disconnection_timeout() [1/2]

auto astarte::device::mqtt::Config::disconnection_timeout ( ) const -> std::chrono::milliseconds
inlinenodiscard

Gets the MQTT disconnection timeout.

Returns
The disconnection timeout value.

◆ disconnection_timeout() [2/2]

auto astarte::device::mqtt::Config::disconnection_timeout ( std::chrono::milliseconds duration) -> Config&
inline

Sets the MQTT disconnection timeout.

Parameters
[in]durationThe timeout duration in milliseconds.
Returns
A reference to the Config object for chaining.

◆ ignore_ssl_errors()

auto astarte::device::mqtt::Config::ignore_ssl_errors ( ) -> Config&
inline

Configures the client to ignore TLS/SSL certificate validation errors.

Returns
A reference to the updated Config object.

◆ keepalive() [1/2]

auto astarte::device::mqtt::Config::keepalive ( ) const -> uint32_t
inlinenodiscard

Gets the MQTT keep-alive interval.

Returns
The connection keepalive value.

◆ keepalive() [2/2]

auto astarte::device::mqtt::Config::keepalive ( uint32_t duration) -> Config&
inline

Sets the MQTT keep-alive interval.

Parameters
[in]durationThe keep-alive duration in seconds.
Returns
A reference to the Config object for chaining.

◆ operator=() [1/2]

auto astarte::device::mqtt::Config::operator= ( Config && other) -> Config &
noexcept

Move assignment operator.

Parameters
[in,out]otherThe config instance to move data from.
Returns
A reference to this config.

◆ operator=() [2/2]

auto astarte::device::mqtt::Config::operator= ( const Config & ) -> Config &=delete
delete

Config is non-copyable.

◆ pairing_url()

auto astarte::device::mqtt::Config::pairing_url ( ) -> std::string_view
inlinenodiscard

Gets the configured Pairing API URL.

Returns
A string view containing the pairing URL.

◆ realm()

auto astarte::device::mqtt::Config::realm ( ) -> std::string_view
inlinenodiscard

Gets the configured realm.

Returns
A string view containing the realm.

◆ store_dir()

auto astarte::device::mqtt::Config::store_dir ( ) -> std::string_view
inlinenodiscard

Gets the configured store directory.

Returns
A string view containing the store directory.

◆ with_credential_secret()

static auto astarte::device::mqtt::Config::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
staticnodiscard

Creates a new Config instance using a credential secret.

Parameters
[in]realmThe Astarte realm.
[in]device_idThe device's unique ID.
[in]credentialThe credential secret string.
[in]pairing_urlThe base URL of the Astarte pairing API.
[in]store_dirPath to a local directory for persisting state.
Returns
A new Config object.

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