sensor-hal-tm1: remove useless package dependency
authorkibak.yoon <kibak.yoon@samsung.com>
Wed, 29 Jun 2016 08:07:36 +0000 (17:07 +0900)
committerkibak.yoon <kibak.yoon@samsung.com>
Wed, 29 Jun 2016 09:13:35 +0000 (18:13 +0900)
- HAL does not use vconf/glib package
- reorder macro constants
- fix error logs

Change-Id: If132ef8b344652b4c06c87e42512c2b18e5e7b25
Signed-off-by: kibak.yoon <kibak.yoon@samsung.com>
CMakeLists.txt
packaging/sensor-hal-tm1.spec
src/accel/accel_device.cpp
src/proxi/proxi_device.cpp

index 390f4a9..818b939 100644 (file)
@@ -17,7 +17,7 @@ MESSAGE("FLAGS: ${CMAKE_EXE_LINKER_FLAGS}")
 #ADD_DEFINITIONS(-Wall -g -D_DEBUG)
 
 INCLUDE(FindPkgConfig)
-PKG_CHECK_MODULES(HAL_PKGS REQUIRED dlog glib-2.0 gio-2.0 gobject-2.0 vconf)
+PKG_CHECK_MODULES(HAL_PKGS REQUIRED dlog)
 
 FOREACH(flag ${HAL_PKGS_CFLAGS})
        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
index 9e755be..3d6f7fd 100644 (file)
@@ -15,9 +15,6 @@ ExcludeArch: %{arm} aarch64 %ix86 x86_64
 
 BuildRequires:  cmake
 BuildRequires:  pkgconfig(dlog)
-BuildRequires:  pkgconfig(glib-2.0)
-BuildRequires:  pkgconfig(gio-2.0)
-BuildRequires:  pkgconfig(vconf)
 BuildRequires:  sensor-hal-devel
 
 %description
index ca696db..a887c09 100644 (file)
 
 #include "accel_device.h"
 
-#define GRAVITY 9.80665
-#define G_TO_MG 1000
-#define RAW_DATA_TO_G_UNIT(X) (((float)(X))/((float)G_TO_MG))
-#define RAW_DATA_TO_METRE_PER_SECOND_SQUARED_UNIT(X) (GRAVITY * (RAW_DATA_TO_G_UNIT(X)))
-
-#define MIN_RANGE(RES) (-((1 << (RES))/2))
-#define MAX_RANGE(RES) (((1 << (RES))/2)-1)
-
 #define MODEL_NAME "K2HH"
 #define VENDOR "ST Microelectronics"
 #define RESOLUTION 16
 #define INPUT_NAME     "accelerometer_sensor"
 #define ACCEL_SENSORHUB_POLL_NODE_NAME "accel_poll_delay"
 
+#define GRAVITY 9.80665
+#define G_TO_MG 1000
+#define RAW_DATA_TO_G_UNIT(X) (((float)(X))/((float)G_TO_MG))
+#define RAW_DATA_TO_METRE_PER_SECOND_SQUARED_UNIT(X) (GRAVITY * (RAW_DATA_TO_G_UNIT(X)))
+
+#define MIN_RANGE(RES) (-((1 << (RES))/2))
+#define MAX_RANGE(RES) (((1 << (RES))/2)-1)
+
 static sensor_info_t sensor_info = {
        id: 0x1,
        name: SENSOR_NAME,
@@ -124,7 +124,7 @@ accel_device::accel_device()
                };
        }
 
-       _I("accel_sensor is created!");
+       _I("accel_device is created!");
 }
 
 accel_device::~accel_device()
@@ -132,10 +132,10 @@ accel_device::~accel_device()
        close(m_node_handle);
        m_node_handle = -1;
 
-       _I("accel_sensor is destroyed!");
+       _I("accel_device is destroyed!");
 }
 
-int accel_device::get_poll_fd()
+int accel_device::get_poll_fd(void)
 {
        return m_node_handle;
 }
@@ -320,7 +320,6 @@ int accel_device::read_fd(uint32_t **ids)
 
 int accel_device::get_data(uint32_t id, sensor_data_t **data, int *length)
 {
-       int remains = 1;
        sensor_data_t *sensor_data;
        sensor_data = (sensor_data_t *)malloc(sizeof(sensor_data_t));
        retvm_if(!sensor_data, -ENOMEM, "Memory allocation failed");
@@ -337,12 +336,11 @@ int accel_device::get_data(uint32_t id, sensor_data_t **data, int *length)
        *data = sensor_data;
        *length = sizeof(sensor_data_t);
 
-       return --remains;
+       return 0;
 }
 
 void accel_device::raw_to_base(sensor_data_t *data)
 {
-       data->value_count = 3;
        data->values[0] = RAW_DATA_TO_METRE_PER_SECOND_SQUARED_UNIT(data->values[0] * RAW_DATA_UNIT);
        data->values[1] = RAW_DATA_TO_METRE_PER_SECOND_SQUARED_UNIT(data->values[1] * RAW_DATA_UNIT);
        data->values[2] = RAW_DATA_TO_METRE_PER_SECOND_SQUARED_UNIT(data->values[2] * RAW_DATA_UNIT);
index 211db23..dc81ef8 100644 (file)
@@ -35,6 +35,7 @@
 #define MIN_RANGE 0
 #define MAX_RANGE 5
 #define RESOLUTION 1
+#define RAW_DATA_UNIT 1
 #define MIN_INTERVAL 1
 #define MAX_BATCH_COUNT 0
 
@@ -55,7 +56,7 @@ static sensor_info_t sensor_info = {
        vendor: VENDOR,
        min_range: MIN_RANGE,
        max_range: MAX_RANGE,
-       resolution: RESOLUTION,
+       resolution: RAW_DATA_UNIT,
        min_interval: MIN_INTERVAL,
        max_batch_count: MAX_BATCH_COUNT,
        wakeup_supported: false
@@ -96,16 +97,17 @@ proxi_device::proxi_device()
                throw ENXIO;
        }
 
-       if (m_method == INPUT_EVENT_METHOD) {
-               if (!util::set_monotonic_clock(m_node_handle))
-                       throw ENXIO;
+       if (m_method != INPUT_EVENT_METHOD)
+               throw ENXIO;
 
-               update_value = [=]() {
-                       return this->update_value_input_event();
-               };
-       }
+       if (!util::set_monotonic_clock(m_node_handle))
+               throw ENXIO;
+
+       update_value = [=]() {
+               return this->update_value_input_event();
+       };
 
-       _I("Proxi_sensor_hal is created!");
+       _I("Proxi_device is created!");
 }
 
 proxi_device::~proxi_device()
@@ -113,7 +115,7 @@ proxi_device::~proxi_device()
        close(m_node_handle);
        m_node_handle = -1;
 
-       _I("Proxi_sensor_hal is destroyed!");
+       _I("Proxi_device is destroyed!");
 }
 
 int proxi_device::get_poll_fd(void)
@@ -133,7 +135,7 @@ bool proxi_device::enable(uint32_t id)
        util::set_enable_node(m_enable_node, m_sensorhub_controlled, true, SENSORHUB_PROXIMITY_ENABLE_BIT);
 
        m_fired_time = 0;
-       INFO("Enable proxi sensor");
+       _I("Enable proxi sensor");
        return true;
 }
 
@@ -141,7 +143,7 @@ bool proxi_device::disable(uint32_t id)
 {
        util::set_enable_node(m_enable_node, m_sensorhub_controlled, false, SENSORHUB_PROXIMITY_ENABLE_BIT);
 
-       INFO("Disable proxi sensor");
+       _I("Disable proxi sensor");
        return true;
 }
 
@@ -175,7 +177,7 @@ bool proxi_device::update_value_input_event(void)
 int proxi_device::read_fd(uint32_t **ids)
 {
        if (!update_value()) {
-               DBG("Failed to update value");
+               _D("Failed to update value");
                return false;
        }
 
@@ -189,7 +191,6 @@ int proxi_device::read_fd(uint32_t **ids)
 
 int proxi_device::get_data(uint32_t id, sensor_data_t **data, int *length)
 {
-       int remains = 1;
        sensor_data_t *sensor_data;
        sensor_data = (sensor_data_t *)malloc(sizeof(sensor_data_t));
        retvm_if(!sensor_data, -ENOMEM, "Memory allocation failed");
@@ -202,5 +203,5 @@ int proxi_device::get_data(uint32_t id, sensor_data_t **data, int *length)
        *data = sensor_data;
        *length = sizeof(sensor_data_t);
 
-       return --remains;
+       return 0;
 }