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 sensor_open().
event
The event of interest for the callback, as a sensor_event_t value.
mode
The mode of the callback, as a sensor_eventmode_t value.
callback
The callback function to call when data becomes available, as a sensor_data_callback_t value.
arg
The user argument to use as part of the callback.

Library:

libsensor

Description:

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

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 fails and returns SENSOR_ENOMEM. Also, 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.