sensor-hal: remove xml dependency and xml-related code
authorMu-Woong Lee <muwoong.lee@samsung.com>
Wed, 3 Feb 2016 07:47:36 +0000 (16:47 +0900)
committerMu-Woong Lee <muwoong.lee@samsung.com>
Wed, 3 Feb 2016 07:47:36 +0000 (16:47 +0900)
- remove xml dependency and clean up code
- sensor-hal: add sensor_properties_s to sensor_handle_t

Change-Id: I7452c08bd3cf793dd08a6ee801722ff0ebc3c5b6
Signed-off-by: kibak.yoon <kibak.yoon@samsung.com>
Signed-off-by: Mu-Woong Lee <muwoong.lee@samsung.com>
14 files changed:
CMakeLists.txt
LICENSE.APLv2
packaging/sensor-plugins-tm1.spec
sensors.xml.in [deleted file]
src/CMakeLists.txt
src/interface/sensor_hal.h
src/interface/sensor_hal_base.cpp
src/interface/sensor_hal_base.h
src/lib/csensor_config.cpp [deleted file]
src/lib/csensor_config.h [deleted file]
src/plugins/accel/accel_sensor_hal.cpp
src/plugins/accel/accel_sensor_hal.h
src/plugins/proxi/proxi_sensor_hal.cpp
src/plugins/proxi/proxi_sensor_hal.h

index f4e5d2d..3e511fe 100644 (file)
@@ -15,10 +15,5 @@ add_definitions(-DLIBDIR="${CMAKE_INSTALL_LIBDIR}")
 # Internal Debugging Options
 #add_definitions(-Wall -g -D_DEBUG)
 
-# Installing files
-CONFIGURE_FILE(sensors.xml.in sensors.xml @ONLY)
-
-INSTALL(FILES sensors.xml DESTINATION etc)
-
 # Sub-directory
 add_subdirectory(src)
index 8534b2c..6b17abb 100644 (file)
@@ -1,4 +1,4 @@
-Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
 
                                  Apache License
                            Version 2.0, January 2004
index 5321ac7..644c42f 100644 (file)
@@ -14,7 +14,6 @@ ExcludeArch: %{arm} aarch64 %ix86 x86_64
 
 BuildRequires:  cmake
 BuildRequires:  pkgconfig(dlog)
-BuildRequires:  pkgconfig(libxml-2.0)
 
 %define accel_state ON
 %define gyro_state OFF
@@ -55,5 +54,4 @@ rm -rf %{buildroot}
 
 %files
 %manifest packaging/%{name}.manifest
-%attr(0644,root,root)/usr/etc/sensors.xml
 %{_libdir}/sensor/*.so
diff --git a/sensors.xml.in b/sensors.xml.in
deleted file mode 100644 (file)
index 31d33cf..0000000
+++ /dev/null
@@ -1,389 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<SENSOR>
-       <ACCEL>
-               <MODEL id="lsm330dlc-accel">
-                       <NAME value="LSM330DLC"/>
-                       <VENDOR value="ST Microelectronics"/>
-                       <RAW_DATA_UNIT value="1" />
-                       <RESOLUTION value="12" />
-               </MODEL>
-
-               <MODEL id="LSM330">
-                       <NAME value="LSM330"/>
-                       <VENDOR value="ST Microelectronics"/>
-                       <RAW_DATA_UNIT value="1" />
-                       <RESOLUTION value="12" />
-               </MODEL>
-
-               <MODEL id="K2HH">
-                       <NAME value="K2HH" />
-                       <VENDOR value="ST Microelectronics"/>
-                       <RAW_DATA_UNIT value="0.122"/>
-                       <RESOLUTION value="16"/>
-               </MODEL>
-
-               <MODEL id="MPU6500">
-                       <NAME value="MPU6500"/>
-                       <VENDOR value="Invensense"/>
-                       <RAW_DATA_UNIT SM-Z910F="0.061" SM-Z9005="0.061" value="0.244"/>
-                       <RESOLUTION value="16" />
-               </MODEL>
-
-               <MODEL id="MPU6515">
-                       <NAME value="MPU6515"/>
-                       <VENDOR value="Invensense"/>
-                       <RAW_DATA_UNIT value="0.061"/>
-                       <RESOLUTION value="16"/>
-               </MODEL>
-
-               <MODEL id="MPU6050">
-                       <NAME value="MPU6050"/>
-                       <VENDOR value="Invensense"/>
-                       <RAW_DATA_UNIT value="0.061"/>
-                       <RESOLUTION value="16"/>
-               </MODEL>
-
-               <MODEL id="MPU6051">
-                       <NAME value="MPU6051"/>
-                       <VENDOR value="Invensense"/>
-                       <RAW_DATA_UNIT value="0.061"/>
-                       <RESOLUTION value="16"/>
-               </MODEL>
-
-               <MODEL id="MPU9250">
-                       <NAME value="MPU9250"/>
-                       <VENDOR value="Invensense"/>
-                       <RAW_DATA_UNIT value="0.244"/>
-                       <RESOLUTION value="16"/>
-               </MODEL>
-
-               <MODEL id="ICM20628">
-                       <NAME value="ICM20628"/>
-                       <VENDOR value="Invensense"/>
-                       <RAW_DATA_UNIT value="0.244" />
-                       <RESOLUTION value="16" />
-               </MODEL>
-
-               <MODEL id="bma222e">
-                       <NAME value="BMA222E"/>
-                       <VENDOR value="BOSCH"/>
-                       <RAW_DATA_UNIT value="15.63"/>
-                       <RESOLUTION value="8"/>
-               </MODEL>
-
-               <MODEL id="BMI160">
-                       <NAME value="BMI160"/>
-                       <VENDOR value="Bosch"/>
-                       <RAW_DATA_UNIT value="0.244"/>
-                       <RESOLUTION value="16"/>
-               </MODEL>
-
-               <MODEL id="maru_sensor_accel_1">
-                       <NAME value="maru_sensor_accel_1"/>
-                       <VENDOR value="Tizen_SDK"/>
-                       <RAW_DATA_UNIT value="0.061"/>
-                       <RESOLUTION value="16"/>
-               </MODEL>
-       </ACCEL>
-
-       <GYRO>
-               <MODEL id="lsm330dlc-gyro">
-                       <NAME value="LSM330DLC"/>
-                       <VENDOR value="ST Microelectronics"/>
-                       <RAW_DATA_UNIT value="17.50"/>
-                       <RESOLUTION value="16"/>
-               </MODEL>
-
-               <MODEL id="LSM330">
-                       <NAME value="LSM330"/>
-                       <VENDOR value="ST Microelectronics"/>
-                       <RAW_DATA_UNIT value="17.50" />
-                       <RESOLUTION value="16" />
-               </MODEL>
-
-               <MODEL id="MPU6500">
-                       <NAME value="MPU6500"/>
-                       <VENDOR value="Invensense"/>
-                       <RAW_DATA_UNIT value="15.26"/>
-                       <RESOLUTION value="16"/>
-               </MODEL>
-
-               <MODEL id="MPU6515">
-                       <NAME value="MPU6515"/>
-                       <VENDOR value="Invensense"/>
-                       <RAW_DATA_UNIT value="15.26"/>
-                       <RESOLUTION value="16"/>
-               </MODEL>
-
-               <MODEL id="MPU6050">
-                       <NAME value="MPU6050"/>
-                       <VENDOR value="Invensense"/>
-                       <RAW_DATA_UNIT value="15.26"/>
-                       <RESOLUTION value="16"/>
-               </MODEL>
-
-               <MODEL id="MPU6051">
-                       <NAME value="MPU6051"/>
-                       <VENDOR value="Invensense"/>
-                       <RAW_DATA_UNIT value="15.26"/>
-                       <RESOLUTION value="16"/>
-               </MODEL>
-
-               <MODEL id="MPU9250">
-                       <NAME value="MPU9250"/>
-                       <VENDOR value="Invensense"/>
-                       <RAW_DATA_UNIT value="15.26"/>
-                       <RESOLUTION value="16"/>
-               </MODEL>
-
-               <MODEL id="ICM20628">
-                       <NAME value="ICM20628"/>
-                       <VENDOR value="Invensense"/>
-                       <RAW_DATA_UNIT value="61.04"/>
-                       <RESOLUTION value="16"/>
-               </MODEL>
-
-               <MODEL id="BMI160">
-                       <NAME value="BMI160"/>
-                       <VENDOR value="Bosch"/>
-                       <RAW_DATA_UNIT value="61.04"/>
-                       <RESOLUTION value="16"/>
-               </MODEL>
-
-               <MODEL id="maru_sensor_gyro_1">
-                       <NAME value="maru_sensor_gyro_1"/>
-                       <VENDOR value="Tizen_SDK"/>
-                       <RAW_DATA_UNIT value="1000"/>
-                       <RESOLUTION value="16"/>
-                       <MIN_RANGE value="-573"/>
-                       <MAX_RANGE value="573"/>
-               </MODEL>
-       </GYRO>
-
-       <PROXI>
-               <MODEL id="taos">
-                       <NAME value="TMD27723"/>
-                       <VENDOR value="TAOS"/>
-               </MODEL>
-
-               <MODEL id="TMD3782">
-                       <NAME value="TMD3782"/>
-                       <VENDOR value="TAOS"/>
-               </MODEL>
-
-               <MODEL id="gp2a">
-                       <NAME value="GP2AP020"/>
-                       <VENDOR value="Sharp"/>
-               </MODEL>
-
-               <MODEL id="gp2ap002s">
-                       <NAME value="GP2AP002S"/>
-                       <VENDOR value="Sharp"/>
-               </MODEL>
-
-               <MODEL id="CM36651">
-                       <NAME value="CM36651"/>
-                       <VENDOR value="Capella"/>
-               </MODEL>
-
-               <MODEL id="MAX88922">
-                       <NAME value="MAX88922"/>
-                       <VENDOR value="MAXIM"/>
-               </MODEL>
-
-               <MODEL id="IMS1911">
-                       <NAME value="IMS1911"/>
-                       <VENDOR value="ITM"/>
-               </MODEL>
-
-               <MODEL id="maru_sensor_proxi_1">
-                       <NAME value="maru_sensor_proxi_1"/>
-                       <VENDOR value="Tizen_SDK"/>
-               </MODEL>
-       </PROXI>
-
-       <LIGHT>
-               <MODEL id="taos">
-                       <NAME value="TMD27723"/>
-                       <VENDOR value="TAOS"/>
-               </MODEL>
-
-               <MODEL id="TMD3782">
-                       <NAME value="TMD3782"/>
-                       <VENDOR value="TAOS"/>
-               </MODEL>
-
-               <MODEL id="gp2a">
-                       <NAME value="GP2AP020"/>
-                       <VENDOR value="Sharp"/>
-               </MODEL>
-
-               <MODEL id="CM36651">
-                       <NAME value="CM36651"/>
-                       <VENDOR value="Capella"/>
-               </MODEL>
-
-               <MODEL id="MAX88922">
-                       <NAME value="MAX88922"/>
-                       <VENDOR value="MAXIM"/>
-               </MODEL>
-
-               <MODEL id="AL3320">
-                       <NAME value="AL3320"/>
-                       <VENDOR value="LITEON"/>
-               </MODEL>
-
-               <MODEL id="BH1733">
-                       <NAME value="BH1733"/>
-                       <VENDOR value="ROHM"/>
-               </MODEL>
-
-               <MODEL id="maru_sensor_light_1">
-                       <NAME value="maru_sensor_light_1"/>
-                       <VENDOR value="Tizen_SDK"/>
-               </MODEL>
-       </LIGHT>
-
-       <MAGNETIC>
-               <MODEL id="AK8975C">
-                       <NAME value="AK8975C" />
-                       <VENDOR value="AKM"/>
-                       <RAW_DATA_UNIT value="0.06"/>
-                       <MIN_RANGE value="-1200"/>
-                       <MAX_RANGE value="1200"/>
-               </MODEL>
-
-               <MODEL id="AK09911C">
-                       <NAME value="AK09911C"/>
-                       <VENDOR value="AKM"/>
-                       <RAW_DATA_UNIT value="0.06"/>
-                       <MIN_RANGE value="-4900"/>
-                       <MAX_RANGE value="4900"/>
-               </MODEL>
-
-               <MODEL id="ak8975">
-                       <NAME value="AK8975"/>
-                       <VENDOR value="AKM"/>
-                       <RAW_DATA_UNIT value="0.03"/>
-                       <MIN_RANGE value="-1200"/>
-                       <MAX_RANGE value="1200"/>
-               </MODEL>
-
-               <MODEL id="MPU9250">
-                       <NAME value="MPU9250"/>
-                       <VENDOR value="Invensense"/>
-                       <RAW_DATA_UNIT value="1.0"/>
-                       <MIN_RANGE value="-4800"/>
-                       <MAX_RANGE value="4800"/>
-               </MODEL>
-
-               <MODEL id="YAS537">
-                       <NAME value="YAS537"/>
-                       <VENDOR value="Yamaha"/>
-                       <RAW_DATA_UNIT value="0.1"/>
-                       <MIN_RANGE value="-4800"/>
-                       <MAX_RANGE value="4800"/>
-               </MODEL>
-
-               <MODEL id="maru_sensor_geo_1">
-                       <NAME value="maru_sensor_geo_1"/>
-                       <VENDOR value="Tizen_SDK"/>
-                       <RAW_DATA_UNIT value="0.6"/>
-                       <RESOLUTION value="14"/>
-                       <MIN_RANGE value="-2000"/>
-                       <MAX_RANGE value="2000"/>
-               </MODEL>
-       </MAGNETIC>
-
-       <PRESSURE>
-               <MODEL id="LPS25H">
-                       <NAME value="LPS25H"/>
-                       <VENDOR value="ST Microelectronics"/>
-                       <RAW_DATA_UNIT value="0.000244"/>
-                       <MIN_RANGE value="260"/>
-                       <MAX_RANGE value="1260"/>
-                       <RESOLUTION value="1"/>
-                       <TEMPERATURE_RESOLUTION value="0.002083"/>
-                       <TEMPERATURE_OFFSET value="42.5"/>
-               </MODEL>
-
-               <MODEL id="LPS331">
-                       <NAME value="LPS331"/>
-                       <VENDOR value="ST Microelectronics"/>
-                       <RAW_DATA_UNIT value="0.000244"/>
-                       <MIN_RANGE value="260"/>
-                       <MAX_RANGE value="1260"/>
-                       <RESOLUTION value="1"/>
-                       <TEMPERATURE_RESOLUTION value="0.002083"/>
-                       <TEMPERATURE_OFFSET value="42.5"/>
-               </MODEL>
-               <MODEL id="maru_sensor_pressure_1">
-                       <NAME value="maru_sensor_pressure_1" />
-                       <VENDOR value="Tizen_SDK"/>
-                       <RAW_DATA_UNIT value="0.0193"/>
-                       <MIN_RANGE value="260"/>
-                       <MAX_RANGE value="1260"/>
-                       <RESOLUTION value="1"/>
-                       <TEMPERATURE_RESOLUTION value="0.05"/>
-                       <TEMPERATURE_OFFSET value="0"/>
-               </MODEL>
-       </PRESSURE>
-
-       <TEMPERATURE>
-               <MODEL id="LPS331">
-                       <NAME value="LPS331" />
-                       <VENDOR value="ST Microelectronics"/>
-                       <RAW_DATA_UNIT value="0.01"/>
-                       <RESOLUTION value="1"/>
-               </MODEL>
-
-               <MODEL id="SHTC1">
-                       <NAME value="SHTC1" />
-                       <VENDOR value="SENSIRION"/>
-                       <RAW_DATA_UNIT value="0.01"/>
-                       <RESOLUTION value="1"/>
-               </MODEL>
-       </TEMPERATURE>
-
-       <HUMIDITY>
-               <MODEL id="SHTC1">
-                       <NAME value="SHTC1" />
-                       <VENDOR value="SENSIRION"/>
-                       <RAW_DATA_UNIT value="0.01"/>
-                       <MIN_RANGE value="-10"/>
-                       <MAX_RANGE value="110"/>
-                       <RESOLUTION value="1"/>
-               </MODEL>
-       </HUMIDITY>
-
-       <ULTRAVIOLET>
-               <MODEL id="UVIS25">
-                       <NAME value="UVIS25" />
-                       <VENDOR value="STM"/>
-                       <RAW_DATA_UNIT value="0.0625"/>
-                       <MIN_RANGE value="0"/>
-                       <MAX_RANGE value="15"/>
-               </MODEL>
-               <MODEL id="maru_sensor_uv_1">
-                       <NAME value="maru_sensor_uv_1" />
-                       <VENDOR value="Tizen_SDK"/>
-                       <RAW_DATA_UNIT value="0.1"/>
-                       <MIN_RANGE value="0"/>
-                       <MAX_RANGE value="15"/>
-               </MODEL>
-               <MODEL id="MAX86902_UV">
-                       <NAME value="MAX86902_UV" />
-                       <VENDOR value="MAXIM"/>
-                       <RAW_DATA_UNIT value="0.1"/>
-                       <MIN_RANGE value="0"/>
-                       <MAX_RANGE value="15"/>
-               </MODEL>
-       </ULTRAVIOLET>
-
-       <BIO_LED_RED>
-               <MODEL id="MAX86902">
-                       <NAME value="MAX86902" />
-                       <VENDOR value="MAXIM"/>
-               </MODEL>
-       </BIO_LED_RED>
-</SENSOR>
index 44d2fbb..dfa75cf 100644 (file)
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.6)
 project(sensor-plugins-tm1 CXX)
 
 INCLUDE(FindPkgConfig)
-PKG_CHECK_MODULES(plugin_pkgs REQUIRED dlog libxml-2.0)
+PKG_CHECK_MODULES(plugin_pkgs REQUIRED dlog)
 
 FOREACH(flag ${plugin_pkgs_LDFLAGS})
        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
@@ -74,7 +74,6 @@ configure_file(hal_module_create.cpp.in hal_module_create.cpp)
 add_library(${PROJECT_NAME} SHARED
        ${SRCS}
        lib/cconfig.cpp
-       lib/csensor_config.cpp
        lib/sensor_logs.cpp
        interface/sensor_hal_base.cpp
        interface/sensor_hal.h
index f7623a3..279a869 100644 (file)
@@ -106,6 +106,7 @@ typedef struct sensor_handle_t {
        std::string name;
        sensor_hal_type type;
        unsigned int event_type; // for Internal API
+       sensor_properties_s properties;
 } sensor_handle_t;
 
 /*
index f450a42..15c6443 100644 (file)
@@ -21,7 +21,6 @@
 #include <dirent.h>
 #include <string.h>
 #include <fstream>
-#include <csensor_config.h>
 
 using std::ifstream;
 using std::ofstream;
@@ -229,48 +228,6 @@ bool sensor_hal_base::set_enable_node(const string &node_path, bool sensorhub_co
        return true;
 }
 
-
-bool sensor_hal_base::find_model_id(const string &sensor_type, string &model_id)
-{
-       string dir_path = "/sys/class/sensors/";
-       string name_node, name;
-       string d_name;
-       DIR *dir = NULL;
-       struct dirent *dir_entry = NULL;
-       bool find = false;
-
-       dir = opendir(dir_path.c_str());
-       if (!dir) {
-               DBG("Failed to open dir: %s", dir_path.c_str());
-               return false;
-       }
-
-       while (!find && (dir_entry = readdir(dir))) {
-               d_name = string(dir_entry->d_name);
-
-               if ((d_name != ".") && (d_name != "..") && (dir_entry->d_ino != 0)) {
-                       name_node = dir_path + d_name + string("/name");
-
-                       ifstream infile(name_node.c_str());
-
-                       if (!infile)
-                               continue;
-
-                       infile >> name;
-
-                       if (csensor_config::get_instance().is_supported(sensor_type, name)) {
-                               model_id = name;
-                               find = true;
-                               break;
-                       }
-               }
-       }
-
-       closedir(dir);
-
-       return find;
-}
-
 bool sensor_hal_base::get_event_num(const string &input_path, string &event_num)
 {
        const string event_prefix = "event";
index cabc837..9b18c63 100644 (file)
@@ -74,7 +74,6 @@ protected:
 
        static unsigned long long get_timestamp(void);
        static unsigned long long get_timestamp(timeval *t);
-       static bool find_model_id(const std::string &sensor_type, std::string &model_id);
        static bool is_sensorhub_controlled(const std::string &key);
        static bool get_node_info(const node_info_query &query, node_info &info);
        static void show_node_info(node_info &info);
diff --git a/src/lib/csensor_config.cpp b/src/lib/csensor_config.cpp
deleted file mode 100755 (executable)
index ba8111b..0000000
+++ /dev/null
@@ -1,279 +0,0 @@
-/*
- * libsensord-share
- *
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * 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 <csensor_config.h>
-#include "sensor_logs.h"
-#include <libxml/xmlmemory.h>
-#include <libxml/parser.h>
-#include <sstream>
-#include <iostream>
-#include <fstream>
-#include <string>
-
-using std::ifstream;
-using std::string;
-using std::istringstream;
-
-#define ROOT_ELEMENT   "SENSOR"
-#define TEXT_ELEMENT   "text"
-#define MODEL_ID_ATTR  "id"
-#define DEFAULT_ATTR   "value"
-
-csensor_config::csensor_config()
-{
-}
-
-csensor_config& csensor_config::get_instance(void)
-{
-       static bool load_done = false;
-       static csensor_config inst;
-
-       if (!load_done) {
-               inst.load_config(SENSOR_CONFIG_FILE_PATH);
-               inst.get_device_id();
-               if (!inst.m_device_id.empty())
-                       INFO("Device ID = %s", inst.m_device_id.c_str());
-               else
-                       ERR("Failed to get Device ID");
-               load_done = true;
-       }
-
-       return inst;
-}
-
-bool csensor_config::load_config(const string& config_path)
-{
-       xmlDocPtr doc;
-       xmlNodePtr cur;
-
-       DBG("csensor_config::load_config(\"%s\") is called!\n",config_path.c_str());
-
-       doc = xmlParseFile(config_path.c_str());
-
-       if (doc == NULL) {
-               ERR("There is no %s\n",config_path.c_str());
-               return false;
-       }
-
-       cur = xmlDocGetRootElement(doc);
-       if(cur == NULL) {
-               ERR("There is no root element in %s\n",config_path.c_str());
-               xmlFreeDoc(doc);
-               return false;
-       }
-
-       if(xmlStrcmp(cur->name, (const xmlChar *)ROOT_ELEMENT)) {
-               ERR("Wrong type document: there is no [%s] root element in %s\n",ROOT_ELEMENT,config_path.c_str());
-               xmlFreeDoc(doc);
-               return false;
-       }
-
-       xmlNodePtr model_list_node_ptr;
-       xmlNodePtr model_node_ptr;
-       xmlNodePtr element_node_ptr;
-       xmlAttrPtr attr_ptr;
-       char* prop = NULL;
-
-       model_list_node_ptr = cur->xmlChildrenNode;
-
-       while (model_list_node_ptr != NULL) {
-               //skip garbage element, [text]
-               if (!xmlStrcmp(model_list_node_ptr->name,(const xmlChar *)TEXT_ELEMENT)) {
-                       model_list_node_ptr = model_list_node_ptr->next;
-                       continue;
-               }
-
-               //insert Model_list to config map
-               m_sensor_config[(const char*)model_list_node_ptr->name];
-               DBG("<%s>\n",(const char*)model_list_node_ptr->name);
-
-               model_node_ptr = model_list_node_ptr->xmlChildrenNode;
-               while (model_node_ptr != NULL){
-                       //skip garbage element, [text]
-                       if (!xmlStrcmp(model_node_ptr->name,(const xmlChar *)TEXT_ELEMENT)) {
-                               model_node_ptr = model_node_ptr->next;
-                               continue;
-                       }
-
-
-                       string model_id;
-                       prop = (char*)xmlGetProp(model_node_ptr,(const xmlChar*)MODEL_ID_ATTR);
-                       model_id = prop;
-                       free(prop);
-
-                       //insert Model to Model_list
-                       m_sensor_config[(const char*)model_list_node_ptr->name][model_id];
-                       DBG("<%s id=\"%s\">\n",(const char*)model_list_node_ptr->name,model_id.c_str());
-
-                       element_node_ptr = model_node_ptr->xmlChildrenNode;
-                       while (element_node_ptr != NULL) {
-                               //skip garbage element, [text]
-                               if (!xmlStrcmp(element_node_ptr->name,(const xmlChar *)TEXT_ELEMENT)) {
-                                       element_node_ptr = element_node_ptr->next;
-                                       continue;
-                               }
-
-                               //insert Element to Model
-                               m_sensor_config[(const char*)model_list_node_ptr->name][model_id][(const char*)element_node_ptr->name];
-                               DBG("<%s id=\"%s\"><%s>\n",(const char*)model_list_node_ptr->name,model_id.c_str(),(const char*)element_node_ptr->name);
-
-                               attr_ptr = element_node_ptr->properties;
-                               while (attr_ptr != NULL) {
-
-                                       string key,value;
-                                       key = (char*)attr_ptr->name;
-                                       prop = (char*)xmlGetProp(element_node_ptr,attr_ptr->name);
-                                       value = prop;
-                                       free(prop);
-
-                                       //insert attribute to Element
-                                       m_sensor_config[(const char*)model_list_node_ptr->name][model_id][(const char*)element_node_ptr->name][key]=value;
-                                       DBG("<%s id=\"%s\"><%s \"%s\"=\"%s\">\n",(const char*)model_list_node_ptr->name,model_id.c_str(),(const char*)element_node_ptr->name,key.c_str(),value.c_str());
-                                       attr_ptr = attr_ptr->next;
-                               }
-
-
-                               element_node_ptr = element_node_ptr->next;
-                       }
-
-                       DBG("\n");
-                       model_node_ptr = model_node_ptr->next;
-               }
-
-               DBG("\n");
-               model_list_node_ptr = model_list_node_ptr->next;
-       }
-
-       xmlFreeDoc(doc);
-       return true;
-}
-
-
-bool csensor_config::get(const string& sensor_type,const string& model_id, const string& element, const string& attr, string& value)
-{
-       auto it_model_list = m_sensor_config.find(sensor_type);
-
-       if (it_model_list == m_sensor_config.end())     {
-               ERR("There is no <%s> element\n",sensor_type.c_str());
-               return false;
-       }
-
-       auto it_model = it_model_list->second.find(model_id);
-
-       if (it_model == it_model_list->second.end()) {
-               ERR("There is no <%s id=\"%s\"> element\n",sensor_type.c_str(),model_id.c_str());
-               return false;
-       }
-
-       auto it_element = it_model->second.find(element);
-
-       if (it_element == it_model->second.end()) {
-               DBG("There is no <%s id=\"%s\"><%s> element\n",sensor_type.c_str(),model_id.c_str(),element.c_str());
-               return false;
-       }
-
-       auto it_attr = it_element->second.find(attr);
-
-       if (it_attr == it_element->second.end()) {
-               DBG("There is no <%s id=\"%s\"><%s \"%s\">\n",sensor_type.c_str(),model_id.c_str(),element.c_str(),attr.c_str());
-               return false;
-       }
-
-       value = it_attr->second;
-
-       return true;
-}
-
-bool csensor_config::get(const string& sensor_type, const string& model_id, const string& element, const string& attr, double& value)
-{
-       string str_value;
-
-       if (get(sensor_type,model_id,element,attr,str_value) == false)
-               return false;
-
-       istringstream convert(str_value);
-
-       if ( !(convert >> value))
-               value = 0;
-
-       return true;
-}
-
-bool csensor_config::get(const string& sensor_type, const string& model_id, const string& element, const string& attr, long& value)
-{
-       string str_value;
-
-       if (get(sensor_type,model_id,element,attr,str_value) == false)
-               return false;
-
-       istringstream convert(str_value);
-
-       if ( !(convert >> value))
-               value = 0;
-
-       return true;
-}
-
-bool csensor_config::get(const string& sensor_type, const string& model_id, const string& element, string& value)
-{
-       if (get(sensor_type, model_id, element, m_device_id, value))
-               return true;
-
-       if (get(sensor_type, model_id, element, DEFAULT_ATTR, value))
-               return true;
-
-       return false;
-}
-
-bool csensor_config::get(const string& sensor_type, const string& model_id, const string& element, double& value)
-{
-       if (get(sensor_type, model_id, element, m_device_id, value))
-               return true;
-
-       if (get(sensor_type, model_id, element, DEFAULT_ATTR, value))
-               return true;
-
-       return false;
-}
-
-bool csensor_config::get(const string& sensor_type, const string& model_id, const string& element, long& value)
-{
-       if (get(sensor_type, model_id, element, m_device_id, value))
-               return true;
-
-       if (get(sensor_type, model_id, element, DEFAULT_ATTR, value))
-               return true;
-
-       return false;
-}
-
-bool csensor_config::is_supported(const string& sensor_type,const string& model_id)
-{
-       auto it_model_list = m_sensor_config.find(sensor_type);
-
-       if (it_model_list == m_sensor_config.end())
-               return false;
-
-       auto it_model = it_model_list->second.find(model_id);
-
-       if (it_model == it_model_list->second.end())
-               return false;
-
-       return true;
-}
diff --git a/src/lib/csensor_config.h b/src/lib/csensor_config.h
deleted file mode 100755 (executable)
index 5ce6c74..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * libsensord-share
- *
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * 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.
- *
- */
-
-#if !defined(_CSENSOR_CONFIG_CLASS_H_)
-#define _CSENSOR_CONFIG_CLASS_H_
-
-#include <cconfig.h>
-
-#define SENSOR_CONFIG_FILE_PATH "/usr/etc/sensors.xml"
-
-typedef std::unordered_map<std::string,std::string> Element;
-/*
-* an Element  is a group of attributes
-* <Element value1 = "10.0", value2 =  "20.0"/>
-*
-* "value" -> "LSM330DLC"
-*
-*/
-
-typedef std::unordered_map<std::string,Element> Model;
-/*
-* a Model is a group of elements to consist of  specific vendor's one sensor configuration
-* <NAME value = "LSM330DLC" />
-* <VENDOR value = "ST Microelectronics"/>
-* <RAW_DATA_UNIT value = "1" />
-* <RESOLUTION value = "12" />
-*
-* <NAME> -> <value = "LSM330DLC"/>
-*
-*/
-
-typedef std::unordered_map<std::string,Model> Model_list;
-/*
-* a Model_list is  a group of Model
-* <MODEL id = "lsm330dlc_accel">
-* </MODEL>
-* <MODEL id = "mpu6500">
-* </MODEL>
-*
-* "lsm330dlc_accel" -> <Model>
-*
-*/
-
-typedef std::unordered_map<std::string,Model_list> Sensor_config;
-/*
-* a SensorConfig represents sensors.xml
-* <ACCEL/>
-* <GYRO/>
-* <PROXIMITY/>
-*
-* "ACCEL" -> Model_list
-*
-*/
-
-class csensor_config : public cconfig
-{
-private:
-       csensor_config();
-       csensor_config(csensor_config const&) {};
-       csensor_config& operator=(csensor_config const&);
-
-       bool load_config(const std::string& config_path);
-
-       Sensor_config m_sensor_config;
-public:
-       static csensor_config& get_instance(void);
-
-       bool get(const std::string& sensor_type, const std::string& model_id, const std::string& element, const std::string& attr, std::string& value);
-       bool get(const std::string& sensor_type, const std::string& model_id, const std::string& element, const std::string& attr, double& value);
-       bool get(const std::string& sensor_type, const std::string& model_id, const std::string& element, const std::string& attr, long& value);
-
-       bool get(const std::string& sensor_type, const std::string& model_id, const std::string& element, std::string& value);
-       bool get(const std::string& sensor_type, const std::string& model_id, const std::string& element, double& value);
-       bool get(const std::string& sensor_type, const std::string& model_id, const std::string& element, long& value);
-
-       bool is_supported(const std::string &sensor_type, const std::string &model_id);
-};
-
-#endif
index 21506bd..879e70d 100755 (executable)
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <linux/input.h>
-#include <csensor_config.h>
 #include <accel_sensor_hal.h>
 #include <sys/poll.h>
 
-using std::ifstream;
-using std::string;
-
 #define GRAVITY 9.80665
 #define G_TO_MG 1000
 #define RAW_DATA_TO_G_UNIT(X) (((float)(X))/((float)G_TO_MG))
@@ -36,29 +32,39 @@ using std::string;
 #define MIN_RANGE(RES) (-((1 << (RES))/2))
 #define MAX_RANGE(RES) (((1 << (RES))/2)-1)
 
-#define SENSOR_TYPE_ACCEL              "ACCEL"
-#define ELEMENT_NAME                   "NAME"
-#define ELEMENT_VENDOR                 "VENDOR"
-#define ELEMENT_RAW_DATA_UNIT  "RAW_DATA_UNIT"
-#define ELEMENT_RESOLUTION             "RESOLUTION"
-
-#define ATTR_VALUE                             "value"
-
-#define INPUT_NAME     "accelerometer_sensor"
-#define ACCEL_SENSORHUB_POLL_NODE_NAME "accel_poll_delay"
+#define MODEL_NAME "K2HH"
+#define VENDOR "ST Microelectronics"
+#define RESOLUTION 16
+#define RAW_DATA_UNIT 0.122
+#define MIN_INTERVAL 1
+#define FIFO_COUNT 0
+#define MAX_BATCH_COUNT 0
+
+static const sensor_properties_s accel_properties = {
+       name : MODEL_NAME,
+       vendor : VENDOR,
+       min_range : MIN_RANGE(RESOLUTION) * RAW_DATA_TO_METRE_PER_SECOND_SQUARED_UNIT(RAW_DATA_UNIT),
+       max_range : MAX_RANGE(RESOLUTION) * RAW_DATA_TO_METRE_PER_SECOND_SQUARED_UNIT(RAW_DATA_UNIT),
+       resolution : RAW_DATA_TO_METRE_PER_SECOND_SQUARED_UNIT(RAW_DATA_UNIT),
+       min_interval : MIN_INTERVAL,
+       fifo_count : FIFO_COUNT,
+       max_batch_count : MAX_BATCH_COUNT,
+};
 
 static const sensor_handle_t handles[] = {
        {
                id: 0x1,
                name: "Accelerometer",
                type: SENSOR_HAL_TYPE_ACCELEROMETER,
-               event_type: (SENSOR_HAL_TYPE_ACCELEROMETER << 16) | 0x0001
+               event_type: (SENSOR_HAL_TYPE_ACCELEROMETER << 16) | 0x0001,
+               properties : accel_properties
        },
        {
                id: 0x2,
                name: "Accelerometer RAW",
                type: SENSOR_HAL_TYPE_ACCELEROMETER,
-               event_type: (SENSOR_HAL_TYPE_ACCELEROMETER << 16) | 0x0002
+               event_type: (SENSOR_HAL_TYPE_ACCELEROMETER << 16) | 0x0002,
+               properties : accel_properties
        }
 };
 
@@ -69,20 +75,15 @@ accel_sensor_hal::accel_sensor_hal()
 , m_z(-1)
 , m_polling_interval(0)
 , m_fired_time(0)
+, m_sensorhub_controlled(false)
 {
-       const string sensorhub_interval_node_name = "accel_poll_delay";
-       csensor_config &config = csensor_config::get_instance();
+       const std::string sensorhub_interval_node_name = "accel_poll_delay";
 
        node_info_query query;
        node_info info;
 
-       if (!find_model_id(SENSOR_TYPE_ACCEL, m_model_id)) {
-               ERR("Failed to find model id");
-               throw ENXIO;
-       }
-
        query.sensorhub_controlled = m_sensorhub_controlled = is_sensorhub_controlled(sensorhub_interval_node_name);
-       query.sensor_type = SENSOR_TYPE_ACCEL;
+       query.sensor_type = "ACCEL";
        query.key = "accelerometer_sensor";
        query.iio_enable_node_name = "accel_enable";
        query.sensorhub_interval_node_name = sensorhub_interval_node_name;
@@ -94,71 +95,15 @@ accel_sensor_hal::accel_sensor_hal()
 
        show_node_info(info);
 
-       m_method = info.method;
        m_data_node = info.data_node_path;
        m_enable_node = info.enable_node_path;
        m_interval_node = info.interval_node_path;
 
-       if (!config.get(SENSOR_TYPE_ACCEL, m_model_id, ELEMENT_VENDOR, m_vendor)) {
-               ERR("[VENDOR] is empty\n");
-               throw ENXIO;
-       }
-
-       INFO("m_vendor = %s", m_vendor.c_str());
-
-       if (!config.get(SENSOR_TYPE_ACCEL, m_model_id, ELEMENT_NAME, m_chip_name)) {
-               ERR("[NAME] is empty\n");
-               throw ENXIO;
-       }
-
-       INFO("m_chip_name = %s\n",m_chip_name.c_str());
-
-       long resolution;
-
-       if (!config.get(SENSOR_TYPE_ACCEL, m_model_id, ELEMENT_RESOLUTION, resolution)) {
-               ERR("[RESOLUTION] is empty\n");
-               throw ENXIO;
-       }
-
-       m_resolution = (int)resolution;
-
-       INFO("m_resolution = %d\n",m_resolution);
-
-       double raw_data_unit;
-
-       if (!config.get(SENSOR_TYPE_ACCEL, m_model_id, ELEMENT_RAW_DATA_UNIT, raw_data_unit)) {
-               ERR("[RAW_DATA_UNIT] is empty\n");
-               throw ENXIO;
-       }
-
-       m_raw_data_unit = (float)(raw_data_unit);
-       INFO("m_raw_data_unit = %f\n", m_raw_data_unit);
-
        if ((m_node_handle = open(m_data_node.c_str(), O_RDWR)) < 0) {
                ERR("accel handle open fail for accel processor, error:%s\n", strerror(errno));
                throw ENXIO;
        }
 
-       if (m_method == INPUT_EVENT_METHOD) {
-               int clockId = CLOCK_MONOTONIC;
-               if (ioctl(m_node_handle, EVIOCSCLOCKID, &clockId) != 0)
-                       ERR("Fail to set monotonic timestamp for %s", m_data_node.c_str());
-
-               update_value = [=]() {
-                       return this->update_value_input_event();
-               };
-       } else {
-               if (!info.buffer_length_node_path.empty())
-                       set_node_value(info.buffer_length_node_path, 480);
-
-               if (!info.buffer_enable_node_path.empty())
-                       set_node_value(info.buffer_enable_node_path, 1);
-
-               update_value = [=]() {
-                       return this->update_value_iio();
-               };
-       }
-
        INFO("accel_sensor_hal is created!\n");
 }
 
@@ -186,7 +131,7 @@ bool accel_sensor_hal::enable(uint32_t id)
        set_interval(id, m_polling_interval);
 
        m_fired_time = 0;
-       INFO("Accel sensor real starting");
+       INFO("Enable accelerometer sensor");
        return true;
 }
 
@@ -194,7 +139,7 @@ bool accel_sensor_hal::disable(uint32_t id)
 {
        set_enable_node(m_enable_node, m_sensorhub_controlled, false, SENSORHUB_ACCELEROMETER_ENABLE_BIT);
 
-       INFO("Accel sensor real stopping");
+       INFO("Disable accelerometer sensor");
        return true;
 }
 
@@ -232,7 +177,7 @@ bool accel_sensor_hal::set_command(uint32_t id, std::string command, std::string
 bool accel_sensor_hal::is_data_ready(void)
 {
        bool ret;
-       ret = update_value();
+       ret = update_value_input_event();
        return ret;
 }
 
@@ -306,56 +251,6 @@ bool accel_sensor_hal::update_value_input_event(void)
        return true;
 }
 
-bool accel_sensor_hal::update_value_iio(void)
-{
-       const int READ_LEN = 14;
-       char data[READ_LEN] = {0,};
-
-       struct pollfd pfd;
-
-       pfd.fd = m_node_handle;
-       pfd.events = POLLIN | POLLERR;
-       pfd.revents = 0;
-
-       int ret = poll(&pfd, 1, -1);
-
-       if (ret == -1) {
-               ERR("poll error:%s m_node_handle:d", strerror(errno), m_node_handle);
-               return false;
-       } else if (!ret) {
-               ERR("poll timeout m_node_handle:%d", m_node_handle);
-               return false;
-       }
-
-       if (pfd.revents & POLLERR) {
-               ERR("poll exception occurred! m_node_handle:%d", m_node_handle);
-               return false;
-       }
-
-       if (!(pfd.revents & POLLIN)) {
-               ERR("poll nothing to read! m_node_handle:%d, pfd.revents = %d", m_node_handle, pfd.revents);
-               return false;
-       }
-
-       int len = read(m_node_handle, data, sizeof(data));
-
-       if (len != sizeof(data)) {
-               ERR("Failed to read data, m_node_handle:%d read_len:%d", m_node_handle, len);
-               return false;
-       }
-
-       short *short_data = (short *)(data);
-       m_x = *(short_data);
-       m_y = *((short *)(data + 2));
-       m_z = *((short *)(data + 4));
-
-       m_fired_time = *((long long*)(data + 6));
-
-       INFO("m_x = %d, m_y = %d, m_z = %d, time = %lluus", m_x, m_y, m_z, m_fired_time);
-
-       return true;
-}
-
 bool accel_sensor_hal::get_sensor_data(uint32_t id, sensor_data_t &data)
 {
        data.accuracy = SENSOR_ACCURACY_GOOD;
@@ -392,20 +287,20 @@ int accel_sensor_hal::get_sensor_event(uint32_t id, sensor_event_t **event)
 void accel_sensor_hal::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] * m_raw_data_unit);
-       data.values[1] = RAW_DATA_TO_METRE_PER_SECOND_SQUARED_UNIT(data.values[1] * m_raw_data_unit);
-       data.values[2] = RAW_DATA_TO_METRE_PER_SECOND_SQUARED_UNIT(data.values[2] * m_raw_data_unit);
+       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);
 }
 
 bool accel_sensor_hal::get_properties(uint32_t id, sensor_properties_s &properties)
 {
-       properties.name = m_chip_name;
-       properties.vendor = m_vendor;
-       properties.min_range = MIN_RANGE(m_resolution)* RAW_DATA_TO_METRE_PER_SECOND_SQUARED_UNIT(m_raw_data_unit);
-       properties.max_range = MAX_RANGE(m_resolution)* RAW_DATA_TO_METRE_PER_SECOND_SQUARED_UNIT(m_raw_data_unit);
-       properties.min_interval = 1;
-       properties.resolution = RAW_DATA_TO_METRE_PER_SECOND_SQUARED_UNIT(m_raw_data_unit);
-       properties.fifo_count = 0;
-       properties.max_batch_count = 0;
+       properties.name = MODEL_NAME;
+       properties.vendor = VENDOR;
+       properties.min_range = accel_properties.min_range;
+       properties.max_range = accel_properties.max_range;
+       properties.min_interval = accel_properties.min_interval;
+       properties.resolution = accel_properties.resolution;
+       properties.fifo_count = accel_properties.fifo_count;
+       properties.max_batch_count = accel_properties.max_batch_count;
        return true;
 }
index 6d28da9..923b29a 100755 (executable)
@@ -21,7 +21,6 @@
 #define _ACCEL_SENSOR_HAL_H_
 
 #include <sensor_hal_base.h>
-#include <functional>
 
 class accel_sensor_hal : public sensor_hal_base
 {
@@ -48,26 +47,13 @@ private:
        int m_z;
        unsigned long m_polling_interval;
        unsigned long long m_fired_time;
+       bool m_sensorhub_controlled;
 
-       std::string m_model_id;
-       std::string m_vendor;
-       std::string m_chip_name;
-
-       int m_resolution;
-       float m_raw_data_unit;
-
-       int m_method;
        std::string m_data_node;
        std::string m_enable_node;
        std::string m_interval_node;
 
-       std::function<bool ()> update_value;
-
-       bool m_sensorhub_controlled;
-
        bool update_value_input_event(void);
-       bool update_value_iio(void);
-
        void raw_to_base(sensor_data_t &data);
 };
 #endif /*_ACCEL_SENSOR_HAL_CLASS_H_*/
index cc9e248..ba307b8 100644 (file)
 #include <sys/stat.h>
 #include <dirent.h>
 #include <linux/input.h>
-#include <csensor_config.h>
 #include <proxi_sensor_hal.h>
-#include <sys/ioctl.h>
-#include <fstream>
 
-using std::string;
-using std::ifstream;
-
-#define SENSOR_TYPE_PROXI              "PROXI"
-#define ELEMENT_NAME                   "NAME"
-#define ELEMENT_VENDOR                 "VENDOR"
-#define ATTR_VALUE                             "value"
+#define MODEL_NAME "K2HH"
+#define VENDOR "ST Microelectronics"
+#define MIN_RANGE 0
+#define MAX_RANGE 5
+#define RESOLUTION 1
+#define MIN_INTERVAL 1
+#define FIFO_COUNT 0
+#define MAX_BATCH_COUNT 0
+
+static const sensor_properties_s proxi_properties = {
+       name : MODEL_NAME,
+       vendor : VENDOR,
+       min_range : MIN_RANGE,
+       max_range : MAX_RANGE,
+       resolution : RESOLUTION,
+       min_interval : MIN_INTERVAL,
+       fifo_count : FIFO_COUNT,
+       max_batch_count : MAX_BATCH_COUNT,
+};
+
+static const sensor_handle_t handles[] = {
+       {
+               id: 0x1,
+               name: "Proximity Sensor",
+               type: SENSOR_HAL_TYPE_PROXIMITY,
+               event_type: (SENSOR_HAL_TYPE_PROXIMITY << 16) | 0x0001,
+               properties : proxi_properties
+       }
+};
 
 proxi_sensor_hal::proxi_sensor_hal()
 : m_node_handle(-1)
 , m_state(-1)
 , m_fired_time(0)
+, m_sensorhub_controlled(false)
 {
-       const string sensorhub_interval_node_name = "prox_poll_delay";
-       csensor_config &config = csensor_config::get_instance();
+       const std::string sensorhub_interval_node_name = "prox_poll_delay";
 
        node_info_query query;
        node_info info;
 
-       if (!find_model_id(SENSOR_TYPE_PROXI, m_model_id)) {
-               ERR("Failed to find model id");
-               throw ENXIO;
-       }
-
        query.sensorhub_controlled = m_sensorhub_controlled = is_sensorhub_controlled(sensorhub_interval_node_name);
-       query.sensor_type = SENSOR_TYPE_PROXI;
+       query.sensor_type = "PROXI";
        query.key = "proximity_sensor";
        query.iio_enable_node_name = "proximity_enable";
        query.sensorhub_interval_node_name = sensorhub_interval_node_name;
@@ -65,29 +79,11 @@ proxi_sensor_hal::proxi_sensor_hal()
        m_data_node = info.data_node_path;
        m_enable_node = info.enable_node_path;
 
-       if (!config.get(SENSOR_TYPE_PROXI, m_model_id, ELEMENT_VENDOR, m_vendor)) {
-               ERR("[VENDOR] is empty\n");
-               throw ENXIO;
-       }
-
-       INFO("m_vendor = %s", m_vendor.c_str());
-
-       if (!config.get(SENSOR_TYPE_PROXI, m_model_id, ELEMENT_NAME, m_chip_name)) {
-               ERR("[NAME] is empty\n");
-               throw ENXIO;
-       }
-
-       INFO("m_chip_name = %s\n",m_chip_name.c_str());
-
        if ((m_node_handle = open(m_data_node.c_str(), O_RDWR)) < 0) {
-               ERR("Proxi handle(%d) open fail", m_node_handle);
+               ERR("accel handle open fail for accel processor, error:%s\n", strerror(errno));
                throw ENXIO;
        }
 
-       int clockId = CLOCK_MONOTONIC;
-       if (ioctl(m_node_handle, EVIOCSCLOCKID, &clockId) != 0)
-               ERR("Fail to set monotonic timestamp for %s", m_data_node.c_str());
-
        INFO("Proxi_sensor_hal is created!\n");
 }
 
@@ -101,13 +97,11 @@ proxi_sensor_hal::~proxi_sensor_hal()
 
 bool proxi_sensor_hal::get_sensors(std::vector<sensor_handle_t> &sensors)
 {
-       sensor_handle_t handle;
-       handle.id = 0x1;
-       handle.name = "Proximity Sensor";
-       handle.type = SENSOR_HAL_TYPE_PROXIMITY;
-       handle.event_type = SENSOR_HAL_TYPE_PROXIMITY << 16 | 0x0001;
+       int size = ARRAY_SIZE(handles);
+
+       for (int i = 0; i < size; ++i)
+               sensors.push_back(handles[i]);
 
-       sensors.push_back(handle);
        return true;
 }
 
@@ -116,7 +110,7 @@ bool proxi_sensor_hal::enable(uint32_t id)
        set_enable_node(m_enable_node, m_sensorhub_controlled, true, SENSORHUB_PROXIMITY_ENABLE_BIT);
 
        m_fired_time = 0;
-       INFO("Proxi sensor real starting");
+       INFO("Enable proximity sensor");
        return true;
 }
 
@@ -124,7 +118,7 @@ bool proxi_sensor_hal::disable(uint32_t id)
 {
        set_enable_node(m_enable_node, m_sensorhub_controlled, false, SENSORHUB_PROXIMITY_ENABLE_BIT);
 
-       INFO("Proxi sensor real stopping");
+       INFO("Disable proximity sensor");
        return true;
 }
 
@@ -148,10 +142,17 @@ bool proxi_sensor_hal::set_command(uint32_t id, std::string command, std::string
        return false;
 }
 
+bool proxi_sensor_hal::is_data_ready(void)
+{
+       bool ret;
+       ret = update_value();
+       return ret;
+}
+
 bool proxi_sensor_hal::update_value(void)
 {
        struct input_event proxi_event;
-       INFO("proxi event detection!");
+       DBG("proxi event detection!");
 
        int len = read(m_node_handle, &proxi_event, sizeof(proxi_event));
 
@@ -160,21 +161,16 @@ bool proxi_sensor_hal::update_value(void)
                return false;
        }
 
-       DBG("read event,  len : %d , type : %x , code : %x , value : %x", len, proxi_event.type, proxi_event.code, proxi_event.value);
        if ((proxi_event.type == EV_ABS) && (proxi_event.code == ABS_DISTANCE)) {
                m_state = proxi_event.value;
                m_fired_time = sensor_hal_base::get_timestamp(&proxi_event.time);
-       } else {
-               return false;
+
+               DBG("m_state = %d, time = %lluus", m_state, m_fired_time);
+
+               return true;
        }
-       return true;
-}
 
-bool proxi_sensor_hal::is_data_ready(void)
-{
-       bool ret;
-       ret = update_value();
-       return ret;
+       return false;
 }
 
 bool proxi_sensor_hal::get_sensor_data(uint32_t id, sensor_data_t &data)
@@ -204,13 +200,13 @@ int proxi_sensor_hal::get_sensor_event(uint32_t id, sensor_event_t **event)
 
 bool proxi_sensor_hal::get_properties(uint32_t id, sensor_properties_s &properties)
 {
-       properties.name = m_chip_name;
-       properties.vendor = m_vendor;
-       properties.min_range = 0;
-       properties.max_range = 1;
-       properties.min_interval = 1;
-       properties.resolution = 1;
-       properties.fifo_count = 0;
-       properties.max_batch_count = 0;
+       properties.name = MODEL_NAME;
+       properties.vendor = VENDOR;
+       properties.min_range = proxi_properties.min_range;
+       properties.max_range = proxi_properties.max_range;
+       properties.min_interval = proxi_properties.min_interval;
+       properties.resolution = proxi_properties.resolution;
+       properties.fifo_count = proxi_properties.fifo_count;
+       properties.max_batch_count = proxi_properties.max_batch_count;
        return true;
 }
index b05316c..a804659 100755 (executable)
@@ -44,16 +44,11 @@ private:
        int m_node_handle;
        unsigned int m_state;
        unsigned long long m_fired_time;
-
-       std::string m_model_id;
-       std::string m_vendor;
-       std::string m_chip_name;
+       bool m_sensorhub_controlled;
 
        std::string m_data_node;
        std::string m_enable_node;
 
-       bool m_sensorhub_controlled;
-
        bool update_value(void);
 };
 #endif /*_PROXI_SENSOR_HAL_H_*/