5#ifndef ASTARTE_DEVICE_SDK_DEVICE_MQTT_H
6#define ASTARTE_DEVICE_SDK_DEVICE_MQTT_H
52 [[nodiscard]]
static auto create(
Config cfg) -> astarte_tl::expected<DeviceMqtt, Error>;
84 -> astarte_tl::expected<void, Error>
override;
101 -> astarte_tl::expected<void, Error>
override;
111 auto connect() -> astarte_tl::expected<void, Error>
override;
135 const std::chrono::system_clock::time_point* timestamp)
136 -> astarte_tl::expected<
void,
Error> override;
147 auto
send_object(std::string_view interface_name, std::string_view path,
149 const std::chrono::system_clock::time_point* timestamp)
150 -> astarte_tl::expected<
void,
Error> override;
160 auto
set_property(std::string_view interface_name, std::string_view path, const
Data& data)
161 -> astarte_tl::expected<
void,
Error> override;
171 -> astarte_tl::expected<
void,
Error> override;
210 auto
get_property(std::string_view interface_name, std::string_view path)
214 struct DeviceMqttImpl;
215 std::shared_ptr<DeviceMqttImpl> astarte_device_impl_;
221 explicit
DeviceMqtt(std::shared_ptr<DeviceMqttImpl> impl);
Represents a single Astarte data value.
Definition data.hpp:61
Astarte object class, representing the Astarte object datastream data.
Definition object.hpp:33
Device(const Device &other)=delete
Device is non-copyable.
Astarte message class, represents a full message for/from Astarte.
Definition msg.hpp:37
Representing the Astarte individual property data.
Definition property.hpp:22
Represents a stored property on the device.
Definition stored_property.hpp:33
Configuration for the Astarte MQTT connection.
Definition config.hpp:55
auto connect() -> astarte_tl::expected< void, Error > override
Connects the device to the Astarte platform.
auto get_all_properties(const std::optional< Ownership > &ownership) -> astarte_tl::expected< std::list< StoredProperty >, Error > override
Retrieves all stored properties matching an ownership filter.
auto disconnect() -> astarte_tl::expected< void, Error > override
Disconnects the device from Astarte.
~DeviceMqtt() override
Virtual destructor.
DeviceMqtt(DeviceMqtt &&other)=default
Move constructor.
auto add_interface_from_file(const std::filesystem::path &json_file) -> astarte_tl::expected< void, Error > override
Adds an interface definition to the device from a JSON file.
auto poll_incoming(const std::chrono::milliseconds &timeout) -> std::optional< Message > override
Polls for incoming messages from Astarte.
DeviceMqtt(DeviceMqtt &other)=delete
Device is non-copyable.
auto operator=(DeviceMqtt &&other) -> DeviceMqtt &=default
Move assignment operator.
auto send_object(std::string_view interface_name, std::string_view path, const DatastreamObject &object, const std::chrono::system_clock::time_point *timestamp) -> astarte_tl::expected< void, Error > override
Sends an aggregated object to an Astarte Interface.
static auto create(Config cfg) -> astarte_tl::expected< DeviceMqtt, Error >
Creates a new instance of the MQTT device.
auto get_properties(std::string_view interface_name) -> astarte_tl::expected< std::list< StoredProperty >, Error > override
Retrieves all stored properties belonging to a specific interface.
auto get_property(std::string_view interface_name, std::string_view path) -> astarte_tl::expected< PropertyIndividual, Error > override
Retrieves a specific property value.
auto send_individual(std::string_view interface_name, std::string_view path, const Data &data, const std::chrono::system_clock::time_point *timestamp) -> astarte_tl::expected< void, Error > override
Sends an individual data point to an Astarte Interface.
auto operator=(DeviceMqtt &other) -> DeviceMqtt &=delete
Device is non-copyable.
auto set_property(std::string_view interface_name, std::string_view path, const Data &data) -> astarte_tl::expected< void, Error > override
Updates a local device property and synchronize it with Astarte.
auto is_connected() const -> bool override
Checks connectivity status.
auto unset_property(std::string_view interface_name, std::string_view path) -> astarte_tl::expected< void, Error > override
Unsets (deletes) a device property.
auto add_interface_from_str(std::string_view json) -> astarte_tl::expected< void, Error > override
Adds an interface definition to the device from a JSON string.
auto remove_interface(const std::string &interface_name) -> astarte_tl::expected< void, Error > override
Removes an installed interface from the device.
Configuration for the Astarte MQTT transport.
Astarte data class and its related methods.
Abstract Astarte device interface.
specific error definitions for the Astarte device SDK.
Astarte message class and its related methods.
Namespace for Astarte device functionality using the MQTT transport protocol.
Definition errors.hpp:57
Ownership
Possible Astarte ownership.
Definition ownership.hpp:23
std::variant< DataSerializationError, InternalError, FileOpenError, InvalidInputError, InterfaceValidationError, InvalidInterfaceVersionError, InvalidInterfaceTypeError, InvalidInterfaceOwnershipeError, InvalidInterfaceAggregationError, InvalidAstarteTypeError, InvalidReliabilityError, InvalidRetentionError, InvalidDatabaseRetentionPolicyError, OperationRefusedError, GrpcLibError, MsgHubError, mqtt::JsonParsingError, mqtt::DeviceRegistrationError, mqtt::PairingApiError, mqtt::MqttError, mqtt::InvalidUrlError, mqtt::RetrieveBrokerUrlError, mqtt::ReadCredentialError, mqtt::WriteCredentialError, mqtt::PairingConfigError, mqtt::CryptoError, mqtt::UuidError, mqtt::HttpError, mqtt::MqttConnectionError > Error
Variant type representing any error from the Astarte device library.
Definition errors.hpp:80
Astarte object class and its related methods.
Ownership definitions for communication with Astarte.
Astarte individual property class and its related methods.
Astarte stored property class.