Astarte device API for C++ 0.6.2
Astarte device SDK for C++
Loading...
Searching...
No Matches
device_grpc.hpp
Go to the documentation of this file.
1// (C) Copyright 2025, SECO Mind Srl
2//
3// SPDX-License-Identifier: Apache-2.0
4
5#ifndef ASTARTE_DEVICE_SDK_DEVICE_GRPC_H
6#define ASTARTE_DEVICE_SDK_DEVICE_GRPC_H
7
12
13#include <chrono>
14#include <filesystem>
15#include <memory>
16#include <optional>
17#include <string>
18#include <string_view>
19
24
26namespace AstarteDeviceSdk {
27
33 public:
39 AstarteDeviceGRPC(const std::string& server_addr, const std::string& node_uuid);
49 auto operator=(AstarteDeviceGRPC&& other) -> AstarteDeviceGRPC& = delete;
50
55 void add_interface_from_json(const std::filesystem::path& json_file) override;
60 void add_interface_from_str(std::string json) override;
65 void add_interface_from_str(std::string_view json) override;
71 void connect() override;
77 // NOLINTNEXTLINE(misc-include-cleaner)
78 [[nodiscard]] auto is_connected(const std::chrono::milliseconds& timeout) const -> bool override;
80 void disconnect() override;
88 void send_individual(const std::string& interface_name, const std::string& path,
89 const AstarteData& data,
90 const std::chrono::system_clock::time_point* timestamp) override;
98 void send_object(const std::string& interface_name, const std::string& path,
99 const AstarteDatastreamObject& object,
100 const std::chrono::system_clock::time_point* timestamp) override;
107 void set_property(const std::string& interface_name, const std::string& path,
108 const AstarteData& data) override;
114 void unset_property(const std::string& interface_name, const std::string& path) override;
120 auto poll_incoming(const std::chrono::milliseconds& timeout)
121 -> std::optional<AstarteMessage> override;
122
123 private:
124 struct AstarteDeviceGRPCImpl;
125 std::shared_ptr<AstarteDeviceGRPCImpl> astarte_device_impl_;
126};
127
128} // namespace AstarteDeviceSdk
129
130#endif // ASTARTE_DEVICE_SDK_DEVICE_GRPC_H
Astarte data class, representing the basic Astarte types.
Definition data.hpp:76
Astarte object class, representing the Astarte object datastream data.
Definition object.hpp:22
void disconnect() override
Disconnect from Astarte.
void connect() override
Connect the device to Astarte.
auto operator=(AstarteDeviceGRPC &&other) -> AstarteDeviceGRPC &=delete
Move assignment operator for the Astarte device class.
auto poll_incoming(const std::chrono::milliseconds &timeout) -> std::optional< AstarteMessage > override
Poll incoming messages.
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.
auto operator=(AstarteDeviceGRPC &other) -> AstarteDeviceGRPC &=delete
Copy assignment operator for the Astarte device class.
AstarteDeviceGRPC(AstarteDeviceGRPC &other)=delete
Copy constructor for the Astarte device class.
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 add_interface_from_str(std::string_view json) override
Add an interface for the device from a json file.
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.
void unset_property(const std::string &interface_name, const std::string &path) override
Unset a device property.
void set_property(const std::string &interface_name, const std::string &path, const AstarteData &data) override
Set a device property.
AstarteDeviceGRPC(AstarteDeviceGRPC &&other)=delete
Move constructor 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.
auto is_connected(const std::chrono::milliseconds &timeout) const -> bool override
Check if the device is connected.
void add_interface_from_str(std::string json) override
Add an interface for the device from a json string.
AstarteDevice(const AstarteDevice &other)=delete
Copy constructor for the Astarte device class.
Astarte data class and its related methods.
Abstract Astarte device object and its related methods.
Astarte message class and its related methods.
Umbrella namespace for the Astarte device SDK.
Definition data.hpp:25
Astarte object class and its related methods.