astarte-platform / astarte-device-sdk-esp32

Astarte device SDK for ESP32 devices, based on esp-idf
Apache License 2.0
13 stars 11 forks source link

Callback functions miss user data #181

Closed sorru94 closed 1 year ago

sorru94 commented 1 year ago

The callbacks astarte_device_data_event_callback_t, astarte_device_unset_event_callback_t, astarte_device_connection_event_callback_t and astarte_device_disconnection_event_callback_t are lacking a way for the user to share data with them. This requires the callback functions implementation to rely on global variables.

A simple solution is to add an entry to the astarte_device_config_t struct with a pointer to user-defined data that will then also be passed to the callbacks using the astarte_device_**_event_t structs.