|
Astarte device API for C++ 0.8.1
Astarte device SDK for C++
|
Class for the Astarte devices. More...
#include <device_grpc.hpp>
Inheritance diagram for astarte::device::grpc::DeviceGrpc:Public Member Functions | |
| DeviceGrpc (const std::string &server_addr, const std::string &node_uuid) | |
| Constructor for the Astarte device class. | |
| ~DeviceGrpc () override | |
| Virtual destructor. | |
| DeviceGrpc (DeviceGrpc &other)=delete | |
| Device is non-copyable. | |
| DeviceGrpc (DeviceGrpc &&other)=delete | |
| Device is non-moveable. | |
| auto | operator= (DeviceGrpc &other) -> DeviceGrpc &=delete |
| Device is non-copyable. | |
| auto | operator= (DeviceGrpc &&other) -> DeviceGrpc &=delete |
| Device is non-moveable. | |
| 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. | |
Class for the Astarte devices.
This class should be instantiated once and then used to communicate with Astarte via the gRPC transport layer.
| astarte::device::grpc::DeviceGrpc::DeviceGrpc | ( | const std::string & | server_addr, |
| const std::string & | node_uuid ) |
Constructor for the Astarte device class.
| [in] | server_addr | The gRPC server address of the Astarte message hub. |
| [in] | node_uuid | The UUID identifier for this device with the Astarte message hub. |
|
override |
Virtual destructor.
|
delete |
Device is non-copyable.
|
delete |
Device is non-moveable.
|
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 transport layer and starts a background routine to maintain connectivity.
Implements astarte::device::Device.
|
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.
|
delete |
Device is non-moveable.
|
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.