sensord: sync with SPIN tizen_2.4 73/49673/4
authorHongkuk, Son <hongkuk.son@samsung.com>
Sun, 18 Oct 2015 05:06:03 +0000 (14:06 +0900)
committerHongkuk, Son <hongkuk.son@samsung.com>
Tue, 20 Oct 2015 10:56:52 +0000 (19:56 +0900)
Signed-off-by: Hongkuk, Son <hongkuk.son@samsung.com>
Change-Id: I6c2150a15109a0ab80c3e642828a2786f137690f

121 files changed:
src/accel/accel_sensor.cpp
src/accel/accel_sensor.h
src/accel/accel_sensor_hal.cpp
src/accel/accel_sensor_hal.h
src/auto_rotation/auto_rotation_sensor.cpp
src/auto_rotation/auto_rotation_sensor.h
src/bio_led_red/bio_led_red_sensor.cpp
src/bio_led_red/bio_led_red_sensor.h
src/bio_led_red/bio_led_red_sensor_hal.cpp
src/bio_led_red/bio_led_red_sensor_hal.h
src/fusion/fusion_sensor.cpp
src/fusion/fusion_sensor.h
src/fusion/hardware_fusion_sensor.html [changed mode: 0644->0755]
src/geo/geo_sensor.cpp
src/geo/geo_sensor.h
src/geo/geo_sensor_hal.cpp
src/geo/geo_sensor_hal.h
src/gravity/gravity_sensor.cpp
src/gravity/gravity_sensor.h
src/gyro/gyro_sensor.cpp
src/gyro/gyro_sensor.h
src/gyro/gyro_sensor_hal.cpp
src/gyro/gyro_sensor_hal.h
src/libsensord/client.cpp [changed mode: 0755->0644]
src/libsensord/client_common.cpp
src/libsensord/command_channel.cpp [changed mode: 0755->0644]
src/libsensord/command_channel.h [changed mode: 0755->0644]
src/libsensord/creg_event_info.h [changed mode: 0755->0644]
src/libsensord/csensor_event_listener.cpp [changed mode: 0755->0644]
src/libsensord/csensor_event_listener.h [changed mode: 0755->0644]
src/libsensord/csensor_handle_info.cpp [changed mode: 0755->0644]
src/libsensord/csensor_handle_info.h [changed mode: 0755->0644]
src/libsensord/poller.h
src/libsensord/sensor_info_manager.cpp
src/libsensord/sensor_info_manager.h
src/libsensord/sensor_internal.h [changed mode: 0755->0644]
src/libsensord/sensor_proxi.h
src/light/light_sensor.cpp
src/light/light_sensor.h
src/light/light_sensor_hal.cpp
src/light/light_sensor_hal.h
src/linear_accel/linear_accel_sensor.cpp
src/linear_accel/linear_accel_sensor.h
src/orientation/orientation_sensor.cpp
src/orientation/orientation_sensor.h
src/pressure/pressure_sensor.cpp
src/pressure/pressure_sensor.h
src/pressure/pressure_sensor_hal.cpp
src/pressure/pressure_sensor_hal.h
src/proxi/proxi_sensor.cpp
src/proxi/proxi_sensor.h
src/proxi/proxi_sensor_hal.cpp
src/proxi/proxi_sensor_hal.h
src/rotation_vector/gaming_rv/gaming_rv_sensor.cpp
src/rotation_vector/gaming_rv/gaming_rv_sensor.h
src/rotation_vector/geomagnetic_rv/geomagnetic_rv_sensor.cpp
src/rotation_vector/geomagnetic_rv/geomagnetic_rv_sensor.h
src/rotation_vector/rv/rv_sensor.cpp
src/rotation_vector/rv/rv_sensor.h
src/rotation_vector/rv_raw/rv_raw_sensor.cpp
src/rotation_vector/rv_raw/rv_raw_sensor.h
src/rotation_vector/rv_raw/rv_raw_sensor_hal.cpp
src/rotation_vector/rv_raw/rv_raw_sensor_hal.h
src/server/command_worker.cpp [changed mode: 0755->0644]
src/server/command_worker.h [changed mode: 0755->0644]
src/server/main.cpp
src/server/permission_checker.cpp
src/shared/CMakeLists.txt [changed mode: 0755->0644]
src/shared/batch_info_list.cpp [new file with mode: 0644]
src/shared/batch_info_list.h [new file with mode: 0644]
src/shared/cclient_info_manager.cpp [changed mode: 0755->0644]
src/shared/cclient_info_manager.h [changed mode: 0755->0644]
src/shared/cclient_sensor_record.cpp [changed mode: 0755->0644]
src/shared/cclient_sensor_record.h [changed mode: 0755->0644]
src/shared/cconfig.cpp
src/shared/cconfig.h
src/shared/cinterval_info_list.h
src/shared/common.cpp [changed mode: 0755->0644]
src/shared/csensor_config.cpp
src/shared/csensor_config.h
src/shared/csensor_event_dispatcher.cpp
src/shared/csensor_event_dispatcher.h
src/shared/csensor_event_queue.cpp [changed mode: 0755->0644]
src/shared/csensor_event_queue.h [changed mode: 0755->0644]
src/shared/csensor_usage.cpp [changed mode: 0755->0644]
src/shared/csensor_usage.h [changed mode: 0755->0644]
src/shared/csocket.cpp [changed mode: 0755->0644]
src/shared/csocket.h [changed mode: 0755->0644]
src/shared/cvirtual_sensor_config.h
src/shared/iio_common.h
src/shared/physical_sensor.cpp [changed mode: 0755->0644]
src/shared/physical_sensor.h [changed mode: 0755->0644]
src/shared/sensor_base.cpp
src/shared/sensor_base.h
src/shared/sensor_hal.cpp
src/shared/sensor_hal.h
src/shared/sensor_info.cpp
src/shared/sensor_info.h
src/shared/sensor_plugin_loader.cpp
src/shared/sensor_plugin_loader.h
src/shared/sf_common.h [changed mode: 0755->0644]
src/shared/virtual_sensor.h
src/shared/worker_thread.h
src/temperature/temperature_sensor.cpp
src/temperature/temperature_sensor.h
src/temperature/temperature_sensor_hal.cpp
src/temperature/temperature_sensor_hal.h
src/tilt/tilt_sensor.cpp
src/tilt/tilt_sensor.h
src/ultraviolet/ultraviolet_sensor.cpp
src/ultraviolet/ultraviolet_sensor.h
src/ultraviolet/ultraviolet_sensor_hal.cpp
src/ultraviolet/ultraviolet_sensor_hal.h
src/uncal_gyro/uncal_gyro_sensor.cpp [changed mode: 0644->0755]
src/uncal_gyro/uncal_gyro_sensor.h [changed mode: 0644->0755]
systemd/sensord.socket [changed mode: 0644->0755]
test/src/api-test.c [changed mode: 0644->0755]
test/src/check-sensor.c [changed mode: 0644->0755]
test/src/fusion-data-collection.c [changed mode: 0644->0755]
test/src/multi-process-performance-test.c [changed mode: 0644->0755]
test/src/sensor-test.c [changed mode: 0644->0755]

index 1dc28ff..0db4c12 100755 (executable)
@@ -26,6 +26,8 @@
 
 using std::bind1st;
 using std::mem_fun;
+using std::string;
+using std::vector;
 
 #define GRAVITY 9.80665
 #define G_TO_MG 1000
@@ -59,7 +61,7 @@ accel_sensor::~accel_sensor()
 
 bool accel_sensor::init()
 {
-       m_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(ACCELEROMETER_SENSOR);
+       m_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(SENSOR_HAL_TYPE_ACCELEROMETER);
 
        if (!m_sensor_hal) {
                ERR("cannot load sensor_hal[%s]", sensor_base::get_name());
@@ -81,9 +83,9 @@ bool accel_sensor::init()
        return true;
 }
 
-sensor_type_t accel_sensor::get_type(void)
+void accel_sensor::get_types(vector<sensor_type_t> &types)
 {
-       return ACCELEROMETER_SENSOR;
+       types.push_back(ACCELEROMETER_SENSOR);
 }
 
 bool accel_sensor::working(void *inst)
@@ -140,7 +142,7 @@ bool accel_sensor::on_stop(void)
        return stop_poll();
 }
 
-bool accel_sensor::get_properties(sensor_properties_s &properties)
+bool accel_sensor::get_properties(sensor_type_t sensor_type, sensor_properties_s &properties)
 {
        return m_sensor_hal->get_properties(properties);
 }
index fec8d69..a873538 100755 (executable)
@@ -31,12 +31,13 @@ public:
        virtual ~accel_sensor();
 
        bool init();
-       virtual sensor_type_t get_type(void);
+       virtual void get_types(std::vector<sensor_type_t> &types);
 
        static bool working(void *inst);
        virtual bool set_interval(unsigned long interval);
-       virtual bool get_properties(sensor_properties_s &properties);
        virtual int get_sensor_data(unsigned int type, sensor_data_t &data);
+       virtual bool get_properties(sensor_type_t sensor_type, sensor_properties_s &properties);
+
 private:
        sensor_hal *m_sensor_hal;
        cmutex m_value_mutex;
@@ -47,7 +48,6 @@ private:
 
        virtual bool on_start(void);
        virtual bool on_stop(void);
-
        void raw_to_base(sensor_data_t &data);
        bool process_event(void);
 };
index 3f4bfba..ac709a5 100755 (executable)
@@ -24,6 +24,7 @@
 #include <sys/poll.h>
 
 using std::ifstream;
+using std::string;
 
 #define GRAVITY 9.80665
 #define G_TO_MG 1000
@@ -157,9 +158,9 @@ string accel_sensor_hal::get_model_id(void)
        return m_model_id;
 }
 
-sensor_type_t accel_sensor_hal::get_type(void)
+sensor_hal_type_t accel_sensor_hal::get_type(void)
 {
-       return ACCELEROMETER_SENSOR;
+       return SENSOR_HAL_TYPE_ACCELEROMETER;
 }
 
 bool accel_sensor_hal::enable(void)
index 5782368..f16d94c 100755 (executable)
 #define _ACCEL_SENSOR_HAL_H_
 
 #include <sensor_hal.h>
-#include <string>
 #include <functional>
 
-using std::string;
-
 class accel_sensor_hal : public sensor_hal
 {
 public:
        accel_sensor_hal();
        virtual ~accel_sensor_hal();
-       string get_model_id(void);
-       sensor_type_t get_type(void);
+       std::string get_model_id(void);
+       sensor_hal_type_t get_type(void);
        bool enable(void);
        bool disable(void);
        bool set_interval(unsigned long val);
@@ -48,17 +45,17 @@ private:
        unsigned long m_polling_interval;
        unsigned long long m_fired_time;
 
-       string m_model_id;
-       string m_vendor;
-       string m_chip_name;
+       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;
-       string m_data_node;
-       string m_enable_node;
-       string m_interval_node;
+       std::string m_data_node;
+       std::string m_enable_node;
+       std::string m_interval_node;
 
        std::function<bool (bool)> update_value;
 
index 9c0e367..5601fae 100755 (executable)
@@ -38,6 +38,8 @@
 
 using std::bind1st;
 using std::mem_fun;
+using std::string;
+using std::vector;
 
 #define SENSOR_NAME                                            "AUTO_ROTATION_SENSOR"
 #define SENSOR_TYPE_AUTO_ROTATION              "AUTO_ROTATION"
@@ -133,9 +135,9 @@ bool auto_rotation_sensor::init()
        return true;
 }
 
-sensor_type_t auto_rotation_sensor::get_type(void)
+void auto_rotation_sensor::get_types(vector<sensor_type_t> &types)
 {
-       return AUTO_ROTATION_SENSOR;
+       types.push_back(AUTO_ROTATION_SENSOR);
 }
 
 bool auto_rotation_sensor::on_start(void)
@@ -208,7 +210,7 @@ int auto_rotation_sensor::get_sensor_data(const unsigned int event_type, sensor_
        return 0;
 }
 
-bool auto_rotation_sensor::get_properties(sensor_properties_s &properties)
+bool auto_rotation_sensor::get_properties(sensor_type_t sensor_type, sensor_properties_s &properties)
 {
        properties.name = "Auto Rotation Sensor";
        properties.vendor = "Samsung Electronics";
index 863d419..d2d1998 100755 (executable)
@@ -21,7 +21,6 @@
 #define _AUTO_ROTATION_SENSOR_H_
 
 #include <sensor_internal.h>
-#include <string>
 #include <auto_rotation_alg.h>
 
 class auto_rotation_sensor : public virtual_sensor {
@@ -30,14 +29,14 @@ public:
        virtual ~auto_rotation_sensor();
 
        bool init();
-       sensor_type_t get_type(void);
+       virtual void get_types(std::vector<sensor_type_t> &types);
 
        static bool working(void *inst);
 
-       void synthesize(const sensor_event_t& event, vector<sensor_event_t> &outs);
+       void synthesize(const sensor_event_t& event, std::vector<sensor_event_t> &outs);
 
        int get_sensor_data(const unsigned int event_type, sensor_data_t &data);
-       virtual bool get_properties(sensor_properties_s &properties);
+       virtual bool get_properties(sensor_type_t sensor_type, sensor_properties_s &properties);
 private:
        sensor_base *m_accel_sensor;
        cmutex m_value_mutex;
@@ -47,8 +46,8 @@ private:
        unsigned long long m_rotation_time;
        auto_rotation_alg *m_alg;
 
-       string m_vendor;
-       string m_raw_data_unit;
+       std::string m_vendor;
+       std::string m_raw_data_unit;
        int m_default_sampling_time;
 
        auto_rotation_alg *get_alg();
index 17d228f..07006c7 100755 (executable)
@@ -26,6 +26,8 @@
 
 using std::bind1st;
 using std::mem_fun;
+using std::string;
+using std::vector;
 
 #define SENSOR_NAME "BIO_LED_RED_SENSOR"
 
@@ -46,7 +48,7 @@ bio_led_red_sensor::~bio_led_red_sensor()
 
 bool bio_led_red_sensor::init()
 {
-       m_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(BIO_LED_RED_SENSOR);
+       m_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(SENSOR_HAL_TYPE_BIO_LED_RED);
 
        if (!m_sensor_hal) {
                ERR("cannot load sensor_hal[%s]", sensor_base::get_name());
@@ -58,9 +60,9 @@ bool bio_led_red_sensor::init()
        return true;
 }
 
-sensor_type_t bio_led_red_sensor::get_type(void)
+void bio_led_red_sensor::get_types(vector<sensor_type_t> &types)
 {
-       return BIO_LED_RED_SENSOR;
+       types.push_back(BIO_LED_RED_SENSOR);
 }
 
 bool bio_led_red_sensor::working(void *inst)
@@ -110,7 +112,7 @@ bool bio_led_red_sensor::on_stop(void)
        return stop_poll();
 }
 
-bool bio_led_red_sensor::get_properties(sensor_properties_s &properties)
+bool bio_led_red_sensor::get_properties(sensor_type_t sensor_type, sensor_properties_s &properties)
 {
        return m_sensor_hal->get_properties(properties);
 }
index f14b4af..78af52a 100755 (executable)
@@ -31,11 +31,11 @@ public:
        virtual ~bio_led_red_sensor();
 
        bool init();
-       virtual sensor_type_t get_type(void);
+       virtual void get_types(std::vector<sensor_type_t> &types);
 
        static bool working(void *inst);
        virtual bool set_interval(unsigned long interval);
-       virtual bool get_properties(sensor_properties_s &properties);
+       virtual bool get_properties(sensor_type_t sensor_type, sensor_properties_s &properties);
        virtual int get_sensor_data(unsigned int type, sensor_data_t &data);
 private:
        sensor_hal *m_sensor_hal;
index 38ee2bb..59fea6a 100755 (executable)
@@ -26,6 +26,7 @@
 #include <fstream>
 
 using std::ifstream;
+using std::string;
 
 #define SENSOR_TYPE_BIO_LED_RED        "BIO_LED_RED"
 #define ELEMENT_NAME                   "NAME"
@@ -112,9 +113,9 @@ string bio_led_red_sensor_hal::get_model_id(void)
 }
 
 
-sensor_type_t bio_led_red_sensor_hal::get_type(void)
+sensor_hal_type_t bio_led_red_sensor_hal::get_type(void)
 {
-       return BIO_LED_RED_SENSOR;
+       return SENSOR_HAL_TYPE_BIO_LED_RED;
 }
 
 bool bio_led_red_sensor_hal::enable(void)
index d94c470..bd9059b 100755 (executable)
 #define _BIO_LED_RED_SENSOR_HAL_H_
 
 #include <sensor_hal.h>
-#include <string>
-
-using std::string;
 
 class bio_led_red_sensor_hal : public sensor_hal
 {
 public:
        bio_led_red_sensor_hal();
        virtual ~bio_led_red_sensor_hal();
-       string get_model_id(void);
-       sensor_type_t get_type(void);
+       std::string get_model_id(void);
+       sensor_hal_type_t get_type(void);
        bool enable(void);
        bool disable(void);
        bool set_interval(unsigned long val);
@@ -40,9 +37,9 @@ public:
        bool get_properties(sensor_properties_s &properties);
 
 private:
-       string m_model_id;
-       string m_vendor;
-       string m_chip_name;
+       std::string m_model_id;
+       std::string m_vendor;
+       std::string m_chip_name;
 
        unsigned long m_polling_interval;
 
@@ -51,9 +48,9 @@ private:
        unsigned long long m_fired_time;
        int m_node_handle;
 
-       string m_enable_node;
-       string m_data_node;
-       string m_interval_node;
+       std::string m_enable_node;
+       std::string m_data_node;
+       std::string m_interval_node;
 
        bool m_sensorhub_controlled;
 
index 38e02e4..bb04436 100755 (executable)
@@ -33,6 +33,9 @@
 #include <cvirtual_sensor_config.h>
 #include <algorithm>
 
+using std::string;
+using std::vector;
+
 #define SENSOR_NAME "FUSION_SENSOR"
 #define SENSOR_TYPE_FUSION             "FUSION"
 
@@ -212,9 +215,9 @@ bool fusion_sensor::init(void)
        return true;
 }
 
-sensor_type_t fusion_sensor::get_type(void)
+void fusion_sensor::get_types(vector<sensor_type_t> &types)
 {
-       return FUSION_SENSOR;
+       types.push_back(FUSION_SENSOR);
 }
 
 bool fusion_sensor::on_start(void)
@@ -458,7 +461,7 @@ int fusion_sensor::get_sensor_data(const unsigned int event_type, sensor_data_t
        return 0;
 }
 
-bool fusion_sensor::get_properties(sensor_properties_s &properties)
+bool fusion_sensor::get_properties(sensor_type_t sensor_type, sensor_properties_s &properties)
 {
        properties.min_range = 0;
        properties.max_range = 0;
index 8b4013f..e057ff0 100755 (executable)
@@ -35,8 +35,8 @@ public:
 
        bool add_interval(int client_id, unsigned int interval);
        bool delete_interval(int client_id);
-       bool get_properties(sensor_properties_s &properties);
-       sensor_type_t get_type(void);
+       virtual bool get_properties(sensor_type_t sensor_type, sensor_properties_s &properties);
+       virtual void get_types(std::vector<sensor_type_t> &types);
 
        int get_sensor_data(const unsigned int data_id, sensor_data_t &data);
 
@@ -63,8 +63,8 @@ private:
        unsigned long long m_time;
        unsigned int m_interval;
 
-       string m_vendor;
-       string m_raw_data_unit;
+       std::string m_vendor;
+       std::string m_raw_data_unit;
        int m_default_sampling_time;
        float m_accel_static_bias[3];
        float m_gyro_static_bias[3];
old mode 100644 (file)
new mode 100755 (executable)
index aae6fea..2c81202
@@ -91,7 +91,7 @@ software sensor fusion, </FONT>
 <P STYLE="margin-bottom: 0cm"><FONT FACE="Liberation Serif, serif">-&gt;In
 the constructor use sensor_plugin_loader to check if the hal sensor
 fusion is present or not:</FONT></P>
-<P STYLE="margin-bottom: 0cm"><FONT FACE="Liberation Serif, serif">sensor_plugin_loader::get_instance().get_sensor_hal(FUSION_SENSOR)</FONT></P>
+<P STYLE="margin-bottom: 0cm"><FONT FACE="Liberation Serif, serif">sensor_plugin_loader::get_instance().get_sensor_hal(SENSOR_HAL_TYPE_FUSION)</FONT></P>
 <P STYLE="margin-bottom: 0cm"><BR>
 </P>
 <P STYLE="margin-bottom: 0cm"><FONT FACE="Liberation Serif, serif">-&gt;If
@@ -103,7 +103,7 @@ this result in virtual_sensor::m_hardware_fusion</FONT></P>
 </P>
 <P STYLE="margin-bottom: 0cm"><FONT FACE="Courier 10 Pitch">sensor_hal
 *fusion_sensor_hal =
-sensor_plugin_loader::get_instance().get_sensor_hal(FUSION_SENSOR);</FONT></P>
+sensor_plugin_loader::get_instance().get_sensor_hal(SENSOR_HAL_TYPE_FUSION);</FONT></P>
 <P STYLE="margin-bottom: 0cm"><FONT FACE="Courier 10 Pitch">if
 (!fusion_sensor_hal)</FONT></P>
 <P STYLE="margin-bottom: 0cm"><FONT FACE="Courier 10 Pitch">&emsp;&emsp;m_hardware_fusion
index 02609ca..6d9c170 100755 (executable)
@@ -23,6 +23,9 @@
 #include <geo_sensor.h>
 #include <sensor_plugin_loader.h>
 
+using std::string;
+using std::vector;
+
 #define SENSOR_NAME "GEOMAGNETIC_SENSOR"
 
 geo_sensor::geo_sensor()
@@ -45,7 +48,7 @@ geo_sensor::~geo_sensor()
 
 bool geo_sensor::init()
 {
-       m_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(GEOMAGNETIC_SENSOR);
+       m_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(SENSOR_HAL_TYPE_GEOMAGNETIC);
 
        if (!m_sensor_hal) {
                ERR("cannot load sensor_hal[%s]", sensor_base::get_name());
@@ -66,15 +69,15 @@ bool geo_sensor::init()
        return true;
 }
 
-sensor_type_t geo_sensor::get_type(void)
+void geo_sensor::get_types(vector<sensor_type_t> &types)
 {
-       return GEOMAGNETIC_SENSOR;
+       types.push_back(GEOMAGNETIC_SENSOR);
 }
 
 bool geo_sensor::working(void *inst)
 {
        geo_sensor *sensor = (geo_sensor*)inst;
-       return sensor->process_event();;
+       return sensor->process_event();
 }
 
 bool geo_sensor::process_event(void)
@@ -125,7 +128,7 @@ bool geo_sensor::on_stop(void)
        return stop_poll();
 }
 
-bool geo_sensor::get_properties(sensor_properties_s &properties)
+bool geo_sensor::get_properties(sensor_type_t sensor_type, sensor_properties_s &properties)
 {
        return m_sensor_hal->get_properties(properties);
 }
index d864ec1..df1e2c3 100755 (executable)
@@ -31,13 +31,13 @@ public:
        virtual ~geo_sensor();
 
        virtual bool init();
-       virtual sensor_type_t get_type(void);
+       virtual void get_types(std::vector<sensor_type_t> &types);
 
        static bool working(void *inst);
 
        virtual bool set_interval(unsigned long interval);
-       virtual bool get_properties(sensor_properties_s &properties);
        int get_sensor_data(unsigned int type, sensor_data_t &data);
+       virtual bool get_properties(sensor_type_t sensor_type, sensor_properties_s &properties);
 private:
        sensor_hal *m_sensor_hal;
 
index 0480752..9b23ea5 100755 (executable)
@@ -26,6 +26,7 @@
 #include <fstream>
 
 using std::ifstream;
+using std::string;
 
 #define SENSOR_TYPE_MAGNETIC   "MAGNETIC"
 #define ELEMENT_NAME                           "NAME"
@@ -147,9 +148,9 @@ string geo_sensor_hal::get_model_id(void)
        return m_model_id;
 }
 
-sensor_type_t geo_sensor_hal::get_type(void)
+sensor_hal_type_t geo_sensor_hal::get_type(void)
 {
-       return GEOMAGNETIC_SENSOR;
+       return SENSOR_HAL_TYPE_GEOMAGNETIC;
 }
 
 bool geo_sensor_hal::enable(void)
@@ -190,7 +191,6 @@ bool geo_sensor_hal::set_interval(unsigned long val)
        INFO("Interval is changed from %dms to %dms]", m_polling_interval, val);
        m_polling_interval = val;
        return true;
-
 }
 
 bool geo_sensor_hal::update_value(bool wait)
index 44afebb..0af57e8 100755 (executable)
 #define _GEO_SENSOR_HAL_H_
 
 #include <sensor_hal.h>
-#include <string>
-
-using std::string;
 
 class geo_sensor_hal : public sensor_hal
 {
 public:
        geo_sensor_hal();
        virtual ~geo_sensor_hal();
-       string get_model_id(void);
-       sensor_type_t get_type(void);
+       std::string get_model_id(void);
+       sensor_hal_type_t get_type(void);
        bool enable(void);
        bool disable(void);
        bool set_interval(unsigned long val);
@@ -39,9 +36,9 @@ public:
        virtual int get_sensor_data(sensor_data_t &data);
        bool get_properties(sensor_properties_s &properties);
 private:
-       string m_model_id;
-       string m_vendor;
-       string m_chip_name;
+       std::string m_model_id;
+       std::string m_vendor;
+       std::string m_chip_name;
 
        float m_min_range;
        float m_max_range;
@@ -57,9 +54,9 @@ private:
        int m_node_handle;
        unsigned long m_polling_interval;
 
-       string m_enable_node;
-       string m_data_node;
-       string m_interval_node;
+       std::string m_enable_node;
+       std::string m_data_node;
+       std::string m_interval_node;
 
        bool m_sensorhub_controlled;
 
index aa23a5e..dfe3ae7 100755 (executable)
@@ -31,6 +31,9 @@
 #include <sensor_plugin_loader.h>
 #include <cvirtual_sensor_config.h>
 
+using std::string;
+using std::vector;
+
 #define INITIAL_VALUE -1
 #define GRAVITY 9.80665
 
@@ -66,7 +69,7 @@ gravity_sensor::gravity_sensor()
 {
        cvirtual_sensor_config &config = cvirtual_sensor_config::get_instance();
 
-       sensor_hal *fusion_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(FUSION_SENSOR);
+       sensor_hal *fusion_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(SENSOR_HAL_TYPE_FUSION);
        if (!fusion_sensor_hal)
                m_hardware_fusion = false;
        else
@@ -157,9 +160,9 @@ bool gravity_sensor::init()
        return true;
 }
 
-sensor_type_t gravity_sensor::get_type(void)
+void gravity_sensor::get_types(vector<sensor_type_t> &types)
 {
-       return GRAVITY_SENSOR;
+       types.push_back(GRAVITY_SENSOR);
 }
 
 bool gravity_sensor::on_start(void)
@@ -374,7 +377,7 @@ int gravity_sensor::get_sensor_data(const unsigned int event_type, sensor_data_t
        return 0;
 }
 
-bool gravity_sensor::get_properties(sensor_properties_s &properties)
+bool gravity_sensor::get_properties(sensor_type_t sensor_type, sensor_properties_s &properties)
 {
        properties.min_range = -GRAVITY;
        properties.max_range = GRAVITY;
index cd15b79..b5114ee 100755 (executable)
@@ -30,15 +30,15 @@ public:
        virtual ~gravity_sensor();
 
        bool init();
-       sensor_type_t get_type(void);
+       virtual void get_types(std::vector<sensor_type_t> &types);
 
-       void synthesize(const sensor_event_t &event, vector<sensor_event_t> &outs);
+       void synthesize(const sensor_event_t& event, std::vector<sensor_event_t> &outs);
 
        bool add_interval(int client_id, unsigned int interval);
        bool delete_interval(int client_id);
 
        int get_sensor_data(const unsigned int event_type, sensor_data_t &data);
-       bool get_properties(sensor_properties_s &properties);
+       virtual bool get_properties(sensor_type_t sensor_type, sensor_properties_s &properties);
 private:
        sensor_base *m_accel_sensor;
        sensor_base *m_gyro_sensor;
@@ -55,9 +55,9 @@ private:
        unsigned long long m_time;
        unsigned int m_interval;
 
-       string m_vendor;
-       string m_raw_data_unit;
-       string m_orientation_data_unit;
+       std::string m_vendor;
+       std::string m_raw_data_unit;
+       std::string m_orientation_data_unit;
        int m_default_sampling_time;
        int m_gravity_sign_compensation[3];
        int m_azimuth_rotation_compensation;
index c7b0001..2cb2859 100755 (executable)
@@ -23,6 +23,9 @@
 #include <gyro_sensor.h>
 #include <sensor_plugin_loader.h>
 
+using std::string;
+using std::vector;
+
 #define MS_TO_US 1000
 #define DPS_TO_MDPS 1000
 #define RAW_DATA_TO_DPS_UNIT(X) ((float)(X)/((float)DPS_TO_MDPS))
@@ -48,7 +51,7 @@ gyro_sensor::~gyro_sensor()
 
 bool gyro_sensor::init()
 {
-       m_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(GYROSCOPE_SENSOR);
+       m_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(SENSOR_HAL_TYPE_GYROSCOPE);
 
        if (!m_sensor_hal) {
                ERR("cannot load sensor_hal[%s]", sensor_base::get_name());
@@ -69,9 +72,9 @@ bool gyro_sensor::init()
        return true;
 }
 
-sensor_type_t gyro_sensor::get_type(void)
+void gyro_sensor::get_types(vector<sensor_type_t> &types)
 {
-       return GYROSCOPE_SENSOR;
+       types.push_back(GYROSCOPE_SENSOR);
 }
 
 bool gyro_sensor::working(void *inst)
@@ -127,7 +130,7 @@ bool gyro_sensor::on_stop(void)
        return stop_poll();
 }
 
-bool gyro_sensor::get_properties(sensor_properties_s &properties)
+bool gyro_sensor::get_properties(sensor_type_t sensor_type, sensor_properties_s &properties)
 {
        return m_sensor_hal->get_properties(properties);
 }
index a56ca2f..81bcb7b 100755 (executable)
@@ -31,13 +31,13 @@ public:
        virtual ~gyro_sensor();
 
        virtual bool init();
-       virtual sensor_type_t get_type(void);
+       virtual void get_types(std::vector<sensor_type_t> &types);
 
        static bool working(void *inst);
 
        virtual bool set_interval(unsigned long interval);
-       virtual bool get_properties(sensor_properties_s &properties);
        int get_sensor_data(unsigned int type, sensor_data_t &data);
+       virtual bool get_properties(sensor_type_t sensor_type, sensor_properties_s &properties);
 private:
        sensor_hal *m_sensor_hal;
        float m_resolution;
index 52b55fb..97a6903 100755 (executable)
@@ -26,6 +26,7 @@
 #include <fstream>
 
 using std::ifstream;
+using std::string;
 
 #define DPS_TO_MDPS 1000
 #define MIN_RANGE(RES) (-((1 << (RES))/2))
@@ -137,9 +138,9 @@ string gyro_sensor_hal::get_model_id(void)
        return m_model_id;
 }
 
-sensor_type_t gyro_sensor_hal::get_type(void)
+sensor_hal_type_t gyro_sensor_hal::get_type(void)
 {
-       return GYROSCOPE_SENSOR;
+       return SENSOR_HAL_TYPE_GYROSCOPE;
 }
 
 bool gyro_sensor_hal::enable(void)
index 6204399..dde408e 100755 (executable)
 #define _GYRO_SENSOR_HAL_H_
 
 #include <sensor_hal.h>
-#include <string>
-
-using std::string;
 
 class gyro_sensor_hal : public sensor_hal
 {
 public:
        gyro_sensor_hal();
        virtual ~gyro_sensor_hal();
-       string get_model_id(void);
-       sensor_type_t get_type(void);
+       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);
@@ -47,18 +44,18 @@ private:
        unsigned long m_polling_interval;
        unsigned long long m_fired_time;
 
-       string m_model_id;
-       string m_vendor;
-       string m_chip_name;
+       std::string m_model_id;
+       std::string m_vendor;
+       std::string m_chip_name;
 
        float m_min_range;
        float m_max_range;
        int m_resolution;
        float m_raw_data_unit;
 
-       string m_data_node;
-       string m_enable_node;
-       string m_interval_node;
+       std::string m_data_node;
+       std::string m_enable_node;
+       std::string m_interval_node;
 
        bool m_sensorhub_controlled;
 
old mode 100755 (executable)
new mode 100644 (file)
index 710bdcf..943e5a9
 #include <common.h>
 #include <sensor_info.h>
 #include <sensor_info_manager.h>
+#include <vector>
+#include <algorithm>
+
+using std::vector;
 
 #ifndef API
 #define API __attribute__((visibility("default")))
 #endif
 
+#define MIN_INTERVAL 10
+
 static const int OP_SUCCESS = 0;
 static const int OP_ERROR =  -1;
 
@@ -260,16 +266,9 @@ static bool change_sensor_rep(sensor_id_t sensor_id, sensor_rep &prev_rep, senso
                        }
                }
 
-               if (prev_rep.interval != cur_rep.interval) {
-                       unsigned int min_interval;
-
-                       if (cur_rep.interval == 0)
-                               min_interval= POLL_MAX_HZ_MS;
-                       else
-                               min_interval = cur_rep.interval;
-
-                       if (!cmd_channel->cmd_set_interval(min_interval)) {
-                               ERR("Sending cmd_set_interval(%d, %s, %d) failed for %s", client_id, get_sensor_name(sensor_id), min_interval, get_client_name());
+               if ( (prev_rep.interval != cur_rep.interval) || (prev_rep.latency != cur_rep.latency)) {
+                       if (!cmd_channel->cmd_set_batch(cur_rep.interval, cur_rep.latency)) {
+                               ERR("Sending cmd_set_batch(%d, %s, %d, %d) failed for %s", client_id, get_sensor_name(sensor_id), cur_rep.interval, cur_rep.latency, get_client_name());
                                return false;
                        }
                }
@@ -297,7 +296,7 @@ static bool change_sensor_rep(sensor_id_t sensor_id, sensor_rep &prev_rep, senso
                                return false;
                        }
                } else {
-                       if (!cmd_channel->cmd_unset_interval()) {
+                       if (!cmd_channel->cmd_unset_batch()) {
                                ERR("Sending cmd_unset_interval(%d, %s) failed for %s", client_id, get_sensor_name(sensor_id), get_client_name());
                                return false;
                        }
@@ -616,14 +615,14 @@ API int sensord_connect(sensor_t sensor)
        retvm_if (!sensor_info_manager::get_instance().is_valid(info),
                OP_ERROR, "Invalid param: sensor (%p)", sensor);
 
-       sensor_id_t sensor_id =  info->get_id();
+       sensor_id_t sensor_id = info->get_id();
 
        AUTOLOCK(lock);
 
        sensor_registered = event_listener.is_sensor_registered(sensor_id);
 
        handle = event_listener.create_handle(sensor_id);
-       if (handle == MAX_HANDLE) {
+       if (handle == MAX_HANDLE_REACHED) {
                ERR("Maximum number of handles reached, sensor: %s in client %s", get_sensor_name(sensor_id), get_client_name());
                return OP_ERROR;
        }
@@ -758,14 +757,15 @@ static bool register_event(int handle, unsigned int event_type, unsigned int int
                return false;
        }
 
-       if (interval == 0)
-               interval = 1;
+       if (interval < MIN_INTERVAL)
+               interval = MIN_INTERVAL;
 
-       INFO("%s registers event %s[0x%x] for sensor %s[%d] with interval: %d, cb: 0x%x, user_data: 0x%x", get_client_name(), get_event_name(event_type),
-                       event_type, get_sensor_name(sensor_id), handle, interval, cb, user_data);
+       INFO("%s registers event %s[0x%x] for sensor %s[%d] with interval: %d, latency: %d,  cb: 0x%x, user_data: 0x%x",
+               get_client_name(), get_event_name(event_type), event_type, get_sensor_name(sensor_id),
+               handle, interval, max_batch_latency, cb, user_data);
 
        event_listener.get_sensor_rep(sensor_id, prev_rep);
-       event_listener.register_event(handle, event_type, interval, cb_type, cb, user_data);
+       event_listener.register_event(handle, event_type, interval, max_batch_latency, cb_type, cb, user_data);
        event_listener.get_sensor_rep(sensor_id, cur_rep);
        ret = change_sensor_rep(sensor_id, prev_rep, cur_rep);
 
@@ -791,7 +791,7 @@ API bool sensord_unregister_event(int handle, unsigned int event_type)
        sensor_id_t sensor_id;
        sensor_rep prev_rep, cur_rep;
        bool ret;
-       unsigned int prev_interval;
+       unsigned int prev_interval, prev_latency;
        int prev_cb_type;
        void *prev_cb;
        void *prev_user_data;
@@ -807,7 +807,7 @@ API bool sensord_unregister_event(int handle, unsigned int event_type)
                event_type, get_sensor_name(sensor_id), handle);
 
        event_listener.get_sensor_rep(sensor_id, prev_rep);
-       event_listener.get_event_info(handle, event_type, prev_interval, prev_cb_type, prev_cb, prev_user_data);
+       event_listener.get_event_info(handle, event_type, prev_interval, prev_latency, prev_cb_type, prev_cb, prev_user_data);
 
        if (!event_listener.unregister_event(handle, event_type)) {
                ERR("%s try to unregister non registered event %s[0x%x] for sensor %s[%d]",
@@ -819,7 +819,7 @@ API bool sensord_unregister_event(int handle, unsigned int event_type)
        ret =  change_sensor_rep(sensor_id, prev_rep, cur_rep);
 
        if (!ret)
-               event_listener.register_event(handle, event_type, prev_interval, prev_cb_type, prev_cb, prev_user_data);
+               event_listener.register_event(handle, event_type, prev_interval, prev_latency, prev_cb_type, prev_cb, prev_user_data);
 
        return ret;
 
@@ -945,12 +945,12 @@ API bool sensord_stop(int handle)
 }
 
 
-API bool sensord_change_event_interval(int handle, unsigned int event_type, unsigned int interval)
+static bool change_event_batch(int handle, unsigned int event_type, unsigned int interval, unsigned int latency)
 {
        sensor_id_t sensor_id;
        sensor_rep prev_rep, cur_rep;
        bool ret;
-       unsigned int prev_interval;
+       unsigned int prev_interval, prev_latency;
        int prev_cb_type;
        void *prev_cb;
        void *prev_user_data;
@@ -962,14 +962,20 @@ API bool sensord_change_event_interval(int handle, unsigned int event_type, unsi
                return false;
        }
 
-       INFO("%s changes interval of event %s[0x%x] for %s[%d] to interval %d", get_client_name(), get_event_name(event_type),
-                       event_type, get_sensor_name(sensor_id), handle, interval);
+       if (interval == 0)
+               interval = 1;
+
+       INFO("%s changes batch of event %s[0x%x] for %s[%d] to (%d, %d)", get_client_name(), get_event_name(event_type),
+                       event_type, get_sensor_name(sensor_id), handle, interval, latency);
 
        event_listener.get_sensor_rep(sensor_id, prev_rep);
 
-       event_listener.get_event_info(handle, event_type, prev_interval, prev_cb_type, prev_cb, prev_user_data);
+       event_listener.get_event_info(handle, event_type, prev_interval, prev_latency, prev_cb_type, prev_cb, prev_user_data);
+
+       if (interval < MIN_INTERVAL)
+               interval = MIN_INTERVAL;
 
-       if (!event_listener.set_event_interval(handle, event_type, interval))
+       if (!event_listener.set_event_batch(handle, event_type, interval, latency))
                return false;
 
        event_listener.get_sensor_rep(sensor_id, cur_rep);
@@ -977,17 +983,45 @@ API bool sensord_change_event_interval(int handle, unsigned int event_type, unsi
        ret = change_sensor_rep(sensor_id, prev_rep, cur_rep);
 
        if (!ret)
-               event_listener.set_event_interval(handle, event_type, prev_interval);
+               event_listener.set_event_batch(handle, event_type, prev_interval, prev_latency);
 
        return ret;
-
 }
 
-API bool sensord_change_event_max_batch_latency(int handle, unsigned int max_batch_latency)
+API bool sensord_change_event_interval(int handle, unsigned int event_type, unsigned int interval)
 {
-       return false;
+       unsigned int prev_interval, prev_latency;
+       int prev_cb_type;
+       void *prev_cb;
+       void *prev_user_data;
+
+       AUTOLOCK(lock);
+
+       if (!event_listener.get_event_info(handle, event_type, prev_interval, prev_latency, prev_cb_type, prev_cb, prev_user_data)) {
+               ERR("Failed to get event info with handle = %d, event_type = 0x%x", handle, event_type);
+               return false;
+       }
+
+       INFO("handle = %d, event_type = 0x%x, interval = %d, prev_latency = %d", handle, event_type, interval, prev_latency);
+       return change_event_batch(handle, event_type, interval, prev_latency);
 }
 
+API bool sensord_change_event_max_batch_latency(int handle, unsigned int event_type, unsigned int max_batch_latency)
+{
+       unsigned int prev_interval, prev_latency;
+       int prev_cb_type;
+       void *prev_cb;
+       void *prev_user_data;
+
+       AUTOLOCK(lock);
+
+       if (!event_listener.get_event_info(handle, event_type, prev_interval, prev_latency, prev_cb_type, prev_cb, prev_user_data)) {
+               ERR("Failed to get event info with handle = %d, event_type = 0x%x", handle, event_type);
+               return false;
+       }
+
+       return change_event_batch(handle, event_type, prev_interval, max_batch_latency);
+}
 
 API bool sensord_set_option(int handle, int option)
 {
index 40f99b1..9efccee 100755 (executable)
@@ -123,8 +123,6 @@ const char* get_log_element_name(log_id id, unsigned int type)
 
 const char* get_sensor_name(sensor_id_t sensor_id)
 {
-       const int SENSOR_TYPE_MASK = 0x0000FFFF;
-
        sensor_type_t sensor_type = (sensor_type_t) (sensor_id & SENSOR_TYPE_MASK);
 
        return get_log_element_name(LOG_ID_SENSOR_TYPE, sensor_type);
old mode 100755 (executable)
new mode 100644 (file)
index 21238a2..c46a1a1
@@ -108,7 +108,8 @@ bool command_channel::cmd_get_id(int &client_id)
        packet->set_cmd(CMD_GET_ID);
 
        cmd_get_id = (cmd_get_id_t *)packet->data();
-       cmd_get_id->pid = getpid();
+
+       get_proc_name(getpid(), cmd_get_id->name);
 
        INFO("%s send cmd_get_id()", get_client_name());
 
@@ -480,33 +481,34 @@ bool command_channel::cmd_unregister_events(event_type_vector &event_vec)
        return true;
 }
 
-bool command_channel::cmd_set_interval(unsigned int interval)
+bool command_channel::cmd_set_batch(unsigned int interval, unsigned int latency)
 {
        cpacket *packet;
-       cmd_set_interval_t *cmd_set_interval;
+       cmd_set_batch_t *cmd_set_batch;
        cmd_done_t *cmd_done;
 
-       packet = new(std::nothrow) cpacket(sizeof(cmd_set_interval_t));
+       packet = new(std::nothrow) cpacket(sizeof(cmd_set_batch_t));
        retvm_if(!packet, false, "Failed to allocate memory");
 
-       packet->set_cmd(CMD_SET_INTERVAL);
+       packet->set_cmd(CMD_SET_BATCH);
 
-       cmd_set_interval = (cmd_set_interval_t*)packet->data();
-       cmd_set_interval->interval = interval;
+       cmd_set_batch = (cmd_set_batch_t*)packet->data();
+       cmd_set_batch->interval = interval;
+       cmd_set_batch->latency = latency;
 
-       INFO("%s send cmd_set_interval(client_id=%d, %s, interval=%d)",
-               get_client_name(), m_client_id, get_sensor_name(m_sensor_id), interval);
+       INFO("%s send cmd_set_batch(client_id=%d, %s, interval=%d, latency = %d)",
+               get_client_name(), m_client_id, get_sensor_name(m_sensor_id), interval, latency);
 
        if (!command_handler(packet, (void **)&cmd_done)) {
-               ERR("%s failed to send/receive command for sensor[%s] with client_id [%d], interval[%d]",
-                       get_client_name(), get_sensor_name(m_sensor_id), m_client_id, interval);
+               ERR("%s failed to send/receive command for sensor[%s] with client_id [%d], interval[%d], latency[%d]",
+                       get_client_name(), get_sensor_name(m_sensor_id), m_client_id, interval, latency);
                delete packet;
                return false;
        }
 
        if (cmd_done->value < 0) {
-               ERR("%s got error[%d] from server for sensor[%s] with client_id [%d], interval[%d]",
-                       get_client_name(), cmd_done->value, get_sensor_name(m_sensor_id), m_client_id, interval);
+               ERR("%s got error[%d] from server for sensor[%s] with client_id [%d], interval[%d], latency[%d]",
+                       get_client_name(), cmd_done->value, get_sensor_name(m_sensor_id), m_client_id, interval, latency);
 
                delete[] (char *)cmd_done;
                delete packet;
@@ -519,17 +521,17 @@ bool command_channel::cmd_set_interval(unsigned int interval)
        return true;
 }
 
-bool command_channel::cmd_unset_interval(void)
+bool command_channel::cmd_unset_batch(void)
 {
        cpacket *packet;
        cmd_done_t *cmd_done;
 
-       packet = new(std::nothrow) cpacket(sizeof(cmd_unset_interval_t));
+       packet = new(std::nothrow) cpacket(sizeof(cmd_unset_batch_t));
        retvm_if(!packet, false, "Failed to allocate memory");
 
-       packet->set_cmd(CMD_UNSET_INTERVAL);
+       packet->set_cmd(CMD_UNSET_BATCH);
 
-       INFO("%s send cmd_unset_interval(client_id=%d, %s)",
+       INFO("%s send cmd_unset_batch(client_id=%d, %s)",
                get_client_name(), m_client_id, get_sensor_name(m_sensor_id));
 
        if (!command_handler(packet, (void **)&cmd_done)) {
old mode 100755 (executable)
new mode 100644 (file)
index 2688c15..ae1ba6a
@@ -23,9 +23,6 @@
 #include <sensor_internal.h>
 #include <cpacket.h>
 #include <csocket.h>
-#include <vector>
-
-using std::vector;
 
 class command_channel
 {
@@ -48,8 +45,8 @@ public:
        bool cmd_register_events(event_type_vector &event_vec);
        bool cmd_unregister_event(unsigned int event_type);
        bool cmd_unregister_events(event_type_vector &event_vec);
-       bool cmd_set_interval(unsigned int interval);
-       bool cmd_unset_interval(void);
+       bool cmd_set_batch(unsigned int interval, unsigned int latency);
+       bool cmd_unset_batch(void);
        bool cmd_set_command(unsigned int cmd, long value);
        bool cmd_get_data(unsigned int type, sensor_data_t* values);
        bool cmd_send_sensorhub_data(const char* buffer, int data_len);
old mode 100755 (executable)
new mode 100644 (file)
index 82f23bd..a270d79
@@ -35,6 +35,7 @@ public:
        int m_handle;
        unsigned int type;
        unsigned int m_interval;
+       unsigned int m_latency;
        int m_cb_type;
        void *m_cb;
        void *m_user_data;
@@ -43,6 +44,7 @@ public:
 
        creg_event_info():m_id(0), m_handle(-1),
                        type(0), m_interval(POLL_1HZ_MS),
+                       m_latency(0),
                        m_cb_type(SENSOR_EVENT_CB), m_cb(NULL), m_user_data(NULL),
                        m_previous_event_time(0), m_fired(false){}
 
old mode 100755 (executable)
new mode 100644 (file)
index 7dbebc3..dea77e0
 
 #include <thread>
 #include <chrono>
+#include <vector>
 
 #define MS_TO_US 1000
 #define MIN_DELIVERY_DIFF_FACTOR 0.75f
 
 using std::thread;
 using std::pair;
+using std::vector;
 
 csensor_event_listener::csensor_event_listener()
 : m_client_id(CLIENT_ID_INVALID)
@@ -114,7 +116,7 @@ bool csensor_event_listener::stop_handle(int handle)
 }
 
 bool csensor_event_listener::register_event(int handle, unsigned int event_type,
-               unsigned int interval, int cb_type, void *cb, void* user_data)
+               unsigned int interval, unsigned int latency, int cb_type, void *cb, void* user_data)
 {
        AUTOLOCK(m_handle_info_lock);
 
@@ -125,7 +127,7 @@ bool csensor_event_listener::register_event(int handle, unsigned int event_type,
                return false;
        }
 
-       if (!it_handle->second.add_reg_event_info(event_type, interval, cb_type, cb, user_data))
+       if (!it_handle->second.add_reg_event_info(event_type, interval, latency, cb_type, cb, user_data))
                return false;
 
        return true;
@@ -148,24 +150,6 @@ bool csensor_event_listener::unregister_event(int handle, unsigned int event_typ
        return true;
 }
 
-bool csensor_event_listener::change_event_interval(int handle, unsigned int event_type,
-               unsigned int interval)
-{
-       AUTOLOCK(m_handle_info_lock);
-
-       auto it_handle = m_sensor_handle_infos.find(handle);
-
-       if (it_handle == m_sensor_handle_infos.end()) {
-               ERR("Handle[%d] is not found for client %s", handle, get_client_name());
-               return false;
-       }
-
-       if (!it_handle->second.change_reg_event_interval(event_type, interval))
-               return false;
-
-       return true;
-}
-
 bool csensor_event_listener::register_accuracy_cb(int handle, sensor_accuracy_changed_cb_t cb, void* user_data)
 {
        AUTOLOCK(m_handle_info_lock);
@@ -268,7 +252,7 @@ bool csensor_event_listener::set_sensor_option(int handle, int sensor_option)
        return true;
 }
 
-bool csensor_event_listener::set_event_interval(int handle, unsigned int event_type, unsigned int interval)
+bool csensor_event_listener::set_event_batch(int handle, unsigned int event_type, unsigned int interval, unsigned int latency)
 {
        AUTOLOCK(m_handle_info_lock);
 
@@ -279,14 +263,14 @@ bool csensor_event_listener::set_event_interval(int handle, unsigned int event_t
                return false;
        }
 
-       if (!it_handle->second.change_reg_event_interval(event_type, interval))
+       if (!it_handle->second.change_reg_event_batch(event_type, interval, latency))
                return false;
 
        return true;
 }
 
 
-bool csensor_event_listener::get_event_info(int handle, unsigned int event_type, unsigned int &interval, int &cb_type, void* &cb, void* &user_data)
+bool csensor_event_listener::get_event_info(int handle, unsigned int event_type, unsigned int &interval, unsigned int &latency, int &cb_type, void* &cb, void* &user_data)
 {
        AUTOLOCK(m_handle_info_lock);
 
@@ -304,8 +288,8 @@ bool csensor_event_listener::get_event_info(int handle, unsigned int event_type,
        if (!event_info)
                return NULL;
 
-
        interval = event_info->m_interval;
+       latency = event_info->m_latency;
        cb_type = event_info->m_cb_type;
        cb = event_info->m_cb;
        user_data = event_info->m_user_data;
@@ -332,13 +316,18 @@ void csensor_event_listener::get_listening_sensors(sensor_id_vector &sensors)
 
 void csensor_event_listener::get_sensor_rep(sensor_id_t sensor, sensor_rep& rep)
 {
+       const unsigned int INVALID_BATCH_VALUE = std::numeric_limits<unsigned int>::max();
+
        AUTOLOCK(m_handle_info_lock);
 
        rep.active = is_sensor_active(sensor);
        rep.option = get_active_option(sensor);
-       rep.interval = get_active_min_interval(sensor);
-       get_active_event_types(sensor, rep.event_types);
+       if (!get_active_batch(sensor, rep.interval, rep.latency)) {
+               rep.interval = INVALID_BATCH_VALUE;
+               rep.latency = INVALID_BATCH_VALUE;
+       }
 
+       get_active_event_types(sensor, rep.event_types);
 }
 
 void csensor_event_listener::operate_sensor(sensor_id_t sensor, int power_save_state)
@@ -443,11 +432,14 @@ void csensor_event_listener::set_client_id(int client_id)
        m_client_id = client_id;
 }
 
-unsigned int csensor_event_listener::get_active_min_interval(sensor_id_t sensor)
+bool csensor_event_listener::get_active_batch(sensor_id_t sensor, unsigned int &interval, unsigned int &latency)
 {
        unsigned int min_interval = POLL_MAX_HZ_MS;
+       unsigned int min_latency = std::numeric_limits<unsigned int>::max();
+
        bool active_sensor_found = false;
-       unsigned int interval;
+       unsigned int _interval;
+       unsigned int _latency;
 
        AUTOLOCK(m_handle_info_lock);
 
@@ -457,18 +449,23 @@ unsigned int csensor_event_listener::get_active_min_interval(sensor_id_t sensor)
                if ((it_handle->second.m_sensor_id == sensor) &&
                        (it_handle->second.m_sensor_state == SENSOR_STATE_STARTED)) {
                                active_sensor_found = true;
-                               interval = it_handle->second.get_min_interval();
-                               min_interval = (interval < min_interval) ? interval : min_interval;
+                               it_handle->second.get_batch(_interval, _latency);
+                               min_interval = (_interval < min_interval) ? _interval : min_interval;
+                               min_latency = (_latency < min_latency) ? _latency : min_latency;
                }
 
                ++it_handle;
        }
 
-       if (!active_sensor_found)
+       if (!active_sensor_found) {
                DBG("Active sensor[0x%x] is not found for client %s", sensor, get_client_name());
+               return false;
+       }
 
-       return (active_sensor_found) ? min_interval : 0;
+       interval = min_interval;
+       latency = min_latency;
 
+       return true;
 }
 
 unsigned int csensor_event_listener::get_active_option(sensor_id_t sensor)
old mode 100755 (executable)
new mode 100644 (file)
index 0f7ac49..2986273
 #include <cmutex.h>
 #include <poller.h>
 
-using std::unordered_map;
-using std::vector;
-using std::string;
-using std::queue;
-using std::mutex;
-using std::lock_guard;
-using std::unique_lock;
-using std::condition_variable;
-
-typedef vector<unsigned int> handle_vector;
-typedef vector<sensor_id_t> sensor_id_vector;
-typedef unordered_map<int,csensor_handle_info> sensor_handle_info_map;
-typedef unordered_map<sensor_id_t, command_channel*> sensor_command_channel_map;
+typedef std::vector<unsigned int> handle_vector;
+typedef std::vector<sensor_id_t> sensor_id_vector;
+typedef std::unordered_map<int,csensor_handle_info> sensor_handle_info_map;
+typedef std::unordered_map<sensor_id_t, command_channel*> sensor_command_channel_map;
 
 typedef struct {
        unsigned long long event_id;
@@ -72,6 +63,7 @@ typedef struct sensor_rep
        bool active;
        int option;
        unsigned int interval;
+       unsigned int latency;
        event_type_vector event_types;
 } sensor_rep;
 
@@ -84,9 +76,8 @@ public:
        bool delete_handle(int handle);
        bool start_handle(int handle);
        bool stop_handle(int handle);
-       bool register_event(int handle, unsigned int event_type, unsigned int interval, int cb_type, void *cb, void* user_data);
+       bool register_event(int handle, unsigned int event_type, unsigned int interval, unsigned int latency, int cb_type, void *cb, void* user_data);
        bool unregister_event(int handle, unsigned int event_type);
-       bool change_event_interval(int handle, unsigned int event_type, unsigned int interval);
 
        bool register_accuracy_cb(int handle, sensor_accuracy_changed_cb_t cb, void* user_data);
        bool unregister_accuracy_cb(int handle);
@@ -95,12 +86,12 @@ public:
        bool get_sensor_params(int handle, int &sensor_state, int &sensor_option);
        bool set_sensor_state(int handle, int sensor_state);
        bool set_sensor_option(int handle, int sensor_option);
-       bool set_event_interval(int handle, unsigned int event_type, unsigned int interval);
-       bool get_event_info(int handle, unsigned int event_type, unsigned int &interval, int &cb_type, void* &cb, void* &user_data);
+       bool set_event_batch(int handle, unsigned int event_type, unsigned int interval, unsigned int latency);
+       bool get_event_info(int handle, unsigned int event_type, unsigned int &interval, unsigned int &latency, int &cb_type, void* &cb, void* &user_data);
        void operate_sensor(sensor_id_t sensor, int power_save_state);
        void get_listening_sensors(sensor_id_vector &sensors);
 
-       unsigned int get_active_min_interval(sensor_id_t sensor_id);
+       bool get_active_batch(sensor_id_t sensor_id, unsigned int &interval, unsigned int &latency);
        unsigned int get_active_option(sensor_id_t sensor_id);
        void get_active_event_types(sensor_id_t sensor_id, event_type_vector &active_event_types);
 
@@ -135,8 +126,8 @@ private:
                THREAD_STATE_STOP,
                THREAD_STATE_TERMINATE,
        };
-       typedef lock_guard<mutex> lock;
-       typedef unique_lock<mutex> ulock;
+       typedef std::lock_guard<std::mutex> lock;
+       typedef std::unique_lock<std::mutex> ulock;
 
        sensor_handle_info_map m_sensor_handle_infos;
        sensor_command_channel_map m_command_channels;
@@ -149,8 +140,8 @@ private:
        cmutex m_handle_info_lock;
 
        thread_state m_thread_state;
-       mutex m_thread_mutex;
-       condition_variable m_thread_cond;
+       std::mutex m_thread_mutex;
+       std::condition_variable m_thread_cond;
 
        hup_observer_t m_hup_observer;
 
old mode 100755 (executable)
new mode 100644 (file)
index d1c8dbb..3aa173f
@@ -19,6 +19,7 @@
 
 #include <client_common.h>
 #include <csensor_handle_info.h>
+#include <limits>
 
 using std::pair;
 
@@ -64,7 +65,7 @@ void csensor_handle_info::get_reg_event_types(event_type_vector &event_types)
        }
 }
 
-bool csensor_handle_info::add_reg_event_info(unsigned int event_type, unsigned int interval, int cb_type, void *cb, void *user_data)
+bool csensor_handle_info::add_reg_event_info(unsigned int event_type, unsigned int interval, unsigned int latency, int cb_type, void *cb, void *user_data)
 {
        creg_event_info event_info;
 
@@ -79,6 +80,7 @@ bool csensor_handle_info::add_reg_event_info(unsigned int event_type, unsigned i
        event_info.m_handle = m_handle;
        event_info.type = event_type;
        event_info.m_interval = interval;
+       event_info.m_latency = latency;
        event_info.m_cb_type = cb_type;
        event_info.m_cb = cb;
        event_info.m_user_data = user_data;
@@ -113,7 +115,7 @@ unsigned long long csensor_handle_info::renew_event_id(void)
        return m_event_id++;
 }
 
-bool csensor_handle_info::change_reg_event_interval(unsigned int event_type, unsigned int interval)
+bool csensor_handle_info::change_reg_event_batch(unsigned int event_type, unsigned int interval, unsigned int latency)
 {
        auto it_event = m_reg_event_infos.find(event_type);
 
@@ -124,29 +126,39 @@ bool csensor_handle_info::change_reg_event_interval(unsigned int event_type, uns
 
        it_event->second.m_id = renew_event_id();
        it_event->second.m_interval = interval;
+       it_event->second.m_latency = latency;
 
        return true;
 }
 
-unsigned int csensor_handle_info::get_min_interval(void)
+void csensor_handle_info::get_batch(unsigned int &interval, unsigned int &latency)
 {
-       unsigned int min_interval = POLL_MAX_HZ_MS;
-       unsigned int interval;
-
        if (m_reg_event_infos.empty()) {
                DBG("No events are registered for client %s", get_client_name());
-               return min_interval;
+               interval = POLL_MAX_HZ_MS;
+               latency = 0;
+               return;
        }
 
+       unsigned int min_interval = POLL_MAX_HZ_MS;
+       unsigned int min_latency = std::numeric_limits<unsigned int>::max();
+
+       unsigned int _interval;
+       unsigned int _latency;
+
        auto it_event = m_reg_event_infos.begin();
 
        while (it_event != m_reg_event_infos.end()) {
-               interval = it_event->second.m_interval;
-               min_interval = (interval < min_interval) ? interval : min_interval;
+               _interval = it_event->second.m_interval;
+               _latency = it_event->second.m_latency;
+
+               min_interval = (_interval < min_interval) ? _interval : min_interval;
+               min_latency = (_latency < min_latency) ? _latency : min_latency;
                ++it_event;
        }
 
-       return min_interval;
+       interval = min_interval;
+       latency = min_latency;
 }
 
 unsigned int csensor_handle_info::get_reg_event_count(void)
old mode 100755 (executable)
new mode 100644 (file)
index b6eca9b..3330dbe
 #include <common.h>
 #include <string.h>
 #include <unordered_map>
-#include <vector>
-using std::unordered_map;
-using std::vector;
 
-typedef unordered_map<unsigned int,creg_event_info> event_info_map;
+typedef std::unordered_map<unsigned int,creg_event_info> event_info_map;
 
 class csensor_handle_info {
 public:
@@ -45,14 +42,14 @@ public:
        csensor_handle_info();
        ~csensor_handle_info();
 
-       bool add_reg_event_info(unsigned int event_type, unsigned int interval, int cb_type, void *cb,void *user_data);
+       bool add_reg_event_info(unsigned int event_type, unsigned int interval, unsigned int latency, int cb_type, void *cb,void *user_data);
        bool delete_reg_event_info(unsigned int event_type);
 
-       bool change_reg_event_interval(unsigned int event_type, unsigned int interval);
+       bool change_reg_event_batch(unsigned int event_type, unsigned int interval, unsigned int latency);
 
        creg_event_info* get_reg_event_info(const unsigned int event_type);
        void get_reg_event_types(event_type_vector &event_types);
-       unsigned int get_min_interval(void);
+       void get_batch(unsigned int &interval, unsigned int &latency);
        unsigned int get_reg_event_count(void);
 
        void clear_all_events(void);
index 5650518..eaf7d93 100755 (executable)
@@ -29,8 +29,6 @@
 #include <algorithm>
 #include <queue>
 
-using std::queue;
-
 class poller {
 public:
        poller(int fd);
@@ -39,7 +37,7 @@ public:
        bool poll(int &event);
 private:
        int m_epfd;
-       queue<int> m_event_queue;
+       std::queue<int> m_event_queue;
 
        bool create(int fd);
        bool fill_event_queue(void);
index f4c6fe1..4a427f2 100755 (executable)
 
 #include <sensor_info_manager.h>
 #include <utility>
+#include <vector>
 
 using std::pair;
 using std::make_pair;
+using std::vector;
 
 sensor_info_manager::sensor_info_manager()
 {
index 512905f..084b5a3 100755 (executable)
 #include <unordered_map>
 #include <unordered_set>
 
-using std::multimap;
-using std::unordered_map;
-using std::unordered_set;
-
 class sensor_info_manager {
 public:
        static sensor_info_manager& get_instance(void);
        const sensor_info* get_info(sensor_type_t type);
-       vector<sensor_info *> get_infos(sensor_type_t type);
+       std::vector<sensor_info *> get_infos(sensor_type_t type);
        const sensor_info* get_info(sensor_id_t id);
        bool is_valid(sensor_info* info);
        void add_info(sensor_info* info);
 
 private:
-       typedef multimap<sensor_type_t, sensor_info*> sensor_infos;
-       typedef unordered_map<sensor_id_t, sensor_info*> id_to_info_map;
-       typedef unordered_set<sensor_info*> info_set;
+       typedef std::multimap<sensor_type_t, sensor_info*> sensor_infos;
+       typedef std::unordered_map<sensor_id_t, sensor_info*> id_to_info_map;
+       typedef std::unordered_set<sensor_info*> info_set;
 
        sensor_info_manager();
        ~sensor_info_manager();
old mode 100755 (executable)
new mode 100644 (file)
index 49c74dc..ff107cb
 #define DEPRECATED __attribute__((deprecated))
 #endif
 
+#ifndef API
+#define API __attribute__((visibility("default")))
+#endif
+
 #include "stdbool.h"
 
 #ifdef __cplusplus
@@ -298,10 +302,11 @@ bool sensord_change_event_interval(int handle, unsigned int event_type, unsigned
  * @brief Change the max batch latency of a specifed event type in a connected sensor.
  *
  * @param[in] handle a handle represensting a connected sensor.
+ * @param[in] event_type an event type to change max batch latency
  * @param[in] max_batch_latency an event in the batch can be delayed by at most max_batch_latency microseconds. If this is set to zero, batch mode is disabled.
  * @return true on success, otherwise false.
  */
-bool sensord_change_event_max_batch_latency(int handle, unsigned int max_batch_latency);
+bool sensord_change_event_max_batch_latency(int handle, unsigned int event_type, unsigned int max_batch_latency);
 
 /**
  * @brief Change the option of a connected sensor.
index 22939d9..1c99fa4 100755 (executable)
@@ -40,7 +40,7 @@ enum proxi_event_type {
 };
 
 enum proxi_change_state {
-       PROXIMITY_STATE_FAR             = 0,
+       PROXIMITY_STATE_FAR     = 0,
        PROXIMITY_STATE_NEAR    = 1,
 };
 
index 73e45cc..e0a61f1 100755 (executable)
 #include <light_sensor.h>
 #include <sensor_plugin_loader.h>
 #include <algorithm>
+#include <string>
 
 using std::bind1st;
 using std::mem_fun;
+using std::string;
+using std::vector;
 
 #define SENSOR_NAME "LIGHT_SENSOR"
 
@@ -56,7 +59,7 @@ light_sensor::~light_sensor()
 
 bool light_sensor::init()
 {
-       m_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(LIGHT_SENSOR);
+       m_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(SENSOR_HAL_TYPE_LIGHT);
 
        if (!m_sensor_hal) {
                ERR("cannot load sensor_hal[%s]", sensor_base::get_name());
@@ -64,12 +67,13 @@ bool light_sensor::init()
        }
 
        INFO("%s is created!", sensor_base::get_name());
+
        return true;
 }
 
-sensor_type_t light_sensor::get_type(void)
+void light_sensor::get_types(vector<sensor_type_t> &types)
 {
-       return LIGHT_SENSOR;
+       types.push_back(LIGHT_SENSOR);
 }
 
 bool light_sensor::working(void *inst)
@@ -148,7 +152,7 @@ bool light_sensor::on_stop(void)
        return stop_poll();
 }
 
-bool light_sensor::get_properties(sensor_properties_s &properties)
+bool light_sensor::get_properties(sensor_type_t sensor_type, sensor_properties_s &properties)
 {
        m_sensor_hal->get_properties(properties);
        return true;
index cdc8e50..1b6d0ca 100755 (executable)
@@ -30,14 +30,13 @@ public:
        virtual ~light_sensor();
 
        virtual bool init();
-       virtual sensor_type_t get_type(void);
+       virtual void get_types(std::vector<sensor_type_t> &types);
 
        static bool working(void *inst);
 
        virtual bool set_interval(unsigned long interval);
-       virtual bool get_properties(sensor_properties_s &properties);
        int get_sensor_data(const unsigned int type, sensor_data_t &data);
-
+       virtual bool get_properties(sensor_type_t sensor_type, sensor_properties_s &properties);
 private:
        static const int m_light_level[];
 
index 835a096..bf3a613 100755 (executable)
@@ -26,6 +26,7 @@
 #include <sys/ioctl.h>
 
 using std::ifstream;
+using std::string;
 
 #define SENSOR_TYPE_LIGHT              "LIGHT"
 #define ELEMENT_NAME                   "NAME"
@@ -114,9 +115,9 @@ string light_sensor_hal::get_model_id(void)
 }
 
 
-sensor_type_t light_sensor_hal::get_type(void)
+sensor_hal_type_t light_sensor_hal::get_type(void)
 {
-       return LIGHT_SENSOR;
+       return SENSOR_HAL_TYPE_LIGHT;
 }
 
 bool light_sensor_hal::enable(void)
index 89a88f1..560cb87 100755 (executable)
 #define _LIGHT_SENSOR_HAL_H_
 
 #include <sensor_hal.h>
-#include <string>
-
-using std::string;
 
 class light_sensor_hal : public sensor_hal
 {
 public:
        light_sensor_hal();
        virtual ~light_sensor_hal();
-       string get_model_id(void);
-       sensor_type_t get_type(void);
+       std::string get_model_id(void);
+       sensor_hal_type_t get_type(void);
        bool enable(void);
        bool disable(void);
        bool set_interval(unsigned long val);
@@ -39,9 +36,9 @@ public:
        virtual int get_sensor_data(sensor_data_t &data);
        bool get_properties(sensor_properties_s &properties);
 private:
-       string m_model_id;
-       string m_vendor;
-       string m_chip_name;
+       std::string m_model_id;
+       std::string m_vendor;
+       std::string m_chip_name;
 
        unsigned long m_polling_interval;
 
@@ -50,9 +47,9 @@ private:
        unsigned long long m_fired_time;
        int m_node_handle;
 
-       string m_enable_node;
-       string m_data_node;
-       string m_interval_node;
+       std::string m_enable_node;
+       std::string m_data_node;
+       std::string m_interval_node;
 
        bool m_sensorhub_controlled;
 
index 6e21ab2..fc2a1bb 100755 (executable)
@@ -31,6 +31,9 @@
 #include <sensor_plugin_loader.h>
 #include <cvirtual_sensor_config.h>
 
+using std::string;
+using std::vector;
+
 #define SENSOR_NAME "LINEAR_ACCEL_SENSOR"
 #define SENSOR_TYPE_LINEAR_ACCEL       "LINEAR_ACCEL"
 #define SENSOR_TYPE_GRAVITY            "GRAVITY"
@@ -78,7 +81,7 @@ linear_accel_sensor::linear_accel_sensor()
        m_enable_linear_accel = 0;
        register_supported_event(LINEAR_ACCEL_RAW_DATA_EVENT);
 
-       sensor_hal *fusion_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(FUSION_SENSOR);
+       sensor_hal *fusion_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(SENSOR_HAL_TYPE_FUSION);
        if (!fusion_sensor_hal)
                m_hardware_fusion = false;
        else
@@ -195,9 +198,9 @@ bool linear_accel_sensor::init()
        return true;
 }
 
-sensor_type_t linear_accel_sensor::get_type(void)
+void linear_accel_sensor::get_types(vector<sensor_type_t> &types)
 {
-       return LINEAR_ACCEL_SENSOR;
+       types.push_back(LINEAR_ACCEL_SENSOR);
 }
 
 bool linear_accel_sensor::on_start(void)
@@ -416,9 +419,9 @@ int linear_accel_sensor::get_sensor_data(const unsigned int event_type, sensor_d
        return 0;
 }
 
-bool linear_accel_sensor::get_properties(sensor_properties_s &properties)
+bool linear_accel_sensor::get_properties(sensor_type_t sensor_type, sensor_properties_s &properties)
 {
-       m_accel_sensor->get_properties(properties);
+       m_accel_sensor->get_properties(ACCELEROMETER_SENSOR, properties);
        properties.name = "Linear Acceleration Sensor";
        properties.vendor = m_vendor;
        properties.resolution = 0.000001;
index e8f8395..e201b93 100755 (executable)
@@ -30,15 +30,15 @@ public:
        virtual ~linear_accel_sensor();
 
        bool init();
-       sensor_type_t get_type(void);
+       virtual void get_types(std::vector<sensor_type_t> &types);
 
-       void synthesize(const sensor_event_t &event, vector<sensor_event_t> &outs);
+       void synthesize(const sensor_event_t& event, std::vector<sensor_event_t> &outs);
 
        bool add_interval(int client_id, unsigned int interval);
        bool delete_interval(int client_id);
 
        int get_sensor_data(const unsigned int event_type, sensor_data_t &data);
-       bool get_properties(sensor_properties_s &properties);
+       virtual bool get_properties(sensor_type_t sensor_type, sensor_properties_s &properties);
 private:
        sensor_base *m_accel_sensor;
        sensor_base *m_gyro_sensor;
@@ -56,9 +56,9 @@ private:
 
        unsigned int m_enable_linear_accel;
 
-       string m_vendor;
-       string m_raw_data_unit;
-       string m_orientation_data_unit;
+       std::string m_vendor;
+       std::string m_raw_data_unit;
+       std::string m_orientation_data_unit;
        int m_default_sampling_time;
        float m_accel_static_bias[3];
        int m_accel_rotation_direction_compensation[3];
index 44d44bd..e560007 100755 (executable)
@@ -32,6 +32,9 @@
 #include <orientation_filter.h>
 #include <cvirtual_sensor_config.h>
 
+using std::string;
+using std::vector;
+
 #define SENSOR_NAME "ORIENTATION_SENSOR"
 #define SENSOR_TYPE_ORIENTATION                "ORIENTATION"
 
@@ -61,7 +64,7 @@ orientation_sensor::orientation_sensor()
 {
        cvirtual_sensor_config &config = cvirtual_sensor_config::get_instance();
 
-       sensor_hal *fusion_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(FUSION_SENSOR);
+       sensor_hal *fusion_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(SENSOR_HAL_TYPE_FUSION);
        if (!fusion_sensor_hal)
                m_hardware_fusion = false;
        else
@@ -139,9 +142,9 @@ bool orientation_sensor::init(void)
        return true;
 }
 
-sensor_type_t orientation_sensor::get_type(void)
+void orientation_sensor::get_types(vector<sensor_type_t> &types)
 {
-       return ORIENTATION_SENSOR;
+       types.push_back(ORIENTATION_SENSOR);
 }
 
 bool orientation_sensor::on_start(void)
@@ -314,7 +317,7 @@ int orientation_sensor::get_sensor_data(const unsigned int event_type, sensor_da
        return 0;
 }
 
-bool orientation_sensor::get_properties(sensor_properties_s &properties)
+bool orientation_sensor::get_properties(sensor_type_t sensor_type, sensor_properties_s &properties)
 {
        if(m_raw_data_unit == "DEGREES") {
                properties.min_range = -180;
index 86c39f9..070a21b 100755 (executable)
@@ -31,12 +31,12 @@ public:
 
        bool init(void);
 
-       void synthesize(const sensor_event_t &event, vector<sensor_event_t> &outs);
+       void synthesize(const sensor_event_t& event, std::vector<sensor_event_t> &outs);
 
        bool add_interval(int client_id, unsigned int interval);
        bool delete_interval(int client_id);
-       bool get_properties(sensor_properties_s &properties);
-       sensor_type_t get_type(void);
+       virtual bool get_properties(sensor_type_t sensor_type, sensor_properties_s &properties);
+       virtual void get_types(std::vector<sensor_type_t> &types);
 
        int get_sensor_data(const unsigned int event_type, sensor_data_t &data);
 
@@ -55,8 +55,8 @@ private:
        unsigned long long m_time;
        unsigned int m_interval;
 
-       string m_vendor;
-       string m_raw_data_unit;
+       std::string m_vendor;
+       std::string m_raw_data_unit;
        int m_default_sampling_time;
        int m_azimuth_rotation_compensation;
        int m_pitch_rotation_compensation;
index 407c6f9..0559021 100755 (executable)
@@ -26,6 +26,8 @@
 
 using std::bind1st;
 using std::mem_fun;
+using std::string;
+using std::vector;
 
 #define SENSOR_NAME "PRESSURE_SENSOR"
 #define SENSOR_TYPE_PRESSURE           "PRESSURE"
@@ -55,7 +57,7 @@ pressure_sensor::~pressure_sensor()
 
 bool pressure_sensor::init()
 {
-       m_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(PRESSURE_SENSOR);
+       m_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(SENSOR_HAL_TYPE_PRESSURE);
 
        if (!m_sensor_hal) {
                ERR("cannot load sensor_hal[%s]", sensor_base::get_name());
@@ -100,9 +102,9 @@ bool pressure_sensor::init()
        return true;
 }
 
-sensor_type_t pressure_sensor::get_type(void)
+void pressure_sensor::get_types(vector<sensor_type_t> &types)
 {
-       return PRESSURE_SENSOR;
+       types.push_back(PRESSURE_SENSOR);
 }
 
 bool pressure_sensor::working(void *inst)
@@ -152,7 +154,7 @@ bool pressure_sensor::on_stop(void)
        return stop_poll();
 }
 
-bool pressure_sensor::get_properties(sensor_properties_s &properties)
+bool pressure_sensor::get_properties(sensor_type_t sensor_type, sensor_properties_s &properties)
 {
        return m_sensor_hal->get_properties(properties);
 }
index 3430dfb..e17f587 100755 (executable)
@@ -31,13 +31,13 @@ public:
        virtual ~pressure_sensor();
 
        bool init();
-       sensor_type_t get_type(void);
+       virtual void get_types(std::vector<sensor_type_t> &types);
 
        static bool working(void *inst);
 
        bool set_interval(unsigned long interval);
-       virtual bool get_properties(sensor_properties_s &properties);
        int get_sensor_data(unsigned int type, sensor_data_t &data);
+       virtual bool get_properties(sensor_type_t sensor_type, sensor_properties_s &properties);
 
 private:
        sensor_hal *m_sensor_hal;
index 33aa181..544240f 100755 (executable)
@@ -26,6 +26,7 @@
 #include <fstream>
 
 using std::ifstream;
+using std::string;
 
 #define SENSOR_TYPE_PRESSURE           "PRESSURE"
 #define ELEMENT_NAME                   "NAME"
@@ -151,9 +152,9 @@ string pressure_sensor_hal::get_model_id(void)
        return m_model_id;
 }
 
-sensor_type_t pressure_sensor_hal::get_type(void)
+sensor_hal_type_t pressure_sensor_hal::get_type(void)
 {
-       return PRESSURE_SENSOR;
+       return SENSOR_HAL_TYPE_PRESSURE;
 }
 
 bool pressure_sensor_hal::enable(void)
index 04412fc..07e8e1b 100755 (executable)
 #define _PRESSURE_SENSOR_HAL_H_
 
 #include <sensor_hal.h>
-#include <string>
-
-using std::string;
 
 class pressure_sensor_hal : public sensor_hal
 {
 public:
        pressure_sensor_hal();
        virtual ~pressure_sensor_hal();
-       string get_model_id(void);
-       sensor_type_t get_type(void);
+       std::string get_model_id(void);
+       sensor_hal_type_t get_type(void);
 
        bool enable(void);
        bool disable(void);
@@ -40,9 +37,9 @@ public:
        virtual int get_sensor_data(sensor_data_t &data);
        virtual bool get_properties(sensor_properties_s &properties);
 private:
-       string m_model_id;
-       string m_vendor;
-       string m_chip_name;
+       std::string m_model_id;
+       std::string m_vendor;
+       std::string m_chip_name;
 
        float m_pressure;
        float m_sea_level_pressure;
@@ -60,9 +57,9 @@ private:
        unsigned long long m_fired_time;
        int m_node_handle;
 
-       string m_enable_node;
-       string m_data_node;
-       string m_interval_node;
+       std::string m_enable_node;
+       std::string m_data_node;
+       std::string m_interval_node;
 
        bool m_sensorhub_controlled;
 
index 65809b9..05352d1 100755 (executable)
@@ -22,6 +22,9 @@
 #include <proxi_sensor.h>
 #include <sensor_plugin_loader.h>
 
+using std::string;
+using std::vector;
+
 #define SENSOR_NAME "PROXI_SENSOR"
 
 proxi_sensor::proxi_sensor()
@@ -44,7 +47,7 @@ proxi_sensor::~proxi_sensor()
 
 bool proxi_sensor::init()
 {
-       m_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(PROXIMITY_SENSOR);
+       m_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(SENSOR_HAL_TYPE_PROXIMITY);
 
        if (!m_sensor_hal) {
                ERR("cannot load sensor_hal[%s]", sensor_base::get_name());
@@ -55,9 +58,9 @@ bool proxi_sensor::init()
        return true;
 }
 
-sensor_type_t proxi_sensor::get_type(void)
+void proxi_sensor::get_types(vector<sensor_type_t> &types)
 {
-       return PROXIMITY_SENSOR;
+       types.push_back(PROXIMITY_SENSOR);
 }
 
 bool proxi_sensor::working(void *inst)
@@ -122,7 +125,7 @@ bool proxi_sensor::on_stop(void)
        return stop_poll();
 }
 
-bool proxi_sensor::get_properties(sensor_properties_s &properties)
+bool proxi_sensor::get_properties(sensor_type_t sensor_type, sensor_properties_s &properties)
 {
        m_sensor_hal->get_properties(properties);
 
index 8584f2d..9c3a009 100755 (executable)
@@ -30,12 +30,12 @@ public:
        virtual ~proxi_sensor();
 
        bool init();
-       sensor_type_t get_type(void);
+       virtual void get_types(std::vector<sensor_type_t> &types);
 
        static bool working(void *inst);
 
-       virtual bool get_properties(sensor_properties_s &properties);
        int get_sensor_data(unsigned int type, sensor_data_t &data);
+       virtual bool get_properties(sensor_type_t sensor_type, sensor_properties_s &properties);
 private:
        sensor_hal *m_sensor_hal;
 
index aee3f7a..7358b08 100755 (executable)
@@ -25,6 +25,7 @@
 #include <sys/ioctl.h>
 #include <fstream>
 
+using std::string;
 using std::ifstream;
 
 #define SENSOR_TYPE_PROXI              "PROXI"
@@ -107,9 +108,9 @@ string proxi_sensor_hal::get_model_id(void)
        return m_model_id;
 }
 
-sensor_type_t proxi_sensor_hal::get_type(void)
+sensor_hal_type_t proxi_sensor_hal::get_type(void)
 {
-       return PROXIMITY_SENSOR;
+       return SENSOR_HAL_TYPE_PROXIMITY;
 }
 
 bool proxi_sensor_hal::enable(void)
index 3b96b04..a1cd3a1 100755 (executable)
@@ -21,9 +21,6 @@
 #define _PROXI_SENSOR_HAL_H_
 
 #include <sensor_hal.h>
-#include <string>
-
-using std::string;
 
 class proxi_sensor_hal : public sensor_hal
 {
@@ -43,20 +40,20 @@ public:
 
        proxi_sensor_hal();
        virtual ~proxi_sensor_hal();
-       string get_model_id(void);
-       sensor_type_t get_type(void);
+       std::string get_model_id(void);
+       sensor_hal_type_t get_type(void);
        bool enable(void);
        bool disable(void);
        bool is_data_ready(bool wait);
        virtual int get_sensor_data(sensor_data_t &data);
        virtual bool get_properties(sensor_properties_s &properties);
 private:
-       string m_model_id;
-       string m_vendor;
-       string m_chip_name;
+       std::string m_model_id;
+       std::string m_vendor;
+       std::string m_chip_name;
 
-       string m_enable_node;
-       string m_data_node;
+       std::string m_enable_node;
+       std::string m_data_node;
 
        unsigned int m_state;
 
index fa359a0..f491038 100755 (executable)
@@ -32,6 +32,9 @@
 #include <orientation_filter.h>
 #include <cvirtual_sensor_config.h>
 
+using std::string;
+using std::vector;
+
 #define SENSOR_NAME "GAMING_RV_SENSOR"
 #define SENSOR_TYPE_GAMING_RV "GAMING_ROTATION_VECTOR"
 
@@ -69,7 +72,7 @@ gaming_rv_sensor::gaming_rv_sensor()
 {
        cvirtual_sensor_config &config = cvirtual_sensor_config::get_instance();
 
-       sensor_hal *fusion_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(FUSION_SENSOR);
+       sensor_hal *fusion_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(SENSOR_HAL_TYPE_FUSION);
        if (!fusion_sensor_hal)
                m_hardware_fusion = false;
        else
@@ -161,9 +164,9 @@ bool gaming_rv_sensor::init()
        return true;
 }
 
-sensor_type_t gaming_rv_sensor::get_type(void)
+void gaming_rv_sensor::get_types(vector<sensor_type_t> &types)
 {
-       return GAMING_RV_SENSOR;
+       types.push_back(GAMING_RV_SENSOR);
 }
 
 bool gaming_rv_sensor::on_start(void)
@@ -316,7 +319,7 @@ int gaming_rv_sensor::get_sensor_data(unsigned int event_type, sensor_data_t &da
        return 0;
 }
 
-bool gaming_rv_sensor::get_properties(sensor_properties_s &properties)
+bool gaming_rv_sensor::get_properties(sensor_type_t sensor_type, sensor_properties_s &properties)
 {
        properties.vendor = m_vendor;
        properties.name = SENSOR_NAME;
index db9dd47..1b748b1 100755 (executable)
@@ -31,12 +31,12 @@ public:
 
        bool init(void);
 
-       void synthesize(const sensor_event_t &event, vector<sensor_event_t> &outs);
+       void synthesize(const sensor_event_t &event, std::vector<sensor_event_t> &outs);
 
        bool add_interval(int client_id, unsigned int interval);
        bool delete_interval(int client_id);
-       bool get_properties(sensor_properties_s &properties);
-       sensor_type_t get_type(void);
+       virtual bool get_properties(sensor_type_t sensor_type, sensor_properties_s &properties);
+       virtual void get_types(std::vector<sensor_type_t> &types);
 
        int get_sensor_data(const unsigned int event_type, sensor_data_t &data);
 
@@ -58,8 +58,8 @@ private:
        unsigned long long m_time;
        unsigned int m_interval;
 
-       string m_vendor;
-       string m_raw_data_unit;
+       std::string m_vendor;
+       std::string m_raw_data_unit;
        int m_default_sampling_time;
 
        float m_accel_static_bias[3];
index c3e8a26..f4aafe8 100755 (executable)
@@ -32,6 +32,9 @@
 #include <orientation_filter.h>
 #include <cvirtual_sensor_config.h>
 
+using std::string;
+using std::vector;
+
 #define SENSOR_NAME "GEOMAGNETIC_RV_SENSOR"
 #define SENSOR_TYPE_GEOMAGNETIC_RV             "GEOMAGNETIC_ROTATION_VECTOR"
 
@@ -50,7 +53,7 @@ geomagnetic_rv_sensor::geomagnetic_rv_sensor()
 {
        cvirtual_sensor_config &config = cvirtual_sensor_config::get_instance();
 
-       sensor_hal *fusion_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(FUSION_SENSOR);
+       sensor_hal *fusion_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(SENSOR_HAL_TYPE_FUSION);
        if (!fusion_sensor_hal)
                m_hardware_fusion = false;
        else
@@ -99,9 +102,9 @@ bool geomagnetic_rv_sensor::init()
        return true;
 }
 
-sensor_type_t geomagnetic_rv_sensor::get_type(void)
+void geomagnetic_rv_sensor::get_types(vector<sensor_type_t> &types)
 {
-       return GEOMAGNETIC_RV_SENSOR;
+       types.push_back(GEOMAGNETIC_RV_SENSOR);
 }
 
 bool geomagnetic_rv_sensor::on_start(void)
@@ -227,7 +230,7 @@ int geomagnetic_rv_sensor::get_sensor_data(unsigned int event_type, sensor_data_
        return 0;
 }
 
-bool geomagnetic_rv_sensor::get_properties(sensor_properties_s &properties)
+bool geomagnetic_rv_sensor::get_properties(sensor_type_t sensor_type, sensor_properties_s &properties)
 {
        properties.vendor = m_vendor;
        properties.name = SENSOR_NAME;
index c87d252..f5ad4b7 100755 (executable)
@@ -31,12 +31,12 @@ public:
 
        bool init(void);
 
-       void synthesize(const sensor_event_t &event, vector<sensor_event_t> &outs);
+       void synthesize(const sensor_event_t &event, std::vector<sensor_event_t> &outs);
 
        bool add_interval(int client_id, unsigned int interval);
        bool delete_interval(int client_id);
-       bool get_properties(sensor_properties_s &properties);
-       sensor_type_t get_type(void);
+       virtual bool get_properties(sensor_type_t sensor_type, sensor_properties_s &properties);
+       virtual void get_types(std::vector<sensor_type_t> &types);
 
        int get_sensor_data(const unsigned int event_type, sensor_data_t &data);
 
@@ -53,8 +53,8 @@ private:
        unsigned long long m_time;
        unsigned int m_interval;
 
-       string m_vendor;
-       string m_raw_data_unit;
+       std::string m_vendor;
+       std::string m_raw_data_unit;
        int m_default_sampling_time;
 
        bool on_start(void);
index bcf20e2..e42716b 100755 (executable)
@@ -32,6 +32,9 @@
 #include <orientation_filter.h>
 #include <cvirtual_sensor_config.h>
 
+using std::string;
+using std::vector;
+
 #define SENSOR_NAME "RV_SENSOR"
 #define SENSOR_TYPE_RV         "ROTATION_VECTOR"
 
@@ -63,7 +66,7 @@ rv_sensor::rv_sensor()
        cvirtual_sensor_config &config = cvirtual_sensor_config::get_instance();
 
        // Will check if fusion_sensor is in the list of hal sensors.
-       sensor_hal *fusion_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(FUSION_SENSOR);
+       sensor_hal *fusion_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(SENSOR_HAL_TYPE_FUSION);
        if (!fusion_sensor_hal)
                m_hardware_fusion = false;
        else
@@ -114,9 +117,9 @@ bool rv_sensor::init()
        return true;
 }
 
-sensor_type_t rv_sensor::get_type(void)
+void rv_sensor::get_types(vector<sensor_type_t> &types)
 {
-       return ROTATION_VECTOR_SENSOR;
+       types.push_back(ROTATION_VECTOR_SENSOR);
 }
 
 bool rv_sensor::on_start(void)
@@ -249,7 +252,7 @@ int rv_sensor::get_sensor_data(unsigned int event_type, sensor_data_t &data)
        return 0;
 }
 
-bool rv_sensor::get_properties(sensor_properties_s &properties)
+bool rv_sensor::get_properties(sensor_type_t sensor_type, sensor_properties_s &properties)
 {
        properties.vendor = m_vendor;
        properties.name = SENSOR_NAME;
index 3e5de3d..00f9761 100755 (executable)
@@ -31,12 +31,12 @@ public:
 
        bool init(void);
 
-       void synthesize(const sensor_event_t &event, vector<sensor_event_t> &outs);
+       void synthesize(const sensor_event_t &event, std::vector<sensor_event_t> &outs);
 
        bool add_interval(int client_id, unsigned int interval);
        bool delete_interval(int client_id);
-       bool get_properties(sensor_properties_s &properties);
-       sensor_type_t get_type(void);
+       virtual bool get_properties(sensor_type_t sensor_type, sensor_properties_s &properties);
+       virtual void get_types(std::vector<sensor_type_t> &types);
 
        int get_sensor_data(const unsigned int event_type, sensor_data_t &data);
 
@@ -60,8 +60,8 @@ private:
        unsigned long long m_time;
        unsigned int m_interval;
 
-       string m_vendor;
-       string m_raw_data_unit;
+       std::string m_vendor;
+       std::string m_raw_data_unit;
        int m_default_sampling_time;
 
        bool on_start(void);
index 3e017ce..f1b3a2b 100755 (executable)
@@ -23,6 +23,9 @@
 #include <rv_raw_sensor.h>
 #include <sensor_plugin_loader.h>
 
+using std::string;
+using std::vector;
+
 #define SENSOR_NAME "RV_RAW_SENSOR"
 
 rv_raw_sensor::rv_raw_sensor()
@@ -43,7 +46,7 @@ rv_raw_sensor::~rv_raw_sensor()
 
 bool rv_raw_sensor::init()
 {
-       m_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(RV_RAW_SENSOR);
+       m_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(SENSOR_HAL_TYPE_RV_RAW);
 
        if (!m_sensor_hal) {
                ERR("cannot load sensor_hal[%s]", sensor_base::get_name());
@@ -64,9 +67,9 @@ bool rv_raw_sensor::init()
        return true;
 }
 
-sensor_type_t rv_raw_sensor::get_type(void)
+void rv_raw_sensor::get_types(vector<sensor_type_t> &types)
 {
-       return RV_RAW_SENSOR;
+       types.push_back(RV_RAW_SENSOR);
 }
 
 bool rv_raw_sensor::working(void *inst)
@@ -116,7 +119,7 @@ bool rv_raw_sensor::on_stop(void)
        return stop_poll();
 }
 
-bool rv_raw_sensor::get_properties(sensor_properties_t &properties)
+bool rv_raw_sensor::get_properties(sensor_type_t sensor_type, sensor_properties_s &properties)
 {
        return m_sensor_hal->get_properties(properties);
 }
index 4d04a4b..f55d0a1 100755 (executable)
@@ -31,13 +31,13 @@ public:
        virtual ~rv_raw_sensor();
 
        virtual bool init();
-       virtual sensor_type_t get_type(void);
+       virtual void get_types(std::vector<sensor_type_t> &types);
 
        static bool working(void *inst);
 
        virtual bool set_interval(unsigned long interval);
-       virtual bool get_properties(sensor_properties_t &properties);
        int get_sensor_data(unsigned int type, sensor_data_t &data);
+       virtual bool get_properties(sensor_type_t sensor_type, sensor_properties_s &properties);
 private:
        sensor_hal *m_sensor_hal;
 
index 261a81e..11eb5c4 100755 (executable)
@@ -26,6 +26,7 @@
 #include <fstream>
 
 using std::ifstream;
+using std::string;
 
 #define SENSOR_TYPE_RV_RAW     "ROTATION_VECTOR"
 #define ELEMENT_NAME                   "NAME"
@@ -108,9 +109,9 @@ string rv_raw_sensor_hal::get_model_id(void)
        return m_model_id;
 }
 
-sensor_type_t rv_raw_sensor_hal::get_type(void)
+sensor_hal_type_t rv_raw_sensor_hal::get_type(void)
 {
-       return RV_RAW_SENSOR;
+       return SENSOR_HAL_TYPE_RV_RAW;
 }
 
 bool rv_raw_sensor_hal::enable(void)
index 565b509..382f454 100755 (executable)
 #define _RV_RAW_SENSOR_HAL_H_
 
 #include <sensor_hal.h>
-#include <string>
-
-using std::string;
 
 class rv_raw_sensor_hal : public sensor_hal
 {
 public:
        rv_raw_sensor_hal();
        virtual ~rv_raw_sensor_hal();
-       string get_model_id(void);
-       sensor_type_t get_type(void);
+       std::string get_model_id(void);
+       sensor_hal_type_t get_type(void);
        bool enable(void);
        bool disable(void);
        bool set_interval(unsigned long val);
@@ -39,9 +36,9 @@ public:
        virtual int get_sensor_data(sensor_data_t &data);
        virtual bool get_properties(sensor_properties_t &properties);
 private:
-       string m_model_id;
-       string m_vendor;
-       string m_chip_name;
+       std::string m_model_id;
+       std::string m_vendor;
+       std::string m_chip_name;
 
        unsigned long m_polling_interval;
 
@@ -54,9 +51,9 @@ private:
        unsigned long long m_fired_time;
        int m_node_handle;
 
-       string m_enable_node;
-       string m_data_node;
-       string m_interval_node;
+       std::string m_enable_node;
+       std::string m_data_node;
+       std::string m_interval_node;
 
        bool m_sensorhub_controlled;
 
old mode 100755 (executable)
new mode 100644 (file)
index 09e633f..e88c897
 #include <sensor_gravity.h>
 #include <thread>
 #include <string>
+#include <vector>
 #include <utility>
 #include <permission_checker.h>
 #include <set>
 
 using std::string;
+using std::vector;
 using std::make_pair;
 using std::set;
 
@@ -47,6 +49,7 @@ command_worker::command_worker(const csocket& socket)
 , m_permission(SENSOR_PERMISSION_NONE)
 , m_socket(socket)
 , m_module(NULL)
+, m_sensor_id(UNKNOWN_SENSOR)
 {
        static bool init = false;
 
@@ -84,8 +87,8 @@ void command_worker::init_cmd_handlers(void)
        m_cmd_handlers[CMD_REG]                                 = &command_worker::cmd_register_event;
        m_cmd_handlers[CMD_UNREG]                               = &command_worker::cmd_unregister_event;
        m_cmd_handlers[CMD_SET_OPTION]                  = &command_worker::cmd_set_option;
-       m_cmd_handlers[CMD_SET_INTERVAL]                = &command_worker::cmd_set_interval;
-       m_cmd_handlers[CMD_UNSET_INTERVAL]              = &command_worker::cmd_unset_interval;
+       m_cmd_handlers[CMD_SET_BATCH]                   = &command_worker::cmd_set_batch;
+       m_cmd_handlers[CMD_UNSET_BATCH]                 = &command_worker::cmd_unset_batch;
        m_cmd_handlers[CMD_SET_COMMAND]                 = &command_worker::cmd_set_command;
        m_cmd_handlers[CMD_GET_DATA]                    = &command_worker::cmd_get_data;
        m_cmd_handlers[CMD_SEND_SENSORHUB_DATA] = &command_worker::cmd_send_sensorhub_data;
@@ -147,17 +150,26 @@ void command_worker::make_sensor_raw_data_map(void)
 
        sensors = sensor_plugin_loader::get_instance().get_sensors(ALL_SENSOR);
 
+    std::sort(sensors.begin(), sensors.end());
+    auto last = std::unique(sensors.begin(), sensors.end());
+
        auto it_sensor = sensors.begin();
 
-       while (it_sensor != sensors.end()) {
-               (*it_sensor)->get_sensor_info(info);
-               permission = (*it_sensor)->get_permission();
+       while (it_sensor != last) {
+
+               vector<sensor_type_t> types;
+               (*it_sensor)->get_types(types);
 
-               sensor_raw_data_map::iterator it_sensor_raw_data;
-               it_sensor_raw_data = m_sensor_raw_data_map.insert(std::make_pair(permission, raw_data_t()));
+               for (unsigned int i = 0; i < types.size(); ++i) {
+                       (*it_sensor)->get_sensor_info(types[i], info);
+                       permission = (*it_sensor)->get_permission();
 
-               info.get_raw_data(it_sensor_raw_data->second);
-               info.clear();
+                       sensor_raw_data_map::iterator it_sensor_raw_data;
+                       it_sensor_raw_data = m_sensor_raw_data_map.insert(std::make_pair(permission, raw_data_t()));
+
+                       info.get_raw_data(it_sensor_raw_data->second);
+                       info.clear();
+               }
                ++it_sensor;
        }
 }
@@ -213,7 +225,7 @@ bool command_worker::stopped(void *ctx)
 
        if ((inst->m_module) && (inst->m_client_id != CLIENT_ID_INVALID)) {
 
-               get_client_info_manager().get_registered_events(inst->m_client_id, inst->m_module->get_id(), event_vec);
+               get_client_info_manager().get_registered_events(inst->m_client_id, inst->m_sensor_id, event_vec);
 
                auto it_event = event_vec.begin();
 
@@ -225,16 +237,16 @@ bool command_worker::stopped(void *ctx)
                        ++it_event;
                }
 
-               if (get_client_info_manager().is_started(inst->m_client_id, inst->m_module->get_id())) {
+               if (get_client_info_manager().is_started(inst->m_client_id, inst->m_sensor_id)) {
                        WARN("Does not receive cmd_stop before connection broken for [%s]!!", inst->m_module->get_name());
                        inst->m_module->delete_interval(inst->m_client_id, false);
                        inst->m_module->stop();
                }
 
-               if (inst->m_module->get_id()) {
-                       if (get_client_info_manager().has_sensor_record(inst->m_client_id, inst->m_module->get_id())) {
-                               INFO("Removing sensor[0x%x] record for client_id[%d]", inst->m_module->get_id(), inst->m_client_id);
-                               get_client_info_manager().remove_sensor_record(inst->m_client_id, inst->m_module->get_id());
+               if (inst->m_sensor_id) {
+                       if (get_client_info_manager().has_sensor_record(inst->m_client_id, inst->m_sensor_id)) {
+                               INFO("Removing sensor[0x%x] record for client_id[%d]", inst->m_sensor_id, inst->m_client_id);
+                               get_client_info_manager().remove_sensor_record(inst->m_client_id, inst->m_sensor_id);
                        }
                }
        }
@@ -356,12 +368,20 @@ bool command_worker::cmd_get_id(void *payload)
 {
        cmd_get_id_t *cmd;
        int client_id;
+       struct ucred cr;
+       socklen_t opt_len = sizeof(cr);
 
        DBG("CMD_GET_ID Handler invoked\n");
        cmd = (cmd_get_id_t*)payload;
 
+       if (getsockopt(m_socket.get_socket_fd(), SOL_SOCKET, SO_PEERCRED, &cr, &opt_len)) {
+               ERR("Failed to get socket option with SO_PEERCRED");
+               return false;
+       }
+
        client_id = get_client_info_manager().create_client_record();
-       get_client_info_manager().set_client_info(client_id, cmd->pid);
+
+       get_client_info_manager().set_client_info(client_id, cr.pid, cmd->name);
 
        m_permission = get_permission();
        get_client_info_manager().set_permission(client_id, m_permission);
@@ -393,6 +413,7 @@ bool command_worker::cmd_hello(void *payload)
        DBG("CMD_HELLO Handler invoked\n");
        cmd = (cmd_hello_t*)payload;
 
+       m_sensor_id = cmd->sensor;
        m_client_id = cmd->client_id;
 
        if (m_permission == SENSOR_PERMISSION_NONE)
@@ -410,14 +431,14 @@ bool command_worker::cmd_hello(void *payload)
        }
 
        if (!is_permission_allowed()) {
-               ERR("Permission denied to connect sensor[0x%x] for client [%d]", m_module->get_id(), m_client_id);
+               ERR("Permission denied to connect sensor[0x%x] for client [%d]", m_sensor_id, m_client_id);
                ret_value = OP_ERROR;
                goto out;
        }
 
-       DBG("Hello sensor [0x%x], client id [%d]", m_module->get_id(), m_client_id);
-       get_client_info_manager().create_sensor_record(m_client_id, m_module->get_id());
-       INFO("New sensor record created for sensor [0x%x], sensor name [%s] on client id [%d]\n", m_module->get_id(), m_module->get_name(), m_client_id);
+       DBG("Hello sensor [0x%x], client id [%d]", m_sensor_id, m_client_id);
+       get_client_info_manager().create_sensor_record(m_client_id, m_sensor_id);
+       INFO("New sensor record created for sensor [0x%x], sensor name [%s] on client id [%d]\n", m_sensor_id, m_module->get_name(), m_client_id);
        ret_value = OP_SUCCESS;
 out:
        if (!send_cmd_done(ret_value))
@@ -431,14 +452,14 @@ bool command_worker::cmd_byebye(void *payload)
        long ret_value = OP_ERROR;
 
        if (!is_permission_allowed()) {
-               ERR("Permission denied to stop sensor[0x%x] for client [%d]", m_module? m_module->get_id() : -1, m_client_id);
+               ERR("Permission denied to stop sensor[0x%x] for client [%d]", m_sensor_id, m_client_id);
                ret_value = OP_ERROR;
                goto out;
        }
 
-       DBG("CMD_BYEBYE for client [%d], sensor [0x%x]", m_client_id, m_module->get_id());
+       DBG("CMD_BYEBYE for client [%d], sensor [0x%x]", m_client_id, m_sensor_id);
 
-       if (!get_client_info_manager().remove_sensor_record(m_client_id, m_module->get_id())) {
+       if (!get_client_info_manager().remove_sensor_record(m_client_id, m_sensor_id)) {
                ERR("Error removing sensor_record for client [%d]", m_client_id);
                ret_value = OP_ERROR;
                goto out;
@@ -462,24 +483,24 @@ bool command_worker::cmd_start(void *payload)
        long ret_value = OP_ERROR;
 
        if (!is_permission_allowed()) {
-               ERR("Permission denied to start sensor[0x%x] for client [%d]", m_module? m_module->get_id() : -1, m_client_id);
+               ERR("Permission denied to start sensor[0x%x] for client [%d]", m_sensor_id, m_client_id);
                ret_value = OP_ERROR;
                goto out;
        }
 
-       DBG("START Sensor [0x%x], called from client [%d]", m_module->get_id(), m_client_id);
+       DBG("START Sensor [0x%x], called from client [%d]", m_sensor_id, m_client_id);
 
        if (m_module->start()) {
-               get_client_info_manager().set_start(m_client_id, m_module->get_id(), true);
+               get_client_info_manager().set_start(m_client_id, m_sensor_id, true);
 /*
  *     Rotation could be changed even LCD is off by pop sync rotation
  *     and a client listening rotation event with always-on option.
  *     To reflect the last rotation state, request it to event dispatcher.
  */
-               get_event_dispathcher().request_last_event(m_client_id, m_module->get_id());
+               get_event_dispathcher().request_last_event(m_client_id, m_sensor_id);
                ret_value = OP_SUCCESS;
        } else {
-               ERR("Failed to start sensor [0x%x] for client [%d]", m_module->get_id(), m_client_id);
+               ERR("Failed to start sensor [0x%x] for client [%d]", m_sensor_id, m_client_id);
                ret_value = OP_ERROR;
        }
 
@@ -495,18 +516,18 @@ bool command_worker::cmd_stop(void *payload)
        long ret_value = OP_ERROR;
 
        if (!is_permission_allowed()) {
-               ERR("Permission denied to stop sensor[0x%x] for client [%d]", m_module? m_module->get_id() : -1, m_client_id);
+               ERR("Permission denied to stop sensor[0x%x] for client [%d]", m_sensor_id, m_client_id);
                ret_value = OP_ERROR;
                goto out;
        }
 
-       DBG("STOP Sensor [0x%x], called from client [%d]", m_module->get_id(), m_client_id);
+       DBG("STOP Sensor [0x%x], called from client [%d]", m_sensor_id, m_client_id);
 
        if (m_module->stop()) {
-               get_client_info_manager().set_start(m_client_id, m_module->get_id(), false);
+               get_client_info_manager().set_start(m_client_id, m_sensor_id, false);
                ret_value = OP_SUCCESS;
        } else {
-               ERR("Failed to stop sensor [0x%x] for client [%d]", m_module->get_id(), m_client_id);
+               ERR("Failed to stop sensor [0x%x] for client [%d]", m_sensor_id, m_client_id);
                ret_value = OP_ERROR;
        }
 
@@ -531,7 +552,7 @@ bool command_worker::cmd_register_event(void *payload)
                goto out;
        }
 
-       if (!get_client_info_manager().register_event(m_client_id, m_module? m_module->get_id() : -1, cmd->event_type)) {
+       if (!get_client_info_manager().register_event(m_client_id, m_sensor_id, cmd->event_type)) {
                INFO("Failed to register event [0x%x] for client [%d] to client info manager",
                        cmd->event_type, m_client_id);
                ret_value = OP_ERROR;
@@ -565,7 +586,7 @@ bool command_worker::cmd_unregister_event(void *payload)
                goto out;
        }
 
-       if (!get_client_info_manager().unregister_event(m_client_id, m_module->get_id(), cmd->event_type)) {
+       if (!get_client_info_manager().unregister_event(m_client_id, m_sensor_id, cmd->event_type)) {
                ERR("Failed to unregister event [0x%x] for client [%d] from client info manager",
                        cmd->event_type, m_client_id);
                ret_value = OP_ERROR;
@@ -590,30 +611,30 @@ out:
        return true;
 }
 
-bool command_worker::cmd_set_interval(void *payload)
+bool command_worker::cmd_set_batch(void *payload)
 {
-       cmd_set_interval_t *cmd;
+       cmd_set_batch_t *cmd;
        long ret_value = OP_ERROR;
 
-       cmd = (cmd_set_interval_t*)payload;
+       cmd = (cmd_set_batch_t*)payload;
 
        if (!is_permission_allowed()) {
-               ERR("Permission denied to register interval for client [%d], for sensor [0x%x] with interval [%d] to client info manager",
-                       m_client_id, m_module? m_module->get_id() : -1, cmd->interval);
+               ERR("Permission denied to set batch for client [%d], for sensor [0x%x] with batch [%d, %d] to client info manager",
+                       m_client_id, m_sensor_id, cmd->interval, cmd->latency);
                ret_value = OP_ERROR;
                goto out;
        }
 
-       if (!get_client_info_manager().set_interval(m_client_id, m_module->get_id(), cmd->interval)) {
-               ERR("Failed to register interval for client [%d], for sensor [0x%x] with interval [%d] to client info manager",
-                       m_client_id, m_module->get_id(), cmd->interval);
+       if (!get_client_info_manager().set_batch(m_client_id, m_sensor_id, cmd->interval, cmd->latency)) {
+               ERR("Failed to set batch for client [%d], for sensor [0x%x] with batch [%d, %d] to client info manager",
+                       m_client_id, m_sensor_id, cmd->interval, cmd->latency);
                ret_value = OP_ERROR;
                goto out;
        }
 
        if (!m_module->add_interval(m_client_id, cmd->interval, false)) {
                ERR("Failed to set interval for client [%d], for sensor [0x%x] with interval [%d]",
-                       m_client_id, m_module->get_id(), cmd->interval);
+                       m_client_id, m_sensor_id, cmd->interval);
                ret_value = OP_ERROR;
                goto out;
        }
@@ -627,20 +648,20 @@ out:
        return true;
 }
 
-bool command_worker::cmd_unset_interval(void *payload)
+bool command_worker::cmd_unset_batch(void *payload)
 {
        long ret_value = OP_ERROR;
 
        if (!is_permission_allowed()) {
-               ERR("Permission denied to unregister interval for client [%d], for sensor [0x%x] to client info manager",
-                       m_client_id, m_module? m_module->get_id() : -1);
+               ERR("Permission denied to unset batch for client [%d], for sensor [0x%x] to client info manager",
+                       m_client_id, m_sensor_id);
                ret_value = OP_ERROR;
                goto out;
        }
 
-       if (!get_client_info_manager().set_interval(m_client_id, m_module->get_id(), 0)) {
-               ERR("Failed to unregister interval for client [%d], for sensor [0x%x] to client info manager",
-                       m_client_id, m_module->get_id());
+       if (!get_client_info_manager().set_batch(m_client_id, m_sensor_id, 0, 0)) {
+               ERR("Failed to unset batch for client [%d], for sensor [0x%x] to client info manager",
+                       m_client_id, m_sensor_id);
                ret_value = OP_ERROR;
                goto out;
        }
@@ -669,14 +690,14 @@ bool command_worker::cmd_set_option(void *payload)
 
        if (!is_permission_allowed()) {
                ERR("Permission denied to set interval for client [%d], for sensor [0x%x] with option [%d] to client info manager",
-                       m_client_id, m_module? m_module->get_id() : -1, cmd->option);
+                       m_client_id, m_sensor_id, cmd->option);
                ret_value = OP_ERROR;
                goto out;
        }
 
-       if (!get_client_info_manager().set_option(m_client_id, m_module->get_id(), cmd->option)) {
+       if (!get_client_info_manager().set_option(m_client_id, m_sensor_id, cmd->option)) {
                ERR("Failed to set option for client [%d], for sensor [0x%x] with option [%d] to client info manager",
-                       m_client_id, m_module->get_id(), cmd->option);
+                       m_client_id, m_sensor_id, cmd->option);
                ret_value = OP_ERROR;
                goto out;
        }
@@ -700,7 +721,7 @@ bool command_worker::cmd_set_command(void *payload)
 
        if (!is_permission_allowed()) {
                ERR("Permission denied to set command for client [%d], for sensor [0x%x] with cmd [%d]",
-                       m_client_id, m_module? m_module->get_id() : -1, cmd->cmd);
+                       m_client_id, m_sensor_id, cmd->cmd);
                ret_value = OP_ERROR;
                goto out;
        }
@@ -729,7 +750,7 @@ bool command_worker::cmd_get_data(void *payload)
 
        if (!is_permission_allowed()) {
                ERR("Permission denied to get data for client [%d], for sensor [0x%x]",
-                       m_client_id, m_module? m_module->get_id() : -1);
+                       m_client_id, m_sensor_id);
                state = OP_ERROR;
                goto out;
        }
@@ -744,7 +765,7 @@ bool command_worker::cmd_get_data(void *payload)
        // 5. repeat 2 ~ 4 operations RETRY_CNT times
        // 6. reverting back to original interval
        if (!state && !data.timestamp) {
-               const int RETRY_CNT     = 3;
+               const int RETRY_CNT     = 5;
                const unsigned long long INIT_WAIT_TIME = 20000; //20ms
                const unsigned long WAIT_TIME = 100000; //100ms
                int retry = 0;
@@ -757,7 +778,7 @@ bool command_worker::cmd_get_data(void *payload)
                }
 
                while (!state && !data.timestamp && (retry++ < RETRY_CNT)) {
-                       INFO("Wait sensor[0x%x] data updated for client [%d] #%d", m_module->get_id(), m_client_id, retry);
+                       INFO("Wait sensor[0x%x] data updated for client [%d] #%d", m_sensor_id, m_client_id, retry);
                        usleep((retry == 1) ? INIT_WAIT_TIME : WAIT_TIME);
                        state = m_module->get_sensor_data(cmd->type, data);
                }
@@ -771,7 +792,7 @@ bool command_worker::cmd_get_data(void *payload)
 
        if (state) {
                ERR("Failed to get data for client [%d], for sensor [0x%x]",
-                       m_client_id, m_module->get_id());
+                       m_client_id, m_sensor_id);
        }
 
 out:
@@ -791,7 +812,7 @@ bool command_worker::cmd_send_sensorhub_data(void *payload)
 
        if (!is_permission_allowed()) {
                ERR("Permission denied to send sensorhub_data for client [%d], for sensor [0x%x]",
-                       m_client_id, m_module? m_module->get_id() : -1);
+                       m_client_id, m_sensor_id);
                ret_value = OP_ERROR;
                goto out;
        }
old mode 100755 (executable)
new mode 100644 (file)
index 33f1b0a..89796f5
@@ -26,9 +26,7 @@
 #include <sensor_base.h>
 #include <map>
 
-using std::multimap;
-
-typedef multimap<int, raw_data_t> sensor_raw_data_map;
+typedef std::multimap<int, raw_data_t> sensor_raw_data_map;
 void insert_priority_list(unsigned int);
 
 class command_worker {
@@ -43,6 +41,7 @@ private:
        csocket m_socket;
        worker_thread m_worker;
        sensor_base *m_module;
+       sensor_id_t m_sensor_id;
        static cmd_handler_t m_cmd_handlers[CMD_CNT];
        static cpacket m_sensor_list;
        static sensor_raw_data_map m_sensor_raw_data_map;
@@ -70,14 +69,14 @@ private:
        bool cmd_stop(void *payload);
        bool cmd_register_event(void *payload);
        bool cmd_unregister_event(void *payload);
-       bool cmd_set_interval(void *payload);
-       bool cmd_unset_interval(void *payload);
+       bool cmd_set_batch(void *payload);
+       bool cmd_unset_batch(void *payload);
        bool cmd_set_option(void *payload);
        bool cmd_set_command(void *payload);
        bool cmd_get_data(void *payload);
        bool cmd_send_sensorhub_data(void *payload);
 
-       void get_info(string &info);
+       void get_info(std::string &info);
 
        int get_permission(void);
        bool is_permission_allowed(void);
index c9be4e0..91c8674 100755 (executable)
@@ -22,6 +22,9 @@
 #include <server.h>
 #include <dbus_util.h>
 #include <sensor_plugin_loader.h>
+#include <string>
+
+using std::string;
 
 static void sig_term_handler(int signo, siginfo_t *info, void *data)
 {
@@ -60,8 +63,6 @@ int main(int argc, char *argv[])
 
        server::get_instance().stop();
 
-       sensor_plugin_loader::get_instance().destroy();
-
        INFO("Sensord terminated");
        return 0;
 }
index f4fff18..dea1763 100755 (executable)
@@ -81,7 +81,7 @@ void permission_checker::init()
        m_permission_infos.push_back(std::make_shared<permission_info> (SENSOR_PERMISSION_STANDARD, false, ""));
        m_permission_infos.push_back(std::make_shared<permission_info> (SENSOR_PERMISSION_BIO, true, "http://tizen.org/privilege/healthinfo"));
 
-       vector<sensor_base *> sensors;
+       std::vector<sensor_base *> sensors;
        sensors = sensor_plugin_loader::get_instance().get_sensors(ALL_SENSOR);
 
        for (unsigned int i = 0; i < sensors.size(); ++i)
old mode 100755 (executable)
new mode 100644 (file)
index 2cadc1a..cdc35ee
@@ -29,6 +29,7 @@ add_library(sensord-server SHARED
        cclient_info_manager.cpp
        cclient_sensor_record.cpp
        cinterval_info_list.cpp
+       batch_info_list.cpp
        sensor_plugin_loader.cpp
        sensor_hal.cpp
        sensor_base.cpp
@@ -63,6 +64,7 @@ install(FILES
        cvirtual_sensor_config.h
        csensor_event_queue.h
        cinterval_info_list.h
+       batch_info_list.h
        sensor_plugin_loader.h
        sensor_hal.h
        sensor_base.h
diff --git a/src/shared/batch_info_list.cpp b/src/shared/batch_info_list.cpp
new file mode 100644 (file)
index 0000000..0fd84b1
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * libsensord-share
+ *
+ * Copyright (c) 2015 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 <batch_info_list.h>
+#include <algorithm>
+
+using std::pair;
+using std::shared_ptr;
+
+batch_info::batch_info(unsigned int interval, unsigned int latency)
+{
+       this->interval = interval;
+       this->latency = latency;
+}
+
+bool batch_info_list::add_batch(int id, unsigned int interval, unsigned int latency)
+{
+       auto it_batch_info = m_batch_infos.find(id);
+
+       if (it_batch_info != m_batch_infos.end()) {
+               it_batch_info->second->interval = interval;
+               it_batch_info->second->latency = latency;
+               return true;
+       }
+
+       m_batch_infos.insert(pair<int, shared_ptr<batch_info>> (id, std::make_shared<batch_info> (interval, latency)));
+       return true;
+}
+
+bool batch_info_list::delete_batch(int id)
+{
+       auto it_batch_info = m_batch_infos.find(id);
+
+       if (it_batch_info == m_batch_infos.end())
+               return false;
+
+       m_batch_infos.erase(it_batch_info);
+       return true;
+}
+
+bool batch_info_list::get_batch(int id, unsigned int &interval, unsigned int &latency)
+{
+       auto it_batch_info = m_batch_infos.find(id);
+
+       if (it_batch_info == m_batch_infos.end())
+               return false;
+
+       interval = it_batch_info->second->interval;
+       latency = it_batch_info->second->latency;
+
+       return true;
+}
+
+bool batch_info_list::get_best_batch(unsigned int &interval, unsigned int &latency)
+{
+       if (m_batch_infos.empty())
+               return false;
+
+       auto get_min_interval = [](pair<const int, shared_ptr<batch_info>> &a, pair<const int, shared_ptr<batch_info>> &b){
+               return (a.second->interval < b.second->interval);
+       };
+
+       auto get_min_latency = [](pair<const int, shared_ptr<batch_info>> &a, pair<const int, shared_ptr<batch_info>> &b){
+               return (a.second->latency < b.second->latency);
+       };
+
+       auto it_interval_min = std::min_element(m_batch_infos.begin(), m_batch_infos.end(), get_min_interval);
+       auto it_latency_min = std::min_element(m_batch_infos.begin(), m_batch_infos.end(), get_min_latency);
+
+       interval = it_interval_min->second->interval;
+       latency = it_latency_min->second->latency;
+
+       return true;
+}
diff --git a/src/shared/batch_info_list.h b/src/shared/batch_info_list.h
new file mode 100644 (file)
index 0000000..d6c22f0
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * libsensord-share
+ *
+ * Copyright (c) 2015 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.
+ *
+ */
+
+#ifndef _BATCH_INFO_LIST_CLASS_H_
+#define _BATCH_INFO_LIST_CLASS_H_
+
+#include <unordered_map>
+#include <memory>
+
+class batch_info
+{
+public:
+       batch_info(unsigned int interval, unsigned int latency);
+       unsigned int interval;
+       unsigned int latency;
+};
+
+class batch_info_list
+{
+private:
+       std::unordered_map<int, std::shared_ptr<batch_info>> m_batch_infos;
+
+public:
+       bool add_batch(int id, unsigned int interval, unsigned int latency);
+       bool delete_batch(int id);
+       bool get_batch(int id, unsigned int &interval, unsigned int &latency);
+       bool get_best_batch(unsigned int &interval, unsigned int &latency);
+};
+#endif
old mode 100755 (executable)
new mode 100644 (file)
index 3302167..1a142de
@@ -22,6 +22,7 @@
 #include <csocket.h>
 
 using std::pair;
+using std::string;
 
 cclient_info_manager::cclient_info_manager()
 {
@@ -37,21 +38,6 @@ cclient_info_manager& cclient_info_manager::get_instance()
        return inst;
 }
 
-
-unsigned int cclient_info_manager::get_interval(int client_id, sensor_id_t sensor_id)
-{
-       AUTOLOCK(m_mutex);
-
-       auto it_record = m_clients.find(client_id);
-
-       if (it_record == m_clients.end()) {
-               ERR("Client[%d] is not found", client_id);
-               return 0;
-       }
-
-       return it_record->second.get_interval(sensor_id);
-}
-
 bool cclient_info_manager::get_registered_events(int client_id, sensor_id_t sensor_id, event_type_vector &event_vec)
 {
        AUTOLOCK(m_mutex);
@@ -104,7 +90,7 @@ bool cclient_info_manager::unregister_event(int client_id, sensor_id_t sensor_id
        return true;
 }
 
-bool cclient_info_manager::set_interval(int client_id, sensor_id_t sensor_id, unsigned int interval)
+bool cclient_info_manager::set_batch(int client_id, sensor_id_t sensor_id, unsigned int interval, unsigned latency)
 {
        AUTOLOCK(m_mutex);
 
@@ -115,10 +101,21 @@ bool cclient_info_manager::set_interval(int client_id, sensor_id_t sensor_id, un
                return false;
        }
 
-       if(!it_record->second.set_interval(sensor_id, interval))
+       return it_record->second.set_batch(sensor_id, interval, latency);
+}
+
+bool cclient_info_manager::get_batch(int client_id, sensor_id_t sensor_id, unsigned int &interval, unsigned int &latency)
+{
+       AUTOLOCK(m_mutex);
+
+       auto it_record = m_clients.find(client_id);
+
+       if (it_record == m_clients.end()) {
+               ERR("Client[%d] is not found", client_id);
                return false;
+       }
 
-       return true;
+       return it_record->second.get_batch(sensor_id, interval, latency);
 }
 
 bool cclient_info_manager::set_option(int client_id, sensor_id_t sensor_id, int option)
@@ -224,7 +221,7 @@ bool cclient_info_manager::has_client_record(int client_id)
 }
 
 
-void cclient_info_manager::set_client_info(int client_id, pid_t pid)
+void cclient_info_manager::set_client_info(int client_id, pid_t pid, const string &name)
 {
        AUTOLOCK(m_mutex);
 
@@ -235,7 +232,7 @@ void cclient_info_manager::set_client_info(int client_id, pid_t pid)
                return;
        }
 
-       it_record->second.set_client_info(pid);
+       it_record->second.set_client_info(pid, name);
 
        return;
 }
old mode 100755 (executable)
new mode 100644 (file)
index ccf67ae..e36c2fb
 #include <unordered_map>
 #include <common.h>
 #include <cmutex.h>
-using std::unordered_map;
+#include <vector>
 
-typedef unordered_map<int,cclient_sensor_record> client_id_sensor_record_map;
-typedef vector<int> client_id_vec;
+typedef std::unordered_map<int,cclient_sensor_record> client_id_sensor_record_map;
+typedef std::vector<int> client_id_vec;
 
 
 class cclient_info_manager {
@@ -37,7 +37,7 @@ public:
        bool remove_client_record(int client_id);
        bool has_client_record(int client_id);
 
-       void set_client_info(int client_id, pid_t pid);
+       void set_client_info(int client_id, pid_t pid, const std::string &name);
        const char* get_client_info(int client_id);
 
        bool set_permission(int client_id, int permission);
@@ -51,8 +51,8 @@ public:
        bool register_event(int client_id, sensor_id_t sensor_id, unsigned int event_type);
        bool unregister_event(int client_id, sensor_id_t sensor_id, unsigned int event_type);
 
-       bool set_interval(int client_id, sensor_id_t sensor_id, unsigned int interval);
-       unsigned int get_interval(int client_id, sensor_id_t sensor_id);
+       bool set_batch(int client_id, sensor_id_t sensor_id, unsigned int interval, unsigned int latency);
+       bool get_batch(int client_id, sensor_id_t sensor_id, unsigned int &interval, unsigned int &latency);
        bool set_option(int client_id, sensor_id_t sensor_id, int option);
 
        bool set_start(int client_id, sensor_id_t sensor_id, bool start);
old mode 100755 (executable)
new mode 100644 (file)
index a302e4c..6995862
@@ -21,6 +21,7 @@
 #include <common.h>
 
 using std::pair;
+using std::string;
 
 cclient_sensor_record::cclient_sensor_record()
 : m_client_id(0)
@@ -72,21 +73,6 @@ bool cclient_sensor_record::unregister_event(sensor_id_t sensor_id, unsigned int
        return true;
 }
 
-bool cclient_sensor_record::set_interval(sensor_id_t sensor_id, unsigned int interval)
-{
-       auto it_usage = m_sensor_usages.find(sensor_id);
-
-       if (it_usage == m_sensor_usages.end()) {
-               csensor_usage usage;
-               usage.m_interval = interval;
-               m_sensor_usages.insert(pair<sensor_id_t, csensor_usage>(sensor_id, usage));
-       } else {
-               it_usage->second.m_interval = interval;
-       }
-
-       return true;
-}
-
 bool cclient_sensor_record::set_option(sensor_id_t sensor_id, int option)
 {
        auto it_usage = m_sensor_usages.find(sensor_id);
@@ -128,18 +114,36 @@ bool cclient_sensor_record::is_started(sensor_id_t sensor_id)
        return it_usage->second.m_start;
 }
 
+bool cclient_sensor_record::set_batch(sensor_id_t sensor_id, unsigned int interval, unsigned int latency)
+{
+       auto it_usage = m_sensor_usages.find(sensor_id);
 
+       if (it_usage == m_sensor_usages.end()) {
+               csensor_usage usage;
+               usage.m_interval = interval;
+               usage.m_latency = latency;
+               m_sensor_usages.insert(pair<sensor_id_t, csensor_usage>(sensor_id, usage));
+       } else {
+               it_usage->second.m_interval = interval;
+               it_usage->second.m_latency = latency;
+       }
 
-unsigned int cclient_sensor_record::get_interval(sensor_id_t sensor_id)
+       return true;
+}
+
+bool cclient_sensor_record::get_batch(sensor_id_t sensor_id, unsigned int &interval, unsigned int &latency)
 {
        auto it_usage = m_sensor_usages.find(sensor_id);
 
        if (it_usage == m_sensor_usages.end()) {
                ERR("Sensor[0x%x] is not found", sensor_id);
-               return 0;
+               return false;
        }
 
-       return it_usage->second.m_interval;
+       interval = it_usage->second.m_interval;
+       latency = it_usage->second.m_latency;
+
+       return true;
 }
 
 bool cclient_sensor_record::is_listening_event(sensor_id_t sensor_id, unsigned int event_type)
@@ -223,17 +227,13 @@ void cclient_sensor_record::set_client_id(int client_id)
        m_client_id = client_id;
 }
 
-void cclient_sensor_record::set_client_info(pid_t pid)
+void cclient_sensor_record::set_client_info(pid_t pid, const string &name)
 {
        char client_info[NAME_MAX + 32];
-       char proc_name[NAME_MAX];
-
        m_pid = pid;
-       get_proc_name(pid, proc_name);
 
-       snprintf(client_info, sizeof(client_info), "%s[pid=%d, id=%d]", proc_name, m_pid, m_client_id);
+       snprintf(client_info, sizeof(client_info), "%s[pid=%d, id=%d]", name.c_str(), m_pid, m_client_id);
        m_client_info.assign(client_info);
-
 }
 
 const char* cclient_sensor_record::get_client_info(void)
old mode 100755 (executable)
new mode 100644 (file)
index c2d9ef7..d42093e
 #include <csensor_usage.h>
 #include <csocket.h>
 #include <unordered_map>
+#include <string>
 
-using std::unordered_map;
-
-typedef unordered_map<sensor_id_t, csensor_usage> sensor_usage_map;
+typedef std::unordered_map<sensor_id_t, csensor_usage> sensor_usage_map;
 
 class cclient_sensor_record {
 public:
@@ -37,7 +36,7 @@ public:
 
        void set_client_id(int client_id);
 
-       void set_client_info(pid_t pid);
+       void set_client_info(pid_t pid, const std::string &name);
        const char* get_client_info(void);
 
        void set_permission(int permission);
@@ -46,8 +45,8 @@ public:
        bool register_event(sensor_id_t sensor_id, unsigned int event_type);
        bool unregister_event(sensor_id_t sensor_id, unsigned int event_type);
 
-       bool set_interval(sensor_id_t sensor_id, unsigned int interval);
-       unsigned int get_interval(sensor_id_t sensor_id);
+       bool set_batch(sensor_id_t sensor_id, unsigned int interval, unsigned int latency);
+       bool get_batch(sensor_id_t sensor_id, unsigned int &interval, unsigned int &latency);
        bool set_option(sensor_id_t sensor_id, int option);
 
        bool set_start(sensor_id_t sensor_id, bool start);
@@ -70,7 +69,7 @@ private:
        int m_client_id;
        pid_t m_pid;
        int m_permission;
-       string m_client_info;
+       std::string m_client_info;
        csocket m_event_socket;
        sensor_usage_map m_sensor_usages;
 };
index 23d11a5..14c7f01 100755 (executable)
 
 #include <cconfig.h>
 #include <fstream>
+#include <string>
 
 using std::ifstream;
+using std::string;
+using std::istringstream;
 
 cconfig::cconfig(void)
 {
index aa92fdd..dd23b11 100755 (executable)
 #include <unordered_map>
 #include <common.h>
 
-using std::unordered_map;
-using std::string;
-using std::istringstream;
-
 class cconfig
 {
 protected:
-       virtual bool load_config(const string& config_path) = 0;
+       virtual bool load_config(const std::string& config_path) = 0;
 
-       string m_device_id;
+       std::string m_device_id;
 public:
        cconfig();
        virtual ~cconfig();
index 340cba6..3c28c95 100755 (executable)
@@ -21,7 +21,6 @@
 #define _CINTERVAL_INFO_LIST_CLASS_H_
 
 #include <list>
-using std::list;
 
 class cinterval_info
 {
@@ -32,7 +31,7 @@ public:
        unsigned int interval;
 };
 
-typedef list<cinterval_info>::iterator cinterval_info_iterator;
+typedef std::list<cinterval_info>::iterator cinterval_info_iterator;
 
 class cinterval_info_list
 {
@@ -40,7 +39,7 @@ private:
        static bool comp_interval_info(cinterval_info a, cinterval_info b);
        cinterval_info_iterator find_if(int client_id, bool is_processor);
 
-       list<cinterval_info> m_list;
+       std::list<cinterval_info> m_list;
 
 public:
        bool add_interval(int client_id, unsigned int interval, bool is_processor);
old mode 100755 (executable)
new mode 100644 (file)
index 884bbf3..7196266
@@ -113,6 +113,7 @@ EXTAPI void sf_log(int type , int priority , const char *tag , const char *fmt ,
        va_end(ap);
 }
 
+#if defined(_DEBUG)
 bool get_proc_name(pid_t pid, char *process_name)
 {
        FILE *fp;
@@ -131,10 +132,26 @@ bool get_proc_name(pid_t pid, char *process_name)
        }
 
        strncpy(process_name, buf, NAME_MAX-1);
+       process_name[NAME_MAX-1] = '\0';
        fclose(fp);
 
        return true;
 }
+#else
+bool get_proc_name(pid_t pid, char *process_name)
+{
+       char buf[NAME_MAX];
+
+       if (sprintf(buf, "%d process", pid) < 1) {
+               return false;
+       }
+
+       strncpy(process_name, buf, NAME_MAX-1);
+       process_name[NAME_MAX-1] = '\0';
+
+       return true;
+}
+#endif
 
 const char* get_client_name(void)
 {
index 1f193a7..f36c818 100755 (executable)
 #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"
index d4c69a5..5ce6c74 100755 (executable)
@@ -24,7 +24,7 @@
 
 #define SENSOR_CONFIG_FILE_PATH "/usr/etc/sensors.xml"
 
-typedef unordered_map<string,string> Element;
+typedef std::unordered_map<std::string,std::string> Element;
 /*
 * an Element  is a group of attributes
 * <Element value1 = "10.0", value2 =  "20.0"/>
@@ -33,7 +33,7 @@ typedef unordered_map<string,string> Element;
 *
 */
 
-typedef unordered_map<string,Element> Model;
+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" />
@@ -45,7 +45,7 @@ typedef unordered_map<string,Element> Model;
 *
 */
 
-typedef unordered_map<string,Model> Model_list;
+typedef std::unordered_map<std::string,Model> Model_list;
 /*
 * a Model_list is  a group of Model
 * <MODEL id = "lsm330dlc_accel">
@@ -57,7 +57,7 @@ typedef unordered_map<string,Model> Model_list;
 *
 */
 
-typedef unordered_map<string,Model_list> Sensor_config;
+typedef std::unordered_map<std::string,Model_list> Sensor_config;
 /*
 * a SensorConfig represents sensors.xml
 * <ACCEL/>
@@ -75,21 +75,21 @@ private:
        csensor_config(csensor_config const&) {};
        csensor_config& operator=(csensor_config const&);
 
-       bool load_config(const string& config_path);
+       bool load_config(const std::string& config_path);
 
        Sensor_config m_sensor_config;
 public:
        static csensor_config& get_instance(void);
 
-       bool get(const string& sensor_type, const string& model_id, const string& element, const string& attr, string& value);
-       bool get(const string& sensor_type, const string& model_id, const string& element, const string& attr, double& value);
-       bool get(const string& sensor_type, const string& model_id, const string& element, const string& attr, long& value);
+       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 string& sensor_type, const string& model_id, const string& element, string& value);
-       bool get(const string& sensor_type, const string& model_id, const string& element, double& value);
-       bool get(const string& sensor_type, const string& model_id, const string& element, 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 string &sensor_type, const string &model_id);
+       bool is_supported(const std::string &sensor_type, const std::string &model_id);
 };
 
 #endif
index 6906ee2..1fc79e0 100755 (executable)
 #include <common.h>
 #include <sf_common.h>
 #include <thread>
+#include <vector>
+
 using std::thread;
+using std::vector;
 
 #define MAX_PENDING_CONNECTION 32
 
index fe9eba1..27131c2 100755 (executable)
 #include <cclient_info_manager.h>
 #include <csocket.h>
 #include <virtual_sensor.h>
+#include <unordered_map>
+#include <list>
 
-typedef unordered_map<unsigned int, sensor_event_t> event_type_last_event_map;
-typedef list<virtual_sensor *> virtual_sensors;
+typedef std::unordered_map<unsigned int, sensor_event_t> event_type_last_event_map;
+typedef std::list<virtual_sensor *> virtual_sensors;
 
 class csensor_event_dispatcher
 {
old mode 100755 (executable)
new mode 100644 (file)
index d3aa0dc..ed95497
 #include <csensor_event_queue.h>
 #include "common.h"
 
-csensor_event_queue::csensor_event_queue()
-{
-}
-
 csensor_event_queue& csensor_event_queue::get_instance()
 {
        static csensor_event_queue inst;
        return inst;
 }
 
-
-void csensor_event_queue::push(sensor_event_t const &event)
+void csensor_event_queue::push(const sensor_event_t &event)
 {
        sensor_event_t *new_event = new(std::nothrow) sensor_event_t;
        retm_if(!new_event, "Failed to allocate memory");
@@ -40,7 +35,12 @@ void csensor_event_queue::push(sensor_event_t const &event)
        push_internal(new_event);
 }
 
-void csensor_event_queue::push(sensorhub_event_t const &event)
+void csensor_event_queue::push(sensor_event_t *event)
+{
+       push_internal(event);
+}
+
+void csensor_event_queue::push(const sensorhub_event_t &event)
 {
        sensorhub_event_t *new_event = new(std::nothrow) sensorhub_event_t;
        retm_if(!new_event, "Failed to allocate memory");
@@ -49,6 +49,11 @@ void csensor_event_queue::push(sensorhub_event_t const &event)
        push_internal(new_event);
 }
 
+void csensor_event_queue::push(sensorhub_event_t *event)
+{
+       push_internal(event);
+}
+
 void csensor_event_queue::push_internal(void *event)
 {
        lock l(m_mutex);
@@ -63,7 +68,6 @@ void csensor_event_queue::push_internal(void *event)
                        delete (sensorhub_event_t *)event;
                else
                        delete (sensor_event_t *)event;
-
        } else
                m_queue.push(event);
 
old mode 100755 (executable)
new mode 100644 (file)
index 4c554d9..8ae00d2
 #include <condition_variable>
 #include <set>
 
-using namespace std;
-using std::queue;
-using std::mutex;
-using std::lock_guard;
-using std::unique_lock;
-using std::condition_variable;
-using std::set;
-
-extern set<unsigned int> priority_list;
+extern std::set<unsigned int> priority_list;
 
 class csensor_event_queue
 {
@@ -51,8 +43,8 @@ private:
                        if (priority_list.empty())
                                return (e2->data.timestamp < e1->data.timestamp);
 
-                       set<unsigned int>::iterator iter_e1 = priority_list.find(e1->event_type);
-                       set<unsigned int>::iterator iter_e2 = priority_list.find(e2->event_type);
+                       std::set<unsigned int>::iterator iter_e1 = priority_list.find(e1->event_type);
+                       std::set<unsigned int>::iterator iter_e2 = priority_list.find(e2->event_type);
 
                        if (iter_e1 == priority_list.end())
                                prioritize_e1 = false;
@@ -82,21 +74,24 @@ private:
 
        std::priority_queue<void*, std::vector<void*>, compare> m_queue;
 
-       mutex m_mutex;
-       condition_variable m_cond_var;
+       std::mutex m_mutex;
+       std::condition_variable m_cond_var;
 
-       typedef lock_guard<mutex> lock;
-       typedef unique_lock<mutex> ulock;
+       typedef std::lock_guard<std::mutex> lock;
+       typedef std::unique_lock<std::mutex> ulock;
 
-       csensor_event_queue();
-       csensor_event_queue(csensor_event_queue const&) {};
-       csensor_event_queue& operator=(csensor_event_queue const&);
+       csensor_event_queue() {};
+       ~csensor_event_queue() {};
+       csensor_event_queue(const csensor_event_queue &) {};
+       csensor_event_queue& operator=(const csensor_event_queue &);
        void push_internal(void *event);
-
 public:
        static csensor_event_queue& get_instance();
-       void push(sensor_event_t const &event);
-       void push(sensorhub_event_t const &event);
+       void push(const sensor_event_t &event);
+       void push(sensor_event_t *event);
+       void push(const sensorhub_event_t &event);
+       void push(sensorhub_event_t *event);
+
        void* pop(void);
 };
 
old mode 100755 (executable)
new mode 100644 (file)
index f270a36..345c014
@@ -23,6 +23,7 @@
 
 csensor_usage::csensor_usage()
 : m_interval(POLL_MAX_HZ_MS)
+, m_latency(0)
 , m_option(SENSOR_OPTION_DEFAULT)
 , m_start(false)
 {
old mode 100755 (executable)
new mode 100644 (file)
index 3535962..3c71dcd
 #include <sf_common.h>
 #include <algorithm>
 #include <vector>
-using std::vector;
 
-typedef vector<unsigned int> reg_event_vector;
+typedef std::vector<unsigned int> reg_event_vector;
 
 class csensor_usage {
 public:
        unsigned int m_interval;
+       unsigned int m_latency;
        int m_option;
        reg_event_vector m_reg_events;
        bool m_start;
old mode 100755 (executable)
new mode 100644 (file)
index 96ff1d5..9845b5f
@@ -20,7 +20,7 @@
 #include <csocket.h>
 #include <attr/xattr.h>
 #include <sys/stat.h>
-
+#include <stdint.h>
 
 csocket::csocket()
 : m_sock_fd(-1)
@@ -160,7 +160,7 @@ bool csocket::accept(csocket& client_socket) const
        return true;
 }
 
-ssize_t csocket::send_for_seqpacket(void const* buffer, size_t size) const
+ssize_t csocket::send_for_seqpacket(const void *buffer, size_t size) const
 {
        ssize_t err, len;
 
@@ -210,14 +210,14 @@ ssize_t csocket::recv_for_seqpacket(void* buffer, size_t size) const
 }
 
 
-ssize_t csocket::send_for_stream(void const* buffer, size_t size) const
+ssize_t csocket::send_for_stream(const void *buffer, size_t size) const
 {
        ssize_t len;
        ssize_t err = 0;
        size_t total_sent_size = 0;
 
        do {
-               len = ::send(m_sock_fd, (void const*)((uint8_t *)buffer + total_sent_size), size - total_sent_size, m_send_flags);
+               len = ::send(m_sock_fd, (const void *)((uint8_t *)buffer + total_sent_size), size - total_sent_size, m_send_flags);
 
                if (len >= 0) {
                        total_sent_size += len;
@@ -269,7 +269,7 @@ ssize_t csocket::recv_for_stream(void* buffer, size_t size) const
 }
 
 
-ssize_t csocket::send(void const* buffer, size_t size) const
+ssize_t csocket::send(const void *buffer, size_t size) const
 {
        if (m_sock_type == SOCK_STREAM)
                return send_for_stream(buffer, size);
old mode 100755 (executable)
new mode 100644 (file)
index b6e8990..c7f719f
@@ -27,8 +27,6 @@
 #include <errno.h>
 #include <fcntl.h>
 #include "common.h"
-#include <string>
-using std::string;
 
 class csocket {
 public:
@@ -47,7 +45,7 @@ public:
        bool connect(const char *sock_path);
 
        //Data Transfer
-       ssize_t send(void const* buffer, size_t size) const;
+       ssize_t send(const void *buffer, size_t size) const;
        ssize_t recv(void* buffer, size_t size) const;
 
        bool set_connection_mode(void);
@@ -66,8 +64,8 @@ private:
        bool set_blocking_mode(bool blocking);
        bool set_sock_type(void);
 
-       ssize_t send_for_seqpacket(void const* buffer, size_t size) const;
-       ssize_t send_for_stream(void const* buffer, size_t size) const;
+       ssize_t send_for_seqpacket(const void *buffer, size_t size) const;
+       ssize_t send_for_stream(const void *buffer, size_t size) const;
        ssize_t recv_for_seqpacket(void* buffer, size_t size) const;
        ssize_t recv_for_stream(void* buffer, size_t size) const;
 
index b3c5f7d..a9af957 100755 (executable)
 
 #define VIRTUAL_SENSOR_CONFIG_FILE_PATH "/usr/etc/virtual_sensors.xml"
 
-typedef unordered_map<string,string> Element;
+typedef std::unordered_map<std::string,std::string> Element;
 /*
 * an Element  is a group of attributes
 * <Element value1 = "10.0", value2 =  "20.0"/>
 *
 */
 
-typedef unordered_map<string,Element> Virtual_sensor;
+typedef std::unordered_map<std::string,Element> Virtual_sensor;
 /*
 * a Virtual_sensor is a group of elements to consist of one virtual sensor's configuration
 *      <ORIENTATION>
@@ -40,7 +40,7 @@ typedef unordered_map<string,Element> Virtual_sensor;
 *              ...
 */
 
-typedef unordered_map<string,Virtual_sensor> virtual_sensor_config;
+typedef std::unordered_map<std::string,Virtual_sensor> virtual_sensor_config;
 /*
 * a Virtual_sensor_config represents virtual_sensors.xml
 * <ORIENTATION/>
@@ -49,7 +49,7 @@ typedef unordered_map<string,Virtual_sensor> virtual_sensor_config;
 *
 */
 
-typedef unordered_map<string,virtual_sensor_config> virtual_sensor_device_config;
+typedef std::unordered_map<std::string,virtual_sensor_config> virtual_sensor_device_config;
 /*
 * a virtual_sensor_device_config represents virtual_sensors.xml
 * <emulator/>
@@ -64,22 +64,22 @@ private:
        cvirtual_sensor_config(cvirtual_sensor_config const&) {};
        cvirtual_sensor_config& operator=(cvirtual_sensor_config const&);
 
-       bool load_config(const string& config_path);
+       bool load_config(const std::string& config_path);
 
        virtual_sensor_device_config m_virtual_sensor_config;
 
 public:
        static cvirtual_sensor_config& get_instance(void);
 
-       bool get(const string& sensor_type, const string& element, const string& attr, string& value);
-       bool get(const string& sensor_type, const string& element, const string& attr, float *value);
-       bool get(const string& sensor_type, const string& element, const string& attr, int *value);
+       bool get(const std::string& sensor_type, const std::string& element, const std::string& attr, std::string& value);
+       bool get(const std::string& sensor_type, const std::string& element, const std::string& attr, float *value);
+       bool get(const std::string& sensor_type, const std::string& element, const std::string& attr, int *value);
 
-       bool get(const string& sensor_type, const string& element, string& value);
-       bool get(const string& sensor_type, const string& element, float *value, int count =1);
-       bool get(const string& sensor_type, const string& element, int *value, int count = 1);
+       bool get(const std::string& sensor_type, const std::string& element, std::string& value);
+       bool get(const std::string& sensor_type, const std::string& element, float *value, int count =1);
+       bool get(const std::string& sensor_type, const std::string& element, int *value, int count = 1);
 
-       bool is_supported(const string &sensor_type);
+       bool is_supported(const std::string &sensor_type);
 };
 
 #endif
index ecda683..80f1f34 100755 (executable)
 #include <string>
 #include <common.h>
 
-using std::string;
-using std::ifstream;
-
-
 #define NO_OF_ULL_BYTES                8
 #define NO_OF_SHORT_VAL                4
 #define CH0_INDEX                      0
@@ -85,9 +81,9 @@ int update_sysfs_string(const char *filepath, const char *val);
 int convert_bytes_to_int(int input, struct channel_parameters *info);
 
 template <typename value_t>
-bool read_node_value(string node_path, value_t &value)
+bool read_node_value(std::string node_path, value_t &value)
 {
-       ifstream handle;
+       std::ifstream handle;
        handle.open(node_path.c_str());
        if (!handle)
        {
old mode 100755 (executable)
new mode 100644 (file)
index 4f9ee3c..15d33a0
@@ -31,13 +31,25 @@ physical_sensor::~physical_sensor()
 
 }
 
-bool physical_sensor::push(sensor_event_t const &event)
+bool physical_sensor::push(const sensor_event_t &event)
 {
        csensor_event_queue::get_instance().push(event);
        return true;
 }
 
-bool physical_sensor::push(sensorhub_event_t const &event)
+bool physical_sensor::push(sensor_event_t *event)
+{
+       csensor_event_queue::get_instance().push(event);
+       return true;
+}
+
+bool physical_sensor::push(const sensorhub_event_t &event)
+{
+       csensor_event_queue::get_instance().push(event);
+       return true;
+}
+
+bool physical_sensor::push(sensorhub_event_t *event)
 {
        csensor_event_queue::get_instance().push(event);
        return true;
old mode 100755 (executable)
new mode 100644 (file)
index 4118ae3..a4098b6
@@ -36,8 +36,10 @@ protected:
        physical_sensor();
        virtual ~physical_sensor();
 
-       bool push(sensor_event_t const &event);
-       bool push(sensorhub_event_t const &event);
+       bool push(const sensor_event_t  &event);
+       bool push(sensor_event_t *event);
+       bool push(const sensorhub_event_t &event);
+       bool push(sensorhub_event_t *event);
 
        void set_poller(working_func_t func, void *arg);
        bool start_poll(void);
index 60c1b2f..056e065 100755 (executable)
 #include <sensor_base.h>
 
 #include <algorithm>
+#include <utility>
+
+using std::make_pair;
+using std::vector;
 
 #define UNKNOWN_NAME "UNKNOWN_SENSOR"
 
@@ -47,14 +51,30 @@ bool sensor_base::is_virtual()
        return false;
 }
 
-void sensor_base::set_id(sensor_id_t id)
+void sensor_base::add_id(sensor_id_t id)
 {
-       m_id = id;
+       m_ids.insert(std::make_pair(static_cast<sensor_type_t> (id & SENSOR_TYPE_MASK), id));
 }
 
 sensor_id_t sensor_base::get_id(void)
 {
-       return m_id;
+       auto it = m_ids.begin();
+
+       if (it != m_ids.end())
+               return it->second;
+
+       return UNKNOWN_SENSOR;
+}
+
+sensor_id_t sensor_base::get_id(sensor_type_t sensor_type)
+{
+
+       auto it = m_ids.find(sensor_type);
+
+       if (it != m_ids.end())
+               return it->second;
+
+       return UNKNOWN_SENSOR;
 }
 
 sensor_privilege_t sensor_base::get_privilege(void)
@@ -78,12 +98,6 @@ void sensor_base::set_permission(int permission)
        m_permission = permission;
 }
 
-
-sensor_type_t sensor_base::get_type()
-{
-       return UNKNOWN_SENSOR;
-}
-
 const char* sensor_base::get_name()
 {
        if (m_name.empty())
@@ -204,7 +218,7 @@ bool sensor_base::add_interval(int client_id, unsigned int interval, bool is_pro
        if (cur_min != prev_min) {
                INFO("Min interval for sensor[0x%x] is changed from %dms to %dms"
                        " by%sclient[%d] adding interval",
-                       get_type(), prev_min, cur_min,
+                       get_id(), prev_min, cur_min,
                        is_processor ? " processor " : " ", client_id);
                set_interval(cur_min);
        }
@@ -227,14 +241,14 @@ bool sensor_base::delete_interval(int client_id, bool is_processor)
        if (!cur_min) {
                INFO("No interval for sensor[0x%x] by%sclient[%d] deleting interval, "
                         "so set to default %dms",
-                        get_type(), is_processor ? " processor " : " ",
+                        get_id(), is_processor ? " processor " : " ",
                         client_id, POLL_1HZ_MS);
 
                set_interval(POLL_1HZ_MS);
        } else if (cur_min != prev_min) {
                INFO("Min interval for sensor[0x%x] is changed from %dms to %dms"
                        " by%sclient[%d] deleting interval",
-                       get_type(), prev_min, cur_min,
+                       get_id(), prev_min, cur_min,
                        is_processor ? " processor " : " ", client_id);
 
                set_interval(cur_min);
@@ -250,13 +264,13 @@ unsigned int sensor_base::get_interval(int client_id, bool is_processor)
        return m_interval_info_list.get_interval(client_id, is_processor);
 }
 
-void sensor_base::get_sensor_info(sensor_info &info)
+void sensor_base::get_sensor_info(sensor_type_t sensor_type, sensor_info &info)
 {
        sensor_properties_s properties;
-       get_properties(properties);
+       get_properties(sensor_type, properties);
 
-       info.set_type(get_type());
-       info.set_id(get_id());
+       info.set_type(sensor_type);
+       info.set_id(get_id(sensor_type));
        info.set_privilege(m_privilege);
        info.set_name(properties.name.c_str());
        info.set_vendor(properties.vendor.c_str());
@@ -266,12 +280,20 @@ void sensor_base::get_sensor_info(sensor_info &info)
        info.set_min_interval(properties.min_interval);
        info.set_fifo_count(properties.fifo_count);
        info.set_max_batch_count(properties.max_batch_count);
-       info.set_supported_events(m_supported_event_info);
+
+       vector<unsigned int> events;
+
+       for (unsigned int i = 0; i < m_supported_event_info.size(); ++ i) {
+               if (m_supported_event_info[i] & (sensor_type << 16))
+                       events.push_back(m_supported_event_info[i]);
+       }
+
+       info.set_supported_events(events);
 
        return;
 }
 
-bool sensor_base::get_properties(sensor_properties_s &properties)
+bool sensor_base::get_properties(sensor_type_t sensor_type, sensor_properties_s &properties)
 {
        return false;
 }
index 0206201..353cee2 100755 (executable)
@@ -21,6 +21,7 @@
 #define _SENSOR_BASE_H_
 
 #include <list>
+#include <map>
 #include <unordered_map>
 #include <vector>
 #include <mutex>
 #include <worker_thread.h>
 #include <sensor_info.h>
 
-using std::string;
-using std::mutex;
-using std::recursive_mutex;
-using std::lock_guard;
-using std::list;
-using std::unordered_map;
-using std::vector;
-using std::unique_lock;
-using std::condition_variable;
-
 class sensor_base
 {
 private:
-       typedef unordered_map<unsigned int, unsigned int> client_info;
+       typedef std::unordered_map<unsigned int, unsigned int> client_info;
 
 public:
        sensor_base();
        virtual ~sensor_base();
 
        virtual bool init(void);
-       void set_id(sensor_id_t id);
-       sensor_id_t get_id(void);
-       virtual sensor_type_t get_type(void);
+       void add_id(sensor_id_t id);
+       sensor_id_t get_id(sensor_type_t sensor_type);
+       virtual void get_types(std::vector<sensor_type_t> &types) {};
+
        sensor_privilege_t get_privilege(void);
        int get_permission(void);
        virtual const char* get_name(void);
@@ -74,9 +66,9 @@ public:
        virtual bool delete_interval(int client_id, bool is_processor);
        unsigned int get_interval(int client_id, bool is_processor);
 
+       void get_sensor_info(sensor_type_t sensor_type, sensor_info &info);
+       virtual bool get_properties(sensor_type_t sensor_type, sensor_properties_s &properties);
 
-       void get_sensor_info(sensor_info &info);
-       virtual bool get_properties(sensor_properties_s &properties);
        bool is_supported(unsigned int event_type);
 
        virtual long set_command(unsigned int cmd, long value);
@@ -87,11 +79,11 @@ public:
        void register_supported_event(unsigned int event_type);
        void unregister_supported_event(unsigned int event_type);
 protected:
-       typedef lock_guard<mutex> lock;
-       typedef lock_guard<recursive_mutex> rlock;
-       typedef unique_lock<mutex> ulock;
+       typedef std::lock_guard<std::mutex> lock;
+       typedef std::lock_guard<std::recursive_mutex> rlock;
+       typedef std::unique_lock<std::mutex> ulock;
 
-       sensor_id_t m_id;
+       std::map<sensor_type_t, sensor_id_t> m_ids;
        sensor_privilege_t m_privilege;
        int m_permission;
 
@@ -106,12 +98,12 @@ protected:
        client_info m_client_info;
        cmutex m_client_info_mutex;
 
-       vector<unsigned int> m_supported_event_info;
-
+       std::vector<unsigned int> m_supported_event_info;
        bool m_started;
 
-       string m_name;
+       std::string m_name;
 
+       sensor_id_t get_id(void);
        void set_privilege(sensor_privilege_t privilege);
        void set_permission(int permission);
        unsigned int get_client_cnt(unsigned int event_type);
index a0bfd84..f5a315d 100755 (executable)
@@ -24,7 +24,9 @@
 #include <csensor_config.h>
 
 using std::ifstream;
+using std::ofstream;
 using std::fstream;
+using std::string;
 
 cmutex sensor_hal::m_shared_mutex;
 
@@ -200,7 +202,7 @@ bool sensor_hal::get_sensorhub_input_event_node_info(const string &interval_node
 
 bool sensor_hal::set_node_value(const string &node_path, int value)
 {
-       fstream node(node_path, fstream::out);
+       ofstream node(node_path, ofstream::binary);
 
        if (!node)
                return false;
@@ -212,7 +214,7 @@ bool sensor_hal::set_node_value(const string &node_path, int value)
 
 bool sensor_hal::set_node_value(const string &node_path, unsigned long long value)
 {
-       fstream node(node_path, fstream::out);
+       ofstream node(node_path, ofstream::binary);
 
        if (!node)
                return false;
@@ -225,7 +227,7 @@ bool sensor_hal::set_node_value(const string &node_path, unsigned long long valu
 
 bool sensor_hal::get_node_value(const string &node_path, int &value)
 {
-       fstream node(node_path, fstream::in);
+       ifstream node(node_path, ifstream::binary);
 
        if (!node)
                return false;
index fdb8299..09762a4 100755 (executable)
@@ -26,8 +26,6 @@
 #include <sensor_internal.h>
 #include <string>
 
-using std::string;
-
 /*
 * As of Linux 3.4, there is a new EVIOCSCLOCKID ioctl to set the desired clock
 * Current kernel-headers package doesn't have it so we should define it here.
@@ -37,22 +35,47 @@ using std::string;
 #define EVIOCSCLOCKID          _IOW('E', 0xa0, int)                    /* Set clockid to be used for timestamps */
 #endif
 
+typedef enum {
+       SENSOR_HAL_TYPE_ACCELEROMETER,
+       SENSOR_HAL_TYPE_GEOMAGNETIC,
+       SENSOR_HAL_TYPE_LIGHT,
+       SENSOR_HAL_TYPE_PROXIMITY,
+       SENSOR_HAL_TYPE_GYROSCOPE,
+       SENSOR_HAL_TYPE_PRESSURE,
+       SENSOR_HAL_TYPE_CONTEXT,
+       SENSOR_HAL_TYPE_BIO,
+       SENSOR_HAL_TYPE_BIO_HRM,
+       SENSOR_HAL_TYPE_PIR,
+       SENSOR_HAL_TYPE_PIR_LONG,
+       SENSOR_HAL_TYPE_TEMPERATURE,
+       SENSOR_HAL_TYPE_HUMIDITY,
+       SENSOR_HAL_TYPE_ULTRAVIOLET,
+       SENSOR_HAL_TYPE_DUST,
+       SENSOR_HAL_TYPE_BIO_LED_IR,
+       SENSOR_HAL_TYPE_BIO_LED_RED,
+       SENSOR_HAL_TYPE_BIO_LED_GREEN,
+       SENSOR_HAL_TYPE_RV_RAW,
+       SENSOR_HAL_TYPE_GYROSCOPE_UNCAL,
+       SENSOR_HAL_TYPE_GEOMAGNETIC_UNCAL,
+       SENSOR_HAL_TYPE_FUSION,
+} sensor_hal_type_t;
+
 typedef struct {
        int method;
-       string data_node_path;
-       string enable_node_path;
-       string interval_node_path;
-       string buffer_enable_node_path;
-       string buffer_length_node_path;
-       string trigger_node_path;
+       std::string data_node_path;
+       std::string enable_node_path;
+       std::string interval_node_path;
+       std::string buffer_enable_node_path;
+       std::string buffer_length_node_path;
+       std::string trigger_node_path;
 } node_info;
 
 typedef struct {
        bool sensorhub_controlled;
-       string sensor_type;
-       string key;
-       string iio_enable_node_name;
-       string sensorhub_interval_node_name;
+       std::string sensor_type;
+       std::string key;
+       std::string iio_enable_node_name;
+       std::string sensorhub_interval_node_name;
 } node_info_query;
 
 enum input_method {
@@ -75,13 +98,14 @@ public:
        virtual ~sensor_hal();
 
        virtual bool init(void *data = NULL);
-       virtual string get_model_id(void) = 0;
-       virtual sensor_type_t get_type(void) = 0;
+       virtual std::string get_model_id(void) = 0;
+       virtual sensor_hal_type_t get_type(void) = 0;
        virtual bool enable(void) = 0;
        virtual bool disable(void) = 0;
        virtual bool set_interval(unsigned long val);
        virtual bool is_data_ready(bool wait) = 0;
-       virtual bool get_properties(sensor_properties_s &properties) = 0;
+       virtual bool get_properties(sensor_properties_s &properties) {return false;};
+       virtual bool get_properties(sensor_type_t sensor_type, sensor_properties_s &properties) {return false;};
        virtual int get_sensor_data(sensor_data_t &data);
        virtual int get_sensor_data(sensorhub_data_t &data);
        virtual long set_command(unsigned int cmd, long val);
@@ -91,24 +115,24 @@ protected:
        cmutex m_mutex;
        static cmutex m_shared_mutex;
 
-       virtual bool set_enable_node(const string &node_path, bool sensorhub_controlled, bool enable, int enable_bit = 0);
+       virtual bool set_enable_node(const std::string &node_path, bool sensorhub_controlled, bool enable, int enable_bit = 0);
 
        static unsigned long long get_timestamp(void);
        static unsigned long long get_timestamp(timeval *t);
-       static bool find_model_id(const string &sensor_type, string &model_id);
-       static bool is_sensorhub_controlled(const string &key);
+       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);
-       static bool set_node_value(const string &node_path, int value);
-       static bool set_node_value(const string &node_path, unsigned long long value);
-       static bool get_node_value(const string &node_path, int &value);
+       static bool set_node_value(const std::string &node_path, int value);
+       static bool set_node_value(const std::string &node_path, unsigned long long value);
+       static bool get_node_value(const std::string &node_path, int &value);
 private:
-       static bool get_event_num(const string &node_path, string &event_num);
-       static bool get_input_method(const string &key, int &method, string &device_num);
+       static bool get_event_num(const std::string &node_path, std::string &event_num);
+       static bool get_input_method(const std::string &key, int &method, std::string &device_num);
 
-       static bool get_iio_node_info(const string& enable_node_name, const string& device_num, node_info &info);
-       static bool get_sensorhub_iio_node_info(const string &interval_node_name, const string& device_num, node_info &info);
-       static bool get_input_event_node_info(const string& device_num, node_info &info);
-       static bool get_sensorhub_input_event_node_info(const string &interval_node_name, const string& device_num, node_info &info);
+       static bool get_iio_node_info(const std::string& enable_node_name, const std::string& device_num, node_info &info);
+       static bool get_sensorhub_iio_node_info(const std::string &interval_node_name, const std::string& device_num, node_info &info);
+       static bool get_input_event_node_info(const std::string& device_num, node_info &info);
+       static bool get_sensorhub_input_event_node_info(const std::string &interval_node_name, const std::string& device_num, node_info &info);
 };
 #endif /*_SENSOR_HAL_CLASS_H_*/
index fe8303c..bed247e 100755 (executable)
 #include <sensor_info.h>
 #include <common.h>
 #include <algorithm>
+#include <vector>
+#include <string>
+
+using std::vector;
+using std::string;
 
 sensor_type_t sensor_info::get_type(void)
 {
index 6a8a09e..185d249 100755 (executable)
 #include <string>
 #include <vector>
 
-using std::string;
-using std::vector;
-
-typedef vector<char> raw_data_t;
+typedef std::vector<char> raw_data_t;
 typedef raw_data_t::iterator raw_data_iterator;
 
 class sensor_info
@@ -45,7 +42,7 @@ public:
        int get_min_interval(void);
        int get_fifo_count(void);
        int get_max_batch_count(void);
-       void get_supported_events(vector<unsigned int> &events);
+       void get_supported_events(std::vector<unsigned int> &events);
        bool is_supported_event(unsigned int event);
 
        void set_type(sensor_type_t type);
@@ -60,7 +57,7 @@ public:
        void set_fifo_count(int fifo_count);
        void set_max_batch_count(int max_batch_count);
        void register_supported_event(unsigned int event);
-       void set_supported_events(vector<unsigned int> &events);
+       void set_supported_events(std::vector<unsigned int> &events);
 
        void clear(void);
 
@@ -71,25 +68,25 @@ private:
        sensor_type_t m_type;
        sensor_id_t m_id;
        sensor_privilege_t m_privilege;
-       string m_name;
-       string m_vendor;
+       std::string m_name;
+       std::string m_vendor;
        float m_min_range;
        float m_max_range;
        float m_resolution;
        int m_min_interval;
        int m_fifo_count;
        int m_max_batch_count;
-       vector<unsigned int> m_supported_events;
+       std::vector<unsigned int> m_supported_events;
 
        void put(raw_data_t &data, int value);
        void put(raw_data_t &data, float value);
-       void put(raw_data_t &data, string &value);
-       void put(raw_data_t &data, vector<unsigned int> &value);
+       void put(raw_data_t &data, std::string &value);
+       void put(raw_data_t &data, std::vector<unsigned int> &value);
 
        raw_data_iterator get(raw_data_iterator it, int &value);
        raw_data_iterator get(raw_data_iterator it, float &value);
-       raw_data_iterator get(raw_data_iterator it, string &value);
-       raw_data_iterator get(raw_data_iterator it, vector<unsigned int> &value);
+       raw_data_iterator get(raw_data_iterator it, std::string &value);
+       raw_data_iterator get(raw_data_iterator it, std::vector<unsigned int> &value);
 };
 
 #endif /* _SENSOR_INFO_H_ */
index 17772c9..3b5831c 100755 (executable)
 using std::make_pair;
 using std::equal;
 using std::unordered_set;
+using std::pair;
+using std::vector;
+using std::string;
+using std::shared_ptr;
+using std::static_pointer_cast;
 
 #define ROOT_ELEMENT "PLUGIN"
 #define TEXT_ELEMENT "text"
@@ -100,12 +105,12 @@ bool sensor_plugin_loader::insert_module(plugin_type type, const string &path)
                if (!load_module(path, hals, handle))
                        return false;
 
-               sensor_hal* hal;
+               shared_ptr<sensor_hal> hal;
 
                for (unsigned int i = 0; i < hals.size(); ++i) {
-                       hal = static_cast<sensor_hal*> (hals[i]);
-                       sensor_type_t sensor_type = hal->get_type();
-                       m_sensor_hals.insert(make_pair(sensor_type, hal));
+                       hal.reset(static_cast<sensor_hal*> (hals[i]));
+                       sensor_hal_type_t sensor_hal_type = hal->get_type();
+                       m_sensor_hals.insert(make_pair(sensor_hal_type, hal));
                }
        } else if (type == PLUGIN_TYPE_SENSOR) {
                DBG("Insert Sensor plugin [%s]", path.c_str());
@@ -116,25 +121,28 @@ bool sensor_plugin_loader::insert_module(plugin_type type, const string &path)
                if (!load_module(path, sensors, handle))
                        return false;
 
-               sensor_base* sensor;
+               shared_ptr<sensor_base> sensor;
 
                for (unsigned int i = 0; i < sensors.size(); ++i) {
-                       sensor = static_cast<sensor_base*> (sensors[i]);
+                       sensor.reset(static_cast<sensor_base*> (sensors[i]));
 
                        if (!sensor->init()) {
                                ERR("Failed to init [%s] module\n", sensor->get_name());
-                               delete sensor;
                                continue;
                        }
 
                        DBG("init [%s] module", sensor->get_name());
 
-                       sensor_type_t sensor_type = sensor->get_type();
+                       vector<sensor_type_t> sensor_types;
 
-                       int idx;
-                       idx = m_sensors.count(sensor_type);
-                       sensor->set_id(idx << SENSOR_INDEX_SHIFT | sensor_type);
-                       m_sensors.insert(make_pair(sensor_type, sensor));
+                       sensor->get_types(sensor_types);
+
+                       for (unsigned int i = 0; i < sensor_types.size(); ++i) {
+                               int idx;
+                               idx = m_sensors.count(sensor_types[i]);
+                               sensor->add_id(idx << SENSOR_INDEX_SHIFT | sensor_types[i]);
+                               m_sensors.insert(make_pair(sensor_types[i], sensor));
+                       }
                }
        }else {
                ERR("Not supported type: %d", type);
@@ -201,10 +209,10 @@ void sensor_plugin_loader::show_sensor_info(void)
        auto it = m_sensors.begin();
 
        while (it != m_sensors.end()) {
-               sensor_base* sensor = it->second;
+               shared_ptr<sensor_base> sensor = it->second;
 
                sensor_info info;
-               sensor->get_sensor_info(info);
+               sensor->get_sensor_info(it->first, info);
                INFO("No:%d [%s]\n", ++index, sensor->get_name());
                info.show();
                it++;
@@ -322,24 +330,24 @@ bool sensor_plugin_loader::get_paths_from_config(const string &config_path, vect
 
 }
 
-sensor_hal* sensor_plugin_loader::get_sensor_hal(sensor_type_t type)
+sensor_hal* sensor_plugin_loader::get_sensor_hal(sensor_hal_type_t type)
 {
        auto it_plugins = m_sensor_hals.find(type);
 
        if (it_plugins == m_sensor_hals.end())
                return NULL;
 
-       return it_plugins->second;
+       return it_plugins->second.get();
 }
 
-vector<sensor_hal *> sensor_plugin_loader::get_sensor_hals(sensor_type_t type)
+vector<sensor_hal *> sensor_plugin_loader::get_sensor_hals(sensor_hal_type_t type)
 {
        vector<sensor_hal *> sensor_hal_list;
        pair<sensor_hal_plugins::iterator, sensor_hal_plugins::iterator> ret;
        ret = m_sensor_hals.equal_range(type);
 
        for (auto it = ret.first; it != ret.second; ++it)
-               sensor_hal_list.push_back(it->second);
+               sensor_hal_list.push_back(it->second.get());
 
        return sensor_hal_list;
 }
@@ -351,7 +359,7 @@ sensor_base* sensor_plugin_loader::get_sensor(sensor_type_t type)
        if (it_plugins == m_sensors.end())
                return NULL;
 
-       return it_plugins->second;
+       return it_plugins->second.get();
 }
 
 vector<sensor_base *> sensor_plugin_loader::get_sensors(sensor_type_t type)
@@ -365,7 +373,7 @@ vector<sensor_base *> sensor_plugin_loader::get_sensors(sensor_type_t type)
                ret = m_sensors.equal_range(type);
 
        for (auto it = ret.first; it != ret.second; ++it)
-               sensor_list.push_back(it->second);
+               sensor_list.push_back(it->second.get());
 
        return sensor_list;
 }
@@ -373,7 +381,6 @@ vector<sensor_base *> sensor_plugin_loader::get_sensors(sensor_type_t type)
 
 sensor_base* sensor_plugin_loader::get_sensor(sensor_id_t id)
 {
-       const int SENSOR_TYPE_MASK = 0x0000FFFF;
        vector<sensor_base *> sensors;
 
        sensor_type_t type = (sensor_type_t) (id & SENSOR_TYPE_MASK);
@@ -394,7 +401,7 @@ vector<sensor_base *> sensor_plugin_loader::get_virtual_sensors(void)
        sensor_base* module;
 
        for (auto sensor_it = m_sensors.begin(); sensor_it != m_sensors.end(); ++sensor_it) {
-               module = sensor_it->second;
+               module = sensor_it->second.get();
 
                if (module && module->is_virtual() == true) {
                        virtual_list.push_back(module);
@@ -404,33 +411,3 @@ vector<sensor_base *> sensor_plugin_loader::get_virtual_sensors(void)
        return virtual_list;
 }
 
-bool sensor_plugin_loader::destroy()
-{
-       sensor_base* sensor;
-
-       for (auto sensor_it = m_sensors.begin(); sensor_it != m_sensors.end(); ++sensor_it) {
-               sensor = sensor_it->second;
-
-               //need to dlclose
-               //unregister_module(module);
-
-               delete sensor;
-       }
-
-       sensor_hal* sensor_hal;
-
-       for (auto sensor_hal_it = m_sensor_hals.begin(); sensor_hal_it != m_sensor_hals.end(); ++sensor_hal_it) {
-               sensor_hal = sensor_hal_it->second;
-
-               // need to dlclose
-               //unregister_module(module);
-
-               delete sensor_hal;
-       }
-
-       m_sensors.clear();
-       m_sensor_hals.clear();
-
-       return true;
-}
-
index 6903024..8e71dcb 100755 (executable)
@@ -21,6 +21,7 @@
 #define _SENSOR_PLUGIN_LOADER_CLASS_H_
 
 #include <sensor_common.h>
+#include <sensor_hal.h>
 
 #include <cmutex.h>
 #include <sstream>
 #include <vector>
 #include <map>
 #include <set>
-
+#include <memory>
 
 class sensor_hal;
 class sensor_base;
 
-using std::pair;
-using std::vector;
-using std::multimap;
-using std::set;
-using std::string;
-using std::istringstream;
-
-typedef multimap<sensor_type_t, sensor_hal*> sensor_hal_plugins;
+typedef std::multimap<sensor_hal_type_t, std::shared_ptr<sensor_hal> > sensor_hal_plugins;
 /*
 * a hal_plugins is a group of hal plugin
 * <HAL>
@@ -50,7 +44,7 @@ typedef multimap<sensor_type_t, sensor_hal*> sensor_hal_plugins;
 *
 */
 
-typedef multimap<sensor_type_t, sensor_base*> sensor_plugins;
+typedef std::multimap<sensor_type_t, std::shared_ptr<sensor_base> > sensor_plugins;
 /*
 * a sensor_plugins is a group of sensor plugin
 * <SENSOR>
@@ -69,11 +63,11 @@ private:
 
        sensor_plugin_loader();
 
-       bool load_module(const string &path, vector<void*> &sensors, void* &handle);
-       bool insert_module(plugin_type type, const string &path);
+       bool load_module(const std::string &path, std::vector<void*> &sensors, void* &handle);
+       bool insert_module(plugin_type type, const std::string &path);
        void show_sensor_info(void);
-       bool get_paths_from_dir(const string &dir_path, vector<string> &hal_paths, vector<string> &sensor_paths);
-       bool get_paths_from_config(const string &config_path, vector<string> &hal_paths, vector<string> &sensor_paths);
+       bool get_paths_from_dir(const std::string &dir_path, std::vector<std::string> &hal_paths, std::vector<std::string> &sensor_paths);
+       bool get_paths_from_config(const std::string &config_path, std::vector<std::string> &hal_paths, std::vector<std::string> &sensor_paths);
 
        sensor_hal_plugins m_sensor_hals;
        sensor_plugins m_sensors;
@@ -82,15 +76,13 @@ public:
        static sensor_plugin_loader& get_instance();
        bool load_plugins(void);
 
-       sensor_hal* get_sensor_hal(sensor_type_t type);
-       vector<sensor_hal *> get_sensor_hals(sensor_type_t type);
+       sensor_hal* get_sensor_hal(sensor_hal_type_t type);
+       std::vector<sensor_hal *> get_sensor_hals(sensor_hal_type_t type);
 
        sensor_base* get_sensor(sensor_type_t type);
-       vector<sensor_base *> get_sensors(sensor_type_t type);
+       std::vector<sensor_base *> get_sensors(sensor_type_t type);
        sensor_base* get_sensor(sensor_id_t id);
 
-       vector<sensor_base*> get_virtual_sensors(void);
-
-       bool destroy();
+       std::vector<sensor_base*> get_virtual_sensors(void);
 };
 #endif /* _SENSOR_PLUGIN_LOADER_CLASS_H_ */
old mode 100755 (executable)
new mode 100644 (file)
index 6481095..777421b
@@ -17,6 +17,8 @@
  *
  */
 
+#include <common.h>
+
 #if !defined(_SF_COMMON_H_)
 #define _SF_COMMON_H_
 #include <unistd.h>
 #include <string>
 #include <vector>
 
-#define COMMAND_CHANNEL_PATH                   "/tmp/sf_command_socket"
-#define EVENT_CHANNEL_PATH                             "/tmp/sf_event_socket"
+#define COMMAND_CHANNEL_PATH                   "/tmp/sensord_command_socket"
+#define EVENT_CHANNEL_PATH                             "/tmp/sensord_event_socket"
 
-#define MAX_HANDLE                     64
+#define MAX_HANDLE                     256
 #define MAX_HANDLE_REACHED     -2
 
 #define CLIENT_ID_INVALID   -1
 
+#define SENSOR_TYPE_MASK  0xFFFF
+
 enum packet_type_t {
        CMD_NONE = 0,
        CMD_GET_ID,
@@ -46,8 +50,8 @@ enum packet_type_t {
        CMD_REG,
        CMD_UNREG,
        CMD_SET_OPTION,
-       CMD_SET_INTERVAL,
-       CMD_UNSET_INTERVAL,
+       CMD_SET_BATCH,
+       CMD_UNSET_BATCH,
        CMD_SET_COMMAND,
        CMD_GET_DATA,
        CMD_SEND_SENSORHUB_DATA,
@@ -73,7 +77,7 @@ enum poll_interval_t {
 };
 
 typedef struct {
-       pid_t pid;
+       char name[NAME_MAX];
 } cmd_get_id_t;
 
 typedef struct {
@@ -127,10 +131,11 @@ typedef struct {
 
 typedef struct {
        unsigned int interval;
-} cmd_set_interval_t;
+       unsigned int latency;
+} cmd_set_batch_t;
 
 typedef struct {
-} cmd_unset_interval_t;
+} cmd_unset_batch_t;
 
 typedef struct {
        int option;
index d6414e3..780ba66 100755 (executable)
@@ -28,7 +28,7 @@ public:
        virtual_sensor();
        virtual ~virtual_sensor();
 
-       virtual void synthesize(const sensor_event_t &event, vector<sensor_event_t> &outs) = 0;
+       virtual void synthesize(const sensor_event_t& event, std::vector<sensor_event_t> &outs) = 0;
        virtual int get_sensor_data(const unsigned int event_type, sensor_data_t &data) = 0;
        bool is_virtual(void);
        bool m_hardware_fusion;
index 67b5f10..6459b3f 100755 (executable)
 #include <mutex>
 #include <condition_variable>
 
-using std::mutex;
-using std::lock_guard;
-using std::unique_lock;
-using std::condition_variable;
-
 class worker_thread
 {
 public:
@@ -50,13 +45,13 @@ private:
                TRANS_FUNC_CNT,
        };
 
-       typedef lock_guard<mutex>  lock;
-       typedef unique_lock<mutex> ulock;
+       typedef std::lock_guard<std::mutex>  lock;
+       typedef std::unique_lock<std::mutex> ulock;
 
        worker_state_t m_state;
        void *m_context;
-       mutex m_mutex;
-       condition_variable m_cond_working;
+       std::mutex m_mutex;
+       std::condition_variable m_cond_working;
        bool m_thread_created;
 
        trans_func_t m_trans_func[TRANS_FUNC_CNT];
index 20d9955..5b09eb1 100755 (executable)
@@ -22,6 +22,9 @@
 #include <temperature_sensor.h>
 #include <sensor_plugin_loader.h>
 
+using std::string;
+using std::vector;
+
 #define SENSOR_NAME "TEMPERATURE_SENSOR"
 
 temperature_sensor::temperature_sensor()
@@ -42,7 +45,7 @@ temperature_sensor::~temperature_sensor()
 
 bool temperature_sensor::init()
 {
-       m_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(TEMPERATURE_SENSOR);
+       m_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(SENSOR_HAL_TYPE_TEMPERATURE);
 
        if (!m_sensor_hal) {
                ERR("cannot load sensor_hal[%s]", sensor_base::get_name());
@@ -63,9 +66,9 @@ bool temperature_sensor::init()
        return true;
 }
 
-sensor_type_t temperature_sensor::get_type(void)
+void temperature_sensor::get_types(vector<sensor_type_t> &types)
 {
-       return TEMPERATURE_SENSOR;
+       types.push_back(TEMPERATURE_SENSOR);
 }
 
 bool temperature_sensor::working(void *inst)
@@ -115,7 +118,7 @@ bool temperature_sensor::on_stop(void)
        return stop_poll();
 }
 
-bool temperature_sensor::get_properties(sensor_properties_s &properties)
+bool temperature_sensor::get_properties(sensor_type_t sensor_type, sensor_properties_s &properties)
 {
        return m_sensor_hal->get_properties(properties);
 }
index 9bb881a..680862d 100755 (executable)
@@ -31,13 +31,13 @@ public:
        virtual ~temperature_sensor();
 
        bool init();
-       sensor_type_t get_type(void);
+       virtual void get_types(std::vector<sensor_type_t> &types);
 
        static bool working(void *inst);
 
        bool set_interval(unsigned long interval);
-       virtual bool get_properties(sensor_properties_s &properties);
        int get_sensor_data(unsigned int type, sensor_data_t &data);
+       virtual bool get_properties(sensor_type_t sensor_type, sensor_properties_s &properties);
 
 private:
        sensor_hal *m_sensor_hal;
index 64bb254..d8952ff 100755 (executable)
@@ -23,6 +23,8 @@
 #include <temperature_sensor_hal.h>
 #include <sys/ioctl.h>
 
+using std::string;
+
 #define SENSOR_TYPE_TEMPERATURE                "TEMPERATURE"
 #define ELEMENT_NAME                           "NAME"
 #define ELEMENT_VENDOR                         "VENDOR"
@@ -115,9 +117,9 @@ string temperature_sensor_hal::get_model_id(void)
        return m_model_id;
 }
 
-sensor_type_t temperature_sensor_hal::get_type(void)
+sensor_hal_type_t temperature_sensor_hal::get_type(void)
 {
-       return TEMPERATURE_SENSOR;
+       return SENSOR_HAL_TYPE_TEMPERATURE;
 }
 
 bool temperature_sensor_hal::enable(void)
index 334a74d..1151afc 100755 (executable)
 #define _TEMPERATURE_SENSOR_HAL_H_
 
 #include <sensor_hal.h>
-#include <string>
-
-using std::string;
 
 class temperature_sensor_hal : public sensor_hal
 {
 public:
        temperature_sensor_hal();
        virtual ~temperature_sensor_hal();
-       string get_model_id(void);
-       sensor_type_t get_type(void);
+       std::string get_model_id(void);
+       sensor_hal_type_t get_type(void);
        bool enable(void);
        bool disable(void);
        bool set_interval(unsigned long val);
@@ -44,15 +41,15 @@ private:
        unsigned long m_polling_interval;
        unsigned long long m_fired_time;
 
-       string m_model_id;
-       string m_vendor;
-       string m_chip_name;
+       std::string m_model_id;
+       std::string m_vendor;
+       std::string m_chip_name;
 
        float m_raw_data_unit;
 
-       string m_data_node;
-       string m_enable_node;
-       string m_interval_node;
+       std::string m_data_node;
+       std::string m_enable_node;
+       std::string m_interval_node;
 
        bool m_sensorhub_controlled;
 
index 58cbb4e..a898dea 100755 (executable)
@@ -32,6 +32,9 @@
 #include <orientation_filter.h>
 #include <cvirtual_sensor_config.h>
 
+using std::string;
+using std::vector;
+
 #define SENSOR_NAME                    "TILT_SENSOR"
 #define SENSOR_TYPE_TILT       "TILT"
 
@@ -120,9 +123,9 @@ bool tilt_sensor::init(void)
        return true;
 }
 
-sensor_type_t tilt_sensor::get_type(void)
+void tilt_sensor::get_types(vector<sensor_type_t> &types)
 {
-       return TILT_SENSOR;
+       types.push_back(TILT_SENSOR);
 }
 
 bool tilt_sensor::on_start(void)
@@ -250,7 +253,7 @@ int tilt_sensor::get_sensor_data(const unsigned int event_type, sensor_data_t &d
        return 0;
 }
 
-bool tilt_sensor::get_properties(sensor_properties_s &properties)
+bool tilt_sensor::get_properties(sensor_type_t sensor_type, sensor_properties_s &properties)
 {
        if(m_raw_data_unit == "DEGREES") {
                properties.min_range = -180;
index 8ac6c62..a6a4bd5 100755 (executable)
@@ -30,16 +30,15 @@ public:
        virtual ~tilt_sensor();
 
        bool init(void);
+       virtual void get_types(std::vector<sensor_type_t> &types);
 
-       void synthesize(const sensor_event_t &event, vector<sensor_event_t> &outs);
+       void synthesize(const sensor_event_t &event, std::vector<sensor_event_t> &outs);
 
        bool add_interval(int client_id, unsigned int interval);
        bool delete_interval(int client_id);
-       bool get_properties(sensor_properties_s &properties);
-       sensor_type_t get_type(void);
 
        int get_sensor_data(const unsigned int event_type, sensor_data_t &data);
-
+       virtual bool get_properties(sensor_type_t sensor_type, sensor_properties_s &properties);
 private:
        sensor_base *m_accel_sensor;
        sensor_base *m_fusion_sensor;
@@ -51,8 +50,8 @@ private:
        unsigned long long m_time;
        unsigned int m_interval;
 
-       string m_vendor;
-       string m_raw_data_unit;
+       std::string m_vendor;
+       std::string m_raw_data_unit;
        int m_default_sampling_time;
        int m_pitch_rotation_compensation;
        int m_roll_rotation_compensation;
index e393c22..e47dc9d 100755 (executable)
@@ -26,6 +26,8 @@
 
 using std::bind1st;
 using std::mem_fun;
+using std::string;
+using std::vector;
 
 #define SENSOR_NAME "ULTRAVIOLET_SENSOR"
 
@@ -46,7 +48,7 @@ ultraviolet_sensor::~ultraviolet_sensor()
 
 bool ultraviolet_sensor::init()
 {
-       m_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(ULTRAVIOLET_SENSOR);
+       m_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(SENSOR_HAL_TYPE_ULTRAVIOLET);
 
        if (!m_sensor_hal) {
                ERR("cannot load sensor_hal[%s]", sensor_base::get_name());
@@ -65,9 +67,9 @@ bool ultraviolet_sensor::init()
        return true;
 }
 
-sensor_type_t ultraviolet_sensor::get_type(void)
+void ultraviolet_sensor::get_types(vector<sensor_type_t> &types)
 {
-       return ULTRAVIOLET_SENSOR;
+       types.push_back(ULTRAVIOLET_SENSOR);
 }
 
 bool ultraviolet_sensor::working(void *inst)
@@ -118,7 +120,7 @@ bool ultraviolet_sensor::on_stop(void)
        return stop_poll();
 }
 
-bool ultraviolet_sensor::get_properties(sensor_properties_s &properties)
+bool ultraviolet_sensor::get_properties(sensor_type_t sensor_type, sensor_properties_s &properties)
 {
        return m_sensor_hal->get_properties(properties);
 }
index 62f7835..3473db5 100755 (executable)
@@ -31,11 +31,11 @@ public:
        virtual ~ultraviolet_sensor();
 
        bool init();
-       virtual sensor_type_t get_type(void);
+       virtual void get_types(std::vector<sensor_type_t> &types);
 
        static bool working(void *inst);
        virtual bool set_interval(unsigned long interval);
-       virtual bool get_properties(sensor_properties_s &properties);
+       virtual bool get_properties(sensor_type_t sensor_type, sensor_properties_s &properties);
        virtual int get_sensor_data(unsigned int type, sensor_data_t &data);
 private:
        sensor_hal *m_sensor_hal;
index 634fd9f..ab6f210 100755 (executable)
@@ -26,6 +26,7 @@
 #include <fstream>
 
 using std::ifstream;
+using std::string;
 
 #define SENSOR_TYPE_ULTRAVIOLET        "ULTRAVIOLET"
 #define ELEMENT_NAME                   "NAME"
@@ -143,9 +144,9 @@ string ultraviolet_sensor_hal::get_model_id(void)
 }
 
 
-sensor_type_t ultraviolet_sensor_hal::get_type(void)
+sensor_hal_type_t ultraviolet_sensor_hal::get_type(void)
 {
-       return ULTRAVIOLET_SENSOR;
+       return SENSOR_HAL_TYPE_ULTRAVIOLET;
 }
 
 bool ultraviolet_sensor_hal::enable(void)
index 1925b7a..5af37ca 100755 (executable)
 #define _ULTRAVIOLET_SENSOR_HAL_H_
 
 #include <sensor_hal.h>
-#include <string>
-
-using std::string;
 
 class ultraviolet_sensor_hal : public sensor_hal
 {
 public:
        ultraviolet_sensor_hal();
        virtual ~ultraviolet_sensor_hal();
-       string get_model_id(void);
-       sensor_type_t get_type(void);
+       std::string get_model_id(void);
+       sensor_hal_type_t get_type(void);
        bool enable(void);
        bool disable(void);
        bool set_interval(unsigned long val);
@@ -40,9 +37,9 @@ public:
        bool get_properties(sensor_properties_s &properties);
 
 private:
-       string m_model_id;
-       string m_vendor;
-       string m_chip_name;
+       std::string m_model_id;
+       std::string m_vendor;
+       std::string m_chip_name;
 
        float m_min_range;
        float m_max_range;
@@ -55,9 +52,9 @@ private:
        unsigned long long m_fired_time;
        int m_node_handle;
 
-       string m_enable_node;
-       string m_data_node;
-       string m_interval_node;
+       std::string m_enable_node;
+       std::string m_data_node;
+       std::string m_interval_node;
 
        bool m_sensorhub_controlled;
 
old mode 100644 (file)
new mode 100755 (executable)
index d152be7..831b6fe
@@ -32,6 +32,9 @@
 #include <orientation_filter.h>
 #include <cvirtual_sensor_config.h>
 
+using std::vector;
+using std::string;
+
 #define SENSOR_NAME "UNCAL_GYROSCOPE_SENSOR"
 #define SENSOR_TYPE_UNCAL_GYRO         "UNCAL_GYROSCOPE"
 
@@ -62,7 +65,7 @@ uncal_gyro_sensor::uncal_gyro_sensor()
 {
        cvirtual_sensor_config &config = cvirtual_sensor_config::get_instance();
 
-       sensor_hal *fusion_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(FUSION_SENSOR);
+       sensor_hal *fusion_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(SENSOR_HAL_TYPE_FUSION);
        if (!fusion_sensor_hal)
                m_hardware_fusion = false;
        else
@@ -119,9 +122,9 @@ bool uncal_gyro_sensor::init(void)
        return true;
 }
 
-sensor_type_t uncal_gyro_sensor::get_type(void)
+void uncal_gyro_sensor::get_types(vector<sensor_type_t> &types)
 {
-       return UNCAL_GYROSCOPE_SENSOR;
+       types.push_back(UNCAL_GYROSCOPE_SENSOR);
 }
 
 bool uncal_gyro_sensor::on_start(void)
@@ -287,7 +290,7 @@ int uncal_gyro_sensor::get_sensor_data(const unsigned int event_type, sensor_dat
        return 0;
 }
 
-bool uncal_gyro_sensor::get_properties(sensor_properties_s &properties)
+bool uncal_gyro_sensor::get_properties(sensor_type_t sensor_type, sensor_properties_s &properties)
 {
        properties.resolution = 0.000001;
        properties.vendor = m_vendor;
old mode 100644 (file)
new mode 100755 (executable)
index dccb6f0..f4c6b8c
@@ -35,8 +35,8 @@ public:
 
        bool add_interval(int client_id, unsigned int interval);
        bool delete_interval(int client_id);
-       bool get_properties(sensor_properties_s &properties);
-       sensor_type_t get_type(void);
+       virtual bool get_properties(sensor_type_t sensor_type, sensor_properties_s &properties);
+       virtual void get_types(std::vector<sensor_type_t> &types);
 
        int get_sensor_data(const unsigned int event_type, sensor_data_t &data);
 
@@ -56,8 +56,8 @@ private:
        unsigned long long m_time;
        unsigned int m_interval;
 
-       string m_vendor;
-       string m_raw_data_unit;
+       std::string m_vendor;
+       std::string m_raw_data_unit;
        int m_default_sampling_time;
        float m_gyro_static_bias[3];
        int m_gyro_rotation_direction_compensation[3];
old mode 100644 (file)
new mode 100755 (executable)
index 5357ca5..b8bd460
@@ -2,7 +2,7 @@
 Description=Sensor daemon socket
 
 [Socket]
-ListenStream=/tmp/sf_command_socket
+ListenStream=/tmp/sensord_command_socket
 SocketMode=0777
 PassCredentials=yes
 Accept=false
old mode 100644 (file)
new mode 100755 (executable)
index fb772c6..6ab4dd0
@@ -121,6 +121,7 @@ bool check_sensor_api(unsigned int event_type, int cond_value)
        sensor_t *output_list;
        result_boolean = sensord_get_sensor_list(sensor_type, &output_list, &output);
        if (!result_boolean) {
+               free(output2);
                fprintf(fp, "Sensor - %d, event - %d, failed at sensord_get_sensor_list\n", sensor_type, event_type);
                return false;
        }
@@ -128,6 +129,8 @@ bool check_sensor_api(unsigned int event_type, int cond_value)
        result = sensord_register_event(handle, event_type, cond_value, 0, callback, NULL);
 
        if (result < 0) {
+               free(output2);
+               free(output_list);
                fprintf(fp, "Sensor - %d, event - %d, failed at sensord_register_event\n", sensor_type, event_type);
                return false;
        }
@@ -137,6 +140,8 @@ bool check_sensor_api(unsigned int event_type, int cond_value)
        if (!result_boolean) {
                sensord_unregister_event(handle, event_type);
                sensord_disconnect(handle);
+               free(output2);
+               free(output_list);
                fprintf(fp, "Sensor - %d, event - %d, failed at sensord_start\n", sensor_type, event_type);
                return false;
        }
@@ -146,6 +151,8 @@ bool check_sensor_api(unsigned int event_type, int cond_value)
        if (!result_boolean) {
                sensord_unregister_event(handle, event_type);
                sensord_disconnect(handle);
+               free(output2);
+               free(output_list);
                fprintf(fp, "Sensor - %d, event - %d, failed at sensord_get_data\n", sensor_type, event_type);
                return false;
        }
@@ -155,12 +162,16 @@ bool check_sensor_api(unsigned int event_type, int cond_value)
 
        result_boolean = sensord_change_event_interval(handle, event_type, 101);
        if (!result_boolean) {
+               free(output2);
+               free(output_list);
                fprintf(fp, "Sensor - %d, event - %d, failed at sensord_change_event_interval\n", sensor_type, event_type);
                return false;
        }
 
        result_boolean = sensord_set_option(handle, SENSOR_OPTION_ON_IN_SCREEN_OFF);
        if (!result_boolean){
+               free(output2);
+               free(output_list);
                fprintf(fp, "Sensor - %d, event - %d, failed at sensord_change_sensor_option\n", sensor_type, event_type);
                return false;
        }
@@ -168,6 +179,8 @@ bool check_sensor_api(unsigned int event_type, int cond_value)
        result_boolean = sensord_unregister_event(handle, event_type);
 
        if (!result_boolean) {
+               free(output2);
+               free(output_list);
                fprintf(fp, "Sensor - %d, event - %d, failed at sensord_unregister_event\n", sensor_type, event_type);
                return false;
        }
@@ -175,6 +188,8 @@ bool check_sensor_api(unsigned int event_type, int cond_value)
        result_boolean = sensord_stop(handle);
 
        if (!result_boolean) {
+               free(output2);
+               free(output_list);
                fprintf(fp, "Sensor - %d, event - %d, failed at sensord_stop\n", sensor_type, event_type);
                return false;
        }
@@ -182,10 +197,15 @@ bool check_sensor_api(unsigned int event_type, int cond_value)
        result_boolean = sensord_disconnect(handle);
 
        if (!result_boolean) {
+               free(output2);
+               free(output_list);
                fprintf(fp, "Sensor - %d, event - %d, failed at sensord_disconnect\n", sensor_type, event_type);
                return false;
        }
 
+       free(output2);
+       free(output_list);
+
        return true;
 }
 
old mode 100644 (file)
new mode 100755 (executable)
index 5fcff08..b231650
@@ -168,6 +168,8 @@ int get_event(sensor_type_t sensor_type, char str[])
                        return UNCAL_GYRO_RAW_DATA_EVENT;
                break;
 
+       default:
+               return -1;
        }
        return -1;
 }
old mode 100644 (file)
new mode 100755 (executable)
index 8c4c771..86e9a0f
@@ -81,7 +81,7 @@ int main(int argc, char **argv)
        int i;
 
        int handle[MAXSIZE];
-       int result[MAXSIZE], start_handle[MAXSIZE], stop_handle[MAXSIZE];
+       int result[MAXSIZE], start_handle[MAXSIZE];
        unsigned int event[MAXSIZE];
        int sensors[MAXSIZE];
 
old mode 100644 (file)
new mode 100755 (executable)
index 82fc74f..20d8ea2
@@ -107,7 +107,8 @@ int main(int argc, char** argv)
                for (j = 0; j < MAX; j++) {
                        char command[100];
                        sprintf(command, "kill %d", pids[j]);
-                       system(command);
+                       if (system(command) == -1)
+                               return -1;
                }
        }
 
old mode 100644 (file)
new mode 100755 (executable)
index d9ddcff..281d8ac
@@ -150,6 +150,7 @@ int main(int argc, char **argv)
        }
        else {
                 usage();
+                return -1;
        }
 
        interval = DEFAULT_EVENT_INTERVAL;