Astarte device API for Zephyr 0.9.0
Astarte device SDK for Zephyr RTOS
Loading...
Searching...
No Matches
device.h
Go to the documentation of this file.
1/*
2 * (C) Copyright 2024, SECO Mind Srl
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ASTARTE_DEVICE_SDK_DEVICE_H
8#define ASTARTE_DEVICE_SDK_DEVICE_H
9
22#include <zephyr/kernel.h>
23
31
38typedef struct astarte_device *astarte_device_handle_t;
39
51
58
64
70
78
85
93
100
116
117#ifdef CONFIG_ASTARTE_DEVICE_SDK_PERMANENT_STORAGE
119typedef struct
120{
122 const char *interface_name;
123 const char *path;
124 astarte_data_t data;
125 void *user_data;
126} astarte_device_property_loader_event_t;
127
129typedef void (*astarte_device_property_loader_cbk_t)(astarte_device_property_loader_event_t event);
130#endif
131
159
160#ifdef __cplusplus
161extern "C" {
162#endif
163
181
192
205 astarte_device_handle_t device, const astarte_interface_t *interface);
206
219 astarte_device_handle_t device, const astarte_interface_t *interface);
220
228
241
255
267 const char *interface_name, const char *path, astarte_data_t data, const int64_t *timestamp);
268
281 const char *interface_name, const char *path, astarte_object_entry_t *entries,
282 size_t entries_len, const int64_t *timestamp);
283
294 const char *interface_name, const char *path, astarte_data_t data);
295
305 astarte_device_handle_t device, const char *interface_name, const char *path);
306
307#ifdef CONFIG_ASTARTE_DEVICE_SDK_PERMANENT_STORAGE
324astarte_result_t astarte_device_get_property(astarte_device_handle_t device,
325 const char *interface_name, const char *path, astarte_device_property_loader_cbk_t loader_cbk,
326 void *user_data);
327#endif
328
341 astarte_device_handle_t device, astarte_device_event_t *event, k_timeout_t timeout);
342
349
350#ifdef __cplusplus
351}
352#endif
353
358#endif /* ASTARTE_DEVICE_SDK_DEVICE_H */
Global Astarte includes and defines.
Definitions for Astarte base data type.
Functions for the generation of Astarte device identifiers.
#define ASTARTE_DEVICE_ID_LEN
Number of characters in the string version of an Astarte device ID.
Definition device_id.h:33
astarte_result_t astarte_device_unset_property(astarte_device_handle_t device, const char *interface_name, const char *path)
Unset a device property.
astarte_device_event_type_t
Type of device event.
Definition device.h:42
astarte_result_t astarte_device_destroy(astarte_device_handle_t device)
Destroy the Astarte device instance.
astarte_result_t astarte_device_send_object(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.
void astarte_device_event_cleanup(astarte_device_event_t *event)
Cleanup an Astarte device event.
astarte_result_t astarte_device_new(astarte_device_config_t *cfg, astarte_device_handle_t *device)
Initialize the Astarte device.
astarte_result_t astarte_device_connect(astarte_device_handle_t device)
Connect a device to Astarte.
astarte_result_t astarte_device_remove_interface(astarte_device_handle_t device, const astarte_interface_t *interface)
Remove an interface from the device.
struct astarte_device * astarte_device_handle_t
Handle for an instance of an Astarte device.
Definition device.h:38
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_send_individual(astarte_device_handle_t device, const char *interface_name, const char *path, astarte_data_t data, const int64_t *timestamp)
Send a value through the device connection.
astarte_result_t astarte_device_force_disconnect(astarte_device_handle_t device)
Force a disconnection for the Astarte device instance.
astarte_result_t astarte_device_disconnect(astarte_device_handle_t device, k_timeout_t timeout)
Disconnect the Astarte device instance.
astarte_result_t astarte_device_set_property(astarte_device_handle_t device, const char *interface_name, const char *path, astarte_data_t data)
Set a device property to the provided value.
astarte_result_t astarte_device_get_event(astarte_device_handle_t device, astarte_device_event_t *event, k_timeout_t timeout)
Fetch the next error event from the Astarte device.
@ ASTARTE_DEVICE_EVENT_DATASTREAM_OBJECT
Datastream object event.
Definition device.h:47
@ ASTARTE_DEVICE_EVENT_PROPERTY_UNSET
Property unset event.
Definition device.h:49
@ ASTARTE_DEVICE_EVENT_PROPERTY_SET
Property set event.
Definition device.h:48
@ ASTARTE_DEVICE_EVENT_DATASTREAM_INDIVIDUAL
Datastream individual event.
Definition device.h:46
@ ASTARTE_DEVICE_EVENT_ERROR
Error event.
Definition device.h:43
@ ASTARTE_DEVICE_EVENT_DISCONNECTED
Disconnection event.
Definition device.h:45
@ ASTARTE_DEVICE_EVENT_CONNECTED
Connection event.
Definition device.h:44
#define ASTARTE_PAIRING_CRED_SECR_LEN
Number of characters in the string representation of a Base64 encoded credential secret.
Definition pairing.h:26
astarte_result_t
Astarte Device SDK return codes.
Definition result.h:31
Astarte interface representation.
Definitions for Astarte object data types.
Functions for device pairing.
Astarte result types.
Base Astarte data type.
Definition data.h:122
Configuration struct for an Astarte device.
Definition device.h:139
int32_t mqtt_poll_timeout_ms
Polling timeout for the MQTT client.
Definition device.h:149
size_t interfaces_size
Number of elements in the interfaces array.
Definition device.h:157
int32_t http_timeout_ms
Timeout for HTTP requests.
Definition device.h:141
const astarte_interface_t ** interfaces
Array of interfaces to be added to the device.
Definition device.h:155
int32_t mqtt_connection_timeout_ms
Connection timeout period.
Definition device.h:147
Context for a single connection event.
Definition device.h:61
astarte_device_handle_t device
Handle to the device triggering the event.
Definition device.h:62
Common context for all data events.
Definition device.h:73
const char * interface_name
Name of the interface on which the event is triggered.
Definition device.h:75
astarte_device_handle_t device
Handle to the device triggering the event.
Definition device.h:74
const char * path
Path on which event is triggered.
Definition device.h:76
Context for a single datastream individual event.
Definition device.h:81
astarte_data_t data
Received data from Astarte.
Definition device.h:83
astarte_device_data_event_t base_event
Generic data event context.
Definition device.h:82
Context for a single datastream object event.
Definition device.h:88
size_t entries_len
Length of the array of Astarte object entries.
Definition device.h:91
astarte_object_entry_t * entries
Received data from Astarte, as an array of entries.
Definition device.h:90
astarte_device_data_event_t base_event
Generic data event context.
Definition device.h:89
Context for a single disconnection event.
Definition device.h:67
astarte_device_handle_t device
Handle to the device triggering the event.
Definition device.h:68
Context for a single error event.
Definition device.h:54
const char * context
Optional string describing where the error occurred.
Definition device.h:56
astarte_result_t result
The error code.
Definition device.h:55
Device event.
Definition device.h:103
astarte_device_event_type_t type
Type of device event.
Definition device.h:104
Context for a single property set event.
Definition device.h:96
astarte_device_data_event_t base_event
Generic data event context.
Definition device.h:97
astarte_data_t data
Received data from Astarte.
Definition device.h:98
Astarte interface definition.
Definition interface.h:79
Object entry data type.
Definition object.h:40