tizen 2.3.1 release submit/tizen_2.3.1/20150915.075932 tizen_2.3.1_release
authorjk7744.park <jk7744.park@samsung.com>
Tue, 8 Sep 2015 13:11:29 +0000 (22:11 +0900)
committerjk7744.park <jk7744.park@samsung.com>
Tue, 8 Sep 2015 13:11:29 +0000 (22:11 +0900)
20 files changed:
AUTHORS [deleted file]
CMakeLists.txt
capi-system-sensor.manifest [new file with mode: 0644]
capi-system-sensor.pc.in
doc/sensor_doc.h [new file with mode: 0755]
include/sensor.h [new file with mode: 0755]
include/sensor_log.h [new file with mode: 0644]
include/sensor_private.h
include/sensors.h [deleted file]
packaging/capi-system-sensor.spec
src/fusion_util.c [new file with mode: 0644]
src/geomanetic_field.c [new file with mode: 0644]
src/sensor.c [deleted file]
src/sensor.cpp [new file with mode: 0755]
test/CMakeLists.txt [deleted file]
test/accelerometer-gravity-with-linear-acceleration.c [deleted file]
test/gyroscope-calc-anger.c [deleted file]
test/rotation.c [deleted file]
test/supported-sensor.c [deleted file]
test/system-sensor.c [deleted file]

diff --git a/AUTHORS b/AUTHORS
deleted file mode 100644 (file)
index 0a63eea..0000000
--- a/AUTHORS
+++ /dev/null
@@ -1 +0,0 @@
-Pius Lee <pius.lee@samsung.com>
index e58b082..0f20d75 100644 (file)
@@ -22,6 +22,9 @@ 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")
 
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror -g -fPIC -fdump-rtl-expand -std=c++0x")
+SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
+
 IF("${ARCH}" STREQUAL "arm")
     ADD_DEFINITIONS("-DTARGET")
 ENDIF("${ARCH}" STREQUAL "arm")
@@ -45,9 +48,10 @@ SET_TARGET_PROPERTIES(${fw_name}
 
 INSTALL(TARGETS ${fw_name} DESTINATION lib)
 INSTALL(
-        DIRECTORY ${INC_DIR}/ DESTINATION include/system
+        DIRECTORY ${INC_DIR}/ DESTINATION include/sensor
         FILES_MATCHING
         PATTERN "*_private.h" EXCLUDE
+        PATTERN "*_log.h" EXCLUDE
         PATTERN "${INC_DIR}/*.h"
         )
 
@@ -62,16 +66,14 @@ CONFIGURE_FILE(
 )
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION lib/pkgconfig)
 
-#ADD_SUBDIRECTORY(test)
-
 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
diff --git a/capi-system-sensor.manifest b/capi-system-sensor.manifest
new file mode 100644 (file)
index 0000000..41a9320
--- /dev/null
@@ -0,0 +1,6 @@
+<manifest>
+    <request>
+        <domain name="_"/>
+    </request>
+</manifest>
+
index 316fa51..ce1ab4e 100644 (file)
@@ -4,12 +4,12 @@
 prefix=@PREFIX@
 exec_prefix=/usr
 libdir=/usr/lib
-includedir=/usr/include/system
+includedir=/usr/include/sensor
 
 Name: @PC_NAME@
 Description: @PACKAGE_DESCRIPTION@
 Version: @VERSION@
-Requires: @PC_REQUIRED@ 
+Requires: @PC_REQUIRED@
 Libs: -L${libdir} @PC_LDFLAGS@
-Cflags: -I${includedir} 
+Cflags: -I${includedir}
 
diff --git a/doc/sensor_doc.h b/doc/sensor_doc.h
new file mode 100755 (executable)
index 0000000..00aa839
--- /dev/null
@@ -0,0 +1,141 @@
+/*
+ * 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
+ *  - http://tizen.org/feature/sensor.heart_rate_monitor\n
+ *  - http://tizen.org/feature/sensor.heart_rate_monitor.led_green\n
+ *  - http://tizen.org/feature/sensor.heart_rate_monitor.led_ir\n
+ *  - http://tizen.org/feature/sensor.heart_rate_monitor.led_red\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
+ *  - http://tizen.org/feature/sensor.heart_rate_monitor\n
+ *  - http://tizen.org/feature/sensor.heart_rate_monitor.led_green\n
+ *  - http://tizen.org/feature/sensor.heart_rate_monitor.led_ir\n
+ *  - http://tizen.org/feature/sensor.heart_rate_monitor.led_red\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
+ *  - http://tizen.org/feature/sensor.heart_rate_monitor\n
+ *  - http://tizen.org/feature/sensor.heart_rate_monitor.led_green\n
+ *  - http://tizen.org/feature/sensor.heart_rate_monitor.led_ir\n
+ *  - http://tizen.org/feature/sensor.heart_rate_monitor.led_red\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__
diff --git a/include/sensor.h b/include/sensor.h
new file mode 100755 (executable)
index 0000000..e990f2c
--- /dev/null
@@ -0,0 +1,839 @@
+/*
+ * 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_H__
+#define __SENSOR_H__
+
+#include <tizen.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ */
+typedef void* sensor_h;
+
+
+/**
+ * @brief The listener handle.
+ * @details This listener is an event listener used to receive sensor data asynchronously.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ */
+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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @remarks If you use proximity sensor, see #sensor_proximity_e
+ */
+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 Enumeration for sensor data accuracy.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ */
+typedef enum
+{
+       SENSOR_DATA_ACCURACY_UNDEFINED   = -1,  /**< Undefined accuracy */
+       SENSOR_DATA_ACCURACY_BAD         = 0,   /**< Bad accuracy */
+       SENSOR_DATA_ACCURACY_NORMAL      = 1,   /**< Normal accuracy */
+       SENSOR_DATA_ACCURACY_GOOD        = 2,   /**< Good accuracy */
+       SENSOR_DATA_ACCURACY_VERYGOOD    = 3    /**< Very good accuracy */
+} sensor_data_accuracy_e;
+
+
+/**
+ * @brief Enumeration for sensor error.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ */
+typedef enum
+{
+       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_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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ */
+typedef enum
+{
+       SENSOR_PROXIMITY_NEAR = 0,    /**< The object is near */
+       SENSOR_PROXIMITY_FAR = 5,     /**< The object is far */
+} sensor_proximity_e;
+
+
+/**
+ * @brief Enumeration for sensor types.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ */
+typedef enum
+{
+       SENSOR_ALL = -1,                         /**< All sensors */
+       SENSOR_ACCELEROMETER,                    /**< Accelerometer */
+       SENSOR_GRAVITY,                          /**< Gravity sensor */
+       SENSOR_LINEAR_ACCELERATION,              /**< Linear acceleration 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_PRESSURE,                         /**< Pressure sensor */
+       SENSOR_ULTRAVIOLET,                      /**< Ultraviolet sensor */
+       SENSOR_TEMPERATURE,                      /**< Temperature sensor */
+       SENSOR_HUMIDITY,                         /**< Humidity sensor */
+       SENSOR_HRM,                              /**< Heart Rate Monitor sensor @if MOBILE (Since Tizen 2.3.1) @endif */
+       SENSOR_HRM_LED_GREEN,                    /**< HRM (LED Green) sensor @if MOBILE (Since Tizen 2.3.1) @endif */
+       SENSOR_HRM_LED_IR,                       /**< HRM (LED IR) sensor @if MOBILE (Since Tizen 2.3.1) @endif */
+       SENSOR_HRM_LED_RED,                      /**< HRM (LED RED) sensor @if MOBILE (Since Tizen 2.3.1) @endif */
+       SENSOR_LAST,                             /**< End of sensor enum values */
+       SENSOR_CUSTOM = 10000                    /**< Custom sensor */
+} sensor_type_e;
+
+/**
+ * @brief Enumeration for sensor options.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ */
+#ifndef __SENSOR_COMMON_H__
+typedef enum
+{
+       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 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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks For getting a handle of HRM Sensor(including HRM_LED_GREEN, HRM_LED_IR and HRM_LED_RED)
+ * the privilege should be set to, %http://tizen.org/privilege/healthinfo.
+ *
+ * @param[in]   type        The sensor type to check
+ * @param[out]  supported   If @c true 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_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 a specific sensor handle.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks For getting a handle of HRM Sensor(including HRM_LED_GREEN, HRM_LED_IR and HRM_LED_RED)
+ * the privilege should be set to, %http://tizen.org/privilege/healthinfo.
+ *
+ * @param[in]  type     The sensor type
+ * @param[out] 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
+ * @retval      #SENSOR_ERROR_PERMISSION_DENIED    Permission denied
+ */
+int sensor_get_default_sensor(sensor_type_e type, sensor_h *sensor);
+
+/**
+ * @brief Gets a sensor list.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @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.
+ *
+ * @param[in]  type         The sensor type
+ * @param[out] list         The sensor list
+ * @param[out] sensor_count The count of sensors
+ *
+ * @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_sensor_list(sensor_type_e type, sensor_h **list, int *sensor_count);
+
+/**
+ * @brief Called when a sensor event occurs.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @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_listener()
+ * @see sensor_listener_set_event_cb()
+ * @see sensor_listener_unset_event_cb()
+ */
+typedef void (*sensor_event_cb)(sensor_h sensor, sensor_event_s *event, void *data);
+
+/**
+ * @brief Creates a sensor listener.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @remarks You must release @a listener using sensor_destroy_listener().
+ *
+ * @param[in]  sensor          The sensor handle
+ * @param[out] listener        A new listener 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
+ * @retval      #SENSOR_ERROR_OUT_OF_MEMORY        Out of memory
+ *
+ * @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_create_listener(sensor_h sensor, sensor_listener_h *listener);
+
+/**
+ * @brief Destroys the sensor handle and releases all its resources.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @remarks After this function is called, the attached sensor is detached and
+ *          the corresponding sensor connection is released.
+ *
+ * @param[in] listener  The listener 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
+ *
+ * @see sensor_create_listener()
+ */
+int sensor_destroy_listener(sensor_listener_h listener);
+
+/**
+ * @brief Starts the sensor server for the given listener.
+ *
+ * @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.
+ *
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in] listener  The listener 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
+ * @retval      #SENSOR_ERROR_IO_ERROR             I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED     Operation failed
+ *
+ * @pre Call sensor_create_listener() before using this function.
+ *
+ * @see sensor_listener_stop()
+ */
+int sensor_listener_start(sensor_listener_h listener);
+
+/**
+ * @brief     Stops the sensor server for the given listener.
+ *
+ * @details   The given @a type event will not occur any more and the callback functions also won't be called.
+ *
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]   listener  The listener 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
+ * @retval      #SENSOR_ERROR_IO_ERROR             I/O error
+ *
+ * @see sensor_listener_start()
+ */
+int sensor_listener_stop(sensor_listener_h listener);
+
+/**
+ * @brief  Registers a callback function to be invoked when a sensor event occurs.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @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) \n
+ *                          Min value is 10ms, Max value is 1000ms(10ms ~ 1000ms)
+ * @param[in]   callback    The callback function to register
+ * @param[in]   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
+ *
+ * @see sensor_event_cb()
+ * @see sensor_listener_unset_event_cb()
+ */
+int sensor_listener_set_event_cb(sensor_listener_h listener, unsigned int interval_ms, sensor_event_cb callback, void *data);
+
+/**
+ * @brief  Unregisters the sensor callback function.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]   listener    The listener 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
+ * @retval      #SENSOR_ERROR_IO_ERROR             I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED     Operation failed
+ *
+ * @see sensor_listener_set_event_cb()
+ */
+int sensor_listener_unset_event_cb(sensor_listener_h listener);
+
+/**
+ * @brief Called when the accuracy of a sensor has changed.
+ *
+ * @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @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
+ */
+typedef void (*sensor_accuracy_changed_cb)(sensor_h sensor, unsigned long long timestamp, sensor_data_accuracy_e accuracy, void *data);
+
+/**
+ * @brief Registers an accuracy callback function to be invoked when the accuracy of a sensor has changed.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @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
+ *
+ * @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_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 Unregisters the sensor accuracy changed callback function.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]   listener    The listener 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
+ * @retval      #SENSOR_ERROR_IO_ERROR             I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED     Operation failed
+ *
+ * @see sensor_listener_set_accuracy_cb()
+ */
+int sensor_listener_unset_accuracy_cb(sensor_listener_h listener);
+
+/**
+ * @brief Gets sensor data.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]   listener    The listener handle
+ * @param[out]  event       The event information
+ *
+ * @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
+ *
+ * @pre In order to read sensor data, an application should call sensor_listener_start().
+ */
+int sensor_listener_read_data(sensor_listener_h listener, sensor_event_s *event);
+
+/**
+ * @brief Changes the interval at sensor measurements.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @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) \n
+ *                             Min value is 10ms, Max value is 1000ms(10ms ~ 1000ms)
+ *
+ * @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_listener_set_interval(sensor_listener_h listener, unsigned int interval_ms);
+
+/**
+ * @brief Changes the max batch latency at sensor measurements.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]   listener           The listener handle
+ * @param[in]   max_batch_latency  The latency at which sensor events are delivered (in milliseconds)
+ *
+ * @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_listener_set_max_batch_latency(sensor_listener_h listener, unsigned int max_batch_latency);
+
+/**
+ * @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @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_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_listener_set_option(sensor_listener_h listener, sensor_option_e option);
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_SYSTEM_SENSOR_INFORMATION_MODULE
+ * @{
+ */
+
+/**
+ * @brief Gets the name of the sensor.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @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_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_name(sensor_h sensor, char** name);
+
+/**
+ * @brief Gets the vendor of the sensor.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @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_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_vendor(sensor_h sensor, char** vendor);
+
+/**
+ * @brief Gets the type of the sensor.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]   sensor          The sensor handle
+ * @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_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_type(sensor_h sensor, sensor_type_e *type);
+
+/**
+ * @brief Gets the minimum range of the sensor.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @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_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_min_range(sensor_h sensor, float *min_range);
+
+/**
+ * @brief Gets the maximum range of the sensor.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @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 Gets the resolution of the sensor.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @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_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 Gets the minimun interval of the sensor.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @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_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_min_interval(sensor_h sensor, int *min_interval);
+
+/**
+ * @brief Gets the fifo count of the sensor.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]   sensor          The sensor handle
+ * @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_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_fifo_count(sensor_h sensor, int *fifo_count);
+
+/**
+ * @brief Gets the maximum batch count of the sensor.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @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_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_batch_count(sensor_h sensor, int *max_batch_count);
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_SYSTEM_SENSOR_UTILITY_MODULE
+ * @{
+ */
+
+/**
+ * @brief  Enumeration of the axis used in #sensor_util_remap_coordinate_system.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @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 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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @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 Converts a rotation vector to a rotation matrix.
+ *
+ * @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @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
+ *
+ * @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_from_vector(float Vx, float Vy, float Vz, float R[]);
+
+/**
+ * @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @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.
+ *
+ * @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)
+ *
+ * @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_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().
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @param[in]  I            The inclination matrix from sensor_util_get_rotation_matrix()
+ * @param[out] inclination  The geomagnetic inclination angle in radians
+ *
+ * @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 Computes the device's orientation based on the rotation matrix.
+ *
+ * @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @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.
+ *
+ * @param[in]  R         A 9 element rotation matrix in the array
+ * @param[out] values    An array of 3 floats to hold the result
+ *
+ * @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_orientation(float R[], float values[]);
+
+/**
+ * @brief Computes the angle change between two rotation matrices.
+ *
+ * @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 @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @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>
+ *
+ * @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
+ *
+ * @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_angle_change(float R[], float prevR[], float angleChange[]);
+
+/**
+ * @brief Gets the declination of the horizontal component of the magnetic field from true north, in degrees.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ *
+ * @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
+ *
+ * @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_declination(float latitude, float longitude, float altitude, float* declination);
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SENSOR_H__ */
diff --git a/include/sensor_log.h b/include/sensor_log.h
new file mode 100644 (file)
index 0000000..5779dfd
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * 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_*/
index b3a6b18..6633db5 100644 (file)
  * 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_MOTION_FACEDOWN+1)
-#define CALIB_CB_NUMBERS (SENSOR_ORIENTATION+1)
-
-struct sensor_handle_s {
-       int ids[ID_NUMBERS];
-//     sensor_type_e type;
-    int started[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];
-};
-
-#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_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_FACEDOWN] = 0; \
-        handle->cb_func[SENSOR_ACCELEROMETER] = 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_FACEDOWN] = NULL; \
-        handle->cb_user_data[SENSOR_ACCELEROMETER] = 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_FACEDOWN] = NULL; \
-               handle->calib_func[SENSOR_ACCELEROMETER] = 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_MAGNETIC] = NULL; \
-               handle->calib_user_data[SENSOR_ORIENTATION] = NULL; \
-    }while(0) \
-
+float clamp(float v);
+int getAngleChange(float *R, float *prevR, float *angleChange);
+int quatToMatrix(float *quat, float *R);
+int matrixToQuat(float *mat, float *q);
+int getRotationMatrix(float *accel, float *geo, float *R, float *I);
+int remapCoordinateSystem(float *inR, int X, int Y, float *outR);
+int getDeclination(float *decl);
+int getInclination(float *incl);
+int setCoordinate(float latitude, float longitude, float altitude, float *declination, float *inclination, int option);
 
 #ifdef __cplusplus
 }
 #endif
 
-#endif // __SENSOR_PRIVATE_H__ 
+#endif // __SENSOR_PRIVATE_H__
diff --git a/include/sensors.h b/include/sensors.h
deleted file mode 100755 (executable)
index 05707a5..0000000
+++ /dev/null
@@ -1,1832 +0,0 @@
-/*
- * 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. 
- */
-
-
-
-
-#ifndef __SENSOR_H__
-#define __SENSOR_H__
-
-#include <tizen.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/**
- * @addtogroup CAPI_SYSTEM_SENSOR_MODULE
- * @{
- */
-
-/**
- * @brief The sensor handle.
- */
-typedef struct sensor_handle_s* sensor_h;
-
-/**
-* @brief       Enumerations of sensor data accuracy.
-*/
-typedef enum
-{
-       SENSOR_DATA_ACCURACY_UNDEFINED   = -1,  /**< Undefined accuracy */
-       SENSOR_DATA_ACCURACY_BAD         = 0,   /**< Bad accuracy */
-       SENSOR_DATA_ACCURACY_NORMAL      = 1,   /**< Normal accuracy */
-       SENSOR_DATA_ACCURACY_GOOD        = 2,   /**< Good accuracy */
-       SENSOR_DATA_ACCURACY_VERYGOOD    = 3    /**< Very good accuracy */
-} sensor_data_accuracy_e;
-
-
-/**
-* @brief       Enumerations of error code for sensor.
-*/
-typedef enum
-{
-       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_e;
-
-
-/**
-* @brief       Enumerations of sensor type.
-*/
-typedef enum
-{
-       SENSOR_ACCELEROMETER,                    /**< Accelerometer */
-       SENSOR_MAGNETIC,                         /**< Magnetic 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_FACEDOWN                   /**< Face to down motion 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_LEFT,            /**< Snap left to right */
-       SENSOR_MOTION_SNAP_RIGHT,           /**< Snap right to left */
-    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.
- */
-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);
-/**
- * @}
- */
-
-
-/**
- * @addtogroup CAPI_SYSTEM_SENSOR_ACCELEROMETER_MODULE
- * @{
- */
-
-/**
- * @brief Called when an accelerometer 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 minus Gx on the x-axis in [m/s^2]
- * @param[in] y             The acceleration minus Gy on the y-axis in [m/s^2]
- * @param[in] z             The acceleration minus Gz on the z-axis in [m/s^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_accelerometer_set_cb().
- *
- * @see sensor_accelerometer_set_cb()
- * @see sensor_accelerometer_unset_cb()
- */
-typedef void (*sensor_accelerometer_event_cb)( unsigned long long timestamp,
-               sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data);
-/**
- * @}
- */
-
-/**
- * @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);
-/**
- * @}
- */
-
-/**
- * @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);
-/**
- * @}
- */
-
-/**
- * @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);
-/**
- * @}
- */
-
-/**
- * @addtogroup CAPI_SYSTEM_SENSOR_ORIENTATION_MODULE
- * @{
- */
-
-/**
- * @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 x, @a y, and @a z 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);
-/**
- * @}
- */
-
-/**
- * @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);
-/**
- * @}
- */
-
-
-
-/**
- * @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);
-/**
- * @}
- */
-
-
-/**
- * @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);
-/**
- * @}
- */
-
-
-/**
- * @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);
-/**
- * @}
- */
-
-
-/**
- * @addtogroup CAPI_SYSTEM_SENSOR_MOTION_PANNING_MODULE
- * @{
- */
-
-/**
- * @brief Called when a panning tap 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);
-/**
- * @}
- */
-
-
-/**
- * @addtogroup CAPI_SYSTEM_SENSOR_MOTION_FACEDOWN_MODULE
- * @{
- */
-
-/**
- * @brief Called when a facedown tap 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);
-/**
- * @}
- */
-
-
-/**
- * @addtogroup CAPI_SYSTEM_SENSOR_MODULE
- * @{
- */
-
-
-/**
- * @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.
- *
- * @param[in]   type        The sensor type to check
- * @param[out]  supported   @c true if 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
- *
- */
-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.
- *
- * @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
- *
- * @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()
- */
-int sensor_get_spec(sensor_type_e type, char** vendor, char** model, float *max, float *min, float *resolution);
-
-
-/**
- * @brief Creates a sensor handle.
- *
- * @remarks @a sensor must be released sensor_destroy() by you.
- *
- * @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()
- */
-int sensor_create(sensor_h *sensor);
-
-
-/**
- * @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.
- *
- * @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
- *
- * @see sensor_create()
- */
-int sensor_destroy(sensor_h sensor);
-
-
-/**
- * @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
- *
- * @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.
- *
- * @param[in]   sensor  The sensor handle
- * @param[in]   type    The sensor type
- *
- * @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_start()
- */
-int sensor_stop(sensor_h sensor, sensor_type_e type);
-
-/**
- * @brief Retrieve minimum and maximum interval time that can use to measuring specific sensor.
- *
- * @param[in]  type    The sensor type
- * @param[out] min     The minimum interval time
- * @param[out] max     The maximum interval time
- *
- * @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]   type         The sensor type
- * @param[out]  supported    @c true if 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
- * @retval      #SENSOR_ERROR_IO_ERROR              I/O error
- */
-int sensor_awake_is_supported(sensor_type_e type, bool *supported);
-
-/**
- * @brief Set the awaken behavior from specific sensor.
- *
- * @param[in]   type         The sensor type
- * @param[in]   enable       @c true if set enable the awaken behavior from the sensor, or @c false
- *
- * @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(sensor_type_e type, bool enable);
-
-/**
- * @brief Set the awaken behavior from specific sensor.
- *
- * @param[in]   type         The sensor type
- * @param[out]   enable       @c true if set enable the awaken behavior from the sensor, or @c false
- *
- * @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_type_e type, bool *enable);
-
-/**
- * @brief Called when a device awaken.
- *
- * @param[in] user_data     The user data passed from the callback registration function
- *
- * @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]   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
- */
-int sensor_awake_set_cb(sensor_awake_cb callback, void* user_data);
-
-/**
- * @brief Unset the callback that called when device awaken.
- * 
- * @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_unset_cb();
-
-/**
- * @}
- *
- * @addtogroup CAPI_SYSTEM_SENSOR_ACCELEROMETER_MODULE
- * @{
- */
-
-
-/**
- * @brief      Registers a callback function to be invoked when an accelerometer 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_accelerometer_set_cb(sensor_h sensor, int interval_ms, sensor_accelerometer_event_cb callback, void *user_data);
-
-
-/**
- * @brief      Unregister the accelerometer 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_accelerometer_set_cb()
- */
-int sensor_accelerometer_unset_cb(sensor_h sensor);
-
-/**
- * @brief change the interval at accelerometer 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_accelerometer_set_cb()
- */
-int sensor_accelerometer_set_interval(sensor_h sensor, int interval_ms);
-
-
-/**
- * @brief      Gets sensor data from the accelerometer sensor.
- *
- * @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
- *
- * @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);
-
-
-/**
- * @}
- *
- * @addtogroup CAPI_SYSTEM_SENSOR_GYROSCOPE_MODULE
- * @{
- */
-
-/**
- * @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      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_MAGNETIC_MODULE
- * @{
- */
-
-/**
- * @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()
- */
-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.
- *
- * @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()
- */
-int sensor_magnetic_unset_cb(sensor_h sensor);
-
-/**
- * @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 sensor data from the magnetic sensor.
- *
- * @remark All values are in micro-Teslas (uT) and measure the ambient magnetic field in the X, Y and Z axis.
- *
- * @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().
- *
- * @see sensor_start()
- */
-int sensor_magnetic_read_data(sensor_h sensor, sensor_data_accuracy_e *accuracy, float *x, float *y, float *z);
-
-/**
- * @brief      Registers a callback function to be invoked when the current sensor reading falls outside of a defined normal range.
- *
- * @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
- * @retval             #SENSOR_ERROR_NOT_NEED_CALIBRATION      Sensor doesn't need calibration
- *
- * @post sensor_calibration_cb() will be invoked.
- *
- * @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);
-
-/**
- * @brief      Unregisters the magnetic calibration 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
- * @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
- * @{
- */
-
-/**
- * @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 
- *
- * @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_orientation_event_cb() will be invoked.
- *
- * @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]   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_orientation_set_cb()
- */
-int sensor_orientation_unset_cb(sensor_h sensor);
-
-/**
- * @brief      Registers a callback function to be invoked when the current sensor reading falls outside of a defined normal range.
- *
- * @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
- * @retval             #SENSOR_ERROR_NOT_NEED_CALIBRATION      Sensor doesn't need calibration
- *
- * @post sensor_calibration_cb() will be invoked.
- *
- * @see sensor_calibration_cb()
- * @see sensor_orientation_unset_calibration_cb()
- */
-int sensor_orientation_set_calibration_cb(sensor_h sensor, sensor_calibration_cb callback, void *user_data);
-
-/**
- * @brief      Unregister the orientation calibration 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
- * @retval             #SENSOR_ERROR_NOT_NEED_CALIBRATION      Sensor doesn't need calibration
- *
- * @see sensor_orientation_set_calibration_cb()
- */
-int sensor_orientation_unset_calibration_cb(sensor_h sensor);
-
-/**
- * @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_PROXIMITY_MODULE
- * @{
- */
-
-/**
- * @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_DOUBLETAP_MODULE
- * @{
- */
-
-/**
- * @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_SNAP_MODULE
- * @{
- */
-
-/**
- * @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      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_PANNING_MODULE
- * @{
- */
-
-/**
- * @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_FACEDOWN_MODULE
- * @{
- */
-
-/**
- * @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_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_GRAVITY_MODULE
- * @{
- */
-
-/**
- * @brief Called when an gravity event occurs.
- *
- * @param[in] accuracy      The accuracy of @a x, @a y, and @a z values
- * @param[in] x             m/s^2
- * @param[in] y             m/s^2
- * @param[in] z             m/s^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_gravity_event_cb)(
-               sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data);
-
-/**
- * @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
- *
- * @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_gravity_set_cb(sensor_h sensor, int interval_ms, sensor_gravity_event_cb callback, void* user_data);
-
-/**
- * @brief      Unregister the gravity 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_gravity_unset_cb(sensor_h sensor);
-
-/**
- * @brief change the interval at gravity 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_gravity_set_cb()
- */
-int sensor_gravity_set_interval(sensor_h sensor, int interval_ms);
-
-/**
- * @brief      Gets sensor data from the gravity sensor.
- *
- * @param[in]   sensor      The sensor handle
- * @param[out]  accuracy    The accuracy of this data
- * @param[in] x             m/s^2
- * @param[in] y             m/s^2
- * @param[in] z             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
- *
- * @pre In order to read sensor data, an application should call sensor_start().
- */
-int sensor_gravity_read_data(sensor_h sensor, sensor_data_accuracy_e* accuracy, float* x, float* y, float* z);
-
-
-/**
- * @}
- */
-
-/**
- * @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);
-
-/**
- * @}
- */
-
-
-/**
- * @}
- *
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
index 6d81d23..4df5a7c 100644 (file)
@@ -1,15 +1,15 @@
 Name:       capi-system-sensor
 Summary:    A Sensor library in TIZEN C API
-Version: 0.1.0
+Version:    0.1.18
 Release:    10
 Group:      TO_BE/FILLED_IN
-License:    Apache 2.0
+License:    Apache-2.0 and PD
 Source0:    %{name}-%{version}.tar.gz
 BuildRequires:  cmake
 BuildRequires:  pkgconfig(dlog)
 BuildRequires:  pkgconfig(sensor)
 BuildRequires:  pkgconfig(capi-base-common)
-Requires(post): /sbin/ldconfig  
+Requires(post): /sbin/ldconfig
 Requires(postun): /sbin/ldconfig
 
 %description
@@ -27,8 +27,11 @@ Requires: %{name} = %{version}-%{release}
 %prep
 %setup -q
 
-
 %build
+%if 0%{?tizen_build_binary_release_type_eng}
+export CFLAGS+=" -DTIZEN_ENGINEER_MODE"
+%endif
+
 MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
 cmake . -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
 
@@ -39,17 +42,21 @@ make %{?jobs:-j%jobs}
 rm -rf %{buildroot}
 %make_install
 
+mkdir -p %{buildroot}/usr/share/license
+cp LICENSE %{buildroot}/usr/share/license/%{name}
+
 %post -p /sbin/ldconfig
 
 %postun -p /sbin/ldconfig
 
 
 %files
+%manifest capi-system-sensor.manifest
 %{_libdir}/libcapi-system-sensor.so.*
+/usr/share/license/%{name}
 
 %files devel
-%{_includedir}/system/sensors.h
+%{_includedir}/sensor/*.h
 %{_libdir}/pkgconfig/*.pc
 %{_libdir}/libcapi-system-sensor.so
 
-
diff --git a/src/fusion_util.c b/src/fusion_util.c
new file mode 100644 (file)
index 0000000..2dc8f1b
--- /dev/null
@@ -0,0 +1,201 @@
+/*
+ * 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>
+
+float clamp(float v)
+{
+       return (v < 0) ? 0.0 : v;
+}
+
+int getAngleChange(float *R, float *prevR, float *angleChange)
+{
+       if(R == NULL || prevR == NULL || angleChange == NULL)
+               return -1;
+
+       float rd1=0,rd4=0, rd6=0,rd7=0, rd8=0;
+       float ri0=0,ri1=0,ri2=0,ri3=0,ri4=0,ri5=0,ri6=0,ri7=0,ri8=0;
+       float pri0=0, pri1=0, pri2=0, pri3=0, pri4=0, pri5=0, pri6=0, pri7=0, pri8=0;
+
+       ri0 = R[0];
+       ri1 = R[1];
+       ri2 = R[2];
+       ri3 = R[3];
+       ri4 = R[4];
+       ri5 = R[5];
+       ri6 = R[6];
+       ri7 = R[7];
+       ri8 = R[8];
+
+       pri0 = prevR[0];
+       pri1 = prevR[1];
+       pri2 = prevR[2];
+       pri3 = prevR[3];
+       pri4 = prevR[4];
+       pri5 = prevR[5];
+       pri6 = prevR[6];
+       pri7 = prevR[7];
+       pri8 = prevR[8];
+
+       rd1 = pri0 * ri1 + pri3 * ri4 + pri6 * ri7;
+       rd4 = pri1 * ri1 + pri4 * ri4 + pri7 * ri7;
+       rd6 = pri2 * ri0 + pri5 * ri3 + pri8 * ri6;
+       rd7 = pri2 * ri1 + pri5 * ri4 + pri8 * ri7;
+       rd8 = pri2 * ri2 + pri5 * ri5 + pri8 * ri8;
+
+       angleChange[0] = atan2(rd1, rd4);
+       angleChange[1] = asin(-rd7);
+       angleChange[2] = atan2(-rd6, rd8);
+
+       return 0;
+}
+int quatToMatrix(float *quat, float *R)
+{
+       if(quat == NULL || R == NULL)
+               return -1;
+
+       float q0 = quat[0];
+       float q1 = quat[1];
+       float q2 = quat[2];
+       float q3 = quat[3];
+
+       float sq_q1 = 2 * q1 * q1;
+       float sq_q2 = 2 * q2 * q2;
+       float sq_q3 = 2 * q3 * q3;
+       float q1_q2 = 2 * q1 * q2;
+       float q3_q0 = 2 * q3 * q0;
+       float q1_q3 = 2 * q1 * q3;
+       float q2_q0 = 2 * q2 * q0;
+       float q2_q3 = 2 * q2 * q3;
+       float q1_q0 = 2 * q1 * q0;
+
+       R[0] = 1 - sq_q2 - sq_q3;
+       R[1] = q1_q2 - q3_q0;
+       R[2] = q1_q3 + q2_q0;
+       R[3] = q1_q2 + q3_q0;
+       R[4] = 1 - sq_q1 - sq_q3;
+       R[5] = q2_q3 - q1_q0;
+       R[6] = q1_q3 - q2_q0;
+       R[7] = q2_q3 + q1_q0;
+       R[8] = 1 - sq_q1 - sq_q2;
+
+       return 0;
+}
+
+int matrixToQuat(float *mat, float *q)
+{
+       if(q == NULL || mat == NULL)
+               return -1;
+
+       const float Hx = mat[0];
+       const float My = mat[4];
+       const float Az = mat[8];
+       q[0] = sqrtf( clamp( Hx - My - Az + 1) * 0.25f );
+       q[1] = sqrtf( clamp(-Hx + My - Az + 1) * 0.25f );
+       q[2] = sqrtf( clamp(-Hx - My + Az + 1) * 0.25f );
+       q[3]= sqrtf( clamp( Hx + My + Az + 1) * 0.25f );
+       q[0] = copysignf(q[0], mat[7] - mat[5]);
+       q[1] = copysignf(q[1], mat[2] - mat[6]);
+       q[2] = copysignf(q[2], mat[3] - mat[1]);
+
+       return 0;
+}
+
+int getRotationMatrix(float *accel, float *geo, float *R, float *I)
+{
+       if(accel == NULL || geo == NULL || R == NULL || I == NULL)
+               return -1;
+
+       float Ax = accel[0];
+       float Ay = accel[1];
+       float Az = accel[2];
+       float Ex = geo[0];
+       float Ey = geo[1];
+       float Ez = geo[2];
+       float Hx = Ey*Az - Ez*Ay;
+       float Hy = Ez*Ax - Ex*Az;
+       float Hz = Ex*Ay - Ey*Ax;
+       float normH =  (float)sqrt(Hx*Hx + Hy*Hy + Hz*Hz);
+       if(normH < 0.1f){
+               return -1;
+       }
+       float invH = 1.0f / normH;
+       Hx *= invH;
+       Hy *= invH;
+       Hz *= invH;
+       float invA = 1.0f / (float)sqrt(Ax*Ax + Ay*Ay + Az*Az);
+       Ax *= invA;
+       Ay *= invA;
+       Az *= invA;
+       float Mx = Ay*Hz - Az*Hy;
+       float My = Az*Hx - Ax*Hz;
+       float Mz = Ax*Hy - Ay*Hx;
+
+       R[0] = Hx;  R[1] = Hy;  R[2] = Hz;
+       R[3] = Mx;  R[4] = My;  R[5] = Mz;
+       R[6] = Ax;  R[7] = Ay;  R[8] = Az;
+
+       float invE = 1.0 / (float)sqrt(Ex*Ex + Ey*Ey + Ez*Ez);
+       float c = (Ex*Mx + Ey*My + Ez*Mz) * invE;
+       float s = (Ex*Ax + Ey*Ay + Ez*Az) * invE;
+
+       I[0] = 1;     I[1] = 0;     I[2] = 0;
+       I[3] = 0;     I[4] = c;     I[5] = s;
+       I[6] = 0;     I[7] =-s;     I[8] = c;
+
+       return 0;
+}
+
+
+int remapCoordinateSystem(float *inR, int X, int Y, float *outR)
+{
+       if(inR == NULL || outR == NULL)
+               return -1;
+
+       if ((X & 0x7C)!=0 || (Y & 0x7C)!=0)
+               return -1;   // invalid parameter
+       if (((X & 0x3)==0) || ((Y & 0x3)==0))
+               return -1;   // no axis specified
+       if ((X & 0x3) == (Y & 0x3))
+               return -1;   // same axis specified
+
+       int Z = X ^ Y;
+       int x = (X & 0x3)-1;
+       int y = (Y & 0x3)-1;
+       int z = (Z & 0x3)-1;
+
+       int axis_y = (z+1)%3;
+       int axis_z = (z+2)%3;
+       if (((x^axis_y)|(y^axis_z)) != 0)
+               Z ^= 0x80;
+
+       char sx = (X>=0x80) ? 1 : 0;
+       char sy = (Y>=0x80) ? 1 : 0;
+       char sz = (Z>=0x80) ? 1 : 0;
+
+       int i = 0 , j = 0;
+       for (j=0 ; j<3 ; j++) {
+               int offset = j*3;
+               for (i=0 ; i<3 ; i++) {
+                       if (x==i)   outR[offset+i] = sx ? -inR[offset+0] : inR[offset+0];
+                       if (y==i)   outR[offset+i] = sy ? -inR[offset+1] : inR[offset+1];
+                       if (z==i)   outR[offset+i] = sz ? -inR[offset+2] : inR[offset+2];
+               }
+       }
+       return 0;
+}
+
diff --git a/src/geomanetic_field.c b/src/geomanetic_field.c
new file mode 100644 (file)
index 0000000..65cd52b
--- /dev/null
@@ -0,0 +1,289 @@
+/*
+ * 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;
+}
+
diff --git a/src/sensor.c b/src/sensor.c
deleted file mode 100644 (file)
index 6fa5ef0..0000000
+++ /dev/null
@@ -1,925 +0,0 @@
-/*
- * 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 <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",
-       "MAGNETIC",
-       "ORIENTATION",
-       "GYROSCOPE",
-       "LIGHT",
-       "PROXIMITY",
-       "MOTION_SNAP",
-       "MOTION_SHAKE",
-       "MOTION_DOUBLETAP",
-    "MOTION_PANNING",
-    "MOTION_FACEDOWN"
-};
-
-#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_MOTION_FACEDOWN || type < 0, SENSOR_ERROR_INVALID_PARAMETER)
-
-#define RETURN_IF_MOTION_TYPE(type) \
-       RETURN_VAL_IF(type > SENSOR_PROXIMITY && type <= SENSOR_MOTION_FACEDOWN, SENSOR_ERROR_INVALID_PARAMETER)
-
-#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,
-       GEOMAGNETIC_SENSOR,
-       GEOMAGNETIC_SENSOR,
-       GYROSCOPE_SENSOR,
-       LIGHT_SENSOR,
-       PROXIMITY_SENSOR,
-       MOTION_SENSOR,
-       MOTION_SENSOR,
-       MOTION_SENSOR,
-       MOTION_SENSOR,
-       MOTION_SENSOR,
-};
-
-int _DTYPE[] = {
-       ACCELEROMETER_BASE_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,
-};
-
-int _EVENT[] = {
-       ACCELEROMETER_EVENT_RAW_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_TOP_TO_BOTTOM,
-};
-
-int _CALIBRATION[] = {
-       ACCELEROMETER_EVENT_CALIBRATION_NEEDED,
-       GEOMAGNETIC_EVENT_CALIBRATION_NEEDED,
-       GEOMAGNETIC_EVENT_CALIBRATION_NEEDED,
-};
-
-int _sensor_ids[] = {
-    ID_ACCELEOMETER,
-    ID_GEOMAGNETIC,
-    ID_GEOMAGNETIC,
-    ID_GYROSCOPE,
-    ID_LIGHT,
-    ID_PROXIMITY,
-    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;
-//    bool proximity = 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_TOP_TO_BOTTOM:
-            nid = SENSOR_MOTION_FACEDOWN;
-            break;
-               case ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME :
-            nid = SENSOR_ACCELEROMETER;
-            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:
-            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 ACCELEROMETER_EVENT_RAW_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 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 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 = properties.sensor_vendor;
-       if(model != NULL)
-               *model = properties.sensor_name;
-
-       *max = data_properties.sensor_max_range;
-       *min = data_properties.sensor_min_range;
-       *resolution = data_properties.sensor_resolution;
-
-       DEBUG_PRINTF("success get %s's format max=%f, min=%f, res=%f\n", TYPE_NAME(type), *max, *min, *resolution);
-
-       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;
-    bool failed = false;
-       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)
-                failed = true;
-            else
-                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)], 0) < 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_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_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 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=[%d]", 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_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);
-    if(type > SENSOR_PROXIMITY && type <= SENSOR_MOTION_DOUBLETAP)
-        RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
-       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_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_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);
-}
diff --git a/src/sensor.cpp b/src/sensor.cpp
new file mode 100755 (executable)
index 0000000..408502e
--- /dev/null
@@ -0,0 +1,806 @@
+/*
+ * 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 <sensor.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,
+       BIO_HRM_SENSOR,
+       BIO_LED_GREEN_SENSOR,
+       BIO_LED_IR_SENSOR,
+       BIO_LED_RED_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;
+
+       _D("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;
+
+       _D("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;
+}
+
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
deleted file mode 100755 (executable)
index 1f8cbcd..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-SET(fw_name "capi-system-sensor")
-SET(fw_test "${fw_name}-test")
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(${fw_test} REQUIRED glib-2.0)
-FOREACH(flag ${${fw_test}_CFLAGS})
-    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall")
-INCLUDE_DIRECTORIES(../include)
-
-#ADD_EXECUTABLE("system-sensor" system-sensor.c)
-#TARGET_LINK_LIBRARIES("system-sensor" ${fw_name} ${${fw_test}_LDFLAGS})
-
-aux_source_directory(. sources)
-FOREACH(src ${sources})
-    GET_FILENAME_COMPONENT(src_name ${src} NAME_WE)
-    MESSAGE("${src_name}")
-    ADD_EXECUTABLE(${src_name} ${src})
-    TARGET_LINK_LIBRARIES(${src_name} ${fw_name} ${${fw_test}_LDFLAGS} ${fw_name} -lm)
-ENDFOREACH()
-
-IF(UNIX)
-
-ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution)
-ADD_CUSTOM_COMMAND(
-        DEPENDS clean 
-        COMMENT "distribution clean"
-        COMMAND find
-        ARGS    . 
-        -not -name config.cmake -and \(
-        -name tester.c -or
-        -name Testing -or
-        -name CMakeFiles -or
-        -name cmake.depends -or
-        -name cmake.check_depends -or
-        -name CMakeCache.txt -or
-        -name cmake.check_cache -or
-        -name *.cmake -or
-        -name Makefile -or
-        -name core -or
-        -name core.* -or
-        -name gmon.out -or
-        -name install_manifest.txt -or
-        -name *.pc -or
-        -name *~ \)
-        | grep -v TC | xargs rm -rf
-        TARGET  distclean
-        VERBATIM
-)
-
-ENDIF(UNIX)
diff --git a/test/accelerometer-gravity-with-linear-acceleration.c b/test/accelerometer-gravity-with-linear-acceleration.c
deleted file mode 100644 (file)
index d3ec69c..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * 
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- * PROPRIETARY/CONFIDENTIAL
- * 
- * This software is the confidential and proprietary information of SAMSUNG 
- * ELECTRONICS ("Confidential Information"). You agree and acknowledge that 
- * this software is owned by Samsung and you shall not disclose such 
- * Confidential Information and shall use it only in accordance with the terms 
- * of the license agreement you entered into with SAMSUNG ELECTRONICS. SAMSUNG 
- * make no representations or warranties about the suitability of the software, 
- * either express or implied, including but not limited to the implied 
- * warranties of merchantability, fitness for a particular purpose, or 
- * non-infringement. SAMSUNG shall not be liable for any damages suffered by 
- * licensee arising out of or related to this software.
- * 
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <glib.h>
-#include <sensors.h>
-
-static GMainLoop *mainloop;
-
-const float Alpha = 0.8;
-
-struct three_axis_s{
-    float x,y,z;
-};
-
-struct three_axis_s gravitys = {0,0,0};
-struct three_axis_s linear_accelation = {0,0,0};
-
-static void test_accelerometer_cb(sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data)
-{
-    gravitys.x = Alpha * gravitys.x + ( 1 - Alpha ) * x;
-    gravitys.y = Alpha * gravitys.y + ( 1 - Alpha ) * y;
-    gravitys.z = Alpha * gravitys.z + ( 1 - Alpha ) * z;
-
-    linear_accelation.x = x - gravitys.x;
-    linear_accelation.y = y - gravitys.y;
-    linear_accelation.z = z - gravitys.z;
-
-       printf("[gravitys x=%f y=%f z=%f] [linear acc x=%f y=%f z=%f]\n", 
-            gravitys.x, gravitys.y, gravitys.z, 
-            linear_accelation.x, linear_accelation.y, linear_accelation.z);
-}
-
-static void sig_quit(int signo)
-{
-       if(mainloop)
-       {
-               g_main_loop_quit(mainloop);
-       }
-}
-
-int main(int argc, char *argv[])
-{
-       int type = SENSOR_ACCELEROMETER;
-       sensor_h handle;
-    bool is_supported;
-       
-       float max = 0, min = 0, res = 0;
-
-       if(sensor_is_supported(type, &is_supported) != SENSOR_ERROR_NONE){
-               printf("unknown error\n");
-               return 0;
-       }
-    if(!is_supported){
-               printf("unsupported sensor\n");
-               return 0;
-    }
-
-       signal(SIGINT, sig_quit);
-       signal(SIGTERM, sig_quit);
-       signal(SIGQUIT, sig_quit);
-
-       mainloop = g_main_loop_new(NULL, FALSE);
-
-       if(sensor_get_spec(type, &max, &min, &res) == SENSOR_ERROR_NONE){
-               printf("max=%f, min=%f, res=%f\n", max, min, res);
-    }else{
-        printf("Error!!!!\n");
-    }
-
-       sensor_create(&handle);
-
-    sensor_accelerometer_set_cb(handle, 0, test_accelerometer_cb, NULL);
-
-       if(sensor_start(handle, type) == SENSOR_ERROR_NONE)
-               printf("Success start \n");
-
-       g_main_loop_run(mainloop);
-       g_main_loop_unref(mainloop);
-
-    sensor_accelerometer_unset_cb(handle);
-
-       if(sensor_stop(handle, type) == SENSOR_ERROR_NONE)
-               printf("Success stop \n");
-
-       sensor_destroy(handle);
-       return 0;
-}
diff --git a/test/gyroscope-calc-anger.c b/test/gyroscope-calc-anger.c
deleted file mode 100644 (file)
index 9dfa9b7..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * 
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- * PROPRIETARY/CONFIDENTIAL
- * 
- * This software is the confidential and proprietary information of SAMSUNG 
- * ELECTRONICS ("Confidential Information"). You agree and acknowledge that 
- * this software is owned by Samsung and you shall not disclose such 
- * Confidential Information and shall use it only in accordance with the terms 
- * of the license agreement you entered into with SAMSUNG ELECTRONICS. SAMSUNG 
- * make no representations or warranties about the suitability of the software, 
- * either express or implied, including but not limited to the implied 
- * warranties of merchantability, fitness for a particular purpose, or 
- * non-infringement. SAMSUNG shall not be liable for any damages suffered by 
- * licensee arising out of or related to this software.
- * 
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <glib.h>
-#include <sensors.h>
-#include <time.h>
-
-struct xyz_axis {
-    float x,y,z;
-};
-
-static struct xyz_axis angles = {0,0,0};
-static time_t timestamp = 0;
-
-static GMainLoop *mainloop;
-
-static void test_gyroscope_cb(sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data)
-{
-    time_t current_timestamp = time(0);
-    if(timestamp != 0){
-        const float dT = difftime(current_timestamp, timestamp);
-        angles.x += x * dT;
-        angles.y += y * dT;
-        angles.z += z * dT;
-        printf("angle x=%f y=%f z=%f\n", angles.x, angles.y, angles.z);
-    }
-    timestamp = current_timestamp;
-}
-
-static void sig_quit(int signo)
-{
-       if(mainloop)
-       {
-               g_main_loop_quit(mainloop);
-       }
-}
-
-int main(int argc, char *argv[])
-{
-       int type = SENSOR_GYROSCOPE;
-       sensor_h handle;
-    bool is_supported;
-       
-       float max = 0, min = 0, res = 0;
-
-       if(sensor_is_supported(type, &is_supported) != SENSOR_ERROR_NONE){
-               printf("unknown error\n");
-               return 0;
-       }
-    if(!is_supported){
-               printf("unsupported sensor\n");
-               return 0;
-    }
-
-       signal(SIGINT, sig_quit);
-       signal(SIGTERM, sig_quit);
-       signal(SIGQUIT, sig_quit);
-
-       mainloop = g_main_loop_new(NULL, FALSE);
-
-       if(sensor_get_spec(type, &max, &min, &res) == SENSOR_ERROR_NONE){
-               printf("max=%f, min=%f, res=%f\n", max, min, res);
-    }else{
-        printf("Error!!!!\n");
-    }
-
-       sensor_create(&handle);
-
-    sensor_gyroscope_set_cb(handle, 0, test_gyroscope_cb, NULL);
-
-       if(sensor_start(handle, type) == SENSOR_ERROR_NONE)
-               printf("Success start \n");
-
-       g_main_loop_run(mainloop);
-       g_main_loop_unref(mainloop);
-
-    sensor_gyroscope_unset_cb(handle);
-
-       if(sensor_stop(handle, type) == SENSOR_ERROR_NONE)
-               printf("Success stop \n");
-
-       sensor_destroy(handle);
-       return 0;
-}
diff --git a/test/rotation.c b/test/rotation.c
deleted file mode 100644 (file)
index 2d40b49..0000000
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * 
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- * PROPRIETARY/CONFIDENTIAL
- * 
- * This software is the confidential and proprietary information of SAMSUNG 
- * ELECTRONICS ("Confidential Information"). You agree and acknowledge that 
- * this software is owned by Samsung and you shall not disclose such 
- * Confidential Information and shall use it only in accordance with the terms 
- * of the license agreement you entered into with SAMSUNG ELECTRONICS. SAMSUNG 
- * make no representations or warranties about the suitability of the software, 
- * either express or implied, including but not limited to the implied 
- * warranties of merchantability, fitness for a particular purpose, or 
- * non-infringement. SAMSUNG shall not be liable for any damages suffered by 
- * licensee arising out of or related to this software.
- * 
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <glib.h>
-#include <sensors.h>
-#include <math.h>
-
-#define RADIAN_VALUE (57.2957)
-#define PITCH_MIN       35
-#define PITCH_MAX       145
-
-
-static GMainLoop *mainloop;
-
-const float Alpha = 0.8;
-
-struct three_axis_s{
-    float x,y,z;
-};
-
-struct three_axis_s gravitys = {0,0,0};
-struct three_axis_s linear_accelation = {0,0,0};
-
-enum {
-    ROTATE_0,
-    ROTATE_90,
-    ROTATE_180,
-    ROTATE_270,
-    ROTATE_ERROR
-};
-
-static int current_rotate = -1;
-
-static void test_accelerometer_cb(sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data)
-{
-    double atan_v, norm_z, raw_z;
-    int acc_theta, acc_pitch;
-    int rotate;
-
-    atan_v = atan2(y, x);
-    acc_theta = (int)(atan_v * (RADIAN_VALUE) + 270)%360;
-    raw_z = (double)(z/(0.004 * 9.81));
-
-    if(raw_z > 250){
-        norm_z = 1.0;
-    }else if(raw_z < -250){
-        norm_z = -1.0;
-    }else{
-        norm_z = ((double)raw_z)/250;
-    }
-
-    acc_pitch = (int)( acos(norm_z) *(RADIAN_VALUE));
-
-    if( (acc_pitch>35) && (acc_pitch<145) ) {
-        if ((acc_theta >= 315 && acc_theta <=359) || (acc_theta >=0 && acc_theta < 45)){
-            rotate = ROTATE_0;
-        }
-        else if(acc_theta >= 45 && acc_theta < 135){
-            rotate = ROTATE_90;
-        }
-        else if(acc_theta >=135 && acc_theta < 225){
-            rotate = ROTATE_180;
-        }
-        else if(acc_theta >=225 && acc_theta < 315){
-            rotate = ROTATE_270;
-        }
-        else {
-            rotate = ROTATE_ERROR;
-        }
-    }else{
-        rotate = ROTATE_ERROR;
-    }
-
-    if(rotate != ROTATE_ERROR && current_rotate != rotate){
-        current_rotate = rotate;
-        printf("rotation is %d\n", rotate * 90);
-    }
-}
-
-static void sig_quit(int signo)
-{
-       if(mainloop)
-       {
-               g_main_loop_quit(mainloop);
-       }
-}
-
-int main(int argc, char *argv[])
-{
-       int type = SENSOR_ACCELEROMETER;
-       sensor_h handle;
-    bool is_supported;
-       
-       float max = 0, min = 0, res = 0;
-
-       if(sensor_is_supported(type, &is_supported) != SENSOR_ERROR_NONE){
-               printf("unknown error\n");
-               return 0;
-       }
-    if(!is_supported){
-               printf("unsupported sensor\n");
-               return 0;
-    }
-
-       signal(SIGINT, sig_quit);
-       signal(SIGTERM, sig_quit);
-       signal(SIGQUIT, sig_quit);
-
-       mainloop = g_main_loop_new(NULL, FALSE);
-
-       if(sensor_get_spec(type, &max, &min, &res) == SENSOR_ERROR_NONE){
-               printf("max=%f, min=%f, res=%f\n", max, min, res);
-    }else{
-        printf("Error!!!!\n");
-    }
-
-       sensor_create(&handle);
-
-    sensor_accelerometer_set_cb(handle, 0, test_accelerometer_cb, NULL);
-
-       if(sensor_start(handle, type) == SENSOR_ERROR_NONE)
-               printf("Success start \n");
-
-       g_main_loop_run(mainloop);
-       g_main_loop_unref(mainloop);
-
-    sensor_accelerometer_unset_cb(handle);
-
-       if(sensor_stop(handle, type) == SENSOR_ERROR_NONE)
-               printf("Success stop \n");
-
-       sensor_destroy(handle);
-       return 0;
-}
diff --git a/test/supported-sensor.c b/test/supported-sensor.c
deleted file mode 100644 (file)
index 739dadc..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- * PROPRIETARY/CONFIDENTIAL
- * 
- * This software is the confidential and proprietary information of SAMSUNG 
- * ELECTRONICS ("Confidential Information"). You agree and acknowledge that 
- * this software is owned by Samsung and you shall not disclose such 
- * Confidential Information and shall use it only in accordance with the terms 
- * of the license agreement you entered into with SAMSUNG ELECTRONICS. SAMSUNG 
- * make no representations or warranties about the suitability of the software, 
- * either express or implied, including but not limited to the implied 
- * warranties of merchantability, fitness for a particular purpose, or 
- * non-infringement. SAMSUNG shall not be liable for any damages suffered by 
- * licensee arising out of or related to this software.
- * 
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sensors.h>
-
-static char* TYPE_NAME[] = {
-       "ACCELEROMETER",
-       "MAGNETIC",
-       "ORIENTATION",
-       "GYROSCOPE",
-       "LIGHT",
-       "PROXIMITY",
-       "MOTION_SNAP",
-       "MOTION_SHAKE",
-       "MOTION_DOUBLETAP",
-       "MOTION_PANNING",
-       "MOTION_FACEDOWN"
-};
-
-int main(int argc, char *argv[])
-{
-       int err;
-    sensor_type_e type;
-    bool is_supported;
-    char* supported_msg;
-       
-    for(type=0; type<=SENSOR_MOTION_FACEDOWN; type++){
-        err = sensor_is_supported(type, &is_supported);
-
-        supported_msg = err < 0 ? "error" : (is_supported ? "support" : "not support");
-
-        printf("%d : %s [%s]\n", type, TYPE_NAME[type], supported_msg);
-    }
-    return 0;
-
-}
diff --git a/test/system-sensor.c b/test/system-sensor.c
deleted file mode 100644 (file)
index 5a29ed7..0000000
+++ /dev/null
@@ -1,270 +0,0 @@
-/*
- * 
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- * PROPRIETARY/CONFIDENTIAL
- * 
- * This software is the confidential and proprietary information of SAMSUNG 
- * ELECTRONICS ("Confidential Information"). You agree and acknowledge that 
- * this software is owned by Samsung and you shall not disclose such 
- * Confidential Information and shall use it only in accordance with the terms 
- * of the license agreement you entered into with SAMSUNG ELECTRONICS. SAMSUNG 
- * make no representations or warranties about the suitability of the software, 
- * either express or implied, including but not limited to the implied 
- * warranties of merchantability, fitness for a particular purpose, or 
- * non-infringement. SAMSUNG shall not be liable for any damages suffered by 
- * licensee arising out of or related to this software.
- * 
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <glib.h>
-#include <sensors.h>
-
-static GMainLoop *mainloop;
-
-static char* TYPE_NAME[] = {
-       "ACCELEROMETER",
-       "MAGNETIC",
-       "ORIENTATION",
-       "GYROSCOPE",
-       "LIGHT",
-       "PROXIMITY",
-       "MOTION_SNAP",
-       "MOTION_SHAKE",
-       "MOTION_DOUBLETAP",
-       "MOTION_PANNING",
-       "MOTION_FACEDOWN"
-};
-
-static char* SNAP[] = {
-       "NONE",
-    "LEFT",
-    "RIGHT"
-};
-
-static char* SHAKE[] = {
-       "NONE",
-       "DETECTION",
-       "CONTINUING",
-       "FINISH",
-       "BREAK"
-};
-
-static void test_calibration_cb(void *user_data)
-{
-    char* xx = (char*)user_data;
-       printf("%s sensor is calibration needed!!!!!!!!!!!!!!!!!!\n", xx);
-}
-
-static void test_accelerometer_cb(sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data)
-{
-       printf("ACCELEROMETER sensor acc=%d x=%f y=%f z=%f\n", accuracy, x, y, z);
-}
-
-static void test_magnetic_cb(sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data)
-{
-       printf("MAGNETIC sensor acc=%d x=%f y=%f z=%f\n", accuracy, x, y, z);
-}
-
-static void test_orientation_cb(sensor_data_accuracy_e accuracy, float azimuth, float pitch, float roll, void *user_data)
-{
-       printf("ORIENTATION sensor acc=%d azimuth=%f pitch=%f roll=%f\n", accuracy, azimuth, pitch, roll);
-}
-
-static void test_gyroscope_cb(sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data)
-{
-       printf("GYROSCOPE sensor acc=%d x=%f y=%f z=%f\n", accuracy, x, y, z);
-}
-
-static void test_light_cb(sensor_data_accuracy_e accuracy, float lux, void *user_data)
-{
-       printf("LIGHT sensor acc=%d lux=%f\n", accuracy, lux);
-}
-
-static void test_proximity_cb(sensor_data_accuracy_e accuracy, float distance, void *user_data)
-{
-       printf("PROXIMITY sensor distance = %fcm\n", distance);
-}
-
-static void test_motion_snap_cb        (sensor_motion_snap_e snap, void *user_data)
-{
-       printf("MOTION_SNAP [%s]\n", SNAP[snap]);
-}
-
-static void test_motion_shake_cb       (sensor_motion_shake_e shake, void *user_data)
-{
-       printf("MOTION_SHAKE [%s]\n", SHAKE[shake]);
-}
-
-static void test_motion_doubletap_cb   (void *user_data)
-{
-       printf("MOTION_DOUBLETAP \n");
-}
-
-static void test_motion_panning_cb (int x, int y, void *user_data)
-{
-       printf("MOTION_PANNING x=[%5d] y=[%5d]\n", x, y);
-}
-
-static void test_motion_facedown_cb (void *user_data)
-{
-       printf("MOTION_FACEDOWN \n");
-}
-
-static void sig_quit(int signo)
-{
-       if(mainloop)
-       {
-               g_main_loop_quit(mainloop);
-       }
-}
-
-int main(int argc, char *argv[])
-{
-       int i;
-       int type;
-       sensor_h handle;
-    bool is_supported;
-       
-       float max = 0, min = 0, res = 0;
-
-       if(argc < 2)
-       {
-               printf("input sensor type\n");
-               for(i=0; i<=SENSOR_MOTION_FACEDOWN; i++){
-                       printf("%d : %s\n", i, TYPE_NAME[i]);
-               }
-               return 0;
-       }
-
-       type = atoi(argv[1]);
-    /*
-       if(sensor_is_supported(type, &is_supported) != SENSOR_ERROR_NONE){
-               printf("unknown error\n");
-               return 0;
-       }
-    if(!is_supported){
-               printf("unsupported sensor\n");
-               return 0;
-    }
-    */
-
-    if(type < 0 || type > SENSOR_MOTION_FACEDOWN)
-               printf("unknown sensor!\n");
-    else
-               printf("selected sensor is (%d)%s\n", type, TYPE_NAME[type]);
-
-       signal(SIGINT, sig_quit);
-       signal(SIGTERM, sig_quit);
-       signal(SIGQUIT, sig_quit);
-
-       mainloop = g_main_loop_new(NULL, FALSE);
-
-
-    if(type < SENSOR_MOTION_SNAP){
-        if(sensor_get_spec(type, &max, &min, &res) == SENSOR_ERROR_NONE){
-            printf("max=%f, min=%f, res=%f\n", max, min, res);
-        }else{
-            printf("Error!!!!\n");
-        }
-    }
-
-       sensor_create(&handle);
-
-       switch(type){
-               case SENSOR_ACCELEROMETER:
-                       sensor_accelerometer_set_cb(handle, 0, test_accelerometer_cb, TYPE_NAME[type]);
-                       break;
-               case SENSOR_MAGNETIC:
-                       sensor_magnetic_set_cb(handle, 0, test_magnetic_cb, TYPE_NAME[type]);
-                       sensor_magnetic_set_calibration_cb(handle, test_calibration_cb, TYPE_NAME[type]);
-                       break;
-               case SENSOR_ORIENTATION:
-                       sensor_orientation_set_cb(handle, 0, test_orientation_cb, TYPE_NAME[type]);
-                       sensor_orientation_set_calibration_cb(handle, test_calibration_cb, TYPE_NAME[type]);
-                       break;
-               case SENSOR_GYROSCOPE:
-                       sensor_gyroscope_set_cb(handle, 0, test_gyroscope_cb, TYPE_NAME[type]);
-                       break;
-               case SENSOR_LIGHT:
-                       sensor_light_set_cb(handle, 0, test_light_cb, TYPE_NAME[type]);
-                       break;
-               case SENSOR_PROXIMITY:
-                       sensor_proximity_set_cb(handle, 0, test_proximity_cb, TYPE_NAME[type]);
-                       break;
-               case SENSOR_MOTION_SNAP:
-                       sensor_motion_snap_set_cb(handle, test_motion_snap_cb, TYPE_NAME[type]);
-                       break;
-               case SENSOR_MOTION_SHAKE:
-                       sensor_motion_shake_set_cb(handle, test_motion_shake_cb, TYPE_NAME[type]);
-                       break;
-               case SENSOR_MOTION_DOUBLETAP:
-                       sensor_motion_doubletap_set_cb(handle, test_motion_doubletap_cb, TYPE_NAME[type]);
-                       break;
-               case SENSOR_MOTION_PANNING:
-            sensor_motion_panning_set_cb(handle, test_motion_panning_cb, TYPE_NAME[type]);
-                       break;
-               case SENSOR_MOTION_FACEDOWN:
-            sensor_motion_facedown_set_cb(handle, test_motion_facedown_cb, TYPE_NAME[type]);
-                       break;
-               default:
-                       goto _ending;
-       }
-
-    printf("Success register callback \n");
-
-       if(sensor_start(handle, type) == SENSOR_ERROR_NONE)
-               printf("Success start \n");
-
-       g_main_loop_run(mainloop);
-       g_main_loop_unref(mainloop);
-
-       switch(type){
-               case SENSOR_ACCELEROMETER:
-            sensor_accelerometer_unset_cb(handle);
-                       break;
-               case SENSOR_MAGNETIC:
-            sensor_magnetic_unset_calibration_cb(handle);
-            sensor_magnetic_unset_cb(handle);
-                       break;
-               case SENSOR_ORIENTATION:
-                       sensor_orientation_unset_calibration_cb(handle);
-            sensor_orientation_unset_cb(handle);
-                       break;
-               case SENSOR_GYROSCOPE:
-            sensor_gyroscope_unset_cb(handle);
-                       break;
-               case SENSOR_LIGHT:
-            sensor_light_unset_cb(handle);
-                       break;
-               case SENSOR_PROXIMITY:
-            sensor_proximity_unset_cb(handle);
-                       break;
-               case SENSOR_MOTION_SNAP:
-            sensor_motion_snap_unset_cb(handle);
-                       break;
-               case SENSOR_MOTION_SHAKE:
-            sensor_motion_shake_unset_cb(handle);
-                       break;
-               case SENSOR_MOTION_DOUBLETAP:
-            sensor_motion_doubletap_unset_cb(handle);
-                       break;
-               case SENSOR_MOTION_PANNING:
-            sensor_motion_panning_unset_cb(handle);
-                       break;
-               case SENSOR_MOTION_FACEDOWN:
-            sensor_motion_facedown_unset_cb(handle);
-                       break;
-
-               default:
-                       goto _ending;
-       }
-
-       if(sensor_stop(handle, type) == SENSOR_ERROR_NONE)
-               printf("Success stop \n");
-
-_ending:
-       sensor_destroy(handle);
-       return 0;
-}