|
Astarte device API for C++ 0.8.1
Astarte device SDK for C++
|
Interface for an Astarte device. More...
#include <device.hpp>
Inheritance diagram for astarte::device::Device:Public Member Functions | |
| 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. | |
| virtual auto | add_interface_from_file (const std::filesystem::path &json_file) -> astarte_tl::expected< void, Error >=0 |
| Adds an interface definition to the device from a JSON file. | |
| virtual auto | add_interface_from_str (std::string_view json) -> astarte_tl::expected< void, Error >=0 |
| Adds an interface definition to the device from a JSON string. | |
| virtual auto | remove_interface (const std::string &interface_name) -> astarte_tl::expected< void, Error >=0 |
| Removes an installed interface from the device. | |
| virtual auto | connect () -> astarte_tl::expected< void, Error >=0 |
| Connects the device to the Astarte platform. | |
| virtual auto | is_connected () const -> bool=0 |
| Checks connectivity status. | |
| virtual auto | disconnect () -> astarte_tl::expected< void, Error >=0 |
| Disconnects the device from Astarte. | |
| virtual 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 >=0 |
| Sends an individual data point to an Astarte Interface. | |
| virtual 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 >=0 |
| Sends an aggregated object to an Astarte Interface. | |
| virtual auto | set_property (std::string_view interface_name, std::string_view path, const Data &data) -> astarte_tl::expected< void, Error >=0 |
| Updates a local device property and synchronize it with Astarte. | |
| virtual auto | unset_property (std::string_view interface_name, std::string_view path) -> astarte_tl::expected< void, Error >=0 |
| Unsets (deletes) a device property. | |
| virtual auto | poll_incoming (const std::chrono::milliseconds &timeout) -> std::optional< Message >=0 |
| Polls for incoming messages from Astarte. | |
| virtual auto | get_all_properties (const std::optional< Ownership > &ownership) -> astarte_tl::expected< std::list< StoredProperty >, Error >=0 |
| Retrieves all stored properties matching an ownership filter. | |
| virtual auto | get_properties (std::string_view interface_name) -> astarte_tl::expected< std::list< StoredProperty >, Error >=0 |
| Retrieves all stored properties belonging to a specific interface. | |
| virtual auto | get_property (std::string_view interface_name, std::string_view path) -> astarte_tl::expected< PropertyIndividual, Error >=0 |
| Retrieves a specific property value. | |
Interface for an Astarte device.
This abstract class normalizes interactions with the Astarte IoT platform, hiding transport-specific implementation details (e.g., MQTT, gRPC) from the user. Users should instantiate a concrete implementation of this class.
|
virtualdefault |
Virtual destructor.
|
default |
Move constructor.
| [in,out] | other | The device instance to move data from. |
|
pure virtual |
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. |
Implemented in astarte::device::grpc::DeviceGrpc, and astarte::device::mqtt::DeviceMqtt.
|
pure virtual |
Adds an interface definition to the device from a JSON string.
| [in] | json | The interface definition as a JSON string view. |
Implemented in astarte::device::grpc::DeviceGrpc, and astarte::device::mqtt::DeviceMqtt.
|
pure virtual |
Connects the device to the Astarte platform.
This is an asynchronous operation. It initializes the transport layer and starts a background routine to maintain connectivity.
Implemented in astarte::device::grpc::DeviceGrpc, and astarte::device::mqtt::DeviceMqtt.
|
pure virtual |
Disconnects the device from Astarte.
Implemented in astarte::device::grpc::DeviceGrpc, and astarte::device::mqtt::DeviceMqtt.
|
pure virtual |
Retrieves all stored properties matching an ownership filter.
| [in] | ownership | Optional filter, if std::nullopt, returns all properties. |
Implemented in astarte::device::grpc::DeviceGrpc, and astarte::device::mqtt::DeviceMqtt.
|
pure virtual |
Retrieves all stored properties belonging to a specific interface.
| [in] | interface_name | The name of the interface to query. |
Implemented in astarte::device::grpc::DeviceGrpc, and astarte::device::mqtt::DeviceMqtt.
|
pure virtual |
Retrieves a specific property value.
| [in] | interface_name | The name of the interface. |
| [in] | path | The exact path of the property. |
Implemented in astarte::device::grpc::DeviceGrpc, and astarte::device::mqtt::DeviceMqtt.
|
nodiscardpure virtual |
Checks connectivity status.
Implemented in astarte::device::grpc::DeviceGrpc, and astarte::device::mqtt::DeviceMqtt.
Device is non-copyable.
Move assignment operator.
| [in,out] | other | The device instance to move data from. |
|
pure virtual |
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. |
Implemented in astarte::device::grpc::DeviceGrpc, and astarte::device::mqtt::DeviceMqtt.
|
pure virtual |
Removes an installed interface from the device.
| [in] | interface_name | The name of the interface to remove. |
Implemented in astarte::device::grpc::DeviceGrpc, and astarte::device::mqtt::DeviceMqtt.
|
pure virtual |
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. |
Implemented in astarte::device::grpc::DeviceGrpc, and astarte::device::mqtt::DeviceMqtt.
|
pure virtual |
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. |
Implemented in astarte::device::grpc::DeviceGrpc, and astarte::device::mqtt::DeviceMqtt.
|
pure virtual |
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. |
Implemented in astarte::device::grpc::DeviceGrpc, and astarte::device::mqtt::DeviceMqtt.
|
pure virtual |
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. |
Implemented in astarte::device::grpc::DeviceGrpc, and astarte::device::mqtt::DeviceMqtt.