+++ /dev/null
-Pius Lee <pius.lee@samsung.com>
-
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-SET(fw_name "capi-system-sensor")
+PROJECT(capi-system-sensor)
-PROJECT(${fw_name})
-
-SET(CMAKE_INSTALL_PREFIX /usr)
+# Setup for pkgconfig File
+SET(fw_name "capi-system-sensor")
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(VERSION 1.0)
-SET(INC_DIR include)
-INCLUDE_DIRECTORIES(${INC_DIR})
-
-SET(dependents "dlog sensor capi-base-common")
-SET(pc_dependents "capi-base-common")
+INCLUDE_DIRECTORIES(include)
+# Build options
INCLUDE(FindPkgConfig)
-pkg_check_modules(${fw_name} REQUIRED ${dependents})
+pkg_check_modules(${fw_name} REQUIRED dlog sensor capi-base-common)
+
FOREACH(flag ${${fw_name}_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror -g -fdump-rtl-expand")
-SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
-
-IF("${ARCH}" STREQUAL "arm")
- ADD_DEFINITIONS("-DTARGET")
-ENDIF("${ARCH}" STREQUAL "arm")
-
-ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
-ADD_DEFINITIONS("-DTIZEN_DEBUG")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIC -Wall -Werror -g -fdump-rtl-expand")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -std=c++0x")
+SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl, --rpath=${LIB_INSTALL_DIR}")
-SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}")
+# Internal Logging Option
+#ADD_DEFINITIONS("-DTIZEN_DEBUG")
-aux_source_directory(src SOURCES)
+# Complile Source files
+AUX_SOURCE_DIRECTORY(src SOURCES)
ADD_LIBRARY(${fw_name} SHARED ${SOURCES})
TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS})
-
-SET_TARGET_PROPERTIES(${fw_name}
- PROPERTIES
- VERSION ${FULLVER}
- SOVERSION ${MAJORVER}
- CLEAN_DIRECT_OUTPUT 1
-)
-
-INSTALL(TARGETS ${fw_name} DESTINATION ${LIB_INSTALL_DIR})
-INSTALL(
- DIRECTORY ${INC_DIR}/ DESTINATION include/system
- FILES_MATCHING
- PATTERN "*_private.h" EXCLUDE
- PATTERN "${INC_DIR}/*.h"
- )
-
-SET(PC_NAME ${fw_name})
-SET(PC_REQUIRED ${pc_dependents})
-SET(PC_LDFLAGS -l${fw_name})
-
-CONFIGURE_FILE(
- ${fw_name}.pc.in
- ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc
- @ONLY
-)
+SET_TARGET_PROPERTIES(${fw_name} PROPERTIES VERSION ${FULLVER} SOVERSION ${MAJORVER} CLEAN_DIRECT_OUTPUT 1)
+CONFIGURE_FILE(${fw_name}.pc.in ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc @ONLY)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+INSTALL(TARGETS ${fw_name} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
+INSTALL(FILES include/sensors.h DESTINATION ${INCLUDE_INSTALL_DIR}/sensor)
+# ###
IF(UNIX)
-
ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution)
ADD_CUSTOM_COMMAND(
- DEPENDS clean
+ DEPENDS clean
COMMENT "distribution clean"
COMMAND find
- ARGS .
+ ARGS .
-not -name config.cmake -and \(
-name tester.c -or
-name Testing -or
TARGET distclean
VERBATIM
)
-
ENDIF(UNIX)
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_"/>
+ </request>
+</manifest>
+
-
# Package Information for pkg-config
prefix=@PREFIX@
-exec_prefix=/usr
+exec_prefix=@PREFIX@/bin
libdir=@LIB_INSTALL_DIR@
-includedir=/usr/include/system
+includedir=@INCLUDE_INSTALL_DIR@/sensor
-Name: @PC_NAME@
-Description: @PACKAGE_DESCRIPTION@
+Name: capi-system-sensor
+Description: A sensor library
Version: @VERSION@
-Requires: @PC_REQUIRED@
-Libs: -L${libdir} @PC_LDFLAGS@
-Cflags: -I${includedir}
+Requires: capi-base-common
+Libs: -L${libdir} -lcapi-system-sensor
+Cflags: -I${includedir}
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __TIZEN_SYSTEM_SENSOR_DOC_H__
+#define __TIZEN_SYSTEM_SENSOR_DOC_H__
+
+ /**
+ * @ingroup CAPI_SYSTEM_FRAMEWORK
+ * @defgroup CAPI_SYSTEM_SENSOR_MODULE Sensor
+ * @brief The @ref CAPI_SYSTEM_SENSOR_MODULE API provides functions to start/stop sensors and receive sensor information.
+ *
+ * @section CAPI_SYSTEM_SENSOR_MODULE_HEADER Required Header
+ * \#include <sensor.h>
+ *
+ * @section CAPI_SYSTEM_SENSOR_MODULE_OVERVIEW Overview
+ * This Sensor API provides functions to make use of sensors in the
+ * device. A variety of hardware sensors are typically available on
+ * mobile devices.
+ *
+ * @section CAPI_SYSTEM_SENSOR_MODULE_FEATURE Related Features
+ * This API is related with the following features:\n
+ * - http://tizen.org/feature/sensor.accelerometer\n
+ * - http://tizen.org/feature/sensor.barometer\n
+ * - http://tizen.org/feature/sensor.gyroscope\n
+ * - http://tizen.org/feature/sensor.magnetometer\n
+ * - http://tizen.org/feature/sensor.photometer\n
+ * - http://tizen.org/feature/sensor.proximity\n
+ * - http://tizen.org/feature/sensor.tiltmeter\n
+ * - http://tizen.org/feature/sensor.ultraviolet\n
+ * - http://tizen.org/feature/sensor.temperature\n
+ * - http://tizen.org/feature/sensor.humidity\n
+ * - http://tizen.org/feature/sensor.linear_acceleration\n
+ * - http://tizen.org/feature/sensor.rotation_vector\n
+ * - http://tizen.org/feature/sensor.gravity\n
+ *
+ * It is recommended to design feature related codes in your application for reliability.\n
+ *
+ * You can check if a devrice supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
+ *
+ * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
+ *
+ * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a>
+ *
+*/
+
+/**
+ * @ingroup CAPI_SYSTEM_SENSOR_MODULE
+ * @defgroup CAPI_SYSTEM_SENSOR_INFORMATION_MODULE Hardware Information
+ * @brief The @ref CAPI_SYSTEM_SENSOR_INFORMATION_MODULE API provides information about hardware.
+ * @section CAPI_SYSTEM_SENSOR_INFORMATION_MODULE_HEADER Required Header
+ * \#include <sensor.h>
+ * @section CAPI_SYSTEM_SENSOR_INFORMATION_MODULE_OVERVIEW Overview
+ * This API provides functions for hardware features, such as name, vendor and other information
+ * @section CAPI_SYSTEM_SENSOR_INFORMATION_MODULE_FEATURE Related Features
+ * This API is related with the following features:\n
+ * - http://tizen.org/feature/sensor.accelerometer\n
+ * - http://tizen.org/feature/sensor.barometer\n
+ * - http://tizen.org/feature/sensor.gyroscope\n
+ * - http://tizen.org/feature/sensor.magnetometer\n
+ * - http://tizen.org/feature/sensor.photometer\n
+ * - http://tizen.org/feature/sensor.proximity\n
+ * - http://tizen.org/feature/sensor.tiltmeter\n
+ * - http://tizen.org/feature/sensor.ultraviolet\n
+ * - http://tizen.org/feature/sensor.temperature\n
+ * - http://tizen.org/feature/sensor.humidity\n
+ * - http://tizen.org/feature/sensor.linear_acceleration\n
+ * - http://tizen.org/feature/sensor.rotation_vector\n
+ * - http://tizen.org/feature/sensor.gravity\n
+ *
+ * It is recommended to design feature related codes in your application for reliability.\n
+ *
+ * You can check if a devrice supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
+ *
+ * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
+ *
+ * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a>
+ *
+ */
+
+/**
+ * @ingroup CAPI_SYSTEM_SENSOR_MODULE
+ * @defgroup CAPI_SYSTEM_SENSOR_UTILITY_MODULE Utility
+ * @brief The @ref CAPI_SYSTEM_SENSOR_UTILITY_MODULE API provides utility functions.
+ * @section CAPI_SYSTEM_SENSOR_UTILITY_MODULE_HEADER Required Header
+ * \#include <sensor.h>
+ * @section CAPI_SYSTEM_SENSOR_UTILITY_MODULE_OVERVIEW Overview
+ * @section CAPI_SYSTEM_SENSOR_UTILITY_MODULE_FEATURE Related Features
+ * This API is related with the following features:\n
+ * - http://tizen.org/feature/sensor.accelerometer\n
+ * - http://tizen.org/feature/sensor.barometer\n
+ * - http://tizen.org/feature/sensor.gyroscope\n
+ * - http://tizen.org/feature/sensor.magnetometer\n
+ * - http://tizen.org/feature/sensor.photometer\n
+ * - http://tizen.org/feature/sensor.proximity\n
+ * - http://tizen.org/feature/sensor.tiltmeter\n
+ * - http://tizen.org/feature/sensor.ultraviolet\n
+ * - http://tizen.org/feature/sensor.temperature\n
+ * - http://tizen.org/feature/sensor.humidity\n
+ * - http://tizen.org/feature/sensor.linear_acceleration\n
+ * - http://tizen.org/feature/sensor.rotation_vector\n
+ * - http://tizen.org/feature/sensor.gravity\n
+ *
+ * It is recommended to design feature related codes in your application for reliability.\n
+ *
+ * You can check if a devrice supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
+ *
+ * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
+ *
+ * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a>
+ *
+ *
+ */
+
+
+#endif // __TIZEN_SYSTEM_SENSORS_DOC_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _SENSOR_LOG_H_
+#define _SENSOR_LOG_H_
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <dlog.h>
+
+#define _DEBUG 1
+
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_SYSTEM_SENSOR"
+
+#define _MSG_SENSOR_ERROR_IO_ERROR "Io Error"
+#define _MSG_SENSOR_ERROR_INVALID_PARAMETER "Invalid Parameter"
+#define _MSG_SENSOR_ERROR_OUT_OF_MEMORY "Out of Memory"
+#define _MSG_SENSOR_ERROR_NOT_NEED_CALIBRATION "Not need calibration"
+#define _MSG_SENSOR_ERROR_NOT_SUPPORTED "Not supported"
+#define _MSG_SENSOR_ERROR_OPERATION_FAILED "Operation failed"
+
+#define _E_MSG(err) SLOGE(_MSG_##err "(0x%08x)", (err))
+
+#ifdef _DEBUG
+ #define _E(fmt, args...) SLOGE(fmt, ##args)
+ #define _W(fmt, args...) SLOGW(fmt, ##args)
+ #define _I(fmt, args...) SLOGI(fmt, ##args)
+ #define _D(fmt, args...) SLOGD(fmt, ##args)
+#else
+ #define _E(...)
+ #define _W(...)
+ #define _I(...)
+ #define _D(...)
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*_SENSOR_LOG_H_*/
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
- * limitations under the License.
+ * limitations under the License.
*/
-
-
-
#ifndef __SENSOR_PRIVATE_H__
#define __SENSOR_PRIVATE_H__
+struct sensor_listener_s {
+ int id;
+ int type;
+ int option;
+ unsigned int magic;
+ void *sensor;
+ void *callback;
+ void *user_data;
+ void *accu_callback;
+ void *accu_user_data;
+};
+
#ifdef __cplusplus
extern "C"
{
#endif
-enum _sensor_ids_index{
- ID_ACCELEOMETER,
- ID_GEOMAGNETIC,
- ID_GYROSCOPE,
- ID_LIGHT,
- ID_PROXIMITY,
- ID_MOTION,
- ID_NUMBERS
-};
-
-#define CB_NUMBERS (SENSOR_LAST)
-#define CALIB_CB_NUMBERS (SENSOR_ORIENTATION+1)
-#define WAKEUP_CB_NUMBERS (SENSOR_DEVICE_ORIENTATION+1)
-#define EMPTY_EVENT 0
-
-struct sensor_handle_s {
- int ids[ID_NUMBERS];
- int started[CB_NUMBERS];
- int sensor_option[CB_NUMBERS];
-
- void* cb_func[CB_NUMBERS];
- void* cb_user_data[CB_NUMBERS];
-
- void* calib_func[CALIB_CB_NUMBERS];
- void* calib_user_data[CALIB_CB_NUMBERS];
-
- void* wakeup_func[WAKEUP_CB_NUMBERS];
- void* wakeup_user_data[WAKEUP_CB_NUMBERS];
-};
-
-#define SENSOR_INIT(handle) \
-do { \
- handle->ids[ID_ACCELEOMETER] = -1; \
- handle->ids[ID_GEOMAGNETIC] = -1; \
- handle->ids[ID_GYROSCOPE] = -1; \
- handle->ids[ID_LIGHT] = -1; \
- handle->ids[ID_PROXIMITY] = -1; \
- handle->ids[ID_MOTION] = -1; \
- handle->started[SENSOR_ACCELEROMETER] = 0; \
- handle->started[SENSOR_GRAVITY] = 0; \
- handle->started[SENSOR_LINEAR_ACCELERATION] = 0; \
- handle->started[SENSOR_DEVICE_ORIENTATION] = 0; \
- handle->started[SENSOR_MAGNETIC] = 0; \
- handle->started[SENSOR_ORIENTATION] = 0; \
- handle->started[SENSOR_GYROSCOPE] = 0; \
- handle->started[SENSOR_LIGHT] = 0; \
- handle->started[SENSOR_PROXIMITY] = 0; \
- handle->started[SENSOR_MOTION_SNAP] = 0; \
- handle->started[SENSOR_MOTION_SHAKE] = 0; \
- handle->started[SENSOR_MOTION_DOUBLETAP] = 0; \
- handle->started[SENSOR_MOTION_PANNING] = 0; \
- handle->started[SENSOR_MOTION_PANNING_BROWSE] = 0; \
- handle->started[SENSOR_MOTION_TILT] = 0; \
- handle->started[SENSOR_MOTION_FACEDOWN] = 0; \
- handle->started[SENSOR_MOTION_DIRECTCALL] = 0; \
- handle->started[SENSOR_MOTION_SMART_ALERT] = 0; \
- handle->started[SENSOR_MOTION_NO_MOVE] = 0; \
- handle->sensor_option[SENSOR_ACCELEROMETER] = 0; \
- handle->sensor_option[SENSOR_GRAVITY] = 0; \
- handle->sensor_option[SENSOR_LINEAR_ACCELERATION] = 0; \
- handle->sensor_option[SENSOR_DEVICE_ORIENTATION] = 0; \
- handle->sensor_option[SENSOR_MAGNETIC] = 0; \
- handle->sensor_option[SENSOR_ORIENTATION] = 0; \
- handle->sensor_option[SENSOR_GYROSCOPE] = 0; \
- handle->sensor_option[SENSOR_LIGHT] = 0; \
- handle->sensor_option[SENSOR_PROXIMITY] = 0; \
- handle->sensor_option[SENSOR_MOTION_SNAP] = 0; \
- handle->sensor_option[SENSOR_MOTION_SHAKE] = 0; \
- handle->sensor_option[SENSOR_MOTION_DOUBLETAP] = 0; \
- handle->sensor_option[SENSOR_MOTION_PANNING] = 0; \
- handle->sensor_option[SENSOR_MOTION_PANNING_BROWSE] = 0; \
- handle->sensor_option[SENSOR_MOTION_TILT] = 0; \
- handle->sensor_option[SENSOR_MOTION_FACEDOWN] = 0; \
- handle->sensor_option[SENSOR_MOTION_DIRECTCALL] = 0; \
- handle->sensor_option[SENSOR_MOTION_SMART_ALERT] = 1; \
- handle->sensor_option[SENSOR_MOTION_NO_MOVE] = 0; \
- handle->cb_func[SENSOR_ACCELEROMETER] = NULL; \
- handle->cb_func[SENSOR_GRAVITY] = NULL; \
- handle->cb_func[SENSOR_LINEAR_ACCELERATION] = NULL; \
- handle->cb_func[SENSOR_DEVICE_ORIENTATION] = NULL; \
- handle->cb_func[SENSOR_MAGNETIC] = NULL; \
- handle->cb_func[SENSOR_ORIENTATION] = NULL; \
- handle->cb_func[SENSOR_GYROSCOPE] = NULL; \
- handle->cb_func[SENSOR_LIGHT] = NULL; \
- handle->cb_func[SENSOR_PROXIMITY] = NULL; \
- handle->cb_func[SENSOR_MOTION_SNAP] = NULL; \
- handle->cb_func[SENSOR_MOTION_SHAKE] = NULL; \
- handle->cb_func[SENSOR_MOTION_DOUBLETAP] = NULL; \
- handle->cb_func[SENSOR_MOTION_PANNING] = NULL; \
- handle->cb_func[SENSOR_MOTION_PANNING_BROWSE] = NULL; \
- handle->cb_func[SENSOR_MOTION_TILT] = NULL; \
- handle->cb_func[SENSOR_MOTION_FACEDOWN] = NULL; \
- handle->cb_func[SENSOR_MOTION_DIRECTCALL] = NULL; \
- handle->cb_func[SENSOR_MOTION_SMART_ALERT] = NULL; \
- handle->cb_func[SENSOR_MOTION_NO_MOVE] = NULL; \
- handle->cb_user_data[SENSOR_ACCELEROMETER] = NULL; \
- handle->cb_user_data[SENSOR_GRAVITY] = NULL; \
- handle->cb_user_data[SENSOR_LINEAR_ACCELERATION] = NULL; \
- handle->cb_user_data[SENSOR_DEVICE_ORIENTATION] = NULL; \
- handle->cb_user_data[SENSOR_MAGNETIC] = NULL; \
- handle->cb_user_data[SENSOR_ORIENTATION] = NULL; \
- handle->cb_user_data[SENSOR_GYROSCOPE] = NULL; \
- handle->cb_user_data[SENSOR_LIGHT] = NULL; \
- handle->cb_user_data[SENSOR_PROXIMITY] = NULL; \
- handle->cb_user_data[SENSOR_MOTION_SNAP] = NULL; \
- handle->cb_user_data[SENSOR_MOTION_SHAKE] = NULL; \
- handle->cb_user_data[SENSOR_MOTION_DOUBLETAP] = NULL; \
- handle->cb_user_data[SENSOR_MOTION_PANNING] = NULL; \
- handle->cb_user_data[SENSOR_MOTION_PANNING_BROWSE] = NULL; \
- handle->cb_user_data[SENSOR_MOTION_TILT] = NULL; \
- handle->cb_user_data[SENSOR_MOTION_FACEDOWN] = NULL; \
- handle->cb_user_data[SENSOR_MOTION_DIRECTCALL] = NULL; \
- handle->cb_user_data[SENSOR_MOTION_SMART_ALERT] = NULL; \
- handle->cb_user_data[SENSOR_MOTION_NO_MOVE] = NULL; \
- handle->calib_func[SENSOR_ACCELEROMETER] = NULL; \
- handle->calib_func[SENSOR_GRAVITY] = NULL; \
- handle->calib_func[SENSOR_LINEAR_ACCELERATION] = NULL; \
- handle->calib_func[SENSOR_DEVICE_ORIENTATION] = NULL; \
- handle->calib_func[SENSOR_MAGNETIC] = NULL; \
- handle->calib_func[SENSOR_ORIENTATION] = NULL; \
- handle->calib_user_data[SENSOR_ACCELEROMETER] = NULL; \
- handle->calib_user_data[SENSOR_GRAVITY] = NULL; \
- handle->calib_user_data[SENSOR_LINEAR_ACCELERATION] = NULL; \
- handle->calib_user_data[SENSOR_DEVICE_ORIENTATION] = NULL; \
- handle->calib_user_data[SENSOR_MAGNETIC] = NULL; \
- handle->calib_user_data[SENSOR_ORIENTATION] = NULL; \
- handle->wakeup_func[SENSOR_ACCELEROMETER] = NULL; \
- handle->wakeup_user_data[SENSOR_ACCELEROMETER] = NULL;\
-}while(0) \
-
float clamp(float v);
int getAngleChange(float *R, float *prevR, float *angleChange);
int quatToMatrix(float *quat, float *R);
}
#endif
-#endif // __SENSOR_PRIVATE_H__
+#endif // __SENSOR_PRIVATE_H__
/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
- * limitations under the License.
+ * limitations under the License.
*/
-
-
-
#ifndef __SENSOR_H__
#define __SENSOR_H__
#endif
/**
+ * @file sensor.h
+ * @brief This file contains Sensor API related structures and enumerations.
+ */
+
+/**
* @addtogroup CAPI_SYSTEM_SENSOR_MODULE
* @{
*/
+#define MAX_VALUE_SIZE 16
+#ifndef TIZEN_ERROR_SENSOR
+#define TIZEN_ERROR_SENSOR -0x02440000
+#endif
+#ifndef TIZEN_ERROR_NOT_SUPPORTED
+#define TIZEN_ERROR_NOT_SUPPORTED (TIZEN_ERROR_MIN_PLATFORM_ERROR+2)
+#endif
+
/**
* @brief The sensor handle.
+ * @details This handle indicates a specific sensor itself.
+ * @since_tizen 2.3
+ */
+typedef void* sensor_h;
+
+
+/**
+ * @brief The listener handle.
+ * @details This listener is an event listener used to receive sensor data asynchronously.
+ * @since_tizen 2.3
+ */
+typedef struct sensor_listener_s *sensor_listener_h;
+
+
+/**
+ * @brief The structure type containing information of an event.
+ * @details It holds information such as timestamp, accuracy, and sensor values.
+ * @since_tizen 2.3
+ *
+ * @remarks If you use proximity sensor, see #sensor_proximity_e
*/
-typedef struct sensor_handle_s* sensor_h;
+typedef struct
+{
+ int accuracy; /**< Accuracy */
+ unsigned long long timestamp; /**< Timestamp */
+ int value_count; /**< Count of values */
+ float values[MAX_VALUE_SIZE]; /**< Sensor values */
+} sensor_event_s;
/**
-* @brief Enumerations of sensor data accuracy.
-*/
+ * @brief Enumeration for sensor data accuracy.
+ * @since_tizen 2.3
+ */
typedef enum
{
SENSOR_DATA_ACCURACY_UNDEFINED = -1, /**< Undefined accuracy */
/**
-* @brief Enumerations of error code for sensor.
+ * @brief Enumeration for sensor error.
+ * @since_tizen 2.3
*/
typedef enum
{
- SENSOR_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
+ SENSOR_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
SENSOR_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< I/O error */
SENSOR_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
- SENSOR_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_SYSTEM_CLASS | 0x02, /**< Out of memory */
- SENSOR_ERROR_NOT_NEED_CALIBRATION = TIZEN_ERROR_SYSTEM_CLASS | 0x03, /**< Sensor doesn't need calibration */
- SENSOR_ERROR_NOT_SUPPORTED = TIZEN_ERROR_SYSTEM_CLASS | 0x04, /**< Unsupported sensor in current device */
- SENSOR_ERROR_OPERATION_FAILED = TIZEN_ERROR_SYSTEM_CLASS | 0x06, /**< Operation failed */
-
+ SENSOR_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Unsupported sensor in the current device */
+ SENSOR_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
+ SENSOR_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
+ SENSOR_ERROR_NOT_NEED_CALIBRATION = TIZEN_ERROR_SENSOR | 0x03, /**< Sensor doesn't need calibration */
+ SENSOR_ERROR_OPERATION_FAILED = TIZEN_ERROR_SENSOR | 0x06, /**< Operation failed */
} sensor_error_e;
+/**
+ * @brief Enumeration for proximity sensor.
+ * @since_tizen 2.3
+ */
+typedef enum
+{
+ SENSOR_PROXIMITY_NEAR = 0, /**< The object is near */
+ SENSOR_PROXIMITY_FAR = 5, /**< The object is far */
+} sensor_proximity_e;
+
/**
-* @brief Enumerations of sensor type.
-*/
+ * @brief Enumeration for sensor types.
+ * @since_tizen 2.3
+ */
typedef enum
{
+ SENSOR_ALL = -1, /**< All sensors */
SENSOR_ACCELEROMETER, /**< Accelerometer */
- SENSOR_GRAVITY, /**< Gravity sensor */
+ SENSOR_GRAVITY, /**< Gravity sensor */
SENSOR_LINEAR_ACCELERATION, /**< Linear acceleration sensor */
- SENSOR_DEVICE_ORIENTATION, /**< Device orientation sensor */
SENSOR_MAGNETIC, /**< Magnetic sensor */
+ SENSOR_ROTATION_VECTOR, /**< Rotation Vector sensor */
SENSOR_ORIENTATION, /**< Orientation sensor */
SENSOR_GYROSCOPE, /**< Gyroscope sensor */
SENSOR_LIGHT, /**< Light sensor */
SENSOR_PROXIMITY, /**< Proximity sensor */
- SENSOR_MOTION_SNAP, /**< Snap motion sensor */
- SENSOR_MOTION_SHAKE, /**< Shake motion sensor */
- SENSOR_MOTION_DOUBLETAP, /**< Double tap motion sensor */
- SENSOR_MOTION_PANNING, /**< Panning motion sensor */
- SENSOR_MOTION_PANNING_BROWSE, /**< Panning browse motion sensor */
- SENSOR_MOTION_TILT, /**< Tilt motion sensor */
- SENSOR_MOTION_FACEDOWN, /**< Face to down motion sensor */
- SENSOR_MOTION_DIRECTCALL, /**< Direct call motion sensor */
- SENSOR_MOTION_SMART_ALERT, /**< Smart alert motion sensor */
- SENSOR_MOTION_NO_MOVE, /**< No move motion sensor */
- SENSOR_LAST /**< End of sensor enum values */
+ SENSOR_PRESSURE, /**< Pressure sensor */
+ SENSOR_ULTRAVIOLET, /**< Ultraviolet sensor */
+ SENSOR_TEMPERATURE, /**< Temperature sensor */
+ SENSOR_HUMIDITY, /**< Humidity sensor */
+ SENSOR_LAST, /**< End of sensor enum values */
+ SENSOR_CUSTOM = 10000 /**< Custom sensor */
} sensor_type_e;
-/**
- * @}
- */
-
-
-/**
- * @addtogroup CAPI_SYSTEM_SENSOR_MOTION_SNAP_MODULE
- * @{
- */
-
-/**
- * @brief Enumerations of snap motion event.
- */
-typedef enum
-{
- SENSOR_MOTION_SNAP_NONE, /**< No Snap */
- SENSOR_MOTION_SNAP_RIGHT, /**< Snap right to left */
- SENSOR_MOTION_SNAP_LEFT, /**< Snap left to right */
- SENSOR_MOTION_SNAP_X_POSITIVE = SENSOR_MOTION_SNAP_RIGHT, /**< Snap to positive direction in X-axis, it is the same as @SENSOR_MOTION_SNAP_RIGHT */
- SENSOR_MOTION_SNAP_X_NEGATIVE = SENSOR_MOTION_SNAP_LEFT, /**< Snap to negative direction in X-axis, it is the same as @SENSOR_MOTION_SNAP_LEFT */
- SENSOR_MOTION_SNAP_Y_POSITIVE, /**< Snap to positive direction in Y-axis */
- SENSOR_MOTION_SNAP_Y_NEGATIVE, /**< Snap to Negative direction in Y-axis */
- SENSOR_MOTION_SNAP_Z_POSITIVE, /**< Snap to positive direction in Z-axis */
- SENSOR_MOTION_SNAP_Z_NEGATIVE, /**< Snap to Negative direction in Z-axis */
-} sensor_motion_snap_e;
-/**
- * @}
- */
-
-/**
- * @addtogroup CAPI_SYSTEM_SENSOR_MOTION_SHAKE_MODULE
- * @{
- */
/**
- * @brief Enumerations of shake motion event.
+ * @brief Enumeration for sensor options.
+ * @since_tizen 2.3
*/
+#ifndef __SENSOR_COMMON_H__
typedef enum
{
- SENSOR_MOTION_SHAKE_NONE, /**< No Shake */
- SENSOR_MOTION_SHAKE_DETECTED, /**< Shake motion detected */
- SENSOR_MOTION_SHAKE_CONTINUING, /**< Shake motion continuing */
- SENSOR_MOTION_SHAKE_FINISHED, /**< Shake motion finished */
- SENSOR_MOTION_SHAKE_BROKEN, /**< Shake motion broken */
-} sensor_motion_shake_e;
-/**
- * @}
- */
-
-/**
- * @addtogroup CAPI_SYSTEM_SENSOR_MODULE
- * @{
- */
-
-/**
- * @brief Called when the current sensor reading falls outside of a defined normal range.
- *
- * @details When something is artificially influencing, such as ferrous metal objects or
- * electromagnetic fields (car electrical systems, automobile engines, steel pitons, etc.), this callback is called.
- * One way of implementing this callback is to notice a user to make big 8-like gesture with device.
- *
- * @param[in] user_data The user data passed from the callback registration function
- *
- * @see sensor_magnetic_set_calibration_cb()
- * @see sensor_magnetic_unset_calibration_cb()
- * @see sensor_orientation_set_calibration_cb()
- * @see sensor_orientation_unset_calibration_cb()
- */
-typedef void (*sensor_calibration_cb)(void *user_data);
-
+ SENSOR_OPTION_DEFAULT, /**< Does not receive data when the LCD is off and in the power save mode */
+ SENSOR_OPTION_ON_IN_SCREEN_OFF, /**< Receives data when the LCD is off */
+ SENSOR_OPTION_ON_IN_POWERSAVE_MODE, /**< Receives data in the power save mode */
+ SENSOR_OPTION_ALWAYS_ON, /**< Receives data when the LCD is off and in the power save mode */
+} sensor_option_e;
+#endif
/**
- * @brief Checks whether the given sensor type is available on a device.
- * @details
- * You need to check availability of a sensor first because this sensor may not be supported on the device.
+ * @brief Checks whether a given sensor type is available on a device.
+ * @details Availability of a sensor should be checked first because this sensor may not be supported on the device.
+ * @since_tizen 2.3
*
* @param[in] type The sensor type to check
- * @param[out] supported @c true if this sensor type is supported, otherwise @c false
+ * @param[out] supported If @c true this sensor type is supported,
+ * otherwise @c false
*
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #SENSOR_ERROR_NONE Successful
+ * @retval #SENSOR_ERROR_NOT_SUPPORTED The sensor type is not supported in the current device
+ * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
*
*/
int sensor_is_supported(sensor_type_e type, bool *supported);
-
/**
- * @brief Gets data specification for a sensor type, except motion sensors.
- *
- * @remark When the given @a type is one of the motion sensors, this function returns #SENSOR_ERROR_INVALID_PARAMETER.
+ * @brief Gets a specific sensor handle.
+ * @since_tizen 2.3
*
- * @param[in] type The sensor type to check
- * @param[out] vendor The vendor name of the sensor
- * @param[out] model The model name of the sensor
- * @param[out] max The maximum range of the sensor in the sensor's unit
- * @param[out] min The minimum range of the sensor in the sensor's unit
- * @param[out] resolution The resolution of the sensor
+ * @param[in] type The sensor type
+ * @param[out] sensor The sensor handle
*
- * @return 0 on success, otherwise a negative error value.
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_NOT_SUPPORTED The sensor type is not supported in current device
- *
- * @pre #sensor_is_supported()
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #SENSOR_ERROR_NONE Successful
+ * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SENSOR_ERROR_NOT_SUPPORTED The sensor type is not supported in the current device
+ * @retval #SENSOR_ERROR_PERMISSION_DENIED Permission denied
*/
-int sensor_get_spec(sensor_type_e type, char** vendor, char** model, float *max, float *min, float *resolution);
-
+int sensor_get_default_sensor(sensor_type_e type, sensor_h *sensor);
/**
- * @brief Creates a sensor handle.
+ * @brief Gets a sensor list.
+ * @since_tizen 2.3
+ * @remarks If you want to get a handle list of all sensors,
+ * use SENSOR_ALL type in sensor_type_e.
+ * @remarks The caller should explicitly free this list.
*
- * @remarks @a sensor must be released sensor_destroy() by you.
+ * @param[in] type The sensor type
+ * @param[out] list The sensor list
+ * @param[out] sensor_count The count of sensors
*
- * @param[out] sensor A new sensor handle to the sensors
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_OUT_OF_MEMORY Out of memory
- *
- * @see sensor_destroy()
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #SENSOR_ERROR_NONE Successful
+ * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SENSOR_ERROR_NOT_SUPPORTED The sensor type is not supported in the current device
+ * @retval #SENSOR_ERROR_PERMISSION_DENIED Permission denied
*/
-int sensor_create(sensor_h *sensor);
-
+int sensor_get_sensor_list(sensor_type_e type, sensor_h **list, int *sensor_count);
/**
- * @brief Destroys the sensor handle and releases all its resources.
- *
- * @remark After this function is called, the attached sensor will be detached and
- * the corresponding sensor connection will be released.
+ * @brief Called when a sensor event occurs.
+ * @since_tizen 2.3
*
- * @param[in] sensor The sensor handle
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @param[in] sensor The sensor handle
+ * @param[in] event The event information
+ * @param[in] data The user data passed from the callback registration function
*
- * @see sensor_create()
+ * @see sensor_create_listener()
+ * @see sensor_listener_set_event_cb()
+ * @see sensor_listener_unset_event_cb()
*/
-int sensor_destroy(sensor_h sensor);
-
+typedef void (*sensor_event_cb)(sensor_h sensor, sensor_event_s *event, void *data);
/**
- * @brief Starts sensor server for the given sensor handle and sensor type.
- * @details
- * After this function is called, sensor events will occur and
- * the specific sensor type related callback function will be called. An application can read sensor data.
- *
- * @param[in] sensor The sensor handle
- * @param[in] type The sensor type
+ * @brief Creates a sensor listener.
+ * @since_tizen 2.3
*
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_NOT_SUPPORTED The sensor type is not supported in current device
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @pre call sensor_create() before using this function.
- * @post This function invokes sensor_calibration_cb(), sensor_accelerometer_event_cb(), sensor_magnetic_event_cb(),
- * sensor_orientation_event_cb(), sensor_gyroscope_event_cb(), sensor_light_event_cb(),
- * sensor_proximity_event_cb(), sensor_motion_snap_event_cb(), sensor_motion_shake_event_cb(),
- * sensor_motion_doubletap_event_cb(), sensor_motion_panning_event_cb(), or sensor_motion_facedown_event_cb().
- *
- * @see sensor_stop()
- */
-int sensor_start(sensor_h sensor, sensor_type_e type);
-
-
-/**
- * @brief Stops sensor server for the given sensor handle and type.
- * @details The given @a type event will not occur any more and the callback functions also won't be called.
+ * @remarks You must release @a listener using sensor_destroy_listener().
*
- * @param[in] sensor The sensor handle
- * @param[in] type The sensor type
+ * @param[in] sensor The sensor handle
+ * @param[out] listener A new listener handle
*
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #SENSOR_ERROR_NONE Successful
+ * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SENSOR_ERROR_NOT_SUPPORTED The sensor type is not supported in the current device
+ * @retval #SENSOR_ERROR_OUT_OF_MEMORY Out of memory
*
- * @see sensor_start()
+ * @see sensor_listener_set_event_cb()
+ * @see sensor_listener_set_interval()
+ * @see sensor_listener_set_max_batch_latency()
+ * @see sensor_listener_set_option()
+ * @see sensor_destroy_listener()
*/
-int sensor_stop(sensor_h sensor, sensor_type_e type);
+int sensor_create_listener(sensor_h sensor, sensor_listener_h *listener);
/**
- * @brief Retrieve minimum and maximum interval time that can use to measuring specific sensor.
+ * @brief Destroys the sensor handle and releases all its resources.
+ * @since_tizen 2.3
*
- * @param[in] type The sensor type
- * @param[out] min The minimum interval time
- * @param[out] max The maximum interval time
+ * @remarks After this function is called, the attached sensor is detached and
+ * the corresponding sensor connection is released.
*
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- */
-int sensor_get_delay_boundary(sensor_type_e type, int *min, int *max);
-
-/**
- * @brief Retrieve whether supported or not supported the awaken from specific sensor.
+ * @param[in] listener The listener handle
*
- * @param[in] type The sensor type
- * @param[out] supported @c true if this sensor type is supported, otherwise @c false
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #SENSOR_ERROR_NONE Successful
+ * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SENSOR_ERROR_NOT_SUPPORTED The sensor type is not supported in the current device
*
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
+ * @see sensor_create_listener()
*/
-int sensor_awake_is_supported(sensor_type_e type, bool *supported);
+int sensor_destroy_listener(sensor_listener_h listener);
/**
- * @brief Set the awaken behavior from specific sensor.
+ * @brief Starts the sensor server for the given listener.
*
- * @param[in] sensor The sensor handle
- * @param[in] type The sensor type
- * @param[out] enable @c true if set enable the awaken behavior from the sensor, or @c false
+ * @details After this function is called, sensor events will occur and
+ * the specific sensor type related callback function will be called. An application can read sensor data.
*
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- */
-int sensor_awake_is_enabled(sensor_h sensor, sensor_type_e type, bool *enable);
-
-/**
- * @brief Called when a device awaken.
+ * @since_tizen 2.3
*
- * @param[in] user_data The user data passed from the callback registration function
+ * @param[in] listener The listener handle
*
- * @see sensor_awake_is_supported()
- * @see sensor_awake_set()
- * @see sensor_awake_set_cb()
- * @see sensor_awake_unset_cb()
- */
-typedef void (*sensor_awake_cb) (void *user_data);
-
-/**
- * @brief Set the callback that called when device awaken.
- *
- * @param[in] sensor The sensor handle
- * @param[in] type The sensor type
- * @param[in] callback The callback function to register
- * @param[in] user_data The user data to be passed to the callback function
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #SENSOR_ERROR_NONE Successful
+ * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SENSOR_ERROR_NOT_SUPPORTED The sensor type is not supported in the current device
+ * @retval #SENSOR_ERROR_IO_ERROR I/O error
+ * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
*
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- */
-int sensor_awake_set_cb(sensor_h sensor, sensor_type_e type, sensor_awake_cb callback, void* user_data);
-
-/**
- * @brief Unset the callback that called when device awaken.
- *
- * @param[in] sensor The sensor handle
- * @param[in] type The sensor type
+ * @pre Call sensor_create_listener() before using this function.
*
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
+ * @see sensor_listener_stop()
*/
-int sensor_awake_unset_cb(sensor_h sensor, sensor_type_e type);
-
+int sensor_listener_start(sensor_listener_h listener);
/**
- * @}
+ * @brief Stops the sensor server for the given listener.
*
- * @addtogroup CAPI_SYSTEM_SENSOR_ACCELEROMETER_MODULE
- * @{
- */
-
-/**
- * @brief Called when an accelerometer event occurs.
+ * @details The given @a type event will not occur any more and the callback functions also won't be called.
+ *
+ * @since_tizen 2.3
*
- * @param[in] timestamp The time in nanosecond at which the event ahppened
- * @param[in] accuracy The accuracy of @a x, @a y, and @a z values
- * @param[in] x The acceleration Gx on the x-axis in [m/s^2]
- * @param[in] y The acceleration Gy on the y-axis in [m/s^2]
- * @param[in] z The acceleration Gz on the z-axis in [m/s^2]
- * @param[in] user_data The user data passed from the callback registration function
+ * @param[in] listener The listener handle
*
- * @pre sensor_start() will invoke this callback if you register this callback using sensor_accelerometer_set_cb().
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #SENSOR_ERROR_NONE Successful
+ * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SENSOR_ERROR_NOT_SUPPORTED The sensor type is not supported in the current device
+ * @retval #SENSOR_ERROR_IO_ERROR I/O error
*
- * @see sensor_accelerometer_set_cb()
- * @see sensor_accelerometer_unset_cb()
+ * @see sensor_listener_start()
*/
-typedef void (*sensor_accelerometer_event_cb)( unsigned long long timestamp,
- sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data);
-
+int sensor_listener_stop(sensor_listener_h listener);
/**
- * @brief Registers a callback function to be invoked when an accelerometer event occurs.
+ * @brief Registers a callback function to be invoked when a sensor event occurs.
+ * @since_tizen 2.3
*
- * @param[in] sensor The sensor handle
- * @param[in] interval_ms The interval sensor events are delivered at (in milliseconds) \n
- * If @a rate is zero, it uses default value(100ms)
+ * @param[in] listener The listener handle
+ * @param[in] interval_ms The interval at which sensor events are delivered (in milliseconds) \n
+ * If @a rate is zero, it uses the default value(100ms)
* @param[in] callback The callback function to register
- * @param[in] user_data The user data to be passed to the callback function
+ * @param[in] data The user data to be passed to the callback function
*
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @post sensor_accelerometer_event_cb() will be invoked.
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #SENSOR_ERROR_NONE Successful
+ * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SENSOR_ERROR_NOT_SUPPORTED The sensor type is not supported in the current device
+ * @retval #SENSOR_ERROR_IO_ERROR I/O error
+ * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
*
- * @see sensor_accelerometer_event_cb()
- * @see sensor_accelerometer_unset_cb()
+ * @see sensor_event_cb()
+ * @see sensor_listener_unset_event_cb()
*/
-int sensor_accelerometer_set_cb(sensor_h sensor, int interval_ms, sensor_accelerometer_event_cb callback, void *user_data);
-
+int sensor_listener_set_event_cb(sensor_listener_h listener, unsigned int interval_ms, sensor_event_cb callback, void *data);
/**
- * @brief Unregister the accelerometer callback function.
+ * @brief Unregisters the sensor callback function.
+ * @since_tizen 2.3
*
- * @param[in] sensor The sensor handle
+ * @param[in] listener The listener handle
*
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #SENSOR_ERROR_NONE Successful
+ * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SENSOR_ERROR_NOT_SUPPORTED The sensor type is not supported in the current device
+ * @retval #SENSOR_ERROR_IO_ERROR I/O error
+ * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
*
- * @see sensor_accelerometer_set_cb()
+ * @see sensor_listener_set_event_cb()
*/
-int sensor_accelerometer_unset_cb(sensor_h sensor);
+int sensor_listener_unset_event_cb(sensor_listener_h listener);
/**
- * @brief change the interval at accelerometer measurements.
- *
- * @param[in] sensor The sensor handle
- * @param[in] interval_ms in milliseconds.
+ * @brief Called when the accuracy of a sensor has changed.
*
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
+ * @details When something is artificially influencing, such as ferrous metal objects or
+ * electromagnetic fields (car electrical systems, automobile engines, steel pitons, and so on.), this callback is called.
+ * One way of implementing this callback is to instruct a user to make big 8-like gestures with the device.
+ * @since_tizen 2.3
*
- * @see sensor_accelerometer_set_cb()
+ * @param[in] sensor The sensor handle
+ * @param[in] timestamp The time in milliseconds at which the event happened
+ * @param[in] accuracy The accuracy of this data
+ * @param[in] user_data The user data passed from the callback registration function
*/
-int sensor_accelerometer_set_interval(sensor_h sensor, int interval_ms);
-
+typedef void (*sensor_accuracy_changed_cb)(sensor_h sensor, unsigned long long timestamp, sensor_data_accuracy_e accuracy, void *data);
/**
- * @brief Gets sensor data from the accelerometer sensor.
+ * @brief Registers an accuracy callback function to be invoked when the accuracy of a sensor has changed.
+ * @since_tizen 2.3
*
- * @param[in] sensor The sensor handle
- * @param[out] accuracy The accuracy of this data
- * @param[out] x The acceleration minus Gx on the x-axis in meters per second squared (m/s^2)
- * @param[out] y The acceleration minus Gy on the y-axis in meters per second squared (m/s^2)
- * @param[out] z The acceleration minus Gz on the z-axis in meters per second squared (m/s^2)
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
+ * @param[in] listener The listener handle
+ * @param[in] callback The callback function to register
+ * @param[in] data The user data to be passed to the callback function
*
- * @pre In order to read sensor data, an application should call sensor_start().
- */
-int sensor_accelerometer_read_data(sensor_h sensor, sensor_data_accuracy_e *accuracy, float *x, float *y, float *z);
-
-
-/**
- * @}
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #SENSOR_ERROR_NONE Successful
+ * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SENSOR_ERROR_NOT_SUPPORTED The sensor type is not supported in the current device
+ * @retval #SENSOR_ERROR_IO_ERROR I/O error
+ * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
*
- * @addtogroup CAPI_SYSTEM_SENSOR_GRAVITY_MODULE
- * @{
+ * @see sensor_accuracy_changed_cb()
+ * @see sensor_listener_unset_accuracy_cb()
*/
+int sensor_listener_set_accuracy_cb(sensor_listener_h listener, sensor_accuracy_changed_cb callback, void *data);
/**
- * @brief Called when an gravity event occurs.
+ * @brief Unregisters the sensor accuracy changed callback function.
+ * @since_tizen 2.3
*
- * @param[in] timestamp The time in nanosecond at which the event ahppened
- * @param[in] accuracy The accuracy of @a x, @a y, and @a z values
- * @param[in] x g (9.8 m/s^2 = 1g)
- * @param[in] y g (9.8 m/s^2 = 1g)
- * @param[in] z g (9.8 m/s^2 = 1g)
- * @param[in] user_data The user data passed from the callback registration function
+ * @param[in] listener The listener handle
*
- * @pre sensor_start() will invoke this callback if you register this callback using sensor_rotation_vector_set_cb().
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #SENSOR_ERROR_NONE Successful
+ * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SENSOR_ERROR_NOT_SUPPORTED The sensor type is not supported in the current device
+ * @retval #SENSOR_ERROR_IO_ERROR I/O error
+ * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
*
- * @see sensor_gravity_set_cb()
- * @see sensor_gravity_unset_cb()
+ * @see sensor_listener_set_accuracy_cb()
*/
-typedef void (*sensor_gravity_event_cb)(unsigned long long timestamp,
- sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data);
+int sensor_listener_unset_accuracy_cb(sensor_listener_h listener);
/**
- * @brief Registers a callback function to be invoked when an gravity event occurs.
- *
- * @param[in] sensor The sensor handle
- * @param[in] interval_ms The interval sensor events are delivered at (in milliseconds) \n
- * If @a rate is zero, it uses default value(100ms)
- * @param[in] callback The callback function to register
- * @param[in] user_data The user data to be passed to the callback function
+ * @brief Gets sensor data.
+ * @since_tizen 2.3
*
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
+ * @param[in] listener The listener handle
+ * @param[out] event The event information
*
- * @post sensor_gravity_event_cb() will be invoked.
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #SENSOR_ERROR_NONE Successful
+ * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SENSOR_ERROR_NOT_SUPPORTED The sensor type is not supported in the current device
+ * @retval #SENSOR_ERROR_IO_ERROR I/O error
*
- * @see sensor_gravity_event_cb()
- * @see sensor_gravity_unset_cb()
+ * @pre In order to read sensor data, an application should call sensor_listener_start().
*/
-int sensor_gravity_set_cb(sensor_h sensor, int interval_ms, sensor_gravity_event_cb callback, void* user_data);
+int sensor_listener_read_data(sensor_listener_h listener, sensor_event_s *event);
/**
- * @brief Unregister the gravity callback function.
+ * @brief Changes the interval at sensor measurements.
+ * @since_tizen 2.3
*
- * @param[in] sensor The sensor handle
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
+ * @param[in] listener The listener handle
+ * @param[in] interval_ms The interval at which sensor events are delivered (in milliseconds) \n
+ * If @a rate is zero, it uses the default value(100ms)
*
- * @see sensor_gravity_set_cb()
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #SENSOR_ERROR_NONE Successful
+ * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SENSOR_ERROR_NOT_SUPPORTED The sensor type is not supported in the current device
+ * @retval #SENSOR_ERROR_IO_ERROR I/O error
+ * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
*/
-int sensor_gravity_unset_cb(sensor_h sensor);
+int sensor_listener_set_interval(sensor_listener_h listener, unsigned int interval_ms);
/**
- * @brief change the interval at gravity measurements.
- *
- * @param[in] sensor The sensor handle
- * @param[in] interval_ms in milliseconds.
+ * @brief Changes the max batch latency at sensor measurements.
+ * @since_tizen 2.3
*
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
+ * @param[in] listener The listener handle
+ * @param[in] max_batch_latency The latency at which sensor events are delivered (in milliseconds)
*
- * @see sensor_gravity_set_cb()
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #SENSOR_ERROR_NONE Successful
+ * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SENSOR_ERROR_NOT_SUPPORTED The sensor type is not supported in the current device
+ * @retval #SENSOR_ERROR_IO_ERROR I/O error
+ * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
*/
-int sensor_gravity_set_interval(sensor_h sensor, int interval_ms);
+int sensor_listener_set_max_batch_latency(sensor_listener_h listener, unsigned int max_batch_latency);
/**
- * @brief Gets sensor data from the gravity sensor.
+ * @brief Changes the option of the sensor.
+ * @details If it is default, sensor data cannot be recieved when the LCD is off and in the power save mode.
+ * @since_tizen 2.3
*
- * @param[in] sensor The sensor handle
- * @param[out] accuracy The accuracy of this data
- * @param[in] x g (9.8 m/s^2 = 1g)
- * @param[in] y g (9.8 m/s^2 = 1g)
- * @param[in] z g (9.8 m/s^2 = 1g)
+ * @param[in] listener The listener handle
+ * @param[in] option The sensor option
*
* @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- *
- * @pre In order to read sensor data, an application should call sensor_start().
+ * @retval #SENSOR_ERROR_NONE Successful
+ * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SENSOR_ERROR_NOT_SUPPORTED The sensor type is not supported in the current device
+ * @retval #SENSOR_ERROR_IO_ERROR I/O error
+ * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
*/
-int sensor_gravity_read_data(sensor_h sensor, sensor_data_accuracy_e* accuracy, float* x, float* y, float* z);
-
+int sensor_listener_set_option(sensor_listener_h listener, sensor_option_e option);
/**
* @}
- *
- * @addtogroup CAPI_SYSTEM_SENSOR_LINEAR_ACCELERATION_MODULE
- * @{
*/
/**
- * @brief Called when an linear accleration event occurs.
- *
- * @param[in] timestamp The time in nanosecond at which the event ahppened
- * @param[in] accuracy The accuracy of @a x, @a y, and @a z values
- * @param[in] x The acceleration Gx on the x-axis in [m/s^2] not including gravity
- * @param[in] y The acceleration Gy on the y-axis in [m/s^2] not including gravity
- * @param[in] z The acceleration Gz on the z-axis in [m/s^2] not including gravity
- * @param[in] user_data The user data passed from the callback registration function
- *
- * @pre sensor_start() will invoke this callback if you register this callback using sensor_linear_acceleration_set_cb().
- *
- * @see sensor_linear_acceleration_set_cb()
- * @see sensor_linear_acceleration_unset_cb()
+ * @addtogroup CAPI_SYSTEM_SENSOR_INFORMATION_MODULE
+ * @{
*/
-typedef void (*sensor_linear_acceleration_event_cb)( unsigned long long timestamp,
- sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data);
/**
- * @brief Registers a callback function to be invoked when an linear acceleration event occurs.
+ * @brief Gets the name of the sensor.
+ * @since_tizen 2.3
*
- * @param[in] sensor The sensor handle
- * @param[in] interval_ms The interval sensor events are delivered at (in milliseconds) \n
- * If @a rate is zero, it uses default value(100ms)
- * @param[in] callback The callback function to register
- * @param[in] user_data The user data to be passed to the callback function
+ * @param[in] sensor The sensor handle
+ * @param[out] name The name of the sensor
*
* @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @post sensor_linear_acceleration_event_cb() will be invoked.
- *
- * @see sensor_linear_acceleration_event_cb()
- * @see sensor_linear_acceleration_unset_cb()
+ * @retval #SENSOR_ERROR_NONE Successful
+ * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SENSOR_ERROR_NOT_SUPPORTED The sensor type is not supported in the current device
+ * @retval #SENSOR_ERROR_IO_ERROR I/O error
+ * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
*/
-int sensor_linear_acceleration_set_cb(sensor_h sensor, int interval_ms, sensor_linear_acceleration_event_cb callback, void *user_data);
+int sensor_get_name(sensor_h sensor, char** name);
/**
- * @brief Unregister the linear acceleration callback function.
+ * @brief Gets the vendor of the sensor.
+ * @since_tizen 2.3
*
- * @param[in] sensor The sensor handle
+ * @param[in] sensor The sensor handle
+ * @param[out] vendor The vendor of the sensor
*
* @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @see sensor_linear_acceleration_set_cb()
+ * @retval #SENSOR_ERROR_NONE Successful
+ * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SENSOR_ERROR_NOT_SUPPORTED The sensor type is not supported in the current device
+ * @retval #SENSOR_ERROR_IO_ERROR I/O error
+ * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
*/
-int sensor_linear_acceleration_unset_cb(sensor_h sensor);
+int sensor_get_vendor(sensor_h sensor, char** vendor);
/**
- * @brief change the interval at linear acceleration measurements.
- *
+ * @brief Gets the type of the sensor.
+ * @since_tizen 2.3
+ *
* @param[in] sensor The sensor handle
- * @param[in] interval_ms in milliseconds.
+ * @param[out] type The type of the sensor
*
* @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @see sensor_linear_acceleration_set_cb()
+ * @retval #SENSOR_ERROR_NONE Successful
+ * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SENSOR_ERROR_NOT_SUPPORTED The sensor type is not supported in the current device
+ * @retval #SENSOR_ERROR_IO_ERROR I/O error
+ * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
*/
-int sensor_linear_acceleration_set_interval(sensor_h sensor, int interval_ms);
+int sensor_get_type(sensor_h sensor, sensor_type_e *type);
/**
- * @brief Gets sensor data from the linear acceleration sensor.
+ * @brief Gets the minimum range of the sensor.
+ * @since_tizen 2.3
*
- * @param[in] sensor The sensor handle
- * @param[out] accuracy The accuracy of this data
- * @param[out] x The acceleration Gx on the x-axis in meters per second squared (m/s^2) not including gravity
- * @param[out] y The acceleration Gy on the y-axis in meters per second squared (m/s^2) not including gravity
- * @param[out] z The acceleration Gz on the z-axis in meters per second squared (m/s^2) not including gravity
+ * @param[in] sensor The sensor handle
+ * @param[out] min_range The minimum range
*
* @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- *
- * @pre In order to read sensor data, an application should call sensor_start().
+ * @retval #SENSOR_ERROR_NONE Successful
+ * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SENSOR_ERROR_NOT_SUPPORTED The sensor type is not supported in the current device
+ * @retval #SENSOR_ERROR_IO_ERROR I/O error
+ * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
*/
-int sensor_linear_acceleration_read_data(sensor_h sensor, sensor_data_accuracy_e *accuracy, float *x, float *y, float *z);
-
+int sensor_get_min_range(sensor_h sensor, float *min_range);
/**
- * @}
- *
- * @addtogroup CAPI_SYSTEM_SENSOR_DEVICE_ORIENTATION_MODULE
- * @{
+ * @brief Gets the maximum range of the sensor.
+ * @since_tizen 2.3
+ *
+ * @param[in] sensor The sensor handle
+ * @param[out] max_range The maximum range
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #SENSOR_ERROR_NONE Successful
+ * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SENSOR_ERROR_NOT_SUPPORTED The sensor type is not supported in the current device
+ * @retval #SENSOR_ERROR_IO_ERROR I/O error
+ * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
*/
+int sensor_get_max_range(sensor_h sensor, float *max_range);
/**
- * @brief Called when an device orientation event occurs.
- *
- * @remark All values are angles in degrees.
- *
- * @param[in] timestamp The time in nanosecond at which the event ahppened
- * @param[in] accuracy The accuracy of @a yaw, @a pitch, and @a roll values
- * @param[in] yaw The rotation around z-axis [0 ~ 360], with positive values when the y-axis moves \n
- * toward the x-axis
- * @param[in] pitch The rotation around x-axis [-180 ~ 180], with positive values when the z-axis moves \n
- * toward the y-axis
- * @param[in] roll The rotation around y-axis [-90 ~ 90], with positive values when the x-axis moves \n
- * toward the z-axis
- * @param[in] user_data The user data passed from the callback registration function
- * @pre sensor_start() will invoke this callback if you register this callback using sensor_device_orientation_set_cb().
- * @see sensor_device_orientation_set_cb()
- * @see sensor_device_orientation_unset_cb()
- */
-typedef void (*sensor_device_orientation_event_cb)( unsigned long long timestamp,
- sensor_data_accuracy_e accuracy, float yaw, float pitch, float roll, void *user_data);
-
-/**
- * @brief Registers a callback function to be invoked when an device orientation event occurs.
+ * @brief Gets the resolution of the sensor.
+ * @since_tizen 2.3
*
- * @param[in] sensor The sensor handle
- * @param[in] interval_ms The interval sensor events are delivered in (in milliseconds) \n
- * If @a interval_ms is zero, it uses default value (100ms)
- * @param[in] callback The callback function to register
- * @param[in] user_data The user data to be passed to the callback function
+ * @param[in] sensor The sensor handle
+ * @param[out] resolution The resolution
*
* @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @post sensor_device_orientation_event_cb() will be invoked.
- *
- * @see sensor_device_orientation_event_cb()
- * @see sensor_device_orientation_unset_cb()
-*/
-int sensor_device_orientation_set_cb(sensor_h sensor, int interval_ms, sensor_device_orientation_event_cb callback, void *user_data);
+ * @retval #SENSOR_ERROR_NONE Successful
+ * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SENSOR_ERROR_NOT_SUPPORTED The sensor type is not supported in the current device
+ * @retval #SENSOR_ERROR_IO_ERROR I/O error
+ * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
+ */
+int sensor_get_resolution(sensor_h sensor, float *resolution);
/**
- * @brief Unregister the device orientation callback function.
+ * @brief Gets the minimun interval of the sensor.
+ * @since_tizen 2.3
*
- * @param[in] sensor The sensor handle
+ * @param[in] sensor The sensor handle
+ * @param[out] min_interval The minimum interval (in milliseconds)
*
* @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @see sensor_device_orientation_set_cb()
+ * @retval #SENSOR_ERROR_NONE Successful
+ * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SENSOR_ERROR_NOT_SUPPORTED The sensor type is not supported in the current device
+ * @retval #SENSOR_ERROR_IO_ERROR I/O error
+ * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
*/
-int sensor_device_orientation_unset_cb(sensor_h sensor);
+int sensor_get_min_interval(sensor_h sensor, int *min_interval);
/**
- * @brief change the interval at device orientation measurements.
- *
+ * @brief Gets the fifo count of the sensor.
+ * @since_tizen 2.3
+ *
* @param[in] sensor The sensor handle
- * @param[in] interval_ms in milliseconds.
+ * @param[out] fifo_count The fifo count
*
* @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @see sensor_device_orientation_set_cb()
+ * @retval #SENSOR_ERROR_NONE Successful
+ * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SENSOR_ERROR_NOT_SUPPORTED The sensor type is not supported in the current device
+ * @retval #SENSOR_ERROR_IO_ERROR I/O error
+ * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
*/
-int sensor_device_orientation_set_interval(sensor_h sensor, int interval_ms);
+int sensor_get_fifo_count(sensor_h sensor, int *fifo_count);
/**
- * @brief Gets sensor data from the device orientation sensor.
+ * @brief Gets the maximum batch count of the sensor.
+ * @since_tizen 2.3
*
- * @remark
- * All values are angles in degrees.
- *
- * @param[in] sensor The sensor handle
- * @param[out] accuracy The accuracy of this data
- * @param[in] yaw The rotation around z-axis [0 ~ 360], with positive values when the y-axis moves \n
- * toward the x-axis
- * @param[out] pitch The rotation in degrees around x-axis [-180 ~ 180], with positive values when the \n
- * z-axis moves toward the y-axis
- * @param[out] roll The rotation in degrees around y-axis [-90 ~ 90], with positive values when the \n
- * x-axis moves toward the z-axis
+ * @param[in] sensor The sensor handle
+ * @param[out] max_batch_count The maximum batch count
*
* @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- *
- * @pre In order to read sensor data, an application should call sensor_start().
- * @see sensor_start()
+ * @retval #SENSOR_ERROR_NONE Successful
+ * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SENSOR_ERROR_NOT_SUPPORTED The sensor type is not supported in the current device
+ * @retval #SENSOR_ERROR_IO_ERROR I/O error
+ * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
*/
-int sensor_device_orientation_read_data(sensor_h sensor, sensor_data_accuracy_e *accuracy, float *yaw, float *pitch, float *roll);
-
-
+int sensor_get_max_batch_count(sensor_h sensor, int *max_batch_count);
/**
* @}
- *
- * @addtogroup CAPI_SYSTEM_SENSOR_MAGNETIC_MODULE
- * @{
*/
/**
- * @brief Called when a magnetic event occurs.
- *
- * @remark @a x, @a y, and @a z values are in micro-Teslas(uT) and measure the ambient magnetic field in the X, Y and Z axis.
- *
- * @param[in] timestamp The time in nanosecond at which the event ahppened
- * @param[in] accuracy The accuracy of @a x, @a y, and @a z values
- * @param[in] x Micro-Tesla value from ambient magnetic field on the x-axis
- * @param[in] y Micro-Tesla value from ambient magnetic field on the y-axis
- * @param[in] z Micro-Tesla value from ambient magnetic field on the z-axis
- * @param[in] user_data The user data passed from the callback registration function
- * @pre sensor_start() will invoke this callback if you register this callback using sensor_magnetic_set_cb().
- * @see sensor_magnetic_set_cb()
- * @see sensor_magnetic_unset_cb()
- */
-typedef void (*sensor_magnetic_event_cb)( unsigned long long timestamp,
- sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data);
-
-/**
- * @brief Registers a callback function to be invoked when a magnetic event occurs.
- *
- * @param[in] sensor The sensor handle
- * @param[in] interval_ms The interval sensor events are delivered in (in milliseconds) \n
- * If @a interval_ms is zero, it uses default value (100ms)
- * @param[in] callback The callback function to register
- * @param[in] user_data The user data to be passed to the callback function
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @post sensor_magnetic_event_cb() will be invoked.
- *
- * @see sensor_magnetic_event_cb()
- * @see sensor_magnetic_unset_cb()
+ * @addtogroup CAPI_SYSTEM_SENSOR_UTILITY_MODULE
+ * @{
*/
-int sensor_magnetic_set_cb(sensor_h sensor, int interval_ms, sensor_magnetic_event_cb callback, void *user_data);
/**
- * @brief Unregister the magnetic callback function.
+ * @brief Enumeration of the axis used in #sensor_util_remap_coordinate_system.
+ * @since_tizen 2.3
*
- * @param[in] sensor The sensor handle
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @see sensor_magnetic_set_cb()
+ * @see #sensor_util_remap_coordinate_system
*/
-int sensor_magnetic_unset_cb(sensor_h sensor);
+typedef enum
+{
+ sensor_util_axis_minus_x,
+ sensor_util_axis_minus_y,
+ sensor_util_axis_minus_z,
+ sensor_util_axis_x,
+ sensor_util_axis_y,
+ sensor_util_axis_z,
+} sensor_util_axis_e;
/**
- * @brief change the interval at magnetic sensor measurements.
- *
- * @param[in] sensor The sensor handle
- * @param[in] interval_ms in milliseconds.
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @see sensor_magnetic_set_cb()
- */
-int sensor_magnetic_set_interval(sensor_h sensor, int interval_ms);
+ * @brief Gets the Inclination matrix "I" and Rotation matrix "R" transforming a vector from the device coordinate to the world's coordinate.
+ *
+ * @details [0 0 g] = R * gravity (g = magnitude of gravity) \n
+ * [0 m 0] = I * R * geomagnetic (m = magnitude of the geomagnetic field) \n
+ * R is the identity matrix when the device is aligned with the world's coordinate system, that is, when the device's X axis points towards the East, the Y axis points to the North Pole and the device is facing the sky. \n
+ * I is a rotation matrix transforming the geomagnetic vector into the same coordinate space as gravity (the world's coordinate space). I is a simple rotation around the X axis. \n
+ * @since_tizen 2.3
+ *
+ * @remarks Parameters Gx, Gy, and Gz can be obtained from the values returned by #SENSOR_GRAVITY. \n
+ * Parameters Mx, My, and Mz can be obtained from the values returned by #SENSOR_MAGNETIC.
+ * Output parameter R and I are always returned as a 3x3 matrix array of 9 floats like this form:
+ * <pre>
+ * { R[0], R[1], R[2],
+ * R[3], R[4], R[5],
+ * R[6], R[7], R[6] }
+ * </pre>
+ *
+ *
+ * @param[in] Gx The X-axis gravity vector in the device's coordinate
+ * @param[in] Gy The Y-axis gravity vector in the device's coordinate
+ * @param[in] Gz The Z-axis gravity vector in the device's coordinate
+ * @param[in] Mx The X-axis geomagnetic vector in the device's coordinate
+ * @param[in] My The Y-axis geomagnetic vector in the device's coordinate
+ * @param[in] Mz The Z-axis geomagnetic vector in the device's coordinate
+ * @param[out] R The array of 9 floats that represent the rotation matrix "R" \n
+ * It can be null.
+ * @param[out] I The array of 9 floats that represent the inclination matrix "I" \n
+ * It can be null.
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #SENSOR_ERROR_NONE Successful
+ * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SENSOR_ERROR_NOT_SUPPORTED The sensor type is not supported in the current device
+ */
+int sensor_util_get_rotation_matrix(float Gx, float Gy, float Gz,
+ float Mx, float My, float Mz,
+ float R[], float I[]);
/**
- * @brief Gets sensor data from the magnetic sensor.
+ * @brief Converts a rotation vector to a rotation matrix.
*
- * @remark All values are in micro-Teslas (uT) and measure the ambient magnetic field in the X, Y and Z axis.
+ * @details Rotation vectors (Vx, Vy, Vz) can be obtained from #SENSOR_ROTATION_VECTOR.
+ * It returns a 9 element rotation matrix in the array R. R must have length as 9.
+ * @since_tizen 2.3
*
- * @param[in] sensor The sensor handle
- * @param[out] accuracy The accuracy of this data
- * @param[out] x Micro-Tesla value on the x-axis
- * @param[out] y Micro-Tesla value on the y-axis
- * @param[out] z Micro-Tesla value on the z-axis
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- *
- * @pre In order to read sensor data, an application should call sensor_start().
+ * @param[in] Vx The X-axis rotation vector
+ * @param[in] Vy The Y-axis rotation vector
+ * @param[in] Vz The Z-axis rotation vector
+ * @param[out] R A 9 element rotation matrix in the array R that must have length as 9
*
- * @see sensor_start()
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #SENSOR_ERROR_NONE Successful
+ * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SENSOR_ERROR_NOT_SUPPORTED The sensor type is not supported in the current device
*/
-int sensor_magnetic_read_data(sensor_h sensor, sensor_data_accuracy_e *accuracy, float *x, float *y, float *z);
+int sensor_util_get_rotation_matrix_from_vector(float Vx, float Vy, float Vz, float R[]);
/**
- * @brief Registers a callback function to be invoked when the current sensor reading falls outside of a defined normal range.
+ * @brief Rotates the supplied rotation matrix so that it is expressed in a different coordinate system.
+ *
+ * @details This is typically used when an application needs to compute the three orientation angles of the device in a different coordinate system.
+ * @since_tizen 2.3
*
- * @param[in] sensor The sensor handle
- * @param[in] callback The callback function to register
- * @param[in] user_data The user data to be passed to the callback function
+ * @remarks inR and outR can be the same array, but this is not recommended for performance reasons.
+ * This returns an error when X and Y define the same axis.
*
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- * @retval #SENSOR_ERROR_NOT_NEED_CALIBRATION Sensor doesn't need calibration
+ * @param[in] inR The rotation matrix (3x3) to be transformed
+ * @param[in] x The world axis and direction on which the X axis of the device is mapped
+ * @param[in] y The world axis and direction on which the Y axis of the device is mapped
+ * @param[out] outR The transformed rotation matrix (3x3)
*
- * @post sensor_calibration_cb() will be invoked.
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #SENSOR_ERROR_NONE Successful
+ * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SENSOR_ERROR_NOT_SUPPORTED The sensor type is not supported in the current device
*
- * @see sensor_calibration_cb()
- * @see sensor_magnetic_unset_calibration_cb()
*/
-int sensor_magnetic_set_calibration_cb(sensor_h sensor, sensor_calibration_cb callback, void *user_data);
+int sensor_util_remap_coordinate_system(float inR[], sensor_util_axis_e x, sensor_util_axis_e y, float outR[]);
/**
- * @brief Unregisters the magnetic calibration callback function.
+ * @brief Computes the geomagnetic inclination angle in radians from the inclination matrix I returned by sensor_util_get_rotation_matrix().
+ * @since_tizen 2.3
*
- * @param[in] sensor The sensor handle
+ * @param[in] I The inclination matrix from sensor_util_get_rotation_matrix()
+ * @param[out] inclination The geomagnetic inclination angle in radians
*
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- * @retval #SENSOR_ERROR_NOT_NEED_CALIBRATION Sensor doesn't need calibration
- * @see sensor_magnetic_set_calibration_cb()
- */
-int sensor_magnetic_unset_calibration_cb(sensor_h sensor);
-
-
-/**
- * @}
- *
- * @addtogroup CAPI_SYSTEM_SENSOR_ORIENTATION_MODULE
- * @{
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #SENSOR_ERROR_NONE Successful
+ * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SENSOR_ERROR_NOT_SUPPORTED The sensor type is not supported in the current device
+ *
+ * @see sensor_util_get_rotation_matrix()
*/
+int sensor_util_get_inclination(float I[], float* inclination);
/**
- * @brief Called when an orientation event occurs.
- *
- * @remark All values are angles in degrees.
- *
- * @param[in] timestamp The time in nanosecond at which the event ahppened
- * @param[in] accuracy The accuracy of @a azimuth, @a pitch, and @a roll values
- * @param[in] azimuth The angle between the magnetic north direction and the y-axis, around the z-axis [0 ~ 359]. \n
- * 0 = North, 90 = East, 180 = South, 270 = West
- * @param[in] pitch The rotation around x-axis [-180 ~ 180], with positive values when the z-axis moves \n
- * toward the y-axis
- * @param[in] roll The rotation around y-axis [-90 ~ 90], with positive values when the x-axis moves \n
- * toward the z-axis
- * @param[in] user_data The user data passed from the callback registration function
- * @pre sensor_start() will invoke this callback if you register this callback using sensor_orientation_set_cb().
- * @see sensor_orientation_set_cb()
- * @see sensor_orientation_unset_cb()
- */
-typedef void (*sensor_orientation_event_cb)( unsigned long long timestamp,
- sensor_data_accuracy_e accuracy, float azimuth, float pitch, float roll, void *user_data);
-
-/**
- * @brief Registers a callback function to be invoked when an orientation event occurs.
- *
- * @param[in] sensor The sensor handle
- * @param[in] interval_ms The interval sensor events are delivered in (in milliseconds) \n
- * If @a interval_ms is zero, it uses default value (100ms)
- * @param[in] callback The callback function to register
- * @param[in] user_data The user data to be passed to the callback function
+ * @brief Computes the device's orientation based on the rotation matrix.
*
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
+ * @details When it returns, the array values are filled with the result:
+ * - values[0]: azimuth, rotation around the Z axis.
+ * - values[1]: pitch, rotation around the X axis.
+ * - values[2]: roll, rotation around the Y axis.
+ * @since_tizen 2.3
*
- * @post sensor_orientation_event_cb() will be invoked.
+ * @remarks Parameter R must be an array of 9 floats from sensor_util_get_rotation_matrix() \n
+ * Returned values are always arrays of 3 floats.
*
- * @see sensor_orientation_event_cb()
- * @see sensor_orientation_unset_cb()
-*/
-int sensor_orientation_set_cb(sensor_h sensor, int interval_ms, sensor_orientation_event_cb callback, void *user_data);
-
-/**
- * @brief Unregister the orientation callback function.
+ * @param[in] R A 9 element rotation matrix in the array
+ * @param[out] values An array of 3 floats to hold the result
*
- * @param[in] sensor The sensor handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #SENSOR_ERROR_NONE Successful
+ * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SENSOR_ERROR_NOT_SUPPORTED The sensor type is not supported in the current device
*
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
+ * @see sensor_util_get_rotation_matrix()
*
- * @see sensor_orientation_set_cb()
*/
-int sensor_orientation_unset_cb(sensor_h sensor);
+int sensor_util_get_orientation(float R[], float values[]);
/**
- * @brief Registers a callback function to be invoked when the current sensor reading falls outside of a defined normal range.
+ * @brief Computes the angle change between two rotation matrices.
*
- * @param[in] sensor The sensor handle
- * @param[in] callback The callback function to register
- * @param[in] user_data The user data to be passed to the callback function
+ * @details Given a current rotation matrix (R) and a previous rotation matrix (prevR), it computes
+ * the rotation around the x,y, and z axes which transforms prevR to R.
+ * It outputs a 3 element vector containing the x,y, and z angle change at indexes 0, 1, and 2 respectively. \n
+ * @since_tizen 2.3
*
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- * @retval #SENSOR_ERROR_NOT_NEED_CALIBRATION Sensor doesn't need calibration
+ * @remarks Each input matrix is a 3x3 matrix like this form:
+ * <pre>
+ * { R[0], R[1], R[2],
+ * R[3], R[4], R[5],
+ * R[6], R[7], R[6] }
+ * </pre>
*
- * @post sensor_calibration_cb() will be invoked.
+ * @param[in] R The current rotation matrix
+ * @param[in] prevR The previous rotation matrix
+ * @param[out] angleChange An array of floats in which the angle change is stored
*
- * @see sensor_orientation_set_calibration_cb()
- * @see sensor_orientation_unset_calibration_cb()
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #SENSOR_ERROR_NONE Successful
+ * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SENSOR_ERROR_NOT_SUPPORTED The sensor type is not supported in the current device
*/
-int sensor_orientation_set_calibration_cb(sensor_h sensor, sensor_calibration_cb callback, void *user_data);
+int sensor_util_get_angle_change(float R[], float prevR[], float angleChange[]);
/**
- * @brief Unregister the orientation calibration callback function.
- *
- * @param[in] sensor The sensor handle
+ * @brief Gets the declination of the horizontal component of the magnetic field from true north, in degrees.
+ * @since_tizen 2.3
*
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- * @retval #SENSOR_ERROR_NOT_NEED_CALIBRATION Sensor doesn't need calibration
+ * @param[in] latitude The latitude in geodetic coordinates
+ * @param[in] longitude The longitude in geodetic coordinates
+ * @param[in] altitude The altitude in geodetic coordinates
+ * @param[out] declination The declination of the horizontal component of the magnetic field in degrees
*
- * @see sensor_orientation_set_calibration_cb()
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #SENSOR_ERROR_NONE Successful
+ * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SENSOR_ERROR_NOT_SUPPORTED The sensor type is not supported in the current device
*/
-int sensor_orientation_unset_calibration_cb(sensor_h sensor);
-
+int sensor_util_get_declination(float latitude, float longitude, float altitude, float* declination);
/**
- * @brief change the interval at orientation measurements.
- *
- * @param[in] sensor The sensor handle
- * @param[in] interval_ms in milliseconds.
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @see sensor_orientation_set_cb()
- */
-int sensor_orientation_set_interval(sensor_h sensor, int interval_ms);
-
-/**
- * @brief Gets sensor data from the orientation sensor.
- *
- * @remark
- * All values are angles in degrees.
- *
- * @param[in] sensor The sensor handle
- * @param[out] accuracy The accuracy of this data
- * @param[out] azimuth The angle in degrees between the magnetic north direction and the y-axis, \n
- * around the z-axis [0 ~ 359]. 0=North, 90=East, 180=South, 270=West
- * @param[out] pitch The rotation in degrees around x-axis [-180 ~ 180], with positive values when the \n
- * z-axis moves toward the y-axis
- * @param[out] roll The rotation in degrees around y-axis [-90 ~ 90], with positive values when the \n
- * x-axis moves toward the z-axis
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- *
- * @pre In order to read sensor data, an application should call sensor_start().
- * @see sensor_start()
- */
-int sensor_orientation_read_data(sensor_h sensor, sensor_data_accuracy_e *accuracy, float *azimuth, float *pitch, float *roll);
-
-
-/**
- * @}
- *
- * @addtogroup CAPI_SYSTEM_SENSOR_GYROSCOPE_MODULE
- * @{
- */
-
-/**
- * @brief Called when a gyroscope event occurs.
- *
- * @remark
- * Measure the rate of rotation around X, Y and Z axis in radians/second values.
- * All values is observed by positive value in the counter-clockwise direction.
- *
- * @param[in] timestamp The time in nanosecond at which the event ahppened
- * @param[in] accuracy The accuracy of @a x, @a y, and @a z values
- * @param[in] x Angular speed around the x-axis in degree per second
- * @param[in] y Angular speed around the y-axis in degree per second
- * @param[in] z Angular speed around the z-axis in degree per second
- * @param[in] user_data The user data passed from the callback registration function
- * @pre sensor_start() will invoke this callback if you register this callback using sensor_gyroscope_set_cb().
- * @see sensor_gyroscope_set_cb()
- * @see sensor_gyroscope_unset_cb()
- */
-typedef void (*sensor_gyroscope_event_cb)( unsigned long long timestamp,
- sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data);
-
-/**
- * @brief Registers a callback function to be invoked when a gyroscope event occurs.
- *
- * @param[in] sensor The sensor handle
- * @param[in] interval_ms The interval sensor events are delivered in (in milliseconds) \n
- * If @a interval_ms is zero, it uses default value (100ms)
- * @param[in] callback The callback function to register
- * @param[in] user_data The user data to be passed to the callback function
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @post sensor_gyroscope_event_cb() will be invoked
- *
- * @see sensor_gyroscope_event_cb()
- * @see sensor_gyroscope_unset_cb()
- */
-int sensor_gyroscope_set_cb(sensor_h sensor, int interval_ms, sensor_gyroscope_event_cb callback, void *user_data);
-
-/**
- * @brief Unregister the gyroscope callback function.
- *
- * @param[in] sensor The sensor handle
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @see sensor_gyroscope_set_cb()
- */
-int sensor_gyroscope_unset_cb(sensor_h sensor);
-
-/**
- * @brief change the interval at gyroscope measurements.
- *
- * @param[in] sensor The sensor handle
- * @param[in] interval_ms in milliseconds.
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @see sensor_gyroscope_set_cb()
- */
-int sensor_gyroscope_set_interval(sensor_h sensor, int interval_ms);
-
-/**
- * @brief
- * Gets sensor data from the gyroscope sensor.
- *
- * @param[in] sensor The sensor handle
- * @param[out] accuracy The accuracy of this data
- * @param[out] x The angular speed around the x-axis in degree per second
- * @param[out] y The angular speed around the y-axis in degree per second
- * @param[out] z The angular speed around the z-axis in degree per second
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- *
- * @pre In order to read sensor data, an application should call sensor_start().
- * @see sensor_start()
- */
-int sensor_gyroscope_read_data(sensor_h sensor, sensor_data_accuracy_e *accuracy, float *x, float *y, float *z);
-
-/**
- * @}
- *
- * @addtogroup CAPI_SYSTEM_SENSOR_LIGHT_MODULE
- * @{
- */
-
-/**
- * @brief Called when a light event occurs.
- *
- * @remark
- * You should use lux between min and max values obtained \n
- * with #sensor_get_spec().
- *
- * @param[in] timestamp The time in nanosecond at which the event ahppened
- * @param[in] lux The ambient light level in SI lux units \n
- * @a lux is between min and max values obtained with #sensor_get_spec().\n
- * @param[in] user_data The user data passed from the callback registration function
- * @pre sensor_start() will invoke this callback if you register this callback using sensor_light_set_cb().
- * @see sensor_light_set_cb()
- * @see sensor_light_unset_cb()
- */
-typedef void (*sensor_light_event_cb)( unsigned long long timestamp, float lux, void *user_data);
-
-/**
- * @brief Registers a callback function to be invoked when a light event occurs.
- *
- * @param[in] sensor The sensor handle
- * @param[in] interval_ms The interval sensor events are delivered in (in milliseconds) \n
- * If @a interval_ms is zero, it uses default value (100ms)
- * @param[in] callback The callback function to register
- * @param[in] user_data The user data to be passed to the callback function
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @post sensor_light_event_cb() will be invoked.
- *
- * @see sensor_light_event_cb()
- * @see sensor_light_unset_cb()
- */
-int sensor_light_set_cb(sensor_h sensor, int interval_ms, sensor_light_event_cb callback, void *user_data);
-
-/**
- * @brief Unregister the light callback function.
- *
- * @param[in] sensor The sensor handle
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @see sensor_light_set_cb()
- */
-int sensor_light_unset_cb(sensor_h sensor);
-
-/**
- * @brief change the interval at light sensor measurements.
- *
- * @param[in] sensor The sensor handle
- * @param[in] interval_ms in milliseconds.
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @see sensor_light_set_cb()
- */
-int sensor_light_set_interval(sensor_h sensor, int interval_ms);
-
-/**
- * @brief Gets sensor data from the light sensor.
- *
- * @remark
- * You should use lux between min and max values obtained \n
- * with #sensor_get_spec().
- *
- * @param[in] sensor The sensor handle
- * @param[out] lux The ambient light level in SI lux units \n
- * @a lux is between min and max values obtained with #sensor_get_spec().\n
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @pre In order to read sensor data, an application should call sensor_start().
- * @see #sensor_data_accuracy_e
- * @see sensor_start()
- */
-int sensor_light_read_data(sensor_h sensor, float *lux);
-
-
-/**
- * @}
- *
- * @addtogroup CAPI_SYSTEM_SENSOR_PROXIMITY_MODULE
- * @{
- */
-
-/**
- * @brief Called when a proximity event occurs.
- *
- * @param[in] timestamp The time in nanosecond at which the event ahppened
- * @param[in] distance The distance measured in centemeters
- * @param[in] user_data The user data passed from the callback registration function
- * @pre sensor_start() will invoke this callback if you register this callback using sensor_proximity_set_cb().
- * @see sensor_proximity_set_cb()
- * @see sensor_proximity_unset_cb()
- */
-typedef void (*sensor_proximity_event_cb)( unsigned long long timestamp, float distance, void *user_data);
-
-/**
- * @brief Registers a callback function to be invoked when a proximity event occurs.
- *
- * @param[in] sensor The sensor handle
- * @param[in] interval_ms The interval sensor events are delivered in (in milliseconds) \n
- * @param[in] callback The callback function to register
- * @param[in] user_data The user data to be passed to the callback function
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @post sensor_proximity_event_cb() will be invoked.
- *
- * @see sensor_proximity_event_cb()
- * @see sensor_proximity_unset_cb()
- */
-int sensor_proximity_set_cb(sensor_h sensor, int interval_ms, sensor_proximity_event_cb callback, void *user_data);
-
-/**
- * @brief Unregister the proximity callback function.
- *
- * @param[in] sensor The sensor handle
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @see sensor_proximity_set_cb()
- */
-int sensor_proximity_unset_cb(sensor_h sensor);
-
-/**
- * @brief change the interval at proximity measurements.
- *
- * @param[in] sensor The sensor handle
- * @param[in] interval_ms in milliseconds.
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @see sensor_proximity_set_cb()
- */
-int sensor_proximity_set_interval(sensor_h sensor, int interval_ms);
-
-/**
- * @brief Gets sensor data from the Proximity sensor.
- *
- * @remark
- * All values are angles in degrees.
- *
- * @param[in] sensor The sensor handle
- * @param[out] distance The distance measured in centemeters
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- *
- * @pre In order to read sensor data, an application should call sensor_start().
- * @see sensor_start()
- */
-int sensor_proximity_read_data(sensor_h sensor, float *distance);
-
-
-/**
- * @}
- *
- * @}
- *
- * @addtogroup CAPI_SYSTEM_SENSOR_MOTION_MODULE
- * @{
- *
- * @addtogroup CAPI_SYSTEM_SENSOR_MOTION_SNAP_MODULE
- * @{
- */
-
-/**
- * @brief Called when a snap motion event occurs.
- * @image html phone_snap.png
- *
- * @param[in] timestamp The time in nanosecond at which the event ahppened
- * @param[in] snap The type of motion snap
- * @param[in] user_data The user data passed from the callback registration function
- * @pre sensor_start() will invoke this callback if you register this callback using sensor_motion_snap_set_cb().
- * @see sensor_motion_snap_set_cb()
- * @see sensor_motion_snap_unset_cb()
- */
-typedef void (*sensor_motion_snap_event_cb) ( unsigned long long timestamp, sensor_motion_snap_e snap, void *user_data);
-
-/**
- * @brief Registers a callback function to be invoked when a motion snap event occurs.
- *
- * @param[in] sensor The sensor handle
- * @param[in] callback The callback function to register
- * @param[in] user_data The user data to be passed to the callback function
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @post sensor_motion_snap_event_cb() will be invoked.
- *
- * @see sensor_motion_snap_event_cb()
- * @see sensor_motion_snap_unset_cb()
- */
-int sensor_motion_snap_set_cb(sensor_h sensor, sensor_motion_snap_event_cb callback, void *user_data);
-
-/**
- * @brief Unregister the snap callback function.
- *
- * @param[in] sensor The sensor handle
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @see sensor_motion_snap_set_cb()
- */
-int sensor_motion_snap_unset_cb(sensor_h sensor);
-
-
-/**
- * @}
- *
- * @addtogroup CAPI_SYSTEM_SENSOR_MOTION_SHAKE_MODULE
- * @{
- */
-
-/**
- * @brief Called when a shake motion event occurs.
- *
- * @param[in] timestamp The time in nanosecond at which the event ahppened
- * @param[in] shake The type of motion shake
- * @param[in] user_data The user data passed from the callback registration function
- * @pre sensor_start() will invoke this callback if you register this callback using sensor_motion_shake_set_cb().
- * @see sensor_motion_shake_set_cb()
- * @see sensor_motion_shake_unset_cb()
- */
-typedef void (*sensor_motion_shake_event_cb) ( unsigned long long timestamp, sensor_motion_shake_e shake, void *user_data);
-
-/**
- * @brief Registers a callback function to be invoked when a motion shake event occurs.
- *
- * @param[in] sensor The sensor handle
- * @param[in] callback The callback function to register
- * @param[in] user_data The user data to be passed to the callback function
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @post sensor_motion_shake_event_cb() will be invoked.
- *
- * @see sensor_motion_shake_event_cb()
- * @see sensor_motion_shake_unset_cb()
- */
-int sensor_motion_shake_set_cb(sensor_h sensor, sensor_motion_shake_event_cb callback, void *user_data);
-
-/**
- * @brief Unregister the callback function.
- *
- * @param[in] sensor The sensor handle
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @see sensor_motion_shake_set_cb()
- */
-int sensor_motion_shake_unset_cb(sensor_h sensor);
-
-/**
- * @}
- *
- * @addtogroup CAPI_SYSTEM_SENSOR_MOTION_DOUBLETAP_MODULE
- * @{
- */
-
-/**
- * @brief Called when a double tap motion event occurs.
- *
- * @param[in] timestamp The time in nanosecond at which the event ahppened
- * @param[in] user_data The user data passed from the callback registration function
- * @pre sensor_start() will invoke this callback if you register this callback using sensor_motion_doubletap_set_cb().
- * @see sensor_motion_doubletap_set_cb()
- * @see sensor_motion_doubletap_unset_cb()
- */
-typedef void (*sensor_motion_doubletap_event_cb) ( unsigned long long timestamp, void *user_data);
-
-/**
- * @brief Registers a callback function to be invoked when a motion doubletap event occurs.
- *
- * @param[in] sensor The sensor handle
- * @param[in] callback The callback function to register
- * @param[in] user_data The user data to be passed to the callback function
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @post sensor_motion_doubletap_event_cb() will be invoked.
- *
- * @see sensor_motion_doubletap_event_cb()
- * @see sensor_motion_doubletap_unset_cb()
- */
-int sensor_motion_doubletap_set_cb(sensor_h sensor, sensor_motion_doubletap_event_cb callback, void *user_data);
-
-/**
- * @brief Unregister the doubletap callback function.
- *
- * @param[in] sensor The sensor handle
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @see sensor_motion_doubletap_set_cb()
- */
-int sensor_motion_doubletap_unset_cb(sensor_h sensor);
-
-/**
- * @}
- *
- * @addtogroup CAPI_SYSTEM_SENSOR_MOTION_PANNING_MODULE
- * @{
- */
-
-/**
- * @brief Called when a panning motion event occurs.
- * @image html phone_panning.png
- *
- * @param[in] timestamp The time in nanosecond at which the event ahppened
- * @param[in] x 1/10 angle on x-axis
- * @param[in] y 1/10 angle on y-axis
- * @param[in] user_data The user data passed from the callback registration function
- * @pre sensor_start() will invoke this callback if you register this callback using sensor_motion_panning_set_cb().
- * @see sensor_motion_panning_set_cb()
- * @see sensor_motion_panning_unset_cb()
- */
-typedef void (*sensor_motion_panning_event_cb) ( unsigned long long timestamp, int x, int y, void *user_data);
-
-/**
- * @brief Registers a callback function to be invoked when a motion panning event occurs.
- *
- * @param[in] sensor The sensor handle
- * @param[in] callback The callback function to register
- * @param[in] user_data The user data to be passed to the callback function
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @post sensor_motion_panning_event_cb() will be invoked.
- *
- * @see sensor_motion_panning_event_cb()
- * @see sensor_motion_panning_unset_cb()
- */
-int sensor_motion_panning_set_cb(sensor_h sensor, sensor_motion_panning_event_cb callback, void *user_data);
-
-/**
- * @brief Unregister the callback function.
- *
- * @param[in] sensor The sensor handle
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @see sensor_motion_panning_set_cb()
- */
-int sensor_motion_panning_unset_cb(sensor_h sensor);
-
-
-/**
- * @}
- *
- * @addtogroup CAPI_SYSTEM_SENSOR_MOTION_PANNING_BROWSE_MODULE
- * @{
- */
-
-/**
- * @brief Called when a panning browse motion event occurs.
- * @image html phone_panning.png
- *
- * @param[in] timestamp The time in nanosecond at which the event ahppened
- * @param[in] x 1/10 angle on x-axis
- * @param[in] y 1/10 angle on y-axis
- * @param[in] user_data The user data passed from the callback registration function
- * @pre sensor_start() will invoke this callback if you register this callback using sensor_motion_panning_browse_set_cb().
- * @see sensor_motion_panning_browse_set_cb()
- * @see sensor_motion_panning_browse_unset_cb()
- */
-typedef void (*sensor_motion_panning_browse_event_cb) ( unsigned long long timestamp, int x, int y, void *user_data);
-
-/**
- * @brief Registers a callback function to be invoked when a motion panning browse event occurs.
- *
- * @param[in] sensor The sensor handle
- * @param[in] callback The callback function to register
- * @param[in] user_data The user data to be passed to the callback function
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @post sensor_motion_panning_browse_event_cb() will be invoked.
- *
- * @see sensor_motion_panning_browse_event_cb()
- * @see sensor_motion_panning_browse_unset_cb()
- */
-int sensor_motion_panning_browse_set_cb(sensor_h sensor, sensor_motion_panning_browse_event_cb callback, void *user_data);
-
-/**
- * @brief Unregister the callback function.
- *
- * @param[in] sensor The sensor handle
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @see sensor_motion_panning_browse_set_cb()
- */
-int sensor_motion_panning_browse_unset_cb(sensor_h sensor);
-
-
-
-/**
- * @}
- *
- * @addtogroup CAPI_SYSTEM_SENSOR_MOTION_TILT_MODULE
- * @{
- */
-
-/**
- * @brief Called when a tilt motion event occurs.
- * @image html phone_panning.png
- *
- * @param[in] timestamp The time in nanosecond at which the event ahppened
- * @param[in] x 1/10 angle on x-axis
- * @param[in] y 1/10 angle on y-axis
- * @param[in] user_data The user data passed from the callback registration function
- * @pre sensor_start() will invoke this callback if you register this callback using sensor_motion_tilt_set_cb().
- * @see sensor_motion_tilt_set_cb()
- * @see sensor_motion_tilt_unset_cb()
- */
-typedef void (*sensor_motion_tilt_event_cb) ( unsigned long long timestamp, int x, int y, void *user_data);
-
-/**
- * @brief Registers a callback function to be invoked when a motion tilt event occurs.
- *
- * @param[in] sensor The sensor handle
- * @param[in] callback The callback function to register
- * @param[in] user_data The user data to be passed to the callback function
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @post sensor_motion_tilt_event_cb() will be invoked.
- *
- * @see sensor_motion_tilt_event_cb()
- * @see sensor_motion_tilt_unset_cb()
- */
-int sensor_motion_tilt_set_cb(sensor_h sensor, sensor_motion_tilt_event_cb callback, void *user_data);
-
-/**
- * @brief Unregister the callback function.
- *
- * @param[in] sensor The sensor handle
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @see sensor_motion_tilt_set_cb()
- */
-int sensor_motion_tilt_unset_cb(sensor_h sensor);
-
-
-/**
- * @}
- *
- * @addtogroup CAPI_SYSTEM_SENSOR_MOTION_FACEDOWN_MODULE
- * @{
- */
-
-/**
- * @brief Called when a facedown motion event occurs.
- * @details
- * This event occurs when device is flipped as follows:
- * @image html phone_facedown.png
- * This motion event will fire only when the device is flipped from face to back.
- * It will not occur when the device is flipped from back to face.
- *
- * @param[in] timestamp The time in nanosecond at which the event ahppened
- * @param[in] user_data The user data passed from the callback registration function
- * @pre sensor_start() will invoke this callback if you register this callback using sensor_motion_facedown_set_cb().
- * @see sensor_motion_facedown_set_cb()
- * @see sensor_motion_facedown_unset_cb()
- */
-typedef void (*sensor_motion_facedown_event_cb) ( unsigned long long timestamp, void *user_data);
-
-/**
- * @brief Registers a callback function to be invoked when a motion facedown event occurs.
- *
- * @param[in] sensor The sensor handle
- * @param[in] callback The callback function to register
- * @param[in] user_data The user data to be passed to the callback function
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @post sensor_motion_facedown_event_cb() will be invoked.
- *
- * @see sensor_motion_facedown_event_cb()
- * @see sensor_motion_facedown_unset_cb()
- */
-int sensor_motion_facedown_set_cb(sensor_h sensor, sensor_motion_facedown_event_cb callback, void *user_data);
-
-/**
- * @brief Unregister the facedown callback function.
- *
- * @param[in] sensor The sensor handle
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @see sensor_motion_facedown_set_cb()
- */
-
-int sensor_motion_facedown_unset_cb(sensor_h sensor);
-
-/**
- * @addtogroup CAPI_SYSTEM_SENSOR_MOTION_DIRECTCALL_MODULE
- * @{
- */
-
-/**
- * @brief Called when a directcall motion event occurs.
- *
- * @param[in] timestamp The time in nanosecond at which the event ahppened
- * @param[in] user_data The user data passed from the callback registration function
- * @pre sensor_start() will invoke this callback if you register this callback using sensor_motion_directcall_set_cb().
- * @see sensor_motion_directcall_set_cb()
- * @see sensor_motion_directcall_unset_cb()
- */
-typedef void (*sensor_motion_directcall_event_cb) ( unsigned long long timestamp, void *user_data);
-
-/**
- * @brief Registers a callback function to be invoked when a motion directcall event occurs.
- *
- * @param[in] sensor The sensor handle
- * @param[in] callback The callback function to register
- * @param[in] user_data The user data to be passed to the callback function
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @post sensor_motion_directcall_event_cb() will be invoked.
- *
- * @see sensor_motion_directcall_event_cb()
- * @see sensor_motion_directcall_unset_cb()
- */
-int sensor_motion_directcall_set_cb(sensor_h sensor, sensor_motion_directcall_event_cb callback, void *user_data);
-
-/**
- * @brief Unregister the directcall callback function.
- *
- * @param[in] sensor The sensor handle
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @see sensor_motion_directcall_set_cb()
- */
-int sensor_motion_directcall_unset_cb(sensor_h sensor);
-
-
-/**
- * @}
- *
- * @addtogroup CAPI_SYSTEM_SENSOR_MOTION_SMART_ALERT_MODULE
- * @{
- */
-
-/**
- * @brief Called when a smart alert motion event occurs.
- * @details
- * This event occurs when device is picked up as follows:
- * @image html phone_smart_alert.png
- * This motion event will fire only when the device is picked up on desk or etc.
- *
- * @param[in] timestamp The time in nanosecond at which the event ahppened
- * @param[in] user_data The user data passed from the callback registration function
- * @pre sensor_start() will invoke this callback if you register this callback using sensor_motion_smart_alert_set_cb().
- * @see sensor_motion_smart_alert_set_cb()
- * @see sensor_motion_smart_alert_unset_cb()
- */
-typedef void (*sensor_motion_smart_alert_event_cb) ( unsigned long long timestamp, void *user_data);
-
-/**
- * @brief Registers a callback function to be invoked when a motion smart alert event occurs.
- *
- * @param[in] sensor The sensor handle
- * @param[in] callback The callback function to register
- * @param[in] user_data The user data to be passed to the callback function
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @post sensor_motion_smart_alert_event_cb() will be invoked.
- *
- * @see sensor_motion_smart_alert_event_cb()
- * @see sensor_motion_smart_alert_unset_cb()
- */
-int sensor_motion_smart_alert_set_cb(sensor_h sensor, sensor_motion_smart_alert_event_cb callback, void *user_data);
-
-/**
- * @brief Unregister the smart alert callback function.
- *
- * @param[in] sensor The sensor handle
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @see sensor_motion_smart_alert_set_cb()
- */
-int sensor_motion_smart_alert_unset_cb(sensor_h sensor);
-
-
-/**
- * @}
- *
- * @addtogroup CAPI_SYSTEM_SENSOR_MOTION_NO_MOVE_MODULE
- * @{
- */
-
-/**
- * @brief Called when a no move motion event occurs.
- * @details
- * This event occurs when device doesn't move
- * @image html phone_no_move.png
- * This motion event will fire only when the device doesn't move at any position during 1 or 2 seconds.
- *
- * @param[in] timestamp The time in nanosecond at which the event ahppened
- * @param[in] user_data The user data passed from the callback registration function
- * @pre sensor_start() will invoke this callback if you register this callback using sensor_motion_no_move_set_cb().
- * @see sensor_motion_no_move_set_cb()
- * @see sensor_motion_no_move_unset_cb()
- */
-typedef void (*sensor_motion_no_move_event_cb) ( unsigned long long timestamp, void *user_data);
-
-
-/**
- * @brief Registers a callback function to be invoked when a motion no move event occurs.
- *
- * @param[in] sensor The sensor handle
- * @param[in] callback The callback function to register
- * @param[in] user_data The user data to be passed to the callback function
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @post sensor_motion_no_move_event_cb() will be invoked.
- *
- * @see sensor_motion_no_move_event_cb()
- * @see sensor_motion_no_move_unset_cb()
- */
-int sensor_motion_no_move_set_cb(sensor_h sensor, sensor_motion_no_move_event_cb callback, void *user_data);
-
-
-/**
- * @brief Unregister the no move callback function.
- *
- * @param[in] sensor The sensor handle
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @see sensor_motion_no_move_set_cb()
- */
-int sensor_motion_no_move_unset_cb(sensor_h sensor);
-
-
-/**
- * @}
- *
- * @}
- *
- * @addtogroup CAPI_SYSTEM_SENSOR_ROTATION_VECTOR_MODULE
- * @{
- */
-
-/**
- * @brief Called when an rotation vector event occurs.
- * @details
- * The values of rotation vector represents orientation of the device as a combination of an angle and an axis.
- * Each value of the rotation vector is not have unit. the x,y,z axis is same unit as accelerometer.
- *
- * @param[in] accuracy The accuracy of @a x, @a y, and @a z values
- * @param[in] x x*sin(θ/2)
- * @param[in] y y*sin(θ/2)
- * @param[in] z z*sin(θ/2)
- * @param[in] w cos(θ/2)
- * @param[in] user_data The user data passed from the callback registration function
- *
- * @pre sensor_start() will invoke this callback if you register this callback using sensor_rotation_vector_set_cb().
- *
- * @see sensor_rotation_vector_set_cb()
- * @see sensor_rotation_vector_unset_cb()
- */
-typedef void (*sensor_rotation_vector_event_cb)(
- sensor_data_accuracy_e accuracy, float x, float y, float z, float w, void *user_data);
-
-/**
- * @brief Registers a callback function to be invoked when an rotation vector event occurs.
- *
- * @param[in] sensor The sensor handle
- * @param[in] interval_ms The interval sensor events are delivered at (in milliseconds) \n
- * If @a rate is zero, it uses default value(100ms)
- * @param[in] callback The callback function to register
- * @param[in] user_data The user data to be passed to the callback function
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @post sensor_accelerometer_event_cb() will be invoked.
- *
- * @see sensor_accelerometer_event_cb()
- * @see sensor_accelerometer_unset_cb()
- */
-int sensor_rotation_vector_set_cb(sensor_h sensor, int interval_ms, sensor_rotation_vector_event_cb callback, void* user_data);
-
-/**
- * @brief Unregister the rotation vector callback function.
- *
- * @param[in] sensor The sensor handle
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
- *
- * @see sensor_rotation_vector_set_cb()
- */
-int sensor_rotation_vector_unset_cb(sensor_h sensor);
-
-/**
- * @brief Gets sensor data from the rotation vector sensor.
- *
- * @details
- * The rotation vector sensor retrieves quaternion elements <cos(θ/2), x*sin(θ/2), y*sin(θ/2), z*sin(θ/2)>. \n
- * Last three elements of the quaternion represents rotation vector. \n
- * Each axis value of rotation vector is composed of the angle from magnitude equal to sin(θ/2) and the axis. \n
- * The value of rotation vector in each axis don't have unit. the axis x,y and z have same unit as the acceleration sensor.
- *
- *
- *
- * @param[in] sensor The sensor handle
- * @param[out] accuracy The accuracy of this data
- * @param[in] x x*sin(θ/2)
- * @param[in] y y*sin(θ/2)
- * @param[in] z z*sin(θ/2)
- * @param[in] w cos(θ/2)
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SENSOR_ERROR_IO_ERROR I/O error
- *
- * @pre In order to read sensor data, an application should call sensor_start().
- */
-int sensor_rotation_vector_read_data(sensor_h sensor, sensor_data_accuracy_e* accuracy, float* x, float* y, float* z, float* w);
-/**
- * @}
- */
-
-
-/**
- * @addtogroup CAPI_SYSTEM_SENSOR_UTILITY_MODULE
- * @{
- */
-
-/**
- * @brief Enumerations of Axis used in #sensor_util_remap_coordinate_system
- *
- * @see #sensor_util_remap_coordinate_system
- */
-typedef enum
-{
- sensor_util_axis_minus_x,
- sensor_util_axis_minus_y,
- sensor_util_axis_minus_z,
- sensor_util_axis_x,
- sensor_util_axis_y,
- sensor_util_axis_z,
-} sensor_util_axis_e;
-/**
- * @}
- */
-
-/**
- * @brief
- * Getting Inclination matrix "I" and Rotation matrix "R" transforming a vector from the device coordinate to the world's coordinate.
- *
- * @details
- * [0 0 g] = R * gravity (g = magnitude of gravity) \n
- * [0 m 0] = I * R * geomagnetic (m = magnitude of geomagnetic field) \n
- * R is the identity matrix when the device is aligned with the world's coordinate system, that is, when the device's X axis points toward East, the Y axis points to the North Pole and the device is facing the sky. \n
- * I is a rotation matrix transforming the geomagnetic vector into the same coordinate space as gravity (the world's coordinate space). I is a simple rotation around the X axis. \n
- *
- * @remark
- * Parameter Gx, Gy, Gz can be got from the values returned by a #sensor_gravity_event_cb or #sensor_gravity_read_data. \n
- * Parameter Mx, My, Mz can be got from the values returned by a #sensor_magnetic_event_cb or #sensor_magnetic_read_data.
- * Output parameter R and I is always returned 3x3 matrix array of 9 floats like this form:
- * <pre>
- * { R[0], R[1], R[2],
- * R[3], R[4], R[5],
- * R[6], R[7], R[6] }
- * </pre>
- *
- *
- * @param[in] Gx X-axis gravity vector in the device's coordinate.
- * @param[in] Gy Y-axis gravity vector in the device's coordinate.
- * @param[in] Gz Z-axis gravity vector in the device's coordinate.
- * @param[in] Mx X-axis geomagnetic vector in the device's coordinate.
- * @param[in] My Y-axis geomagnetic vector in the device's coordinate.
- * @param[in] Mz Z-axis geomagnetic vector in the device's coordinate.
- * @param[out] R Array of 9 floats that represents the rotation matrix "R". It can be null.
- * @param[out] I Array of 9 floats that represents the inclination matrix "I". It can be null.
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- */
-int sensor_util_get_rotation_matrix(float Gx, float Gy, float Gz,
- float Mx, float My, float Mz,
- float R[], float I[]);
-
-/**
- * @brief
- * Convert a rotation vector to a rotation matrix.
- *
- * @details
- * rotation vectors (Vx, Vy, Vz) can be got from #sensor_rotation_vector_event_cb or #sensor_rotation_vector_read_data.
- * It returns a 9 elements rotation matrix in the array R. R must have langth 9.
- *
- * @param[in] Vx X-axis rotation vector.
- * @param[in] Vy Y-axis rotation vector.
- * @param[in] Vz Z-axis rotation vector.
- * @param[out] R A 9 elements ration matrix in the array R that must have length 9.
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- *
- * @see sensor_util_rotation_matrix3
- * @see sensor_util_rotation_matrix4
- */
-int sensor_util_get_rotation_matrix_from_vector(float Vx, float Vy, float Vz, float R[]);
-
-/**
- * @brief
- * Rotates the supplied rotation matrix so it is expressed in a different coordinate system.
- *
- * @details
- * This is typically used when an application needs to compute the three orientation angles of the device in a different coordinate system.
- *
- * @remark
- * inR and outR can be the same array, but it is not recommended for performance reason.
- * Return error when X and Y defines the same axis.
- *
- * @param[in] inR the rotation matrix (3x3) to be transformed. Usually it is the matrix returned by get #sensor_util_rotation_matrix3 or #sensor_util_rotation_matrix4.
- * @param[in] x defines on which world axis and direction the X axis of the device is mapped.
- * @param[in] y defines on which world axis and direction the Y axis of the device is mapped.
- * @param[out] outR the transformed rotation matrix (3x3).
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- *
- * @see sensor_util_rotation_matrix3
- * @see sensor_util_rotation_matrix4
- * @see sensor_util_rotation_matrix_from_vector
- * @see sensor_util_rotation_matrix_from_quaternion
- */
-int sensor_util_remap_coordinate_system(float inR[], sensor_util_axis_e x, sensor_util_axis_e y, float outR[]);
-
-/**
- * @brief
- * Computes the geomagnetic inclination angle in radians from the inclination matrix I returned by #sensor_util_get_rotation_matrix()
- *
- * @param[in] I inclination matrix from #sensor_util_get_rotation_matrix()
- * @param[out] inclination The geomagnetic inclination angle in radians.
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- *
- * @see sensor_util_get_rotation_matrix()
- */
-int sensor_util_get_inclination(float I[], float* inclination);
-
-/**
- * @brief
- * Compute the device's orientation based on the rotation matrix
- *
- * @details
- * When it returns, they array values is filled with the result:
- * - values[0]: azimuth, rotation around the Z axis.
- * - values[1]: pitch, rotation around the X axis.
- * - values[2]: roll, rotation around the Y axis.
- *
- * @remark
- * Parameter R must be array of 9 floats from #sensor_util_get_rotation_matrix() \n
- * Returned values are always array of 3 floats.
- *
- *
- * @param[in] R A 9 elements ration matrix in the array.
- * @param[values] values An array of 3 floats to hold the result.
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- *
- * @see sensor_util_get_rotation_matrix()
- *
- */
-int sensor_util_get_orientation(float R[], float values[]);
-
-/**
- * @brief
- * Helper function to compute the angle change between two rotation matrices.
- *
- * @details
- * Given a current rotation matrix (R) and a previous rotation matrix (prevR) computes
- * the rotation around the x,y, and z axes which transforms prevR to R.
- * outputs a 3 element vector containing the x,y, and z angle change at indexes 0, 1, and 2 respectively. \n
- *
- * @remark
- * Each input matrix is 3x3 matrix like this form:
- * <pre>
- * { R[0], R[1], R[2],
- * R[3], R[4], R[5],
- * R[6], R[7], R[6] }
- * </pre>
- *
- * @param[in] R current rotation matrix
- * @param[in] prevR previous rotation matrix
- * @param[out] angleChange an array of floats in which the angle change is stored
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- */
-int sensor_util_get_angle_change(float R[], float prevR[], float angleChange[]);
-
-/**
- * @brief
- * Getting the declination of the horizontal component of the magnetic field from true north, in degrees
- *
- * @param[in] latitude Latitude in geodetic coordinates
- * @param[in] longitude Longitude in geodetic coordinates
- * @param[in] altitude Altitude in geodetic coordinates
- * @param[out] declination The declination of the horizontal component of the magnetic field in degrees.
- *
- * @return 0 on success, otherwise a negative error value
- * @retval #SENSOR_ERROR_NONE Successful
- * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
- */
-int sensor_util_get_declination(float latitude, float longitude, float altitude, float* declination);
-
-/**
- * @brief Determines whether or not to be near from proximity sensor's distance value.
- *
- * @remark
- * This function can be used to determine the proximity to device from other object like human face.
- *
- * @param[in] distance Distance in centimeter from proximity sensor.
- * @param[out] is_near proximity to device from other object.
- */
-int sensor_util_is_near(float distance, bool *is_near);
-
-/**
- * @brief Continues to sense even when LCD is off
- *
- * @param[in] sensor The sensor handle
- * @param[out] type The sensor type
- */
-int sensor_set_always_on(sensor_h sensor, sensor_type_e type);
-/**
- * @}
- */
-
-
-/**
- *
- * @}
+ * @}
*/
#ifdef __cplusplus
}
#endif
-#endif
-
+#endif /* __SENSOR_H__ */
<manifest>
- <request>
- <domain name="_"/>
- </request>
+ <request>
+ <domain name="_"/>
+ </request>
</manifest>
+
Name: capi-system-sensor
Summary: A Sensor library in TIZEN C API
-Version: 0.1.17
+Version: 0.1.0
Release: 0
-Group: framework/system
-License: Apache-2.0
+Group: System/API
+License: Apache 2.0
Source0: %{name}-%{version}.tar.gz
-Source1001: capi-system-sensor.manifest
+Source1: capi-system-sensor.manifest
+
BuildRequires: cmake
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(sensor)
BuildRequires: pkgconfig(capi-base-common)
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
%description
-%{summary}
+A Sensor Library in TIZEN C API package.
%package devel
Summary: A Sensor library in TIZEN C API (Development)
-Group: framework/system
+Group: System/Development
Requires: %{name} = %{version}-%{release}
%description devel
-%{summary}
-
+A Sensor library in TIZEN C API package (Development).
+%devel_desc
%prep
%setup -q
-cp %{SOURCE1001} .
-
%build
+cp %{SOURCE1} .
MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
-
-%cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER} -DVERSION="%{version}"
-
-%__make %{?jobs:-j%jobs}
-
+%cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
+%__make %{?_smp_mflags}
%install
+rm -rf %{buildroot}
%make_install
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
-
%files
-%manifest %{name}.manifest
-%license LICENSE
+%manifest capi-system-sensor.manifest
%{_libdir}/libcapi-system-sensor.so.*
+%license LICENSE.APLv2
%files devel
-%manifest %{name}.manifest
-%license LICENSE
-%{_includedir}/system/sensors.h
-%{_libdir}/pkgconfig/*.pc
+%manifest capi-system-sensor.manifest
+%license LICENSE.APLv2
%{_libdir}/libcapi-system-sensor.so
+%{_libdir}/pkgconfig/*.pc
+%{_includedir}/sensor/*.h
+
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include <math.h>
#include <stdlib.h>
-#include <math.h>\r
-#include <stdlib.h>\r
-\r
-const float c[13][13] = {\r
- {0.0, -29496.6, -3594.9, 3350.2, 3992.6, -1818.3, 1051.0, 2158.4, 1226.7, 512.8, -360.9, 1033.3, -1452.4, },\r
- {4944.4, -1586.3, 5241.4, -7122.5, 4476.4, 3631.5, 1296.8, -2663.8, 543.0, 1197.6, -1532.7, -699.6, -179.4, },\r
- {-4689.9, -498.9, 1445.0, 2385.6, 652.3, 1539.3, 1135.8, -136.1, -813.2, 369.4, 189.6, -859.0, 238.5, },\r
- {-490.5, 487.8, -424.2, 501.2, -746.9, -664.0, -1408.7, 927.7, -231.9, -431.5, -181.8, 557.5, 649.2, },\r
- {1584.9, -826.5, 343.7, -228.6, 66.1, -361.6, -124.4, 171.7, -516.0, 174.8, -23.4, -119.8, -292.1, },\r
- {453.4, 1451.7, -556.3, 0.0, 70.8, -5.5, 30.7, 64.2, 170.6, -417.8, 184.8, 79.2, 300.6, },\r
- {-393.2, 659.0, 612.7, -361.8, 7.2, 36.9, -52.3, 4.1, 74.8, -12.2, -12.4, -75.3, -20.8, },\r
- {-2053.7, -611.1, 133.1, 307.5, 43.2, -67.1, -2.1, 3.2, -35.3, 63.3, 44.1, 19.8, 58.5, },\r
- {737.3, -1121.6, 492.9, -465.2, 247.7, 48.1, -27.1, 1.1, -2.3, -22.0, 25.4, 41.0, -23.4, },\r
- {-2611.8, 1249.5, 1062.2, -405.9, -249.3, 139.2, 15.8, -15.8, 4.3, -6.2, -2.7, 0.9, -10.2, },\r
- {681.2, -21.1, 776.8, 514.2, -532.2, -41.3, -78.2, -16.4, -5.3, -4.9, -1.7, 1.9, 1.9, },\r
- {93.3, 695.4, -196.8, -431.1, 142.6, -37.6, -124.0, -29.6, -18.5, -5.2, -1.0, 2.2, -2.2, },\r
- {-807.3, 238.5, 1363.4, -1217.3, 167.0, 125.0, 0.0, 5.9, 7.7, -8.5, -0.6, 0.5, 0.0, }};\r
-\r
-\r
-const float cd[13][13] = {\r
- {0.0, 11.6, -18.1, 1.0, -7.9, -7.9, -2.9, 2.7, -5.0, 0.0, 0.0, 0.0, 0.0, },\r
- {-25.9, 16.5, -7.6, -12.6, 12.7, 6.1, -3.8, -3.5, 6.7, -12.7, 0.0, 0.0, 0.0, },\r
- {-39.0, -10.2, 1.6, -5.6, -34.0, -13.8, -1.5, -17.4, -33.6, 0.0, -21.1, 0.0, 79.5, },\r
- {22.4, -7.6, -2.1, -6.1, 9.6, -4.7, 19.9, 26.6, 8.3, 24.9, 33.1, 32.8, 64.9, },\r
- {6.1, 10.6, 8.2, -0.6, -1.6, 2.0, -9.3, 4.9, -5.3, -22.6, 0.0, 0.0, -48.7, },\r
- {4.1, 13.8, 5.6, 8.9, -0.4, 0.7, -0.7, 1.9, 4.4, -10.1, -7.4, 0.0, 0.0, },\r
- {-3.8, -31.4, -4.0, -3.3, 1.2, 0.6, 1.1, -1.7, 2.1, 1.7, -8.3, 0.0, 0.0, },\r
- {24.8, 8.7, -2.0, -1.2, -4.9, -0.7, 0.2, 0.4, -1.5, -0.8, 0.0, 0.0, 0.0, },\r
- {-6.7, 11.2, 16.6, 10.7, 1.5, -0.7, 1.0, 0.2, 0.1, -1.0, -0.8, 0.0, 0.0, },\r
- {0.0, -21.7, 0.0, -5.6, 3.4, 0.0, -1.5, 0.8, 0.1, -0.1, -0.5, 0.0, 0.0, },\r
- {24.3, -21.1, 0.0, -11.7, -7.4, 0.0, -2.0, -1.6, 0.0, -0.1, -0.1, -0.3, 0.0, },\r
- {0.0, 40.9, 0.0, 24.0, 0.0, 9.4, 0.0, -2.3, -0.9, 0.0, -0.1, 0.0, -0.3, },\r
- {0.0, 0.0, 0.0, 0.0, 0.0, 20.8, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.1, }};\r
-\r
-float g_declination = 0;\r
-float g_inclination = 0;\r
-\r
-static void E0000(int IENTRY, int maxdeg, float alt,float glat,float glon, float time, float *dec, float *dip, float *ti, float *gv);\r
-\r
-int getDeclination(float *decl)\r
-{\r
- if(decl == NULL)\r
- return -1;\r
- \r
- *decl = g_declination;\r
-\r
- return 0;\r
-}\r
-\r
-int getInclination(float *incl)\r
-{\r
- if(incl == NULL)\r
- return -1;\r
-\r
- *incl = g_inclination;\r
-\r
- return 0;\r
-}\r
-\r
-int setCoordinate(float latitude, float longitude, float altitude, float *declination, float *inclination, int option)\r
-{\r
- float dec, dip, ti, gv;\r
- float h;\r
- float rTd=0.017453292;\r
- \r
- E0000(0,12,0.0,0.0,0.0,0.0,NULL,NULL,NULL,NULL);\r
- E0000(1,0,altitude,latitude,longitude,2,&dec,&dip,&ti,&gv);\r
-\r
- h=ti*(cos((dip*rTd)));\r
-\r
- /* deal with geographic and magnetic poles */\r
-\r
- if (h < 100.0) /* at magnetic poles */\r
- {\r
- dec = 0;\r
- }\r
-\r
- if(option == 1)\r
- {\r
- if(declination != NULL)\r
- *declination = dec;\r
- if(inclination != NULL)\r
- *inclination = dip;\r
- }\r
- else if( option == 0)\r
- {\r
- g_declination = dec;\r
- g_inclination = dip;\r
- }\r
-\r
- return 0;\r
-}\r
-/*************************************************************************/\r
-\r
-static void E0000(int IENTRY, int maxdeg, float alt, float glat, float glon, float time, float *dec, float *dip, float *ti, float *gv)\r
-{\r
- static int maxord,n,m,j,D1,D2,D3,D4;\r
- static float tc[13][13],dp[13][13],snorm[169],\r
- sp[13],cp[13],fn[13],fm[13],pp[13],k[13][13],pi,dtr,a,b,re,\r
- a2,b2,c2,a4,b4,c4,flnmj,otime,oalt,\r
- olat,olon,dt,rlon,rlat,srlon,srlat,crlon,crlat,srlat2,\r
- crlat2,q,q1,q2,ct,st,r2,r,d,ca,sa,aor,ar,br,bt,bp,bpp,\r
- par,temp1,temp2,parp,bx,by,bz,bh;\r
- static float *p = snorm;\r
-\r
- switch(IENTRY){case 0: goto GEOMAG; case 1: goto GEOMG1;}\r
-\r
-GEOMAG:\r
- maxord = 12;\r
- sp[0] = 0.0;\r
- cp[0] = *p = pp[0] = 1.0;\r
- dp[0][0] = 0.0;\r
- a = 6378.137;\r
- b = 6356.7523142;\r
- re = 6371.2;\r
- a2 = a*a;\r
- b2 = b*b;\r
- c2 = a2-b2;\r
- a4 = a2*a2;\r
- b4 = b2*b2;\r
- c4 = a4 - b4;\r
-\r
- *snorm = 1.0;\r
- fm[0] = 0.0;\r
- for (n=1; n<=maxord; n++)\r
- {\r
- *(snorm+n) = *(snorm+n-1)*(float)(2*n-1)/(float)n;\r
- j = 2;\r
- for (m=0,D1=1,D2=(n-m+D1)/D1; D2>0; D2--,m+=D1)\r
- {\r
- k[m][n] = (float)(((n-1)*(n-1))-(m*m))/(float)((2*n-1)*(2*n-3));\r
- if (m > 0)\r
- {\r
- flnmj = (float)((n-m+1)*j)/(float)(n+m);\r
- *(snorm+n+m*13) = *(snorm+n+(m-1)*13)*sqrt(flnmj);\r
- j = 1;\r
- }\r
- }\r
- fn[n] = (float)(n+1);\r
- fm[n] = (float)n;\r
- }\r
- k[1][1] = 0.0;\r
-\r
- otime = oalt = olat = olon = -1000.0;\r
- \r
- return;\r
-\r
- /*************************************************************************/\r
-\r
-GEOMG1:\r
-\r
- dt = time;\r
- pi = 3.14159265359;\r
- dtr = pi/180.0;\r
- rlon = glon*dtr;\r
- rlat = glat*dtr;\r
- srlon = sin(rlon);\r
- srlat = sin(rlat);\r
- crlon = cos(rlon);\r
- crlat = cos(rlat);\r
- srlat2 = srlat*srlat;\r
- crlat2 = crlat*crlat;\r
- sp[1] = srlon;\r
- cp[1] = crlon;\r
-\r
- if (alt != oalt || glat != olat)\r
- {\r
- q = sqrt(a2-c2*srlat2);\r
- q1 = alt*q;\r
- q2 = ((q1+a2)/(q1+b2))*((q1+a2)/(q1+b2));\r
- ct = srlat/sqrt(q2*crlat2+srlat2);\r
- st = sqrt(1.0-(ct*ct));\r
- r2 = (alt*alt)+2.0*q1+(a4-c4*srlat2)/(q*q);\r
- r = sqrt(r2);\r
- d = sqrt(a2*crlat2+b2*srlat2);\r
- ca = (alt+d)/r;\r
- sa = c2*crlat*srlat/(r*d);\r
- }\r
- if (glon != olon)\r
- {\r
- for (m=2; m<=maxord; m++)\r
- {\r
- sp[m] = sp[1]*cp[m-1]+cp[1]*sp[m-1];\r
- cp[m] = cp[1]*cp[m-1]-sp[1]*sp[m-1];\r
- }\r
- }\r
- aor = re/r;\r
- ar = aor*aor;\r
- br = bt = bp = bpp = 0.0;\r
- for (n=1; n<=maxord; n++)\r
- {\r
- ar = ar*aor;\r
- for (m=0,D3=1,D4=(n+m+D3)/D3; D4>0; D4--,m+=D3)\r
- {\r
- if (alt != oalt || glat != olat)\r
- {\r
- if (n == m)\r
- {\r
- *(p+n+m*13) = st**(p+n-1+(m-1)*13);\r
- dp[m][n] = st*dp[m-1][n-1]+ct**(p+n-1+(m-1)*13);\r
- goto S50;\r
- }\r
- if (n == 1 && m == 0)\r
- {\r
- *(p+n+m*13) = ct**(p+n-1+m*13);\r
- dp[m][n] = ct*dp[m][n-1]-st**(p+n-1+m*13);\r
- goto S50;\r
- }\r
- if (n > 1 && n != m)\r
- {\r
- if (m > n-2) *(p+n-2+m*13) = 0.0;\r
- if (m > n-2) dp[m][n-2] = 0.0;\r
- *(p+n+m*13) = ct**(p+n-1+m*13)-k[m][n]**(p+n-2+m*13);\r
- dp[m][n] = ct*dp[m][n-1] - st**(p+n-1+m*13)-k[m][n]*dp[m][n-2];\r
- }\r
- }\r
-S50:\r
- if (time != otime)\r
- {\r
- tc[m][n] = c[m][n]+dt*cd[m][n];\r
- if (m != 0) tc[n][m-1] = c[n][m-1]+dt*cd[n][m-1];\r
- }\r
- \r
- par = ar**(p+n+m*13);\r
- if (m == 0)\r
- {\r
- temp1 = tc[m][n]*cp[m];\r
- temp2 = tc[m][n]*sp[m];\r
- }\r
- else\r
- {\r
- temp1 = tc[m][n]*cp[m]+tc[n][m-1]*sp[m];\r
- temp2 = tc[m][n]*sp[m]-tc[n][m-1]*cp[m];\r
- }\r
- bt = bt-ar*temp1*dp[m][n];\r
- bp += (fm[m]*temp2*par);\r
- br += (fn[n]*temp1*par);\r
- \r
- if (st == 0.0 && m == 1)\r
- {\r
- if (n == 1) pp[n] = pp[n-1];\r
- else pp[n] = ct*pp[n-1]-k[m][n]*pp[n-2];\r
- parp = ar*pp[n];\r
- bpp += (fm[m]*temp2*parp);\r
- }\r
- }\r
- }\r
- if (st == 0.0) bp = bpp;\r
- else bp /= st;\r
- \r
- bx = -bt*ca-br*sa;\r
- by = bp;\r
- bz = bt*sa-br*ca;\r
- bh = sqrt((bx*bx)+(by*by));\r
- *ti = sqrt((bh*bh)+(bz*bz));\r
- *dec = atan2(by,bx)/dtr;\r
- *dip = atan2(bz,bh)/dtr;\r
- *gv = -999.0;\r
- if (fabs(glat) >= 55.)\r
- {\r
- if (glat > 0.0 && glon >= 0.0) *gv = *dec-glon;\r
- if (glat > 0.0 && glon < 0.0) *gv = *dec+fabs(glon);\r
- if (glat < 0.0 && glon >= 0.0) *gv = *dec+glon;\r
- if (glat < 0.0 && glon < 0.0) *gv = *dec-fabs(glon);\r
- if (*gv > +180.0) *gv -= 360.0;\r
- if (*gv < -180.0) *gv += 360.0;\r
- }\r
- otime = time;\r
- oalt = alt;\r
- olat = glat;\r
- olon = glon;\r
- return;\r
-}\r
-\r
+/*
+ * This file is part of WMM source code.
+ * The original code is the WMM Source from National Oceanic And Atmospheric.
+ *
+ * See the license below for more details.
+ *
+ * The WMM source code is in the public domain and not licensed or under
+ * copyright. The information and software may be used freely by the public.
+ * As required by 17 U.S.C. 403, third parties producing copyrighted works
+ * consisting predominantly of the material produced by U.S.
+ * government agencies must provide notice with such work identifying the U.S.
+ * Government material incorporated and stating that such material is not
+ * subject to copyright protection.
+ */
+
+#include <math.h>
+#include <stdlib.h>
+
+const float c[13][13] = {
+ {0.0, -29496.6, -3594.9, 3350.2, 3992.6, -1818.3, 1051.0, 2158.4, 1226.7, 512.8, -360.9, 1033.3, -1452.4, },
+ {4944.4, -1586.3, 5241.4, -7122.5, 4476.4, 3631.5, 1296.8, -2663.8, 543.0, 1197.6, -1532.7, -699.6, -179.4, },
+ {-4689.9, -498.9, 1445.0, 2385.6, 652.3, 1539.3, 1135.8, -136.1, -813.2, 369.4, 189.6, -859.0, 238.5, },
+ {-490.5, 487.8, -424.2, 501.2, -746.9, -664.0, -1408.7, 927.7, -231.9, -431.5, -181.8, 557.5, 649.2, },
+ {1584.9, -826.5, 343.7, -228.6, 66.1, -361.6, -124.4, 171.7, -516.0, 174.8, -23.4, -119.8, -292.1, },
+ {453.4, 1451.7, -556.3, 0.0, 70.8, -5.5, 30.7, 64.2, 170.6, -417.8, 184.8, 79.2, 300.6, },
+ {-393.2, 659.0, 612.7, -361.8, 7.2, 36.9, -52.3, 4.1, 74.8, -12.2, -12.4, -75.3, -20.8, },
+ {-2053.7, -611.1, 133.1, 307.5, 43.2, -67.1, -2.1, 3.2, -35.3, 63.3, 44.1, 19.8, 58.5, },
+ {737.3, -1121.6, 492.9, -465.2, 247.7, 48.1, -27.1, 1.1, -2.3, -22.0, 25.4, 41.0, -23.4, },
+ {-2611.8, 1249.5, 1062.2, -405.9, -249.3, 139.2, 15.8, -15.8, 4.3, -6.2, -2.7, 0.9, -10.2, },
+ {681.2, -21.1, 776.8, 514.2, -532.2, -41.3, -78.2, -16.4, -5.3, -4.9, -1.7, 1.9, 1.9, },
+ {93.3, 695.4, -196.8, -431.1, 142.6, -37.6, -124.0, -29.6, -18.5, -5.2, -1.0, 2.2, -2.2, },
+ {-807.3, 238.5, 1363.4, -1217.3, 167.0, 125.0, 0.0, 5.9, 7.7, -8.5, -0.6, 0.5, 0.0, }};
+
+
+const float cd[13][13] = {
+ {0.0, 11.6, -18.1, 1.0, -7.9, -7.9, -2.9, 2.7, -5.0, 0.0, 0.0, 0.0, 0.0, },
+ {-25.9, 16.5, -7.6, -12.6, 12.7, 6.1, -3.8, -3.5, 6.7, -12.7, 0.0, 0.0, 0.0, },
+ {-39.0, -10.2, 1.6, -5.6, -34.0, -13.8, -1.5, -17.4, -33.6, 0.0, -21.1, 0.0, 79.5, },
+ {22.4, -7.6, -2.1, -6.1, 9.6, -4.7, 19.9, 26.6, 8.3, 24.9, 33.1, 32.8, 64.9, },
+ {6.1, 10.6, 8.2, -0.6, -1.6, 2.0, -9.3, 4.9, -5.3, -22.6, 0.0, 0.0, -48.7, },
+ {4.1, 13.8, 5.6, 8.9, -0.4, 0.7, -0.7, 1.9, 4.4, -10.1, -7.4, 0.0, 0.0, },
+ {-3.8, -31.4, -4.0, -3.3, 1.2, 0.6, 1.1, -1.7, 2.1, 1.7, -8.3, 0.0, 0.0, },
+ {24.8, 8.7, -2.0, -1.2, -4.9, -0.7, 0.2, 0.4, -1.5, -0.8, 0.0, 0.0, 0.0, },
+ {-6.7, 11.2, 16.6, 10.7, 1.5, -0.7, 1.0, 0.2, 0.1, -1.0, -0.8, 0.0, 0.0, },
+ {0.0, -21.7, 0.0, -5.6, 3.4, 0.0, -1.5, 0.8, 0.1, -0.1, -0.5, 0.0, 0.0, },
+ {24.3, -21.1, 0.0, -11.7, -7.4, 0.0, -2.0, -1.6, 0.0, -0.1, -0.1, -0.3, 0.0, },
+ {0.0, 40.9, 0.0, 24.0, 0.0, 9.4, 0.0, -2.3, -0.9, 0.0, -0.1, 0.0, -0.3, },
+ {0.0, 0.0, 0.0, 0.0, 0.0, 20.8, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.1, }};
+
+float g_declination = 0;
+float g_inclination = 0;
+
+static void E0000(int IENTRY, int maxdeg, float alt,float glat,float glon, float time, float *dec, float *dip, float *ti, float *gv);
+
+int getDeclination(float *decl)
+{
+ if(decl == NULL)
+ return -1;
+
+ *decl = g_declination;
+
+ return 0;
+}
+
+int getInclination(float *incl)
+{
+ if(incl == NULL)
+ return -1;
+
+ *incl = g_inclination;
+
+ return 0;
+}
+
+int setCoordinate(float latitude, float longitude, float altitude, float *declination, float *inclination, int option)
+{
+ float dec, dip, ti, gv;
+ float h;
+ float rTd=0.017453292;
+
+ E0000(0,12,0.0,0.0,0.0,0.0,NULL,NULL,NULL,NULL);
+ E0000(1,0,altitude,latitude,longitude,2,&dec,&dip,&ti,&gv);
+
+ h=ti*(cos((dip*rTd)));
+
+ /* deal with geographic and magnetic poles */
+
+ if (h < 100.0) /* at magnetic poles */
+ {
+ dec = 0;
+ }
+
+ if(option == 1)
+ {
+ if(declination != NULL)
+ *declination = dec;
+ if(inclination != NULL)
+ *inclination = dip;
+ }
+ else if( option == 0)
+ {
+ g_declination = dec;
+ g_inclination = dip;
+ }
+
+ return 0;
+}
+/*************************************************************************/
+
+static void E0000(int IENTRY, int maxdeg, float alt, float glat, float glon, float time, float *dec, float *dip, float *ti, float *gv)
+{
+ static int maxord,n,m,j,D1,D2,D3,D4;
+ static float tc[13][13],dp[13][13],snorm[169],
+ sp[13],cp[13],fn[13],fm[13],pp[13],k[13][13],pi,dtr,a,b,re,
+ a2,b2,c2,a4,b4,c4,flnmj,otime,oalt,
+ olat,olon,dt,rlon,rlat,srlon,srlat,crlon,crlat,srlat2,
+ crlat2,q,q1,q2,ct,st,r2,r,d,ca,sa,aor,ar,br,bt,bp,bpp,
+ par,temp1,temp2,parp,bx,by,bz,bh;
+ static float *p = snorm;
+
+ switch(IENTRY){case 0: goto GEOMAG; case 1: goto GEOMG1;}
+
+GEOMAG:
+ maxord = 12;
+ sp[0] = 0.0;
+ cp[0] = *p = pp[0] = 1.0;
+ dp[0][0] = 0.0;
+ a = 6378.137;
+ b = 6356.7523142;
+ re = 6371.2;
+ a2 = a*a;
+ b2 = b*b;
+ c2 = a2-b2;
+ a4 = a2*a2;
+ b4 = b2*b2;
+ c4 = a4 - b4;
+
+ *snorm = 1.0;
+ fm[0] = 0.0;
+ for (n=1; n<=maxord; n++)
+ {
+ *(snorm+n) = *(snorm+n-1)*(float)(2*n-1)/(float)n;
+ j = 2;
+ for (m=0,D1=1,D2=(n-m+D1)/D1; D2>0; D2--,m+=D1)
+ {
+ k[m][n] = (float)(((n-1)*(n-1))-(m*m))/(float)((2*n-1)*(2*n-3));
+ if (m > 0)
+ {
+ flnmj = (float)((n-m+1)*j)/(float)(n+m);
+ *(snorm+n+m*13) = *(snorm+n+(m-1)*13)*sqrt(flnmj);
+ j = 1;
+ }
+ }
+ fn[n] = (float)(n+1);
+ fm[n] = (float)n;
+ }
+ k[1][1] = 0.0;
+
+ otime = oalt = olat = olon = -1000.0;
+
+ return;
+
+ /*************************************************************************/
+
+GEOMG1:
+
+ dt = time;
+ pi = 3.14159265359;
+ dtr = pi/180.0;
+ rlon = glon*dtr;
+ rlat = glat*dtr;
+ srlon = sin(rlon);
+ srlat = sin(rlat);
+ crlon = cos(rlon);
+ crlat = cos(rlat);
+ srlat2 = srlat*srlat;
+ crlat2 = crlat*crlat;
+ sp[1] = srlon;
+ cp[1] = crlon;
+
+ if (alt != oalt || glat != olat)
+ {
+ q = sqrt(a2-c2*srlat2);
+ q1 = alt*q;
+ q2 = ((q1+a2)/(q1+b2))*((q1+a2)/(q1+b2));
+ ct = srlat/sqrt(q2*crlat2+srlat2);
+ st = sqrt(1.0-(ct*ct));
+ r2 = (alt*alt)+2.0*q1+(a4-c4*srlat2)/(q*q);
+ r = sqrt(r2);
+ d = sqrt(a2*crlat2+b2*srlat2);
+ ca = (alt+d)/r;
+ sa = c2*crlat*srlat/(r*d);
+ }
+ if (glon != olon)
+ {
+ for (m=2; m<=maxord; m++)
+ {
+ sp[m] = sp[1]*cp[m-1]+cp[1]*sp[m-1];
+ cp[m] = cp[1]*cp[m-1]-sp[1]*sp[m-1];
+ }
+ }
+ aor = re/r;
+ ar = aor*aor;
+ br = bt = bp = bpp = 0.0;
+ for (n=1; n<=maxord; n++)
+ {
+ ar = ar*aor;
+ for (m=0,D3=1,D4=(n+m+D3)/D3; D4>0; D4--,m+=D3)
+ {
+ if (alt != oalt || glat != olat)
+ {
+ if (n == m)
+ {
+ *(p+n+m*13) = st**(p+n-1+(m-1)*13);
+ dp[m][n] = st*dp[m-1][n-1]+ct**(p+n-1+(m-1)*13);
+ goto S50;
+ }
+ if (n == 1 && m == 0)
+ {
+ *(p+n+m*13) = ct**(p+n-1+m*13);
+ dp[m][n] = ct*dp[m][n-1]-st**(p+n-1+m*13);
+ goto S50;
+ }
+ if (n > 1 && n != m)
+ {
+ if (m > n-2) *(p+n-2+m*13) = 0.0;
+ if (m > n-2) dp[m][n-2] = 0.0;
+ *(p+n+m*13) = ct**(p+n-1+m*13)-k[m][n]**(p+n-2+m*13);
+ dp[m][n] = ct*dp[m][n-1] - st**(p+n-1+m*13)-k[m][n]*dp[m][n-2];
+ }
+ }
+S50:
+ if (time != otime)
+ {
+ tc[m][n] = c[m][n]+dt*cd[m][n];
+ if (m != 0) tc[n][m-1] = c[n][m-1]+dt*cd[n][m-1];
+ }
+
+ par = ar**(p+n+m*13);
+ if (m == 0)
+ {
+ temp1 = tc[m][n]*cp[m];
+ temp2 = tc[m][n]*sp[m];
+ }
+ else
+ {
+ temp1 = tc[m][n]*cp[m]+tc[n][m-1]*sp[m];
+ temp2 = tc[m][n]*sp[m]-tc[n][m-1]*cp[m];
+ }
+ bt = bt-ar*temp1*dp[m][n];
+ bp += (fm[m]*temp2*par);
+ br += (fn[n]*temp1*par);
+
+ if (st == 0.0 && m == 1)
+ {
+ if (n == 1) pp[n] = pp[n-1];
+ else pp[n] = ct*pp[n-1]-k[m][n]*pp[n-2];
+ parp = ar*pp[n];
+ bpp += (fm[m]*temp2*parp);
+ }
+ }
+ }
+ if (st == 0.0) bp = bpp;
+ else bp /= st;
+
+ bx = -bt*ca-br*sa;
+ by = bp;
+ bz = bt*sa-br*ca;
+ bh = sqrt((bx*bx)+(by*by));
+ *ti = sqrt((bh*bh)+(bz*bz));
+ *dec = atan2(by,bx)/dtr;
+ *dip = atan2(bz,bh)/dtr;
+ *gv = -999.0;
+ if (fabs(glat) >= 55.)
+ {
+ if (glat > 0.0 && glon >= 0.0) *gv = *dec-glon;
+ if (glat > 0.0 && glon < 0.0) *gv = *dec+fabs(glon);
+ if (glat < 0.0 && glon >= 0.0) *gv = *dec+glon;
+ if (glat < 0.0 && glon < 0.0) *gv = *dec-fabs(glon);
+ if (*gv > +180.0) *gv -= 360.0;
+ if (*gv < -180.0) *gv += 360.0;
+ }
+ otime = time;
+ oalt = alt;
+ olat = glat;
+ olon = glon;
+ return;
+}
+
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-
-
-#include <math.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/time.h>
-
-#include <sensor.h>
-#include <sensor_accel.h>
-#include <sensor_geomag.h>
-#include <sensor_light.h>
-#include <sensor_proxi.h>
-#include <sensor_motion.h>
-#include <sensor_gyro.h>
-#include <sensors.h>
-#include <sensor_private.h>
-#include <dlog.h>
-
-#define _DEBUG 1
-
-#ifdef _DEBUG
-#undef LOG_TAG
-#define LOG_TAG "TIZEN_SYSTEM_SENSOR"
-#include <stdio.h>
-#include <libgen.h>
-static char* _DONT_USE_THIS_ARRAY_DIRECTLY[] = {
- "ACCELEROMETER",
- "GRAVITY",
- "LINEAR_ACCELERATION",
- "DEVICE_ORIENTATION",
- "MAGNETIC",
- "ORIENTATION",
- "GYROSCOPE",
- "LIGHT",
- "PROXIMITY",
- "MOTION_SNAP",
- "MOTION_SHAKE",
- "MOTION_DOUBLETAP",
- "MOTION_PANNING",
- "MOTION_PANNING_BROWSE",
- "MOTION_TILT",
- "MOTION_FACEDOWN",
- "MOTION_DIRECTCALL",
- "MOTION_SMART_ALERT",
- "MOTION_NO_MOVE",
- "LAST"
-};
-
-#define _MSG_SENSOR_ERROR_IO_ERROR "Io Error"
-#define _MSG_SENSOR_ERROR_INVALID_PARAMETER "Invalid Parameter"
-#define _MSG_SENSOR_ERROR_OUT_OF_MEMORY "Out of Memory"
-#define _MSG_SENSOR_ERROR_NOT_NEED_CALIBRATION "Not need calibration"
-#define _MSG_SENSOR_ERROR_NOT_SUPPORTED "Not supported"
-#define _MSG_SENSOR_ERROR_OPERATION_FAILED "Operation failed"
-
-#define TYPE_NAME(type) _DONT_USE_THIS_ARRAY_DIRECTLY[type]
-
-#define DEBUG_PRINT(txt) LOGD("%s : " txt, __FUNCTION__)
-#define DEBUG_PRINTF(fmt, ...) LOGD("%s : " fmt, __FUNCTION__, __VA_ARGS__)
-#define ERROR_PRINT(err) LOGD("[%s]" _MSG_##err "(0x%08x)", __FUNCTION__, err)
-#define ERROR_PRINTF(err, fmt, ...) LOGD("[%s]" _MSG_##err "(0x%08x) : " fmt, __FUNCTION__, err, __VA_ARGS__)
-#else
-#define TYPE_NAME(type) ""
-#define DEBUG_PRINT(txt)
-#define DEBUG_PRINTF(fmt, ...)
-#define ERROR_PRINT(err)
-#define ERROR_PRINTF(err)
-#endif
-
-#define RETURN_VAL_IF(expr, err) \
- do { \
- if (expr) { \
- ERROR_PRINT(err); \
- return (err); \
- } \
- } while(0)
-
-#define RETURN_ERROR(err) \
- do { \
- ERROR_PRINT(err); \
- return err; \
- } while(0)
-
-
-#define RETURN_IF_NOT_HANDLE(handle) \
- RETURN_VAL_IF(handle == NULL, SENSOR_ERROR_INVALID_PARAMETER)
-
-#define RETURN_IF_NOT_TYPE(type) \
- RETURN_VAL_IF(type >= SENSOR_LAST || type < 0, SENSOR_ERROR_INVALID_PARAMETER)
-
-#define RETURN_IF_MOTION_TYPE(type) \
- RETURN_VAL_IF(type >= SENSOR_MOTION_SNAP && type <= SENSOR_MOTION_NO_MOVE, SENSOR_ERROR_INVALID_PARAMETER)
-
-#define RETURN_IF_NOT_WAKEUP_TYPE(type) \
- RETURN_VAL_IF(type > SENSOR_DEVICE_ORIENTATION, SENSOR_ERROR_NOT_SUPPORTED)
-
-#define RETURN_IF_ERROR(val) \
- RETURN_VAL_IF(val < 0, val)
-
-#define MICROSECONDS(tv) ((tv.tv_sec * 1000000ll) + tv.tv_usec)
-
-sensor_data_accuracy_e _accu_table[] = {
- SENSOR_ACCURACY_UNDEFINED,
- SENSOR_ACCURACY_BAD,
- SENSOR_ACCURACY_NORMAL,
- SENSOR_ACCURACY_GOOD,
- SENSOR_ACCURACY_VERYGOOD,
-};
-
-sensor_type_t _TYPE[] = {
- ACCELEROMETER_SENSOR,
- ACCELEROMETER_SENSOR,
- ACCELEROMETER_SENSOR,
- ACCELEROMETER_SENSOR,
- GEOMAGNETIC_SENSOR,
- GEOMAGNETIC_SENSOR,
- GYROSCOPE_SENSOR,
- LIGHT_SENSOR,
- PROXIMITY_SENSOR,
- MOTION_SENSOR,
- MOTION_SENSOR,
- MOTION_SENSOR,
- MOTION_SENSOR,
- MOTION_SENSOR,
- MOTION_SENSOR,
- MOTION_SENSOR,
- MOTION_SENSOR,
- MOTION_SENSOR,
- MOTION_SENSOR,
-};
-
-int _DTYPE[] = {
- ACCELEROMETER_BASE_DATA_SET,
- ACCELEROMETER_GRAVITY_DATA_SET,
- ACCELEROMETER_LINEAR_ACCELERATION_DATA_SET,
- ACCELEROMETER_ORIENTATION_DATA_SET,
- GEOMAGNETIC_RAW_DATA_SET,
- GEOMAGNETIC_BASE_DATA_SET,
- GYRO_BASE_DATA_SET,
- LIGHT_LUX_DATA_SET,
- PROXIMITY_DISTANCE_DATA_SET,
- MOTION_SENSOR,
- MOTION_SENSOR,
- MOTION_SENSOR,
- MOTION_SENSOR,
- MOTION_SENSOR,
- MOTION_SENSOR,
- MOTION_SENSOR,
- MOTION_SENSOR,
- MOTION_SENSOR,
- MOTION_SENSOR,
-};
-
-int _EVENT[] = {
- ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME,
- ACCELEROMETER_EVENT_GRAVITY_DATA_REPORT_ON_TIME,
- ACCELEROMETER_EVENT_LINEAR_ACCELERATION_DATA_REPORT_ON_TIME,
- ACCELEROMETER_EVENT_ORIENTATION_DATA_REPORT_ON_TIME,
- GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME,
- GEOMAGNETIC_EVENT_ATTITUDE_DATA_REPORT_ON_TIME,
- GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME,
- LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME,
- PROXIMITY_EVENT_DISTANCE_DATA_REPORT_ON_TIME,
- MOTION_ENGINE_EVENT_SNAP,
- MOTION_ENGINE_EVENT_SHAKE,
- MOTION_ENGINE_EVENT_DOUBLETAP,
- MOTION_ENGINE_EVENT_PANNING,
- MOTION_ENGINE_EVENT_PANNING_BROWSE,
- MOTION_ENGINE_EVENT_TILT,
- MOTION_ENGINE_EVENT_TOP_TO_BOTTOM,
- MOTION_ENGINE_EVENT_DIRECT_CALL,
- MOTION_ENGINE_EVENT_SMART_ALERT,
- MOTION_ENGINE_EVENT_NO_MOVE,
-};
-
-int _CALIBRATION[] = {
- ACCELEROMETER_EVENT_CALIBRATION_NEEDED,
- ACCELEROMETER_EVENT_CALIBRATION_NEEDED,
- ACCELEROMETER_EVENT_CALIBRATION_NEEDED,
- ACCELEROMETER_EVENT_CALIBRATION_NEEDED,
- GEOMAGNETIC_EVENT_CALIBRATION_NEEDED,
- GEOMAGNETIC_EVENT_CALIBRATION_NEEDED,
- EMPTY_EVENT,
- EMPTY_EVENT,
- EMPTY_EVENT,
- EMPTY_EVENT,
- EMPTY_EVENT,
- EMPTY_EVENT,
- EMPTY_EVENT,
- EMPTY_EVENT,
- EMPTY_EVENT,
- EMPTY_EVENT,
- EMPTY_EVENT,
- EMPTY_EVENT,
- EMPTY_EVENT,
-};
-
-
-int _WAKEUP[] = {
- ACCELEROMETER_EVENT_SET_WAKEUP,
- ACCELEROMETER_EVENT_SET_WAKEUP,
- ACCELEROMETER_EVENT_SET_WAKEUP,
- ACCELEROMETER_EVENT_SET_WAKEUP,
- EMPTY_EVENT,
- EMPTY_EVENT,
- EMPTY_EVENT,
- EMPTY_EVENT,
- EMPTY_EVENT,
- EMPTY_EVENT,
- EMPTY_EVENT,
- EMPTY_EVENT,
- EMPTY_EVENT,
- EMPTY_EVENT,
- EMPTY_EVENT,
- EMPTY_EVENT,
- EMPTY_EVENT,
- EMPTY_EVENT,
- EMPTY_EVENT,
-};
-
-int _sensor_ids[] = {
- ID_ACCELEOMETER,
- ID_ACCELEOMETER,
- ID_ACCELEOMETER,
- ID_ACCELEOMETER,
- ID_GEOMAGNETIC,
- ID_GEOMAGNETIC,
- ID_GYROSCOPE,
- ID_LIGHT,
- ID_PROXIMITY,
- ID_MOTION,
- ID_MOTION,
- ID_MOTION,
- ID_MOTION,
- ID_MOTION,
- ID_MOTION,
- ID_MOTION,
- ID_MOTION,
- ID_MOTION,
- ID_MOTION
-};
-
-
-
-#define _SID(id) (_sensor_ids[id])
-#define _ACCU(accuracy) (_accu_table[accuracy + 1])
-
-static int _sensor_connect(sensor_h handle, sensor_type_e type)
-{
- int id = 0;
- bool support = true;
-
- RETURN_IF_NOT_TYPE(type);
-
- if(handle->ids[_SID(type)] < 0){
- sensor_is_supported(type, &support);
- if(!support)
- return SENSOR_ERROR_NOT_SUPPORTED;
-
- id = sf_connect(_TYPE[type]);
-
- DEBUG_PRINTF("%s sensor connect legacy=[%d] type=[%d]", TYPE_NAME(type), type, _TYPE[type]);
- if(id < 0){
- return id == -2 ? SENSOR_ERROR_IO_ERROR : SENSOR_ERROR_OPERATION_FAILED;
- }
- DEBUG_PRINTF("%s sensor id created [%d]", TYPE_NAME(type), id);
- handle->ids[_SID(type)] = id;
- }
- return SENSOR_ERROR_NONE;
-}
-
-static void _sensor_callback (unsigned int event_type, sensor_event_data_t* event, void* udata)
-{
- int i = 0;
- int data_num = 0;
- sensor_data_t *data = NULL;
- sensor_panning_data_t *panning_data = NULL;
- int motion = 0;
- int nid = 0;
-
- struct timeval sv;
- unsigned long long motion_time_stamp = 0;
-
- sensor_h sensor = (sensor_h)udata;
-
- switch(event_type)
- {
- case MOTION_ENGINE_EVENT_SNAP:
- nid = SENSOR_MOTION_SNAP;
- break;
- case MOTION_ENGINE_EVENT_SHAKE:
- nid = SENSOR_MOTION_SHAKE;
- break;
- case MOTION_ENGINE_EVENT_DOUBLETAP:
- nid = SENSOR_MOTION_DOUBLETAP;
- break;
- case MOTION_ENGINE_EVENT_PANNING:
- nid = SENSOR_MOTION_PANNING;
- break;
- case MOTION_ENGINE_EVENT_TILT:
- nid = SENSOR_MOTION_TILT;
- break;
- case MOTION_ENGINE_EVENT_PANNING_BROWSE:
- nid = SENSOR_MOTION_PANNING_BROWSE;
- break;
- case MOTION_ENGINE_EVENT_TOP_TO_BOTTOM:
- nid = SENSOR_MOTION_FACEDOWN;
- break;
- case MOTION_ENGINE_EVENT_DIRECT_CALL:
- nid = SENSOR_MOTION_DIRECTCALL;
- break;
- case MOTION_ENGINE_EVENT_SMART_ALERT:
- nid = SENSOR_MOTION_SMART_ALERT;
- break;
- case MOTION_ENGINE_EVENT_NO_MOVE:
- nid = SENSOR_MOTION_NO_MOVE;
- break;
- case ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME :
- nid = SENSOR_ACCELEROMETER;
- break;
- case ACCELEROMETER_EVENT_GRAVITY_DATA_REPORT_ON_TIME :
- nid = SENSOR_GRAVITY;
- break;
- case ACCELEROMETER_EVENT_LINEAR_ACCELERATION_DATA_REPORT_ON_TIME :
- nid = SENSOR_LINEAR_ACCELERATION;
- break;
- case ACCELEROMETER_EVENT_ORIENTATION_DATA_REPORT_ON_TIME :
- nid = SENSOR_DEVICE_ORIENTATION;
- break;
- case GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME :
- nid = SENSOR_MAGNETIC;
- break;
- case GEOMAGNETIC_EVENT_ATTITUDE_DATA_REPORT_ON_TIME :
- nid = SENSOR_ORIENTATION;
- break;
- case GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME :
- nid = SENSOR_GYROSCOPE;
- break;
- case LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME :
- nid = SENSOR_LIGHT;
- break;
- case PROXIMITY_EVENT_DISTANCE_DATA_REPORT_ON_TIME :
- nid = SENSOR_PROXIMITY;
- break;
- }
-
- if(sensor->cb_func[nid] == NULL || sensor->started[nid] == 0)
- return;
-
- switch(event_type)
- {
- case MOTION_ENGINE_EVENT_SNAP:
- case MOTION_ENGINE_EVENT_SHAKE:
- motion = *(int*)event->event_data;
- break;
- case MOTION_ENGINE_EVENT_PANNING:
- case MOTION_ENGINE_EVENT_TILT:
- case MOTION_ENGINE_EVENT_PANNING_BROWSE:
- panning_data = (sensor_panning_data_t *)event->event_data;
- break;
- case MOTION_ENGINE_EVENT_DOUBLETAP:
- motion = *(int*)event->event_data;
- if(motion != MOTION_ENGIEN_DOUBLTAP_DETECTION)
- return;
- break;
- case MOTION_ENGINE_EVENT_TOP_TO_BOTTOM:
- motion = *(int*)event->event_data;
- if(motion != MOTION_ENGIEN_TOP_TO_BOTTOM_DETECTION)
- return;
- break;
- case MOTION_ENGINE_EVENT_DIRECT_CALL:
- motion = *(int*)event->event_data;
- if(motion != MOTION_ENGINE_DIRECT_CALL_DETECTION)
- return;
- break;
- case MOTION_ENGINE_EVENT_SMART_ALERT:
- motion = *(int*)event->event_data;
- if(motion != MOTION_ENGINE_SMART_ALERT_DETECTION)
- return;
- break;
- case MOTION_ENGINE_EVENT_NO_MOVE:
- motion = *(int*)event->event_data;
- if(motion != MOTION_ENGINE_NO_MOVE_DETECTION)
- return;
- break;
- case ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME :
- case ACCELEROMETER_EVENT_GRAVITY_DATA_REPORT_ON_TIME :
- case ACCELEROMETER_EVENT_LINEAR_ACCELERATION_DATA_REPORT_ON_TIME :
- case ACCELEROMETER_EVENT_ORIENTATION_DATA_REPORT_ON_TIME :
- case GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME :
- case GEOMAGNETIC_EVENT_ATTITUDE_DATA_REPORT_ON_TIME :
- case GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME :
- case LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME :
- case PROXIMITY_EVENT_DISTANCE_DATA_REPORT_ON_TIME :
- data = (sensor_data_t*)(event->event_data);
- data_num = (event->event_data_size)/sizeof(sensor_data_t);
- break;
- /*
- case PROXIMITY_EVENT_CHANGE_STATE :
- proximity = *(int*)(event->event_data) == PROXIMITY_STATE_FAR ? 0 : 1;
- break;
- */
- default:
- DEBUG_PRINTF("unknown typed sensor happen!! event=%d\n", event_type);
- return;
-
- }
-
- switch(event_type)
- {
- case MOTION_ENGINE_EVENT_SNAP:
- gettimeofday(&sv, NULL);
- motion_time_stamp = MICROSECONDS(sv);
- ((sensor_motion_snap_event_cb)sensor->cb_func[nid])(motion_time_stamp, motion, sensor->cb_user_data[nid]);
- break;
- case MOTION_ENGINE_EVENT_SHAKE:
- gettimeofday(&sv, NULL);
- motion_time_stamp = MICROSECONDS(sv);
- ((sensor_motion_shake_event_cb)sensor->cb_func[nid])(motion_time_stamp,motion, sensor->cb_user_data[nid]);
- break;
- case MOTION_ENGINE_EVENT_DOUBLETAP:
- gettimeofday(&sv, NULL);
- motion_time_stamp = MICROSECONDS(sv);
- ((sensor_motion_doubletap_event_cb)sensor->cb_func[nid])(motion_time_stamp,sensor->cb_user_data[nid]);
- break;
- case MOTION_ENGINE_EVENT_TOP_TO_BOTTOM:
- gettimeofday(&sv, NULL);
- motion_time_stamp = MICROSECONDS(sv);
- ((sensor_motion_facedown_event_cb)sensor->cb_func[nid])(motion_time_stamp,sensor->cb_user_data[nid]);
- break;
- case MOTION_ENGINE_EVENT_PANNING:
- gettimeofday(&sv, NULL);
- motion_time_stamp = MICROSECONDS(sv);
- ((sensor_motion_panning_event_cb)sensor->cb_func[nid])(motion_time_stamp,panning_data->x, panning_data->y, sensor->cb_user_data[nid]);
- break;
- case MOTION_ENGINE_EVENT_TILT:
- gettimeofday(&sv, NULL);
- motion_time_stamp = MICROSECONDS(sv);
- ((sensor_motion_tilt_event_cb)sensor->cb_func[nid])(motion_time_stamp,panning_data->x, panning_data->y, sensor->cb_user_data[nid]);
- break;
- case MOTION_ENGINE_EVENT_PANNING_BROWSE:
- gettimeofday(&sv, NULL);
- motion_time_stamp = MICROSECONDS(sv);
- ((sensor_motion_panning_browse_event_cb)sensor->cb_func[nid])(motion_time_stamp,panning_data->x, panning_data->y, sensor->cb_user_data[nid]);
- break;
- case MOTION_ENGINE_EVENT_DIRECT_CALL:
- gettimeofday(&sv, NULL);
- motion_time_stamp = MICROSECONDS(sv);
- ((sensor_motion_directcall_event_cb)sensor->cb_func[nid])(motion_time_stamp,sensor->cb_user_data[nid]);
- break;
- case MOTION_ENGINE_EVENT_SMART_ALERT:
- gettimeofday(&sv, NULL);
- motion_time_stamp = MICROSECONDS(sv);
- ((sensor_motion_smart_alert_event_cb)sensor->cb_func[nid])(motion_time_stamp,sensor->cb_user_data[nid]);
- break;
- case MOTION_ENGINE_EVENT_NO_MOVE:
- gettimeofday(&sv, NULL);
- motion_time_stamp = MICROSECONDS(sv);
- ((sensor_motion_no_move_event_cb)sensor->cb_func[nid])(motion_time_stamp,sensor->cb_user_data[nid]);
- break;
- case ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME :
- for(i=0; i<data_num; i++){
- ((sensor_accelerometer_event_cb)sensor->cb_func[nid])
- (data[i].time_stamp, _ACCU(data[i].data_accuracy),
- data[i].values[0], data[i].values[1], data[i].values[2],
- sensor->cb_user_data[nid]);
- }
- break;
- case ACCELEROMETER_EVENT_GRAVITY_DATA_REPORT_ON_TIME :
- for(i=0; i<data_num; i++){
- ((sensor_gravity_event_cb)sensor->cb_func[nid])
- (data[i].time_stamp, _ACCU(data[i].data_accuracy),
- data[i].values[0], data[i].values[1], data[i].values[2],
- sensor->cb_user_data[nid]);
- }
- break;
- case ACCELEROMETER_EVENT_LINEAR_ACCELERATION_DATA_REPORT_ON_TIME :
- for(i=0; i<data_num; i++){
- ((sensor_linear_acceleration_event_cb)sensor->cb_func[nid])
- (data[i].time_stamp, _ACCU(data[i].data_accuracy),
- data[i].values[0], data[i].values[1], data[i].values[2],
- sensor->cb_user_data[nid]);
- }
- break;
- case ACCELEROMETER_EVENT_ORIENTATION_DATA_REPORT_ON_TIME :
- for(i=0; i<data_num; i++){
- ((sensor_device_orientation_event_cb)sensor->cb_func[nid])
- (data[i].time_stamp, _ACCU(data[i].data_accuracy),
- data[i].values[0], data[i].values[1], data[i].values[2],
- sensor->cb_user_data[nid]);
- }
- break;
- case GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME :
- for(i=0; i<data_num; i++){
- ((sensor_magnetic_event_cb)sensor->cb_func[nid])
- (data[i].time_stamp,_ACCU(data[i].data_accuracy),
- data[i].values[0], data[i].values[1], data[i].values[2],
- sensor->cb_user_data[nid]);
- }
- break;
- case GEOMAGNETIC_EVENT_ATTITUDE_DATA_REPORT_ON_TIME :
- for(i=0; i<data_num; i++){
- ((sensor_orientation_event_cb)sensor->cb_func[nid])
- (data[i].time_stamp,_ACCU(data[i].data_accuracy),
- data[i].values[0], data[i].values[1], data[i].values[2],
- sensor->cb_user_data[nid]);
- }
- break;
- case GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME :
- for(i=0; i<data_num; i++){
- ((sensor_gyroscope_event_cb)sensor->cb_func[nid])
- (data[i].time_stamp,_ACCU(data[i].data_accuracy),
- data[i].values[0], data[i].values[1], data[i].values[2],
- sensor->cb_user_data[nid]);
- }
- break;
- case LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME :
- for(i=0; i<data_num; i++){
- ((sensor_light_event_cb)sensor->cb_func[nid])
- (data[i].time_stamp,
- data[i].values[0],
- sensor->cb_user_data[nid]);
- }
- break;
- case PROXIMITY_EVENT_DISTANCE_DATA_REPORT_ON_TIME :
- for(i=0; i<data_num; i++){
- ((sensor_proximity_event_cb)sensor->cb_func[nid])
- (data[i].time_stamp,
- data[i].values[0],
- sensor->cb_user_data[nid]);
- }
- break;
- }
-}
-
-int sensor_is_supported(sensor_type_e type, bool* supported)
-{
- DEBUG_PRINT("sensor_is_support");
-
- RETURN_IF_NOT_TYPE(type);
-
- if(supported == NULL)
- RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
-
- *supported = !(sf_is_sensor_event_available(_TYPE[type], _EVENT[type]) < 0);
- DEBUG_PRINTF("%s sensor available function return [%d]", TYPE_NAME(type), *supported);
-
- return SENSOR_ERROR_NONE;
-}
-
-int sensor_get_spec(sensor_type_e type, char** vendor, char** model, float* max, float* min, float* resolution)
-{
- sensor_data_properties_t data_properties;
- sensor_properties_t properties;
-
- DEBUG_PRINT("sensor_get_spec");
-
- RETURN_IF_MOTION_TYPE(type);
-
- RETURN_IF_NOT_TYPE(type);
-
- if(sf_get_data_properties(_DTYPE[type], &data_properties) < 0)
- RETURN_ERROR(SENSOR_ERROR_NOT_SUPPORTED);
-
- if(sf_get_properties(_TYPE[type], &properties) < 0)
- RETURN_ERROR(SENSOR_ERROR_NOT_SUPPORTED);
-
- if(vendor != NULL)
- *vendor = strdup(properties.sensor_vendor);
- if(model != NULL)
- *model = strdup(properties.sensor_name);
- if(max != NULL)
- *max = data_properties.sensor_max_range;
- if(min != NULL)
- *min = data_properties.sensor_min_range;
- if(resolution != NULL)
- *resolution = data_properties.sensor_resolution;
-
- DEBUG_PRINTF("success get %s's format max=%f, min=%f, res=%f\n", TYPE_NAME(type), (max) ? *max : 0,(min) ? *min : 0, (resolution) ? *resolution : 0);
-
- return SENSOR_ERROR_NONE;
-}
-
-
-int sensor_create(sensor_h* handle)
-{
- struct sensor_handle_s* sensor = NULL;
-
- DEBUG_PRINT("sensor_create");
-
- if(handle == NULL)
- RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
-
- sensor = (struct sensor_handle_s*)malloc( sizeof(struct sensor_handle_s) );
- if(sensor==NULL)
- RETURN_ERROR(SENSOR_ERROR_OUT_OF_MEMORY);
- else
- {
- SENSOR_INIT(sensor);
-
- *handle = (sensor_h)sensor;
-
- return SENSOR_ERROR_NONE;
- }
-}
-
-int sensor_destroy(sensor_h handle)
-{
-
- int i=0;
- RETURN_IF_NOT_HANDLE(handle);
-
- DEBUG_PRINT("sensor_destroy");
-
- for(i=0; i<ID_NUMBERS; i++){
- if( handle->ids[i] >= 0 ){
- if(sf_disconnect(handle->ids[i]) >= 0){
- handle->ids[i] = -1;
- }
- }
- }
-
- free(handle);
- handle = NULL;
-
- return SENSOR_ERROR_NONE;
-}
-
-int sensor_start(sensor_h handle, sensor_type_e type)
-{
- int err;
- DEBUG_PRINT("sensor_start");
- RETURN_IF_NOT_HANDLE(handle);
- RETURN_IF_NOT_TYPE(type);
-
- if( (err = _sensor_connect(handle, type)) != SENSOR_ERROR_NONE){
- return err;
- }
-
- if (sf_start(handle->ids[_SID(type)], handle->sensor_option[type]) < 0) {
- RETURN_ERROR(SENSOR_ERROR_IO_ERROR);
- } else {
- handle->started[type] = 1;
- return SENSOR_ERROR_NONE;
- }
-}
-
-int sensor_stop(sensor_h handle, sensor_type_e type)
-{
- DEBUG_PRINT("sensor_stop");
- RETURN_IF_NOT_HANDLE(handle);
- RETURN_IF_NOT_TYPE(type);
- if (sf_stop(handle->ids[_SID(type)]) < 0) {
- RETURN_ERROR(SENSOR_ERROR_IO_ERROR);
- } else {
- handle->started[type] = 0;
- return SENSOR_ERROR_NONE;
- }
-}
-
-static void _sensor_calibration (unsigned int event_type, sensor_event_data_t* event, void* udata)
-{
- sensor_h sensor = (sensor_h)udata;
-
- switch (event_type) {
- case ACCELEROMETER_EVENT_CALIBRATION_NEEDED:
- if(sensor->calib_func[SENSOR_ACCELEROMETER] != NULL){
- ((sensor_calibration_cb)sensor->calib_func[SENSOR_ACCELEROMETER])(sensor->calib_user_data[SENSOR_ACCELEROMETER]);
- }
- break;
- case GEOMAGNETIC_EVENT_CALIBRATION_NEEDED:
- if(sensor->calib_func[SENSOR_MAGNETIC] != NULL){
- ((sensor_calibration_cb)sensor->calib_func[SENSOR_MAGNETIC])(sensor->calib_user_data[SENSOR_MAGNETIC]);
- }
- if(sensor->calib_func[SENSOR_ORIENTATION] != NULL){
- ((sensor_calibration_cb)sensor->calib_func[SENSOR_ORIENTATION])(sensor->calib_user_data[SENSOR_ORIENTATION]);
- }
- break;
- default:
- DEBUG_PRINTF("not calibration event happened in calibration callback!! event=%d", event_type);
- return;
- }
-}
-
-static int _sensor_set_calibration_cb(sensor_h handle, sensor_type_e type, sensor_calibration_cb callback, void *user_data)
-{
- int ret, err;
-
- DEBUG_PRINTF("%s sensor register calibration callback", TYPE_NAME(type));
-
- RETURN_IF_NOT_HANDLE(handle);
- switch(type){
- case SENSOR_ACCELEROMETER:
- case SENSOR_GRAVITY:
- case SENSOR_LINEAR_ACCELERATION:
- case SENSOR_DEVICE_ORIENTATION:
- case SENSOR_MAGNETIC:
- case SENSOR_ORIENTATION:
- break;
- default:
- RETURN_ERROR(SENSOR_ERROR_NOT_NEED_CALIBRATION);
- }
-
- ret = sf_is_sensor_event_available( _TYPE[type], _CALIBRATION[type] );
- if (ret != 0 ){
- DEBUG_PRINTF("Unsupported calibration ret=[%d] error=[%d] legacy=[%d] type=[%d] cal_id=[%d]", ret, SENSOR_ERROR_NOT_NEED_CALIBRATION, type, _TYPE[type], _CALIBRATION[type]);
- RETURN_ERROR(SENSOR_ERROR_NOT_NEED_CALIBRATION);
- }
-
- if( (err = _sensor_connect(handle, type)) != SENSOR_ERROR_NONE){
- return err;
- }
-
- handle->calib_func[type] = callback;
- handle->calib_user_data[type] = user_data;
-
- DEBUG_PRINTF("type : %s / id : %d / event : %x ", TYPE_NAME(type), handle->ids[_SID(type)], _CALIBRATION[type]);
-
- ret = sf_register_event(handle->ids[_SID(type)], _CALIBRATION[type], NULL, _sensor_calibration, handle);
- if(ret < 0){
- handle->calib_func[type] = NULL;
- handle->calib_user_data[type] = NULL;
- if(ret == -2)
- RETURN_ERROR(SENSOR_ERROR_IO_ERROR);
- else
- RETURN_ERROR(SENSOR_ERROR_OPERATION_FAILED);
- }
-
- return SENSOR_ERROR_NONE;
-}
-
-static int _sensor_unset_calibration_cb(sensor_h handle, sensor_type_e type)
-{
- int ret;
-
- DEBUG_PRINTF("%s sensor register calibration callback", TYPE_NAME(type));
-
- RETURN_IF_NOT_HANDLE(handle);
- switch (type) {
- case SENSOR_ACCELEROMETER:
- case SENSOR_GRAVITY:
- case SENSOR_LINEAR_ACCELERATION:
- case SENSOR_DEVICE_ORIENTATION:
- case SENSOR_MAGNETIC:
- case SENSOR_ORIENTATION:
- break;
- default:
- RETURN_ERROR(SENSOR_ERROR_NOT_NEED_CALIBRATION);
- }
-
- if(handle->calib_func[type] == NULL)
- return SENSOR_ERROR_NONE;
-
- ret = sf_unregister_event(handle->ids[_SID(type)], _CALIBRATION[type]);
-
- if (ret < 0){
- if(ret == -2)
- RETURN_ERROR(SENSOR_ERROR_IO_ERROR);
- else
- RETURN_ERROR(SENSOR_ERROR_OPERATION_FAILED);
- }
-
- handle->calib_func[type] = NULL;
- handle->calib_user_data[type] = NULL;
-
- return SENSOR_ERROR_NONE;
-}
-
-static void _sensor_wakeup (unsigned int event_type, sensor_event_data_t* event, void* udata)
-{
- sensor_h sensor = (sensor_h)udata;
-
- switch (event_type) {
- case ACCELEROMETER_EVENT_SET_WAKEUP:
- if(sensor->wakeup_func[SENSOR_ACCELEROMETER] != NULL){
- ((sensor_awake_cb)sensor->wakeup_func[SENSOR_ACCELEROMETER])(sensor->wakeup_user_data[SENSOR_ACCELEROMETER]);
- }
- break;
- default:
- DEBUG_PRINTF("not wakeup event happened in wakeup callback!! event=%d", event_type);
- return;
- }
-}
-
-static int _sensor_set_wakeup_cb(sensor_h handle, sensor_type_e type, sensor_awake_cb callback, void *user_data)
-{
- int ret, err;
-
- DEBUG_PRINTF("%s sensor register wakeup callback", TYPE_NAME(type));
-
- RETURN_IF_NOT_HANDLE(handle);
- RETURN_IF_NOT_WAKEUP_TYPE(type);
-
- ret = sf_is_sensor_event_available( _TYPE[type], _WAKEUP[type] );
- if (ret != 0 ){
- DEBUG_PRINTF("Unsupported wakeup ret=[%d] error=[%d] legacy=[%d] type=[%d] wakeup_id=[%d]", ret, SENSOR_ERROR_NOT_SUPPORTED, type, _TYPE[type], _WAKEUP[type]);
- RETURN_ERROR(SENSOR_ERROR_NOT_SUPPORTED);
- }
-
- if( (err = _sensor_connect(handle, type)) != SENSOR_ERROR_NONE){
- return err;
- }
-
- handle->wakeup_func[type] = callback;
- handle->wakeup_user_data[type] = user_data;
-
- DEBUG_PRINTF("type : %s / id : %d / event : %x ", TYPE_NAME(type), handle->ids[_SID(type)], _WAKEUP[type]);
-
- ret = sf_register_event(handle->ids[_SID(type)], _WAKEUP[type], NULL, _sensor_wakeup, handle);
- if(ret < 0){
- handle->wakeup_func[type] = NULL;
- handle->wakeup_user_data[type] = NULL;
- if(ret == -2)
- RETURN_ERROR(SENSOR_ERROR_IO_ERROR);
- else
- RETURN_ERROR(SENSOR_ERROR_OPERATION_FAILED);
- }
-
- return SENSOR_ERROR_NONE;
-}
-
-
-static int _sensor_unset_wakeup_cb(sensor_h handle, sensor_type_e type)
-{
- int ret;
-
- DEBUG_PRINTF("%s sensor unregister wakeup callback", TYPE_NAME(type));
-
- RETURN_IF_NOT_HANDLE(handle);
- RETURN_IF_NOT_WAKEUP_TYPE(type);
-
- if(handle->wakeup_func[type] == NULL)
- return SENSOR_ERROR_NONE;
-
- ret = sf_unregister_event(handle->ids[_SID(type)], _WAKEUP[type]);
-
- if (ret < 0){
- if(ret == -2)
- RETURN_ERROR(SENSOR_ERROR_IO_ERROR);
- else
- RETURN_ERROR(SENSOR_ERROR_OPERATION_FAILED);
- }
-
- handle->wakeup_func[type] = NULL;
- handle->wakeup_user_data[type] = NULL;
-
- return SENSOR_ERROR_NONE;
-}
-
-
-static int _sensor_change_data_cb (sensor_h handle, sensor_type_e type, int rate)
-{
- int err = 0;
- event_condition_t condition;
-
- RETURN_IF_NOT_HANDLE(handle);
- RETURN_IF_NOT_TYPE(type);
-
- DEBUG_PRINTF("sensor change condition %s", TYPE_NAME(type));
-
- if(rate < 0){
- RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
- }
-
- if(rate > 0){
- condition.cond_op = CONDITION_EQUAL;
- condition.cond_value1 = rate;
- }
-
- err = sf_change_event_condition(handle->ids[_SID(type)], _EVENT[type], (rate > 0 ? &condition : NULL));
-
- DEBUG_PRINTF("%s sensor change condition function return [%d] event=[%d]", TYPE_NAME(type), err, _EVENT[type]);
-
- if(err < 0){
- if(err == -2)
- RETURN_ERROR(SENSOR_ERROR_IO_ERROR);
- else
- RETURN_ERROR(SENSOR_ERROR_OPERATION_FAILED);
- }
-
- return SENSOR_ERROR_NONE;
-}
-
-static int _sensor_set_data_cb (sensor_h handle, sensor_type_e type, int rate, void* cb, void* user_data)
-{
- int err = 0;
- event_condition_t condition;
-
- RETURN_IF_NOT_HANDLE(handle);
- RETURN_IF_NOT_TYPE(type);
-
- DEBUG_PRINTF("sensor register callback %s", TYPE_NAME(type));
-
- if(rate < 0){
- RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
- }
-
- if(rate > 0){
- condition.cond_op = CONDITION_EQUAL;
- condition.cond_value1 = rate;
- }
-
- handle->cb_func[type] = cb;
- handle->cb_user_data[type] = user_data;
-
- if( (err = _sensor_connect(handle, type)) != SENSOR_ERROR_NONE){
- DEBUG_PRINTF("%s sensor connect error handle=[%d] legacy=[%d] err=[%d]", TYPE_NAME(type), handle, type, err);
- return err;
- }
-
- err = sf_register_event(handle->ids[_SID(type)], _EVENT[type],
- (rate > 0 ? &condition : NULL), _sensor_callback, handle);
-
- DEBUG_PRINTF("%s sensor register function return [%d] event=[%x]", TYPE_NAME(type), err, _EVENT[type]);
-
- if(err < 0){
- handle->cb_func[type] = NULL;
- handle->cb_user_data[type] = NULL;
- if(err == -2)
- RETURN_ERROR(SENSOR_ERROR_IO_ERROR);
- else
- RETURN_ERROR(SENSOR_ERROR_OPERATION_FAILED);
- }
-
- return SENSOR_ERROR_NONE;
-}
-
-static int _sensor_unset_data_cb (sensor_h handle, sensor_type_e type)
-{
- int error;
- DEBUG_PRINTF("sensor unregister callback %s", TYPE_NAME(type));
- RETURN_IF_NOT_HANDLE(handle);
- if (handle->ids[_SID(type)] < 0 )
- return SENSOR_ERROR_INVALID_PARAMETER;
-
- error = sf_unregister_event(handle->ids[_SID(type)], _EVENT[type]);
-
- if (error < 0){
- if(error == -2)
- RETURN_ERROR(SENSOR_ERROR_IO_ERROR);
- else
- RETURN_ERROR(SENSOR_ERROR_OPERATION_FAILED);
- }
-
- handle->cb_func[type] = NULL;
- handle->cb_user_data[type] = NULL;
- return SENSOR_ERROR_NONE;
-}
-
-int sensor_accelerometer_set_cb(sensor_h handle, int rate, sensor_accelerometer_event_cb callback, void *user_data)
-{
- return _sensor_set_data_cb(handle, SENSOR_ACCELEROMETER, rate, (void*) callback, user_data);
-}
-
-int sensor_accelerometer_unset_cb(sensor_h handle)
-{
- return _sensor_unset_data_cb(handle, SENSOR_ACCELEROMETER);
-}
-
-int sensor_gravity_set_cb(sensor_h handle, int rate, sensor_gravity_event_cb callback, void* user_data)
-{
- return _sensor_set_data_cb(handle, SENSOR_GRAVITY, rate, (void*) callback, user_data);
-}
-
-int sensor_gravity_unset_cb(sensor_h handle)
-{
- return _sensor_unset_data_cb(handle, SENSOR_GRAVITY);
-}
-
-int sensor_linear_acceleration_set_cb(sensor_h handle, int rate, sensor_linear_acceleration_event_cb callback, void* user_data)
-{
- return _sensor_set_data_cb(handle, SENSOR_LINEAR_ACCELERATION, rate, (void*) callback, user_data);
-}
-
-int sensor_linear_acceleration_unset_cb(sensor_h handle)
-{
- return _sensor_unset_data_cb(handle, SENSOR_LINEAR_ACCELERATION);
-}
-
-int sensor_device_orientation_set_cb(sensor_h handle, int rate, sensor_device_orientation_event_cb callback, void* user_data)
-{
- return _sensor_set_data_cb(handle, SENSOR_DEVICE_ORIENTATION, rate, (void*) callback, user_data);
-}
-
-int sensor_device_orientation_unset_cb(sensor_h handle)
-{
- return _sensor_unset_data_cb(handle, SENSOR_DEVICE_ORIENTATION);
-}
-
-int sensor_magnetic_set_cb(sensor_h handle, int rate, sensor_magnetic_event_cb callback, void *user_data)
-{
- return _sensor_set_data_cb(handle, SENSOR_MAGNETIC, rate, (void*) callback, user_data);
-}
-
-int sensor_magnetic_unset_cb(sensor_h handle)
-{
- return _sensor_unset_data_cb(handle, SENSOR_MAGNETIC);
-}
-
-int sensor_magnetic_set_calibration_cb(sensor_h handle, sensor_calibration_cb callback, void *user_data)
-{
- return _sensor_set_calibration_cb(handle, SENSOR_MAGNETIC, callback, user_data);
-}
-int sensor_magnetic_unset_calibration_cb(sensor_h handle)
-{
- return _sensor_unset_calibration_cb(handle, SENSOR_MAGNETIC);
-}
-
-int sensor_orientation_set_cb(sensor_h handle, int rate, sensor_orientation_event_cb callback, void *user_data)
-{
- return _sensor_set_data_cb(handle, SENSOR_ORIENTATION, rate, (void*) callback, user_data);
-}
-
-int sensor_orientation_unset_cb(sensor_h handle)
-{
- return _sensor_unset_data_cb(handle, SENSOR_ORIENTATION);
-}
-int sensor_orientation_set_calibration_cb(sensor_h handle, sensor_calibration_cb callback, void *user_data)
-{
- return _sensor_set_calibration_cb(handle, SENSOR_ORIENTATION, callback, user_data);
-}
-int sensor_orientation_unset_calibration_cb(sensor_h handle)
-{
- return _sensor_unset_calibration_cb(handle, SENSOR_ORIENTATION);
-}
-
-int sensor_gyroscope_set_cb(sensor_h handle, int rate, sensor_gyroscope_event_cb callback, void *user_data)
-{
- return _sensor_set_data_cb(handle, SENSOR_GYROSCOPE, rate, (void*) callback, user_data);
-}
-
-int sensor_gyroscope_unset_cb(sensor_h handle)
-{
- return _sensor_unset_data_cb(handle, SENSOR_GYROSCOPE);
-}
-
-int sensor_light_set_cb(sensor_h handle, int rate, sensor_light_event_cb callback, void *user_data)
-{
- return _sensor_set_data_cb(handle, SENSOR_LIGHT, rate, (void*) callback, user_data);
-}
-
-int sensor_light_unset_cb(sensor_h handle)
-{
- return _sensor_unset_data_cb(handle, SENSOR_LIGHT);
-}
-
-int sensor_proximity_set_cb(sensor_h handle, int interval_ms, sensor_proximity_event_cb callback, void *user_data)
-{
- return _sensor_set_data_cb(handle, SENSOR_PROXIMITY, interval_ms, (void*) callback, user_data);
-}
-
-int sensor_proximity_unset_cb(sensor_h handle)
-{
- return _sensor_unset_data_cb(handle, SENSOR_PROXIMITY);
-}
-
-static int _sensor_read_data(sensor_h handle, sensor_type_e type,
- sensor_data_accuracy_e* accuracy, float* values, int values_size)
-{
- int err = 0;
- sensor_data_t data;
-
- RETURN_IF_NOT_HANDLE(handle);
- RETURN_IF_MOTION_TYPE(type);
- RETURN_IF_NOT_TYPE(type);
-
- DEBUG_PRINTF("sensor read data %s", TYPE_NAME(type));
-
- if( (err = _sensor_connect(handle, type)) != SENSOR_ERROR_NONE)
- return err;
- if ( sf_get_data(handle->ids[_SID(type)], _DTYPE[type], &data) < 0 )
- {
- RETURN_ERROR(SENSOR_ERROR_IO_ERROR);
- }
-
- // this error will never happen. but it exist for more safe code..
- if(values_size > 12 || values_size < 0)
- RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
-
- if(accuracy != NULL)
- *accuracy = _ACCU(data.data_accuracy);
- memcpy(values, data.values, values_size * sizeof(float));
-
- return SENSOR_ERROR_NONE;
-}
-
-int sensor_accelerometer_read_data (sensor_h handle,
- sensor_data_accuracy_e* accuracy, float* x, float* y, float* z)
-{
- float values[3] = {0,0,0};
- int err = _sensor_read_data(handle, SENSOR_ACCELEROMETER, accuracy, values, 3);
- if(err < 0) return err;
-
- if(x == NULL || y == NULL || z == NULL)
- RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
-
- *x = values[0];
- *y = values[1];
- *z = values[2];
-
- return SENSOR_ERROR_NONE;
-}
-
-int sensor_gravity_read_data (sensor_h handle,
- sensor_data_accuracy_e* accuracy, float* x, float* y, float* z)
-{
- float values[3] = {0,0,0};
- int err = _sensor_read_data(handle, SENSOR_GRAVITY, accuracy, values, 3);
- if(err < 0) return err;
-
- if(x == NULL || y == NULL || z == NULL)
- RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
-
- *x = values[0];
- *y = values[1];
- *z = values[2];
-
- return SENSOR_ERROR_NONE;
-}
-
-int sensor_linear_acceleration_read_data (sensor_h handle,
- sensor_data_accuracy_e* accuracy, float* x, float* y, float* z)
-{
- float values[3] = {0,0,0};
- int err = _sensor_read_data(handle, SENSOR_LINEAR_ACCELERATION, accuracy, values, 3);
- if(err < 0) return err;
-
- if(x == NULL || y == NULL || z == NULL)
- RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
-
- *x = values[0];
- *y = values[1];
- *z = values[2];
-
- return SENSOR_ERROR_NONE;
-}
-
-int sensor_device_orientation_read_data (sensor_h handle,
- sensor_data_accuracy_e* accuracy, float* yaw, float* pitch, float* roll)
-{
- float values[3] = {0,0,0};
- int err = _sensor_read_data(handle, SENSOR_DEVICE_ORIENTATION, accuracy, values, 3);
- if(err < 0) return err;
-
- if(yaw == NULL || pitch == NULL || roll == NULL)
- RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
-
- *yaw = values[0];
- *pitch = values[1];
- *roll = values[2];
-
- return SENSOR_ERROR_NONE;
-}
-
-int sensor_magnetic_read_data (sensor_h handle, sensor_data_accuracy_e* accuracy, float* x, float* y, float* z)
-{
- float values[3] = {0,0,0};
- int err = _sensor_read_data(handle, SENSOR_MAGNETIC, accuracy, values, 3);
- if(err < 0) return err;
-
- if(x == NULL || y == NULL || z == NULL)
- RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
-
- *x = values[0];
- *y = values[1];
- *z = values[2];
-
- return SENSOR_ERROR_NONE;
-}
-
-int sensor_orientation_read_data (sensor_h handle, sensor_data_accuracy_e* accuracy, float* azimuth, float* pitch, float* roll)
-{
- float values[3] = {0,0,0};
- int err = _sensor_read_data(handle, SENSOR_ORIENTATION, accuracy, values, 3);
- if(err < 0) return err;
-
- if(azimuth == NULL || pitch == NULL || roll == NULL)
- RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
-
- *azimuth = values[0];
- *pitch = values[1];
- *roll = values[2];
-
- return SENSOR_ERROR_NONE;
-}
-
-int sensor_gyroscope_read_data (sensor_h handle, sensor_data_accuracy_e* accuracy, float* x, float* y, float* z)
-{
- float values[3] = {0,0,0};
- int err = _sensor_read_data(handle, SENSOR_GYROSCOPE, accuracy, values, 3);
- if(err < 0) return err;
-
- if(x == NULL || y == NULL || z == NULL)
- RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
-
- *x = values[0];
- *y = values[1];
- *z = values[2];
-
- return SENSOR_ERROR_NONE;
-}
-
-int sensor_light_read_data (sensor_h handle, float* lux)
-{
- float values[1] = {0};
- int err = _sensor_read_data(handle, SENSOR_LIGHT, NULL, values, 1);
- if(err < 0) return err;
-
- if(lux == NULL)
- RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
-
- *lux = values[0];
-
- return SENSOR_ERROR_NONE;
-}
-
-int sensor_proximity_read_data (sensor_h handle, float* distance)
-{
- float values[1] = {0};
- int err = _sensor_read_data(handle, SENSOR_PROXIMITY, NULL, values, 1);
- if(err < 0) return err;
-
- if(distance == NULL)
- RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
-
- *distance = values[0];
-
- return SENSOR_ERROR_NONE;
-}
-
-
-int sensor_motion_snap_set_cb (sensor_h handle, sensor_motion_snap_event_cb callback, void *user_data)
-{
- return _sensor_set_data_cb(handle, SENSOR_MOTION_SNAP, 0, (void*) callback, user_data);
-}
-
-int sensor_motion_snap_unset_cb (sensor_h handle)
-{
- return _sensor_unset_data_cb(handle, SENSOR_MOTION_SNAP);
-}
-
-int sensor_motion_shake_set_cb (sensor_h handle, sensor_motion_shake_event_cb callback, void *user_data)
-{
- return _sensor_set_data_cb(handle, SENSOR_MOTION_SHAKE, 0, (void*) callback, user_data);
-}
-
-int sensor_motion_shake_unset_cb (sensor_h handle)
-{
- return _sensor_unset_data_cb(handle, SENSOR_MOTION_SHAKE);
-}
-
-int sensor_motion_doubletap_set_cb (sensor_h handle, sensor_motion_doubletap_event_cb callback, void *user_data)
-{
- return _sensor_set_data_cb(handle, SENSOR_MOTION_DOUBLETAP, 0, (void*) callback, user_data);
-}
-
-int sensor_motion_doubletap_unset_cb (sensor_h handle)
-{
- return _sensor_unset_data_cb(handle, SENSOR_MOTION_DOUBLETAP);
-}
-
-int sensor_motion_panning_set_cb (sensor_h handle, sensor_motion_panning_event_cb callback, void *user_data)
-{
- return _sensor_set_data_cb(handle, SENSOR_MOTION_PANNING, 0, (void*) callback, user_data);
-}
-
-int sensor_motion_panning_unset_cb (sensor_h handle)
-{
- return _sensor_unset_data_cb(handle, SENSOR_MOTION_PANNING);
-}
-
-int sensor_motion_tilt_set_cb (sensor_h handle, sensor_motion_tilt_event_cb callback, void *user_data)
-{
- return _sensor_set_data_cb(handle, SENSOR_MOTION_TILT, 0, (void*) callback, user_data);
-}
-
-int sensor_motion_tilt_unset_cb (sensor_h handle)
-{
- return _sensor_unset_data_cb(handle, SENSOR_MOTION_TILT);
-}
-int sensor_motion_panning_browse_set_cb (sensor_h handle, sensor_motion_panning_browse_event_cb callback, void *user_data)
-{
- return _sensor_set_data_cb(handle, SENSOR_MOTION_PANNING_BROWSE, 0, (void*) callback, user_data);
-}
-
-int sensor_motion_panning_browse_unset_cb (sensor_h handle)
-{
- return _sensor_unset_data_cb(handle, SENSOR_MOTION_PANNING_BROWSE);
-}
-
-int sensor_motion_facedown_set_cb (sensor_h handle, sensor_motion_facedown_event_cb callback, void *user_data)
-{
- return _sensor_set_data_cb(handle, SENSOR_MOTION_FACEDOWN, 0, (void*) callback, user_data);
-}
-
-int sensor_motion_facedown_unset_cb (sensor_h handle)
-{
- return _sensor_unset_data_cb(handle, SENSOR_MOTION_FACEDOWN);
-}
-
-int sensor_motion_directcall_set_cb (sensor_h handle, sensor_motion_directcall_event_cb callback, void *user_data)
-{
- return _sensor_set_data_cb(handle, SENSOR_MOTION_DIRECTCALL, 0, (void*) callback, user_data);
-}
-
-int sensor_motion_directcall_unset_cb (sensor_h handle)
-{
- return _sensor_unset_data_cb(handle, SENSOR_MOTION_DIRECTCALL);
-}
-
-int sensor_motion_smart_alert_set_cb (sensor_h handle, sensor_motion_smart_alert_event_cb callback, void *user_data)
-{
- return _sensor_set_data_cb(handle, SENSOR_MOTION_SMART_ALERT, 0, (void*) callback, user_data);
-}
-
-int sensor_motion_smart_alert_unset_cb (sensor_h handle)
-{
- return _sensor_unset_data_cb(handle, SENSOR_MOTION_SMART_ALERT);
-}
-
-int sensor_motion_no_move_set_cb (sensor_h handle, sensor_motion_no_move_event_cb callback, void *user_data)
-{
- return _sensor_set_data_cb(handle, SENSOR_MOTION_NO_MOVE, 0, (void*) callback, user_data);
-}
-
-int sensor_motion_no_move_unset_cb (sensor_h handle)
-{
- return _sensor_unset_data_cb(handle, SENSOR_MOTION_NO_MOVE);
-}
-
-int sensor_awake_unset_cb(sensor_h handle, sensor_type_e type)
-{
- return _sensor_unset_wakeup_cb(handle, type);
-}
-
-int sensor_awake_set_cb(sensor_h handle, sensor_type_e type, sensor_awake_cb callback, void* user_data)
-{
- return _sensor_set_wakeup_cb(handle, type, callback, user_data);
-}
-
-int sensor_awake_is_enabled(sensor_h handle, sensor_type_e type, bool *enable)
-{
- RETURN_IF_NOT_TYPE(type);
- RETURN_IF_NOT_WAKEUP_TYPE(type);
- *enable = (handle->wakeup_func[type] != NULL) ? true : false;
-
- return SENSOR_ERROR_NONE;
-}
-
-int sensor_awake_is_supported(sensor_type_e type, bool *supported)
-{
- DEBUG_PRINT("sensor_is_support");
-
- RETURN_IF_NOT_TYPE(type);
- RETURN_IF_NOT_WAKEUP_TYPE(type);
-
- if(supported == NULL)
- RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
-
- *supported = !(sf_is_sensor_event_available(_TYPE[type], _WAKEUP[type]) < 0);
- DEBUG_PRINTF("%s sensor available function return [%d]", TYPE_NAME(type), *supported);
-
- return SENSOR_ERROR_NONE;
-}
-
-int sensor_get_delay_boundary(sensor_type_e type, int *min, int *max)
-{
- RETURN_ERROR(SENSOR_ERROR_NOT_SUPPORTED);
-}
-
-int sensor_util_get_declination(float latitude, float longitude, float altitude, float *declination)
-{
- if(declination == NULL)
- RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
-
- setCoordinate(latitude, longitude, altitude, declination, NULL, 1);
-
- return SENSOR_ERROR_NONE;
-}
-
-int sensor_util_get_angle_change(float R[], float prevR[], float angleChange[])
-{
- if(-1 == getAngleChange(R, prevR, angleChange))
- RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
-
- return SENSOR_ERROR_NONE;
-}
-
-int sensor_util_get_orientation(float R[], float values[])
-{
- if(R == NULL || values == NULL)
- RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
-
- values[0] = (float)atan2(R[1], R[4]);
- values[1] = (float)asin(-R[7]);
- values[2] = (float)atan2(-R[6], R[8]);
-
- return SENSOR_ERROR_NONE;
-
-}
-
-int sensor_util_get_inclination(float I[], float* inclination)
-{
- if(I == NULL || inclination == NULL)
- RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
-
- *inclination = atan2(I[5], I[4]);
-
- RETURN_ERROR(SENSOR_ERROR_NOT_SUPPORTED);
-}
-
-int sensor_util_remap_coordinate_system(float inR[], sensor_util_axis_e x, sensor_util_axis_e y, float outR[])
-{
- if(-1 == remapCoordinateSystem(inR, x, y, outR))
- RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
-
- return SENSOR_ERROR_NONE;
-}
-
-int sensor_util_get_rotation_matrix_from_vector(float Vx, float Vy, float Vz, float R[])
-{
- float RV[4] = {0, Vx, Vy, Vz};
-
- RV[0] = 1 - Vx * Vx - Vy*Vy - Vz*Vz;
- RV[0] = (Vx > 0) ? (float)(sqrt(Vx)) : 0;
-
- if( -1 == quatToMatrix(RV, R))
- RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
-
- return SENSOR_ERROR_NONE;
-}
-
-int sensor_util_get_rotation_matrix(float Gx, float Gy, float Gz,float Mx, float My, float Mz,float R[], float I[])
-{
- float G[3] = {Gx, Gy, Gz};
- float M[3] = {Mx, My, Mz};
-
- if(-1 == getRotationMatrix(G, M, R, I))
- RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
-
- return SENSOR_ERROR_NONE;
-}
-
-
-int sensor_accelerometer_set_interval(sensor_h sensor, int interval_ms)
-{
- return _sensor_change_data_cb(sensor, SENSOR_ACCELEROMETER, interval_ms);
-}
-
-int sensor_gravity_set_interval(sensor_h sensor, int interval_ms)
-{
- return _sensor_change_data_cb(sensor, SENSOR_ACCELEROMETER, interval_ms);
-}
-
-int sensor_linear_acceleration_set_interval(sensor_h sensor, int interval_ms)
-{
- return _sensor_change_data_cb(sensor, SENSOR_LINEAR_ACCELERATION, interval_ms);
-}
-
-int sensor_device_orientation_set_interval(sensor_h sensor, int interval_ms)
-{
- return _sensor_change_data_cb(sensor, SENSOR_DEVICE_ORIENTATION, interval_ms);
-}
-
-int sensor_gyroscope_set_interval(sensor_h sensor, int interval_ms)
-{
- return _sensor_change_data_cb(sensor, SENSOR_GYROSCOPE, interval_ms);
-}
-
-int sensor_light_set_interval(sensor_h sensor, int interval_ms)
-{
- return _sensor_change_data_cb(sensor, SENSOR_LIGHT, interval_ms);
-}
-
-int sensor_magnetic_set_interval(sensor_h sensor, int interval_ms)
-{
- return _sensor_change_data_cb(sensor, SENSOR_MAGNETIC, interval_ms);
-}
-
-int sensor_orientation_set_interval(sensor_h sensor, int interval_ms)
-{
- return _sensor_change_data_cb(sensor, SENSOR_ORIENTATION, interval_ms);
-}
-
-int sensor_proximity_set_interval(sensor_h sensor, int interval_ms)
-{
- return _sensor_change_data_cb(sensor, SENSOR_PROXIMITY, interval_ms);
-}
-
-int sensor_set_always_on(sensor_h handle, sensor_type_e type)
-{
- RETURN_IF_NOT_HANDLE(handle);
- RETURN_IF_MOTION_TYPE(type);
- RETURN_IF_NOT_TYPE(type);
-
- if(-1 == sf_change_sensor_option(handle->ids[_SID(type)], 1))
- RETURN_ERROR(SENSOR_ERROR_IO_ERROR);
-
- return SENSOR_ERROR_NONE;
-}
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/time.h>
+
+#include <sensor_internal.h>
+#include <sensors.h>
+#include <sensor_private.h>
+#include <libgen.h>
+#include <memory>
+#include <sensor_log.h>
+
+#define RETURN_VAL_IF(expr, err) \
+ do { \
+ if (expr) { \
+ _E_MSG(err); \
+ return (err); \
+ } \
+ } while (0)
+
+#define RETURN_ERROR(err) \
+ do { \
+ _E_MSG(err); \
+ return (err); \
+ } while (0)
+
+#define SENSOR_SHIFT_TYPE 16
+#define SENSOR_UNDEFINED_ID -1
+
+#define SENSOR_LISTENER_MAGIC 0xCAFECAFE
+
+sensor_type_t _TYPE[] = {
+ ACCELEROMETER_SENSOR,
+ GRAVITY_SENSOR,
+ LINEAR_ACCEL_SENSOR,
+ GEOMAGNETIC_SENSOR,
+ ROTATION_VECTOR_SENSOR,
+ ORIENTATION_SENSOR,
+ GYROSCOPE_SENSOR,
+ LIGHT_SENSOR,
+ PROXIMITY_SENSOR,
+ PRESSURE_SENSOR,
+ ULTRAVIOLET_SENSOR,
+ TEMPERATURE_SENSOR,
+ HUMIDITY_SENSOR,
+};
+
+static int sensor_connect (sensor_h sensor, sensor_listener_h listener)
+{
+ int id = SENSOR_UNDEFINED_ID;
+ int event_type;
+ sensor_type_t type;
+ bool support = false;
+
+ if (!listener)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ _D("called sensor_connect : listener[0x%x], sensor[0x%x]", listener, sensor);
+
+ sensord_get_type(sensor, &type);
+ event_type = type << SENSOR_SHIFT_TYPE | 0x1;
+
+ if (!sensord_is_supported_event_type(sensor, event_type, &support))
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ if (!support)
+ return SENSOR_ERROR_NOT_SUPPORTED;
+
+ id = sensord_connect(sensor);
+
+ if (id < 0)
+ return SENSOR_ERROR_OPERATION_FAILED;
+
+ _D("success sensor_connect: id[%d]", id);
+
+ listener->id = id;
+ listener->type = type;
+
+ return id;
+}
+
+static sensor_type_t _sensor_type_to_internal_type(sensor_type_e type)
+{
+ return (type == SENSOR_ALL) ? ALL_SENSOR : _TYPE[type];
+}
+
+int sensor_is_supported(sensor_type_e type, bool *supported)
+{
+ sensor_t sensor;
+ bool _supported;
+ sensor_type_t internal_type;
+
+ if (type < SENSOR_ALL || type > SENSOR_CUSTOM)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ if (!supported)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ _D("called sensor_is_supported : type[%d]", type);
+
+ internal_type = _sensor_type_to_internal_type(type);
+
+ sensor = sensord_get_sensor(internal_type);
+ _supported = false;
+
+ if (sensor)
+ _supported = true;
+
+ *supported = _supported;
+
+ _D("success sensor(%d) is supported[%d] : sensor[0x%x]",
+ type, _supported, sensor);
+
+ return SENSOR_ERROR_NONE;
+}
+
+int sensor_get_default_sensor(sensor_type_e type, sensor_h *sensor)
+{
+ sensor_t _sensor;
+ sensor_privilege_t privilege;
+ sensor_type_t internal_type;
+
+ _D("called sensor_get_default_sensor : type[%d], sensor[0x%x]", type, sensor);
+
+ if (type < SENSOR_ALL || type > SENSOR_CUSTOM)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ if (!sensor)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ internal_type = _sensor_type_to_internal_type(type);
+
+ _sensor = sensord_get_sensor(internal_type);
+
+ if (!_sensor)
+ return SENSOR_ERROR_NOT_SUPPORTED;
+
+ sensord_get_privilege(_sensor, &privilege);
+
+ if (privilege != SENSOR_PRIVILEGE_PUBLIC)
+ return SENSOR_ERROR_NOT_SUPPORTED;
+
+ *sensor = _sensor;
+
+ _D("success sensor_get_default_sensor sensor[0x%x]", _sensor);
+
+ return SENSOR_ERROR_NONE;
+}
+
+int sensor_get_sensor_list(sensor_type_e type, sensor_h **list, int *sensor_count)
+{
+ sensor_h *_list = NULL;
+ int count;
+ sensor_type_t internal_type;
+
+ _D("called sensor_get_list : type[%d]");
+
+ if (type < SENSOR_ALL || type > SENSOR_CUSTOM)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ if (!sensor_count || !list)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ internal_type = _sensor_type_to_internal_type(type);
+
+ sensord_get_sensor_list(internal_type, &_list, &count);
+
+ int i, j;
+ int count_public = 0;
+
+ for (i = 0; i < count; ++i) {
+ sensor_privilege_t privilege;
+
+ sensord_get_privilege(_list[i], &privilege);
+ if (privilege != SENSOR_PRIVILEGE_PUBLIC)
+ continue;
+
+ count_public++;
+ }
+
+ if (count_public == 0) {
+ free(_list);
+ return SENSOR_ERROR_NOT_SUPPORTED;
+ }
+
+ *list = (sensor_h *) malloc((sizeof(int *)) * count_public);
+
+ if (!*list) {
+ free(_list);
+ return SENSOR_ERROR_OUT_OF_MEMORY;
+ }
+
+ for (i = 0, j = 0; i < count; ++i) {
+ sensor_privilege_t privilege;
+
+ sensord_get_privilege(_list[i], &privilege);
+ if (privilege != SENSOR_PRIVILEGE_PUBLIC)
+ continue;
+
+ *(*list + j) = _list[i];
+ j++;
+ }
+
+ free(_list);
+
+ *sensor_count = count_public;
+
+ _D("success sensor_get_list");
+
+ return SENSOR_ERROR_NONE;
+}
+
+int sensor_create_listener(sensor_h sensor, sensor_listener_h *listener)
+{
+ struct sensor_listener_s *_listener;
+ int error;
+
+ _D("called sensor_create_listener : listener[0x%x]", listener);
+
+ if (!sensor || !listener)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ _listener = new(std::nothrow) struct sensor_listener_s;
+
+ if (!_listener)
+ return SENSOR_ERROR_OUT_OF_MEMORY;
+
+ error = sensor_connect(sensor, _listener);
+
+ if (error < 0) {
+ delete (struct sensor_listener_s *)_listener;
+ return error;
+ }
+
+ _listener->sensor = sensor;
+ _listener->option = SENSOR_OPTION_DEFAULT;
+ _listener->magic = SENSOR_LISTENER_MAGIC;
+
+ *listener = (sensor_listener_h) _listener;
+
+ _D("success sensor_create_listener");
+
+ return SENSOR_ERROR_NONE;
+}
+
+int sensor_destroy_listener(sensor_listener_h listener)
+{
+ _D("called sensor_destroy : listener[0x%x]", listener);
+
+ if (!listener)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ if (listener->magic != SENSOR_LISTENER_MAGIC)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ sensord_disconnect(listener->id);
+ listener->magic = 0;
+
+ delete (sensor_listener_s *)listener;
+
+ _D("success sensor_destroy");
+
+ return SENSOR_ERROR_NONE;
+}
+
+int sensor_listener_start(sensor_listener_h listener)
+{
+ int id;
+ unsigned int option = 0;
+
+ _D("called sensor_listener_start : listener[0x%x]", listener);
+
+ if (!listener)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ if (listener->magic != SENSOR_LISTENER_MAGIC)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ id = listener->id;
+ option = listener->option;
+
+ if (!sensord_start(id, option))
+ return SENSOR_ERROR_OPERATION_FAILED;
+
+ _E("success sensor_listener_start : id[%d]", id);
+
+ return SENSOR_ERROR_NONE;
+}
+
+int sensor_listener_stop(sensor_listener_h listener)
+{
+ int id;
+
+ _D("called sensor_listener_stop : listener[0x%x]", listener);
+
+ if (!listener)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ if (listener->magic != SENSOR_LISTENER_MAGIC)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ id = listener->id;
+
+ if (!sensord_stop(id))
+ return SENSOR_ERROR_OPERATION_FAILED;
+
+ _D("success sensor_listener_stop");
+
+ return SENSOR_ERROR_NONE;
+}
+
+static void sensor_callback(sensor_t sensor, unsigned int event_type, sensor_data_t *data, void *user_data)
+{
+ sensor_event_s event;
+ sensor_listener_h listener;
+ listener = (sensor_listener_h)user_data;
+
+ _D("success sensor_callback, sensor[%p] listener[%p] listener->callback[%p]", sensor, listener, listener->callback);
+ if (!sensor || !listener->callback)
+ return;
+
+ event.accuracy = data->accuracy;
+ event.timestamp = data->timestamp;
+ event.value_count = data->value_count;
+
+ for (int i = 0; i < data->value_count; ++i)
+ event.values[i] = data->values[i];
+
+ ((sensor_event_cb) listener->callback)(sensor, &event, listener->user_data);
+ return;
+}
+
+int sensor_listener_set_event_cb(sensor_listener_h listener,
+ unsigned int interval, sensor_event_cb callback, void *user_data)
+{
+ int id;
+ unsigned int event_id;
+
+ if (!listener || !callback)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ if (listener->magic != SENSOR_LISTENER_MAGIC)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ _D("called sensor_listener_set_event : listener[0x%x], interval[%d], callback[0x%x], user_data[0x%x], id[%d]",
+ listener, interval, callback, user_data, listener->id);
+
+ id = listener->id;
+ event_id = (listener->type) << SENSOR_SHIFT_TYPE | 0x1;
+
+ listener->callback = (void *)callback;
+ listener->user_data = user_data;
+
+ if (!sensord_register_event(id, event_id, interval, 0,
+ sensor_callback, listener)) {
+ listener->callback = NULL;
+ listener->user_data = NULL;
+
+ return SENSOR_ERROR_OPERATION_FAILED;
+ }
+
+ _D("success sensor_listener_set_event");
+
+ return SENSOR_ERROR_NONE;
+}
+
+int sensor_listener_unset_event_cb(sensor_listener_h listener)
+{
+ int id;
+ int type;
+ unsigned int event_id;
+
+ _D("called sensor_unregister_event : listener[0x%x]", listener);
+
+ if (!listener)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ if (listener->magic != SENSOR_LISTENER_MAGIC)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ id = listener->id;
+ type = (int)listener->type;
+ event_id = type << SENSOR_SHIFT_TYPE | 0x1;
+
+ if (!sensord_unregister_event(id, event_id))
+ return SENSOR_ERROR_OPERATION_FAILED;
+
+ listener->callback = NULL;
+ listener->user_data = NULL;
+
+ _D("success sensor_unregister_event");
+
+ return SENSOR_ERROR_NONE;
+}
+
+static void accuracy_changed_callback(sensor_t sensor,
+ unsigned long long timestamp, int accuracy, void *data)
+{
+ sensor_listener_h listener = (sensor_listener_h)data;
+
+ if (!sensor || !listener->accu_callback)
+ return;
+
+ ((sensor_accuracy_changed_cb)listener->accu_callback)
+ (sensor, timestamp, (sensor_data_accuracy_e)accuracy, listener->accu_user_data);
+
+ return;
+}
+
+int sensor_listener_set_accuracy_cb(sensor_listener_h listener,
+ sensor_accuracy_changed_cb callback, void *data)
+{
+ int id;
+
+ _E("called sensor_register_accuracy_cb : listener[0x%x], callback[0x%x], user_data[0x%x] cb[%p]",
+ listener, callback, data, accuracy_changed_callback);
+
+ if (!listener || !callback)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ if (listener->magic != SENSOR_LISTENER_MAGIC)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ id = listener->id;
+ listener->accu_callback = (void *)callback;
+ listener->accu_user_data = data;
+
+ if (!sensord_register_accuracy_cb(id, accuracy_changed_callback, listener)) {
+ listener->accu_callback = NULL;
+ listener->accu_user_data = NULL;
+
+ return SENSOR_ERROR_OPERATION_FAILED;
+ }
+
+ _D("success sensor_register_accuracy_cb");
+
+ return SENSOR_ERROR_NONE;
+}
+
+int sensor_listener_unset_accuracy_cb(sensor_listener_h listener)
+{
+ int id;
+
+ _D("called sensor_unregister_accuracy_cb : listener[0x%x]", listener);
+
+ if (!listener)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ if (listener->magic != SENSOR_LISTENER_MAGIC)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ id = listener->id;
+
+ if (!sensord_unregister_accuracy_cb(id))
+ return SENSOR_ERROR_OPERATION_FAILED;
+
+ listener->accu_callback = NULL;
+ listener->accu_user_data = NULL;
+
+ _D("success sensor_unregister_accuracy_cb");
+
+ return SENSOR_ERROR_NONE;
+}
+
+int sensor_listener_set_interval(sensor_listener_h listener, unsigned int interval)
+{
+ int id;
+ int type;
+ unsigned int event_id;
+
+ _D("called sensor_set_interval : listener[0x%x], interval[%d]", listener, interval);
+
+ if (!listener)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ if (listener->magic != SENSOR_LISTENER_MAGIC)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ id = listener->id;
+ type = (int)listener->type;
+ event_id = type << SENSOR_SHIFT_TYPE | 0x1;
+
+ if (!sensord_change_event_interval(id, event_id, interval))
+ return SENSOR_ERROR_OPERATION_FAILED;
+
+ _D("success sensor_set_interval");
+
+ return SENSOR_ERROR_NONE;
+}
+
+int sensor_listener_set_max_batch_latency(sensor_listener_h listener, unsigned int max_batch_latency)
+{
+ _D("called sensor_set_max_batch_latency : listener[0x%x], max_batch_latency[%d]", listener, max_batch_latency);
+
+ if (!listener)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ if (listener->magic != SENSOR_LISTENER_MAGIC)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ if (!sensord_change_event_max_batch_latency(listener->id, max_batch_latency))
+ return SENSOR_ERROR_NOT_SUPPORTED;
+
+ _D("success sensor_set_max_batch_latency");
+
+ return SENSOR_ERROR_NONE;
+}
+
+int sensor_listener_set_option(sensor_listener_h listener, sensor_option_e option)
+{
+ int id;
+
+ _D("called sensor_set_option : listener[0x%x], option[%d]", listener, option);
+
+ if (!listener)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ if (listener->magic != SENSOR_LISTENER_MAGIC)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ id = listener->id;
+
+ if (!sensord_set_option(id, (int)option))
+ return SENSOR_ERROR_OPERATION_FAILED;
+
+ listener->option = option;
+
+ _D("success sensor_set_option");
+
+ return SENSOR_ERROR_NONE;
+}
+
+int sensor_listener_read_data(sensor_listener_h listener, sensor_event_s *event)
+{
+ int id;
+ int type;
+ sensor_data_t data;
+ unsigned int data_id;
+
+ _D("called sensor_read_data : listener[0x%x]", listener);
+
+ if (!listener || !event)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ if (listener->magic != SENSOR_LISTENER_MAGIC)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ id = listener->id;
+ type = (int)listener->type;
+ data_id = type << SENSOR_SHIFT_TYPE | 0x1;
+
+ if (!sensord_get_data(id, data_id, &data))
+ return SENSOR_ERROR_OPERATION_FAILED;
+
+ event->accuracy = data.accuracy;
+ event->timestamp = data.timestamp;
+ event->value_count = data.value_count;
+
+ for (int i = 0; i < data.value_count; ++i)
+ event->values[i] = data.values[i];
+
+ _D("success sensor_read_data");
+
+ return SENSOR_ERROR_NONE;
+}
+
+int sensor_get_name(sensor_h sensor, char** name)
+{
+ _D("called sensor_get_name");
+
+ if (!sensor || !name)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ *name = strdup(sensord_get_name(sensor));
+
+ _D("success sensor_get_vendor : [%s]", *name);
+
+ return SENSOR_ERROR_NONE;
+}
+
+int sensor_get_vendor(sensor_h sensor, char** vendor)
+{
+ _D("called sensor_get_vendor");
+
+ if (!sensor || !vendor)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ *vendor = strdup(sensord_get_vendor(sensor));
+
+ _D("success sensor_vendor : [%s]", *vendor);
+
+ return SENSOR_ERROR_NONE;
+}
+
+int sensor_get_type(sensor_h sensor, sensor_type_e *type)
+{
+ sensor_type_t _type;
+ int type_size;
+ _D("called sensor_get_type");
+
+ if (!sensor || !type)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ if (!sensord_get_type(sensor, &_type))
+ return SENSOR_ERROR_OPERATION_FAILED;
+
+ type_size = sizeof(_TYPE) / sizeof(sensor_type_t);
+
+ for (int i = 0; i < type_size; ++i) {
+ if (_TYPE[i] == _type) {
+ *type = (sensor_type_e)i;
+ break;
+ }
+ }
+
+ _D("success sensor_get_type : [%d]", *type);
+
+ return SENSOR_ERROR_NONE;
+}
+
+int sensor_get_min_range(sensor_h sensor, float *min_range)
+{
+ _D("called sensor_get_min_range");
+
+ if (!sensor || !min_range)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ if (!sensord_get_min_range(sensor, min_range))
+ return SENSOR_ERROR_OPERATION_FAILED;
+
+ _D("success sensor_get_min_range : [%d]", *min_range);
+
+ return SENSOR_ERROR_NONE;
+}
+
+int sensor_get_max_range(sensor_h sensor, float *max_range)
+{
+ _D("called sensor_get_max_range");
+
+ if (!sensor || !max_range)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ if (!sensord_get_max_range(sensor, max_range))
+ return SENSOR_ERROR_OPERATION_FAILED;
+
+ _D("success sensor_get_max_range : [%d]", *max_range);
+
+ return SENSOR_ERROR_NONE;
+}
+
+int sensor_get_resolution(sensor_h sensor, float *resolution)
+{
+ _D("called sensor_get_resolution");
+
+ if (!sensor || !resolution)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ if (!sensord_get_resolution(sensor, resolution))
+ return SENSOR_ERROR_OPERATION_FAILED;
+
+ _D("success sensor_get_resolution : [%d]", *resolution);
+
+ return SENSOR_ERROR_NONE;
+}
+
+int sensor_get_min_interval(sensor_h sensor, int *min_interval)
+{
+ _D("called sensor_get_min_interval");
+
+ if (!sensor || !min_interval)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ if (!sensord_get_min_interval(sensor, min_interval))
+ return SENSOR_ERROR_OPERATION_FAILED;
+
+ _D("success sensor_get_min_interval : [%d]", *min_interval);
+
+ return SENSOR_ERROR_NONE;
+}
+
+int sensor_get_fifo_count(sensor_h sensor, int *fifo_count)
+{
+ _D("called sensor_get_fifo_count");
+
+ if (!sensor || !fifo_count)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ if (!sensord_get_fifo_count(sensor, fifo_count))
+ return SENSOR_ERROR_OPERATION_FAILED;
+
+ _D("success sensor_get_fifo_count : [%d]", *fifo_count);
+
+ return SENSOR_ERROR_NONE;
+}
+
+int sensor_get_max_batch_count(sensor_h sensor, int *max_batch_count)
+{
+ _D("called sensor_get_max_batch_count");
+
+ if (!sensor || !max_batch_count)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ if (!sensord_get_max_batch_count(sensor, max_batch_count))
+ return SENSOR_ERROR_OPERATION_FAILED;
+
+ _D("success sensor_get_max_batch_count : [%d]", *max_batch_count);
+
+ return SENSOR_ERROR_NONE;
+}
+
+/*
+ * FUNCTIONS : SENSOR_UTIL_*
+ */
+
+int sensor_util_get_declination (float latitude, float longitude, float altitude, float *declination)
+{
+ if (!declination)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ setCoordinate (latitude, longitude, altitude, declination, NULL, 1);
+
+ return SENSOR_ERROR_NONE;
+}
+
+int sensor_util_get_angle_change (float R[], float prevR[], float angleChange[])
+{
+ if (getAngleChange (R, prevR, angleChange) < 0)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ return SENSOR_ERROR_NONE;
+}
+
+int sensor_util_get_orientation (float R[], float values[])
+{
+ if (!R || !values)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ values[0] = (float) atan2 (R[1], R[4]);
+ values[1] = (float) asin (-R[7]);
+ values[2] = (float) atan2 (-R[6], R[8]);
+
+ return SENSOR_ERROR_NONE;
+}
+
+int sensor_util_get_inclination (float I[], float* inclination)
+{
+ if (!I || !inclination)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ *inclination = atan2(I[5], I[4]);
+
+ return SENSOR_ERROR_NONE;
+}
+
+int sensor_util_remap_coordinate_system (float inR[], sensor_util_axis_e x, sensor_util_axis_e y, float outR[])
+{
+ if (remapCoordinateSystem (inR, x, y, outR) < 0)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ return SENSOR_ERROR_NONE;
+}
+
+int sensor_util_get_rotation_matrix_from_vector (float Vx, float Vy, float Vz, float R[])
+{
+ float RV[4] = {0, Vx, Vy, Vz};
+
+ RV[0] = 1 - Vx * Vx - Vy*Vy - Vz*Vz;
+ RV[0] = (Vx > 0) ? (float) (sqrt (Vx)) : 0;
+
+ if (quatToMatrix(RV, R) < 0)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ return SENSOR_ERROR_NONE;
+}
+
+int sensor_util_get_rotation_matrix (float Gx, float Gy, float Gz,float Mx, float My, float Mz,float R[], float I[])
+{
+ float G[3] = {Gx, Gy, Gz};
+ float M[3] = {Mx, My, Mz};
+
+ if (getRotationMatrix (G, M, R, I) < 0)
+ return SENSOR_ERROR_INVALID_PARAMETER;
+
+ return SENSOR_ERROR_NONE;
+}
+