|
Astarte device API for C++ 0.8.1
Astarte device SDK for C++
|
MQTT implementation of an Astarte device. More...
#include <device_mqtt.hpp>
Inheritance diagram for astarte::device::mqtt::DeviceMqtt:Public Member Functions | |
| ~DeviceMqtt () override | |
| Virtual destructor. | |
| DeviceMqtt (DeviceMqtt &other)=delete | |
| Device is non-copyable. | |
| auto | operator= (DeviceMqtt &other) -> DeviceMqtt &=delete |
| Device is non-copyable. | |
| DeviceMqtt (DeviceMqtt &&other)=default | |
| Move constructor. | |
| auto | operator= (DeviceMqtt &&other) -> DeviceMqtt &=default |
| Move assignment operator. | |
| 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 | 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. | |
| auto | connect () -> astarte_tl::expected< void, Error > override |
| Connects the device to the Astarte platform. | |
| auto | is_connected () const -> bool override |
| Checks connectivity status. | |
| auto | disconnect () -> astarte_tl::expected< void, Error > override |
| Disconnects the device from Astarte. | |
| 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 | 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. | |
| 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 | unset_property (std::string_view interface_name, std::string_view path) -> astarte_tl::expected< void, Error > override |
| Unsets (deletes) a device property. | |
| auto | poll_incoming (const std::chrono::milliseconds &timeout) -> std::optional< Message > override |
| Polls for incoming messages from Astarte. | |
| 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 | 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. | |
Public Member Functions inherited from astarte::device::Device | |
| virtual | ~Device ()=default |
| Virtual destructor. | |
| Device (const Device &other)=delete | |
| Device is non-copyable. | |
| Device (Device &&other)=default | |
| Move constructor. | |
| auto | operator= (const Device &other) -> Device &=delete |
| Device is non-copyable. | |
| auto | operator= (Device &&other) -> Device &=default |
| Move assignment operator. | |
Static Public Member Functions | |
| static auto | create (Config cfg) -> astarte_tl::expected< DeviceMqtt, Error > |
| Creates a new instance of the MQTT device. | |
MQTT implementation of an Astarte device.
This class implements the abstract Device interface using MQTT as the underlying transport protocol. It handles connection management, data serialization, and protocol-specific communication with the Astarte platform.
|
override |
Virtual destructor.
|
delete |
Device is non-copyable.
|
default |
Move constructor.
| [in,out] | other | The device instance to move data from. |
|
overridevirtual |
Adds an interface definition to the device from a JSON file.
Parses the JSON file to validate and register a new Astarte Interface.
| [in] | json_file | The filesystem path to the .json interface definition. |
Implements astarte::device::Device.
|
overridevirtual |
Adds an interface definition to the device from a JSON string.
| [in] | json | The interface definition as a JSON string view. |
Implements astarte::device::Device.
|
overridevirtual |
Connects the device to the Astarte platform.
This is an asynchronous operation. It initializes the MQTT transport layer and starts a background routine to maintain connectivity.
Implements astarte::device::Device.
|
staticnodiscard |
Creates a new instance of the MQTT device.
| [in] | cfg | The configuration options used to connect the device to Astarte. |
|
overridevirtual |
Disconnects the device from Astarte.
Implements astarte::device::Device.
|
overridevirtual |
Retrieves all stored properties matching an ownership filter.
| [in] | ownership | Optional filter, if std::nullopt, returns all properties. |
Implements astarte::device::Device.
|
overridevirtual |
Retrieves all stored properties belonging to a specific interface.
| [in] | interface_name | The name of the interface to query. |
Implements astarte::device::Device.
|
overridevirtual |
Retrieves a specific property value.
| [in] | interface_name | The name of the interface. |
| [in] | path | The exact path of the property. |
Implements astarte::device::Device.
|
nodiscardoverridevirtual |
Checks connectivity status.
Implements astarte::device::Device.
|
default |
Move assignment operator.
| [in,out] | other | The device instance to move data from. |
|
delete |
Device is non-copyable.
|
overridevirtual |
Polls for incoming messages from Astarte.
This method blocks the calling thread until a message is received or the timeout expires.
| [in] | timeout | The maximum duration to block waiting for a message. |
Implements astarte::device::Device.
|
overridevirtual |
Removes an installed interface from the device.
| [in] | interface_name | The name of the interface to remove. |
Implements astarte::device::Device.
|
overridevirtual |
Sends an individual data point to an Astarte Interface.
| [in] | interface_name | The name of the target interface. |
| [in] | path | The specific mapping path within the interface (e.g., "/sensors/temp"). |
| [in] | data | The value payload to transmit. |
| [in] | timestamp | Optional timestamp. Should match the interface timestamp configuration. |
Implements astarte::device::Device.
|
overridevirtual |
Sends an aggregated object to an Astarte Interface.
| [in] | interface_name | The name of the target interface. |
| [in] | path | The common base path for the object aggregation. |
| [in] | object | The map of keys and values constituting the object. |
| [in] | timestamp | Optional timestamp. Should match the interface timestamp configuration. |
Implements astarte::device::Device.
|
overridevirtual |
Updates a local device property and synchronize it with Astarte.
| [in] | interface_name | The name of the interface containing the property. |
| [in] | path | The specific path of the property. |
| [in] | data | The new value for the property. |
Implements astarte::device::Device.
|
overridevirtual |
Unsets (deletes) a device property.
| [in] | interface_name | The name of the interface containing the property. |
| [in] | path | The specific path of the property to unset. |
Implements astarte::device::Device.