Functions for device management.
More...
|
astarte_result_t | astarte_device_new (astarte_device_config_t *cfg, astarte_device_handle_t *device) |
| Allocate a new instance of an Astarte device.
|
|
astarte_result_t | astarte_device_destroy (astarte_device_handle_t device) |
| Destroy the Astarte device instance.
|
|
astarte_result_t | astarte_device_add_interface (astarte_device_handle_t device, const astarte_interface_t *interface) |
| add an interface to the device.
|
|
astarte_result_t | astarte_device_connect (astarte_device_handle_t device) |
| Connect a device to Astarte.
|
|
astarte_result_t | astarte_device_disconnect (astarte_device_handle_t device) |
| Disconnect the Astarte device instance.
|
|
astarte_result_t | astarte_device_poll (astarte_device_handle_t device) |
| Poll data from Astarte.
|
|
astarte_result_t | astarte_device_stream_individual (astarte_device_handle_t device, const char *interface_name, const char *path, astarte_individual_t individual, const int64_t *timestamp) |
| Send an individual value through the device connection.
|
|
astarte_result_t | astarte_device_stream_aggregated (astarte_device_handle_t device, const char *interface_name, const char *path, astarte_object_entry_t *entries, size_t entries_len, const int64_t *timestamp) |
| Send an aggregated object through the device connection.
|
|
astarte_result_t | astarte_device_set_property (astarte_device_handle_t device, const char *interface_name, const char *path, astarte_individual_t individual) |
| Set a device property to the provided individual value.
|
|
astarte_result_t | astarte_device_unset_property (astarte_device_handle_t device, const char *interface_name, const char *path) |
| Unset a device property.
|
|
Functions for device management.
◆ astarte_device_connection_cbk_t
Function pointer for connection events.
◆ astarte_device_datastream_individual_cbk_t
Function pointer for datastream individual events.
◆ astarte_device_datastream_object_cbk_t
Function pointer for datastream object events.
◆ astarte_device_disconnection_cbk_t
Function pointer for disconnection events.
◆ astarte_device_handle_t
Handle for an instance of an Astarte device.
Each handle is a pointer to an opaque internally allocated data struct containing all the data for the Astarte device.
◆ astarte_device_property_set_cbk_t
Function pointer for property set events.
◆ astarte_device_property_unset_cbk_t
Function pointer for property unset events.
◆ astarte_device_add_interface()
add an interface to the device.
- Warning
- This function has to be called while the device is in the disconnected state, before a call to astarte_device_connect or after a call to astarte_device_disconnect.
- Note
- The user is responsible for making sure the interface struct remains valid for the lifetime of the device. It is recommended to declare interface structs as static constants.
- Parameters
-
device | A valid Astarte device handle. |
interface | The interface to add to the device. |
- Returns
- ASTARTE_RESULT_OK if successful, otherwise an error code.
◆ astarte_device_connect()
Connect a device to Astarte.
- Parameters
-
[in] | device | Device instance to connect to Astarte. |
- Returns
- ASTARTE_RESULT_OK if successful, otherwise an error code.
◆ astarte_device_destroy()
Destroy the Astarte device instance.
- Note
- The device handle will become invalid after this operation.
- Parameters
-
[in] | device | Device instance to be destroyed. |
- Returns
- ASTARTE_RESULT_OK if successful, otherwise an error code.
◆ astarte_device_disconnect()
Disconnect the Astarte device instance.
- Note
- It will be possible to re-connect the device after disconnection.
- Parameters
-
[in] | device | Device instance to be disconnected. |
- Returns
- ASTARTE_RESULT_OK if successful, otherwise an error code.
◆ astarte_device_new()
Allocate a new instance of an Astarte device.
This function has to be called to initialize the device SDK before doing anything else. If an error code is returned the astarte_device_free function must not be called.
- Note
- A device can be instantiated and connected to Astarte only if it has been previously registered on Astarte.
- Parameters
-
[in] | cfg | Configuration struct. |
[out] | device | Device instance initialized. |
- Returns
- ASTARTE_RESULT_OK if successful, otherwise an error code.
◆ astarte_device_poll()
Poll data from Astarte.
- Parameters
-
[in] | device | Device instance to poll data from Astarte. |
- Returns
- ASTARTE_RESULT_OK if successful, otherwise an error code.
◆ astarte_device_set_property()
Set a device property to the provided individual value.
- Parameters
-
[in] | device | Handle to the device instance. |
[in] | interface_name | Interface of the property. |
[in] | path | Path of the property. |
[in] | individual | New individual value for the property. |
- Returns
- ASTARTE_RESULT_OK if successful, otherwise an error code.
◆ astarte_device_stream_aggregated()
Send an aggregated object through the device connection.
- Parameters
-
[in] | device | Handle to the device instance. |
[in] | interface_name | Interface where to publish data. |
[in] | path | Path where to publish data. |
[in] | entries | The object entries to stream, organized as an array. |
[in] | entries_len | The number of element in the entries array. |
[in] | timestamp | Timestamp of the message, ignored if set to NULL. |
- Returns
- ASTARTE_RESULT_OK if successful, otherwise an error code.
◆ astarte_device_stream_individual()
Send an individual value through the device connection.
- Parameters
-
[in] | device | Handle to the device instance. |
[in] | interface_name | Interface where to publish data. |
[in] | path | Path where to publish data. |
[in] | individual | Astarte individual value to stream. |
[in] | timestamp | Timestamp of the message, ignored if set to NULL. |
- Returns
- ASTARTE_RESULT_OK if successful, otherwise an error code.
◆ astarte_device_unset_property()
Unset a device property.
- Parameters
-
[in] | device | Handle to the device instance. |
[in] | interface_name | Interface of the property. |
[in] | path | Path of the property. |
- Returns
- ASTARTE_RESULT_OK if successful, otherwise an error code.