Tizen Native API
5.0
|
The Sensor Recorder API provides functions to start/stop recording sensor events and read the recorded data.
#include <sensor.h>
This Sensor API provides functions to record sensors events in the device. Several sensors are typically available on mobile devices.
Functions | |
int | sensor_recorder_is_supported (sensor_type_e type, bool *supported) |
Checks whether it is supported to record a given sensor type. | |
int | sensor_recorder_start (sensor_type_e type, sensor_recorder_option_h option) |
Starts to record a given sensor type. | |
int | sensor_recorder_stop (sensor_type_e type) |
Stops recording a given sensor type. | |
int | sensor_recorder_create_option (sensor_recorder_option_h *option) |
Creates a recorder option handle. | |
int | sensor_recorder_destroy_option (sensor_recorder_option_h option) |
Destroys a recorder option handle. | |
int | sensor_recorder_option_set_int (sensor_recorder_option_h option, sensor_recorder_option_e param, int value) |
Sets a recording option parameter. | |
int | sensor_recorder_create_query (sensor_recorder_query_h *query) |
Creates a recorder query handle. | |
int | sensor_recorder_destroy_query (sensor_recorder_query_h query) |
Destroys a recorder query handle. | |
int | sensor_recorder_query_set_int (sensor_recorder_query_h query, sensor_recorder_query_e param, int value) |
Sets an integer-type query parameter. | |
int | sensor_recorder_query_set_time (sensor_recorder_query_h query, sensor_recorder_query_e param, time_t t) |
Sets a time-type query parameter. | |
int | sensor_recorder_read (sensor_type_e type, sensor_recorder_query_h query, sensor_recorder_data_cb cb, void *user_data) |
Queries the recorded data asynchronously. | |
int | sensor_recorder_read_sync (sensor_type_e type, sensor_recorder_query_h query, sensor_recorder_data_cb cb, void *user_data) |
Queries the recorded data synchronously. | |
int | sensor_recorder_data_get_time (sensor_recorder_data_h data, time_t *start_time, time_t *end_time) |
Gets the start and the end time of the time period of a given record data. | |
int | sensor_recorder_data_get_int (sensor_recorder_data_h data, sensor_recorder_data_e key, int *value) |
Gets an integer value from a record data. | |
int | sensor_recorder_data_get_double (sensor_recorder_data_h data, sensor_recorder_data_e key, double *value) |
Gets a double value from a record data. | |
Typedefs | |
typedef void * | sensor_recorder_option_h |
Option handle to contain recording policies and parameters. | |
typedef void * | sensor_recorder_query_h |
Query handle to contain filtering and aggregation parameters for recorded data. | |
typedef void * | sensor_recorder_data_h |
Data handle to contain retrieved sensor records. | |
typedef bool(* | sensor_recorder_data_cb )(sensor_type_e type, sensor_recorder_data_h data, int remains, sensor_error_e error, void *user_data) |
Called when the query results are retrieved. |
typedef bool(* sensor_recorder_data_cb)(sensor_type_e type, sensor_recorder_data_h data, int remains, sensor_error_e error, void *user_data) |
Called when the query results are retrieved.
One of the following errors can be delivered.
SENSOR_ERROR_NONE, Successful
SENSOR_ERROR_OPERATION_FAILED, Operation failed
SENSOR_ERROR_NO_DATA, No data retrieved.
[in] | type | Sensor type |
[in] | data | Retrieved data record |
[in] | remains | Number of remaining records to be delivered |
[in] | error | Error |
[in] | user_data | The user data passed from sensor_recorder_read() or sensor_recorder_read_sync() |
true
, it continues to iterate to the next record; If false
, the iteration stops typedef void* sensor_recorder_data_h |
Data handle to contain retrieved sensor records.
typedef void* sensor_recorder_option_h |
Option handle to contain recording policies and parameters.
one or more sensor options can be created by using sensor_recorder_create_option().
typedef void* sensor_recorder_query_h |
Query handle to contain filtering and aggregation parameters for recorded data.
one or more sensor options can be created by using sensor_recorder_create_query().
Enumeration for data attributes can be contained in sensor_recorder_data_h.
SENSOR_RECORDER_DATA_STEPS |
Count of both walking and running steps; int |
SENSOR_RECORDER_DATA_WALK_STEPS |
Count of walking steps; int |
SENSOR_RECORDER_DATA_RUN_STEPS |
Count of running steps; int |
SENSOR_RECORDER_DATA_DISTANCE |
Distance walked or ran (m); double |
SENSOR_RECORDER_DATA_CALORIE |
Calorie burned (kcal); double |
SENSOR_RECORDER_DATA_HEART_RATE |
Heart Rate (BPM); int |
SENSOR_RECORDER_DATA_SLEEP_STATE |
Sleep state; int; One of sensor_sleep_state_e |
SENSOR_RECORDER_DATA_PRESSURE |
Pressure; double |
SENSOR_RECORDER_DATA_MAX_PRESSURE |
Max pressure; double |
SENSOR_RECORDER_DATA_MIN_PRESSURE |
Min pressure; double |
SENSOR_RECORDER_DATA_AVERAGE_PRESSURE |
Average pressure; double |
Enumeration for intervals between data records.
Some sensor types including SENSOR_HRM may not fit to continuous monitoring and recording. To reduce the battery use for recording such sensors, recording interval between each sensor data is chosen. For example, an application set the interval of 1 hour, the platform tries to retrieve the sensor data only once per hour, thus it will be more battery efficient than to listen the sensor data continuously.
If the application does not set the interval explicitly, the default value is chosen. The default values are differ from sensor to sensor.
Enumeration for option parameters for sensor recording.
None, one, or more option parameters can be set to sensor_recorder_option_h, then applications can request to record a specific sensor with the parameters via sensor_recorder_start(). If a parameter is not supported for the specified sensor type, it will be ignored.
SENSOR_RECORDER_OPTION_RETENTION_PERIOD |
Desired retention period for the recorded sensor data (hours); int; |
SENSOR_RECORDER_OPTION_INTERVAL |
Desired interval between data records (minutes); int; see sensor_recorder_interval_e |
Enumeration for filtering and aggregation parameters for querying sensor records.
None, one, or more query parameters can be set to sensor_recorder_query_h, to specify the data to be retrieved via sensor_recorder_read(). If a necessary parameter is not set, the default value is chosen.
SENSOR_RECORDER_QUERY_START_TIME |
Start time of the data to be queried (Epoch); time_t; If unspecified, 1 day ago |
SENSOR_RECORDER_QUERY_END_TIME |
End time of the data to be queried (Epoch); time_t; If unspecified, the current time |
SENSOR_RECORDER_QUERY_ANCHOR_TIME |
The anchor time to slice the querying duration of time (Epoch); time_t; It needs to be set with SENSOR_RECORDER_QUERY_TIME_INTERVAL, otherwise, it is ignored |
SENSOR_RECORDER_QUERY_TIME_INTERVAL |
The interval of each sliced querying duration (minutes); int |
int sensor_recorder_create_option | ( | sensor_recorder_option_h * | option | ) |
Creates a recorder option handle.
[out] | option | Option 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_recorder_create_query | ( | sensor_recorder_query_h * | query | ) |
Creates a recorder query handle.
[out] | query | Query 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_recorder_data_get_double | ( | sensor_recorder_data_h | data, |
sensor_recorder_data_e | key, | ||
double * | value | ||
) |
Gets a double value from a record data.
[in] | data | Record data handle |
[in] | key | Data attribute to retrieve |
[out] | value | Retrieved value |
SENSOR_ERROR_NONE | Successful |
SENSOR_ERROR_INVALID_PARAMETER | Invalid parameter |
SENSOR_ERROR_OPERATION_FAILED | Operation failed |
SENSOR_ERROR_NO_DATA | No data retrieved |
int sensor_recorder_data_get_int | ( | sensor_recorder_data_h | data, |
sensor_recorder_data_e | key, | ||
int * | value | ||
) |
Gets an integer value from a record data.
[in] | data | Record data handle |
[in] | key | Data attribute to retrieve |
[out] | value | Retrieved value |
SENSOR_ERROR_NONE | Successful |
SENSOR_ERROR_INVALID_PARAMETER | Invalid parameter |
SENSOR_ERROR_OPERATION_FAILED | Operation failed |
SENSOR_ERROR_NO_DATA | No data retrieved |
int sensor_recorder_data_get_time | ( | sensor_recorder_data_h | data, |
time_t * | start_time, | ||
time_t * | end_time | ||
) |
Gets the start and the end time of the time period of a given record data.
[in] | data | Record data handle |
[out] | start_time | Start time of the time period of the record |
[out] | end_time | End time of the time period of the record |
SENSOR_ERROR_NONE | Successful |
SENSOR_ERROR_INVALID_PARAMETER | Invalid parameter |
SENSOR_ERROR_OPERATION_FAILED | Operation failed |
int sensor_recorder_destroy_option | ( | sensor_recorder_option_h | option | ) |
Destroys a recorder option handle.
[in] | option | Option handle |
SENSOR_ERROR_NONE | Successful |
SENSOR_ERROR_INVALID_PARAMETER | Invalid parameter |
SENSOR_ERROR_OPERATION_FAILED | Operation failed |
int sensor_recorder_destroy_query | ( | sensor_recorder_query_h | query | ) |
Destroys a recorder query handle.
[in] | query | Query handle |
SENSOR_ERROR_NONE | Successful |
SENSOR_ERROR_INVALID_PARAMETER | Invalid parameter |
SENSOR_ERROR_OPERATION_FAILED | Operation failed |
int sensor_recorder_is_supported | ( | sensor_type_e | type, |
bool * | supported | ||
) |
Checks whether it is supported to record a given sensor type.
[in] | type | A sensor type to check |
[out] | supported | If supported, true ; Otherwise false |
SENSOR_ERROR_NONE | Successful |
SENSOR_ERROR_INVALID_PARAMETER | Invalid parameter |
SENSOR_ERROR_OPERATION_FAILED | Operation failed |
int sensor_recorder_option_set_int | ( | sensor_recorder_option_h | option, |
sensor_recorder_option_e | param, | ||
int | value | ||
) |
Sets a recording option parameter.
[in] | option | Option handle |
[in] | param | Option parameter |
[in] | value | Value |
SENSOR_ERROR_NONE | Successful |
SENSOR_ERROR_INVALID_PARAMETER | Invalid parameter |
SENSOR_ERROR_OPERATION_FAILED | Operation failed |
int sensor_recorder_query_set_int | ( | sensor_recorder_query_h | query, |
sensor_recorder_query_e | param, | ||
int | value | ||
) |
Sets an integer-type query parameter.
[in] | query | Query handle |
[in] | param | Query parameter |
[in] | value | Value |
SENSOR_ERROR_NONE | Successful |
SENSOR_ERROR_INVALID_PARAMETER | Invalid parameter |
SENSOR_ERROR_OPERATION_FAILED | Operation failed |
int sensor_recorder_query_set_time | ( | sensor_recorder_query_h | query, |
sensor_recorder_query_e | param, | ||
time_t | t | ||
) |
Sets a time-type query parameter.
[in] | query | Query handle |
[in] | param | Query parameter |
[in] | t | Time |
SENSOR_ERROR_NONE | Successful |
SENSOR_ERROR_INVALID_PARAMETER | Invalid parameter |
SENSOR_ERROR_OPERATION_FAILED | Operation failed |
int sensor_recorder_read | ( | sensor_type_e | type, |
sensor_recorder_query_h | query, | ||
sensor_recorder_data_cb | cb, | ||
void * | user_data | ||
) |
Queries the recorded data asynchronously.
[in] | type | Sensor type |
[in] | query | Query handle |
[in] | cb | Callback function to receive the queried data |
[in] | user_data | User data to be passed to the callback function |
SENSOR_ERROR_NONE | Successful |
SENSOR_ERROR_INVALID_PARAMETER | Invalid parameter |
SENSOR_ERROR_NOT_SUPPORTED | Not supported to record the sensor type |
SENSOR_ERROR_PERMISSION_DENIED | Permission denied |
SENSOR_ERROR_OPERATION_FAILED | Operation failed |
int sensor_recorder_read_sync | ( | sensor_type_e | type, |
sensor_recorder_query_h | query, | ||
sensor_recorder_data_cb | cb, | ||
void * | user_data | ||
) |
Queries the recorded data synchronously.
[in] | type | Sensor type |
[in] | query | Query handle |
[in] | cb | Callback function to receive the queried data |
[in] | user_data | User data to be passed to the callback function |
SENSOR_ERROR_NONE | Successful |
SENSOR_ERROR_INVALID_PARAMETER | Invalid parameter |
SENSOR_ERROR_NOT_SUPPORTED | Not supported to record the sensor type |
SENSOR_ERROR_PERMISSION_DENIED | Permission denied |
SENSOR_ERROR_OPERATION_FAILED | Operation failed |
SENSOR_ERROR_NO_DATA | No data retrieved |
int sensor_recorder_start | ( | sensor_type_e | type, |
sensor_recorder_option_h | option | ||
) |
Starts to record a given sensor type.
[in] | type | A sensor type to be recorded |
[in] | option | Option |
SENSOR_ERROR_NONE | Successful |
SENSOR_ERROR_INVALID_PARAMETER | Invalid parameter |
SENSOR_ERROR_NOT_SUPPORTED | Not supported to record the sensor type |
SENSOR_ERROR_PERMISSION_DENIED | Permission denied |
SENSOR_ERROR_OPERATION_FAILED | Operation failed |
SENSOR_ERROR_NOT_AVAILABLE | The sensor is already being recorded by the request of the current application |
int sensor_recorder_stop | ( | sensor_type_e | type | ) |
Stops recording a given sensor type.
[in] | type | A sensor type being recorded |
SENSOR_ERROR_NONE | Successful |
SENSOR_ERROR_INVALID_PARAMETER | Invalid parameter |
SENSOR_ERROR_NOT_SUPPORTED | The sensor type is not supported |
SENSOR_ERROR_OPERATION_FAILED | Operation failed |