sensor-plugins-tm1: enable proximity sensor HAL
authorMu-Woong Lee <muwoong.lee@samsung.com>
Wed, 3 Feb 2016 07:47:24 +0000 (16:47 +0900)
committerMu-Woong Lee <muwoong.lee@samsung.com>
Wed, 3 Feb 2016 07:47:24 +0000 (16:47 +0900)
Change-Id: Ie0c62492dfe819e9f34e1c7e6328d4bd2f1cfeb4
Signed-off-by: kibak.yoon <kibak.yoon@samsung.com>
Signed-off-by: Mu-Woong Lee <muwoong.lee@samsung.com>
packaging/sensor-plugins-tm1.spec
src/plugins/proxi/proxi_sensor_hal.cpp
src/plugins/proxi/proxi_sensor_hal.h

index 294400c..5321ac7 100644 (file)
@@ -18,7 +18,7 @@ BuildRequires:  pkgconfig(libxml-2.0)
 
 %define accel_state ON
 %define gyro_state OFF
-%define proxi_state OFF
+%define proxi_state ON
 %define light_state OFF
 %define geo_state OFF
 %define pressure_state OFF
index 4b7f948..cc9e248 100644 (file)
@@ -34,9 +34,9 @@ using std::ifstream;
 #define ATTR_VALUE                             "value"
 
 proxi_sensor_hal::proxi_sensor_hal()
-: m_state(-1)
+: m_node_handle(-1)
+, m_state(-1)
 , m_fired_time(0)
-, m_node_handle(-1)
 {
        const string sensorhub_interval_node_name = "prox_poll_delay";
        csensor_config &config = csensor_config::get_instance();
@@ -99,20 +99,20 @@ proxi_sensor_hal::~proxi_sensor_hal()
        INFO("Proxi_sensor_hal is destroyed!\n");
 }
 
-string proxi_sensor_hal::get_model_id(void)
+bool proxi_sensor_hal::get_sensors(std::vector<sensor_handle_t> &sensors)
 {
-       return m_model_id;
-}
+       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;
 
-sensor_hal_type_t proxi_sensor_hal::get_type(void)
-{
-       return SENSOR_HAL_TYPE_PROXIMITY;
+       sensors.push_back(handle);
+       return true;
 }
 
-bool proxi_sensor_hal::enable(void)
+bool proxi_sensor_hal::enable(uint32_t id)
 {
-       AUTOLOCK(m_mutex);
-
        set_enable_node(m_enable_node, m_sensorhub_controlled, true, SENSORHUB_PROXIMITY_ENABLE_BIT);
 
        m_fired_time = 0;
@@ -120,21 +120,34 @@ bool proxi_sensor_hal::enable(void)
        return true;
 }
 
-bool proxi_sensor_hal::disable(void)
+bool proxi_sensor_hal::disable(uint32_t id)
 {
-       AUTOLOCK(m_mutex);
-
        set_enable_node(m_enable_node, m_sensorhub_controlled, false, SENSORHUB_PROXIMITY_ENABLE_BIT);
 
        INFO("Proxi sensor real stopping");
        return true;
 }
 
-bool proxi_sensor_hal::set_interval(unsigned long val)
+int proxi_sensor_hal::get_poll_fd()
+{
+       return m_node_handle;
+}
+
+bool proxi_sensor_hal::set_interval(uint32_t id, unsigned long interval_ms)
 {
        return true;
 }
 
+bool proxi_sensor_hal::set_batch_latency(uint32_t id, unsigned long val)
+{
+       return false;
+}
+
+bool proxi_sensor_hal::set_command(uint32_t id, std::string command, std::string value)
+{
+       return false;
+}
+
 bool proxi_sensor_hal::update_value(void)
 {
        struct input_event proxi_event;
@@ -149,7 +162,6 @@ bool proxi_sensor_hal::update_value(void)
 
        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)) {
-               AUTOLOCK(m_value_mutex);
                m_state = proxi_event.value;
                m_fired_time = sensor_hal_base::get_timestamp(&proxi_event.time);
        } else {
@@ -165,18 +177,32 @@ bool proxi_sensor_hal::is_data_ready(void)
        return ret;
 }
 
-int proxi_sensor_hal::get_sensor_data(sensor_data_t &data)
+bool proxi_sensor_hal::get_sensor_data(uint32_t id, sensor_data_t &data)
 {
-       AUTOLOCK(m_value_mutex);
        data.accuracy = SENSOR_ACCURACY_UNDEFINED;
        data.timestamp = m_fired_time;
        data.value_count = 1;
        data.values[0] = m_state;
 
-       return 0;
+       return true;
+}
+
+int proxi_sensor_hal::get_sensor_event(uint32_t id, sensor_event_t **event)
+{
+       sensor_event_t *sensor_event;
+       sensor_event = (sensor_event_t *)malloc(sizeof(sensor_event_t));
+
+       sensor_event->data.accuracy = SENSOR_ACCURACY_GOOD;
+       sensor_event->data.timestamp = m_fired_time;
+       sensor_event->data.value_count = 1;
+       sensor_event->data.values[0] = m_state;
+
+       *event = sensor_event;
+
+       return sizeof(sensor_event_t);
 }
 
-bool proxi_sensor_hal::get_properties(sensor_properties_s &properties)
+bool proxi_sensor_hal::get_properties(uint32_t id, sensor_properties_s &properties)
 {
        properties.name = m_chip_name;
        properties.vendor = m_vendor;
index 27c4684..b05316c 100755 (executable)
@@ -27,29 +27,32 @@ class proxi_sensor_hal : public sensor_hal_base
 public:
        proxi_sensor_hal();
        virtual ~proxi_sensor_hal();
-       std::string get_model_id(void);
-       sensor_hal_type_t get_type(void);
-       bool enable(void);
-       bool disable(void);
-       bool set_interval(unsigned long ms_interval);
+
+       int get_poll_fd(void);
+       bool get_sensors(std::vector<sensor_handle_t> &sensors);
+       bool enable(uint32_t id);
+       bool disable(uint32_t id);
+       bool set_interval(uint32_t id, unsigned long ms_interval);
+       bool set_batch_latency(uint32_t id, unsigned long val);
+       bool set_command(uint32_t id, std::string command, std::string value);
        bool is_data_ready(void);
-       virtual int get_sensor_data(sensor_data_t &data);
-       virtual bool get_properties(sensor_properties_s &properties);
+       bool get_sensor_data(uint32_t id, sensor_data_t &data);
+       int get_sensor_event(uint32_t id, sensor_event_t **event);
+       bool get_properties(uint32_t id, sensor_properties_s &properties);
+
 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;
 
-       std::string m_enable_node;
        std::string m_data_node;
+       std::string m_enable_node;
 
-       unsigned int m_state;
-
-       unsigned long long m_fired_time;
-
-       int m_node_handle;
        bool m_sensorhub_controlled;
-       cmutex m_value_mutex;
 
        bool update_value(void);
 };