Updated: April 19, 2023 |
Register a data callback for a specified event
#include <sensor/sensor_api.h>
sensor_error_t sensor_register_data_callback(sensor_handle_t handle, sensor_event_t event, sensor_eventmode_t mode, sensor_data_callback_t callback, void *arg)
This function registers a data callback for the specified event. For the callback function, return true if the received buffer is to be freed on return of the function. Return false if the buffer is to be freed later using sensor_return_buffer().
There is a limit in the number of data callbacks that can be registered for a given handle. If this limit is exceeded, the function fails and returns SENSOR_ENOMEM. Also, there is a limit of only one callback of SENSOR_EVENTMODE_READWRITE per given logical sensor unit.
SENSOR_EOK when the function successfully completes, otherwise another sensor_error_t value that provides the reason that the call failed.