Tizen Native API
4.0
|
The Sensor Provider API provides functions to define a new sensor instance and provide its data.
#include <sensor.h>
This Sensor API provides functions to define a new sensor instance from an application. Other applications are able to be notified whenever a new sensor instance is registered and listen to the new sensor.
Functions | |
int | sensor_create_provider (const char *uri, sensor_provider_h *provider) |
Creates a sensor provider. | |
int | sensor_add_provider (sensor_provider_h provider) |
Registers the sensor provider. | |
int | sensor_remove_provider (sensor_provider_h provider) |
Unregisters the sensor provider. | |
int | sensor_destroy_provider (sensor_provider_h provider) |
Releases all the resources allocated for the sensor provider. | |
int | sensor_provider_set_name (sensor_provider_h provider, const char *name) |
Sets the name to the sensor provider. | |
int | sensor_provider_set_vendor (sensor_provider_h provider, const char *vendor) |
Sets the vendor to the sensor provider. | |
int | sensor_provider_set_range (sensor_provider_h provider, float min_range, float max_range) |
Sets the range of possible sensor values to the sensor provider. | |
int | sensor_provider_set_resolution (sensor_provider_h provider, float resolution) |
Sets the resolution of sensor values to the sensor provider. | |
int | sensor_provider_set_start_cb (sensor_provider_h provider, sensor_provider_start_cb callback, void *user_data) |
Registers the callback function to be invoked when a listener starts the sensor provider. | |
int | sensor_provider_set_stop_cb (sensor_provider_h provider, sensor_provider_stop_cb callback, void *user_data) |
Registers the callback function to be invoked when a sensor listener stops the sensor provider. | |
int | sensor_provider_set_interval_changed_cb (sensor_provider_h provider, sensor_provider_interval_changed_cb callback, void *user_data) |
Registers the callback function to be invoked when the interval is changed. | |
int | sensor_provider_publish (sensor_provider_h provider, sensor_event_s event) |
Publishes a sensor event through the declared sensor. | |
Typedefs | |
typedef struct _sensor_provider_s * | sensor_provider_h |
Sensor provider handle. | |
typedef void(* | sensor_provider_start_cb )(sensor_provider_h provider, void *user_data) |
Called when a sensor listener starts the sensor provider. | |
typedef void(* | sensor_provider_stop_cb )(sensor_provider_h provider, void *user_data) |
Called when a sensor listener stops the sensor provider. | |
typedef void(* | sensor_provider_interval_changed_cb )(sensor_provider_h provider, unsigned int interval_ms, void *user_data) |
Called when the interval of the sensor provider is changed. |
typedef struct _sensor_provider_s* sensor_provider_h |
Sensor provider handle.
One or more sensor providers can be created by using sensor_create_provider(). The sensor's data can be published to listeners, via the provider.
typedef void(* sensor_provider_interval_changed_cb)(sensor_provider_h provider, unsigned int interval_ms, void *user_data) |
Called when the interval of the sensor provider is changed.
[in] | provider | The sensor provider handle |
[in] | interval_ms | The interval |
[in] | user_data | The user data to be passed to the callback function |
typedef void(* sensor_provider_start_cb)(sensor_provider_h provider, void *user_data) |
Called when a sensor listener starts the sensor provider.
[in] | provider | The sensor provider handle |
[in] | user_data | The user data to be passed to the callback function |
typedef void(* sensor_provider_stop_cb)(sensor_provider_h provider, void *user_data) |
Called when a sensor listener stops the sensor provider.
[in] | provider | The sensor provider handle |
[in] | user_data | The user data to be passed to the callback function |
int sensor_add_provider | ( | sensor_provider_h | provider | ) |
Registers the sensor provider.
A sensor provider is created via sensor_create_provider(), and the three callback functions sensor_provider_start_cb(), sensor_provider_stop_cb(), and sensor_provider_set_interval_changed_cb() should be set in advance.
[in] | provider | The sensor provider handle |
SENSOR_ERROR_NONE | Successful |
SENSOR_ERROR_INVALID_PARAMETER | Invalid parameter |
SENSOR_ERROR_PERMISSION_DENIED | Permission denied |
SENSOR_ERROR_OPERATION_FAILED | Operation failed |
int sensor_create_provider | ( | const char * | uri, |
sensor_provider_h * | provider | ||
) |
Creates a sensor provider.
This function creates a sensor provider handle with a given URI. The URI should be in the valid form described in Sensor URIs. In addition, it is not allowed to set the vendor in the URI to "tizen.org", as it is pre-assigned to the platform-defined sensors.
[in] | uri | The URI of sensor to be created |
[out] | provider | The sensor provider handle |
SENSOR_ERROR_NONE | Successful |
SENSOR_ERROR_INVALID_PARAMETER | Invalid parameter |
SENSOR_ERROR_OUT_OF_MEMORY | Out of memory |
SENSOR_ERROR_OPERATION_FAILED | Operation failed |
int sensor_destroy_provider | ( | sensor_provider_h | provider | ) |
Releases all the resources allocated for the sensor provider.
[in] | provider | The sensor provider handle |
SENSOR_ERROR_NONE | Successful |
SENSOR_ERROR_INVALID_PARAMETER | Invalid parameter |
int sensor_provider_publish | ( | sensor_provider_h | provider, |
sensor_event_s | event | ||
) |
Publishes a sensor event through the declared sensor.
This function publishes a sensor's data to its listeners.
[in] | provider | The sensor provider handle |
[out] | event | The sensor event |
SENSOR_ERROR_NONE | Successful |
SENSOR_ERROR_INVALID_PARAMETER | Invalid parameter |
SENSOR_ERROR_OPERATION_FAILED | Operation failed |
int sensor_provider_set_interval_changed_cb | ( | sensor_provider_h | provider, |
sensor_provider_interval_changed_cb | callback, | ||
void * | user_data | ||
) |
Registers the callback function to be invoked when the interval is changed.
[in] | provider | The sensor provider handle |
[in] | callback | The callback function to attach to the provider handle |
[in] | user_data | The user data to be passed to the callback function |
SENSOR_ERROR_NONE | Successful |
SENSOR_ERROR_INVALID_PARAMETER | Invalid parameter |
SENSOR_ERROR_OPERATION_FAILED | Operation failed |
int sensor_provider_set_name | ( | sensor_provider_h | provider, |
const char * | name | ||
) |
Sets the name to the sensor provider.
[in] | provider | The sensor provider handle |
[in] | name | The name of the sensor |
SENSOR_ERROR_NONE | Successful |
SENSOR_ERROR_INVALID_PARAMETER | Invalid parameter |
int sensor_provider_set_range | ( | sensor_provider_h | provider, |
float | min_range, | ||
float | max_range | ||
) |
Sets the range of possible sensor values to the sensor provider.
[in] | provider | The sensor provider handle |
[in] | min_range | The lower bound |
[in] | max_range | The upper bound |
SENSOR_ERROR_NONE | Successful |
SENSOR_ERROR_INVALID_PARAMETER | Invalid parameter |
int sensor_provider_set_resolution | ( | sensor_provider_h | provider, |
float | resolution | ||
) |
Sets the resolution of sensor values to the sensor provider.
[in] | provider | The sensor provider handle |
[in] | resolution | The resolution |
SENSOR_ERROR_NONE | Successful |
SENSOR_ERROR_INVALID_PARAMETER | Invalid parameter |
int sensor_provider_set_start_cb | ( | sensor_provider_h | provider, |
sensor_provider_start_cb | callback, | ||
void * | user_data | ||
) |
Registers the callback function to be invoked when a listener starts the sensor provider.
[in] | provider | The provider handle |
[in] | callback | The callback function to attach to the provider handle |
[in] | user_data | The user data to be passed to the callback function |
SENSOR_ERROR_NONE | Successful |
SENSOR_ERROR_INVALID_PARAMETER | Invalid parameter |
SENSOR_ERROR_OPERATION_FAILED | Operation failed |
int sensor_provider_set_stop_cb | ( | sensor_provider_h | provider, |
sensor_provider_stop_cb | callback, | ||
void * | user_data | ||
) |
Registers the callback function to be invoked when a sensor listener stops the sensor provider.
[in] | provider | The sensor provider handle |
[in] | callback | The callback function to attach to the provider handle |
[in] | user_data | The user data to be passed to the callback function |
SENSOR_ERROR_NONE | Successful |
SENSOR_ERROR_INVALID_PARAMETER | Invalid parameter |
SENSOR_ERROR_OPERATION_FAILED | Operation failed |
int sensor_provider_set_vendor | ( | sensor_provider_h | provider, |
const char * | vendor | ||
) |
Sets the vendor to the sensor provider.
[in] | provider | The sensor provider handle |
[in] | vendor | The vendor of the sensor |
SENSOR_ERROR_NONE | Successful |
SENSOR_ERROR_INVALID_PARAMETER | Invalid parameter |
int sensor_remove_provider | ( | sensor_provider_h | provider | ) |
Unregisters the sensor provider.
[in] | provider | The sensor provider handle |
SENSOR_ERROR_NONE | Successful |
SENSOR_ERROR_INVALID_PARAMETER | Invalid parameter |
SENSOR_ERROR_OPERATION_FAILED | Operation failed |