Astarte device API for Zephyr 0.9.0
Astarte device SDK for Zephyr RTOS
Loading...
Searching...
No Matches
data.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_DATA_H
8#define ASTARTE_DEVICE_SDK_DATA_H
9
25
27typedef struct
28{
29 const void *buf;
30 size_t len;
31} astarte_data_binaryblob_t;
32
34typedef struct
35{
37 const void **blobs;
39 size_t *sizes;
41 size_t count;
42} astarte_data_binaryblobarray_t;
43
45typedef struct
46{
47 const bool *buf;
48 size_t len;
49} astarte_data_booleanarray_t;
50
52typedef struct
53{
54 const double *buf;
55 size_t len;
56} astarte_data_doublearray_t;
57
59typedef struct
60{
61 const int32_t *buf;
62 size_t len;
63} astarte_data_integerarray_t;
64
66typedef struct
67{
68 const int64_t *buf;
69 size_t len;
70} astarte_data_longintegerarray_t;
71
73typedef struct
74{
75 const char **buf;
76 size_t len;
77} astarte_data_stringarray_t;
78
80typedef union
81{
83 astarte_data_binaryblob_t binaryblob;
85 bool boolean;
87 int64_t datetime;
89 double dbl;
91 int32_t integer;
93 int64_t longinteger;
95 const char *string;
96
98 astarte_data_binaryblobarray_t binaryblob_array;
100 astarte_data_booleanarray_t boolean_array;
102 astarte_data_longintegerarray_t datetime_array;
104 astarte_data_doublearray_t double_array;
106 astarte_data_integerarray_t integer_array;
108 astarte_data_longintegerarray_t longinteger_array;
110 astarte_data_stringarray_t string_array;
111} astarte_data_param_t;
112
121typedef struct
122{
124 astarte_data_param_t data;
130
131#ifdef __cplusplus
132extern "C" {
133#endif
134
142astarte_data_t astarte_data_from_binaryblob(const void *buf, size_t len);
185
196astarte_data_t astarte_data_from_binaryblob_array(const void **blobs, size_t *sizes, size_t count);
212astarte_data_t astarte_data_from_datetime_array(const int64_t *buf, size_t len);
220astarte_data_t astarte_data_from_double_array(const double *buf, size_t len);
228astarte_data_t astarte_data_from_integer_array(const int32_t *buf, size_t len);
244astarte_data_t astarte_data_from_string_array(const char **buf, size_t len);
245
253
262astarte_result_t astarte_data_to_binaryblob(astarte_data_t data, const void **buf, size_t *len);
311
322 astarte_data_t data, const void ***blobs, size_t **sizes, size_t *count);
341 astarte_data_t data, const int64_t **buf, size_t *len);
350astarte_result_t astarte_data_to_double_array(astarte_data_t data, const double **buf, size_t *len);
360 astarte_data_t data, const int32_t **buf, size_t *len);
370 astarte_data_t data, const int64_t **buf, size_t *len);
380
381#ifdef __cplusplus
382}
383#endif
384
389#endif /* ASTARTE_DEVICE_SDK_DATA_H */
Global Astarte includes and defines.
astarte_result_t astarte_data_to_binaryblob(astarte_data_t data, const void **buf, size_t *len)
Convert Astarte data (of the binary blob type) to an array of binary blobs.
astarte_data_t astarte_data_from_string(const char *val)
Initialize an astarte data from the input string.
astarte_data_t astarte_data_from_double(double val)
Initialize an astarte data from the input double.
astarte_result_t astarte_data_to_boolean(astarte_data_t data, bool *val)
Convert Astarte data (of the boolean type) to a bool.
astarte_result_t astarte_data_to_string(astarte_data_t data, const char **val)
Convert Astarte data (of the string type) to a const char *.
astarte_data_t astarte_data_from_integer_array(const int32_t *buf, size_t len)
Initialize an astarte data from the input integer array.
astarte_result_t astarte_data_to_longinteger_array(astarte_data_t data, const int64_t **buf, size_t *len)
Convert Astarte data (of longinteger array type) to an int64_t array.
astarte_data_t astarte_data_from_binaryblob_array(const void **blobs, size_t *sizes, size_t count)
Initialize an astarte data from the input binaryblob array.
astarte_result_t astarte_data_to_binaryblob_array(astarte_data_t data, const void ***blobs, size_t **sizes, size_t *count)
Convert Astarte data (of binaryblob array type) to an array of binaryblob arrays.
astarte_data_t astarte_data_from_datetime_array(const int64_t *buf, size_t len)
Initialize an astarte data from the input datetime array.
astarte_result_t astarte_data_to_datetime(astarte_data_t data, int64_t *val)
Convert Astarte data (of the datetime type) to an int64_t.
astarte_result_t astarte_data_to_string_array(astarte_data_t data, const char ***buf, size_t *len)
Convert Astarte data (of string type) to a const char* array.
astarte_data_t astarte_data_from_double_array(const double *buf, size_t len)
Initialize an astarte data from the input double array.
astarte_result_t astarte_data_to_boolean_array(astarte_data_t data, const bool **buf, size_t *len)
Convert Astarte data (of boolean array type) to a bool array.
astarte_mapping_type_t astarte_data_get_type(astarte_data_t data)
Get the type of Astarte data.
astarte_result_t astarte_data_to_longinteger(astarte_data_t data, int64_t *val)
Convert Astarte data (of the long integer type) to an int64_t.
astarte_result_t astarte_data_to_double_array(astarte_data_t data, const double **buf, size_t *len)
Convert Astarte data (of double array type) to a double array.
astarte_result_t astarte_data_to_integer(astarte_data_t data, int32_t *val)
Convert Astarte data (of the integer type) to an int32_t.
astarte_data_t astarte_data_from_datetime(int64_t val)
Initialize an astarte data from the input datetime.
astarte_data_t astarte_data_from_longinteger_array(const int64_t *buf, size_t len)
Initialize an astarte data from the input longinteger array.
astarte_result_t astarte_data_to_datetime_array(astarte_data_t data, const int64_t **buf, size_t *len)
Convert Astarte data (of datetime array type) to an int64_t array.
astarte_data_t astarte_data_from_boolean_array(const bool *buf, size_t len)
Initialize an astarte data from the input boolean array.
astarte_data_t astarte_data_from_string_array(const char **buf, size_t len)
Initialize an astarte data from the input string array.
astarte_result_t astarte_data_to_integer_array(astarte_data_t data, const int32_t **buf, size_t *len)
Convert Astarte data (of integer array type) to an int32_t array.
astarte_data_t astarte_data_from_binaryblob(const void *buf, size_t len)
Initialize an astarte data from the input binaryblob.
astarte_data_t astarte_data_from_boolean(bool val)
Initialize an astarte data from the input boolean.
astarte_result_t astarte_data_to_double(astarte_data_t data, double *val)
Convert Astarte data (of double type) to a double.
astarte_data_t astarte_data_from_longinteger(int64_t val)
Initialize an astarte data from the input longinteger.
astarte_data_t astarte_data_from_integer(int32_t val)
Initialize an astarte data from the input integer.
astarte_mapping_type_t
Allowed types in a mapping on an Astarte interface.
Definition mapping.h:34
astarte_result_t
Astarte Device SDK return codes.
Definition result.h:31
Astarte interface mapping representation.
Astarte result types.
Base Astarte data type.
Definition data.h:122
bool is_owned
Flag indicating if the memory backing the data is owned and dynamically allocated.
Definition data.h:128
astarte_mapping_type_t tag
Tag of the tagged enum.
Definition data.h:126
astarte_data_param_t data
Data portion of the tagged enum.
Definition data.h:124