Astarte Device SDK ESP32
ESP32 device SDK for the Astarte platform
|
Astarte device SDK high level API. More...
#include "astarte.h"
#include "astarte_bson_deserializer.h"
#include "astarte_interface.h"
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
Go to the source code of this file.
Data Structures | |
struct | astarte_device_data_event_t |
struct | astarte_device_unset_event_t |
struct | astarte_device_connection_event_t |
struct | astarte_device_disconnection_event_t |
struct | astarte_device_config_t |
Macros | |
#define | ASTARTE_INVALID_TIMESTAMP 0 |
Typedefs | |
typedef struct astarte_device * | astarte_device_handle_t |
typedef void(* | astarte_device_data_event_callback_t) (astarte_device_data_event_t *event) |
typedef void(* | astarte_device_connection_event_callback_t) (astarte_device_connection_event_t *event) |
typedef void(* | astarte_device_disconnection_event_callback_t) (astarte_device_disconnection_event_t *event) |
typedef void(* | astarte_device_unset_event_callback_t) (astarte_device_unset_event_t *event) |
Functions | |
astarte_device_handle_t | astarte_device_init (astarte_device_config_t *cfg) |
initialize Astarte device. More... | |
void | astarte_device_destroy (astarte_device_handle_t device) |
destroy Astarte device. More... | |
astarte_err_t | astarte_device_add_interface (astarte_device_handle_t device, const astarte_interface_t *interface) |
add an interface to the device. More... | |
astarte_err_t | astarte_device_start (astarte_device_handle_t device) |
start Astarte device. More... | |
astarte_err_t | astarte_device_stop (astarte_device_handle_t device) |
stop Astarte device. More... | |
astarte_err_t | astarte_device_stream_double (astarte_device_handle_t device, const char *interface_name, const char *path, double value, int qos) |
send a double value on a datastream endpoint. More... | |
astarte_err_t | astarte_device_stream_double_with_timestamp (astarte_device_handle_t device, const char *interface_name, const char *path, double value, uint64_t ts_epoch_millis, int qos) |
send a double value on a datastream endpoint with an explicit timestamp. More... | |
astarte_err_t | astarte_device_stream_integer (astarte_device_handle_t device, const char *interface_name, const char *path, int32_t value, int qos) |
send a 32 bit integer value on a datastream endpoint. More... | |
astarte_err_t | astarte_device_stream_integer_with_timestamp (astarte_device_handle_t device, const char *interface_name, const char *path, int32_t value, uint64_t ts_epoch_millis, int qos) |
send a 32 bit integer value on a datastream endpoint with an explicit timestamp. More... | |
astarte_err_t | astarte_device_stream_longinteger (astarte_device_handle_t device, const char *interface_name, const char *path, int64_t value, int qos) |
send a 64 bit integer value on a datastream endpoint. More... | |
astarte_err_t | astarte_device_stream_longinteger_with_timestamp (astarte_device_handle_t device, const char *interface_name, const char *path, int64_t value, uint64_t ts_epoch_millis, int qos) |
send a 64 bit integer value on a datastream endpoint with an explicit timestamp. More... | |
astarte_err_t | astarte_device_stream_boolean (astarte_device_handle_t device, const char *interface_name, const char *path, bool value, int qos) |
send a boolean value on a datastream endpoint. More... | |
astarte_err_t | astarte_device_stream_boolean_with_timestamp (astarte_device_handle_t device, const char *interface_name, const char *path, bool value, uint64_t ts_epoch_millis, int qos) |
send a boolean value on a datastream endpoint with an explicit timestamp. More... | |
astarte_err_t | astarte_device_stream_string (astarte_device_handle_t device, const char *interface_name, const char *path, const char *value, int qos) |
send a UTF8 encoded string on a datastream endpoint. More... | |
astarte_err_t | astarte_device_stream_string_with_timestamp (astarte_device_handle_t device, const char *interface_name, const char *path, const char *value, uint64_t ts_epoch_millis, int qos) |
send a UTF8 encoded string on a datastream endpoint with an explicit timestamp. More... | |
astarte_err_t | astarte_device_stream_binaryblob (astarte_device_handle_t device, const char *interface_name, const char *path, void *value, size_t size, int qos) |
send a binary value on a datastream endpoint. More... | |
astarte_err_t | astarte_device_stream_binaryblob_with_timestamp (astarte_device_handle_t device, const char *interface_name, const char *path, void *value, size_t size, uint64_t ts_epoch_millis, int qos) |
send a binary value on a datastream endpoint with an explicit timestamp. More... | |
astarte_err_t | astarte_device_stream_datetime (astarte_device_handle_t device, const char *interface_name, const char *path, int64_t value, int qos) |
send a datetime value on a datastream endpoint. More... | |
astarte_err_t | astarte_device_stream_datetime_with_timestamp (astarte_device_handle_t device, const char *interface_name, const char *path, int64_t value, uint64_t ts_epoch_millis, int qos) |
send a datetime value on a datastream endpoint with an explicit timestamp. More... | |
astarte_err_t | astarte_device_stream_double_array_with_timestamp (astarte_device_handle_t device, const char *interface_name, const char *path, const double *values, int count, uint64_t ts_epoch_millis, int qos) |
send a double array value on a datastream endpoint with an explicit timestamp. More... | |
static astarte_err_t | astarte_device_stream_double_array (astarte_device_handle_t device, const char *interface_name, const char *path, const double *values, int count, uint64_t ts_epoch_millis, int qos) |
send a double array value on a datastream endpoint. More... | |
astarte_err_t | astarte_device_stream_integer_array_with_timestamp (astarte_device_handle_t device, const char *interface_name, const char *path, const int32_t *values, int count, uint64_t ts_epoch_millis, int qos) |
send a 32 bit integer array value on a datastream endpoint with an explicit timestamp. More... | |
static astarte_err_t | astarte_device_stream_integer_array (astarte_device_handle_t device, const char *interface_name, const char *path, const int32_t *values, int count, int qos) |
send a 32 bit integer array value on a datastream endpoint. More... | |
astarte_err_t | astarte_device_stream_longinteger_array_with_timestamp (astarte_device_handle_t device, const char *interface_name, const char *path, const int64_t *values, int count, uint64_t ts_epoch_millis, int qos) |
send a 64 bit integer array value on a datastream endpoint with an explicit timestamp. More... | |
static astarte_err_t | astarte_device_stream_longinteger_array (astarte_device_handle_t device, const char *interface_name, const char *path, const int64_t *values, int count, int qos) |
send a 64 bit integer array value on a datastream endpoint. More... | |
astarte_err_t | astarte_device_stream_boolean_array_with_timestamp (astarte_device_handle_t device, const char *interface_name, const char *path, const bool *values, int count, uint64_t ts_epoch_millis, int qos) |
send a boolean array value on a datastream endpoint with an explicit timestamp. More... | |
static astarte_err_t | astarte_device_stream_boolean_array (astarte_device_handle_t device, const char *interface_name, const char *path, const bool *values, int count, int qos) |
send a boolean array value on a datastream endpoint. More... | |
astarte_err_t | astarte_device_stream_string_array_with_timestamp (astarte_device_handle_t device, const char *interface_name, const char *path, const char *const *values, int count, uint64_t ts_epoch_millis, int qos) |
send a string array value on a datastream endpoint with an explicit timestamp. More... | |
static astarte_err_t | astarte_device_stream_string_array (astarte_device_handle_t device, const char *interface_name, const char *path, const char *const *values, int count, int qos) |
send a string array value on a datastream endpoint. More... | |
astarte_err_t | astarte_device_stream_binaryblob_array_with_timestamp (astarte_device_handle_t device, const char *interface_name, const char *path, const void *const *values, const int *sizes, int count, uint64_t ts_epoch_millis, int qos) |
send a binary blob array value on a datastream endpoint with an explicit timestamp. More... | |
static astarte_err_t | astarte_device_stream_binaryblob_array (astarte_device_handle_t device, const char *interface_name, const char *path, const void *const *values, const int *sizes, int count, int qos) |
send a binary blob array value on a datastream endpoint with an explicit timestamp. More... | |
astarte_err_t | astarte_device_stream_datetime_array_with_timestamp (astarte_device_handle_t device, const char *interface_name, const char *path, const int64_t *values, int count, uint64_t ts_epoch_millis, int qos) |
send a datetime value on a datastream endpoint with an explicit timestamp. More... | |
static astarte_err_t | astarte_device_stream_datetime_array (astarte_device_handle_t device, const char *interface_name, const char *path, const int64_t *values, int count, int qos) |
send a datetime value on a datastream endpoint. More... | |
astarte_err_t | astarte_device_stream_aggregate (astarte_device_handle_t device, const char *interface_name, const char *path_prefix, const void *bson_document, int qos) |
send an aggregate value on a datastream endpoint of an interface with object aggregation. More... | |
astarte_err_t | astarte_device_stream_aggregate_with_timestamp (astarte_device_handle_t device, const char *interface_name, const char *path_prefix, const void *bson_document, uint64_t ts_epoch_millis, int qos) |
send an aggregate value on a datastream endpoint of an interface with object aggregation with an explicit timestamp. More... | |
astarte_err_t | astarte_device_set_double_property (astarte_device_handle_t device, const char *interface_name, const char *path, double value) |
send a double value on a properties endpoint. More... | |
astarte_err_t | astarte_device_set_integer_property (astarte_device_handle_t device, const char *interface_name, const char *path, int32_t value) |
send a 32 bit integer value on a properties endpoint. More... | |
astarte_err_t | astarte_device_set_longinteger_property (astarte_device_handle_t device, const char *interface_name, const char *path, int64_t value) |
send a 64 bit integer value on a properties endpoint. More... | |
astarte_err_t | astarte_device_set_boolean_property (astarte_device_handle_t device, const char *interface_name, const char *path, bool value) |
send a boolean value on a properties endpoint. More... | |
astarte_err_t | astarte_device_set_string_property (astarte_device_handle_t device, const char *interface_name, const char *path, const char *value) |
send a UTF8 encoded string on a properties endpoint. More... | |
astarte_err_t | astarte_device_set_binaryblob_property (astarte_device_handle_t device, const char *interface_name, const char *path, void *value, size_t size) |
send a binary value on a properties endpoint. More... | |
astarte_err_t | astarte_device_set_datetime_property (astarte_device_handle_t device, const char *interface_name, const char *path, int64_t value) |
send a datetime value on a properties endpoint. More... | |
astarte_err_t | astarte_device_unset_path (astarte_device_handle_t device, const char *interface_name, const char *path) |
unset a path belonging to a properties interface. More... | |
bool | astarte_device_is_connected (astarte_device_handle_t device) |
check if the device is connected. More... | |
char * | astarte_device_get_encoded_id (astarte_device_handle_t device) |
Get the encoded hardware ID of the device. More... | |
Astarte device SDK high level API.
astarte_err_t astarte_device_add_interface | ( | astarte_device_handle_t | device, |
const astarte_interface_t * | interface | ||
) |
add an interface to the device.
This function has to be called before astarte_device_start to add all the needed Astarte interfaces, that will be sent in the device introspection when it connects.
device | A valid Astarte device handle. |
interface | A pointer to an astarte_interface_t struct describing the interface. The caller is responsible for making sure the pointed interface remains valid for the lifetime of the astarte_device. It is recommended to declare interface structs as static const. |
void astarte_device_destroy | ( | astarte_device_handle_t | device | ) |
destroy Astarte device.
This function destroys the device, freeing all its resources.
device | A valid Astarte device handle. |
char* astarte_device_get_encoded_id | ( | astarte_device_handle_t | device | ) |
Get the encoded hardware ID of the device.
Get the encoded hardware ID of the device. The string is owned by astarte_device_handle_t and it is freed when the device is closed/freed.
device | An Astarte device handle. |
astarte_device_handle_t astarte_device_init | ( | astarte_device_config_t * | cfg | ) |
initialize Astarte device.
This function has to be called to initialize the device SDK before doing anything else.
If hwid is not defined explicitly in cfg, the device will use an hwid derived from unique device features (e.g. MAC address, CPU features...). An explicit hwid can be passed in the astarte_device_config_t struct. For example, it is possible to use a UUIDv5 as hwid, using a personal UUID namespace and some custom device data to derive it.
Example:
uuid_t uuid_ns; if (uuid_from_string("de40ff58-5696-4b35-a6d6-0cc7280bcd56", uuid_ns) != 0) { ESP_LOGE(TAG, "Error while parsing namespace UUID"); }
uuid_t device_uuid; const char *unique_data = "my_unique_data" uuid_generate_v5(uuid_ns, unique_data, strlen(unique_data), device_uuid);
char hwid[32]; astarte_hwid_encode(hwid, sizeof(hwid), device_uuid);
astarte_device_config_t cfg = { .data_event_callback = astarte_data_events_handler, .hwid = hwid, };
bool astarte_device_is_connected | ( | astarte_device_handle_t | device | ) |
check if the device is connected.
check if the Astarte device is currently connected to the MQTT broker.
device | An Astarte device handle. |
astarte_err_t astarte_device_set_binaryblob_property | ( | astarte_device_handle_t | device, |
const char * | interface_name, | ||
const char * | path, | ||
void * | value, | ||
size_t | size | ||
) |
send a binary value on a properties endpoint.
This function sends a binary value on a path of a given properties interface.
device | A started Astarte device handle. |
interface_name | A string containing the name of the interface. |
path | A string containing the path (beginning with /). |
value | A pointer to the binary data to be sent. |
size | The length in bytes of the binary data to be sent. |
astarte_err_t astarte_device_set_boolean_property | ( | astarte_device_handle_t | device, |
const char * | interface_name, | ||
const char * | path, | ||
bool | value | ||
) |
send a boolean value on a properties endpoint.
This function sends a boolean value on a path of a given properties interface.
device | A started Astarte device handle. |
interface_name | A string containing the name of the interface. |
path | A string containing the path (beginning with /). |
value | The value to be sent (0 or 1). |
astarte_err_t astarte_device_set_datetime_property | ( | astarte_device_handle_t | device, |
const char * | interface_name, | ||
const char * | path, | ||
int64_t | value | ||
) |
send a datetime value on a properties endpoint.
This function sends a datetime value on a path of a given properties interface. The datetime represents the number of milliseconds since Unix epoch (1970-01-01).
device | A started Astarte device handle. |
interface_name | A string containing the name of the interface. |
path | A string containing the path (beginning with /). |
value | The value to be sent, representing the number of milliseconds since Unix epoch (1970-01-01). |
astarte_err_t astarte_device_set_double_property | ( | astarte_device_handle_t | device, |
const char * | interface_name, | ||
const char * | path, | ||
double | value | ||
) |
send a double value on a properties endpoint.
This function sends a double value on a path of a given properties interface.
device | A started Astarte device handle. |
interface_name | A string containing the name of the interface. |
path | A string containing the path (beginning with /). |
value | The value to be sent. |
astarte_err_t astarte_device_set_integer_property | ( | astarte_device_handle_t | device, |
const char * | interface_name, | ||
const char * | path, | ||
int32_t | value | ||
) |
send a 32 bit integer value on a properties endpoint.
This function sends a 32 bit int value on a path of a given properties interface.
device | A started Astarte device handle. |
interface_name | A string containing the name of the interface. |
path | A string containing the path (beginning with /). |
value | The value to be sent. |
astarte_err_t astarte_device_set_longinteger_property | ( | astarte_device_handle_t | device, |
const char * | interface_name, | ||
const char * | path, | ||
int64_t | value | ||
) |
send a 64 bit integer value on a properties endpoint.
This function sends a 64 bit int value on a path of a given properties interface.
device | A started Astarte device handle. |
interface_name | A string containing the name of the interface. |
path | A string containing the path (beginning with /). |
value | The value to be sent. |
astarte_err_t astarte_device_set_string_property | ( | astarte_device_handle_t | device, |
const char * | interface_name, | ||
const char * | path, | ||
const char * | value | ||
) |
send a UTF8 encoded string on a properties endpoint.
This function sends a UTF8 encoded string on a path of a given properties interface.
device | A started Astarte device handle. |
interface_name | A string containing the name of the interface. |
path | A string containing the path (beginning with /). |
value | The value to be sent (a NULL terminated string). |
astarte_err_t astarte_device_start | ( | astarte_device_handle_t | device | ) |
start Astarte device.
This function starts the device, making it connect to the broker and perform its work.
device | A valid Astarte device handle. |
astarte_err_t astarte_device_stop | ( | astarte_device_handle_t | device | ) |
stop Astarte device.
This function stops the device, making it disconnect from the broker.
device | A valid Astarte device handle. |
astarte_err_t astarte_device_stream_aggregate | ( | astarte_device_handle_t | device, |
const char * | interface_name, | ||
const char * | path_prefix, | ||
const void * | bson_document, | ||
int | qos | ||
) |
send an aggregate value on a datastream endpoint of an interface with object aggregation.
This function sends an aggregate value on a path of a given datastream interface. The value is represented with a BSON document that can be built with astarte_bson_serializer.
device | A started Astarte device handle. |
interface_name | A string containing the name of the interface. |
path_prefix | A string containing the path prefix of the aggregate (beginning with /). The path prefix is the common prefix of the endpoints in the aggregate interface. |
bson_document | A pointer to the document buffer containing the aggregate. Here's an example of how you can obtain the bson_document for an AirSensor interface containing 3 endpoints: |
astarte_bson_serializer_handle_t bs = astarte_bson_serializer_new(); astarte_bson_serializer_append_double(bs, "co2", 4.0); astarte_bson_serializer_append_double(bs, "temperature", 20.0); astarte_bson_serializer_append_double(bs, "humidity", 77.2); astarte_bson_serializer_append_end_of_document(bs); int size; const void *document = astarte_bson_serializer_get_document(bs, &size); // Use the returned buffer before destroy call astarte_bson_serializer_destroy(bs);
qos | The MQTT QoS to be used for the publish (0, 1 or 2). |
astarte_err_t astarte_device_stream_aggregate_with_timestamp | ( | astarte_device_handle_t | device, |
const char * | interface_name, | ||
const char * | path_prefix, | ||
const void * | bson_document, | ||
uint64_t | ts_epoch_millis, | ||
int | qos | ||
) |
send an aggregate value on a datastream endpoint of an interface with object aggregation with an explicit timestamp.
This function sends an aggregate value on a path of a given datastream interface. The value is represented with a BSON document that can be built with astarte_bson_serializer.
device | A started Astarte device handle. |
interface_name | A string containing the name of the interface. |
path_prefix | A string containing the path prefix of the aggregate (beginning with /). The path prefix is the common prefix of the endpoints in the aggregate interface. |
bson_document | A pointer to the document buffer containing the aggregate. Here's an example of how you can obtain the bson_document for an AirSensor interface containing 3 endpoints: |
astarte_bson_serializer_handle_t bs = astarte_bson_serializer_new(); astarte_bson_serializer_append_double(bs, "co2", 4.0); astarte_bson_serializer_append_double(bs, "temperature", 20.0); astarte_bson_serializer_append_double(bs, "humidity", 77.2); astarte_bson_serializer_append_end_of_document(bs); int size; const void *document = astarte_bson_serializer_get_document(bs, &size); // Use the returned buffer before destroy call astarte_bson_serializer_destroy(bs);
ts_epoch_millis | The timestamp of the datastream. This is useful only on mappings with explicit_timestamp set to true and it's represented as milliseconds since epoch. A value of ASTARTE_INVALID_TIMESTAMP is ignored. |
qos | The MQTT QoS to be used for the publish (0, 1 or 2). |
astarte_err_t astarte_device_stream_binaryblob | ( | astarte_device_handle_t | device, |
const char * | interface_name, | ||
const char * | path, | ||
void * | value, | ||
size_t | size, | ||
int | qos | ||
) |
send a binary value on a datastream endpoint.
This function sends a binary value on a path of a given datastream interface.
device | A started Astarte device handle. |
interface_name | A string containing the name of the interface. |
path | A string containing the path (beginning with /). |
value | A pointer to the binary data to be sent. |
size | The length in bytes of the binary data to be sent. |
qos | The MQTT QoS to be used for the publish (0, 1 or 2). |
|
inlinestatic |
send a binary blob array value on a datastream endpoint with an explicit timestamp.
This function sends a binary blob array value on a path of a given datastream interface.
device | A started Astarte device handle. |
interface_name | A string containing the name of the interface. |
path | A string containing the path (beginning with /). |
values | The array of binary blobs to be sent (having each one const void * type). |
sizes | The size of each binary blob that is in the given values array. |
count | The number of values stored in values array. |
qos | The MQTT QoS to be used for the publish (0, 1 or 2). |
astarte_err_t astarte_device_stream_binaryblob_array_with_timestamp | ( | astarte_device_handle_t | device, |
const char * | interface_name, | ||
const char * | path, | ||
const void *const * | values, | ||
const int * | sizes, | ||
int | count, | ||
uint64_t | ts_epoch_millis, | ||
int | qos | ||
) |
send a binary blob array value on a datastream endpoint with an explicit timestamp.
This function sends a binary blob array value on a path of a given datastream interface.
device | A started Astarte device handle. |
interface_name | A string containing the name of the interface. |
path | A string containing the path (beginning with /). |
values | The array of binary blobs to be sent (having each one const void * type). |
sizes | The size of each binary blob that is in the given values array. |
count | The number of values stored in values array. |
ts_epoch_millis | The timestamp of the datastream. This is useful only on mappings with explicit_timestamp set to true and it's represented as milliseconds since epoch. A value of ASTARTE_INVALID_TIMESTAMP is ignored. |
qos | The MQTT QoS to be used for the publish (0, 1 or 2). |
astarte_err_t astarte_device_stream_binaryblob_with_timestamp | ( | astarte_device_handle_t | device, |
const char * | interface_name, | ||
const char * | path, | ||
void * | value, | ||
size_t | size, | ||
uint64_t | ts_epoch_millis, | ||
int | qos | ||
) |
send a binary value on a datastream endpoint with an explicit timestamp.
This function sends a binary value on a path of a given datastream interface.
device | A started Astarte device handle. |
interface_name | A string containing the name of the interface. |
path | A string containing the path (beginning with /). |
value | A pointer to the binary data to be sent. |
size | The length in bytes of the binary data to be sent. |
ts_epoch_millis | The timestamp of the datastream. This is useful only on mappings with explicit_timestamp set to true and it's represented as milliseconds since epoch. A value of ASTARTE_INVALID_TIMESTAMP is ignored. |
qos | The MQTT QoS to be used for the publish (0, 1 or 2). |
astarte_err_t astarte_device_stream_boolean | ( | astarte_device_handle_t | device, |
const char * | interface_name, | ||
const char * | path, | ||
bool | value, | ||
int | qos | ||
) |
send a boolean value on a datastream endpoint.
This function sends a boolean value on a path of a given datastream interface.
device | A started Astarte device handle. |
interface_name | A string containing the name of the interface. |
path | A string containing the path (beginning with /). |
value | The value to be sent (0 or 1). |
qos | The MQTT QoS to be used for the publish (0, 1 or 2). |
|
inlinestatic |
send a boolean array value on a datastream endpoint.
This function sends a boolean array value on a path of a given datastream interface.
device | A started Astarte device handle. |
interface_name | A string containing the name of the interface. |
path | A string containing the path (beginning with /). |
values | The array of booleans to be sent (false or true). |
count | The number of values stored in values array. |
qos | The MQTT QoS to be used for the publish (0, 1 or 2). |
astarte_err_t astarte_device_stream_boolean_array_with_timestamp | ( | astarte_device_handle_t | device, |
const char * | interface_name, | ||
const char * | path, | ||
const bool * | values, | ||
int | count, | ||
uint64_t | ts_epoch_millis, | ||
int | qos | ||
) |
send a boolean array value on a datastream endpoint with an explicit timestamp.
This function sends a boolean array value on a path of a given datastream interface.
device | A started Astarte device handle. |
interface_name | A string containing the name of the interface. |
path | A string containing the path (beginning with /). |
values | The array of booleans to be sent (false or true). |
count | The number of values stored in values array. |
ts_epoch_millis | The timestamp of the datastream. This is useful only on mappings with explicit_timestamp set to true and it's represented as milliseconds since epoch. A value of ASTARTE_INVALID_TIMESTAMP is ignored. |
qos | The MQTT QoS to be used for the publish (0, 1 or 2). |
astarte_err_t astarte_device_stream_boolean_with_timestamp | ( | astarte_device_handle_t | device, |
const char * | interface_name, | ||
const char * | path, | ||
bool | value, | ||
uint64_t | ts_epoch_millis, | ||
int | qos | ||
) |
send a boolean value on a datastream endpoint with an explicit timestamp.
This function sends a boolean value on a path of a given datastream interface.
device | A started Astarte device handle. |
interface_name | A string containing the name of the interface. |
path | A string containing the path (beginning with /). |
value | The value to be sent (0 or 1). |
ts_epoch_millis | The timestamp of the datastream. This is useful only on mappings with explicit_timestamp set to true and it's represented as milliseconds since epoch. A value of ASTARTE_INVALID_TIMESTAMP is ignored. |
qos | The MQTT QoS to be used for the publish (0, 1 or 2). |
astarte_err_t astarte_device_stream_datetime | ( | astarte_device_handle_t | device, |
const char * | interface_name, | ||
const char * | path, | ||
int64_t | value, | ||
int | qos | ||
) |
send a datetime value on a datastream endpoint.
This function sends a datetime value on a path of a given datastream interface. The datetime represents the number of milliseconds since Unix epoch (1970-01-01).
device | A started Astarte device handle. |
interface_name | A string containing the name of the interface. |
path | A string containing the path (beginning with /). |
value | The value to be sent, representing the number of milliseconds since Unix epoch (1970-01-01). |
qos | The MQTT QoS to be used for the publish (0, 1 or 2). |
|
inlinestatic |
send a datetime value on a datastream endpoint.
This function sends a datetime value on a path of a given datastream interface. The datetime represents the number of milliseconds since Unix epoch (1970-01-01).
device | A started Astarte device handle. |
interface_name | A string containing the name of the interface. |
path | A string containing the path (beginning with /). |
values | The array of datetimes, each one representing the number of milliseconds since Unix epoch (1970-01-01). |
count | The number of values stored in values array. |
qos | The MQTT QoS to be used for the publish (0, 1 or 2). |
astarte_err_t astarte_device_stream_datetime_array_with_timestamp | ( | astarte_device_handle_t | device, |
const char * | interface_name, | ||
const char * | path, | ||
const int64_t * | values, | ||
int | count, | ||
uint64_t | ts_epoch_millis, | ||
int | qos | ||
) |
send a datetime value on a datastream endpoint with an explicit timestamp.
This function sends a datetime value on a path of a given datastream interface. The datetime represents the number of milliseconds since Unix epoch (1970-01-01).
device | A started Astarte device handle. |
interface_name | A string containing the name of the interface. |
path | A string containing the path (beginning with /). |
values | The array of datetimes, each one representing the number of milliseconds since Unix epoch (1970-01-01). |
count | The number of values stored in values array. |
ts_epoch_millis | The timestamp of the datastream. This is useful only on mappings with explicit_timestamp set to true and it's represented as milliseconds since epoch. A value of ASTARTE_INVALID_TIMESTAMP is ignored. |
qos | The MQTT QoS to be used for the publish (0, 1 or 2). |
astarte_err_t astarte_device_stream_datetime_with_timestamp | ( | astarte_device_handle_t | device, |
const char * | interface_name, | ||
const char * | path, | ||
int64_t | value, | ||
uint64_t | ts_epoch_millis, | ||
int | qos | ||
) |
send a datetime value on a datastream endpoint with an explicit timestamp.
This function sends a datetime value on a path of a given datastream interface. The datetime represents the number of milliseconds since Unix epoch (1970-01-01).
device | A started Astarte device handle. |
interface_name | A string containing the name of the interface. |
path | A string containing the path (beginning with /). |
value | The value to be sent, representing the number of milliseconds since Unix epoch (1970-01-01). |
ts_epoch_millis | The timestamp of the datastream. This is useful only on mappings with explicit_timestamp set to true and it's represented as milliseconds since epoch. A value of ASTARTE_INVALID_TIMESTAMP is ignored. |
qos | The MQTT QoS to be used for the publish (0, 1 or 2). |
astarte_err_t astarte_device_stream_double | ( | astarte_device_handle_t | device, |
const char * | interface_name, | ||
const char * | path, | ||
double | value, | ||
int | qos | ||
) |
send a double value on a datastream endpoint.
This function sends a double value on a path of a given datastream interface.
device | A started Astarte device handle. |
interface_name | A string containing the name of the interface. |
path | A string containing the path (beginning with /). |
value | The value to be sent. |
qos | The MQTT QoS to be used for the publish (0, 1 or 2). |
|
inlinestatic |
send a double array value on a datastream endpoint.
This function sends a double array value on a path of a given datastream interface.
device | A started Astarte device handle. |
interface_name | A string containing the name of the interface. |
path | A string containing the path (beginning with /). |
values | The array of double to be sent. |
count | The number of values stored in values array. |
qos | The MQTT QoS to be used for the publish (0, 1 or 2). |
astarte_err_t astarte_device_stream_double_array_with_timestamp | ( | astarte_device_handle_t | device, |
const char * | interface_name, | ||
const char * | path, | ||
const double * | values, | ||
int | count, | ||
uint64_t | ts_epoch_millis, | ||
int | qos | ||
) |
send a double array value on a datastream endpoint with an explicit timestamp.
This function sends a double array value on a path of a given datastream interface.
device | A started Astarte device handle. |
interface_name | A string containing the name of the interface. |
path | A string containing the path (beginning with /). |
values | The array of double to be sent. |
count | The number of values stored in values array. |
ts_epoch_millis | The timestamp of the datastream. This is useful only on mappings with explicit_timestamp set to true and it's represented as milliseconds since epoch. A value of ASTARTE_INVALID_TIMESTAMP is ignored. |
qos | The MQTT QoS to be used for the publish (0, 1 or 2). |
astarte_err_t astarte_device_stream_double_with_timestamp | ( | astarte_device_handle_t | device, |
const char * | interface_name, | ||
const char * | path, | ||
double | value, | ||
uint64_t | ts_epoch_millis, | ||
int | qos | ||
) |
send a double value on a datastream endpoint with an explicit timestamp.
This function sends a double value on a path of a given datastream interface.
device | A started Astarte device handle. |
interface_name | A string containing the name of the interface. |
path | A string containing the path (beginning with /). |
value | The value to be sent. |
ts_epoch_millis | The timestamp of the datastream. This is useful only on mappings with explicit_timestamp set to true and it's represented as milliseconds since epoch. A value of ASTARTE_INVALID_TIMESTAMP is ignored. |
qos | The MQTT QoS to be used for the publish (0, 1 or 2). |
astarte_err_t astarte_device_stream_integer | ( | astarte_device_handle_t | device, |
const char * | interface_name, | ||
const char * | path, | ||
int32_t | value, | ||
int | qos | ||
) |
send a 32 bit integer value on a datastream endpoint.
This function sends a 32 bit int value on a path of a given datastream interface.
device | A started Astarte device handle. |
interface_name | A string containing the name of the interface. |
path | A string containing the path (beginning with /). |
value | The value to be sent. |
qos | The MQTT QoS to be used for the publish (0, 1 or 2). |
|
inlinestatic |
send a 32 bit integer array value on a datastream endpoint.
This function sends a signed 32 bit int array value on a path of a given datastream interface.
device | A started Astarte device handle. |
interface_name | A string containing the name of the interface. |
path | A string containing the path (beginning with /). |
values | The array of int32_t to be sent. |
count | The number of values stored in values array. |
qos | The MQTT QoS to be used for the publish (0, 1 or 2). |
astarte_err_t astarte_device_stream_integer_array_with_timestamp | ( | astarte_device_handle_t | device, |
const char * | interface_name, | ||
const char * | path, | ||
const int32_t * | values, | ||
int | count, | ||
uint64_t | ts_epoch_millis, | ||
int | qos | ||
) |
send a 32 bit integer array value on a datastream endpoint with an explicit timestamp.
This function sends a signed 32 bit int array value on a path of a given datastream interface.
device | A started Astarte device handle. |
interface_name | A string containing the name of the interface. |
path | A string containing the path (beginning with /). |
values | The array of int32_t to be sent. |
count | The number of values stored in values array. |
ts_epoch_millis | The timestamp of the datastream. This is useful only on mappings with explicit_timestamp set to true and it's represented as milliseconds since epoch. A value of ASTARTE_INVALID_TIMESTAMP is ignored. |
qos | The MQTT QoS to be used for the publish (0, 1 or 2). |
astarte_err_t astarte_device_stream_integer_with_timestamp | ( | astarte_device_handle_t | device, |
const char * | interface_name, | ||
const char * | path, | ||
int32_t | value, | ||
uint64_t | ts_epoch_millis, | ||
int | qos | ||
) |
send a 32 bit integer value on a datastream endpoint with an explicit timestamp.
This function sends a 32 bit int value on a path of a given datastream interface.
device | A started Astarte device handle. |
interface_name | A string containing the name of the interface. |
path | A string containing the path (beginning with /). |
value | The value to be sent. |
ts_epoch_millis | The timestamp of the datastream. This is useful only on mappings with explicit_timestamp set to true and it's represented as milliseconds since epoch. A value of ASTARTE_INVALID_TIMESTAMP is ignored. |
qos | The MQTT QoS to be used for the publish (0, 1 or 2). |
astarte_err_t astarte_device_stream_longinteger | ( | astarte_device_handle_t | device, |
const char * | interface_name, | ||
const char * | path, | ||
int64_t | value, | ||
int | qos | ||
) |
send a 64 bit integer value on a datastream endpoint.
This function sends a 64 bit int value on a path of a given datastream interface.
device | A started Astarte device handle. |
interface_name | A string containing the name of the interface. |
path | A string containing the path (beginning with /). |
value | The value to be sent. |
qos | The MQTT QoS to be used for the publish (0, 1 or 2). |
|
inlinestatic |
send a 64 bit integer array value on a datastream endpoint.
This function sends a signed 64 bit int array value on a path of a given datastream interface.
device | A started Astarte device handle. |
interface_name | A string containing the name of the interface. |
path | A string containing the path (beginning with /). |
values | The array of int64_t to be sent. |
count | The number of values stored in values array. |
qos | The MQTT QoS to be used for the publish (0, 1 or 2). |
astarte_err_t astarte_device_stream_longinteger_array_with_timestamp | ( | astarte_device_handle_t | device, |
const char * | interface_name, | ||
const char * | path, | ||
const int64_t * | values, | ||
int | count, | ||
uint64_t | ts_epoch_millis, | ||
int | qos | ||
) |
send a 64 bit integer array value on a datastream endpoint with an explicit timestamp.
This function sends a signed 64 bit int array value on a path of a given datastream interface.
device | A started Astarte device handle. |
interface_name | A string containing the name of the interface. |
path | A string containing the path (beginning with /). |
values | The array of int64_t to be sent. |
count | The number of values stored in values array. |
ts_epoch_millis | The timestamp of the datastream. This is useful only on mappings with explicit_timestamp set to true and it's represented as milliseconds since epoch. A value of ASTARTE_INVALID_TIMESTAMP is ignored. |
qos | The MQTT QoS to be used for the publish (0, 1 or 2). |
astarte_err_t astarte_device_stream_longinteger_with_timestamp | ( | astarte_device_handle_t | device, |
const char * | interface_name, | ||
const char * | path, | ||
int64_t | value, | ||
uint64_t | ts_epoch_millis, | ||
int | qos | ||
) |
send a 64 bit integer value on a datastream endpoint with an explicit timestamp.
This function sends a 64 bit int value on a path of a given datastream interface.
device | A started Astarte device handle. |
interface_name | A string containing the name of the interface. |
path | A string containing the path (beginning with /). |
value | The value to be sent. |
ts_epoch_millis | The timestamp of the datastream. This is useful only on mappings with explicit_timestamp set to true and it's represented as milliseconds since epoch. A value of ASTARTE_INVALID_TIMESTAMP is ignored. |
qos | The MQTT QoS to be used for the publish (0, 1 or 2). |
astarte_err_t astarte_device_stream_string | ( | astarte_device_handle_t | device, |
const char * | interface_name, | ||
const char * | path, | ||
const char * | value, | ||
int | qos | ||
) |
send a UTF8 encoded string on a datastream endpoint.
This function sends a UTF8 encoded string on a path of a given datastream interface.
device | A started Astarte device handle. |
interface_name | A string containing the name of the interface. |
path | A string containing the path (beginning with /). |
value | The value to be sent (a NULL terminated string). |
qos | The MQTT QoS to be used for the publish (0, 1 or 2). |
|
inlinestatic |
send a string array value on a datastream endpoint.
This function sends a string array value on a path of a given datastream interface. The datetime represents the number of milliseconds since Unix epoch (1970-01-01).
device | A started Astarte device handle. |
interface_name | A string containing the name of the interface. |
path | A string containing the path (beginning with /). |
values | The array of C strings to be sent (having each one const char * type and encoded as 0 terminated UTF-8 string). |
count | The number of values stored in values array. |
qos | The MQTT QoS to be used for the publish (0, 1 or 2). |
astarte_err_t astarte_device_stream_string_array_with_timestamp | ( | astarte_device_handle_t | device, |
const char * | interface_name, | ||
const char * | path, | ||
const char *const * | values, | ||
int | count, | ||
uint64_t | ts_epoch_millis, | ||
int | qos | ||
) |
send a string array value on a datastream endpoint with an explicit timestamp.
This function sends a string array value on a path of a given datastream interface.
device | A started Astarte device handle. |
interface_name | A string containing the name of the interface. |
path | A string containing the path (beginning with /). |
values | The array of C strings to be sent (having each one const char * type and encoded as 0 terminated UTF-8 string). |
count | The number of values stored in values array. |
ts_epoch_millis | The timestamp of the datastream. This is useful only on mappings with explicit_timestamp set to true and it's represented as milliseconds since epoch. A value of ASTARTE_INVALID_TIMESTAMP is ignored. |
qos | The MQTT QoS to be used for the publish (0, 1 or 2). |
astarte_err_t astarte_device_stream_string_with_timestamp | ( | astarte_device_handle_t | device, |
const char * | interface_name, | ||
const char * | path, | ||
const char * | value, | ||
uint64_t | ts_epoch_millis, | ||
int | qos | ||
) |
send a UTF8 encoded string on a datastream endpoint with an explicit timestamp.
This function sends a UTF8 encoded string on a path of a given datastream interface.
device | A started Astarte device handle. |
interface_name | A string containing the name of the interface. |
path | A string containing the path (beginning with /). |
value | The value to be sent (a NULL terminated string). |
ts_epoch_millis | The timestamp of the datastream. This is useful only on mappings with explicit_timestamp set to true and it's represented as milliseconds since epoch. A value of ASTARTE_INVALID_TIMESTAMP is ignored. |
qos | The MQTT QoS to be used for the publish (0, 1 or 2). |
astarte_err_t astarte_device_unset_path | ( | astarte_device_handle_t | device, |
const char * | interface_name, | ||
const char * | path | ||
) |
unset a path belonging to a properties interface.
This function is used to unset a path. It is possible to use it only with an interface of type properties and on a path belonging to an endpoint with allow_unset set to true.
device | A started Astarte device handle. |
interface_name | A string containing the name of the interface. |
path | A string containing the path (beginning with /). |