Astarte device API for Zephyr 0.7.2
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
46
49
56
59
68
75
79
87
91
98
101
104
105#if defined(CONFIG_ASTARTE_DEVICE_SDK_PERMANENT_STORAGE)
107typedef struct
108{
110 const char *interface_name;
111 const char *path;
112 astarte_individual_t individual;
113 void *user_data;
114} astarte_device_property_loader_event_t;
115
117typedef void (*astarte_device_property_loader_cbk_t)(astarte_device_property_loader_event_t event);
118#endif
119
161
162#ifdef __cplusplus
163extern "C" {
164#endif
165
180
191
206 astarte_device_handle_t device, const astarte_interface_t *interface);
207
215
228
242
250
262 const char *interface_name, const char *path, astarte_individual_t individual,
263 const int64_t *timestamp);
264
277 const char *interface_name, const char *path, astarte_object_entry_t *entries,
278 size_t entries_len, const int64_t *timestamp);
279
290 const char *interface_name, const char *path, astarte_individual_t individual);
291
301 astarte_device_handle_t device, const char *interface_name, const char *path);
302
303#if defined(CONFIG_ASTARTE_DEVICE_SDK_PERMANENT_STORAGE)
320astarte_result_t astarte_device_get_property(astarte_device_handle_t device,
321 const char *interface_name, const char *path, astarte_device_property_loader_cbk_t loader_cbk,
322 void *user_data);
323#endif
324
325#ifdef __cplusplus
326}
327#endif
328
333#endif /* ASTARTE_DEVICE_SDK_DEVICE_H */
Astarte types and defines.
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:31
void(* astarte_device_datastream_individual_cbk_t)(astarte_device_datastream_individual_event_t event)
Function pointer for datastream individual events.
Definition device.h:77
astarte_result_t astarte_device_unset_property(astarte_device_handle_t device, const char *interface_name, const char *path)
Unset a device property.
void(* astarte_device_property_unset_cbk_t)(astarte_device_data_event_t event)
Function pointer for property unset events.
Definition device.h:103
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.
void(* astarte_device_property_set_cbk_t)(astarte_device_property_set_event_t event)
Function pointer for property set events.
Definition device.h:100
astarte_result_t astarte_device_destroy(astarte_device_handle_t device)
Destroy the Astarte device instance.
astarte_result_t astarte_device_poll(astarte_device_handle_t device)
Poll data from Astarte.
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_connect(astarte_device_handle_t device)
Connect a device to Astarte.
void(* astarte_device_datastream_object_cbk_t)(astarte_device_datastream_object_event_t event)
Function pointer for datastream object events.
Definition device.h:89
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.
void(* astarte_device_connection_cbk_t)(astarte_device_connection_event_t event)
Function pointer for connection events.
Definition device.h:48
void(* astarte_device_disconnection_cbk_t)(astarte_device_disconnection_event_t event)
Function pointer for disconnection events.
Definition device.h:58
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_force_disconnect(astarte_device_handle_t device)
Force a disconnection for the Astarte device instance.
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_disconnect(astarte_device_handle_t device, k_timeout_t timeout)
Disconnect the Astarte device instance.
#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
Definitions for Astarte individual data types.
Astarte interface representation.
Definitions for Astarte object data types.
Functions for device pairing.
Astarte result types.
Configuration struct for an Astarte device.
Definition device.h:127
astarte_device_datastream_individual_cbk_t datastream_individual_cbk
Optional callback for a datastream individual reception event.
Definition device.h:147
int32_t mqtt_poll_timeout_ms
Polling timeout for the MQTT client.
Definition device.h:137
astarte_device_disconnection_cbk_t disconnection_cbk
Optional callback for a disconnection event.
Definition device.h:145
astarte_device_property_set_cbk_t property_set_cbk
Optional callback for a set property event.
Definition device.h:151
size_t interfaces_size
Number of elements in the interfaces array.
Definition device.h:159
void * cbk_user_data
User data passed to each callback function.
Definition device.h:155
astarte_device_property_unset_cbk_t property_unset_cbk
Optional callback for a unset property event.
Definition device.h:153
int32_t http_timeout_ms
Timeout for HTTP requests.
Definition device.h:129
const astarte_interface_t ** interfaces
Array of interfaces to be added to the device.
Definition device.h:157
int32_t mqtt_connection_timeout_ms
Connection timeout period.
Definition device.h:135
astarte_device_connection_cbk_t connection_cbk
Optional callback for a connection event.
Definition device.h:143
astarte_device_datastream_object_cbk_t datastream_object_cbk
Optional callback for a datastream object reception event.
Definition device.h:149
Context for a single connection event.
Definition device.h:42
astarte_device_handle_t device
Handle to the device triggering the event.
Definition device.h:43
void * user_data
User data configured during device initialization.
Definition device.h:44
Common context for all data events.
Definition device.h:62
const char * interface_name
Name of the interface on which the event is triggered.
Definition device.h:64
void * user_data
User data configured during device initialization.
Definition device.h:66
astarte_device_handle_t device
Handle to the device triggering the event.
Definition device.h:63
const char * path
Path on which event is triggered.
Definition device.h:65
Context for a single datastream individual event.
Definition device.h:71
astarte_device_data_event_t data_event
Generic data event context.
Definition device.h:72
astarte_individual_t individual
Received data from Astarte.
Definition device.h:73
Context for a single datastream object event.
Definition device.h:82
size_t entries_len
Length of the array of Astarte object entries.
Definition device.h:85
astarte_object_entry_t * entries
Received data from Astarte, as an array of entries.
Definition device.h:84
astarte_device_data_event_t data_event
Generic data event context.
Definition device.h:83
Context for a single disconnection event.
Definition device.h:52
void * user_data
User data configured during device initialization.
Definition device.h:54
astarte_device_handle_t device
Handle to the device triggering the event.
Definition device.h:53
Context for a single property set event.
Definition device.h:94
astarte_device_data_event_t data_event
Generic data event context.
Definition device.h:95
astarte_individual_t individual
Received data from Astarte.
Definition device.h:96
Base Astarte individual data type.
Definition individual.h:128
Astarte interface definition.
Definition interface.h:79
Object entry data type.
Definition object.h:40