sensor_register_data_callback()

Register a data callback for a specified event

Synopsis:

#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)

Arguments:

handle
The handle returned by a call to the sensor_open() function.
event
The event of interest for the callback.
mode
The mode of the callback (read-only or read-write)
callback
The callback function to call when data becomes available
arg
The user argument to use as part of the callback.

Library:

libsensor

Description:

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().

Note:

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 will fail and return SENSOR_ENOMEM. Note as well that there is a limit of only one callback of SENSOR_EVENTMODE_READWRITE per given logical sensor unit.

Returns:

SENSOR_EOK when the function successfully completes, otherwise another sensor_error_t value that provides the reason that the call failed.