Astarte device API for C++ 0.8.1
Astarte device SDK for C++
Loading...
Searching...
No Matches
AstarteDeviceSdk::AstarteDeviceGrpc Class Reference

Class for the Astarte devices. More...

#include <device_grpc.hpp>

+ Inheritance diagram for AstarteDeviceSdk::AstarteDeviceGrpc:

Public Member Functions

 AstarteDeviceGrpc (const std::string &server_addr, const std::string &node_uuid)
 Constructor for the Astarte device class.
 
 ~AstarteDeviceGrpc () override
 Destructor for the Astarte device class.
 
 AstarteDeviceGrpc (AstarteDeviceGrpc &other)=delete
 Copy constructor for the Astarte device class.
 
 AstarteDeviceGrpc (AstarteDeviceGrpc &&other)=delete
 Move constructor for the Astarte device class.
 
auto operator= (AstarteDeviceGrpc &other) -> AstarteDeviceGrpc &=delete
 Copy assignment operator for the Astarte device class.
 
auto operator= (AstarteDeviceGrpc &&other) -> AstarteDeviceGrpc &=delete
 Move assignment operator for the Astarte device class.
 
auto add_interface_from_file (const std::filesystem::path &json_file) -> astarte_tl::expected< void, AstarteError > override
 Add an interface for the device from a JSON file.
 
auto add_interface_from_str (std::string_view json) -> astarte_tl::expected< void, AstarteError > override
 Add an interface for the device from a JSON string view.
 
auto remove_interface (const std::string &interface_name) -> astarte_tl::expected< void, AstarteError > override
 Remove an installed interface.
 
auto connect () -> astarte_tl::expected< void, AstarteError > override
 Connect the device to Astarte.
 
auto is_connected () const -> bool override
 Check if the device is connected.
 
auto disconnect () -> astarte_tl::expected< void, AstarteError > override
 Disconnect from Astarte.
 
auto send_individual (std::string_view interface_name, std::string_view path, const AstarteData &data, const std::chrono::system_clock::time_point *timestamp) -> astarte_tl::expected< void, AstarteError > override
 Send individual data to Astarte.
 
auto send_object (std::string_view interface_name, std::string_view path, const AstarteDatastreamObject &object, const std::chrono::system_clock::time_point *timestamp) -> astarte_tl::expected< void, AstarteError > override
 Send object data to Astarte.
 
auto set_property (std::string_view interface_name, std::string_view path, const AstarteData &data) -> astarte_tl::expected< void, AstarteError > override
 Set a device property.
 
auto unset_property (std::string_view interface_name, std::string_view path) -> astarte_tl::expected< void, AstarteError > override
 Unset a device property.
 
auto poll_incoming (const std::chrono::milliseconds &timeout) -> std::optional< AstarteMessage > override
 Poll incoming messages.
 
auto get_all_properties (const std::optional< AstarteOwnership > &ownership) -> astarte_tl::expected< std::list< AstarteStoredProperty >, AstarteError >
 Get all stored properties matching the input filter.
 
auto get_properties (std::string_view interface_name) -> astarte_tl::expected< std::list< AstarteStoredProperty >, AstarteError >
 Get stored properties matching the interface.
 
auto get_property (std::string_view interface_name, std::string_view path) -> astarte_tl::expected< AstartePropertyIndividual, AstarteError >
 Get a single stored property matching the interface name and path.
 
- Public Member Functions inherited from AstarteDeviceSdk::AstarteDevice
virtual ~AstarteDevice ()=default
 Virtual destructor.
 
 AstarteDevice (const AstarteDevice &other)=delete
 Copy constructor for the Astarte device class.
 
 AstarteDevice (AstarteDevice &&other)=default
 Move constructor for the Astarte device class.
 
auto operator= (const AstarteDevice &other) -> AstarteDevice &=delete
 Copy assignment operator for the Astarte device class.
 
auto operator= (AstarteDevice &&other) -> AstarteDevice &=default
 Move assignment operator for the Astarte device class.
 

Additional Inherited Members

- Protected Member Functions inherited from AstarteDeviceSdk::AstarteDevice
 AstarteDevice ()=default
 Protected default constructor.
 

Detailed Description

Class for the Astarte devices.

This class should be instantiated once and then used to communicate with Astarte.

Constructor & Destructor Documentation

◆ AstarteDeviceGrpc() [1/3]

AstarteDeviceSdk::AstarteDeviceGrpc::AstarteDeviceGrpc ( const std::string & server_addr,
const std::string & node_uuid )

Constructor for the Astarte device class.

Parameters
server_addrThe gRPC server address of the Astarte message hub.
node_uuidThe UUID identifier for this device with the Astarte message hub.

◆ ~AstarteDeviceGrpc()

AstarteDeviceSdk::AstarteDeviceGrpc::~AstarteDeviceGrpc ( )
override

Destructor for the Astarte device class.

◆ AstarteDeviceGrpc() [2/3]

AstarteDeviceSdk::AstarteDeviceGrpc::AstarteDeviceGrpc ( AstarteDeviceGrpc & other)
delete

Copy constructor for the Astarte device class.

◆ AstarteDeviceGrpc() [3/3]

AstarteDeviceSdk::AstarteDeviceGrpc::AstarteDeviceGrpc ( AstarteDeviceGrpc && other)
delete

Move constructor for the Astarte device class.

Member Function Documentation

◆ add_interface_from_file()

auto AstarteDeviceSdk::AstarteDeviceGrpc::add_interface_from_file ( const std::filesystem::path & json_file) -> astarte_tl::expected< void, AstarteError >
overridevirtual

Add an interface for the device from a JSON file.

Parameters
json_fileThe path to the .json interface file.
Returns
An error if generated.

Implements AstarteDeviceSdk::AstarteDevice.

◆ add_interface_from_str()

auto AstarteDeviceSdk::AstarteDeviceGrpc::add_interface_from_str ( std::string_view json) -> astarte_tl::expected< void, AstarteError >
overridevirtual

Add an interface for the device from a JSON string view.

Parameters
jsonThe interface definition as a JSON string view.
Returns
An error if generated.

Implements AstarteDeviceSdk::AstarteDevice.

◆ connect()

auto AstarteDeviceSdk::AstarteDeviceGrpc::connect ( ) -> astarte_tl::expected< void, AstarteError >
overridevirtual

Connect the device to Astarte.

This is an asynchronous funciton. It will start a management thread that will manage the device connectivity.

Returns
An error if generated.

Implements AstarteDeviceSdk::AstarteDevice.

◆ disconnect()

auto AstarteDeviceSdk::AstarteDeviceGrpc::disconnect ( ) -> astarte_tl::expected< void, AstarteError >
overridevirtual

Disconnect from Astarte.

Returns
An error if generated.

Implements AstarteDeviceSdk::AstarteDevice.

◆ get_all_properties()

auto AstarteDeviceSdk::AstarteDeviceGrpc::get_all_properties ( const std::optional< AstarteOwnership > & ownership) -> astarte_tl::expected< std::list< AstarteStoredProperty >, AstarteError >

Get all stored properties matching the input filter.

Parameters
ownershipOptional ownership filter.
Returns
A list of stored properties, as returned by the message hub, or an error upon failure.

◆ get_properties()

auto AstarteDeviceSdk::AstarteDeviceGrpc::get_properties ( std::string_view interface_name) -> astarte_tl::expected< std::list< AstarteStoredProperty >, AstarteError >

Get stored properties matching the interface.

Parameters
interface_nameThe name of the interface for the properties.
Returns
A list of stored properties, as returned by the message hub, or an error upon failure.

◆ get_property()

auto AstarteDeviceSdk::AstarteDeviceGrpc::get_property ( std::string_view interface_name,
std::string_view path ) -> astarte_tl::expected< AstartePropertyIndividual, AstarteError >

Get a single stored property matching the interface name and path.

Parameters
interface_nameThe name of the interface for the property.
pathExact path for the property.
Returns
The stored property, as returned by the message hub, or an error upon failure.

◆ is_connected()

auto AstarteDeviceSdk::AstarteDeviceGrpc::is_connected ( ) const -> bool
nodiscardoverridevirtual

Check if the device is connected.

Returns
True if the device is connected to the message hub, false otherwise.

Implements AstarteDeviceSdk::AstarteDevice.

◆ operator=() [1/2]

auto AstarteDeviceSdk::AstarteDeviceGrpc::operator= ( AstarteDeviceGrpc && other) -> AstarteDeviceGrpc &=delete
delete

Move assignment operator for the Astarte device class.

◆ operator=() [2/2]

auto AstarteDeviceSdk::AstarteDeviceGrpc::operator= ( AstarteDeviceGrpc & other) -> AstarteDeviceGrpc &=delete
delete

Copy assignment operator for the Astarte device class.

◆ poll_incoming()

auto AstarteDeviceSdk::AstarteDeviceGrpc::poll_incoming ( const std::chrono::milliseconds & timeout) -> std::optional< AstarteMessage >
overridevirtual

Poll incoming messages.

Parameters
timeoutWill block for this timeout if no message is present.
Returns
The received message when present, std::nullopt otherwise.

Implements AstarteDeviceSdk::AstarteDevice.

◆ remove_interface()

auto AstarteDeviceSdk::AstarteDeviceGrpc::remove_interface ( const std::string & interface_name) -> astarte_tl::expected< void, AstarteError >
overridevirtual

Remove an installed interface.

Parameters
interface_nameThe interface name.
Returns
An error if generated.

Implements AstarteDeviceSdk::AstarteDevice.

◆ send_individual()

auto AstarteDeviceSdk::AstarteDeviceGrpc::send_individual ( std::string_view interface_name,
std::string_view path,
const AstarteData & data,
const std::chrono::system_clock::time_point * timestamp ) -> astarte_tl::expected< void, AstarteError >
overridevirtual

Send individual data to Astarte.

Parameters
interface_nameThe name of the interface on which to send the data.
pathThe path to the interface endpoint to use for sending.
dataThe data to send.
timestampThe timestamp for the data, this might be a nullptr.
Returns
An error if generated.

Implements AstarteDeviceSdk::AstarteDevice.

◆ send_object()

auto AstarteDeviceSdk::AstarteDeviceGrpc::send_object ( std::string_view interface_name,
std::string_view path,
const AstarteDatastreamObject & object,
const std::chrono::system_clock::time_point * timestamp ) -> astarte_tl::expected< void, AstarteError >
overridevirtual

Send object data to Astarte.

Parameters
interface_nameThe name of the interface on which to send the data.
pathThe common path to the interface endpoint to use for sending.
objectThe data to send.
timestampThe timestamp for the data, this might be a nullptr.
Returns
An error if generated.

Implements AstarteDeviceSdk::AstarteDevice.

◆ set_property()

auto AstarteDeviceSdk::AstarteDeviceGrpc::set_property ( std::string_view interface_name,
std::string_view path,
const AstarteData & data ) -> astarte_tl::expected< void, AstarteError >
overridevirtual

Set a device property.

Parameters
interface_nameThe name of the interface for the property.
pathThe property full path.
dataThe property data.
Returns
An error if generated.

Implements AstarteDeviceSdk::AstarteDevice.

◆ unset_property()

auto AstarteDeviceSdk::AstarteDeviceGrpc::unset_property ( std::string_view interface_name,
std::string_view path ) -> astarte_tl::expected< void, AstarteError >
overridevirtual

Unset a device property.

Parameters
interface_nameThe name of the interface for the property.
pathThe property full path.
Returns
An error if generated.

Implements AstarteDeviceSdk::AstarteDevice.


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