Astarte device API for C++ 0.6.2
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.
 
auto operator= (AstarteDeviceGRPC &other) -> AstarteDeviceGRPC &=delete
 Copy assignment operator for the Astarte device class.
 
 AstarteDeviceGRPC (AstarteDeviceGRPC &&other)=delete
 Move constructor for the Astarte device class.
 
auto operator= (AstarteDeviceGRPC &&other) -> AstarteDeviceGRPC &=delete
 Move assignment operator for the Astarte device class.
 
void add_interface_from_json (const std::filesystem::path &json_file) override
 Add an interface for the device from a json file.
 
void add_interface_from_str (std::string json) override
 Add an interface for the device from a json string.
 
void add_interface_from_str (std::string_view json) override
 Add an interface for the device from a json file.
 
void connect () override
 Connect the device to Astarte.
 
auto is_connected (const std::chrono::milliseconds &timeout) const -> bool override
 Check if the device is connected.
 
void disconnect () override
 Disconnect from Astarte.
 
void send_individual (const std::string &interface_name, const std::string &path, const AstarteData &data, const std::chrono::system_clock::time_point *timestamp) override
 Send individual data to Astarte.
 
void send_object (const std::string &interface_name, const std::string &path, const AstarteDatastreamObject &object, const std::chrono::system_clock::time_point *timestamp) override
 Send object data to Astarte.
 
void set_property (const std::string &interface_name, const std::string &path, const AstarteData &data) override
 Set a device property.
 
void unset_property (const std::string &interface_name, const std::string &path) override
 Unset a device property.
 
auto poll_incoming (const std::chrono::milliseconds &timeout) -> std::optional< AstarteMessage > override
 Poll incoming messages.
 
- Public Member Functions inherited from AstarteDeviceSdk::AstarteDevice
virtual ~AstarteDevice ()=default
 Virtual destructor.
 
 AstarteDevice (const AstarteDevice &other)=delete
 Copy constructor for the Astarte device class.
 
auto operator= (const AstarteDevice &other) -> AstarteDevice &=delete
 Copy assignment operator for the Astarte device class.
 
 AstarteDevice (AstarteDevice &&other)=default
 Move constructor 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_json()

void AstarteDeviceSdk::AstarteDeviceGRPC::add_interface_from_json ( const std::filesystem::path & json_file)
overridevirtual

Add an interface for the device from a json file.

Parameters
json_fileThe path to the .json interface file.

Implements AstarteDeviceSdk::AstarteDevice.

◆ add_interface_from_str() [1/2]

void AstarteDeviceSdk::AstarteDeviceGRPC::add_interface_from_str ( std::string json)
overridevirtual

Add an interface for the device from a json string.

Parameters
jsonThe interface to add.

Implements AstarteDeviceSdk::AstarteDevice.

◆ add_interface_from_str() [2/2]

void AstarteDeviceSdk::AstarteDeviceGRPC::add_interface_from_str ( std::string_view json)
overridevirtual

Add an interface for the device from a json file.

Parameters
jsonThe interface to add.

Implements AstarteDeviceSdk::AstarteDevice.

◆ connect()

void AstarteDeviceSdk::AstarteDeviceGRPC::connect ( )
overridevirtual

Connect the device to Astarte.

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

Implements AstarteDeviceSdk::AstarteDevice.

◆ disconnect()

void AstarteDeviceSdk::AstarteDeviceGRPC::disconnect ( )
overridevirtual

Disconnect from Astarte.

Implements AstarteDeviceSdk::AstarteDevice.

◆ is_connected()

auto AstarteDeviceSdk::AstarteDeviceGRPC::is_connected ( const std::chrono::milliseconds & timeout) const -> bool
nodiscardoverridevirtual

Check if the device is connected.

Parameters
timeoutThis is the maximum timeout used to 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.

◆ send_individual()

void AstarteDeviceSdk::AstarteDeviceGRPC::send_individual ( const std::string & interface_name,
const std::string & path,
const AstarteData & data,
const std::chrono::system_clock::time_point * timestamp )
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.

Implements AstarteDeviceSdk::AstarteDevice.

◆ send_object()

void AstarteDeviceSdk::AstarteDeviceGRPC::send_object ( const std::string & interface_name,
const std::string & path,
const AstarteDatastreamObject & object,
const std::chrono::system_clock::time_point * timestamp )
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.

Implements AstarteDeviceSdk::AstarteDevice.

◆ set_property()

void AstarteDeviceSdk::AstarteDeviceGRPC::set_property ( const std::string & interface_name,
const std::string & path,
const AstarteData & data )
overridevirtual

Set a device property.

Parameters
interface_nameThe name of the interface for the property.
pathThe property full path.
dataThe property data.

Implements AstarteDeviceSdk::AstarteDevice.

◆ unset_property()

void AstarteDeviceSdk::AstarteDeviceGRPC::unset_property ( const std::string & interface_name,
const std::string & path )
overridevirtual

Unset a device property.

Parameters
interface_nameThe name of the interface for the property.
pathThe property full path.

Implements AstarteDeviceSdk::AstarteDevice.


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