Astarte device API for C++ 0.7.1
Astarte device SDK for C++
Loading...
Searching...
No Matches
device.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_H
6#define ASTARTE_DEVICE_SDK_DEVICE_H
7
12
13#include <chrono>
14#include <filesystem>
15#include <optional>
16#include <string>
17#include <string_view>
18
22
24namespace AstarteDeviceSdk {
25
32 public:
37 virtual ~AstarteDevice() = default;
39 AstarteDevice(const AstarteDevice& other) = delete;
44 AstarteDevice(AstarteDevice&& other) = default;
46 auto operator=(const AstarteDevice& other) -> AstarteDevice& = delete;
52 auto operator=(AstarteDevice&& other) -> AstarteDevice& = default;
57 virtual void add_interface_from_file(const std::filesystem::path& json_file) = 0;
62 virtual void add_interface_from_str(std::string_view json) = 0;
67 virtual void remove_interface(const std::string& interface_name) = 0;
73 virtual void connect() = 0;
78 [[nodiscard]] virtual auto is_connected() const -> bool = 0;
82 virtual void disconnect() = 0;
90 virtual void send_individual(std::string_view interface_name, std::string_view path,
91 const AstarteData& data,
92 const std::chrono::system_clock::time_point* timestamp) = 0;
100 virtual void send_object(std::string_view interface_name, std::string_view path,
101 const AstarteDatastreamObject& object,
102 const std::chrono::system_clock::time_point* timestamp) = 0;
109 virtual void set_property(std::string_view interface_name, std::string_view path,
110 const AstarteData& data) = 0;
116 virtual void unset_property(std::string_view interface_name, std::string_view path) = 0;
123 virtual auto poll_incoming(const std::chrono::milliseconds& timeout)
124 -> std::optional<AstarteMessage> = 0;
125
126 protected:
131 AstarteDevice() = default;
132};
133
134} // namespace AstarteDeviceSdk
135
136#endif // ASTARTE_DEVICE_SDK_DEVICE_H
Astarte data class, representing the basic Astarte types.
Definition data.hpp:39
Astarte object class, representing the Astarte object datastream data.
Definition object.hpp:22
auto operator=(AstarteDevice &&other) -> AstarteDevice &=default
Move assignment operator for the Astarte device class.
AstarteDevice(AstarteDevice &&other)=default
Move constructor for the Astarte device class.
virtual void add_interface_from_file(const std::filesystem::path &json_file)=0
Add an interface for the device from a JSON file.
virtual void set_property(std::string_view interface_name, std::string_view path, const AstarteData &data)=0
Set a device property on Astarte.
virtual void unset_property(std::string_view interface_name, std::string_view path)=0
Unset a device property on Astarte.
virtual void send_individual(std::string_view interface_name, std::string_view path, const AstarteData &data, const std::chrono::system_clock::time_point *timestamp)=0
Send an individual data payload to Astarte.
virtual void connect()=0
Connect the device to Astarte.
virtual void remove_interface(const std::string &interface_name)=0
Remove an installed interface.
virtual void add_interface_from_str(std::string_view json)=0
Add an interface for the device from a JSON string view.
AstarteDevice(const AstarteDevice &other)=delete
Copy constructor for the Astarte device class.
virtual auto poll_incoming(const std::chrono::milliseconds &timeout) -> std::optional< AstarteMessage >=0
Poll for incoming messages from Astarte.
virtual void disconnect()=0
Disconnect the device from Astarte.
virtual void send_object(std::string_view interface_name, std::string_view path, const AstarteDatastreamObject &object, const std::chrono::system_clock::time_point *timestamp)=0
Send an aggregate object data payload to Astarte.
virtual ~AstarteDevice()=default
Virtual destructor.
virtual auto is_connected() const -> bool=0
Check if the device is connected to the Astarte message hub.
auto operator=(const AstarteDevice &other) -> AstarteDevice &=delete
Copy assignment operator for the Astarte device class.
Astarte message class, represents a full message for/from Astarte.
Definition msg.hpp:25
Astarte data class and its related methods.
Astarte message class and its related methods.
Umbrella namespace for the Astarte device SDK.
Definition data.hpp:22
Astarte object class and its related methods.