From 38a96bf155069d5d971a1c889c08a4903eca0b0e Mon Sep 17 00:00:00 2001 From: "kibak.yoon" Date: Sat, 20 Feb 2016 19:10:00 +0900 Subject: [PATCH 01/16] sensord: fix the bug that set_attribute returns bool Change-Id: I63e0683bcd2fbb0f207522ec4003b05081eb5fe5 Signed-off-by: kibak.yoon --- src/server/physical_sensor.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/server/physical_sensor.cpp b/src/server/physical_sensor.cpp index e7c3516..0096e8e 100644 --- a/src/server/physical_sensor.cpp +++ b/src/server/physical_sensor.cpp @@ -22,6 +22,9 @@ #define UNKNOWN_NAME "UNKNOWN_SENSOR" +#define OP_SUCCESS 0 +#define OP_ERROR -1 + cmutex physical_sensor::m_mutex; physical_sensor::physical_sensor() @@ -152,7 +155,10 @@ int physical_sensor::set_attribute(int32_t attribute, int32_t value) if (!m_sensor_device) return false; - return m_sensor_device->set_attribute_int(m_info->id, attribute, value); + if (!m_sensor_device->set_attribute_int(m_info->id, attribute, value)) + return OP_ERROR; + + return OP_SUCCESS; } int physical_sensor::set_attribute(int32_t attribute, char *value, int value_len) @@ -162,7 +168,10 @@ int physical_sensor::set_attribute(int32_t attribute, char *value, int value_len if (!m_sensor_device) return false; - return m_sensor_device->set_attribute_str(m_info->id, attribute, value, value_len); + if (!m_sensor_device->set_attribute_str(m_info->id, attribute, value, value_len)) + return OP_ERROR; + + return OP_SUCCESS; } bool physical_sensor::set_wakeup(int wakeup) -- 2.7.4 From 7a2a3370d9f1bf3554f8dc83855856283cccc316 Mon Sep 17 00:00:00 2001 From: "kibak.yoon" Date: Wed, 2 Mar 2016 22:29:15 +0900 Subject: [PATCH 02/16] sensord: move .service/.socket to packaging Change-Id: Iaea00fe48fed8c44e20c24efbfc088e0c16f9cf9 Signed-off-by: kibak.yoon --- CMakeLists.txt | 1 - {systemd => packaging}/sensord.service | 0 packaging/sensord.spec | 20 +++++++++++++------- {systemd => packaging}/sensord_command.socket | 0 {systemd => packaging}/sensord_event.socket | 0 systemd/CMakeLists.txt | 6 ------ 6 files changed, 13 insertions(+), 14 deletions(-) rename {systemd => packaging}/sensord.service (100%) rename {systemd => packaging}/sensord_command.socket (100%) rename {systemd => packaging}/sensord_event.socket (100%) delete mode 100644 systemd/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 1994fe5..9b88ac8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,6 @@ INCLUDE_DIRECTORIES( ) # Sub-directory -ADD_SUBDIRECTORY(systemd) ADD_SUBDIRECTORY(src/server) ADD_SUBDIRECTORY(src/client) ADD_SUBDIRECTORY(src/shared) diff --git a/systemd/sensord.service b/packaging/sensord.service similarity index 100% rename from systemd/sensord.service rename to packaging/sensord.service diff --git a/packaging/sensord.spec b/packaging/sensord.spec index 7b93195..fdc6316 100644 --- a/packaging/sensord.spec +++ b/packaging/sensord.spec @@ -2,11 +2,13 @@ Name: sensord Summary: Sensor daemon Version: 2.0.2 Release: 0 -Group: System/Sensor Framework +Group: System/Sensor Framework License: Apache-2.0 Source0: %{name}-%{version}.tar.gz -Source1: sensord.manifest -Source2: libsensord.manifest +Source1: sensord.service +Source2: sensord_command.socket +Source3: sensord_event.socket + BuildRequires: cmake BuildRequires: libattr-devel @@ -70,8 +72,6 @@ Sensor functional testing %prep %setup -q -cp %{SOURCE1} . -cp %{SOURCE2} . MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` @@ -89,6 +89,12 @@ make %{?jobs:-j%jobs} rm -rf %{buildroot} %make_install +mkdir -p %{buildroot}%{_libdir}/systemd/system/ + +install -m 0644 %SOURCE1 %{buildroot}%{_libdir}/systemd/system/ +install -m 0644 %SOURCE2 %{buildroot}%{_libdir}/systemd/system/ +install -m 0644 %SOURCE3 %{buildroot}%{_libdir}/systemd/system/ + %install_service multi-user.target.wants sensord.service %install_service sockets.target.wants sensord_event.socket %install_service sockets.target.wants sensord_command.socket @@ -108,7 +114,7 @@ ln -sf %{_libdir}/libsensor.so.%{version} %{_libdir}/libsensor.so.1 %files %attr(0644,root,root)/usr/etc/virtual_sensors.xml -%manifest sensord.manifest +%manifest packaging/sensord.manifest %{_bindir}/sensord %{_unitdir}/sensord.service %{_unitdir}/sensord_command.socket @@ -120,7 +126,7 @@ ln -sf %{_libdir}/libsensor.so.%{version} %{_libdir}/libsensor.so.1 %files -n libsensord %defattr(-,root,root,-) -%manifest libsensord.manifest +%manifest packaging/libsensord.manifest %{_libdir}/libsensor.so.* %{_libdir}/libsensord-shared.so %license LICENSE.APLv2 diff --git a/systemd/sensord_command.socket b/packaging/sensord_command.socket similarity index 100% rename from systemd/sensord_command.socket rename to packaging/sensord_command.socket diff --git a/systemd/sensord_event.socket b/packaging/sensord_event.socket similarity index 100% rename from systemd/sensord_event.socket rename to packaging/sensord_event.socket diff --git a/systemd/CMakeLists.txt b/systemd/CMakeLists.txt deleted file mode 100644 index 64fbd69..0000000 --- a/systemd/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -INSTALL(FILES - ${CMAKE_CURRENT_SOURCE_DIR}/sensord.service - ${CMAKE_CURRENT_SOURCE_DIR}/sensord_command.socket - ${CMAKE_CURRENT_SOURCE_DIR}/sensord_event.socket - DESTINATION lib/systemd/system) - -- 2.7.4 From ecab3b1c44b4c3b7a285b66d32d9f931d234b9e6 Mon Sep 17 00:00:00 2001 From: "kibak.yoon" Date: Wed, 2 Mar 2016 22:41:10 +0900 Subject: [PATCH 03/16] sensord: restructuring sensord directories - src/server/plugins -> src/sensor - modify CMakeLists.txt Change-Id: I253b84e4dda7cc2cd4f62ca8e4b310be247881a6 Signed-off-by: kibak.yoon --- CMakeLists.txt | 12 +- src/client/CMakeLists.txt | 6 +- src/sensor/CMakeLists.txt | 70 +++++ .../plugins => sensor}/accel/accel_sensor.cpp | 0 .../plugins => sensor}/accel/accel_sensor.h | 0 .../auto_rotation/auto_rotation_alg.cpp | 0 .../auto_rotation/auto_rotation_alg.h | 0 .../auto_rotation/auto_rotation_alg_emul.cpp | 0 .../auto_rotation/auto_rotation_alg_emul.h | 0 .../auto_rotation/auto_rotation_sensor.cpp | 0 .../auto_rotation/auto_rotation_sensor.h | 0 .../plugins => sensor}/fusion/fusion_sensor.cpp | 0 .../plugins => sensor}/fusion/fusion_sensor.h | 0 .../fusion/hardware_fusion_sensor.html | 0 .../plugins => sensor}/gravity/gravity_sensor.cpp | 0 .../plugins => sensor}/gravity/gravity_sensor.h | 0 .../linear_accel/linear_accel_sensor.cpp | 0 .../linear_accel/linear_accel_sensor.h | 0 .../orientation/orientation_sensor.cpp | 0 .../orientation/orientation_sensor.h | 0 .../rotation_vector/gaming_rv/gaming_rv_sensor.cpp | 0 .../rotation_vector/gaming_rv/gaming_rv_sensor.h | 0 .../geomagnetic_rv/geomagnetic_rv_sensor.cpp | 0 .../geomagnetic_rv/geomagnetic_rv_sensor.h | 0 .../rotation_vector/rv/rv_sensor.cpp | 0 .../rotation_vector/rv/rv_sensor.h | 0 .../data/100ms/gravity/single_roll_throw/accel.txt | 0 .../data/100ms/gravity/single_roll_throw/gyro.txt | 0 .../100ms/gravity/single_roll_throw/magnetic.txt | 0 .../100ms/linear_acceleration/move_x_y_z/accel.txt | 0 .../100ms/linear_acceleration/move_x_y_z/gyro.txt | 0 .../linear_acceleration/move_x_y_z/magnetic.txt | 0 .../100ms/orientation/roll_pitch_yaw/accel.txt | 0 .../data/100ms/orientation/roll_pitch_yaw/gyro.txt | 0 .../100ms/orientation/roll_pitch_yaw/magnetic.txt | 0 .../data/25ms/pedo/Climb_stairs_down/In_hand/accel | 0 .../data/25ms/pedo/Climb_stairs_down/In_hand/gyro | 0 .../25ms/pedo/Climb_stairs_down/In_hand/magnetic | 0 .../25ms/pedo/Climb_stairs_down/Pant_pocket/accel | 0 .../25ms/pedo/Climb_stairs_down/Pant_pocket/gyro | 0 .../pedo/Climb_stairs_down/Pant_pocket/magnetic | 0 .../25ms/pedo/Climb_stairs_down/Shirt_pocket/accel | 0 .../25ms/pedo/Climb_stairs_down/Shirt_pocket/gyro | 0 .../pedo/Climb_stairs_down/Shirt_pocket/magnetic | 0 .../pedo/Climb_stairs_down/While_talking/accel | 0 .../25ms/pedo/Climb_stairs_down/While_talking/gyro | 0 .../pedo/Climb_stairs_down/While_talking/magnetic | 0 .../data/25ms/pedo/Climb_stairs_up/In_hand/accel | 0 .../data/25ms/pedo/Climb_stairs_up/In_hand/gyro | 0 .../25ms/pedo/Climb_stairs_up/In_hand/magnetic | 0 .../25ms/pedo/Climb_stairs_up/Pant_pocket/accel | 0 .../25ms/pedo/Climb_stairs_up/Pant_pocket/gyro | 0 .../25ms/pedo/Climb_stairs_up/Pant_pocket/magnetic | 0 .../25ms/pedo/Climb_stairs_up/Shirt_pocket/accel | 0 .../25ms/pedo/Climb_stairs_up/Shirt_pocket/gyro | 0 .../pedo/Climb_stairs_up/Shirt_pocket/magnetic | 0 .../25ms/pedo/Climb_stairs_up/While_talking/accel | 0 .../25ms/pedo/Climb_stairs_up/While_talking/gyro | 0 .../pedo/Climb_stairs_up/While_talking/magnetic | 0 .../design/data/25ms/pedo/Walk_fast/In_hand/accel | 0 .../design/data/25ms/pedo/Walk_fast/In_hand/gyro | 0 .../data/25ms/pedo/Walk_fast/In_hand/magnetic | 0 .../data/25ms/pedo/Walk_fast/Pant_pocket/accel | 0 .../data/25ms/pedo/Walk_fast/Pant_pocket/gyro | 0 .../data/25ms/pedo/Walk_fast/Pant_pocket/magnetic | 0 .../data/25ms/pedo/Walk_fast/Shirt_pocket/accel | 0 .../data/25ms/pedo/Walk_fast/Shirt_pocket/gyro | 0 .../data/25ms/pedo/Walk_fast/Shirt_pocket/magnetic | 0 .../data/25ms/pedo/Walk_fast/While_talking/accel | 0 .../data/25ms/pedo/Walk_fast/While_talking/gyro | 0 .../25ms/pedo/Walk_fast/While_talking/magnetic | 0 .../design/data/25ms/pedo/Walk_slow/In_hand/accel | 0 .../design/data/25ms/pedo/Walk_slow/In_hand/gyro | 0 .../data/25ms/pedo/Walk_slow/In_hand/magnetic | 0 .../data/25ms/pedo/Walk_slow/Pant_pocket/accel | 0 .../data/25ms/pedo/Walk_slow/Pant_pocket/gyro | 0 .../data/25ms/pedo/Walk_slow/Pant_pocket/magnetic | 0 .../data/25ms/pedo/Walk_slow/Shirt_pocket/accel | 0 .../data/25ms/pedo/Walk_slow/Shirt_pocket/gyro | 0 .../data/25ms/pedo/Walk_slow/Shirt_pocket/magnetic | 0 .../data/25ms/pedo/Walk_slow/While_talking/accel | 0 .../data/25ms/pedo/Walk_slow/While_talking/gyro | 0 .../25ms/pedo/Walk_slow/While_talking/magnetic | 0 ...ock_diagram_gravity_and_linear_acceleration.png | Bin .../block_diagram_orientation_estimation.png | Bin .../documentation/diagram/device_orientation.png | Bin .../documentation/diagram/kalman_filter_stages.png | Bin .../diagram/orientation_effect_on_gravity.png | Bin .../projection_diagram_gravity_computation.png | Bin .../design/documentation/equation/equation_1.png | Bin .../design/documentation/equation/equation_10.png | Bin .../design/documentation/equation/equation_11.png | Bin .../design/documentation/equation/equation_12.png | Bin .../design/documentation/equation/equation_13.png | Bin .../documentation/equation/equation_13_updated.png | Bin .../design/documentation/equation/equation_14.png | Bin .../design/documentation/equation/equation_15.png | Bin .../design/documentation/equation/equation_16.png | Bin .../design/documentation/equation/equation_17.png | Bin .../design/documentation/equation/equation_18.png | Bin .../design/documentation/equation/equation_19.png | Bin .../design/documentation/equation/equation_2.png | Bin .../design/documentation/equation/equation_20.png | Bin .../design/documentation/equation/equation_21.png | Bin .../design/documentation/equation/equation_22.png | Bin .../design/documentation/equation/equation_23.png | Bin .../design/documentation/equation/equation_24.png | Bin .../design/documentation/equation/equation_25.png | Bin .../design/documentation/equation/equation_26.png | Bin .../design/documentation/equation/equation_27.png | Bin .../design/documentation/equation/equation_28.png | Bin .../design/documentation/equation/equation_29.png | Bin .../design/documentation/equation/equation_3.png | Bin .../design/documentation/equation/equation_30.png | Bin .../design/documentation/equation/equation_31.png | Bin .../design/documentation/equation/equation_32.png | Bin .../design/documentation/equation/equation_33.png | Bin .../design/documentation/equation/equation_34.png | Bin .../design/documentation/equation/equation_35.png | Bin .../design/documentation/equation/equation_36.png | Bin .../design/documentation/equation/equation_37.png | Bin .../design/documentation/equation/equation_38.png | Bin .../design/documentation/equation/equation_39.png | Bin .../design/documentation/equation/equation_4.png | Bin .../design/documentation/equation/equation_40.png | Bin .../design/documentation/equation/equation_5.png | Bin .../design/documentation/equation/equation_6.png | Bin .../design/documentation/equation/equation_7.png | Bin .../design/documentation/equation/equation_8.png | Bin .../design/documentation/equation/equation_9.png | Bin .../design/documentation/sensor_fusion.htm | 0 .../sensor_fusion/design/lib/axis_rot2quat.m | 0 .../sensor_fusion/design/lib/estimate_gaming_rv.m | 0 .../design/lib/estimate_geomagnetic_rv.m | 0 .../sensor_fusion/design/lib/estimate_gravity.m | 0 .../design/lib/estimate_linear_acceleration.m | 0 .../design/lib/estimate_orientation.m | 0 .../sensor_fusion/design/lib/euler2quat.m | 0 .../sensor_fusion/design/lib/quat2euler.m | 0 .../sensor_fusion/design/lib/quat2rot_mat.m | 0 .../sensor_fusion/design/lib/quat_prod.m | 0 .../sensor_fusion/design/lib/rot_mat2quat.m | 0 .../sensor_fusion/design/lib/sf_pedometer.m | 0 .../plugins => sensor}/sensor_fusion/design/readme | 0 .../sensor_fusion/design/sf_gaming_rv.m | 0 .../sensor_fusion/design/sf_geomagnetic_rv.m | 0 .../sensor_fusion/design/sf_gravity.m | 0 .../sensor_fusion/design/sf_linear_acceleration.m | 0 .../sensor_fusion/design/sf_orientation.m | 0 .../sensor_fusion/euler_angles.cpp | 0 .../sensor_fusion/euler_angles.h | 0 .../plugins => sensor}/sensor_fusion/matrix.cpp | 0 .../plugins => sensor}/sensor_fusion/matrix.h | 0 .../sensor_fusion/orientation_filter.cpp | 0 .../sensor_fusion/orientation_filter.h | 0 .../sensor_fusion/quaternion.cpp | 0 .../plugins => sensor}/sensor_fusion/quaternion.h | 0 .../sensor_fusion/rotation_matrix.cpp | 0 .../sensor_fusion/rotation_matrix.h | 0 .../sensor_fusion/sensor_data.cpp | 0 .../plugins => sensor}/sensor_fusion/sensor_data.h | 0 .../sensor_fusion/test/gravity_sensor.cpp | 0 .../sensor_fusion/test/gravity_sensor.h | 0 .../test/linear_acceleration_sensor.cpp | 0 .../test/linear_acceleration_sensor.h | 0 .../sensor_fusion/test/orientation_sensor.cpp | 0 .../sensor_fusion/test/orientation_sensor.h | 0 .../euler_angles_test/euler_angles_main.cpp | 0 .../gravity_sensor_test/gravity_sensor_main.cpp | 0 .../linear_acceleration_sensor_main.cpp | 0 .../test/test_projects/matrix_test/matrix_main.cpp | 0 .../orientation_sensor_main.cpp | 0 .../quaternion_test/quaternion_main.cpp | 0 .../rotation_matrix_test/rotation_matrix_main.cpp | 0 .../sensor_data_test/sensor_data_main.cpp | 0 .../test/test_projects/vector_test/vector_main.cpp | 0 .../plugins => sensor}/sensor_fusion/vector.cpp | 0 .../plugins => sensor}/sensor_fusion/vector.h | 0 .../plugins => sensor}/tilt/tilt_sensor.cpp | 0 src/{server/plugins => sensor}/tilt/tilt_sensor.h | 0 src/{server/plugins => sensor}/virtual_sensors.xml | 0 src/server/CMakeLists.txt | 15 +- src/server/plugins/CMakeLists.txt | 126 --------- .../test/test_projects/euler_angles_test/.cproject | 112 -------- .../test/test_projects/euler_angles_test/.project | 89 ------- .../test_projects/gravity_sensor_test/.cproject | 117 --------- .../test_projects/gravity_sensor_test/.project | 89 ------- .../linear_acceleration_sensor_test/.cproject | 112 -------- .../linear_acceleration_sensor_test/.project | 89 ------- .../test/test_projects/matrix_test/.cproject | 112 -------- .../test/test_projects/matrix_test/.project | 89 ------- .../orientation_sensor_test/.cproject | 112 -------- .../test_projects/orientation_sensor_test/.project | 89 ------- .../test/test_projects/quaternion_test/.cproject | 112 -------- .../test/test_projects/quaternion_test/.project | 89 ------- .../test_projects/rotation_matrix_test/.cproject | 112 -------- .../test_projects/rotation_matrix_test/.project | 89 ------- .../test/test_projects/sensor_data_test/.cproject | 112 -------- .../test/test_projects/sensor_data_test/.project | 89 ------- .../test/test_projects/vector_test/.cproject | 112 -------- .../test/test_projects/vector_test/.project | 83 ------ src/server/plugins/sensor_module_create.cpp.in | 289 --------------------- src/shared/CMakeLists.txt | 6 +- {test => src/test}/CMakeLists.txt | 0 {test => src/test}/src/api-test.c | 0 {test => src/test}/src/check-sensor.c | 0 {test => src/test}/src/check-sensor.h | 0 {test => src/test}/src/fusion-data-collection.c | 0 .../test}/src/multi-process-performance-test.c | 0 .../test}/src/multi-thread-performance-test.c | 0 {test => src/test}/src/sensor-test.c | 0 211 files changed, 90 insertions(+), 2242 deletions(-) create mode 100644 src/sensor/CMakeLists.txt rename src/{server/plugins => sensor}/accel/accel_sensor.cpp (100%) rename src/{server/plugins => sensor}/accel/accel_sensor.h (100%) rename src/{server/plugins => sensor}/auto_rotation/auto_rotation_alg.cpp (100%) rename src/{server/plugins => sensor}/auto_rotation/auto_rotation_alg.h (100%) rename src/{server/plugins => sensor}/auto_rotation/auto_rotation_alg_emul.cpp (100%) rename src/{server/plugins => sensor}/auto_rotation/auto_rotation_alg_emul.h (100%) rename src/{server/plugins => sensor}/auto_rotation/auto_rotation_sensor.cpp (100%) rename src/{server/plugins => sensor}/auto_rotation/auto_rotation_sensor.h (100%) rename src/{server/plugins => sensor}/fusion/fusion_sensor.cpp (100%) rename src/{server/plugins => sensor}/fusion/fusion_sensor.h (100%) rename src/{server/plugins => sensor}/fusion/hardware_fusion_sensor.html (100%) rename src/{server/plugins => sensor}/gravity/gravity_sensor.cpp (100%) rename src/{server/plugins => sensor}/gravity/gravity_sensor.h (100%) rename src/{server/plugins => sensor}/linear_accel/linear_accel_sensor.cpp (100%) rename src/{server/plugins => sensor}/linear_accel/linear_accel_sensor.h (100%) rename src/{server/plugins => sensor}/orientation/orientation_sensor.cpp (100%) rename src/{server/plugins => sensor}/orientation/orientation_sensor.h (100%) rename src/{server/plugins => sensor}/rotation_vector/gaming_rv/gaming_rv_sensor.cpp (100%) rename src/{server/plugins => sensor}/rotation_vector/gaming_rv/gaming_rv_sensor.h (100%) rename src/{server/plugins => sensor}/rotation_vector/geomagnetic_rv/geomagnetic_rv_sensor.cpp (100%) rename src/{server/plugins => sensor}/rotation_vector/geomagnetic_rv/geomagnetic_rv_sensor.h (100%) rename src/{server/plugins => sensor}/rotation_vector/rv/rv_sensor.cpp (100%) rename src/{server/plugins => sensor}/rotation_vector/rv/rv_sensor.h (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/100ms/gravity/single_roll_throw/accel.txt (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/100ms/gravity/single_roll_throw/gyro.txt (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/100ms/gravity/single_roll_throw/magnetic.txt (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/100ms/linear_acceleration/move_x_y_z/accel.txt (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/100ms/linear_acceleration/move_x_y_z/gyro.txt (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/100ms/linear_acceleration/move_x_y_z/magnetic.txt (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/100ms/orientation/roll_pitch_yaw/accel.txt (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/100ms/orientation/roll_pitch_yaw/gyro.txt (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/100ms/orientation/roll_pitch_yaw/magnetic.txt (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/In_hand/accel (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/In_hand/gyro (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/In_hand/magnetic (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Pant_pocket/accel (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Pant_pocket/gyro (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Pant_pocket/magnetic (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Shirt_pocket/accel (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Shirt_pocket/gyro (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Shirt_pocket/magnetic (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/While_talking/accel (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/While_talking/gyro (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/While_talking/magnetic (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/In_hand/accel (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/In_hand/gyro (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/In_hand/magnetic (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Pant_pocket/accel (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Pant_pocket/gyro (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Pant_pocket/magnetic (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Shirt_pocket/accel (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Shirt_pocket/gyro (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Shirt_pocket/magnetic (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/While_talking/accel (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/While_talking/gyro (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/While_talking/magnetic (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Walk_fast/In_hand/accel (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Walk_fast/In_hand/gyro (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Walk_fast/In_hand/magnetic (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Walk_fast/Pant_pocket/accel (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Walk_fast/Pant_pocket/gyro (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Walk_fast/Pant_pocket/magnetic (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Walk_fast/Shirt_pocket/accel (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Walk_fast/Shirt_pocket/gyro (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Walk_fast/Shirt_pocket/magnetic (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Walk_fast/While_talking/accel (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Walk_fast/While_talking/gyro (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Walk_fast/While_talking/magnetic (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Walk_slow/In_hand/accel (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Walk_slow/In_hand/gyro (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Walk_slow/In_hand/magnetic (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Walk_slow/Pant_pocket/accel (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Walk_slow/Pant_pocket/gyro (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Walk_slow/Pant_pocket/magnetic (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Walk_slow/Shirt_pocket/accel (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Walk_slow/Shirt_pocket/gyro (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Walk_slow/Shirt_pocket/magnetic (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Walk_slow/While_talking/accel (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Walk_slow/While_talking/gyro (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/data/25ms/pedo/Walk_slow/While_talking/magnetic (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/diagram/block_diagram_gravity_and_linear_acceleration.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/diagram/block_diagram_orientation_estimation.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/diagram/device_orientation.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/diagram/kalman_filter_stages.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/diagram/orientation_effect_on_gravity.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/diagram/projection_diagram_gravity_computation.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_1.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_10.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_11.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_12.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_13.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_13_updated.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_14.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_15.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_16.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_17.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_18.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_19.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_2.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_20.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_21.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_22.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_23.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_24.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_25.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_26.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_27.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_28.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_29.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_3.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_30.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_31.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_32.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_33.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_34.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_35.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_36.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_37.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_38.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_39.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_4.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_40.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_5.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_6.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_7.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_8.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/equation/equation_9.png (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/documentation/sensor_fusion.htm (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/lib/axis_rot2quat.m (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/lib/estimate_gaming_rv.m (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/lib/estimate_geomagnetic_rv.m (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/lib/estimate_gravity.m (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/lib/estimate_linear_acceleration.m (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/lib/estimate_orientation.m (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/lib/euler2quat.m (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/lib/quat2euler.m (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/lib/quat2rot_mat.m (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/lib/quat_prod.m (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/lib/rot_mat2quat.m (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/lib/sf_pedometer.m (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/readme (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/sf_gaming_rv.m (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/sf_geomagnetic_rv.m (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/sf_gravity.m (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/sf_linear_acceleration.m (100%) rename src/{server/plugins => sensor}/sensor_fusion/design/sf_orientation.m (100%) rename src/{server/plugins => sensor}/sensor_fusion/euler_angles.cpp (100%) rename src/{server/plugins => sensor}/sensor_fusion/euler_angles.h (100%) rename src/{server/plugins => sensor}/sensor_fusion/matrix.cpp (100%) rename src/{server/plugins => sensor}/sensor_fusion/matrix.h (100%) rename src/{server/plugins => sensor}/sensor_fusion/orientation_filter.cpp (100%) rename src/{server/plugins => sensor}/sensor_fusion/orientation_filter.h (100%) rename src/{server/plugins => sensor}/sensor_fusion/quaternion.cpp (100%) rename src/{server/plugins => sensor}/sensor_fusion/quaternion.h (100%) rename src/{server/plugins => sensor}/sensor_fusion/rotation_matrix.cpp (100%) rename src/{server/plugins => sensor}/sensor_fusion/rotation_matrix.h (100%) rename src/{server/plugins => sensor}/sensor_fusion/sensor_data.cpp (100%) rename src/{server/plugins => sensor}/sensor_fusion/sensor_data.h (100%) rename src/{server/plugins => sensor}/sensor_fusion/test/gravity_sensor.cpp (100%) rename src/{server/plugins => sensor}/sensor_fusion/test/gravity_sensor.h (100%) rename src/{server/plugins => sensor}/sensor_fusion/test/linear_acceleration_sensor.cpp (100%) rename src/{server/plugins => sensor}/sensor_fusion/test/linear_acceleration_sensor.h (100%) rename src/{server/plugins => sensor}/sensor_fusion/test/orientation_sensor.cpp (100%) rename src/{server/plugins => sensor}/sensor_fusion/test/orientation_sensor.h (100%) rename src/{server/plugins => sensor}/sensor_fusion/test/test_projects/euler_angles_test/euler_angles_main.cpp (100%) rename src/{server/plugins => sensor}/sensor_fusion/test/test_projects/gravity_sensor_test/gravity_sensor_main.cpp (100%) rename src/{server/plugins => sensor}/sensor_fusion/test/test_projects/linear_acceleration_sensor_test/linear_acceleration_sensor_main.cpp (100%) rename src/{server/plugins => sensor}/sensor_fusion/test/test_projects/matrix_test/matrix_main.cpp (100%) rename src/{server/plugins => sensor}/sensor_fusion/test/test_projects/orientation_sensor_test/orientation_sensor_main.cpp (100%) rename src/{server/plugins => sensor}/sensor_fusion/test/test_projects/quaternion_test/quaternion_main.cpp (100%) rename src/{server/plugins => sensor}/sensor_fusion/test/test_projects/rotation_matrix_test/rotation_matrix_main.cpp (100%) rename src/{server/plugins => sensor}/sensor_fusion/test/test_projects/sensor_data_test/sensor_data_main.cpp (100%) rename src/{server/plugins => sensor}/sensor_fusion/test/test_projects/vector_test/vector_main.cpp (100%) rename src/{server/plugins => sensor}/sensor_fusion/vector.cpp (100%) rename src/{server/plugins => sensor}/sensor_fusion/vector.h (100%) rename src/{server/plugins => sensor}/tilt/tilt_sensor.cpp (100%) rename src/{server/plugins => sensor}/tilt/tilt_sensor.h (100%) rename src/{server/plugins => sensor}/virtual_sensors.xml (100%) delete mode 100644 src/server/plugins/CMakeLists.txt delete mode 100644 src/server/plugins/sensor_fusion/test/test_projects/euler_angles_test/.cproject delete mode 100644 src/server/plugins/sensor_fusion/test/test_projects/euler_angles_test/.project delete mode 100644 src/server/plugins/sensor_fusion/test/test_projects/gravity_sensor_test/.cproject delete mode 100644 src/server/plugins/sensor_fusion/test/test_projects/gravity_sensor_test/.project delete mode 100644 src/server/plugins/sensor_fusion/test/test_projects/linear_acceleration_sensor_test/.cproject delete mode 100644 src/server/plugins/sensor_fusion/test/test_projects/linear_acceleration_sensor_test/.project delete mode 100644 src/server/plugins/sensor_fusion/test/test_projects/matrix_test/.cproject delete mode 100644 src/server/plugins/sensor_fusion/test/test_projects/matrix_test/.project delete mode 100644 src/server/plugins/sensor_fusion/test/test_projects/orientation_sensor_test/.cproject delete mode 100644 src/server/plugins/sensor_fusion/test/test_projects/orientation_sensor_test/.project delete mode 100644 src/server/plugins/sensor_fusion/test/test_projects/quaternion_test/.cproject delete mode 100644 src/server/plugins/sensor_fusion/test/test_projects/quaternion_test/.project delete mode 100644 src/server/plugins/sensor_fusion/test/test_projects/rotation_matrix_test/.cproject delete mode 100644 src/server/plugins/sensor_fusion/test/test_projects/rotation_matrix_test/.project delete mode 100644 src/server/plugins/sensor_fusion/test/test_projects/sensor_data_test/.cproject delete mode 100644 src/server/plugins/sensor_fusion/test/test_projects/sensor_data_test/.project delete mode 100644 src/server/plugins/sensor_fusion/test/test_projects/vector_test/.cproject delete mode 100644 src/server/plugins/sensor_fusion/test/test_projects/vector_test/.project delete mode 100644 src/server/plugins/sensor_module_create.cpp.in rename {test => src/test}/CMakeLists.txt (100%) rename {test => src/test}/src/api-test.c (100%) rename {test => src/test}/src/check-sensor.c (100%) rename {test => src/test}/src/check-sensor.h (100%) rename {test => src/test}/src/fusion-data-collection.c (100%) rename {test => src/test}/src/multi-process-performance-test.c (100%) rename {test => src/test}/src/multi-thread-performance-test.c (100%) rename {test => src/test}/src/sensor-test.c (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b88ac8..591edb4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,19 +12,9 @@ MESSAGE("FLAGS: ${CMAKE_EXE_LINKER_FLAGS}") # Internal Debugging Options #add_definitions(-Wall -g -D_DEBUG) -INCLUDE_DIRECTORIES( - ${CMAKE_CURRENT_SOURCE_DIR}/src/ - ${CMAKE_CURRENT_SOURCE_DIR}/src/shared - ${CMAKE_CURRENT_SOURCE_DIR}/src/hal -) - # Sub-directory ADD_SUBDIRECTORY(src/server) ADD_SUBDIRECTORY(src/client) ADD_SUBDIRECTORY(src/shared) ADD_SUBDIRECTORY(src/hal) - -IF("${TEST_SUITE}" STREQUAL "ON") -ADD_SUBDIRECTORY(test) -ENDIF() - +ADD_SUBDIRECTORY(src/test) diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt index f002263..0ad7db0 100644 --- a/src/client/CMakeLists.txt +++ b/src/client/CMakeLists.txt @@ -22,7 +22,11 @@ ENDFOREACH(flag) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -fvisibility-inlines-hidden -g -fPIC") -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) +INCLUDE_DIRECTORIES( + ${CMAKE_SOURCE_DIR}/src/hal + ${CMAKE_SOURCE_DIR}/src/shared + ${CMAKE_CURRENT_SOURCE_DIR} +) FILE(GLOB_RECURSE SRCS *.cpp) ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS}) diff --git a/src/sensor/CMakeLists.txt b/src/sensor/CMakeLists.txt new file mode 100644 index 0000000..b37f7bf --- /dev/null +++ b/src/sensor/CMakeLists.txt @@ -0,0 +1,70 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(sensors CXX) +INCLUDE(GNUInstallDirs) + +SET(HRM "OFF") +SET(HRM_VIRT "OFF") +SET(AUTO_ROTATION "ON") +SET(GRAVITY "OFF") +SET(LINEAR_ACCEL "OFF") +SET(ORIENTATION "OFF") +SET(FUSION "OFF") +SET(MOTION "OFF") +SET(RV "OFF") + +INCLUDE_DIRECTORIES( + ${CMAKE_SOURCE_DIR}/src/shared + ${CMAKE_SOURCE_DIR}/src/server + ${CMAKE_CURRENT_SOURCE_DIR} +) + +FILE(GLOB SENSOR_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +SET(SENSOR_HEADERS ${SENSOR_HEADERS} ${CMAKE_CURRENT_SOURCE_DIR}) + +FILE(GLOB_RECURSE SENSOR_SRCS ${SENSOR_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/accel/*.cpp) +SET(SENSOR_HEADERS ${SENSOR_HEADERS} ${CMAKE_CURRENT_SOURCE_DIR}/accel) +SET(SENSOR_DEFINITIONS ${SENSOR_DEFINITIONS} "-DENABLE_ACCEL") + +IF("${HRM}" STREQUAL "ON") + FILE(GLOB_RECURSE SENSOR_SRCS ${SENSOR_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/hrm/*.cpp) + SET(SENSOR_HEADERS ${SENSOR_HEADERS} ${CMAKE_CURRENT_SOURCE_DIR}/hrm) + SET(SENSOR_DEFINITIONS ${SENSOR_DEFINITIONS} "-DENABLE_HRM") +ENDIF() +IF("${HRM_VIRT}" STREQUAL "ON") +add_subdirectory(hrm_virt) +ENDIF() +IF("${AUTO_ROTATION}" STREQUAL "ON") + FILE(GLOB_RECURSE SENSOR_SRCS ${SENSOR_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/auto_rotation/*.cpp) + SET(SENSOR_HEADERS ${SENSOR_HEADERS} ${CMAKE_CURRENT_SOURCE_DIR}/auto_rotation) + SET(SENSOR_DEFINITIONS ${SENSOR_DEFINITIONS} "-DENABLE_AUTO_ROTATION") +ENDIF() +IF("${GRAVITY}" STREQUAL "ON") + FILE(GLOB_RECURSE SENSOR_SRCS ${SENSOR_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/gravity/*.cpp) + SET(SENSOR_HEADERS ${SENSOR_HEADERS} ${CMAKE_CURRENT_SOURCE_DIR}/gravity) + SET(SENSOR_DEFINITIONS ${SENSOR_DEFINITIONS} "-DENABLE_GRAVITY") +ENDIF() +IF("${LINEAR_ACCEL}" STREQUAL "ON") + FILE(GLOB_RECURSE SENSOR_SRCS ${SENSOR_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/linear_accel/*.cpp) + SET(SENSOR_HEADERS ${SENSOR_HEADERS} ${CMAKE_CURRENT_SOURCE_DIR}/linear_accel) + SET(SENSOR_DEFINITIONS ${SENSOR_DEFINITIONS} "-DENABLE_LINEAR_ACCEL") +ENDIF() +IF("${ORIENTATION}" STREQUAL "ON") +add_subdirectory(orientation) +ENDIF() +IF("${RV}" STREQUAL "ON") +add_subdirectory(rotation_vector) +ENDIF() +IF("${FUSION}" STREQUAL "ON") +add_subdirectory(fusion) +ENDIF() +IF("${MOTION}" STREQUAL "ON") +add_subdirectory(motion) +ENDIF() + +MESSAGE("${SENSOR_SRCS}") +SET(SENSOR_SRCS ${SENSOR_SRCS} PARENT_SCOPE) +SET(SENSOR_HEADERS ${SENSOR_HEADERS} PARENT_SCOPE) +SET(SENSOR_DEFINITIONS ${SENSOR_DEFINITIONS} PARENT_SCOPE) + +# Installing files +INSTALL(FILES virtual_sensors.xml virtual_sensors.xml DESTINATION etc) diff --git a/src/server/plugins/accel/accel_sensor.cpp b/src/sensor/accel/accel_sensor.cpp similarity index 100% rename from src/server/plugins/accel/accel_sensor.cpp rename to src/sensor/accel/accel_sensor.cpp diff --git a/src/server/plugins/accel/accel_sensor.h b/src/sensor/accel/accel_sensor.h similarity index 100% rename from src/server/plugins/accel/accel_sensor.h rename to src/sensor/accel/accel_sensor.h diff --git a/src/server/plugins/auto_rotation/auto_rotation_alg.cpp b/src/sensor/auto_rotation/auto_rotation_alg.cpp similarity index 100% rename from src/server/plugins/auto_rotation/auto_rotation_alg.cpp rename to src/sensor/auto_rotation/auto_rotation_alg.cpp diff --git a/src/server/plugins/auto_rotation/auto_rotation_alg.h b/src/sensor/auto_rotation/auto_rotation_alg.h similarity index 100% rename from src/server/plugins/auto_rotation/auto_rotation_alg.h rename to src/sensor/auto_rotation/auto_rotation_alg.h diff --git a/src/server/plugins/auto_rotation/auto_rotation_alg_emul.cpp b/src/sensor/auto_rotation/auto_rotation_alg_emul.cpp similarity index 100% rename from src/server/plugins/auto_rotation/auto_rotation_alg_emul.cpp rename to src/sensor/auto_rotation/auto_rotation_alg_emul.cpp diff --git a/src/server/plugins/auto_rotation/auto_rotation_alg_emul.h b/src/sensor/auto_rotation/auto_rotation_alg_emul.h similarity index 100% rename from src/server/plugins/auto_rotation/auto_rotation_alg_emul.h rename to src/sensor/auto_rotation/auto_rotation_alg_emul.h diff --git a/src/server/plugins/auto_rotation/auto_rotation_sensor.cpp b/src/sensor/auto_rotation/auto_rotation_sensor.cpp similarity index 100% rename from src/server/plugins/auto_rotation/auto_rotation_sensor.cpp rename to src/sensor/auto_rotation/auto_rotation_sensor.cpp diff --git a/src/server/plugins/auto_rotation/auto_rotation_sensor.h b/src/sensor/auto_rotation/auto_rotation_sensor.h similarity index 100% rename from src/server/plugins/auto_rotation/auto_rotation_sensor.h rename to src/sensor/auto_rotation/auto_rotation_sensor.h diff --git a/src/server/plugins/fusion/fusion_sensor.cpp b/src/sensor/fusion/fusion_sensor.cpp similarity index 100% rename from src/server/plugins/fusion/fusion_sensor.cpp rename to src/sensor/fusion/fusion_sensor.cpp diff --git a/src/server/plugins/fusion/fusion_sensor.h b/src/sensor/fusion/fusion_sensor.h similarity index 100% rename from src/server/plugins/fusion/fusion_sensor.h rename to src/sensor/fusion/fusion_sensor.h diff --git a/src/server/plugins/fusion/hardware_fusion_sensor.html b/src/sensor/fusion/hardware_fusion_sensor.html similarity index 100% rename from src/server/plugins/fusion/hardware_fusion_sensor.html rename to src/sensor/fusion/hardware_fusion_sensor.html diff --git a/src/server/plugins/gravity/gravity_sensor.cpp b/src/sensor/gravity/gravity_sensor.cpp similarity index 100% rename from src/server/plugins/gravity/gravity_sensor.cpp rename to src/sensor/gravity/gravity_sensor.cpp diff --git a/src/server/plugins/gravity/gravity_sensor.h b/src/sensor/gravity/gravity_sensor.h similarity index 100% rename from src/server/plugins/gravity/gravity_sensor.h rename to src/sensor/gravity/gravity_sensor.h diff --git a/src/server/plugins/linear_accel/linear_accel_sensor.cpp b/src/sensor/linear_accel/linear_accel_sensor.cpp similarity index 100% rename from src/server/plugins/linear_accel/linear_accel_sensor.cpp rename to src/sensor/linear_accel/linear_accel_sensor.cpp diff --git a/src/server/plugins/linear_accel/linear_accel_sensor.h b/src/sensor/linear_accel/linear_accel_sensor.h similarity index 100% rename from src/server/plugins/linear_accel/linear_accel_sensor.h rename to src/sensor/linear_accel/linear_accel_sensor.h diff --git a/src/server/plugins/orientation/orientation_sensor.cpp b/src/sensor/orientation/orientation_sensor.cpp similarity index 100% rename from src/server/plugins/orientation/orientation_sensor.cpp rename to src/sensor/orientation/orientation_sensor.cpp diff --git a/src/server/plugins/orientation/orientation_sensor.h b/src/sensor/orientation/orientation_sensor.h similarity index 100% rename from src/server/plugins/orientation/orientation_sensor.h rename to src/sensor/orientation/orientation_sensor.h diff --git a/src/server/plugins/rotation_vector/gaming_rv/gaming_rv_sensor.cpp b/src/sensor/rotation_vector/gaming_rv/gaming_rv_sensor.cpp similarity index 100% rename from src/server/plugins/rotation_vector/gaming_rv/gaming_rv_sensor.cpp rename to src/sensor/rotation_vector/gaming_rv/gaming_rv_sensor.cpp diff --git a/src/server/plugins/rotation_vector/gaming_rv/gaming_rv_sensor.h b/src/sensor/rotation_vector/gaming_rv/gaming_rv_sensor.h similarity index 100% rename from src/server/plugins/rotation_vector/gaming_rv/gaming_rv_sensor.h rename to src/sensor/rotation_vector/gaming_rv/gaming_rv_sensor.h diff --git a/src/server/plugins/rotation_vector/geomagnetic_rv/geomagnetic_rv_sensor.cpp b/src/sensor/rotation_vector/geomagnetic_rv/geomagnetic_rv_sensor.cpp similarity index 100% rename from src/server/plugins/rotation_vector/geomagnetic_rv/geomagnetic_rv_sensor.cpp rename to src/sensor/rotation_vector/geomagnetic_rv/geomagnetic_rv_sensor.cpp diff --git a/src/server/plugins/rotation_vector/geomagnetic_rv/geomagnetic_rv_sensor.h b/src/sensor/rotation_vector/geomagnetic_rv/geomagnetic_rv_sensor.h similarity index 100% rename from src/server/plugins/rotation_vector/geomagnetic_rv/geomagnetic_rv_sensor.h rename to src/sensor/rotation_vector/geomagnetic_rv/geomagnetic_rv_sensor.h diff --git a/src/server/plugins/rotation_vector/rv/rv_sensor.cpp b/src/sensor/rotation_vector/rv/rv_sensor.cpp similarity index 100% rename from src/server/plugins/rotation_vector/rv/rv_sensor.cpp rename to src/sensor/rotation_vector/rv/rv_sensor.cpp diff --git a/src/server/plugins/rotation_vector/rv/rv_sensor.h b/src/sensor/rotation_vector/rv/rv_sensor.h similarity index 100% rename from src/server/plugins/rotation_vector/rv/rv_sensor.h rename to src/sensor/rotation_vector/rv/rv_sensor.h diff --git a/src/server/plugins/sensor_fusion/design/data/100ms/gravity/single_roll_throw/accel.txt b/src/sensor/sensor_fusion/design/data/100ms/gravity/single_roll_throw/accel.txt similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/100ms/gravity/single_roll_throw/accel.txt rename to src/sensor/sensor_fusion/design/data/100ms/gravity/single_roll_throw/accel.txt diff --git a/src/server/plugins/sensor_fusion/design/data/100ms/gravity/single_roll_throw/gyro.txt b/src/sensor/sensor_fusion/design/data/100ms/gravity/single_roll_throw/gyro.txt similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/100ms/gravity/single_roll_throw/gyro.txt rename to src/sensor/sensor_fusion/design/data/100ms/gravity/single_roll_throw/gyro.txt diff --git a/src/server/plugins/sensor_fusion/design/data/100ms/gravity/single_roll_throw/magnetic.txt b/src/sensor/sensor_fusion/design/data/100ms/gravity/single_roll_throw/magnetic.txt similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/100ms/gravity/single_roll_throw/magnetic.txt rename to src/sensor/sensor_fusion/design/data/100ms/gravity/single_roll_throw/magnetic.txt diff --git a/src/server/plugins/sensor_fusion/design/data/100ms/linear_acceleration/move_x_y_z/accel.txt b/src/sensor/sensor_fusion/design/data/100ms/linear_acceleration/move_x_y_z/accel.txt similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/100ms/linear_acceleration/move_x_y_z/accel.txt rename to src/sensor/sensor_fusion/design/data/100ms/linear_acceleration/move_x_y_z/accel.txt diff --git a/src/server/plugins/sensor_fusion/design/data/100ms/linear_acceleration/move_x_y_z/gyro.txt b/src/sensor/sensor_fusion/design/data/100ms/linear_acceleration/move_x_y_z/gyro.txt similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/100ms/linear_acceleration/move_x_y_z/gyro.txt rename to src/sensor/sensor_fusion/design/data/100ms/linear_acceleration/move_x_y_z/gyro.txt diff --git a/src/server/plugins/sensor_fusion/design/data/100ms/linear_acceleration/move_x_y_z/magnetic.txt b/src/sensor/sensor_fusion/design/data/100ms/linear_acceleration/move_x_y_z/magnetic.txt similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/100ms/linear_acceleration/move_x_y_z/magnetic.txt rename to src/sensor/sensor_fusion/design/data/100ms/linear_acceleration/move_x_y_z/magnetic.txt diff --git a/src/server/plugins/sensor_fusion/design/data/100ms/orientation/roll_pitch_yaw/accel.txt b/src/sensor/sensor_fusion/design/data/100ms/orientation/roll_pitch_yaw/accel.txt similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/100ms/orientation/roll_pitch_yaw/accel.txt rename to src/sensor/sensor_fusion/design/data/100ms/orientation/roll_pitch_yaw/accel.txt diff --git a/src/server/plugins/sensor_fusion/design/data/100ms/orientation/roll_pitch_yaw/gyro.txt b/src/sensor/sensor_fusion/design/data/100ms/orientation/roll_pitch_yaw/gyro.txt similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/100ms/orientation/roll_pitch_yaw/gyro.txt rename to src/sensor/sensor_fusion/design/data/100ms/orientation/roll_pitch_yaw/gyro.txt diff --git a/src/server/plugins/sensor_fusion/design/data/100ms/orientation/roll_pitch_yaw/magnetic.txt b/src/sensor/sensor_fusion/design/data/100ms/orientation/roll_pitch_yaw/magnetic.txt similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/100ms/orientation/roll_pitch_yaw/magnetic.txt rename to src/sensor/sensor_fusion/design/data/100ms/orientation/roll_pitch_yaw/magnetic.txt diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/In_hand/accel b/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/In_hand/accel similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/In_hand/accel rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/In_hand/accel diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/In_hand/gyro b/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/In_hand/gyro similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/In_hand/gyro rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/In_hand/gyro diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/In_hand/magnetic b/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/In_hand/magnetic similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/In_hand/magnetic rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/In_hand/magnetic diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Pant_pocket/accel b/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Pant_pocket/accel similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Pant_pocket/accel rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Pant_pocket/accel diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Pant_pocket/gyro b/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Pant_pocket/gyro similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Pant_pocket/gyro rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Pant_pocket/gyro diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Pant_pocket/magnetic b/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Pant_pocket/magnetic similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Pant_pocket/magnetic rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Pant_pocket/magnetic diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Shirt_pocket/accel b/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Shirt_pocket/accel similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Shirt_pocket/accel rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Shirt_pocket/accel diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Shirt_pocket/gyro b/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Shirt_pocket/gyro similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Shirt_pocket/gyro rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Shirt_pocket/gyro diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Shirt_pocket/magnetic b/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Shirt_pocket/magnetic similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Shirt_pocket/magnetic rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/Shirt_pocket/magnetic diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/While_talking/accel b/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/While_talking/accel similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/While_talking/accel rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/While_talking/accel diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/While_talking/gyro b/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/While_talking/gyro similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/While_talking/gyro rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/While_talking/gyro diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/While_talking/magnetic b/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/While_talking/magnetic similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/While_talking/magnetic rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_down/While_talking/magnetic diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/In_hand/accel b/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/In_hand/accel similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/In_hand/accel rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/In_hand/accel diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/In_hand/gyro b/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/In_hand/gyro similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/In_hand/gyro rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/In_hand/gyro diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/In_hand/magnetic b/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/In_hand/magnetic similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/In_hand/magnetic rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/In_hand/magnetic diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Pant_pocket/accel b/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Pant_pocket/accel similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Pant_pocket/accel rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Pant_pocket/accel diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Pant_pocket/gyro b/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Pant_pocket/gyro similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Pant_pocket/gyro rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Pant_pocket/gyro diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Pant_pocket/magnetic b/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Pant_pocket/magnetic similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Pant_pocket/magnetic rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Pant_pocket/magnetic diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Shirt_pocket/accel b/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Shirt_pocket/accel similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Shirt_pocket/accel rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Shirt_pocket/accel diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Shirt_pocket/gyro b/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Shirt_pocket/gyro similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Shirt_pocket/gyro rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Shirt_pocket/gyro diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Shirt_pocket/magnetic b/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Shirt_pocket/magnetic similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Shirt_pocket/magnetic rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/Shirt_pocket/magnetic diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/While_talking/accel b/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/While_talking/accel similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/While_talking/accel rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/While_talking/accel diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/While_talking/gyro b/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/While_talking/gyro similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/While_talking/gyro rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/While_talking/gyro diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/While_talking/magnetic b/src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/While_talking/magnetic similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/While_talking/magnetic rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Climb_stairs_up/While_talking/magnetic diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_fast/In_hand/accel b/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/In_hand/accel similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_fast/In_hand/accel rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/In_hand/accel diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_fast/In_hand/gyro b/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/In_hand/gyro similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_fast/In_hand/gyro rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/In_hand/gyro diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_fast/In_hand/magnetic b/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/In_hand/magnetic similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_fast/In_hand/magnetic rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/In_hand/magnetic diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_fast/Pant_pocket/accel b/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/Pant_pocket/accel similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_fast/Pant_pocket/accel rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/Pant_pocket/accel diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_fast/Pant_pocket/gyro b/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/Pant_pocket/gyro similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_fast/Pant_pocket/gyro rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/Pant_pocket/gyro diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_fast/Pant_pocket/magnetic b/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/Pant_pocket/magnetic similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_fast/Pant_pocket/magnetic rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/Pant_pocket/magnetic diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_fast/Shirt_pocket/accel b/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/Shirt_pocket/accel similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_fast/Shirt_pocket/accel rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/Shirt_pocket/accel diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_fast/Shirt_pocket/gyro b/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/Shirt_pocket/gyro similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_fast/Shirt_pocket/gyro rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/Shirt_pocket/gyro diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_fast/Shirt_pocket/magnetic b/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/Shirt_pocket/magnetic similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_fast/Shirt_pocket/magnetic rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/Shirt_pocket/magnetic diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_fast/While_talking/accel b/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/While_talking/accel similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_fast/While_talking/accel rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/While_talking/accel diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_fast/While_talking/gyro b/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/While_talking/gyro similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_fast/While_talking/gyro rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/While_talking/gyro diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_fast/While_talking/magnetic b/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/While_talking/magnetic similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_fast/While_talking/magnetic rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_fast/While_talking/magnetic diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_slow/In_hand/accel b/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/In_hand/accel similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_slow/In_hand/accel rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/In_hand/accel diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_slow/In_hand/gyro b/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/In_hand/gyro similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_slow/In_hand/gyro rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/In_hand/gyro diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_slow/In_hand/magnetic b/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/In_hand/magnetic similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_slow/In_hand/magnetic rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/In_hand/magnetic diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_slow/Pant_pocket/accel b/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/Pant_pocket/accel similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_slow/Pant_pocket/accel rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/Pant_pocket/accel diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_slow/Pant_pocket/gyro b/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/Pant_pocket/gyro similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_slow/Pant_pocket/gyro rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/Pant_pocket/gyro diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_slow/Pant_pocket/magnetic b/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/Pant_pocket/magnetic similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_slow/Pant_pocket/magnetic rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/Pant_pocket/magnetic diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_slow/Shirt_pocket/accel b/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/Shirt_pocket/accel similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_slow/Shirt_pocket/accel rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/Shirt_pocket/accel diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_slow/Shirt_pocket/gyro b/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/Shirt_pocket/gyro similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_slow/Shirt_pocket/gyro rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/Shirt_pocket/gyro diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_slow/Shirt_pocket/magnetic b/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/Shirt_pocket/magnetic similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_slow/Shirt_pocket/magnetic rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/Shirt_pocket/magnetic diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_slow/While_talking/accel b/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/While_talking/accel similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_slow/While_talking/accel rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/While_talking/accel diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_slow/While_talking/gyro b/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/While_talking/gyro similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_slow/While_talking/gyro rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/While_talking/gyro diff --git a/src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_slow/While_talking/magnetic b/src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/While_talking/magnetic similarity index 100% rename from src/server/plugins/sensor_fusion/design/data/25ms/pedo/Walk_slow/While_talking/magnetic rename to src/sensor/sensor_fusion/design/data/25ms/pedo/Walk_slow/While_talking/magnetic diff --git a/src/server/plugins/sensor_fusion/design/documentation/diagram/block_diagram_gravity_and_linear_acceleration.png b/src/sensor/sensor_fusion/design/documentation/diagram/block_diagram_gravity_and_linear_acceleration.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/diagram/block_diagram_gravity_and_linear_acceleration.png rename to src/sensor/sensor_fusion/design/documentation/diagram/block_diagram_gravity_and_linear_acceleration.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/diagram/block_diagram_orientation_estimation.png b/src/sensor/sensor_fusion/design/documentation/diagram/block_diagram_orientation_estimation.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/diagram/block_diagram_orientation_estimation.png rename to src/sensor/sensor_fusion/design/documentation/diagram/block_diagram_orientation_estimation.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/diagram/device_orientation.png b/src/sensor/sensor_fusion/design/documentation/diagram/device_orientation.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/diagram/device_orientation.png rename to src/sensor/sensor_fusion/design/documentation/diagram/device_orientation.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/diagram/kalman_filter_stages.png b/src/sensor/sensor_fusion/design/documentation/diagram/kalman_filter_stages.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/diagram/kalman_filter_stages.png rename to src/sensor/sensor_fusion/design/documentation/diagram/kalman_filter_stages.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/diagram/orientation_effect_on_gravity.png b/src/sensor/sensor_fusion/design/documentation/diagram/orientation_effect_on_gravity.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/diagram/orientation_effect_on_gravity.png rename to src/sensor/sensor_fusion/design/documentation/diagram/orientation_effect_on_gravity.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/diagram/projection_diagram_gravity_computation.png b/src/sensor/sensor_fusion/design/documentation/diagram/projection_diagram_gravity_computation.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/diagram/projection_diagram_gravity_computation.png rename to src/sensor/sensor_fusion/design/documentation/diagram/projection_diagram_gravity_computation.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_1.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_1.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_1.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_1.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_10.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_10.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_10.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_10.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_11.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_11.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_11.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_11.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_12.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_12.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_12.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_12.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_13.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_13.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_13.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_13.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_13_updated.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_13_updated.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_13_updated.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_13_updated.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_14.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_14.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_14.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_14.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_15.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_15.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_15.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_15.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_16.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_16.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_16.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_16.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_17.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_17.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_17.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_17.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_18.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_18.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_18.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_18.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_19.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_19.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_19.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_19.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_2.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_2.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_2.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_2.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_20.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_20.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_20.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_20.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_21.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_21.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_21.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_21.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_22.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_22.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_22.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_22.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_23.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_23.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_23.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_23.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_24.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_24.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_24.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_24.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_25.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_25.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_25.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_25.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_26.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_26.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_26.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_26.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_27.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_27.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_27.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_27.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_28.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_28.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_28.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_28.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_29.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_29.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_29.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_29.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_3.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_3.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_3.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_3.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_30.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_30.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_30.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_30.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_31.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_31.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_31.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_31.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_32.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_32.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_32.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_32.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_33.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_33.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_33.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_33.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_34.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_34.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_34.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_34.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_35.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_35.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_35.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_35.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_36.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_36.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_36.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_36.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_37.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_37.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_37.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_37.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_38.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_38.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_38.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_38.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_39.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_39.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_39.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_39.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_4.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_4.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_4.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_4.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_40.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_40.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_40.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_40.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_5.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_5.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_5.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_5.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_6.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_6.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_6.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_6.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_7.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_7.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_7.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_7.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_8.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_8.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_8.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_8.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/equation/equation_9.png b/src/sensor/sensor_fusion/design/documentation/equation/equation_9.png similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/equation/equation_9.png rename to src/sensor/sensor_fusion/design/documentation/equation/equation_9.png diff --git a/src/server/plugins/sensor_fusion/design/documentation/sensor_fusion.htm b/src/sensor/sensor_fusion/design/documentation/sensor_fusion.htm similarity index 100% rename from src/server/plugins/sensor_fusion/design/documentation/sensor_fusion.htm rename to src/sensor/sensor_fusion/design/documentation/sensor_fusion.htm diff --git a/src/server/plugins/sensor_fusion/design/lib/axis_rot2quat.m b/src/sensor/sensor_fusion/design/lib/axis_rot2quat.m similarity index 100% rename from src/server/plugins/sensor_fusion/design/lib/axis_rot2quat.m rename to src/sensor/sensor_fusion/design/lib/axis_rot2quat.m diff --git a/src/server/plugins/sensor_fusion/design/lib/estimate_gaming_rv.m b/src/sensor/sensor_fusion/design/lib/estimate_gaming_rv.m similarity index 100% rename from src/server/plugins/sensor_fusion/design/lib/estimate_gaming_rv.m rename to src/sensor/sensor_fusion/design/lib/estimate_gaming_rv.m diff --git a/src/server/plugins/sensor_fusion/design/lib/estimate_geomagnetic_rv.m b/src/sensor/sensor_fusion/design/lib/estimate_geomagnetic_rv.m similarity index 100% rename from src/server/plugins/sensor_fusion/design/lib/estimate_geomagnetic_rv.m rename to src/sensor/sensor_fusion/design/lib/estimate_geomagnetic_rv.m diff --git a/src/server/plugins/sensor_fusion/design/lib/estimate_gravity.m b/src/sensor/sensor_fusion/design/lib/estimate_gravity.m similarity index 100% rename from src/server/plugins/sensor_fusion/design/lib/estimate_gravity.m rename to src/sensor/sensor_fusion/design/lib/estimate_gravity.m diff --git a/src/server/plugins/sensor_fusion/design/lib/estimate_linear_acceleration.m b/src/sensor/sensor_fusion/design/lib/estimate_linear_acceleration.m similarity index 100% rename from src/server/plugins/sensor_fusion/design/lib/estimate_linear_acceleration.m rename to src/sensor/sensor_fusion/design/lib/estimate_linear_acceleration.m diff --git a/src/server/plugins/sensor_fusion/design/lib/estimate_orientation.m b/src/sensor/sensor_fusion/design/lib/estimate_orientation.m similarity index 100% rename from src/server/plugins/sensor_fusion/design/lib/estimate_orientation.m rename to src/sensor/sensor_fusion/design/lib/estimate_orientation.m diff --git a/src/server/plugins/sensor_fusion/design/lib/euler2quat.m b/src/sensor/sensor_fusion/design/lib/euler2quat.m similarity index 100% rename from src/server/plugins/sensor_fusion/design/lib/euler2quat.m rename to src/sensor/sensor_fusion/design/lib/euler2quat.m diff --git a/src/server/plugins/sensor_fusion/design/lib/quat2euler.m b/src/sensor/sensor_fusion/design/lib/quat2euler.m similarity index 100% rename from src/server/plugins/sensor_fusion/design/lib/quat2euler.m rename to src/sensor/sensor_fusion/design/lib/quat2euler.m diff --git a/src/server/plugins/sensor_fusion/design/lib/quat2rot_mat.m b/src/sensor/sensor_fusion/design/lib/quat2rot_mat.m similarity index 100% rename from src/server/plugins/sensor_fusion/design/lib/quat2rot_mat.m rename to src/sensor/sensor_fusion/design/lib/quat2rot_mat.m diff --git a/src/server/plugins/sensor_fusion/design/lib/quat_prod.m b/src/sensor/sensor_fusion/design/lib/quat_prod.m similarity index 100% rename from src/server/plugins/sensor_fusion/design/lib/quat_prod.m rename to src/sensor/sensor_fusion/design/lib/quat_prod.m diff --git a/src/server/plugins/sensor_fusion/design/lib/rot_mat2quat.m b/src/sensor/sensor_fusion/design/lib/rot_mat2quat.m similarity index 100% rename from src/server/plugins/sensor_fusion/design/lib/rot_mat2quat.m rename to src/sensor/sensor_fusion/design/lib/rot_mat2quat.m diff --git a/src/server/plugins/sensor_fusion/design/lib/sf_pedometer.m b/src/sensor/sensor_fusion/design/lib/sf_pedometer.m similarity index 100% rename from src/server/plugins/sensor_fusion/design/lib/sf_pedometer.m rename to src/sensor/sensor_fusion/design/lib/sf_pedometer.m diff --git a/src/server/plugins/sensor_fusion/design/readme b/src/sensor/sensor_fusion/design/readme similarity index 100% rename from src/server/plugins/sensor_fusion/design/readme rename to src/sensor/sensor_fusion/design/readme diff --git a/src/server/plugins/sensor_fusion/design/sf_gaming_rv.m b/src/sensor/sensor_fusion/design/sf_gaming_rv.m similarity index 100% rename from src/server/plugins/sensor_fusion/design/sf_gaming_rv.m rename to src/sensor/sensor_fusion/design/sf_gaming_rv.m diff --git a/src/server/plugins/sensor_fusion/design/sf_geomagnetic_rv.m b/src/sensor/sensor_fusion/design/sf_geomagnetic_rv.m similarity index 100% rename from src/server/plugins/sensor_fusion/design/sf_geomagnetic_rv.m rename to src/sensor/sensor_fusion/design/sf_geomagnetic_rv.m diff --git a/src/server/plugins/sensor_fusion/design/sf_gravity.m b/src/sensor/sensor_fusion/design/sf_gravity.m similarity index 100% rename from src/server/plugins/sensor_fusion/design/sf_gravity.m rename to src/sensor/sensor_fusion/design/sf_gravity.m diff --git a/src/server/plugins/sensor_fusion/design/sf_linear_acceleration.m b/src/sensor/sensor_fusion/design/sf_linear_acceleration.m similarity index 100% rename from src/server/plugins/sensor_fusion/design/sf_linear_acceleration.m rename to src/sensor/sensor_fusion/design/sf_linear_acceleration.m diff --git a/src/server/plugins/sensor_fusion/design/sf_orientation.m b/src/sensor/sensor_fusion/design/sf_orientation.m similarity index 100% rename from src/server/plugins/sensor_fusion/design/sf_orientation.m rename to src/sensor/sensor_fusion/design/sf_orientation.m diff --git a/src/server/plugins/sensor_fusion/euler_angles.cpp b/src/sensor/sensor_fusion/euler_angles.cpp similarity index 100% rename from src/server/plugins/sensor_fusion/euler_angles.cpp rename to src/sensor/sensor_fusion/euler_angles.cpp diff --git a/src/server/plugins/sensor_fusion/euler_angles.h b/src/sensor/sensor_fusion/euler_angles.h similarity index 100% rename from src/server/plugins/sensor_fusion/euler_angles.h rename to src/sensor/sensor_fusion/euler_angles.h diff --git a/src/server/plugins/sensor_fusion/matrix.cpp b/src/sensor/sensor_fusion/matrix.cpp similarity index 100% rename from src/server/plugins/sensor_fusion/matrix.cpp rename to src/sensor/sensor_fusion/matrix.cpp diff --git a/src/server/plugins/sensor_fusion/matrix.h b/src/sensor/sensor_fusion/matrix.h similarity index 100% rename from src/server/plugins/sensor_fusion/matrix.h rename to src/sensor/sensor_fusion/matrix.h diff --git a/src/server/plugins/sensor_fusion/orientation_filter.cpp b/src/sensor/sensor_fusion/orientation_filter.cpp similarity index 100% rename from src/server/plugins/sensor_fusion/orientation_filter.cpp rename to src/sensor/sensor_fusion/orientation_filter.cpp diff --git a/src/server/plugins/sensor_fusion/orientation_filter.h b/src/sensor/sensor_fusion/orientation_filter.h similarity index 100% rename from src/server/plugins/sensor_fusion/orientation_filter.h rename to src/sensor/sensor_fusion/orientation_filter.h diff --git a/src/server/plugins/sensor_fusion/quaternion.cpp b/src/sensor/sensor_fusion/quaternion.cpp similarity index 100% rename from src/server/plugins/sensor_fusion/quaternion.cpp rename to src/sensor/sensor_fusion/quaternion.cpp diff --git a/src/server/plugins/sensor_fusion/quaternion.h b/src/sensor/sensor_fusion/quaternion.h similarity index 100% rename from src/server/plugins/sensor_fusion/quaternion.h rename to src/sensor/sensor_fusion/quaternion.h diff --git a/src/server/plugins/sensor_fusion/rotation_matrix.cpp b/src/sensor/sensor_fusion/rotation_matrix.cpp similarity index 100% rename from src/server/plugins/sensor_fusion/rotation_matrix.cpp rename to src/sensor/sensor_fusion/rotation_matrix.cpp diff --git a/src/server/plugins/sensor_fusion/rotation_matrix.h b/src/sensor/sensor_fusion/rotation_matrix.h similarity index 100% rename from src/server/plugins/sensor_fusion/rotation_matrix.h rename to src/sensor/sensor_fusion/rotation_matrix.h diff --git a/src/server/plugins/sensor_fusion/sensor_data.cpp b/src/sensor/sensor_fusion/sensor_data.cpp similarity index 100% rename from src/server/plugins/sensor_fusion/sensor_data.cpp rename to src/sensor/sensor_fusion/sensor_data.cpp diff --git a/src/server/plugins/sensor_fusion/sensor_data.h b/src/sensor/sensor_fusion/sensor_data.h similarity index 100% rename from src/server/plugins/sensor_fusion/sensor_data.h rename to src/sensor/sensor_fusion/sensor_data.h diff --git a/src/server/plugins/sensor_fusion/test/gravity_sensor.cpp b/src/sensor/sensor_fusion/test/gravity_sensor.cpp similarity index 100% rename from src/server/plugins/sensor_fusion/test/gravity_sensor.cpp rename to src/sensor/sensor_fusion/test/gravity_sensor.cpp diff --git a/src/server/plugins/sensor_fusion/test/gravity_sensor.h b/src/sensor/sensor_fusion/test/gravity_sensor.h similarity index 100% rename from src/server/plugins/sensor_fusion/test/gravity_sensor.h rename to src/sensor/sensor_fusion/test/gravity_sensor.h diff --git a/src/server/plugins/sensor_fusion/test/linear_acceleration_sensor.cpp b/src/sensor/sensor_fusion/test/linear_acceleration_sensor.cpp similarity index 100% rename from src/server/plugins/sensor_fusion/test/linear_acceleration_sensor.cpp rename to src/sensor/sensor_fusion/test/linear_acceleration_sensor.cpp diff --git a/src/server/plugins/sensor_fusion/test/linear_acceleration_sensor.h b/src/sensor/sensor_fusion/test/linear_acceleration_sensor.h similarity index 100% rename from src/server/plugins/sensor_fusion/test/linear_acceleration_sensor.h rename to src/sensor/sensor_fusion/test/linear_acceleration_sensor.h diff --git a/src/server/plugins/sensor_fusion/test/orientation_sensor.cpp b/src/sensor/sensor_fusion/test/orientation_sensor.cpp similarity index 100% rename from src/server/plugins/sensor_fusion/test/orientation_sensor.cpp rename to src/sensor/sensor_fusion/test/orientation_sensor.cpp diff --git a/src/server/plugins/sensor_fusion/test/orientation_sensor.h b/src/sensor/sensor_fusion/test/orientation_sensor.h similarity index 100% rename from src/server/plugins/sensor_fusion/test/orientation_sensor.h rename to src/sensor/sensor_fusion/test/orientation_sensor.h diff --git a/src/server/plugins/sensor_fusion/test/test_projects/euler_angles_test/euler_angles_main.cpp b/src/sensor/sensor_fusion/test/test_projects/euler_angles_test/euler_angles_main.cpp similarity index 100% rename from src/server/plugins/sensor_fusion/test/test_projects/euler_angles_test/euler_angles_main.cpp rename to src/sensor/sensor_fusion/test/test_projects/euler_angles_test/euler_angles_main.cpp diff --git a/src/server/plugins/sensor_fusion/test/test_projects/gravity_sensor_test/gravity_sensor_main.cpp b/src/sensor/sensor_fusion/test/test_projects/gravity_sensor_test/gravity_sensor_main.cpp similarity index 100% rename from src/server/plugins/sensor_fusion/test/test_projects/gravity_sensor_test/gravity_sensor_main.cpp rename to src/sensor/sensor_fusion/test/test_projects/gravity_sensor_test/gravity_sensor_main.cpp diff --git a/src/server/plugins/sensor_fusion/test/test_projects/linear_acceleration_sensor_test/linear_acceleration_sensor_main.cpp b/src/sensor/sensor_fusion/test/test_projects/linear_acceleration_sensor_test/linear_acceleration_sensor_main.cpp similarity index 100% rename from src/server/plugins/sensor_fusion/test/test_projects/linear_acceleration_sensor_test/linear_acceleration_sensor_main.cpp rename to src/sensor/sensor_fusion/test/test_projects/linear_acceleration_sensor_test/linear_acceleration_sensor_main.cpp diff --git a/src/server/plugins/sensor_fusion/test/test_projects/matrix_test/matrix_main.cpp b/src/sensor/sensor_fusion/test/test_projects/matrix_test/matrix_main.cpp similarity index 100% rename from src/server/plugins/sensor_fusion/test/test_projects/matrix_test/matrix_main.cpp rename to src/sensor/sensor_fusion/test/test_projects/matrix_test/matrix_main.cpp diff --git a/src/server/plugins/sensor_fusion/test/test_projects/orientation_sensor_test/orientation_sensor_main.cpp b/src/sensor/sensor_fusion/test/test_projects/orientation_sensor_test/orientation_sensor_main.cpp similarity index 100% rename from src/server/plugins/sensor_fusion/test/test_projects/orientation_sensor_test/orientation_sensor_main.cpp rename to src/sensor/sensor_fusion/test/test_projects/orientation_sensor_test/orientation_sensor_main.cpp diff --git a/src/server/plugins/sensor_fusion/test/test_projects/quaternion_test/quaternion_main.cpp b/src/sensor/sensor_fusion/test/test_projects/quaternion_test/quaternion_main.cpp similarity index 100% rename from src/server/plugins/sensor_fusion/test/test_projects/quaternion_test/quaternion_main.cpp rename to src/sensor/sensor_fusion/test/test_projects/quaternion_test/quaternion_main.cpp diff --git a/src/server/plugins/sensor_fusion/test/test_projects/rotation_matrix_test/rotation_matrix_main.cpp b/src/sensor/sensor_fusion/test/test_projects/rotation_matrix_test/rotation_matrix_main.cpp similarity index 100% rename from src/server/plugins/sensor_fusion/test/test_projects/rotation_matrix_test/rotation_matrix_main.cpp rename to src/sensor/sensor_fusion/test/test_projects/rotation_matrix_test/rotation_matrix_main.cpp diff --git a/src/server/plugins/sensor_fusion/test/test_projects/sensor_data_test/sensor_data_main.cpp b/src/sensor/sensor_fusion/test/test_projects/sensor_data_test/sensor_data_main.cpp similarity index 100% rename from src/server/plugins/sensor_fusion/test/test_projects/sensor_data_test/sensor_data_main.cpp rename to src/sensor/sensor_fusion/test/test_projects/sensor_data_test/sensor_data_main.cpp diff --git a/src/server/plugins/sensor_fusion/test/test_projects/vector_test/vector_main.cpp b/src/sensor/sensor_fusion/test/test_projects/vector_test/vector_main.cpp similarity index 100% rename from src/server/plugins/sensor_fusion/test/test_projects/vector_test/vector_main.cpp rename to src/sensor/sensor_fusion/test/test_projects/vector_test/vector_main.cpp diff --git a/src/server/plugins/sensor_fusion/vector.cpp b/src/sensor/sensor_fusion/vector.cpp similarity index 100% rename from src/server/plugins/sensor_fusion/vector.cpp rename to src/sensor/sensor_fusion/vector.cpp diff --git a/src/server/plugins/sensor_fusion/vector.h b/src/sensor/sensor_fusion/vector.h similarity index 100% rename from src/server/plugins/sensor_fusion/vector.h rename to src/sensor/sensor_fusion/vector.h diff --git a/src/server/plugins/tilt/tilt_sensor.cpp b/src/sensor/tilt/tilt_sensor.cpp similarity index 100% rename from src/server/plugins/tilt/tilt_sensor.cpp rename to src/sensor/tilt/tilt_sensor.cpp diff --git a/src/server/plugins/tilt/tilt_sensor.h b/src/sensor/tilt/tilt_sensor.h similarity index 100% rename from src/server/plugins/tilt/tilt_sensor.h rename to src/sensor/tilt/tilt_sensor.h diff --git a/src/server/plugins/virtual_sensors.xml b/src/sensor/virtual_sensors.xml similarity index 100% rename from src/server/plugins/virtual_sensors.xml rename to src/sensor/virtual_sensors.xml diff --git a/src/server/CMakeLists.txt b/src/server/CMakeLists.txt index 7c33264..50ac418 100644 --- a/src/server/CMakeLists.txt +++ b/src/server/CMakeLists.txt @@ -6,20 +6,25 @@ SET(DEPENDENTS "glib-2.0 gio-2.0 dlog libsystemd-daemon libxml-2.0 cynara-client INCLUDE(FindPkgConfig) PKG_CHECK_MODULES(SERVER_PKGS REQUIRED ${DEPENDENTS}) -ADD_SUBDIRECTORY(plugins) -ADD_DEFINITIONS(${PLUGIN_DEFS}) +ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../sensor ${CMAKE_CURRENT_BINARY_DIR}/sensor) +ADD_DEFINITIONS(${SENSOR_DEFINITIONS}) FOREACH(flag ${SERVER_PKGS_CFLAGS}) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") ENDFOREACH(flag) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ldl -fPIE") SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie") -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) -INCLUDE_DIRECTORIES(${DIR_INCLUDE}) +INCLUDE_DIRECTORIES( + ${CMAKE_SOURCE_DIR}/src/shared + ${CMAKE_SOURCE_DIR}/src/hal + ${CMAKE_CURRENT_SOURCE_DIR} + ${SENSOR_HEADERS} +) FILE(GLOB SERVER_SRCS *.cpp) -ADD_EXECUTABLE(${PROJECT_NAME} ${SERVER_SRCS} ${PLUGIN_SRCS}) +ADD_EXECUTABLE(${PROJECT_NAME} ${SENSOR_SRCS} ${SERVER_SRCS}) TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${SERVER_PKGS_LDFLAGS} "sensord-shared") diff --git a/src/server/plugins/CMakeLists.txt b/src/server/plugins/CMakeLists.txt deleted file mode 100644 index 432e427..0000000 --- a/src/server/plugins/CMakeLists.txt +++ /dev/null @@ -1,126 +0,0 @@ -cmake_minimum_required(VERSION 2.6) -project(sensord-plugins CXX) - -INCLUDE(FindPkgConfig) -PKG_CHECK_MODULES(plugin_pkgs REQUIRED dlog libxml-2.0) - -FOREACH(flag ${plugin_pkgs_LDFLAGS}) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") -ENDFOREACH(flag) - -FOREACH(flag ${plugin_pkgs_CFLAGS}) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") -ENDFOREACH(flag) - -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") - -include_directories(${CMAKE_CURRENT_SOURCE_DIR}) - -SET(DIR_INCLUDE "${DIR_INCLUDE} ${CMAKE_CURRENT_SOURCE_DIR}/accel") -list (APPEND PLUGIN_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/accel/accel_sensor.cpp") - -IF("${AUTO_ROTATION}" STREQUAL "ON") -list (APPEND DIR_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/auto_rotation") -list (APPEND PLUGIN_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/auto_rotation/auto_rotation_alg.cpp") -list (APPEND PLUGIN_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/auto_rotation/auto_rotation_alg_emul.cpp") -list (APPEND PLUGIN_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/auto_rotation/auto_rotation_sensor.cpp") -list (APPEND PLUGIN_DEFS "-DENABLE_AUTO_ROTATION") -ENDIF() - -IF("${ORIENTATION}" STREQUAL "ON") -set(SENSOR_FUSION_ENABLE "1") -set(ORIENTATION_ENABLE "1") -ENDIF() -IF("${RV}" STREQUAL "ON") -set(SENSOR_FUSION_ENABLE "1") -set(RV_ENABLE "1") -ENDIF() -IF("${GEOMAGNETIC_RV}" STREQUAL "ON") -set(SENSOR_FUSION_ENABLE "1") -set(GEOMAGNETIC_RV_ENABLE "1") -ENDIF() -IF("${GAMING_RV}" STREQUAL "ON") -set(SENSOR_FUSION_ENABLE "1") -set(GAMING_RV_ENABLE "1") -ENDIF() -IF("${TILT}" STREQUAL "ON") -set(SENSOR_FUSION_ENABLE "1") -set(TILT_ENABLE "1") -ENDIF() -IF("${GYROSCOPE_UNCAL}" STREQUAL "ON") -set(SENSOR_FUSION_ENABLE "1") -set(GYROSCOPE_UNCAL_ENABLE "1") -ENDIF() -IF("${GRAVITY}" STREQUAL "ON") -set(SENSOR_FUSION_ENABLE "1") -set(ORIENTATION_ENABLE "1") -set(GRAVITY_ENABLE "1") -ENDIF() -IF("${LINEAR_ACCEL}" STREQUAL "ON") -set(SENSOR_FUSION_ENABLE "1") -set(ORIENTATION_ENABLE "1") -set(GRAVITY_ENABLE "1") -set(LINEAR_ACCEL_ENABLE "1") -ENDIF() - -IF("${SENSOR_FUSION_ENABLE}" STREQUAL "1") -list (APPEND DIR_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/sensor_fusion") -list (APPEND PLUGIN_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/sensor_fusion/euler_angles.cpp") -list (APPEND PLUGIN_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/sensor_fusion/matrix.cpp") -list (APPEND PLUGIN_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/sensor_fusion/orientation_filter.cpp") -list (APPEND PLUGIN_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/sensor_fusion/quaternion.cpp") -list (APPEND PLUGIN_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/sensor_fusion/rotation_matrix.cpp") -list (APPEND PLUGIN_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/sensor_fusion/sensor_data.cpp") -list (APPEND PLUGIN_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/sensor_fusion/vector.cpp") -list (APPEND DIR_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/fusion") -list (APPEND PLUGIN_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/fusion/fusion_sensor.cpp") -list (APPEND PLUGIN_DEFS "-DENABLE_SENSOR_FUSION") -ENDIF() - -IF("${ORIENTATION_ENABLE}" STREQUAL "1") -list (APPEND DIR_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/orientation") -list (APPEND PLUGIN_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/orientation/orientation_sensor.cpp") -list (APPEND PLUGIN_DEFS "-DENABLE_ORIENTATION") -ENDIF() -IF("${GRAVITY_ENABLE}" STREQUAL "1") -list (APPEND DIR_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/gravity") -list (APPEND PLUGIN_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/gravity/gravity_sensor.cpp") -list (APPEND PLUGIN_DEFS "-DENABLE_GRAVITY") -ENDIF() -IF("${LINEAR_ACCEL_ENABLE}" STREQUAL "1") -list (APPEND DIR_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/linear_accel") -list (APPEND PLUGIN_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/linear_accel/linear_accel_sensor.cpp") -list (APPEND PLUGIN_DEFS "-DENABLE_LINEAR_ACCEL") -ENDIF() -IF("${TILT_ENABLE}" STREQUAL "1") -list (APPEND DIR_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/tilt") -list (APPEND PLUGIN_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/tilt/tilt_sensor.cpp") -list (APPEND PLUGIN_DEFS "-DENABLE_TILT") -ENDIF() -IF("${GYROSCOPE_UNCAL_ENABLE}" STREQUAL "1") -list (APPEND DIR_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/gyroscope_uncal") -list (APPEND PLUGIN_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/gyroscope_uncal/gyroscope_uncal_sensor.cpp") -list (APPEND PLUGIN_DEFS "-DENABLE_GYROSCOPE_UNCAL") -ENDIF() -IF("${RV_ENABLE}" STREQUAL "1") -list (APPEND DIR_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/rotation_vector/rv") -list (APPEND PLUGIN_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/rotation_vector/rv/rv_sensor.cpp") -list (APPEND PLUGIN_DEFS "-DENABLE_RV") -ENDIF() -IF("${GEOMAGNETIC_RV_ENABLE}" STREQUAL "1") -list (APPEND DIR_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/rotation_vector/geomagnetic_rv") -list (APPEND PLUGIN_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/rotation_vector/geomagnetic_rv/geomagnetic_rv_sensor.cpp") -list (APPEND PLUGIN_DEFS "-DENABLE_GEOMAGNETIC_RV") -ENDIF() -IF("${GAMING_RV_ENABLE}" STREQUAL "1") -list (APPEND DIR_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/rotation_vector/gaming_rv") -list (APPEND PLUGIN_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/rotation_vector/gaming_rv/gaming_rv_sensor.cpp") -list (APPEND PLUGIN_DEFS "-DENABLE_GAMING_RV") -ENDIF() - -set(PLUGIN_SRCS ${PLUGIN_SRCS} PARENT_SCOPE) -set(DIR_INCLUDE ${DIR_INCLUDE} PARENT_SCOPE) -set(PLUGIN_DEFS ${PLUGIN_DEFS} PARENT_SCOPE) - -# Installing files -INSTALL(FILES virtual_sensors.xml virtual_sensors.xml DESTINATION etc) diff --git a/src/server/plugins/sensor_fusion/test/test_projects/euler_angles_test/.cproject b/src/server/plugins/sensor_fusion/test/test_projects/euler_angles_test/.cproject deleted file mode 100644 index 7f29995..0000000 --- a/src/server/plugins/sensor_fusion/test/test_projects/euler_angles_test/.cproject +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/server/plugins/sensor_fusion/test/test_projects/euler_angles_test/.project b/src/server/plugins/sensor_fusion/test/test_projects/euler_angles_test/.project deleted file mode 100644 index eca2f5e..0000000 --- a/src/server/plugins/sensor_fusion/test/test_projects/euler_angles_test/.project +++ /dev/null @@ -1,89 +0,0 @@ - - - euler_angles_test - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.autoBuildTarget - all - - - org.eclipse.cdt.make.core.buildArguments - - - - org.eclipse.cdt.make.core.buildCommand - make - - - org.eclipse.cdt.make.core.buildLocation - ${workspace_loc:/euler_angles_test/Debug} - - - org.eclipse.cdt.make.core.cleanBuildTarget - clean - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.fullBuildTarget - all - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - true - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - org.tizen.nativecpp.apichecker.core.builder - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - org.tizen.nativecpp.apichecker.core.tizenCppNature - - diff --git a/src/server/plugins/sensor_fusion/test/test_projects/gravity_sensor_test/.cproject b/src/server/plugins/sensor_fusion/test/test_projects/gravity_sensor_test/.cproject deleted file mode 100644 index ee95ab0..0000000 --- a/src/server/plugins/sensor_fusion/test/test_projects/gravity_sensor_test/.cproject +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/server/plugins/sensor_fusion/test/test_projects/gravity_sensor_test/.project b/src/server/plugins/sensor_fusion/test/test_projects/gravity_sensor_test/.project deleted file mode 100644 index db26c33..0000000 --- a/src/server/plugins/sensor_fusion/test/test_projects/gravity_sensor_test/.project +++ /dev/null @@ -1,89 +0,0 @@ - - - gravity_sensor_test - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.autoBuildTarget - all - - - org.eclipse.cdt.make.core.buildArguments - - - - org.eclipse.cdt.make.core.buildCommand - make - - - org.eclipse.cdt.make.core.buildLocation - ${workspace_loc:/gravity_sensor_test/Debug} - - - org.eclipse.cdt.make.core.cleanBuildTarget - clean - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.fullBuildTarget - all - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - true - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - org.tizen.nativecpp.apichecker.core.builder - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - org.tizen.nativecpp.apichecker.core.tizenCppNature - - diff --git a/src/server/plugins/sensor_fusion/test/test_projects/linear_acceleration_sensor_test/.cproject b/src/server/plugins/sensor_fusion/test/test_projects/linear_acceleration_sensor_test/.cproject deleted file mode 100644 index 2cab1cd..0000000 --- a/src/server/plugins/sensor_fusion/test/test_projects/linear_acceleration_sensor_test/.cproject +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/server/plugins/sensor_fusion/test/test_projects/linear_acceleration_sensor_test/.project b/src/server/plugins/sensor_fusion/test/test_projects/linear_acceleration_sensor_test/.project deleted file mode 100644 index b5b1ce9..0000000 --- a/src/server/plugins/sensor_fusion/test/test_projects/linear_acceleration_sensor_test/.project +++ /dev/null @@ -1,89 +0,0 @@ - - - linear_acceleration_sensor_test - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.autoBuildTarget - all - - - org.eclipse.cdt.make.core.buildArguments - - - - org.eclipse.cdt.make.core.buildCommand - make - - - org.eclipse.cdt.make.core.buildLocation - ${workspace_loc:/linear_acceleration_sensor_test/Debug} - - - org.eclipse.cdt.make.core.cleanBuildTarget - clean - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.fullBuildTarget - all - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - true - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - org.tizen.nativecpp.apichecker.core.builder - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - org.tizen.nativecpp.apichecker.core.tizenCppNature - - diff --git a/src/server/plugins/sensor_fusion/test/test_projects/matrix_test/.cproject b/src/server/plugins/sensor_fusion/test/test_projects/matrix_test/.cproject deleted file mode 100644 index 1e6728f..0000000 --- a/src/server/plugins/sensor_fusion/test/test_projects/matrix_test/.cproject +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/server/plugins/sensor_fusion/test/test_projects/matrix_test/.project b/src/server/plugins/sensor_fusion/test/test_projects/matrix_test/.project deleted file mode 100644 index 3d8db3d..0000000 --- a/src/server/plugins/sensor_fusion/test/test_projects/matrix_test/.project +++ /dev/null @@ -1,89 +0,0 @@ - - - matrix_test - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.autoBuildTarget - all - - - org.eclipse.cdt.make.core.buildArguments - - - - org.eclipse.cdt.make.core.buildCommand - make - - - org.eclipse.cdt.make.core.buildLocation - ${workspace_loc:/matrix_test/Debug} - - - org.eclipse.cdt.make.core.cleanBuildTarget - clean - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.fullBuildTarget - all - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - true - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - org.tizen.nativecpp.apichecker.core.builder - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - org.tizen.nativecpp.apichecker.core.tizenCppNature - - diff --git a/src/server/plugins/sensor_fusion/test/test_projects/orientation_sensor_test/.cproject b/src/server/plugins/sensor_fusion/test/test_projects/orientation_sensor_test/.cproject deleted file mode 100644 index 65deaf8..0000000 --- a/src/server/plugins/sensor_fusion/test/test_projects/orientation_sensor_test/.cproject +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/server/plugins/sensor_fusion/test/test_projects/orientation_sensor_test/.project b/src/server/plugins/sensor_fusion/test/test_projects/orientation_sensor_test/.project deleted file mode 100644 index 7ceec3c..0000000 --- a/src/server/plugins/sensor_fusion/test/test_projects/orientation_sensor_test/.project +++ /dev/null @@ -1,89 +0,0 @@ - - - orientation_sensor_test - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.autoBuildTarget - all - - - org.eclipse.cdt.make.core.buildArguments - - - - org.eclipse.cdt.make.core.buildCommand - make - - - org.eclipse.cdt.make.core.buildLocation - ${workspace_loc:/orientation_sensor_test/Debug} - - - org.eclipse.cdt.make.core.cleanBuildTarget - clean - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.fullBuildTarget - all - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - true - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - org.tizen.nativecpp.apichecker.core.builder - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - org.tizen.nativecpp.apichecker.core.tizenCppNature - - diff --git a/src/server/plugins/sensor_fusion/test/test_projects/quaternion_test/.cproject b/src/server/plugins/sensor_fusion/test/test_projects/quaternion_test/.cproject deleted file mode 100644 index de46268..0000000 --- a/src/server/plugins/sensor_fusion/test/test_projects/quaternion_test/.cproject +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/server/plugins/sensor_fusion/test/test_projects/quaternion_test/.project b/src/server/plugins/sensor_fusion/test/test_projects/quaternion_test/.project deleted file mode 100644 index 74b100d..0000000 --- a/src/server/plugins/sensor_fusion/test/test_projects/quaternion_test/.project +++ /dev/null @@ -1,89 +0,0 @@ - - - quaternion_test - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.autoBuildTarget - all - - - org.eclipse.cdt.make.core.buildArguments - - - - org.eclipse.cdt.make.core.buildCommand - make - - - org.eclipse.cdt.make.core.buildLocation - ${workspace_loc:/quaternion_test/Debug} - - - org.eclipse.cdt.make.core.cleanBuildTarget - clean - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.fullBuildTarget - all - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - true - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - org.tizen.nativecpp.apichecker.core.builder - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - org.tizen.nativecpp.apichecker.core.tizenCppNature - - diff --git a/src/server/plugins/sensor_fusion/test/test_projects/rotation_matrix_test/.cproject b/src/server/plugins/sensor_fusion/test/test_projects/rotation_matrix_test/.cproject deleted file mode 100644 index dd975a2..0000000 --- a/src/server/plugins/sensor_fusion/test/test_projects/rotation_matrix_test/.cproject +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/server/plugins/sensor_fusion/test/test_projects/rotation_matrix_test/.project b/src/server/plugins/sensor_fusion/test/test_projects/rotation_matrix_test/.project deleted file mode 100644 index 6e760b0..0000000 --- a/src/server/plugins/sensor_fusion/test/test_projects/rotation_matrix_test/.project +++ /dev/null @@ -1,89 +0,0 @@ - - - rotation_matrix_test - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.autoBuildTarget - all - - - org.eclipse.cdt.make.core.buildArguments - - - - org.eclipse.cdt.make.core.buildCommand - make - - - org.eclipse.cdt.make.core.buildLocation - ${workspace_loc:/rotation_matrix_test/Debug} - - - org.eclipse.cdt.make.core.cleanBuildTarget - clean - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.fullBuildTarget - all - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - true - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - org.tizen.nativecpp.apichecker.core.builder - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - org.tizen.nativecpp.apichecker.core.tizenCppNature - - diff --git a/src/server/plugins/sensor_fusion/test/test_projects/sensor_data_test/.cproject b/src/server/plugins/sensor_fusion/test/test_projects/sensor_data_test/.cproject deleted file mode 100644 index 031195b..0000000 --- a/src/server/plugins/sensor_fusion/test/test_projects/sensor_data_test/.cproject +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/server/plugins/sensor_fusion/test/test_projects/sensor_data_test/.project b/src/server/plugins/sensor_fusion/test/test_projects/sensor_data_test/.project deleted file mode 100644 index 2e0296a..0000000 --- a/src/server/plugins/sensor_fusion/test/test_projects/sensor_data_test/.project +++ /dev/null @@ -1,89 +0,0 @@ - - - sensor_data_test - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.autoBuildTarget - all - - - org.eclipse.cdt.make.core.buildArguments - - - - org.eclipse.cdt.make.core.buildCommand - make - - - org.eclipse.cdt.make.core.buildLocation - ${workspace_loc:/sensor_data_test/Debug} - - - org.eclipse.cdt.make.core.cleanBuildTarget - clean - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.fullBuildTarget - all - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - true - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - org.tizen.nativecpp.apichecker.core.builder - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - org.tizen.nativecpp.apichecker.core.tizenCppNature - - diff --git a/src/server/plugins/sensor_fusion/test/test_projects/vector_test/.cproject b/src/server/plugins/sensor_fusion/test/test_projects/vector_test/.cproject deleted file mode 100644 index bc0fbe4..0000000 --- a/src/server/plugins/sensor_fusion/test/test_projects/vector_test/.cproject +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/server/plugins/sensor_fusion/test/test_projects/vector_test/.project b/src/server/plugins/sensor_fusion/test/test_projects/vector_test/.project deleted file mode 100644 index 92bc08d..0000000 --- a/src/server/plugins/sensor_fusion/test/test_projects/vector_test/.project +++ /dev/null @@ -1,83 +0,0 @@ - - - vector_test - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.autoBuildTarget - all - - - org.eclipse.cdt.make.core.buildArguments - - - - org.eclipse.cdt.make.core.buildCommand - make - - - org.eclipse.cdt.make.core.buildLocation - ${workspace_loc:/vector_test/Debug} - - - org.eclipse.cdt.make.core.cleanBuildTarget - clean - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.fullBuildTarget - all - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - true - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - - diff --git a/src/server/plugins/sensor_module_create.cpp.in b/src/server/plugins/sensor_module_create.cpp.in deleted file mode 100644 index 576fdf6..0000000 --- a/src/server/plugins/sensor_module_create.cpp.in +++ /dev/null @@ -1,289 +0,0 @@ -#ifdef ENABLE_ACCEL -#include -#endif -#ifdef ENABLE_GYRO -#include -#endif -#ifdef ENABLE_PROXI -#include -#endif -#ifdef ENABLE_LIGHT -#include -#endif -#ifdef ENABLE_GEO -#include -#endif -#ifdef ENABLE_AUTO_ROTATION -#include -#endif -#ifdef ENABLE_PRESSURE -#include -#endif -#ifdef ENABLE_TEMPERATURE -#include -#endif -#ifdef ENABLE_ULTRAVIOLET -#include -#endif -#ifdef ENABLE_BIO_LED_RED -#include -#endif -#ifdef ENABLE_SENSOR_FUSION -#include -#endif -#ifdef ENABLE_ORIENTATION -#include -#endif -#ifdef ENABLE_GEOMAGNETIC_RV -#include -#endif -#ifdef ENABLE_GAMING_RV -#include -#endif -#ifdef ENABLE_TILT -#include -#endif -#ifdef ENABLE_UNCAL_GYRO -#include -#endif -#ifdef ENABLE_GRAVITY -#include -#endif -#ifdef ENABLE_LINEAR_ACCEL -#include -#endif -#ifdef ENABLE_RV -#include -#endif -#ifdef ENABLE_RV_RAW -#include -#endif - -extern "C" sensor_module* create(void) -{ - sensor_module *module = new(std::nothrow) sensor_module; - retvm_if(!module, NULL, "Failed to allocate memory"); - -#ifdef ENABLE_ACCEL - accel_sensor *accel_sensor_ptr = NULL; - try { - accel_sensor_ptr = new(std::nothrow) accel_sensor; - } catch (int err) { - ERR("Failed to create accel_sensor module, err: %d, cause: %s", err, strerror(err)); - } - if (accel_sensor_ptr != NULL) { - module->sensors.push_back(accel_sensor_ptr); - } -#endif - -#ifdef ENABLE_AUTO_ROTATION - auto_rotation_sensor *auto_rotation_sensor_ptr = NULL; - try { - auto_rotation_sensor_ptr = new(std::nothrow) auto_rotation_sensor; - } catch (int err) { - ERR("Failed to create auto_rotation_sensor module, err: %d, cause: %s", err, strerror(err)); - } - if (auto_rotation_sensor_ptr != NULL) - module->sensors.push_back(auto_rotation_sensor_ptr); -#endif - -#ifdef ENABLE_GYRO - gyro_sensor *gyro_sensor_ptr = NULL; - try { - gyro_sensor_ptr = new(std::nothrow) gyro_sensor; - } catch (int err) { - ERR("Failed to create gyro_sensor module, err: %d, cause: %s", err, strerror(err)); - } - if (gyro_sensor_ptr != NULL) - module->sensors.push_back(gyro_sensor_ptr); -#endif - -#ifdef ENABLE_PROXI - proxi_sensor *proxi_sensor_ptr = NULL; - try { - proxi_sensor_ptr = new(std::nothrow) proxi_sensor; - } catch (int err) { - ERR("Failed to create proxi_sensor module, err: %d, cause: %s", err, strerror(err)); - } - if (proxi_sensor_ptr != NULL) - module->sensors.push_back(proxi_sensor_ptr); -#endif - -#ifdef ENABLE_LIGHT - light_sensor *light_sensor_ptr = NULL; - try { - light_sensor_ptr = new(std::nothrow) light_sensor; - } catch (int err) { - ERR("Failed to create light_sensor module, err: %d, cause: %s", err, strerror(err)); - } - if (light_sensor_ptr != NULL) - module->sensors.push_back(light_sensor_ptr); -#endif - -#ifdef ENABLE_GEO - geo_sensor *geo_sensor_ptr = NULL; - try { - geo_sensor_ptr = new(std::nothrow) geo_sensor; - } catch (int err) { - ERR("Failed to create geo_sensor module, err: %d, cause: %s", err, strerror(err)); - } - if (geo_sensor_ptr != NULL) - module->sensors.push_back(geo_sensor_ptr); -#endif - -#ifdef ENABLE_PRESSURE - pressure_sensor *pressure_sensor_ptr = NULL; - try { - pressure_sensor_ptr = new(std::nothrow) pressure_sensor; - } catch (int err) { - ERR("Failed to create pressure_sensor module, err: %d, cause: %s", err, strerror(err)); - } - if (pressure_sensor_ptr != NULL) - module->sensors.push_back(pressure_sensor_ptr); -#endif - -#ifdef ENABLE_TEMPERATURE - temperature_sensor *temperature_sensor_ptr = NULL; - try { - temperature_sensor_ptr = new(std::nothrow) temperature_sensor; - } catch (int err) { - ERR("Failed to create temperature_sensor module, err: %d, cause: %s", err, strerror(err)); - } - if (temperature_sensor_ptr != NULL) - module->sensors.push_back(temperature_sensor_ptr); -#endif - -#ifdef ENABLE_ULTRAVIOLET - ultraviolet_sensor *ultraviolet_sensor_ptr = NULL; - try { - ultraviolet_sensor_ptr = new(std::nothrow) ultraviolet_sensor; - } catch (int err) { - ERR("Failed to create ultraviolet_sensor module, err: %d, cause: %s", err, strerror(err)); - } - if (ultraviolet_sensor_ptr != NULL) - module->sensors.push_back(ultraviolet_sensor_ptr); -#endif - -#ifdef ENABLE_SENSOR_FUSION - fusion_sensor *fusion_sensor_ptr = NULL; - try { - fusion_sensor_ptr = new(std::nothrow) fusion_sensor; - } catch (int err) { - ERR("Failed to create fusion_sensor module, err: %d, cause: %s", err, strerror(err)); - } - if (fusion_sensor_ptr != NULL) - module->sensors.push_back(fusion_sensor_ptr); -#endif - -#ifdef ENABLE_ORIENTATION - orientation_sensor *orientation_sensor_ptr = NULL; - try { - orientation_sensor_ptr = new(std::nothrow) orientation_sensor; - } catch (int err) { - ERR("Failed to create orientation_sensor module, err: %d, cause: %s", err, strerror(err)); - } - if (orientation_sensor_ptr != NULL) - module->sensors.push_back(orientation_sensor_ptr); -#endif - -#ifdef ENABLE_GRAVITY - gravity_sensor *gravity_sensor_ptr = NULL; - try { - gravity_sensor_ptr = new(std::nothrow) gravity_sensor; - } catch (int err) { - ERR("Failed to create gravity_sensor module, err: %d, cause: %s", err, strerror(err)); - } - if (gravity_sensor_ptr != NULL) - module->sensors.push_back(gravity_sensor_ptr); -#endif - -#ifdef ENABLE_LINEAR_ACCEL - linear_accel_sensor *linear_accel_sensor_ptr = NULL; - try { - linear_accel_sensor_ptr = new(std::nothrow) linear_accel_sensor; - } catch (int err) { - ERR("Failed to create linear_accel_sensor module, err: %d, cause: %s", err, strerror(err)); - } - if (linear_accel_sensor_ptr != NULL) - module->sensors.push_back(linear_accel_sensor_ptr); -#endif - -#ifdef ENABLE_GEOMAGNETIC_RV - geomagnetic_rv_sensor *geomagnetic_rv_sensor_ptr = NULL; - try { - geomagnetic_rv_sensor_ptr = new(std::nothrow) geomagnetic_rv_sensor; - } catch (int err) { - ERR("Failed to create geomagnetic_rv_sensor module, err: %d, cause: %s", err, strerror(err)); - } - if (geomagnetic_rv_sensor_ptr != NULL) - module->sensors.push_back(geomagnetic_rv_sensor_ptr); -#endif - -#ifdef ENABLE_GAMING_RV - gaming_rv_sensor *gaming_rv_sensor_ptr = NULL; - try { - gaming_rv_sensor_ptr = new(std::nothrow) gaming_rv_sensor; - } catch (int err) { - ERR("Failed to create gaming_rv_sensor module, err: %d, cause: %s", err, strerror(err)); - } - if (gaming_rv_sensor_ptr != NULL) - module->sensors.push_back(gaming_rv_sensor_ptr); -#endif - -#ifdef ENABLE_RV - rv_sensor *rv_sensor_ptr = NULL; - try { - rv_sensor_ptr = new(std::nothrow) rv_sensor; - } catch (int err) { - ERR("Failed to create rv_sensor module, err: %d, cause: %s", err, strerror(err)); - } - if (rv_sensor_ptr != NULL) - module->sensors.push_back(rv_sensor_ptr); -#endif - -#ifdef ENABLE_TILT - tilt_sensor *tilt_sensor_ptr = NULL; - try { - tilt_sensor_ptr = new(std::nothrow) tilt_sensor; - } catch (int err) { - ERR("Failed to create tilt_sensor module, err: %d, cause: %s", err, strerror(err)); - } - if (tilt_sensor_ptr != NULL) - module->sensors.push_back(tilt_sensor_ptr); -#endif - -#ifdef ENABLE_UNCAL_GYRO - uncal_gyro_sensor *uncal_gyro_sensor_ptr = NULL; - try { - uncal_gyro_sensor_ptr = new(std::nothrow) uncal_gyro_sensor; - } catch (int err) { - ERR("Failed to create uncal_gyro_sensor module, err: %d, cause: %s", err, strerror(err)); - } - if (uncal_gyro_sensor_ptr != NULL) - module->sensors.push_back(uncal_gyro_sensor_ptr); -#endif - -#ifdef ENABLE_BIO_LED_RED - bio_led_red_sensor *bio_led_red_sensor_ptr = NULL; - try { - bio_led_red_sensor_ptr = new(std::nothrow) bio_led_red_sensor; - } catch (int err) { - ERR("Failed to create bio_led_red_sensor module, err: %d, cause: %s", err, strerror(err)); - } - if (bio_led_red_sensor_ptr != NULL) - module->sensors.push_back(bio_led_red_sensor_ptr); -#endif - -#ifdef ENABLE_RV_RAW - rv_raw_sensor *rv_raw_sensor_ptr = NULL; - try { - rv_raw_sensor_ptr = new(std::nothrow) rv_raw_sensor; - } catch (int err) { - ERR("Failed to create rv_raw_sensor module, err: %d, cause: %s", err, strerror(err)); - } - if (rv_raw_sensor_ptr != NULL) - module->sensors.push_back(rv_raw_sensor_ptr); -#endif - - return module; -} diff --git a/src/shared/CMakeLists.txt b/src/shared/CMakeLists.txt index a1fb14d..8b8416e 100644 --- a/src/shared/CMakeLists.txt +++ b/src/shared/CMakeLists.txt @@ -11,8 +11,10 @@ FOREACH(flag ${SHARED_PKGS_CFLAGS}) ENDFOREACH(flag) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/client) +INCLUDE_DIRECTORIES( + ${CMAKE_SOURCE_DIR}/src/hal + ${CMAKE_CURRENT_SOURCE_DIR} +) FILE(GLOB_RECURSE SRCS *.cpp) ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS}) diff --git a/test/CMakeLists.txt b/src/test/CMakeLists.txt similarity index 100% rename from test/CMakeLists.txt rename to src/test/CMakeLists.txt diff --git a/test/src/api-test.c b/src/test/src/api-test.c similarity index 100% rename from test/src/api-test.c rename to src/test/src/api-test.c diff --git a/test/src/check-sensor.c b/src/test/src/check-sensor.c similarity index 100% rename from test/src/check-sensor.c rename to src/test/src/check-sensor.c diff --git a/test/src/check-sensor.h b/src/test/src/check-sensor.h similarity index 100% rename from test/src/check-sensor.h rename to src/test/src/check-sensor.h diff --git a/test/src/fusion-data-collection.c b/src/test/src/fusion-data-collection.c similarity index 100% rename from test/src/fusion-data-collection.c rename to src/test/src/fusion-data-collection.c diff --git a/test/src/multi-process-performance-test.c b/src/test/src/multi-process-performance-test.c similarity index 100% rename from test/src/multi-process-performance-test.c rename to src/test/src/multi-process-performance-test.c diff --git a/test/src/multi-thread-performance-test.c b/src/test/src/multi-thread-performance-test.c similarity index 100% rename from test/src/multi-thread-performance-test.c rename to src/test/src/multi-thread-performance-test.c diff --git a/test/src/sensor-test.c b/src/test/src/sensor-test.c similarity index 100% rename from test/src/sensor-test.c rename to src/test/src/sensor-test.c -- 2.7.4 From 0c16f3c7f6148217dd79db6bccc25d755a342285 Mon Sep 17 00:00:00 2001 From: "kibak.yoon" Date: Wed, 2 Mar 2016 22:49:00 +0900 Subject: [PATCH 04/16] sensord: clean up boiler plates Change-Id: I4740cd857c6b2b8c2f53bd0a14fa750c23c69de2 Signed-off-by: kibak.yoon --- src/client/client.cpp | 4 ++-- src/client/client_common.cpp | 4 ++-- src/client/client_common.h | 2 +- src/client/command_channel.cpp | 4 ++-- src/client/command_channel.h | 4 ++-- src/client/reg_event_info.h | 4 ++-- src/client/sensor_client_info.cpp | 4 ++-- src/client/sensor_client_info.h | 4 ++-- src/client/sensor_event_listener.cpp | 2 +- src/client/sensor_event_listener.h | 4 ++-- src/client/sensor_handle_info.cpp | 4 ++-- src/client/sensor_handle_info.h | 4 ++-- src/client/sensor_info_manager.cpp | 4 ++-- src/client/sensor_info_manager.h | 4 ++-- src/server/client_info_manager.cpp | 4 ++-- src/server/client_info_manager.h | 4 ++-- src/server/client_sensor_record.cpp | 4 ++-- src/server/client_sensor_record.h | 4 ++-- src/server/device_config.cpp | 2 +- src/server/device_config.h | 4 ++-- src/server/physical_sensor.cpp | 2 +- src/server/physical_sensor.h | 2 +- src/server/plugin_info_list.cpp | 4 ++-- src/server/plugin_info_list.h | 4 ++-- src/server/sensor_base.cpp | 2 +- src/server/sensor_base.h | 2 +- src/server/sensor_event_dispatcher.cpp | 4 ++-- src/server/sensor_event_dispatcher.h | 4 ++-- src/server/sensor_event_poller.cpp | 2 +- src/server/sensor_event_poller.h | 2 +- src/server/sensor_event_queue.cpp | 4 ++-- src/server/sensor_event_queue.h | 4 ++-- src/server/sensor_loader.cpp | 4 ++-- src/server/sensor_loader.h | 4 ++-- src/server/sensor_usage.cpp | 4 ++-- src/server/sensor_usage.h | 4 ++-- src/server/virtual_sensor.cpp | 2 +- src/server/virtual_sensor.h | 2 +- src/server/virtual_sensor_config.cpp | 2 +- src/server/virtual_sensor_config.h | 2 +- src/server/worker_thread.cpp | 2 +- src/server/worker_thread.h | 2 +- src/shared/cbase_lock.cpp | 4 ++-- src/shared/cbase_lock.h | 4 ++-- src/shared/cmutex.cpp | 6 +++--- src/shared/cmutex.h | 4 ++-- src/shared/command_common.h | 4 ++-- src/shared/cpacket.cpp | 4 ++-- src/shared/cpacket.h | 4 ++-- src/shared/csocket.cpp | 4 ++-- src/shared/csocket.h | 4 ++-- src/shared/poller.cpp | 4 ++-- src/shared/poller.h | 4 ++-- src/shared/sensor_common.h | 2 +- src/shared/sensor_deprecated.h | 4 ++-- src/shared/sensor_info.cpp | 4 ++-- src/shared/sensor_info.h | 4 ++-- src/shared/sensor_internal.h | 2 +- src/shared/sensor_internal_deprecated.h | 2 +- src/shared/sensor_log.cpp | 4 ++-- src/shared/sensor_log.h | 4 ++-- src/shared/sensor_types.h | 4 ++-- 62 files changed, 107 insertions(+), 107 deletions(-) diff --git a/src/client/client.cpp b/src/client/client.cpp index 81d00d0..6e1a416 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -1,7 +1,7 @@ /* - * libsensord + * sensord * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2013 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. diff --git a/src/client/client_common.cpp b/src/client/client_common.cpp index 344af09..19831a2 100644 --- a/src/client/client_common.cpp +++ b/src/client/client_common.cpp @@ -1,7 +1,7 @@ /* - * libsensord + * sensord * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2013 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. diff --git a/src/client/client_common.h b/src/client/client_common.h index 1d5938d..532cb8d 100644 --- a/src/client/client_common.h +++ b/src/client/client_common.h @@ -1,5 +1,5 @@ /* - * libsensord + * sensord * * Copyright (c) 2014 Samsung Electronics Co., Ltd. * diff --git a/src/client/command_channel.cpp b/src/client/command_channel.cpp index cdb8fe9..a034e0b 100644 --- a/src/client/command_channel.cpp +++ b/src/client/command_channel.cpp @@ -1,7 +1,7 @@ /* - * libsensord + * sensord * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2013 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. diff --git a/src/client/command_channel.h b/src/client/command_channel.h index f205106..63d5ceb 100644 --- a/src/client/command_channel.h +++ b/src/client/command_channel.h @@ -1,7 +1,7 @@ /* - * libsensord + * sensord * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2013 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. diff --git a/src/client/reg_event_info.h b/src/client/reg_event_info.h index 18e1335..cf2fd76 100644 --- a/src/client/reg_event_info.h +++ b/src/client/reg_event_info.h @@ -1,7 +1,7 @@ /* - * libsensord + * sensord * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2013 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. diff --git a/src/client/sensor_client_info.cpp b/src/client/sensor_client_info.cpp index 30dfab2..3ffc120 100644 --- a/src/client/sensor_client_info.cpp +++ b/src/client/sensor_client_info.cpp @@ -1,7 +1,7 @@ /* - * libsensord + * sensord * - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/client/sensor_client_info.h b/src/client/sensor_client_info.h index b408356..e3869d2 100644 --- a/src/client/sensor_client_info.h +++ b/src/client/sensor_client_info.h @@ -1,7 +1,7 @@ /* - * libsensord + * sensord * - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/client/sensor_event_listener.cpp b/src/client/sensor_event_listener.cpp index 4550da6..568d8cb 100644 --- a/src/client/sensor_event_listener.cpp +++ b/src/client/sensor_event_listener.cpp @@ -1,5 +1,5 @@ /* - * libsensord + * sensord * * Copyright (c) 2014 Samsung Electronics Co., Ltd. * diff --git a/src/client/sensor_event_listener.h b/src/client/sensor_event_listener.h index d9fc2f8..aaa29a6 100644 --- a/src/client/sensor_event_listener.h +++ b/src/client/sensor_event_listener.h @@ -1,7 +1,7 @@ /* - * libsensord + * sensord * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2013 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. diff --git a/src/client/sensor_handle_info.cpp b/src/client/sensor_handle_info.cpp index 1be96c0..6d9e429 100644 --- a/src/client/sensor_handle_info.cpp +++ b/src/client/sensor_handle_info.cpp @@ -1,7 +1,7 @@ /* - * libsensord + * sensord * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2013 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. diff --git a/src/client/sensor_handle_info.h b/src/client/sensor_handle_info.h index d9b2ec9..c72fb00 100644 --- a/src/client/sensor_handle_info.h +++ b/src/client/sensor_handle_info.h @@ -1,7 +1,7 @@ /* - * libsensord + * sensord * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2013 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. diff --git a/src/client/sensor_info_manager.cpp b/src/client/sensor_info_manager.cpp index 4a427f2..530eddd 100644 --- a/src/client/sensor_info_manager.cpp +++ b/src/client/sensor_info_manager.cpp @@ -1,7 +1,7 @@ /* - * libsensord + * sensord * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2013 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. diff --git a/src/client/sensor_info_manager.h b/src/client/sensor_info_manager.h index 084b5a3..e36acc9 100644 --- a/src/client/sensor_info_manager.h +++ b/src/client/sensor_info_manager.h @@ -1,7 +1,7 @@ /* - * libsensord + * sensord * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2013 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. diff --git a/src/server/client_info_manager.cpp b/src/server/client_info_manager.cpp index 6c84889..068778b 100644 --- a/src/server/client_info_manager.cpp +++ b/src/server/client_info_manager.cpp @@ -1,7 +1,7 @@ /* - * libsensord-share + * sensord * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2013 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. diff --git a/src/server/client_info_manager.h b/src/server/client_info_manager.h index bee9995..7a9dde6 100644 --- a/src/server/client_info_manager.h +++ b/src/server/client_info_manager.h @@ -1,7 +1,7 @@ /* - * libsensord-share + * sensord * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2013 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. diff --git a/src/server/client_sensor_record.cpp b/src/server/client_sensor_record.cpp index fbc4ed8..c7ee8e1 100644 --- a/src/server/client_sensor_record.cpp +++ b/src/server/client_sensor_record.cpp @@ -1,7 +1,7 @@ /* - * libsensord-share + * sensord * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2013 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. diff --git a/src/server/client_sensor_record.h b/src/server/client_sensor_record.h index cad13f4..ac3f3db 100644 --- a/src/server/client_sensor_record.h +++ b/src/server/client_sensor_record.h @@ -1,7 +1,7 @@ /* - * libsensord-share + * sensord * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2013 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. diff --git a/src/server/device_config.cpp b/src/server/device_config.cpp index 3497ca6..10239f1 100644 --- a/src/server/device_config.cpp +++ b/src/server/device_config.cpp @@ -1,5 +1,5 @@ /* - * libsensord-share + * sensord * * Copyright (c) 2014 Samsung Electronics Co., Ltd. * diff --git a/src/server/device_config.h b/src/server/device_config.h index a5f2339..3b85f2f 100644 --- a/src/server/device_config.h +++ b/src/server/device_config.h @@ -1,7 +1,7 @@ /* - * libsensord-share + * sensord * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/server/physical_sensor.cpp b/src/server/physical_sensor.cpp index 0096e8e..f631265 100644 --- a/src/server/physical_sensor.cpp +++ b/src/server/physical_sensor.cpp @@ -1,5 +1,5 @@ /* - * libsensord-share + * sensord * * Copyright (c) 2014 Samsung Electronics Co., Ltd. * diff --git a/src/server/physical_sensor.h b/src/server/physical_sensor.h index 33378f6..a35edc8 100644 --- a/src/server/physical_sensor.h +++ b/src/server/physical_sensor.h @@ -1,5 +1,5 @@ /* - * libsensord-share + * sensord * * Copyright (c) 2014 Samsung Electronics Co., Ltd. * diff --git a/src/server/plugin_info_list.cpp b/src/server/plugin_info_list.cpp index 0de1b21..db36f04 100644 --- a/src/server/plugin_info_list.cpp +++ b/src/server/plugin_info_list.cpp @@ -1,7 +1,7 @@ /* - * libsensord-share + * sensord * - * Copyright (c) 2013 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/server/plugin_info_list.h b/src/server/plugin_info_list.h index b8ee5ea..e8b034e 100644 --- a/src/server/plugin_info_list.h +++ b/src/server/plugin_info_list.h @@ -1,7 +1,7 @@ /* - * libsensord-share + * sensord * - * Copyright (c) 2013 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/server/sensor_base.cpp b/src/server/sensor_base.cpp index 654ac97..4aaacf6 100644 --- a/src/server/sensor_base.cpp +++ b/src/server/sensor_base.cpp @@ -1,5 +1,5 @@ /* - * libsensord-share + * sensord * * Copyright (c) 2014 Samsung Electronics Co., Ltd. * diff --git a/src/server/sensor_base.h b/src/server/sensor_base.h index 144de20..072c3f2 100644 --- a/src/server/sensor_base.h +++ b/src/server/sensor_base.h @@ -1,5 +1,5 @@ /* - * libsensord-share + * sensord * * Copyright (c) 2014 Samsung Electronics Co., Ltd. * diff --git a/src/server/sensor_event_dispatcher.cpp b/src/server/sensor_event_dispatcher.cpp index d2deaa2..564ab70 100644 --- a/src/server/sensor_event_dispatcher.cpp +++ b/src/server/sensor_event_dispatcher.cpp @@ -1,7 +1,7 @@ /* - * libsensord-share + * sensord * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2013 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. diff --git a/src/server/sensor_event_dispatcher.h b/src/server/sensor_event_dispatcher.h index bc23f5c..b597816 100644 --- a/src/server/sensor_event_dispatcher.h +++ b/src/server/sensor_event_dispatcher.h @@ -1,7 +1,7 @@ /* - * libsensord-share + * sensord * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2013 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. diff --git a/src/server/sensor_event_poller.cpp b/src/server/sensor_event_poller.cpp index 1d5e69b..97fd19a 100644 --- a/src/server/sensor_event_poller.cpp +++ b/src/server/sensor_event_poller.cpp @@ -1,5 +1,5 @@ /* - * libsensord-share + * sensord * * Copyright (c) 2016 Samsung Electronics Co., Ltd. * diff --git a/src/server/sensor_event_poller.h b/src/server/sensor_event_poller.h index 4267b1e..03e5a59 100644 --- a/src/server/sensor_event_poller.h +++ b/src/server/sensor_event_poller.h @@ -1,5 +1,5 @@ /* - * libsensord-share + * sensord * * Copyright (c) 2016 Samsung Electronics Co., Ltd. * diff --git a/src/server/sensor_event_queue.cpp b/src/server/sensor_event_queue.cpp index 27865ea..9378c8d 100644 --- a/src/server/sensor_event_queue.cpp +++ b/src/server/sensor_event_queue.cpp @@ -1,7 +1,7 @@ /* - * libsensord-share + * sensord * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2013 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. diff --git a/src/server/sensor_event_queue.h b/src/server/sensor_event_queue.h index ba9decb..df33035 100644 --- a/src/server/sensor_event_queue.h +++ b/src/server/sensor_event_queue.h @@ -1,7 +1,7 @@ /* - * libsensord-share + * sensord * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2013 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. diff --git a/src/server/sensor_loader.cpp b/src/server/sensor_loader.cpp index 95dfd6c..74448da 100644 --- a/src/server/sensor_loader.cpp +++ b/src/server/sensor_loader.cpp @@ -1,7 +1,7 @@ /* - * libsensord-share + * sensord * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2013 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. diff --git a/src/server/sensor_loader.h b/src/server/sensor_loader.h index 9585105..19997d7 100644 --- a/src/server/sensor_loader.h +++ b/src/server/sensor_loader.h @@ -1,7 +1,7 @@ /* - * libsensord-share + * sensord * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2013 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. diff --git a/src/server/sensor_usage.cpp b/src/server/sensor_usage.cpp index 08963ce..6041913 100644 --- a/src/server/sensor_usage.cpp +++ b/src/server/sensor_usage.cpp @@ -1,7 +1,7 @@ /* - * libsensord-share + * sensord * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2013 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. diff --git a/src/server/sensor_usage.h b/src/server/sensor_usage.h index 59165e4..f13018d 100644 --- a/src/server/sensor_usage.h +++ b/src/server/sensor_usage.h @@ -1,7 +1,7 @@ /* - * libsensord-share + * sensord * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2013 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. diff --git a/src/server/virtual_sensor.cpp b/src/server/virtual_sensor.cpp index 232d7f1..fd03a49 100644 --- a/src/server/virtual_sensor.cpp +++ b/src/server/virtual_sensor.cpp @@ -1,5 +1,5 @@ /* - * libsensord-share + * sensord * * Copyright (c) 2014 Samsung Electronics Co., Ltd. * diff --git a/src/server/virtual_sensor.h b/src/server/virtual_sensor.h index 5ea14e3..270285b 100644 --- a/src/server/virtual_sensor.h +++ b/src/server/virtual_sensor.h @@ -1,5 +1,5 @@ /* - * libsensord-share + * sensord * * Copyright (c) 2014 Samsung Electronics Co., Ltd. * diff --git a/src/server/virtual_sensor_config.cpp b/src/server/virtual_sensor_config.cpp index 4e30ba8..bc59fb7 100644 --- a/src/server/virtual_sensor_config.cpp +++ b/src/server/virtual_sensor_config.cpp @@ -1,5 +1,5 @@ /* - * libsensord-share + * sensord * * Copyright (c) 2014 Samsung Electronics Co., Ltd. * diff --git a/src/server/virtual_sensor_config.h b/src/server/virtual_sensor_config.h index d9ed919..37d9fd7 100644 --- a/src/server/virtual_sensor_config.h +++ b/src/server/virtual_sensor_config.h @@ -1,5 +1,5 @@ /* - * libsensord-share + * sensord * * Copyright (c) 2014 Samsung Electronics Co., Ltd. * diff --git a/src/server/worker_thread.cpp b/src/server/worker_thread.cpp index 152cc19..afd188c 100644 --- a/src/server/worker_thread.cpp +++ b/src/server/worker_thread.cpp @@ -1,5 +1,5 @@ /* - * libsensord-share + * sensord * * Copyright (c) 2014 Samsung Electronics Co., Ltd. * diff --git a/src/server/worker_thread.h b/src/server/worker_thread.h index b12fed5..2f5acab 100644 --- a/src/server/worker_thread.h +++ b/src/server/worker_thread.h @@ -1,5 +1,5 @@ /* - * libsensord-share + * sensord * * Copyright (c) 2014 Samsung Electronics Co., Ltd. * diff --git a/src/shared/cbase_lock.cpp b/src/shared/cbase_lock.cpp index 2aec244..f30ce18 100644 --- a/src/shared/cbase_lock.cpp +++ b/src/shared/cbase_lock.cpp @@ -1,7 +1,7 @@ /* - * libsensord-share + * sensord * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2013 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. diff --git a/src/shared/cbase_lock.h b/src/shared/cbase_lock.h index 5b82be2..5a6b5e5 100644 --- a/src/shared/cbase_lock.h +++ b/src/shared/cbase_lock.h @@ -1,7 +1,7 @@ /* - * libsensord-share + * sensord * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2013 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. diff --git a/src/shared/cmutex.cpp b/src/shared/cmutex.cpp index d8ef7fe..a033061 100644 --- a/src/shared/cmutex.cpp +++ b/src/shared/cmutex.cpp @@ -1,7 +1,7 @@ /* - * libsensord-share + * sensord * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2013 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. @@ -18,7 +18,7 @@ */ #include -#include "sensor_log.h" +#include cmutex::cmutex() { diff --git a/src/shared/cmutex.h b/src/shared/cmutex.h index 7537c7c..868500a 100644 --- a/src/shared/cmutex.h +++ b/src/shared/cmutex.h @@ -1,7 +1,7 @@ /* - * libsensord-share + * sensord * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2013 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. diff --git a/src/shared/command_common.h b/src/shared/command_common.h index 6fa17b4..141c24c 100644 --- a/src/shared/command_common.h +++ b/src/shared/command_common.h @@ -1,7 +1,7 @@ /* - * libsensord-share + * sensord * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/shared/cpacket.cpp b/src/shared/cpacket.cpp index a400b4e..fc908a4 100644 --- a/src/shared/cpacket.cpp +++ b/src/shared/cpacket.cpp @@ -1,7 +1,7 @@ /* - * libsensord-share + * sensord * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2013 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. diff --git a/src/shared/cpacket.h b/src/shared/cpacket.h index 6cc69ec..6cf6317 100644 --- a/src/shared/cpacket.h +++ b/src/shared/cpacket.h @@ -1,7 +1,7 @@ /* - * libsensord-share + * sensord * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2013 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. diff --git a/src/shared/csocket.cpp b/src/shared/csocket.cpp index b31cb0e..cf65aac 100644 --- a/src/shared/csocket.cpp +++ b/src/shared/csocket.cpp @@ -1,7 +1,7 @@ /* - * libsensord-share + * sensord * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2013 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. diff --git a/src/shared/csocket.h b/src/shared/csocket.h index 81abac4..b538fe1 100644 --- a/src/shared/csocket.h +++ b/src/shared/csocket.h @@ -1,7 +1,7 @@ /* - * libsensord-share + * sensord * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2013 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. diff --git a/src/shared/poller.cpp b/src/shared/poller.cpp index 50c1f18..b0180fe 100644 --- a/src/shared/poller.cpp +++ b/src/shared/poller.cpp @@ -1,7 +1,7 @@ /* - * libsensord + * sensord * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2013 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. diff --git a/src/shared/poller.h b/src/shared/poller.h index 5f7e112..b43d491 100644 --- a/src/shared/poller.h +++ b/src/shared/poller.h @@ -1,7 +1,7 @@ /* - * libsensord + * sensord * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2013 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. diff --git a/src/shared/sensor_common.h b/src/shared/sensor_common.h index abbb21c..de74ebb 100644 --- a/src/shared/sensor_common.h +++ b/src/shared/sensor_common.h @@ -1,5 +1,5 @@ /* - * libsensord-share + * sensord * * Copyright (c) 2014 Samsung Electronics Co., Ltd. * diff --git a/src/shared/sensor_deprecated.h b/src/shared/sensor_deprecated.h index bb80e6c..41b7945 100644 --- a/src/shared/sensor_deprecated.h +++ b/src/shared/sensor_deprecated.h @@ -1,7 +1,7 @@ /* - * libsensord + * sensord * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. diff --git a/src/shared/sensor_info.cpp b/src/shared/sensor_info.cpp index 030b99e..394ee92 100644 --- a/src/shared/sensor_info.cpp +++ b/src/shared/sensor_info.cpp @@ -1,7 +1,7 @@ /* - * libsensord + * sensord * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2013 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. diff --git a/src/shared/sensor_info.h b/src/shared/sensor_info.h index 536c6f9..6a7ab8b 100644 --- a/src/shared/sensor_info.h +++ b/src/shared/sensor_info.h @@ -1,7 +1,7 @@ /* - * libsensord + * sensord * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2013 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. diff --git a/src/shared/sensor_internal.h b/src/shared/sensor_internal.h index d5b495f..c1a102b 100644 --- a/src/shared/sensor_internal.h +++ b/src/shared/sensor_internal.h @@ -1,5 +1,5 @@ /* - * libsensord + * sensord * * Copyright (c) 2014 Samsung Electronics Co., Ltd. * diff --git a/src/shared/sensor_internal_deprecated.h b/src/shared/sensor_internal_deprecated.h index a2c05bd..5116303 100644 --- a/src/shared/sensor_internal_deprecated.h +++ b/src/shared/sensor_internal_deprecated.h @@ -1,5 +1,5 @@ /* - * libsensord + * sensord * * Copyright (c) 2014 Samsung Electronics Co., Ltd. * diff --git a/src/shared/sensor_log.cpp b/src/shared/sensor_log.cpp index 98ccf20..d28ae63 100644 --- a/src/shared/sensor_log.cpp +++ b/src/shared/sensor_log.cpp @@ -1,7 +1,7 @@ /* - * libsensord-share + * sensord * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2013 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. diff --git a/src/shared/sensor_log.h b/src/shared/sensor_log.h index c414264..9df8791 100644 --- a/src/shared/sensor_log.h +++ b/src/shared/sensor_log.h @@ -1,7 +1,7 @@ /* - * libsensord-share + * sensord * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2013 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. diff --git a/src/shared/sensor_types.h b/src/shared/sensor_types.h index f364b87..57b20eb 100644 --- a/src/shared/sensor_types.h +++ b/src/shared/sensor_types.h @@ -1,7 +1,7 @@ /* - * libsensord-share + * sensord * - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. -- 2.7.4 From 5ef1fad6591e4fd56014bdcb35ca2eab17b9dc26 Mon Sep 17 00:00:00 2001 From: "kibak.yoon" Date: Wed, 2 Mar 2016 23:35:51 +0900 Subject: [PATCH 05/16] sensord: clean up the source code - syntax / coding style - clean up including header files - remove compiler warning - remove useless lines/white space - correct typing-errors - sync with private source Change-Id: I4abce149946aa4cf3a81296a88cb6288a71c1ced Signed-off-by: kibak.yoon --- src/client/client.cpp | 37 +++-- src/client/client_common.cpp | 161 ++++++--------------- src/client/client_common.h | 33 +---- src/client/command_channel.cpp | 23 ++- src/client/command_channel.h | 7 +- src/client/reg_event_info.h | 15 +- src/client/sensor_client_info.cpp | 5 - src/client/sensor_event_listener.cpp | 7 +- src/client/sensor_event_listener.h | 6 +- src/client/sensor_handle_info.h | 2 +- src/{shared => client}/sensor_internal.h | 5 +- .../sensor_internal_deprecated.h | 4 - src/hal/sensor_hal.h | 48 +++--- src/sensor/auto_rotation/auto_rotation_sensor.cpp | 5 + src/sensor/auto_rotation/auto_rotation_sensor.h | 4 +- .../rotation_vector/gaming_rv/gaming_rv_sensor.cpp | 4 +- .../rotation_vector/gaming_rv/gaming_rv_sensor.h | 6 +- src/server/client_sensor_record.h | 3 +- src/server/command_worker.cpp | 3 +- src/server/command_worker.h | 5 +- src/server/device_config.h | 8 +- src/server/physical_sensor.cpp | 16 +- src/server/sensor_base.cpp | 83 +++++------ src/server/sensor_base.h | 24 +-- src/server/sensor_event_dispatcher.cpp | 7 +- src/server/sensor_event_dispatcher.h | 3 +- src/server/sensor_event_poller.cpp | 2 - src/server/sensor_event_queue.cpp | 2 +- src/server/sensor_event_queue.h | 6 +- .../{plugin_info_list.cpp => sensor_info_list.cpp} | 55 ++++--- .../{plugin_info_list.h => sensor_info_list.h} | 52 +++---- src/server/sensor_loader.cpp | 56 ++++--- src/server/sensor_loader.h | 10 +- src/server/sensor_usage.cpp | 3 +- src/server/server.cpp | 2 +- src/server/server.h | 9 +- src/server/virtual_sensor.cpp | 1 - src/server/virtual_sensor.h | 2 - src/shared/command_common.h | 7 +- src/shared/cpacket.h | 2 + src/shared/csocket.cpp | 1 + src/shared/csocket.h | 2 +- src/shared/poller.cpp | 4 +- src/shared/sensor_common.h | 14 +- src/shared/sensor_info.cpp | 9 +- src/shared/sensor_info.h | 2 +- src/shared/sensor_log.cpp | 4 +- src/shared/sensor_log.h | 10 +- src/shared/sensor_types.h | 43 +++--- src/test/src/check-sensor.c | 6 +- src/test/src/sensor-test.c | 2 +- 51 files changed, 374 insertions(+), 456 deletions(-) rename src/{shared => client}/sensor_internal.h (99%) rename src/{shared => client}/sensor_internal_deprecated.h (99%) rename src/server/{plugin_info_list.cpp => sensor_info_list.cpp} (66%) rename src/server/{plugin_info_list.h => sensor_info_list.h} (57%) diff --git a/src/client/client.cpp b/src/client/client.cpp index 6e1a416..96a3e95 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -17,9 +17,11 @@ * */ +#include #include #include #include +#include #include #include #include @@ -37,9 +39,6 @@ using std::vector; #define DEFAULT_INTERVAL POLL_10HZ_MS -static const int OP_SUCCESS = 0; -static const int OP_ERROR = -1; - static cmutex lock; static int g_power_save_state = 0; @@ -161,7 +160,7 @@ void restore_session(void) { AUTOLOCK(lock); - _I("Trying to restore session for %s", get_client_name()); + _I("Trying to restore sensor client session for %s", get_client_name()); command_channel *cmd_channel; int client_id; @@ -221,7 +220,7 @@ void restore_session(void) ++it_sensor; } - _I("Succeeded to restore session for %s", get_client_name()); + _I("Succeeded to restore sensor client session for %s", get_client_name()); return; @@ -486,11 +485,12 @@ API bool sensord_get_supported_event_types(sensor_t sensor, unsigned int **event sensor_info* info = sensor_to_sensor_info(sensor); retvm_if (!sensor_info_manager::get_instance().is_valid(info) || !event_types || !count, - false, "Invalid param: sensor (%p), event_types(%p), count(%)", sensor, event_types, count); + false, "Invalid param: sensor (%p), event_types(%p), count(%p)", sensor, event_types, count); unsigned int event_type; event_type = info->get_supported_event(); - *event_types = (unsigned int *) malloc(sizeof(unsigned int)); + *event_types = (unsigned int *)malloc(sizeof(unsigned int)); + retvm_if(!*event_types, false, "Failed to allocate memory"); (*event_types)[0] = event_type; @@ -504,7 +504,7 @@ API bool sensord_is_supported_event_type(sensor_t sensor, unsigned int event_typ sensor_info* info = sensor_to_sensor_info(sensor); retvm_if (!sensor_info_manager::get_instance().is_valid(info) || !event_type || !supported, - false, "Invalid param: sensor (%p), event_type(%p), supported(%)", sensor, event_type, supported); + false, "Invalid param: sensor (%p), event_type(%p), supported(%p)", sensor, event_type, supported); *supported = info->is_supported_event(event_type); @@ -548,7 +548,11 @@ API int sensord_connect(sensor_t sensor) if (!sensor_registered) { cmd_channel = new(std::nothrow) command_channel(); - retvm_if (!cmd_channel, OP_ERROR, "Failed to allocate memory"); + if (!cmd_channel) { + _E("Failed to allocated memory"); + sensor_client_info::get_instance().delete_handle(handle); + return OP_ERROR; + } if (!cmd_channel->create_channel()) { _E("%s failed to create command channel for %s", get_client_name(), get_sensor_name(sensor_id)); @@ -881,6 +885,9 @@ static bool change_event_batch(int handle, unsigned int event_type, unsigned int return false; } + if (interval == 0) + interval = DEFAULT_INTERVAL; + _I("%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); @@ -888,9 +895,6 @@ static bool change_event_batch(int handle, unsigned int event_type, unsigned int sensor_client_info::get_instance().get_event_info(handle, event_type, prev_interval, prev_latency, prev_cb_type, prev_cb, prev_user_data); - if (interval == 0) - interval = DEFAULT_INTERVAL; - if (!sensor_client_info::get_instance().set_event_batch(handle, event_type, interval, latency)) return false; @@ -1068,12 +1072,12 @@ API bool sensord_set_attribute_str(int handle, int attribute, const char *value, AUTOLOCK(lock); if (!sensor_client_info::get_instance().get_sensor_id(handle, sensor_id)) { - _E("client %s failed to get handle information", get_client_name()); + _E("Client %s failed to get handle information", get_client_name()); return false; } if (!sensor_client_info::get_instance().get_command_channel(sensor_id, &cmd_channel)) { - _E("client %s failed to get command channel for %s", + _E("Client %s failed to get command channel for %s", get_client_name(), get_sensor_name(sensor_id)); return false; } @@ -1101,6 +1105,11 @@ API bool sensord_send_sensorhub_data(int handle, const char *data, int data_len) return sensord_set_attribute_str(handle, 0, data, data_len); } +API bool sensord_send_command(int handle, const char *command, int command_len) +{ + return sensord_set_attribute_str(handle, 0, command, command_len); +} + API bool sensord_get_data(int handle, unsigned int data_id, sensor_data_t* sensor_data) { sensor_id_t sensor_id; diff --git a/src/client/client_common.cpp b/src/client/client_common.cpp index 19831a2..519880b 100644 --- a/src/client/client_common.cpp +++ b/src/client/client_common.cpp @@ -16,123 +16,69 @@ * limitations under the License. * */ +#include #include #include #include #include #include -#include -using std::unordered_map; - -#define FILL_LOG_ELEMENT(ID, TYPE, CNT, PRINT_PER_CNT) {ID, TYPE, {#TYPE, CNT, PRINT_PER_CNT} } - -log_element g_log_elements[] = { - FILL_LOG_ELEMENT(LOG_ID_SENSOR_TYPE, UNKNOWN_SENSOR, 0, 1), - FILL_LOG_ELEMENT(LOG_ID_SENSOR_TYPE, ACCELEROMETER_SENSOR, 0, 1), - FILL_LOG_ELEMENT(LOG_ID_SENSOR_TYPE, GEOMAGNETIC_SENSOR, 0, 1), - FILL_LOG_ELEMENT(LOG_ID_SENSOR_TYPE, LIGHT_SENSOR, 0, 1), - FILL_LOG_ELEMENT(LOG_ID_SENSOR_TYPE, PROXIMITY_SENSOR, 0, 1), - FILL_LOG_ELEMENT(LOG_ID_SENSOR_TYPE, GYROSCOPE_SENSOR, 0, 1), - FILL_LOG_ELEMENT(LOG_ID_SENSOR_TYPE, PRESSURE_SENSOR, 0, 1), - FILL_LOG_ELEMENT(LOG_ID_SENSOR_TYPE, CONTEXT_SENSOR, 0, 1), - FILL_LOG_ELEMENT(LOG_ID_SENSOR_TYPE, AUTO_ROTATION_SENSOR, 0, 1), - FILL_LOG_ELEMENT(LOG_ID_SENSOR_TYPE, GRAVITY_SENSOR, 0, 1), - FILL_LOG_ELEMENT(LOG_ID_SENSOR_TYPE, LINEAR_ACCEL_SENSOR, 0, 1), - FILL_LOG_ELEMENT(LOG_ID_SENSOR_TYPE, ORIENTATION_SENSOR, 0, 1), - FILL_LOG_ELEMENT(LOG_ID_SENSOR_TYPE, TEMPERATURE_SENSOR, 0, 1), - FILL_LOG_ELEMENT(LOG_ID_SENSOR_TYPE, ROTATION_VECTOR_SENSOR, 0, 1), - FILL_LOG_ELEMENT(LOG_ID_SENSOR_TYPE, GEOMAGNETIC_RV_SENSOR, 0, 1), - FILL_LOG_ELEMENT(LOG_ID_SENSOR_TYPE, GAMING_RV_SENSOR, 0, 1), - FILL_LOG_ELEMENT(LOG_ID_SENSOR_TYPE, FUSION_SENSOR, 0, 1), - FILL_LOG_ELEMENT(LOG_ID_SENSOR_TYPE, TILT_SENSOR, 0, 1), - FILL_LOG_ELEMENT(LOG_ID_SENSOR_TYPE, GYROSCOPE_UNCAL_SENSOR, 0, 1), - FILL_LOG_ELEMENT(LOG_ID_SENSOR_TYPE, ULTRAVIOLET_SENSOR, 0, 1), - FILL_LOG_ELEMENT(LOG_ID_SENSOR_TYPE, BIO_LED_RED_SENSOR, 0, 1), - FILL_LOG_ELEMENT(LOG_ID_SENSOR_TYPE, GESTURE_WRIST_UP_SENSOR, 0, 1), - - FILL_LOG_ELEMENT(LOG_ID_EVENT, PROXIMITY_CHANGE_STATE_EVENT, 0,1), - FILL_LOG_ELEMENT(LOG_ID_EVENT, LIGHT_CHANGE_LEVEL_EVENT, 0, 1), - FILL_LOG_ELEMENT(LOG_ID_EVENT, PROXIMITY_STATE_EVENT, 0, 10), - FILL_LOG_ELEMENT(LOG_ID_EVENT, PROXIMITY_DISTANCE_DATA_EVENT, 0, 10), - FILL_LOG_ELEMENT(LOG_ID_EVENT, AUTO_ROTATION_CHANGE_STATE_EVENT, 0, 1), - FILL_LOG_ELEMENT(LOG_ID_EVENT, ACCELEROMETER_RAW_DATA_EVENT, 0, 10), - FILL_LOG_ELEMENT(LOG_ID_EVENT, GYROSCOPE_RAW_DATA_EVENT, 0, 10), - FILL_LOG_ELEMENT(LOG_ID_EVENT, GEOMAGNETIC_RAW_DATA_EVENT, 0, 10), - FILL_LOG_ELEMENT(LOG_ID_EVENT, PRESSURE_RAW_DATA_EVENT, 0, 10), - FILL_LOG_ELEMENT(LOG_ID_EVENT, LIGHT_LEVEL_DATA_EVENT, 0, 10), - FILL_LOG_ELEMENT(LOG_ID_EVENT, LIGHT_LUX_DATA_EVENT, 0, 10), - FILL_LOG_ELEMENT(LOG_ID_EVENT, GRAVITY_RAW_DATA_EVENT, 0, 10), - FILL_LOG_ELEMENT(LOG_ID_EVENT, LINEAR_ACCEL_RAW_DATA_EVENT, 0, 10), - FILL_LOG_ELEMENT(LOG_ID_EVENT, ORIENTATION_RAW_DATA_EVENT, 0, 10), - FILL_LOG_ELEMENT(LOG_ID_EVENT, PRESSURE_RAW_DATA_EVENT, 0, 10), - FILL_LOG_ELEMENT(LOG_ID_EVENT, TEMPERATURE_RAW_DATA_EVENT, 0, 10), - FILL_LOG_ELEMENT(LOG_ID_EVENT, ROTATION_VECTOR_RAW_DATA_EVENT, 0, 10), - FILL_LOG_ELEMENT(LOG_ID_EVENT, GEOMAGNETIC_RV_RAW_DATA_EVENT, 0, 10), - FILL_LOG_ELEMENT(LOG_ID_EVENT, GAMING_RV_RAW_DATA_EVENT, 0, 10), - FILL_LOG_ELEMENT(LOG_ID_EVENT, FUSION_EVENT, 0, 10), - FILL_LOG_ELEMENT(LOG_ID_EVENT, TILT_RAW_DATA_EVENT, 0, 10), - FILL_LOG_ELEMENT(LOG_ID_EVENT, GYROSCOPE_UNCAL_RAW_DATA_EVENT, 0, 10), - FILL_LOG_ELEMENT(LOG_ID_EVENT, ULTRAVIOLET_RAW_DATA_EVENT, 0, 10), - FILL_LOG_ELEMENT(LOG_ID_EVENT, BIO_LED_RED_RAW_DATA_EVENT, 0, 10), +#include + +typedef std::map sensor_type_map; +static sensor_type_map g_log_maps = { + {UNKNOWN_SENSOR, {"UNKNOWN", "UNKNOWN_EVENT"}}, + {ACCELEROMETER_SENSOR, {"ACCELEROMETER", "ACCELEROMETER_RAW_DATA_EVENT"}}, + {GRAVITY_SENSOR, {"GRAVITY", "GRAVITY_RAW_DATA_EVENT"}}, + {LINEAR_ACCEL_SENSOR, {"LINEAR_ACCEL", "LINEAR_ACCEL_RAW_DATA_EVENT"}}, + {GEOMAGNETIC_SENSOR, {"GEOMAGNETIC SENSOR", "GEOMAGNETIC SENSOR_RAW_DATA_EVENT"}}, + {ROTATION_VECTOR_SENSOR, {"ROTATION VECTOR", "ROTATION VECTOR_RAW_DATA_EVENT"}}, + {ORIENTATION_SENSOR, {"ORIENTATION", "ORIENTATION_RAW_DATA_EVENT"}}, + {GYROSCOPE_SENSOR, {"GYROSCOPE", "GYROSCOPE_RAW_DATA_EVENT"}}, + {LIGHT_SENSOR, {"LIGHT", "LIGHT_RAW_DATA_EVENT"}}, + {PROXIMITY_SENSOR, {"PROXIMITY", "PROXIMITY_RAW_DATA_EVENT"}}, + {PRESSURE_SENSOR, {"PRESSURE", "PRESSURE_RAW_DATA_EVENT"}}, + {ULTRAVIOLET_SENSOR, {"ULTRAVIOLET", "ULTRAVIOLET_RAW_DATA_EVENT"}}, + {TEMPERATURE_SENSOR, {"TEMPERATURE", "TEMPERATURE_RAW_DATA_EVENT"}}, + {HUMIDITY_SENSOR, {"HUMIDITY", "HUMIDITY_RAW_DATA_EVENT"}}, + {BIO_HRM_SENSOR, {"BIO_HRM", "BIO_HRM_RAW_DATA_EVENT"}}, + {BIO_LED_GREEN_SENSOR, {"BIO_LED_GREEN", "BIO_LED_GREEN_RAW_DATA_EVENT"}}, + {BIO_LED_IR_SENSOR, {"BIO_LED_IR", "BIO_LED_IR_RAW_DATA_EVENT"}}, + {BIO_LED_RED_SENSOR, {"BIO_LED_RED", "BIO_LED_RED_RAW_DATA_EVENT"}}, + {GYROSCOPE_UNCAL_SENSOR, {"GYROSCOPE_UNCAL", "GYROSCOPE_UNCAL_RAW_DATA_EVENT"}}, + {GEOMAGNETIC_UNCAL_SENSOR, {"GEOMAGNETIC_UNCAL", "GEOMAGNETIC_UNCAL_RAW_DATA_EVENT"}}, + {GYROSCOPE_RV_SENSOR, {"GYROSCOPE_RV", "GYROSCOPE_RV_RAW_DATA_EVENT"}}, + {GEOMAGNETIC_RV_SENSOR, {"GEOMAGNETIC_RV", "GEOMAGNETIC_RV_RAW_DATA_EVENT"}}, + {CONTEXT_SENSOR, {"CONTEXT", "CONTEXT_RAW_DATA_EVENT"}}, }; -typedef unordered_map log_map; -static log_map g_log_maps[LOG_ID_END]; - -static void init_log_maps(void); - -class initiator { -public: - initiator() - { - init_log_maps(); - } -}; - -static initiator g_initiator; - -void init_log_maps(void) +const char* get_sensor_name(sensor_id_t sensor_id) { - int cnt; + const char* p_unknown = "UNKNOWN"; + sensor_type_t sensor_type = (sensor_type_t) (sensor_id >> SENSOR_TYPE_SHIFT); - cnt = sizeof(g_log_elements) / sizeof(g_log_elements[0]); + auto iter = g_log_maps.find(sensor_type); - for (int i = 0; i < cnt; ++i) { - g_log_maps[g_log_elements[i].id][g_log_elements[i].type] = &g_log_elements[i].log_attr; + if (iter == g_log_maps.end()) { + _I("Unknown type value: 0x%x", sensor_type); + return p_unknown; } + return iter->second.sensor_name; } -const char* get_log_element_name(log_id id, unsigned int type) +const char* get_event_name(unsigned int event_type) { const char* p_unknown = "UNKNOWN"; + sensor_type_t sensor_type = (sensor_type_t) (event_type >> EVENT_TYPE_SHIFT); - auto iter = g_log_maps[id].find(type); + auto iter = g_log_maps.find(sensor_type); - if (iter == g_log_maps[id].end()) { - _I("Unknown type value: 0x%x", type); + if (iter == g_log_maps.end()) { + _I("Unknown type value: 0x%x", sensor_type); return p_unknown; } - return iter->second->name; -} - -const char* get_sensor_name(sensor_id_t sensor_id) -{ - sensor_type_t sensor_type = (sensor_type_t) (sensor_id >> SENSOR_TYPE_SHIFT); - - return get_log_element_name(LOG_ID_SENSOR_TYPE, sensor_type); -} - -const char* get_event_name(unsigned int event_type) -{ - return get_log_element_name(LOG_ID_EVENT, event_type); -} - - -const char* get_data_name(unsigned int data_id) -{ - return get_log_element_name(LOG_ID_DATA, data_id); + return iter->second.event_name; } bool is_one_shot_event(unsigned int event_type) @@ -200,27 +146,8 @@ unsigned long long get_timestamp(void) void print_event_occurrence_log(sensor_handle_info &sensor_handle_info, const reg_event_info *event_info) { - log_attr *log_attr; - - auto iter = g_log_maps[LOG_ID_EVENT].find(event_info->type); - - if (iter == g_log_maps[LOG_ID_EVENT].end()) - return; - - log_attr = iter->second; - - log_attr->cnt++; - - if ((log_attr->cnt != 1) && ((log_attr->cnt % log_attr->print_per_cnt) != 0)) { - return; - } - - _I("%s receives %s with %s[%d][state: %d, option: %d count: %d]", get_client_name(), log_attr->name, - get_sensor_name(sensor_handle_info.m_sensor_id), sensor_handle_info.m_handle, sensor_handle_info.m_sensor_state, - sensor_handle_info.m_sensor_option, log_attr->cnt); - - _I("0x%x(cb_event_type = %s, &user_data, client_data = 0x%x)\n", event_info->m_cb, - log_attr->name, event_info->m_user_data); + _D("%s receives %s[%d]", get_client_name(), + get_sensor_name(sensor_handle_info.m_sensor_id), sensor_handle_info.m_handle); } /* diff --git a/src/client/client_common.h b/src/client/client_common.h index 532cb8d..85606db 100644 --- a/src/client/client_common.h +++ b/src/client/client_common.h @@ -30,38 +30,11 @@ #define CLIENT_NAME_SIZE NAME_MAX+10 -enum log_id { - LOG_ID_START = 0, - LOG_ID_SENSOR_TYPE = 0, - LOG_ID_EVENT, - LOG_ID_DATA, - LOG_ID_PROPERTY, - LOG_ID_END, -}; - struct log_attr { - const char *name; - unsigned long cnt; - const unsigned int print_per_cnt; -}; - -struct log_element { - log_id id; - int type; - struct log_attr log_attr; + char *sensor_name; + char *event_name; }; - -typedef struct { - int handle; - unsigned int event_type; - sensor_event_data_t ev_data; - int sensor_state; - int sensor_option; - sensor_type_t sensor; - reg_event_info event_info; -} log_info; - bool is_one_shot_event(unsigned int event_type); bool is_ontime_event(unsigned int event_type); bool is_panning_event(unsigned int event_type); @@ -69,10 +42,8 @@ bool is_single_state_event(unsigned int event_type); unsigned int get_calibration_event_type(unsigned int event_type); unsigned long long get_timestamp(void); -const char* get_log_element_name(log_id id, unsigned int type); const char* get_sensor_name(sensor_id_t sensor_id); const char* get_event_name(unsigned int event_type); -const char* get_data_name(unsigned int data_id); void print_event_occurrence_log(sensor_handle_info &sensor_handle_info, const reg_event_info *event_info); class sensor_info; diff --git a/src/client/command_channel.cpp b/src/client/command_channel.cpp index a034e0b..4e978a8 100644 --- a/src/client/command_channel.cpp +++ b/src/client/command_channel.cpp @@ -58,7 +58,7 @@ bool command_channel::command_handler(cpacket *packet, void **return_payload) if (m_command_socket.recv(&header, sizeof(header)) <= 0) { m_command_socket.close(); - _E("Failed to receive header for reply packet in client %s", get_client_name()); + _E("Failed to receive header for command reply packet in client %s", get_client_name()); return false; } @@ -67,7 +67,7 @@ bool command_channel::command_handler(cpacket *packet, void **return_payload) if (m_command_socket.recv(buffer, header.size) <= 0) { m_command_socket.close(); - _E("Failed to receive reply packet in client %s", get_client_name()); + _E("Failed to receive command reply packet in client %s", get_client_name()); delete[] buffer; return false; } @@ -611,15 +611,15 @@ bool command_channel::cmd_get_data(unsigned int type, sensor_data_t* sensor_data cmd_get_data->type = type; if (!command_handler(packet, (void **)&cmd_get_data_done)) { - _E("Client %s failed to send/receive command with client_id [%d], data_id[%s]", - get_client_name(), m_client_id, get_data_name(type)); + _E("Client %s failed to send/receive command with client_id [%d]", + get_client_name(), m_client_id); delete packet; return false; } if (cmd_get_data_done->state < 0 ) { - _E("Client %s got error[%d] from server with client_id [%d], data_id[%s]", - get_client_name(), cmd_get_data_done->state, m_client_id, get_data_name(type)); + _E("Client %s got error[%d] from server with client_id [%d]", + get_client_name(), cmd_get_data_done->state, m_client_id); sensor_data->accuracy = SENSOR_ACCURACY_UNDEFINED; sensor_data->timestamp = 0; sensor_data->value_count = 0; @@ -663,14 +663,14 @@ bool command_channel::cmd_set_attribute_int(int attribute, int value) get_client_name(), m_client_id, get_sensor_name(m_sensor_id), attribute, value); if (!command_handler(packet, (void **)&cmd_done)) { - _E("Client %s failed to send/receive command for sensor[%s] with client_id [%d], property[0x%x], value[%d]", + _E("Client %s failed to send/receive command for sensor[%s] with client_id [%d], attribute[0x%x], value[%d]", get_client_name(), get_sensor_name(m_sensor_id), m_client_id, attribute, value); delete packet; return false; } if (cmd_done->value < 0) { - _E("Client %s got error[%d] from server for sensor[%s] with property[0x%x], value[%d]", + _E("Client %s got error[%d] from server for sensor[%s] with attribute[0x%x], value[%d]", get_client_name(), cmd_done->value, get_sensor_name(m_sensor_id), attribute, value); delete[] (char *)cmd_done; @@ -700,8 +700,8 @@ bool command_channel::cmd_set_attribute_str(int attribute, const char* value, in cmd_set_attribute_str->value_len = value_len; memcpy(cmd_set_attribute_str->value, value, value_len); - _I("%s send cmd_set_attribute_str(client_id=%d, value_len = %d, buffer = 0x%x)", - get_client_name(), m_client_id, value_len, value); + _I("%s send cmd_set_attribute_str(client_id=%d, attribute = 0x%x, value_len = %d, value = 0x%x)", + get_client_name(), m_client_id, attribute, value_len, value); if (!command_handler(packet, (void **)&cmd_done)) { _E("%s failed to send/receive command with client_id [%d]", @@ -721,8 +721,5 @@ bool command_channel::cmd_set_attribute_str(int attribute, const char* value, in delete[] (char *)cmd_done; delete packet; - return true; - - } diff --git a/src/client/command_channel.h b/src/client/command_channel.h index 63d5ceb..faa3837 100644 --- a/src/client/command_channel.h +++ b/src/client/command_channel.h @@ -27,7 +27,6 @@ class command_channel { public: - command_channel(); ~command_channel(); @@ -48,9 +47,9 @@ public: bool cmd_unregister_events(event_type_vector &event_vec); bool cmd_set_batch(unsigned int interval, unsigned int latency); bool cmd_unset_batch(void); - bool cmd_get_data(unsigned int type, sensor_data_t* values); + bool cmd_get_data(unsigned int type, sensor_data_t *values); bool cmd_set_attribute_int(int attribute, int value); - bool cmd_set_attribute_str(int attribute, const char* buffer, int data_len); + bool cmd_set_attribute_str(int attribute, const char *value, int value_len); private: csocket m_command_socket; int m_client_id; @@ -58,4 +57,4 @@ private: bool command_handler(cpacket *packet, void **return_payload); }; -#endif /* COMMAND_CHANNEL_H_ */ +#endif /* _COMMAND_CHANNEL_H_ */ diff --git a/src/client/reg_event_info.h b/src/client/reg_event_info.h index cf2fd76..fa8994c 100644 --- a/src/client/reg_event_info.h +++ b/src/client/reg_event_info.h @@ -40,17 +40,16 @@ public: void *m_cb; void *m_user_data; unsigned long long m_previous_event_time; - bool m_fired; + bool m_fired; GMainContext *m_maincontext; - reg_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), m_maincontext(NULL){} + reg_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), m_maincontext(NULL) {} - ~reg_event_info(){} + ~reg_event_info() {} }; - #endif /* _REG_EVENT_INFO_H_ */ diff --git a/src/client/sensor_client_info.cpp b/src/client/sensor_client_info.cpp index 3ffc120..684cd52 100644 --- a/src/client/sensor_client_info.cpp +++ b/src/client/sensor_client_info.cpp @@ -24,9 +24,6 @@ #include #include -#define MS_TO_US 1000 -#define MIN_DELIVERY_DIFF_FACTOR 0.75f - using std::thread; using std::pair; @@ -417,7 +414,6 @@ bool sensor_client_info::close_command_channel(sensor_id_t sensor_id) return true; } - bool sensor_client_info::has_client_id(void) { return (m_client_id != CLIENT_ID_INVALID); @@ -641,7 +637,6 @@ bool sensor_client_info::is_sensor_registered(sensor_id_t sensor) return false; } - bool sensor_client_info::is_sensor_active(sensor_id_t sensor) { AUTOLOCK(m_handle_info_lock); diff --git a/src/client/sensor_event_listener.cpp b/src/client/sensor_event_listener.cpp index 568d8cb..7ea6c95 100644 --- a/src/client/sensor_event_listener.cpp +++ b/src/client/sensor_event_listener.cpp @@ -25,10 +25,9 @@ #include #include -#define MS_TO_US 1000 -#define MIN_DELIVERY_DIFF_FACTOR 0.75f +#include -/* TODO: this macro should be adjusted */ +/* TODO: this macro should be adjusted(4224 = 4096(data) + 128(header)) */ #define EVENT_BUFFER_SIZE 4224 using std::thread; @@ -353,8 +352,6 @@ ssize_t sensor_event_listener::sensor_event_poll(void* buffer, int buffer_len, s return len; } - - void sensor_event_listener::listen_events(void) { struct epoll_event event; diff --git a/src/client/sensor_event_listener.h b/src/client/sensor_event_listener.h index aaa29a6..4af7092 100644 --- a/src/client/sensor_event_listener.h +++ b/src/client/sensor_event_listener.h @@ -97,6 +97,8 @@ private: hup_observer_t m_hup_observer; + sensor_client_info &m_client_info; + sensor_event_listener(); ~sensor_event_listener(); @@ -106,7 +108,7 @@ private: bool create_event_channel(void); void close_event_channel(void); - ssize_t sensor_event_poll(void* buffer, int buffer_len, struct epoll_event &event); + ssize_t sensor_event_poll(void *buffer, int buffer_len, struct epoll_event &event); void listen_events(void); client_callback_info* handle_calibration_cb(sensor_handle_info &handle_info, unsigned event_type, unsigned long long time, int accuracy); @@ -122,7 +124,5 @@ private: static gboolean callback_dispatcher(gpointer data); void set_thread_state(thread_state state); - - sensor_client_info &m_client_info; }; #endif /* _SENSOR_EVENT_LISTENER_H_ */ diff --git a/src/client/sensor_handle_info.h b/src/client/sensor_handle_info.h index c72fb00..f56da67 100644 --- a/src/client/sensor_handle_info.h +++ b/src/client/sensor_handle_info.h @@ -20,12 +20,12 @@ #ifndef _SENSOR_HANDLE_INFO_H_ #define _SENSOR_HANDLE_INFO_H_ +#include #include #include #include #include #include -#include typedef std::unordered_map event_info_map; diff --git a/src/shared/sensor_internal.h b/src/client/sensor_internal.h similarity index 99% rename from src/shared/sensor_internal.h rename to src/client/sensor_internal.h index c1a102b..b16e086 100644 --- a/src/shared/sensor_internal.h +++ b/src/client/sensor_internal.h @@ -30,10 +30,8 @@ /*header for common sensor type*/ #include - -/*header for each sensor type*/ #include - +#include #include #ifdef __cplusplus @@ -355,6 +353,7 @@ bool sensord_set_attribute_str(int handle, int attribute, const char *value, int * @return true on success, otherwise false. */ bool sensord_send_sensorhub_data(int handle, const char *data, int data_len); +bool sensord_send_command(int handle, const char *command, int command_len); /** * @brief get sensor data from a connected sensor diff --git a/src/shared/sensor_internal_deprecated.h b/src/client/sensor_internal_deprecated.h similarity index 99% rename from src/shared/sensor_internal_deprecated.h rename to src/client/sensor_internal_deprecated.h index 5116303..469b8da 100644 --- a/src/shared/sensor_internal_deprecated.h +++ b/src/client/sensor_internal_deprecated.h @@ -30,13 +30,9 @@ /*header for common sensor type*/ #include - -/*header for each sensor type*/ #include - #include - #ifdef __cplusplus extern "C" { diff --git a/src/hal/sensor_hal.h b/src/hal/sensor_hal.h index 9ae5c62..8d89f75 100644 --- a/src/hal/sensor_hal.h +++ b/src/hal/sensor_hal.h @@ -69,16 +69,6 @@ typedef enum { SENSOR_DEVICE_GYROSCOPE_RV, SENSOR_DEVICE_GEOMAGNETIC_RV, - SENSOR_DEVICE_ACTIVITY_STATIONARY = 0x100, - SENSOR_DEVICE_ACTIVITY_WALK, - SENSOR_DEVICE_ACTIVITY_RUN, - SENSOR_DEVICE_ACTIVITY_IN_VEHICLE, - SENSOR_DEVICE_ACTIVITY_ON_BICYCLE, - - SENSOR_DEVICE_GESTURE_MOVEMENT = 0x200, - SENSOR_DEVICE_GESTURE_WRIST_UP, - SENSOR_DEVICE_GESTURE_WRIST_DOWN, - SENSOR_DEVICE_HUMAN_PEDOMETER = 0x300, SENSOR_DEVICE_HUMAN_SLEEP_MONITOR, @@ -96,11 +86,21 @@ typedef enum { SENSOR_DEVICE_HRM_RAW, SENSOR_DEVICE_TILT, SENSOR_DEVICE_ROTATION_VECTOR_RAW, + + SENSOR_DEVICE_ACTIVITY_STATIONARY = 0x1100, + SENSOR_DEVICE_ACTIVITY_WALK, + SENSOR_DEVICE_ACTIVITY_RUN, + SENSOR_DEVICE_ACTIVITY_IN_VEHICLE, + SENSOR_DEVICE_ACTIVITY_ON_BICYCLE, + + SENSOR_DEVICE_GESTURE_MOVEMENT = 0x1200, + SENSOR_DEVICE_GESTURE_WRIST_UP, + SENSOR_DEVICE_GESTURE_WRIST_DOWN, } sensor_device_type; /* * A platform sensor handler is generated based on this handle - * ID can be assigned from HAL developer. so it has to be unique in HAL. + * This id can be assigned from HAL developer. so it has to be unique in 1 sensor_device. */ typedef struct sensor_info_t { uint32_t id; @@ -175,15 +175,29 @@ public: virtual bool enable(uint32_t id) = 0; virtual bool disable(uint32_t id) = 0; - virtual bool set_interval(uint32_t id, unsigned long val) = 0; - virtual bool set_batch_latency(uint32_t id, unsigned long val) = 0; - virtual bool set_attribute_int(uint32_t id, int32_t attribute, int32_t value) = 0; - virtual bool set_attribute_str(uint32_t id, int32_t attribute, char *value, int value_len) = 0; - virtual int read_fd(uint32_t **ids) = 0; virtual int get_data(uint32_t id, sensor_data_t **data, int *length) = 0; - virtual bool flush(uint32_t id) = 0; + virtual bool set_interval(uint32_t id, unsigned long val) + { + return false; + } + virtual bool set_batch_latency(uint32_t id, unsigned long val) + { + return false; + } + virtual bool set_attribute_int(uint32_t id, int32_t attribute, int32_t value) + { + return false; + } + virtual bool set_attribute_str(uint32_t id, int32_t attribute, char *value, int value_len) + { + return false; + } + virtual bool flush(uint32_t id) + { + return false; + } }; #endif /* __cplusplus */ diff --git a/src/sensor/auto_rotation/auto_rotation_sensor.cpp b/src/sensor/auto_rotation/auto_rotation_sensor.cpp index b1f7dba..3afd961 100644 --- a/src/sensor/auto_rotation/auto_rotation_sensor.cpp +++ b/src/sensor/auto_rotation/auto_rotation_sensor.cpp @@ -174,6 +174,11 @@ void auto_rotation_sensor::synthesize(const sensor_event_t& event) int remains; rotation_event = (sensor_event_t *)malloc(sizeof(sensor_event_t)); + if (!rotation_event) { + _E("Failed to allocate memory"); + return; + } + remains = get_data(&rotation_data, &data_length); if (remains < 0) diff --git a/src/sensor/auto_rotation/auto_rotation_sensor.h b/src/sensor/auto_rotation/auto_rotation_sensor.h index 9b40c7c..ef69a6d 100644 --- a/src/sensor/auto_rotation/auto_rotation_sensor.h +++ b/src/sensor/auto_rotation/auto_rotation_sensor.h @@ -21,7 +21,7 @@ #define _AUTO_ROTATION_SENSOR_H_ #include -#include +#include #include class auto_rotation_sensor : public virtual_sensor { @@ -67,4 +67,4 @@ private: auto_rotation_alg *get_alg(); }; -#endif +#endif /* _AUTO_ROTATION_SENSOR_H_ */ diff --git a/src/sensor/rotation_vector/gaming_rv/gaming_rv_sensor.cpp b/src/sensor/rotation_vector/gaming_rv/gaming_rv_sensor.cpp index 5a7adc2..3fd0268 100644 --- a/src/sensor/rotation_vector/gaming_rv/gaming_rv_sensor.cpp +++ b/src/sensor/rotation_vector/gaming_rv/gaming_rv_sensor.cpp @@ -34,7 +34,7 @@ using std::string; using std::vector; -#define SENSOR_NAME "GAMING_RV_SENSOR" +#define SENSOR_NAME "GYROSCOPE_RV_SENSOR" #define SENSOR_TYPE_GAMING_RV "GAMING_ROTATION_VECTOR" #define ACCELEROMETER_ENABLED 0x01 @@ -144,7 +144,7 @@ bool gaming_rv_sensor::init() void gaming_rv_sensor::get_types(vector &types) { - types.push_back(GAMING_RV_SENSOR); + types.push_back(GYROSCOPE_RV_SENSOR); } bool gaming_rv_sensor::on_start(void) diff --git a/src/sensor/rotation_vector/gaming_rv/gaming_rv_sensor.h b/src/sensor/rotation_vector/gaming_rv/gaming_rv_sensor.h index 3307263..ec89b21 100644 --- a/src/sensor/rotation_vector/gaming_rv/gaming_rv_sensor.h +++ b/src/sensor/rotation_vector/gaming_rv/gaming_rv_sensor.h @@ -17,8 +17,8 @@ * */ -#ifndef _GAMING_RV_SENSOR_H_ -#define _GAMING_RV_SENSOR_H_ +#ifndef _GYROSCOPE_RV_SENSOR_H_ +#define _GYROSCOPE_RV_SENSOR_H_ #include #include @@ -70,4 +70,4 @@ private: bool on_stop(void); }; -#endif /*_GAMING_RV_SENSOR_H_*/ +#endif /*_GYROSCOPE_RV_SENSOR_H_*/ diff --git a/src/server/client_sensor_record.h b/src/server/client_sensor_record.h index ac3f3db..9386507 100644 --- a/src/server/client_sensor_record.h +++ b/src/server/client_sensor_record.h @@ -20,7 +20,8 @@ #ifndef _CLIENT_SENSOR_RECORD_H_ #define _CLIENT_SENSOR_RECORD_H_ -#include +#include +#include #include #include #include diff --git a/src/server/command_worker.cpp b/src/server/command_worker.cpp index 8e6931d..4970e2a 100644 --- a/src/server/command_worker.cpp +++ b/src/server/command_worker.cpp @@ -17,10 +17,10 @@ * */ +#include #include #include #include -#include #include #include #include @@ -221,7 +221,6 @@ bool command_worker::stopped(void *ctx) _I("%s is stopped", info.c_str()); if ((inst->m_module) && (inst->m_client_id != CLIENT_ID_INVALID)) { - if (get_client_info_manager().is_started(inst->m_client_id, inst->m_sensor_id)) { _W("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); diff --git a/src/server/command_worker.h b/src/server/command_worker.h index f455cb6..abe89e6 100644 --- a/src/server/command_worker.h +++ b/src/server/command_worker.h @@ -20,13 +20,13 @@ #ifndef _COMMAND_WORKER_H_ #define _COMMAND_WORKER_H_ +#include #include #include #include #include #include #include -#include typedef std::multimap sensor_raw_data_map; void insert_priority_list(unsigned int); @@ -35,9 +35,6 @@ class command_worker { private: typedef bool (command_worker::*cmd_handler_t)(void *payload); - static const int OP_ERROR = -1; - static const int OP_SUCCESS = 0; - int m_client_id; int m_permission; csocket m_socket; diff --git a/src/server/device_config.h b/src/server/device_config.h index 3b85f2f..5c73509 100644 --- a/src/server/device_config.h +++ b/src/server/device_config.h @@ -25,16 +25,16 @@ #include class device_config { -protected: - virtual bool load_config(const std::string& config_path) = 0; - - std::string m_device_id; public: device_config(); virtual ~device_config(); bool get_device_id(void); +protected: + virtual bool load_config(const std::string& config_path) = 0; + + std::string m_device_id; }; #endif /* _DEVICE_CONFIG_H_ */ diff --git a/src/server/physical_sensor.cpp b/src/server/physical_sensor.cpp index f631265..83efec8 100644 --- a/src/server/physical_sensor.cpp +++ b/src/server/physical_sensor.cpp @@ -17,14 +17,12 @@ * */ +#include #include #include #define UNKNOWN_NAME "UNKNOWN_SENSOR" -#define OP_SUCCESS 0 -#define OP_ERROR -1 - cmutex physical_sensor::m_mutex; physical_sensor::physical_sensor() @@ -74,7 +72,7 @@ int physical_sensor::get_poll_fd() AUTOLOCK(m_mutex); if (!m_sensor_device) - return -1; + return OP_ERROR; return m_sensor_device->get_poll_fd(); } @@ -101,14 +99,14 @@ int physical_sensor::get_data(sensor_data_t **data, int *length) AUTOLOCK(m_mutex); if (!m_sensor_device) - return -1; + return OP_ERROR; int remains = 0; remains = m_sensor_device->get_data(m_info->id, data, length); if (*length < 0) { _E("Failed to get sensor event"); - return -1; + return OP_ERROR; } return remains; @@ -153,7 +151,7 @@ int physical_sensor::set_attribute(int32_t attribute, int32_t value) AUTOLOCK(m_mutex); if (!m_sensor_device) - return false; + return OP_ERROR; if (!m_sensor_device->set_attribute_int(m_info->id, attribute, value)) return OP_ERROR; @@ -166,7 +164,7 @@ int physical_sensor::set_attribute(int32_t attribute, char *value, int value_len AUTOLOCK(m_mutex); if (!m_sensor_device) - return false; + return OP_ERROR; if (!m_sensor_device->set_attribute_str(m_info->id, attribute, value, value_len)) return OP_ERROR; @@ -210,7 +208,7 @@ bool physical_sensor::get_sensor_info(sensor_info &info) info.set_max_range(m_info->max_range); info.set_resolution(m_info->resolution); info.set_min_interval(m_info->min_interval); - info.set_fifo_count(0); // FIXME + info.set_fifo_count(0); info.set_max_batch_count(m_info->max_batch_count); info.set_supported_event(get_event_type()); info.set_wakeup_supported(m_info->wakeup_supported); diff --git a/src/server/sensor_base.cpp b/src/server/sensor_base.cpp index 4aaacf6..4fefeff 100644 --- a/src/server/sensor_base.cpp +++ b/src/server/sensor_base.cpp @@ -18,18 +18,20 @@ */ #include -#include -#include -#include #include #include #include +#include + +#include +#include +#include using std::make_pair; using std::vector; sensor_base::sensor_base() -: m_unique_id(-1) +: m_id(SENSOR_ID_INVALID) , m_permission(SENSOR_PERMISSION_STANDARD) , m_started(false) , m_client(0) @@ -42,15 +44,15 @@ sensor_base::~sensor_base() void sensor_base::set_id(sensor_id_t id) { - m_unique_id = id; + m_id = id; } sensor_id_t sensor_base::get_id(void) { - if (m_unique_id == -1) + if (m_id == SENSOR_ID_INVALID) return UNKNOWN_SENSOR; - return m_unique_id; + return m_id; } sensor_type_t sensor_base::get_type(void) @@ -80,7 +82,7 @@ bool sensor_base::is_virtual() int sensor_base::get_data(sensor_data_t **data, int *length) { - return -1; + return OP_ERROR; } bool sensor_base::flush(void) @@ -90,12 +92,12 @@ bool sensor_base::flush(void) int sensor_base::set_attribute(int32_t cmd, int32_t value) { - return -1; + return OP_ERROR; } int sensor_base::set_attribute(int32_t attribute, char *value, int value_size) { - return -1; + return OP_ERROR; } bool sensor_base::start() @@ -149,14 +151,14 @@ bool sensor_base::add_interval(int client_id, unsigned int interval, bool is_pro { unsigned int prev_min, cur_min; - AUTOLOCK(m_plugin_info_list_mutex); + AUTOLOCK(m_sensor_info_list_mutex); - prev_min = m_plugin_info_list.get_min_interval(); + prev_min = m_sensor_info_list.get_min_interval(); - if (!m_plugin_info_list.add_interval(client_id, interval, is_processor)) + if (!m_sensor_info_list.add_interval(client_id, interval, is_processor)) return false; - cur_min = m_plugin_info_list.get_min_interval(); + cur_min = m_sensor_info_list.get_min_interval(); if (cur_min != prev_min) { _I("Min interval for sensor[0x%llx] is changed from %dms to %dms" @@ -173,14 +175,14 @@ bool sensor_base::add_interval(int client_id, unsigned int interval, bool is_pro bool sensor_base::delete_interval(int client_id, bool is_processor) { unsigned int prev_min, cur_min; - AUTOLOCK(m_plugin_info_list_mutex); + AUTOLOCK(m_sensor_info_list_mutex); - prev_min = m_plugin_info_list.get_min_interval(); + prev_min = m_sensor_info_list.get_min_interval(); - if (!m_plugin_info_list.delete_interval(client_id, is_processor)) + if (!m_sensor_info_list.delete_interval(client_id, is_processor)) return false; - cur_min = m_plugin_info_list.get_min_interval(); + cur_min = m_sensor_info_list.get_min_interval(); if (!cur_min) { _I("No interval for sensor[0x%llx] by%sclient[%d] deleting interval, " @@ -203,23 +205,23 @@ bool sensor_base::delete_interval(int client_id, bool is_processor) unsigned int sensor_base::get_interval(int client_id, bool is_processor) { - AUTOLOCK(m_plugin_info_list_mutex); + AUTOLOCK(m_sensor_info_list_mutex); - return m_plugin_info_list.get_interval(client_id, is_processor); + return m_sensor_info_list.get_interval(client_id, is_processor); } bool sensor_base::add_batch(int client_id, unsigned int latency) { unsigned int prev_max, cur_max; - AUTOLOCK(m_plugin_info_list_mutex); + AUTOLOCK(m_sensor_info_list_mutex); - prev_max = m_plugin_info_list.get_max_batch(); + prev_max = m_sensor_info_list.get_max_batch(); - if (!m_plugin_info_list.add_batch(client_id, latency)) + if (!m_sensor_info_list.add_batch(client_id, latency)) return false; - cur_max = m_plugin_info_list.get_max_batch(); + cur_max = m_sensor_info_list.get_max_batch(); if (cur_max != prev_max) { _I("Max latency for sensor[0x%llx] is changed from %dms to %dms by client[%d] adding latency", @@ -233,14 +235,14 @@ bool sensor_base::add_batch(int client_id, unsigned int latency) bool sensor_base::delete_batch(int client_id) { unsigned int prev_max, cur_max; - AUTOLOCK(m_plugin_info_list_mutex); + AUTOLOCK(m_sensor_info_list_mutex); - prev_max = m_plugin_info_list.get_max_batch(); + prev_max = m_sensor_info_list.get_max_batch(); - if (!m_plugin_info_list.delete_batch(client_id)) + if (!m_sensor_info_list.delete_batch(client_id)) return false; - cur_max = m_plugin_info_list.get_max_batch(); + cur_max = m_sensor_info_list.get_max_batch(); if (!cur_max) { _I("No latency for sensor[0x%llx] by client[%d] deleting latency, so set to default 0 ms", @@ -259,23 +261,23 @@ bool sensor_base::delete_batch(int client_id) unsigned int sensor_base::get_batch(int client_id) { - AUTOLOCK(m_plugin_info_list_mutex); + AUTOLOCK(m_sensor_info_list_mutex); - return m_plugin_info_list.get_batch(client_id); + return m_sensor_info_list.get_batch(client_id); } bool sensor_base::add_wakeup(int client_id, int wakeup) { int prev_wakeup, cur_wakeup; - AUTOLOCK(m_plugin_info_list_mutex); + AUTOLOCK(m_sensor_info_list_mutex); - prev_wakeup = m_plugin_info_list.is_wakeup_on(); + prev_wakeup = m_sensor_info_list.is_wakeup_on(); - if (!m_plugin_info_list.add_wakeup(client_id, wakeup)) + if (!m_sensor_info_list.add_wakeup(client_id, wakeup)) return false; - cur_wakeup = m_plugin_info_list.is_wakeup_on(); + cur_wakeup = m_sensor_info_list.is_wakeup_on(); if ((cur_wakeup == SENSOR_WAKEUP_ON) && (prev_wakeup < SENSOR_WAKEUP_ON)) { _I("Wakeup for sensor[0x%llx] is changed from %d to %d by client[%d] adding wakeup", @@ -289,14 +291,14 @@ bool sensor_base::add_wakeup(int client_id, int wakeup) bool sensor_base::delete_wakeup(int client_id) { int prev_wakeup, cur_wakeup; - AUTOLOCK(m_plugin_info_list_mutex); + AUTOLOCK(m_sensor_info_list_mutex); - prev_wakeup = m_plugin_info_list.is_wakeup_on(); + prev_wakeup = m_sensor_info_list.is_wakeup_on(); - if (!m_plugin_info_list.delete_wakeup(client_id)) + if (!m_sensor_info_list.delete_wakeup(client_id)) return false; - cur_wakeup = m_plugin_info_list.is_wakeup_on(); + cur_wakeup = m_sensor_info_list.is_wakeup_on(); if ((cur_wakeup < SENSOR_WAKEUP_ON) && (prev_wakeup == SENSOR_WAKEUP_ON)) { _I("Wakeup for sensor[0x%llx] is changed from %d to %d by client[%d] deleting wakeup", @@ -309,9 +311,9 @@ bool sensor_base::delete_wakeup(int client_id) int sensor_base::get_wakeup(int client_id) { - AUTOLOCK(m_plugin_info_list_mutex); + AUTOLOCK(m_sensor_info_list_mutex); - return m_plugin_info_list.is_wakeup_on(); + return m_sensor_info_list.is_wakeup_on(); } bool sensor_base::is_wakeup_supported(void) @@ -381,4 +383,3 @@ unsigned long long sensor_base::get_timestamp(timeval *t) return ((unsigned long long)(t->tv_sec)*1000000LL +t->tv_usec); } - diff --git a/src/server/sensor_base.h b/src/server/sensor_base.h index 072c3f2..0260119 100644 --- a/src/server/sensor_base.h +++ b/src/server/sensor_base.h @@ -20,9 +20,8 @@ #ifndef _SENSOR_BASE_H_ #define _SENSOR_BASE_H_ -#include #include -#include +#include #include #include @@ -30,6 +29,7 @@ #include #include #include +#include class sensor_base { public: @@ -44,9 +44,9 @@ public: virtual sensor_type_t get_type(); virtual unsigned int get_event_type(void); virtual const char* get_name(void); + virtual bool is_virtual(void); virtual bool get_sensor_info(sensor_info &info); - virtual bool is_virtual(void); /* set/get data */ virtual int get_data(sensor_data_t **data, int *length); @@ -61,16 +61,16 @@ public: bool is_started(void); /* interval / batch / wakeup */ - bool add_interval(int client_id, unsigned int interval, bool is_processor); - bool delete_interval(int client_id, bool is_processor); + virtual bool add_interval(int client_id, unsigned int interval, bool is_processor); + virtual bool delete_interval(int client_id, bool is_processor); unsigned int get_interval(int client_id, bool is_processor); - bool add_batch(int client_id, unsigned int latency); - bool delete_batch(int client_id); + virtual bool add_batch(int client_id, unsigned int latency); + virtual bool delete_batch(int client_id); unsigned int get_batch(int client_id); - bool add_wakeup(int client_id, int wakeup); - bool delete_wakeup(int client_id); + virtual bool add_wakeup(int client_id, int wakeup); + virtual bool delete_wakeup(int client_id); int get_wakeup(int client_id); bool is_wakeup_supported(void); @@ -83,11 +83,11 @@ protected: void set_permission(int permission); private: - sensor_id_t m_unique_id; + sensor_id_t m_id; int m_permission; - plugin_info_list m_plugin_info_list; - cmutex m_plugin_info_list_mutex; + sensor_info_list m_sensor_info_list; + cmutex m_sensor_info_list_mutex; bool m_started; unsigned int m_client; diff --git a/src/server/sensor_event_dispatcher.cpp b/src/server/sensor_event_dispatcher.cpp index 564ab70..a673ae4 100644 --- a/src/server/sensor_event_dispatcher.cpp +++ b/src/server/sensor_event_dispatcher.cpp @@ -17,6 +17,7 @@ * */ +#include #include #include #include @@ -29,7 +30,6 @@ using std::pair; #define MAX_PENDING_CONNECTION 32 sensor_event_dispatcher::sensor_event_dispatcher() -: m_lcd_on(false) { } @@ -282,8 +282,7 @@ void sensor_event_dispatcher::request_last_event(int client_id, sensor_id_t sens } } - -bool sensor_event_dispatcher::add_active_virtual_sensor(virtual_sensor * sensor) +bool sensor_event_dispatcher::add_active_virtual_sensor(virtual_sensor *sensor) { AUTOLOCK(m_active_virtual_sensors_mutex); @@ -297,7 +296,7 @@ bool sensor_event_dispatcher::add_active_virtual_sensor(virtual_sensor * sensor) return true; } -bool sensor_event_dispatcher::delete_active_virtual_sensor(virtual_sensor * sensor) +bool sensor_event_dispatcher::delete_active_virtual_sensor(virtual_sensor *sensor) { AUTOLOCK(m_active_virtual_sensors_mutex); diff --git a/src/server/sensor_event_dispatcher.h b/src/server/sensor_event_dispatcher.h index b597816..befb9ea 100644 --- a/src/server/sensor_event_dispatcher.h +++ b/src/server/sensor_event_dispatcher.h @@ -20,6 +20,7 @@ #ifndef _SENSOR_EVENT_DISPATCHER_H_ #define _SENSOR_EVENT_DISPATCHER_H_ +#include #include #include #include @@ -28,13 +29,11 @@ #include #include - typedef std::unordered_map event_type_last_event_map; typedef std::list virtual_sensors; class sensor_event_dispatcher { private: - bool m_lcd_on; csocket m_accept_socket; cmutex m_mutex; cmutex m_last_events_mutex; diff --git a/src/server/sensor_event_poller.cpp b/src/server/sensor_event_poller.cpp index 97fd19a..274c11e 100644 --- a/src/server/sensor_event_poller.cpp +++ b/src/server/sensor_event_poller.cpp @@ -24,8 +24,6 @@ #include #include -#define EPOLL_MAX_FD 32 - sensor_event_poller::sensor_event_poller() { init_sensor_map(); diff --git a/src/server/sensor_event_queue.cpp b/src/server/sensor_event_queue.cpp index 9378c8d..26b4d97 100644 --- a/src/server/sensor_event_queue.cpp +++ b/src/server/sensor_event_queue.cpp @@ -18,7 +18,7 @@ */ #include -#include "sensor_log.h" +#include sensor_event_queue& sensor_event_queue::get_instance() { diff --git a/src/server/sensor_event_queue.h b/src/server/sensor_event_queue.h index df33035..1564d7d 100644 --- a/src/server/sensor_event_queue.h +++ b/src/server/sensor_event_queue.h @@ -82,9 +82,9 @@ private: typedef std::lock_guard lock; typedef std::unique_lock ulock; - sensor_event_queue() {}; - ~sensor_event_queue() {}; - sensor_event_queue(const sensor_event_queue &) {}; + sensor_event_queue() {} + ~sensor_event_queue() {} + sensor_event_queue(const sensor_event_queue &) {} sensor_event_queue& operator=(const sensor_event_queue &); void push_internal(void *event); public: diff --git a/src/server/plugin_info_list.cpp b/src/server/sensor_info_list.cpp similarity index 66% rename from src/server/plugin_info_list.cpp rename to src/server/sensor_info_list.cpp index db36f04..21e6f62 100644 --- a/src/server/plugin_info_list.cpp +++ b/src/server/sensor_info_list.cpp @@ -17,40 +17,39 @@ * */ -#include +#include #include - -cinterval_info::cinterval_info(int client_id, bool is_processor, unsigned int interval) +interval_info::interval_info(int client_id, bool is_processor, unsigned int interval) { this->client_id = client_id; this->is_processor = is_processor; this->interval = interval; } -cbatch_info::cbatch_info(int client_id, unsigned int latency) +batch_info::batch_info(int client_id, unsigned int latency) { this->client_id = client_id; this->latency = latency; } -cwakeup_info::cwakeup_info(int client_id, int wakeup) +wakeup_info::wakeup_info(int client_id, int wakeup) { this->client_id = client_id; this->wakeup = wakeup; } -bool plugin_info_list::comp_interval_info(cinterval_info a, cinterval_info b) +bool sensor_info_list::comp_interval_info(interval_info a, interval_info b) { return a.interval < b.interval; } -bool plugin_info_list::comp_batch_info(cbatch_info a, cbatch_info b) +bool sensor_info_list::comp_batch_info(batch_info a, batch_info b) { return a.latency < b.latency; } -cinterval_info_iterator plugin_info_list::find_if_interval_info(int client_id, bool is_processor) +interval_info_iterator sensor_info_list::find_if_interval_info(int client_id, bool is_processor) { auto iter = m_interval_info_list.begin(); @@ -64,7 +63,7 @@ cinterval_info_iterator plugin_info_list::find_if_interval_info(int client_id, b return iter; } -cbatch_info_iterator plugin_info_list::find_if_batch_info(int client_id) +batch_info_iterator sensor_info_list::find_if_batch_info(int client_id) { auto iter = m_batch_info_list.begin(); @@ -78,7 +77,7 @@ cbatch_info_iterator plugin_info_list::find_if_batch_info(int client_id) return iter; } -cwakeup_info_iterator plugin_info_list::find_if_wakeup_info(int client_id) +wakeup_info_iterator sensor_info_list::find_if_wakeup_info(int client_id) { auto iter = m_wakeup_info_list.begin(); @@ -92,19 +91,19 @@ cwakeup_info_iterator plugin_info_list::find_if_wakeup_info(int client_id) return iter; } -bool plugin_info_list::add_interval(int client_id, unsigned int interval, bool is_processor) +bool sensor_info_list::add_interval(int client_id, unsigned int interval, bool is_processor) { auto iter = find_if_interval_info(client_id, is_processor); if (iter != m_interval_info_list.end()) - *iter = cinterval_info(client_id, is_processor, interval); + *iter = interval_info(client_id, is_processor, interval); else - m_interval_info_list.push_back(cinterval_info(client_id, is_processor, interval)); + m_interval_info_list.push_back(interval_info(client_id, is_processor, interval)); return true; } -bool plugin_info_list::delete_interval(int client_id, bool is_processor) +bool sensor_info_list::delete_interval(int client_id, bool is_processor) { auto iter = find_if_interval_info(client_id, is_processor); @@ -116,7 +115,7 @@ bool plugin_info_list::delete_interval(int client_id, bool is_processor) return true; } -unsigned int plugin_info_list::get_interval(int client_id, bool is_processor) +unsigned int sensor_info_list::get_interval(int client_id, bool is_processor) { auto iter = find_if_interval_info(client_id, is_processor); @@ -126,7 +125,7 @@ unsigned int plugin_info_list::get_interval(int client_id, bool is_processor) return iter->interval; } -unsigned int plugin_info_list::get_min_interval(void) +unsigned int sensor_info_list::get_min_interval(void) { if (m_interval_info_list.empty()) return 0; @@ -136,19 +135,19 @@ unsigned int plugin_info_list::get_min_interval(void) return iter->interval; } -bool plugin_info_list::add_batch(int client_id, unsigned int latency) +bool sensor_info_list::add_batch(int client_id, unsigned int latency) { auto iter = find_if_batch_info(client_id); if (iter != m_batch_info_list.end()) - *iter = cbatch_info(client_id, latency); + *iter = batch_info(client_id, latency); else - m_batch_info_list.push_back(cbatch_info(client_id, latency)); + m_batch_info_list.push_back(batch_info(client_id, latency)); return true; } -bool plugin_info_list::delete_batch(int client_id) +bool sensor_info_list::delete_batch(int client_id) { auto iter = find_if_batch_info(client_id); @@ -160,7 +159,7 @@ bool plugin_info_list::delete_batch(int client_id) return true; } -unsigned int plugin_info_list::get_batch(int client_id) +unsigned int sensor_info_list::get_batch(int client_id) { auto iter = find_if_batch_info(client_id); @@ -170,7 +169,7 @@ unsigned int plugin_info_list::get_batch(int client_id) return iter->latency; } -unsigned int plugin_info_list::get_max_batch(void) +unsigned int sensor_info_list::get_max_batch(void) { if (m_batch_info_list.empty()) return 0; @@ -180,19 +179,19 @@ unsigned int plugin_info_list::get_max_batch(void) return iter->latency; } -bool plugin_info_list::add_wakeup(int client_id, int wakeup) +bool sensor_info_list::add_wakeup(int client_id, int wakeup) { auto iter = find_if_wakeup_info(client_id); if (iter != m_wakeup_info_list.end()) - *iter = cwakeup_info(client_id, wakeup); + *iter = wakeup_info(client_id, wakeup); else - m_wakeup_info_list.push_back(cwakeup_info(client_id, wakeup)); + m_wakeup_info_list.push_back(wakeup_info(client_id, wakeup)); return true; } -bool plugin_info_list::delete_wakeup(int client_id) +bool sensor_info_list::delete_wakeup(int client_id) { auto iter = find_if_wakeup_info(client_id); @@ -204,7 +203,7 @@ bool plugin_info_list::delete_wakeup(int client_id) return true; } -int plugin_info_list::get_wakeup(int client_id) +int sensor_info_list::get_wakeup(int client_id) { auto iter = find_if_wakeup_info(client_id); @@ -214,7 +213,7 @@ int plugin_info_list::get_wakeup(int client_id) return iter->wakeup; } -int plugin_info_list::is_wakeup_on(void) +int sensor_info_list::is_wakeup_on(void) { if (m_wakeup_info_list.empty()) return -1; diff --git a/src/server/plugin_info_list.h b/src/server/sensor_info_list.h similarity index 57% rename from src/server/plugin_info_list.h rename to src/server/sensor_info_list.h index e8b034e..fc253aa 100644 --- a/src/server/plugin_info_list.h +++ b/src/server/sensor_info_list.h @@ -17,53 +17,40 @@ * */ -#ifndef _PLUGIN_INFO_LIST_H_ -#define _PLUGIN_INFO_LIST_H_ +#ifndef _SENSOR_INFO_LIST_H_ +#define _SENSOR_INFO_LIST_H_ #include -class cinterval_info { +class interval_info { public: - cinterval_info(int client_id, bool is_processor, unsigned int interval); + interval_info(int client_id, bool is_processor, unsigned int interval); int client_id; bool is_processor; unsigned int interval; }; -typedef std::list::iterator cinterval_info_iterator; +typedef std::list::iterator interval_info_iterator; -class cbatch_info { +class batch_info { public: - cbatch_info(int client_id, unsigned int latency); + batch_info(int client_id, unsigned int latency); int client_id; unsigned int latency; }; -typedef std::list::iterator cbatch_info_iterator; +typedef std::list::iterator batch_info_iterator; -class cwakeup_info { +class wakeup_info { public: - cwakeup_info(int client_id, int wakeup); + wakeup_info(int client_id, int wakeup); int client_id; int wakeup; }; -typedef std::list::iterator cwakeup_info_iterator; - -class plugin_info_list { -private: - static bool comp_interval_info(cinterval_info a, cinterval_info b); - cinterval_info_iterator find_if_interval_info(int client_id, bool is_processor); - - static bool comp_batch_info(cbatch_info a, cbatch_info b); - cbatch_info_iterator find_if_batch_info(int client_id); - - cwakeup_info_iterator find_if_wakeup_info(int client_id); - - std::list m_interval_info_list; - std::list m_batch_info_list; - std::list m_wakeup_info_list; +typedef std::list::iterator wakeup_info_iterator; +class sensor_info_list { public: bool add_interval(int client_id, unsigned int interval, bool is_processor); bool delete_interval(int client_id, bool is_processor); @@ -79,5 +66,18 @@ public: bool delete_wakeup(int client_id); int get_wakeup(int client_id); int is_wakeup_on(void); + +private: + static bool comp_interval_info(interval_info a, interval_info b); + interval_info_iterator find_if_interval_info(int client_id, bool is_processor); + + static bool comp_batch_info(batch_info a, batch_info b); + batch_info_iterator find_if_batch_info(int client_id); + + wakeup_info_iterator find_if_wakeup_info(int client_id); + + std::list m_interval_info_list; + std::list m_batch_info_list; + std::list m_wakeup_info_list; }; -#endif /* _PLUGIN_INFO_LIST_H_ */ +#endif /* _SENSOR_INFO_LIST_H_ */ diff --git a/src/server/sensor_loader.cpp b/src/server/sensor_loader.cpp index 74448da..d8636f1 100644 --- a/src/server/sensor_loader.cpp +++ b/src/server/sensor_loader.cpp @@ -17,15 +17,15 @@ * */ +#include +#include +#include #include -#include -#include #include #include -#include -#include -#include #include +#include +#include #include #include @@ -37,9 +37,7 @@ using std::vector; using std::string; -#define DEVICE_PLUGINS_DIR_PATH "/usr/lib/sensor" -#define SENSOR_TYPE_SHIFT 32 -#define SENSOR_INDEX_MASK 0xFFFFFFFF +#define DEVICE_HAL_DIR_PATH "/usr/lib/sensor" sensor_loader::sensor_loader() { @@ -53,10 +51,10 @@ sensor_loader& sensor_loader::get_instance() bool sensor_loader::load(void) { - std::vector device_plugin_paths; - std::vector unique_device_plugin_paths; + std::vector device_hal_paths; + std::vector unique_device_hal_paths; - get_paths_from_dir(string(DEVICE_PLUGINS_DIR_PATH), device_plugin_paths); + get_paths_from_dir(string(DEVICE_HAL_DIR_PATH), device_hal_paths); std::unordered_set s; auto unique = [&s](vector &paths, const string &path) { @@ -64,13 +62,13 @@ bool sensor_loader::load(void) paths.push_back(path); }; - for_each(device_plugin_paths.begin(), device_plugin_paths.end(), + for_each(device_hal_paths.begin(), device_hal_paths.end(), [&](const string &path) { - unique(unique_device_plugin_paths, path); + unique(unique_device_hal_paths, path); } ); - for_each(unique_device_plugin_paths.begin(), unique_device_plugin_paths.end(), + for_each(unique_device_hal_paths.begin(), unique_device_hal_paths.end(), [&](const string &path) { void *handle; load_sensor_devices(path, handle); @@ -86,7 +84,7 @@ bool sensor_loader::load(void) bool sensor_loader::load_sensor_devices(const string &path, void* &handle) { sensor_device_t *_devices = NULL; - sensor_device *device; + sensor_device *device = NULL; const sensor_info_t *infos; _I("load device: [%s]", path.c_str()); @@ -156,7 +154,7 @@ void sensor_loader::create_physical_sensors(sensor_type_t type) continue; } - sensor = reinterpret_cast(create_sensor<_sensor>()); + sensor = dynamic_cast(create_sensor<_sensor>()); if (!sensor) { _E("Memory allocation failed[%s]", info->name); @@ -177,7 +175,6 @@ void sensor_loader::create_physical_sensors(sensor_type_t type) m_devices[info] = NULL; } - return; } template @@ -187,7 +184,7 @@ void sensor_loader::create_virtual_sensors(const char *name) sensor_type_t type; virtual_sensor *instance; - instance = reinterpret_cast(create_sensor<_sensor>()); + instance = dynamic_cast(create_sensor<_sensor>()); if (!instance) { _E("Memory allocation failed[%s]", name); return; @@ -249,7 +246,7 @@ void sensor_loader::show_sensor_info(void) _I("===============================================\n"); } -bool sensor_loader::get_paths_from_dir(const string &dir_path, vector &plugin_paths) +bool sensor_loader::get_paths_from_dir(const string &dir_path, vector &hal_paths) { DIR *dir = NULL; struct dirent *dir_entry = NULL; @@ -263,13 +260,13 @@ bool sensor_loader::get_paths_from_dir(const string &dir_path, vector &p string name; - while ((dir_entry = readdir(dir))) { + while (dir_entry = readdir(dir)) { name = string(dir_entry->d_name); if (name == "." || name == "..") continue; - plugin_paths.push_back(dir_path + "/" + name); + hal_paths.push_back(dir_path + "/" + name); } closedir(dir); @@ -278,12 +275,12 @@ bool sensor_loader::get_paths_from_dir(const string &dir_path, vector &p sensor_base* sensor_loader::get_sensor(sensor_type_t type) { - auto it_plugins = m_sensors.find(type); + auto it = m_sensors.find(type); - if (it_plugins == m_sensors.end()) + if (it == m_sensors.end()) return NULL; - return it_plugins->second.get(); + return it->second.get(); } sensor_base* sensor_loader::get_sensor(sensor_id_t id) @@ -336,12 +333,13 @@ vector sensor_loader::get_virtual_sensors(void) vector virtual_list; sensor_base* sensor; - for (auto sensor_it = m_sensors.begin(); sensor_it != m_sensors.end(); ++sensor_it) { - sensor = sensor_it->second.get(); + for (auto it = m_sensors.begin(); it != m_sensors.end(); ++it) { + sensor = it->second.get(); - if (sensor && sensor->is_virtual() == true) { - virtual_list.push_back(sensor); - } + if (!sensor || !sensor->is_virtual()) + continue; + + virtual_list.push_back(sensor); } return virtual_list; diff --git a/src/server/sensor_loader.h b/src/server/sensor_loader.h index 19997d7..763ea9a 100644 --- a/src/server/sensor_loader.h +++ b/src/server/sensor_loader.h @@ -17,8 +17,8 @@ * */ -#ifndef _SENSOR_PLUGIN_LOADER_H_ -#define _SENSOR_PLUGIN_LOADER_H_ +#ifndef _SENSOR_LOADER_H_ +#define _SENSOR_LOADER_H_ #include #include @@ -32,8 +32,6 @@ #include #include #include -#include -#include class sensor_base; @@ -52,7 +50,7 @@ private: template sensor_base* create_sensor(void); void show_sensor_info(void); - bool get_paths_from_dir(const std::string &dir_path, std::vector &plugin_paths); + bool get_paths_from_dir(const std::string &dir_path, std::vector &hal_paths); sensor_map_t m_sensors; sensor_device_map_t m_devices; @@ -67,4 +65,4 @@ public: std::vector get_sensors(sensor_type_t type); std::vector get_virtual_sensors(void); }; -#endif /* _SENSOR_PLUGIN_LOADER_H_ */ +#endif /* _SENSOR_LOADER_H_ */ diff --git a/src/server/sensor_usage.cpp b/src/server/sensor_usage.cpp index 6041913..8f4e758 100644 --- a/src/server/sensor_usage.cpp +++ b/src/server/sensor_usage.cpp @@ -17,7 +17,8 @@ * */ -#include +#include +#include #include #include diff --git a/src/server/server.cpp b/src/server/server.cpp index 52671ce..213a43c 100644 --- a/src/server/server.cpp +++ b/src/server/server.cpp @@ -57,7 +57,7 @@ int server::get_systemd_socket(const char *name) } if (sd_listen_fds(fd_env) < 0) { - ERR("Failed to listen fds from systemd"); + _E("Failed to listen fds from systemd"); return -1; } diff --git a/src/server/server.h b/src/server/server.h index 8c69a7a..3f32b3f 100644 --- a/src/server/server.h +++ b/src/server/server.h @@ -24,6 +24,11 @@ #include class server { +public: + void run(void); + void stop(void); + static server& get_instance(); + private: GMainLoop *m_mainloop; csocket m_command_channel_accept_socket; @@ -42,10 +47,6 @@ private: void accept_event_channel(void); int get_systemd_socket(const char *name); -public: - void run(void); - void stop(void); - static server& get_instance(); }; #endif /* _SERVER_H_ */ diff --git a/src/server/virtual_sensor.cpp b/src/server/virtual_sensor.cpp index fd03a49..6701642 100644 --- a/src/server/virtual_sensor.cpp +++ b/src/server/virtual_sensor.cpp @@ -22,7 +22,6 @@ virtual_sensor::virtual_sensor() -: m_hardware_fusion(false) { } diff --git a/src/server/virtual_sensor.h b/src/server/virtual_sensor.h index 270285b..a0adbcc 100644 --- a/src/server/virtual_sensor.h +++ b/src/server/virtual_sensor.h @@ -50,8 +50,6 @@ protected: bool deactivate(void); private: - bool m_hardware_fusion; - virtual bool set_interval(unsigned long interval) = 0; virtual bool set_batch_latency(unsigned long latency) = 0; virtual bool set_wakeup(int wakeup) = 0; diff --git a/src/shared/command_common.h b/src/shared/command_common.h index 141c24c..a75415c 100644 --- a/src/shared/command_common.h +++ b/src/shared/command_common.h @@ -20,21 +20,22 @@ #ifndef _COMMAND_COMMON_H_ #define _COMMAND_COMMON_H_ +#include #include -#define COMMAND_CHANNEL_PATH "/tmp/sensord_command_socket" -#define EVENT_CHANNEL_PATH "/tmp/sensord_event_socket" +#define COMMAND_CHANNEL_PATH "/tmp/sensord_command_socket" +#define EVENT_CHANNEL_PATH "/tmp/sensord_event_socket" #define MAX_HANDLE 256 #define MAX_HANDLE_REACHED -2 enum packet_type_t { + CMD_DONE = -1, CMD_NONE = 0, CMD_GET_ID, CMD_GET_SENSOR_LIST, CMD_HELLO, CMD_BYEBYE, - CMD_DONE, CMD_START, CMD_STOP, CMD_REG, diff --git a/src/shared/cpacket.h b/src/shared/cpacket.h index 6cf6317..64845e8 100644 --- a/src/shared/cpacket.h +++ b/src/shared/cpacket.h @@ -20,6 +20,8 @@ #ifndef _CPACKET_H_ #define _CPACKET_H_ +#include + typedef struct packet_header { int cmd; size_t size; diff --git a/src/shared/csocket.cpp b/src/shared/csocket.cpp index cf65aac..513c4b1 100644 --- a/src/shared/csocket.cpp +++ b/src/shared/csocket.cpp @@ -17,6 +17,7 @@ * */ +#include #include #include #include diff --git a/src/shared/csocket.h b/src/shared/csocket.h index b538fe1..474c38d 100644 --- a/src/shared/csocket.h +++ b/src/shared/csocket.h @@ -26,7 +26,7 @@ #include #include #include -#include "sensor_log.h" +#include class csocket { public: diff --git a/src/shared/poller.cpp b/src/shared/poller.cpp index b0180fe..6676632 100644 --- a/src/shared/poller.cpp +++ b/src/shared/poller.cpp @@ -24,11 +24,13 @@ #define EPOLL_MAX 32 poller::poller() +: m_epfd(-1) { init_poll_fd(); } poller::poller(int fd) +: m_epfd(-1) { init_poll_fd(); add_fd(fd); @@ -100,7 +102,7 @@ bool poller::poll(struct epoll_event &event) m_event_queue.pop(); if (event.events & EPOLLERR) { - _D("Poll error!"); + _E("Poll error!"); return false; } diff --git a/src/shared/sensor_common.h b/src/shared/sensor_common.h index de74ebb..7ba2a89 100644 --- a/src/shared/sensor_common.h +++ b/src/shared/sensor_common.h @@ -20,11 +20,19 @@ #ifndef __SENSOR_COMMON_H__ #define __SENSOR_COMMON_H__ +#include +#include #include #include -#include -#define CLIENT_ID_INVALID -1 +#define OP_ERROR -1 +#define OP_SUCCESS 0 + +#define CLIENT_ID_INVALID -1 +#define SENSOR_ID_INVALID -1 + +#define SENSOR_TYPE_SHIFT 32 +#define SENSOR_INDEX_MASK 0xFFFFFFFF #ifndef NAME_MAX #define NAME_MAX 256 @@ -125,6 +133,6 @@ typedef struct sensor_event_t { #include typedef std::vector event_type_vector; -#endif +#endif /* __cplusplus */ #endif /* __SENSOR_COMMON_H__ */ diff --git a/src/shared/sensor_info.cpp b/src/shared/sensor_info.cpp index 394ee92..eae3bde 100644 --- a/src/shared/sensor_info.cpp +++ b/src/shared/sensor_info.cpp @@ -81,7 +81,7 @@ int sensor_info::get_max_batch_count(void) return m_max_batch_count; } -unsigned int sensor_info::get_supported_event() +unsigned int sensor_info::get_supported_event(void) { return m_supported_event; } @@ -221,8 +221,7 @@ void sensor_info::show(void) _I("Min_interval = %d", m_min_interval); _I("Fifo_count = %d", m_fifo_count); _I("Max_batch_count = %d", m_max_batch_count); - _I("supported_event = 0x%x", m_supported_event); - + _I("Supported_event = 0x%x", m_supported_event); _I("Wakeup_supported = %d", m_wakeup_supported); } @@ -249,7 +248,7 @@ void sensor_info::put(raw_data_t &data, int value) { char buffer[sizeof(value)]; - int *temp = (int *) buffer; + int *temp = (int *)buffer; *temp = value; copy(&buffer[0], &buffer[sizeof(buffer)], back_inserter(data)); @@ -259,7 +258,7 @@ void sensor_info::put(raw_data_t &data, unsigned int value) { char buffer[sizeof(value)]; - unsigned int *temp = (unsigned int *) buffer; + unsigned int *temp = (unsigned int *)buffer; *temp = value; copy(&buffer[0], &buffer[sizeof(buffer)], back_inserter(data)); diff --git a/src/shared/sensor_info.h b/src/shared/sensor_info.h index 6a7ab8b..e2e9e57 100644 --- a/src/shared/sensor_info.h +++ b/src/shared/sensor_info.h @@ -42,7 +42,7 @@ public: int get_min_interval(void); int get_fifo_count(void); int get_max_batch_count(void); - unsigned int get_supported_event(); + unsigned int get_supported_event(void); bool is_supported_event(unsigned int event); bool is_wakeup_supported(void); diff --git a/src/shared/sensor_log.cpp b/src/shared/sensor_log.cpp index d28ae63..0026801 100644 --- a/src/shared/sensor_log.cpp +++ b/src/shared/sensor_log.cpp @@ -23,9 +23,11 @@ #include #include #include +#include #include +#include #include -#include "sensor_log.h" +#include #define PATH_MAX 256 diff --git a/src/shared/sensor_log.h b/src/shared/sensor_log.h index 9df8791..be30df0 100644 --- a/src/shared/sensor_log.h +++ b/src/shared/sensor_log.h @@ -17,10 +17,10 @@ * */ -#ifndef _SENSOR_LOGS_H_ -#define _SENSOR_LOGS_H_ +#ifndef _SENSOR_LOG_H_ +#define _SENSOR_LOG_H_ -#include +#include #include #define EVENT_TYPE_SHIFT 16 @@ -33,6 +33,8 @@ #endif #define LOG_TAG "SENSOR" +#define LOG_DUMP(fp, fmt, arg...) do { if (fp) fprintf(fp, fmt, ##arg); else _E(fmt, ##arg); } while(0) + #ifdef _DEBUG #define DBG SLOGD #else @@ -123,4 +125,4 @@ bool get_proc_name(pid_t pid, char *process_name); } #endif -#endif /* _SENSOR_LOGS_H_ */ +#endif /* _SENSOR_LOG_H_ */ diff --git a/src/shared/sensor_types.h b/src/shared/sensor_types.h index 57b20eb..dfa5461 100644 --- a/src/shared/sensor_types.h +++ b/src/shared/sensor_types.h @@ -41,25 +41,19 @@ typedef enum { ULTRAVIOLET_SENSOR, TEMPERATURE_SENSOR, HUMIDITY_SENSOR, - BIO_HRM_SENSOR, - BIO_LED_GREEN_SENSOR, - BIO_LED_IR_SENSOR, - BIO_LED_RED_SENSOR, + HRM_SENSOR, + BIO_HRM_SENSOR = HRM_SENSOR, + HRM_LED_GREEN_SENSOR, + BIO_LED_GREEN_SENSOR = HRM_LED_GREEN_SENSOR, + HRM_LED_IR_SENSOR, + BIO_LED_IR_SENSOR = HRM_LED_IR_SENSOR, + HRM_LED_RED_SENSOR, + BIO_LED_RED_SENSOR = HRM_LED_RED_SENSOR, GYROSCOPE_UNCAL_SENSOR, - UNCAL_GEOMAGNETIC_SENSOR, - GAMING_RV_SENSOR, + GEOMAGNETIC_UNCAL_SENSOR, + GYROSCOPE_RV_SENSOR, GEOMAGNETIC_RV_SENSOR, - ACTIVITY_STATIONARY_SENSOR = 0x1100, - ACTIVITY_WALK_SENSOR, - ACTIVITY_RUN_SENSOR, - ACTIVITY_IN_VEHICLE_SENSOR, - ACTIVITY_ON_BICYCLE_SENSOR, - - GESTURE_MOVEMENT_SENSOR = 0x1200, - GESTURE_WRIST_UP_SENSOR, - GESTURE_WRIST_DOWN_SENSOR, - HUMAN_PEDOMETER_SENSOR = 0x300, HUMAN_SLEEP_MONITOR_SENSOR, @@ -74,9 +68,20 @@ typedef enum { THERMOMETER_SENSOR, PEDOMETER_SENSOR, FLAT_SENSOR, - BIO_SENSOR, + HRM_RAW_SENSOR, + BIO_SENSOR = HRM_RAW_SENSOR, TILT_SENSOR, RV_RAW_SENSOR, + + ACTIVITY_STATIONARY_SENSOR = 0x1100, + ACTIVITY_WALK_SENSOR, + ACTIVITY_RUN_SENSOR, + ACTIVITY_IN_VEHICLE_SENSOR, + ACTIVITY_ON_BICYCLE_SENSOR, + + GESTURE_MOVEMENT_SENSOR = 0x1200, + GESTURE_WRIST_UP_SENSOR, + GESTURE_WRIST_DOWN_SENSOR, } sensor_type_t; // Sensor Event Types @@ -112,7 +117,7 @@ enum event_types_t { BIO_LED_RED_RAW_DATA_EVENT = (BIO_LED_RED_SENSOR << 16) | 0x0001, - GAMING_RV_RAW_DATA_EVENT = (GAMING_RV_SENSOR << 16) | 0x0001, + GAMING_RV_RAW_DATA_EVENT = (GYROSCOPE_RV_SENSOR << 16) | 0x0001, GEOMAGNETIC_RV_RAW_DATA_EVENT = (GEOMAGNETIC_RV_SENSOR << 16) | 0x0001, @@ -262,4 +267,6 @@ enum motion_property_id { } #endif +#include + #endif /* _SENSOR_TYPES_H_ */ diff --git a/src/test/src/check-sensor.c b/src/test/src/check-sensor.c index 0475880..d9cd3ba 100644 --- a/src/test/src/check-sensor.c +++ b/src/test/src/check-sensor.c @@ -80,7 +80,7 @@ void printpollinglogs(sensor_type_t type,sensor_data_t data) case(GEOMAGNETIC_RV_SENSOR): printf("Geomagnetic Rv [%lld] [%6.6f] [%6.6f] [%6.6f] [%6.6f]\n\n", data.timestamp, data.values[0], data.values[1], data.values[2], data.values[3]); break; - case(GAMING_RV_SENSOR): + case(GYROSCOPE_RV_SENSOR): printf("Gaming Rv [%lld] [%6.6f] [%6.6f] [%6.6f] [%6.6f]\n\n", data.timestamp, data.values[0], data.values[1], data.values[2], data.values[3]); break; case(GYROSCOPE_UNCAL_SENSOR): @@ -158,7 +158,7 @@ int get_event(sensor_type_t sensor_type, char str[]) if (strcmp(str, "RAW_DATA_EVENT") == 0) return GEOMAGNETIC_RV_RAW_DATA_EVENT; break; - case GAMING_RV_SENSOR: + case GYROSCOPE_RV_SENSOR: if (strcmp(str, "RAW_DATA_EVENT") == 0) return GAMING_RV_RAW_DATA_EVENT; break; @@ -226,7 +226,7 @@ void callback(sensor_t sensor, unsigned int event_type, sensor_data_t *data, voi case GEOMAGNETIC_RV_SENSOR: printf("Geomagnetic RV [%lld] [%6.6f] [%6.6f] [%6.6f] [%6.6f]\n", data->timestamp, data->values[0], data->values[1], data->values[2], data->values[3]); break; - case GAMING_RV_SENSOR: + case GYROSCOPE_RV_SENSOR: printf("Gaming RV [%lld] [%6.6f] [%6.6f] [%6.6f] [%6.6f]\n", data->timestamp, data->values[0], data->values[1], data->values[2], data->values[3]); break; case GYROSCOPE_UNCAL_SENSOR: diff --git a/src/test/src/sensor-test.c b/src/test/src/sensor-test.c index 82d27fa..9f5310f 100644 --- a/src/test/src/sensor-test.c +++ b/src/test/src/sensor-test.c @@ -125,7 +125,7 @@ int main(int argc, char **argv) event = GEOMAGNETIC_RV_RAW_DATA_EVENT; } else if (strcmp(argv[1], "gaming_rv") == 0) { - sensor_type = GAMING_RV_SENSOR; + sensor_type = GYROSCOPE_RV_SENSOR; event = GAMING_RV_RAW_DATA_EVENT; } else if (strcmp(argv[1], "light") == 0) { -- 2.7.4 From 672dffa735835a38540fe397675f47c9819e1388 Mon Sep 17 00:00:00 2001 From: "kibak.yoon" Date: Wed, 2 Mar 2016 23:38:31 +0900 Subject: [PATCH 06/16] sensord: lazy loading atexit() because static variables is used in atexit() - if atexit() is called before the declaration of static variables, they can be released while the registered callback is processing. - so atexit() function has to be called lazily. Change-Id: I2feef2013d01470559ad51f8712fbd8ea9f2ae02 Signed-off-by: kibak.yoon --- src/client/client.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/client/client.cpp b/src/client/client.cpp index 96a3e95..3ab4146 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -56,14 +56,14 @@ public: { sensor_event_listener::get_instance().set_hup_observer(restore_session); } - - ~initiator() - { - _D("Good bye! %s\n", get_client_name()); - clean_up(); - } }; +void good_bye(void) +{ + _I("Good bye! %s\n", get_client_name()); + clean_up(); +} + static initiator g_initiator; static int g_power_save_state_cb_cnt = 0; @@ -540,6 +540,9 @@ API int sensord_connect(sensor_t sensor) sensor_registered = sensor_client_info::get_instance().is_sensor_registered(sensor_id); + // lazy loading after creating static variables + atexit(good_bye); + handle = sensor_client_info::get_instance().create_handle(sensor_id); if (handle == MAX_HANDLE_REACHED) { _E("Maximum number of handles reached, sensor: %s in client %s", get_sensor_name(sensor_id), get_client_name()); -- 2.7.4 From 100f1e2b6312c458ce59b5595ec3fd036e55ae3a Mon Sep 17 00:00:00 2001 From: "kibak.yoon" Date: Wed, 2 Mar 2016 23:51:17 +0900 Subject: [PATCH 07/16] sensord: fix the bug/memory leak/inefficient code - clean up the source code Change-Id: I11a5c3922b4c2f287910076580f426c1b9832d4f Signed-off-by: kibak.yoon --- src/client/sensor_event_listener.cpp | 72 ++++++++++++++++------------------ src/server/command_worker.cpp | 31 +++------------ src/server/command_worker.h | 5 ++- src/server/device_config.cpp | 22 ++++++----- src/server/sensor_event_dispatcher.cpp | 28 +++++-------- src/server/sensor_event_dispatcher.h | 21 +++++----- src/server/sensor_event_poller.cpp | 25 ++++++------ src/server/sensor_event_queue.cpp | 2 +- src/server/sensor_event_queue.h | 61 ++++------------------------ src/server/server.cpp | 6 +-- 10 files changed, 100 insertions(+), 173 deletions(-) diff --git a/src/client/sensor_event_listener.cpp b/src/client/sensor_event_listener.cpp index 7ea6c95..9e14fc2 100644 --- a/src/client/sensor_event_listener.cpp +++ b/src/client/sensor_event_listener.cpp @@ -77,26 +77,23 @@ void sensor_event_listener::operate_sensor(sensor_id_t sensor, int power_save_st m_client_info.get_sensor_handle_info(sensor, handles_info); - auto it_handle = handles_info.begin(); + for (auto it_handle = handles_info.begin(); it_handle != handles_info.end(); ++it_handle) { + if (it_handle->second.m_sensor_id != sensor) + continue; - while (it_handle != handles_info.end()) { - if (it_handle->second.m_sensor_id == sensor) { - if ((it_handle->second.m_sensor_state == SENSOR_STATE_STARTED) && - power_save_state && - !(it_handle->second.m_sensor_option & power_save_state)) { + if ((it_handle->second.m_sensor_state == SENSOR_STATE_STARTED) && + power_save_state && + !(it_handle->second.m_sensor_option & power_save_state)) { - m_client_info.set_sensor_state(it_handle->first, SENSOR_STATE_PAUSED); - _I("%s's %s[%d] is paused", get_client_name(), get_sensor_name(sensor), it_handle->first); + m_client_info.set_sensor_state(it_handle->first, SENSOR_STATE_PAUSED); + _I("%s's %s[%d] is paused", get_client_name(), get_sensor_name(sensor), it_handle->first); - } else if ((it_handle->second.m_sensor_state == SENSOR_STATE_PAUSED) && - (!power_save_state || (it_handle->second.m_sensor_option & power_save_state))) { + } else if ((it_handle->second.m_sensor_state == SENSOR_STATE_PAUSED) && + (!power_save_state || (it_handle->second.m_sensor_option & power_save_state))) { - m_client_info.set_sensor_state(it_handle->first, SENSOR_STATE_STARTED); - _I("%s's %s[%d] is resumed", get_client_name(), get_sensor_name(sensor), it_handle->first); - } + m_client_info.set_sensor_state(it_handle->first, SENSOR_STATE_STARTED); + _I("%s's %s[%d] is resumed", get_client_name(), get_sensor_name(sensor), it_handle->first); } - - ++it_handle; } } @@ -171,7 +168,6 @@ void sensor_event_listener::handle_events(void* event) sensor_event_t *sensor_event = (sensor_event_t *)event; sensor_id = sensor_event->sensor_id; - sensor_event->data = (sensor_data_t *)((char *)sensor_event + sizeof(sensor_event_t)); sensor_data = sensor_event->data; cur_time = sensor_event->data->timestamp; accuracy = sensor_event->data->accuracy; @@ -316,7 +312,7 @@ gboolean sensor_event_listener::callback_dispatcher(gpointer data) delete[] (char *)data->event_data; } - free(cb_info->buffer); + free(cb_info->sensor_data); delete cb_info; /* @@ -354,37 +350,37 @@ ssize_t sensor_event_listener::sensor_event_poll(void* buffer, int buffer_len, s void sensor_event_listener::listen_events(void) { + char buffer[EVENT_BUFFER_SIZE]; struct epoll_event event; ssize_t len = -1; do { - lock l(m_thread_mutex); - if (m_thread_state == THREAD_STATE_START) { - void *buffer = malloc(EVENT_BUFFER_SIZE); + void *buffer_data; + int data_len; - if (!buffer) { - _E("Failed to allocate memory"); - break; - } + lock l(m_thread_mutex); + if (m_thread_state != THREAD_STATE_START) + break; - len = sensor_event_poll(buffer, EVENT_BUFFER_SIZE, event); - if (len <= 0) { - _I("sensor_event_poll failed"); - free(buffer); - break; - } + len = sensor_event_poll(buffer, sizeof(sensor_event_t), event); + if (len <= 0) { + _I("Failed to sensor_event_poll()"); + break; + } - void *buffer_shrinked = realloc(buffer, len); - if (!buffer_shrinked) { - _E("Failed to allocate memory"); - free(buffer); - break; - } + data_len = ((sensor_event_t *)buffer)->data_length; + buffer_data = malloc(data_len); - handle_events(buffer_shrinked); - } else { + len = sensor_event_poll(buffer_data, data_len, event); + if (len <= 0) { + _I("Failed to sensor_event_poll() for sensor_data"); + free(buffer_data); break; } + + ((sensor_event_t *)buffer)->data = (sensor_data_t *)buffer_data; + + handle_events((void *)buffer); } while (true); if (m_poller != NULL) { diff --git a/src/server/command_worker.cpp b/src/server/command_worker.cpp index 4970e2a..0423eab 100644 --- a/src/server/command_worker.cpp +++ b/src/server/command_worker.cpp @@ -25,7 +25,6 @@ #include #include #include -#include #include #include @@ -36,8 +35,7 @@ using std::make_pair; command_worker::cmd_handler_t command_worker::m_cmd_handlers[]; sensor_raw_data_map command_worker::m_sensor_raw_data_map; cpacket command_worker::m_sensor_list; - -std::set priority_list; +cmutex command_worker::m_shared_mutex; command_worker::command_worker(const csocket& socket) : m_client_id(CLIENT_ID_INVALID) @@ -48,6 +46,8 @@ command_worker::command_worker(const csocket& socket) { static bool init = false; + AUTOLOCK(m_shared_mutex); + if (!init) { init_cmd_handlers(); make_sensor_raw_data_map(); @@ -320,10 +320,12 @@ bool command_worker::send_cmd_get_data_done(int state, sensor_data_t *data) if (m_socket.send(ret_packet->packet(), ret_packet->size()) <= 0) { _E("Failed to send a cmd_get_data_done"); + free(data); delete ret_packet; return false; } + free(data); delete ret_packet; return true; } @@ -542,8 +544,6 @@ bool command_worker::cmd_register_event(void *payload) goto out; } - insert_priority_list(cmd->event_type); - ret_value = OP_SUCCESS; _D("Registering Event [0x%x] is done for client [%d]", cmd->event_type, m_client_id); @@ -885,24 +885,3 @@ sensor_event_dispatcher& command_worker::get_event_dispathcher(void) return sensor_event_dispatcher::get_instance(); } -void insert_priority_list(unsigned int event_type) -{ - if (event_type == ORIENTATION_RAW_DATA_EVENT || - event_type == LINEAR_ACCEL_RAW_DATA_EVENT || - event_type == GRAVITY_RAW_DATA_EVENT || - event_type == ROTATION_VECTOR_RAW_DATA_EVENT) { - priority_list.insert(ACCELEROMETER_RAW_DATA_EVENT); - priority_list.insert(GYROSCOPE_RAW_DATA_EVENT); - priority_list.insert(GEOMAGNETIC_RAW_DATA_EVENT); - } - - if (event_type == GEOMAGNETIC_RV_RAW_DATA_EVENT) { - priority_list.insert(ACCELEROMETER_RAW_DATA_EVENT); - priority_list.insert(GEOMAGNETIC_RAW_DATA_EVENT); - } - - if (event_type == GAMING_RV_RAW_DATA_EVENT) { - priority_list.insert(ACCELEROMETER_RAW_DATA_EVENT); - priority_list.insert(GYROSCOPE_RAW_DATA_EVENT); - } -} diff --git a/src/server/command_worker.h b/src/server/command_worker.h index abe89e6..d03d4a3 100644 --- a/src/server/command_worker.h +++ b/src/server/command_worker.h @@ -29,7 +29,6 @@ #include typedef std::multimap sensor_raw_data_map; -void insert_priority_list(unsigned int); class command_worker { private: @@ -83,6 +82,10 @@ private: static client_info_manager& get_client_info_manager(void); static sensor_event_dispatcher& get_event_dispathcher(void); + +protected: + static cmutex m_shared_mutex; + public: command_worker(const csocket& socket); virtual ~command_worker(); diff --git a/src/server/device_config.cpp b/src/server/device_config.cpp index 10239f1..ac7a7bd 100644 --- a/src/server/device_config.cpp +++ b/src/server/device_config.cpp @@ -54,16 +54,18 @@ bool device_config::get_device_id(void) getline(in_file, line); start_pos = line.find(START_DELIMETER); - if (start_pos != std::string::npos) { - start_pos = start_pos + START_DELIMETER.size(); - end_pos = line.find(END_DELIMETER, start_pos); - - if (end_pos != std::string::npos) { - m_device_id = line.substr(start_pos, end_pos - start_pos); - ret = true; - break; - } - } + if (start_pos == std::string::npos) + continue; + + start_pos = start_pos + START_DELIMETER.size(); + end_pos = line.find(END_DELIMETER, start_pos); + + if (end_pos == std::string::npos) + continue; + + m_device_id = line.substr(start_pos, end_pos - start_pos); + ret = true; + break; } in_file.close(); diff --git a/src/server/sensor_event_dispatcher.cpp b/src/server/sensor_event_dispatcher.cpp index a673ae4..df64e80 100644 --- a/src/server/sensor_event_dispatcher.cpp +++ b/src/server/sensor_event_dispatcher.cpp @@ -142,8 +142,7 @@ void sensor_event_dispatcher::dispatch_event(void) void sensor_event_dispatcher::send_sensor_events(vector &events) { - void *event; - sensor_event_t *sensor_events = NULL; + sensor_event_t *sensor_event = NULL; client_info_manager& client_info_manager = get_client_info_manager(); const int RESERVED_CLIENT_CNT = 20; @@ -154,19 +153,10 @@ void sensor_event_dispatcher::send_sensor_events(vector &events) unsigned int event_type; int length; - sensor_events = (sensor_event_t*)events[i]; - length = sizeof(sensor_event_t) + sensor_events->data_length; - sensor_id = sensor_events->sensor_id; - event_type = sensor_events->event_type; - - event = (void *)malloc(length); - if (!event) { - _E("Failed to allocate memory"); - return; - } - - memcpy(event, sensor_events, sizeof(sensor_event_t)); - memcpy((char *)event + sizeof(sensor_event_t), sensor_events->data, sensor_events->data_length); + sensor_event = (sensor_event_t*)events[i]; + length = sizeof(sensor_event_t) + sensor_event->data_length; + sensor_id = sensor_event->sensor_id; + event_type = sensor_event->event_type; id_vec.clear(); client_info_manager.get_listener_ids(sensor_id, event_type, id_vec); @@ -176,7 +166,9 @@ void sensor_event_dispatcher::send_sensor_events(vector &events) while (it_client_id != id_vec.end()) { csocket client_socket; client_info_manager.get_event_socket(*it_client_id, client_socket); - bool ret = (client_socket.send(event, length) > 0); + bool ret = (client_socket.send(sensor_event, sizeof(sensor_event_t)) > 0); + + ret = (ret & (client_socket.send(sensor_event->data, sensor_event->data_length) > 0)); if (ret) _D("Event[0x%x] sent to %s on socket[%d]", event_type, client_info_manager.get_client_info(*it_client_id), client_socket.get_socket_fd()); @@ -186,8 +178,8 @@ void sensor_event_dispatcher::send_sensor_events(vector &events) ++it_client_id; } - free(sensor_events->data); - free(sensor_events); + free(sensor_event->data); + free(sensor_event); } } diff --git a/src/server/sensor_event_dispatcher.h b/src/server/sensor_event_dispatcher.h index befb9ea..243fb70 100644 --- a/src/server/sensor_event_dispatcher.h +++ b/src/server/sensor_event_dispatcher.h @@ -33,6 +33,17 @@ typedef std::unordered_map event_type_last_event_m typedef std::list virtual_sensors; class sensor_event_dispatcher { +public: + static sensor_event_dispatcher& get_instance(); + + bool run(void); + void accept_event_connections(csocket client_socket); + + void request_last_event(int client_id, sensor_id_t sensor_id); + + bool add_active_virtual_sensor(virtual_sensor *sensor); + bool delete_active_virtual_sensor(virtual_sensor *sensor); + private: csocket m_accept_socket; cmutex m_mutex; @@ -61,16 +72,6 @@ private: virtual_sensors get_active_virtual_sensors(void); void sort_sensor_events(std::vector &events); -public: - static sensor_event_dispatcher& get_instance(); - - bool run(void); - void accept_event_connections(csocket client_socket); - - void request_last_event(int client_id, sensor_id_t sensor_id); - - bool add_active_virtual_sensor(virtual_sensor *sensor); - bool delete_active_virtual_sensor(virtual_sensor *sensor); }; #endif /* _SENSOR_EVENT_DISPATCHER_H_ */ diff --git a/src/server/sensor_event_poller.cpp b/src/server/sensor_event_poller.cpp index 274c11e..0063871 100644 --- a/src/server/sensor_event_poller.cpp +++ b/src/server/sensor_event_poller.cpp @@ -42,19 +42,16 @@ void sensor_event_poller::init_sensor_map() std::vector sensors; sensors = sensor_loader::get_instance().get_sensors(ALL_SENSOR); - auto it_sensor = sensors.begin(); + std::vector::iterator it; - while (it_sensor != sensors.end()) { - if ((*it_sensor)->is_virtual()) { - ++it_sensor; + for (it = sensors.begin(); it != sensors.end(); ++it) { + sensor = dynamic_cast(*it); + if (sensor == NULL) continue; - } - sensor = dynamic_cast(*it_sensor); fd = sensor->get_poll_fd(); m_fd_sensors.insert(std::make_pair(fd, sensor)); - ++it_sensor; } } @@ -62,8 +59,8 @@ void sensor_event_poller::init_fd() { fd_sensors_t::iterator it; for (it = m_fd_sensors.begin(); it != m_fd_sensors.end(); it = m_fd_sensors.upper_bound(it->first)) { - if (!add_poll_fd(it->first)) - continue; + /* if fd is not valid, it is not added to poller */ + add_poll_fd(it->first); } } @@ -88,10 +85,9 @@ bool sensor_event_poller::poll() if (!read_fd(fd, ids)) continue; - process_event(fd, ids); + if (!process_event(fd, ids)) + continue; } - - return true; } bool sensor_event_poller::read_fd(int fd, std::vector &ids) @@ -143,7 +139,10 @@ bool sensor_event_poller::process_event(int fd, const std::vector &ids event->data_length = data_length; event->data = data; - sensor->push(event); + if (!sensor->push(event)) { + free(event); + free(data); + } } } diff --git a/src/server/sensor_event_queue.cpp b/src/server/sensor_event_queue.cpp index 26b4d97..300808e 100644 --- a/src/server/sensor_event_queue.cpp +++ b/src/server/sensor_event_queue.cpp @@ -47,7 +47,7 @@ void* sensor_event_queue::pop(void) while (m_queue.empty()) m_cond_var.wait(u); - void *event = m_queue.top(); + void *event = m_queue.front(); m_queue.pop(); return event; diff --git a/src/server/sensor_event_queue.h b/src/server/sensor_event_queue.h index 1564d7d..f5e31ae 100644 --- a/src/server/sensor_event_queue.h +++ b/src/server/sensor_event_queue.h @@ -20,62 +20,22 @@ #ifndef _SENSOR_EVENT_QUEUE_H_ #define _SENSOR_EVENT_QUEUE_H_ -#include -#include +#include #include #include #include -#include -#include - -extern std::set priority_list; class sensor_event_queue { -private: - static const unsigned int QUEUE_FULL_SIZE = 1000; - - class compare { - public: - bool operator() (void *&v1, void *&v2) { - sensor_event_t *e1 = (sensor_event_t *)v1; - sensor_event_t *e2 = (sensor_event_t *)v2; - bool prioritize_e1 = true; - bool prioritize_e2 = true; - - if (priority_list.empty()) - return (e2->data->timestamp < e1->data->timestamp); - - std::set::iterator iter_e1 = priority_list.find(e1->event_type); - std::set::iterator iter_e2 = priority_list.find(e2->event_type); - - if (iter_e1 == priority_list.end()) - prioritize_e1 = false; - - if (iter_e2 == priority_list.end()) - prioritize_e2 = false; +public: + static sensor_event_queue& get_instance(); - if (prioritize_e2) { - if (!prioritize_e1) - return true; - else { - if (e2->data->timestamp <= e1->data->timestamp) - return true; - return false; - } - } - else { - if (prioritize_e1) - return false; - else if (e2->data->timestamp <= e1->data->timestamp) - return true; - else - return false; - } - } - }; + void push(sensor_event_t *event); + void* pop(void); - std::priority_queue, compare> m_queue; +private: + static const unsigned int QUEUE_FULL_SIZE = 1000; + std::queue m_queue; std::mutex m_mutex; std::condition_variable m_cond_var; @@ -87,11 +47,6 @@ private: sensor_event_queue(const sensor_event_queue &) {} sensor_event_queue& operator=(const sensor_event_queue &); void push_internal(void *event); -public: - static sensor_event_queue& get_instance(); - - void push(sensor_event_t *event); - void* pop(void); }; #endif /* _SENSOR_EVENT_QUEUE_H_*/ diff --git a/src/server/server.cpp b/src/server/server.cpp index 213a43c..5e902bb 100644 --- a/src/server/server.cpp +++ b/src/server/server.cpp @@ -26,7 +26,7 @@ #include #include -#define SYSTEMD_SOCKET_MAX 2 +#define SYSTEMD_SOCKET_MAX 2 using std::thread; @@ -162,7 +162,7 @@ bool server::listen_command_channel(void) sock_fd = get_systemd_socket(COMMAND_CHANNEL_PATH); if (sock_fd >= 0) { - INFO("Succeeded to get systemd socket(%d)", sock_fd); + _I("Succeeded to get systemd socket(%d)", sock_fd); m_command_channel_accept_socket = csocket(sock_fd); return true; } @@ -195,7 +195,7 @@ bool server::listen_event_channel(void) sock_fd = get_systemd_socket(EVENT_CHANNEL_PATH); if (sock_fd >= 0) { - INFO("Succeeded to get systemd socket(%d)", sock_fd); + _I("Succeeded to get systemd socket(%d)", sock_fd); m_event_channel_accept_socket = csocket(sock_fd); return true; } -- 2.7.4 From ad60f6010ca0b1713420e70a5af8f4866f8d3098 Mon Sep 17 00:00:00 2001 From: "kibak.yoon" Date: Thu, 3 Mar 2016 12:05:46 +0900 Subject: [PATCH 08/16] sensord: fix the svace issue because of using non-terminated string Change-Id: Ibcbee0bac176f72c647639f8fb950dca1cf8fe70 Signed-off-by: kibak.yoon --- src/shared/command_common.h | 4 ++-- src/shared/csocket.cpp | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/shared/command_common.h b/src/shared/command_common.h index a75415c..bb67f70 100644 --- a/src/shared/command_common.h +++ b/src/shared/command_common.h @@ -23,8 +23,8 @@ #include #include -#define COMMAND_CHANNEL_PATH "/tmp/sensord_command_socket" -#define EVENT_CHANNEL_PATH "/tmp/sensord_event_socket" +#define COMMAND_CHANNEL_PATH "/tmp/sensord_command_socket\0" +#define EVENT_CHANNEL_PATH "/tmp/sensord_event_socket\0" #define MAX_HANDLE 256 #define MAX_HANDLE_REACHED -2 diff --git a/src/shared/csocket.cpp b/src/shared/csocket.cpp index 513c4b1..c6e7998 100644 --- a/src/shared/csocket.cpp +++ b/src/shared/csocket.cpp @@ -95,8 +95,7 @@ bool csocket::bind (const char *sock_path) m_addr.sun_family = AF_UNIX; - strncpy(m_addr.sun_path, sock_path, sizeof(m_addr.sun_path)); - m_addr.sun_path[sizeof(m_addr.sun_path)-1] = '\0'; + strncpy(m_addr.sun_path, sock_path, strlen(sock_path)); length = strlen(m_addr.sun_path) + sizeof(m_addr.sun_family); @@ -297,8 +296,7 @@ bool csocket::connect(const char *sock_path) m_addr.sun_family = AF_UNIX; - strncpy(m_addr.sun_path, sock_path, sizeof(m_addr.sun_path)); - m_addr.sun_path[sizeof(m_addr.sun_path)-1] = '\0'; + strncpy(m_addr.sun_path, sock_path, strlen(sock_path)); addr_len = strlen(m_addr.sun_path) + sizeof(m_addr.sun_family); -- 2.7.4 From bee21953a47d138c26b7793219acdf3c7ebddcd5 Mon Sep 17 00:00:00 2001 From: "kibak.yoon" Date: Mon, 7 Mar 2016 13:15:52 +0900 Subject: [PATCH 09/16] sensord: remove sensord compiler warnings Change-Id: I2a8136c8bdd25fad9a6824ddbbff7c90ec26c529 Signed-off-by: kibak.yoon --- src/client/client_common.h | 5 ++--- src/client/sensor_event_listener.cpp | 7 ++++--- src/server/sensor_event_dispatcher.cpp | 2 -- src/server/sensor_loader.cpp | 2 +- src/test/src/sensor-test.c | 6 +++++- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/client/client_common.h b/src/client/client_common.h index 85606db..8b5ec8e 100644 --- a/src/client/client_common.h +++ b/src/client/client_common.h @@ -27,12 +27,11 @@ #include #define BASE_GATHERING_INTERVAL 100 - #define CLIENT_NAME_SIZE NAME_MAX+10 struct log_attr { - char *sensor_name; - char *event_name; + const char *sensor_name; + const char *event_name; }; bool is_one_shot_event(unsigned int event_type); diff --git a/src/client/sensor_event_listener.cpp b/src/client/sensor_event_listener.cpp index 9e14fc2..778392d 100644 --- a/src/client/sensor_event_listener.cpp +++ b/src/client/sensor_event_listener.cpp @@ -28,7 +28,7 @@ #include /* TODO: this macro should be adjusted(4224 = 4096(data) + 128(header)) */ -#define EVENT_BUFFER_SIZE 4224 +#define EVENT_BUFFER_SIZE sizeof(sensor_event_t) using std::thread; using std::pair; @@ -368,7 +368,8 @@ void sensor_event_listener::listen_events(void) break; } - data_len = ((sensor_event_t *)buffer)->data_length; + sensor_event_t *sensor_event = reinterpret_cast(buffer); + data_len = sensor_event->data_length; buffer_data = malloc(data_len); len = sensor_event_poll(buffer_data, data_len, event); @@ -378,7 +379,7 @@ void sensor_event_listener::listen_events(void) break; } - ((sensor_event_t *)buffer)->data = (sensor_data_t *)buffer_data; + sensor_event->data = reinterpret_cast(buffer_data); handle_events((void *)buffer); } while (true); diff --git a/src/server/sensor_event_dispatcher.cpp b/src/server/sensor_event_dispatcher.cpp index df64e80..b03a5e4 100644 --- a/src/server/sensor_event_dispatcher.cpp +++ b/src/server/sensor_event_dispatcher.cpp @@ -151,10 +151,8 @@ void sensor_event_dispatcher::send_sensor_events(vector &events) for (unsigned int i = 0; i < events.size(); ++i) { sensor_id_t sensor_id; unsigned int event_type; - int length; sensor_event = (sensor_event_t*)events[i]; - length = sizeof(sensor_event_t) + sensor_event->data_length; sensor_id = sensor_event->sensor_id; event_type = sensor_event->event_type; diff --git a/src/server/sensor_loader.cpp b/src/server/sensor_loader.cpp index d8636f1..5626214 100644 --- a/src/server/sensor_loader.cpp +++ b/src/server/sensor_loader.cpp @@ -260,7 +260,7 @@ bool sensor_loader::get_paths_from_dir(const string &dir_path, vector &h string name; - while (dir_entry = readdir(dir)) { + while ((dir_entry = readdir(dir))) { name = string(dir_entry->d_name); if (name == "." || name == "..") diff --git a/src/test/src/sensor-test.c b/src/test/src/sensor-test.c index 9f5310f..823f246 100644 --- a/src/test/src/sensor-test.c +++ b/src/test/src/sensor-test.c @@ -215,7 +215,11 @@ int main(int argc, char **argv) arg.event = event; arg.interval = interval; - return check_sensor((void*)&arg); + void *result = check_sensor((void*)&arg); + if (!result) + return -1; + + return 0; } } -- 2.7.4 From 217c8a4878748fdead8cd868ce5814ec3b9c5e65 Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Tue, 16 Feb 2016 13:06:42 +0900 Subject: [PATCH 10/16] libsensord: Disable deprecated sf_* APIs The functions just return -1. Change-Id: I76a78ca9d2d84affbc43562fd3e37ec604e7525f Signed-off-by: Mu-Woong Lee --- src/client/client.cpp | 92 --------------------------------------- src/client/client_deprecated.cpp | 94 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 92 deletions(-) create mode 100644 src/client/client_deprecated.cpp diff --git a/src/client/client.cpp b/src/client/client.cpp index 3ab4146..cef182c 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -18,7 +18,6 @@ */ #include -#include #include #include #include @@ -1151,94 +1150,3 @@ API bool sensord_get_data(int handle, unsigned int data_id, sensor_data_t* senso return true; } - -/* deprecated APIs */ -API int sf_connect(sensor_type_t sensor_type) -{ - sensor_t sensor; - - sensor = sensord_get_sensor(sensor_type); - - return sensord_connect(sensor); -} - -API int sf_disconnect(int handle) -{ - return sensord_disconnect(handle) ? OP_SUCCESS : OP_ERROR; -} - -API int sf_start(int handle, int option) -{ - return sensord_start(handle, option) ? OP_SUCCESS : OP_ERROR; -} - -API int sf_stop(int handle) -{ - return sensord_stop(handle) ? OP_SUCCESS : OP_ERROR; -} - -API int sf_register_event(int handle, unsigned int event_type, event_condition_t *event_condition, sensor_callback_func_t cb, void *user_data) -{ - unsigned int interval = BASE_GATHERING_INTERVAL; - - if (event_condition != NULL) { - if ((event_condition->cond_op == CONDITION_EQUAL) && (event_condition->cond_value1 > 0)) - interval = event_condition->cond_value1; - } - - return register_event(handle, event_type, interval, 0, SENSOR_LEGACY_CB, (void*) cb, user_data) ? OP_SUCCESS : OP_ERROR; -} - -API int sf_unregister_event(int handle, unsigned int event_type) -{ - return sensord_unregister_event(handle, event_type) ? OP_SUCCESS : OP_ERROR; -} - -API int sf_change_event_condition(int handle, unsigned int event_type, event_condition_t *event_condition) -{ - unsigned int interval = BASE_GATHERING_INTERVAL; - - if (event_condition != NULL) { - if ((event_condition->cond_op == CONDITION_EQUAL) && (event_condition->cond_value1 > 0)) - interval = event_condition->cond_value1; - } - - return sensord_change_event_interval(handle, event_type, interval) ? OP_SUCCESS : OP_ERROR; -} - -API int sf_change_sensor_option(int handle, int option) -{ - return sensord_set_option(handle, option) ? OP_SUCCESS : OP_ERROR; -} - -API int sf_send_sensorhub_data(int handle, const char* data, int data_len) -{ - return sensord_send_sensorhub_data(handle, data, data_len) ? OP_SUCCESS : OP_ERROR; -} - -API int sf_get_data(int handle, unsigned int data_id, sensor_data_t* sensor_data) -{ - return sensord_get_data(handle, data_id, sensor_data) ? OP_SUCCESS : OP_ERROR; -} - -API int sf_check_rotation(unsigned long *rotation) -{ - rotation = 0; - return 0; -} - -API int sf_is_sensor_event_available(sensor_type_t sensor_type, unsigned int event_type) -{ - return 0; -} - -API int sf_get_data_properties(unsigned int data_id, sensor_data_properties_t *return_data_properties) -{ - return 0; -} - -API int sf_get_properties(sensor_type_t sensor_type, sensor_properties_t *return_properties) -{ - return 0; -} - diff --git a/src/client/client_deprecated.cpp b/src/client/client_deprecated.cpp new file mode 100644 index 0000000..38cf33f --- /dev/null +++ b/src/client/client_deprecated.cpp @@ -0,0 +1,94 @@ +/* + * sensord + * + * Copyright (c) 2016 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 + +#ifndef API +#define API __attribute__((visibility("default"))) +#endif + +API int sf_connect(sensor_type_t sensor_type) +{ + return OP_ERROR; +} + +API int sf_disconnect(int handle) +{ + return OP_ERROR; +} + +API int sf_start(int handle, int option) +{ + return OP_ERROR; +} + +API int sf_stop(int handle) +{ + return OP_ERROR; +} + +API int sf_register_event(int handle, unsigned int event_type, event_condition_t *event_condition, sensor_callback_func_t cb, void *user_data) +{ + return OP_ERROR; +} + +API int sf_unregister_event(int handle, unsigned int event_type) +{ + return OP_ERROR; +} + +API int sf_change_event_condition(int handle, unsigned int event_type, event_condition_t *event_condition) +{ + return OP_ERROR; +} + +API int sf_change_sensor_option(int handle, int option) +{ + return OP_ERROR; +} + +API int sf_send_sensorhub_data(int handle, const char* data, int data_len) +{ + return OP_ERROR; +} + +API int sf_get_data(int handle, unsigned int data_id, sensor_data_t* sensor_data) +{ + return OP_ERROR; +} + +API int sf_check_rotation(unsigned long *rotation) +{ + return OP_ERROR; +} + +API int sf_is_sensor_event_available(sensor_type_t sensor_type, unsigned int event_type) +{ + return OP_ERROR; +} + +API int sf_get_data_properties(unsigned int data_id, sensor_data_properties_t *return_data_properties) +{ + return OP_ERROR; +} + +API int sf_get_properties(sensor_type_t sensor_type, sensor_properties_t *return_properties) +{ + return OP_ERROR; +} -- 2.7.4 From 2317e40aad123cefaa4e49e8bc839bb02962eb3b Mon Sep 17 00:00:00 2001 From: "kibak.yoon" Date: Tue, 15 Mar 2016 09:24:19 +0900 Subject: [PATCH 11/16] sensord: remove set_wakeup API and implementations Change-Id: I4ee5cdcbb06d97539fb163f604863722c4a2d10f Signed-off-by: kibak.yoon --- src/client/client.cpp | 34 ------------------ src/client/command_channel.cpp | 39 -------------------- src/client/command_channel.h | 1 - src/client/sensor_client_info.cpp | 32 ----------------- src/client/sensor_client_info.h | 2 -- src/client/sensor_handle_info.cpp | 1 - src/client/sensor_handle_info.h | 1 - src/client/sensor_internal.h | 13 +------ src/server/client_info_manager.cpp | 16 --------- src/server/client_info_manager.h | 1 - src/server/client_sensor_record.cpp | 14 -------- src/server/client_sensor_record.h | 1 - src/server/command_worker.cpp | 31 ---------------- src/server/command_worker.h | 1 - src/server/physical_sensor.cpp | 5 --- src/server/physical_sensor.h | 1 - src/server/sensor_base.cpp | 60 ------------------------------- src/server/sensor_base.h | 8 +---- src/server/sensor_info_list.cpp | 71 ------------------------------------- src/server/sensor_info_list.h | 17 --------- src/server/sensor_usage.cpp | 1 - src/server/sensor_usage.h | 1 - src/server/virtual_sensor.h | 2 -- src/shared/command_common.h | 4 --- src/shared/sensor_common.h | 6 ---- 25 files changed, 2 insertions(+), 361 deletions(-) diff --git a/src/client/client.cpp b/src/client/client.cpp index cef182c..4366792 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -999,40 +999,6 @@ API bool sensord_set_option(int handle, int option) } -API bool sensord_set_wakeup(int handle, int wakeup) -{ - sensor_id_t sensor_id; - command_channel *cmd_channel; - int client_id; - - AUTOLOCK(lock); - - if (!sensor_client_info::get_instance().get_sensor_id(handle, sensor_id)) { - _E("client %s failed to get handle information", get_client_name()); - return false; - } - - retvm_if ((wakeup != SENSOR_WAKEUP_ON) && (wakeup != SENSOR_WAKEUP_OFF), false, "Invalid wakeup value : %d, handle: %d, %s, %s", - wakeup, handle, get_sensor_name(sensor_id), get_client_name()); - - sensor_client_info::get_instance().set_sensor_wakeup(handle, wakeup); - - if (!sensor_client_info::get_instance().get_command_channel(sensor_id, &cmd_channel)) { - _E("client %s failed to get command channel for %s", get_client_name(), get_sensor_name(sensor_id)); - return false; - } - - client_id = sensor_client_info::get_instance().get_client_id(); - retvm_if ((client_id < 0), false, "Invalid client id : %d, handle: %d, %s, %s", client_id, handle, get_sensor_name(sensor_id), get_client_name()); - - if (!cmd_channel->cmd_set_wakeup(wakeup)) { - _E("Sending cmd_set_wakeup(%d, %s, %d) failed for %s", client_id, get_sensor_name(sensor_id), wakeup, get_client_name()); - return false; - } - - return true; -} - API bool sensord_set_attribute_int(int handle, int attribute, int value) { sensor_id_t sensor_id; diff --git a/src/client/command_channel.cpp b/src/client/command_channel.cpp index 4e978a8..d1c91c3 100644 --- a/src/client/command_channel.cpp +++ b/src/client/command_channel.cpp @@ -374,45 +374,6 @@ bool command_channel::cmd_set_option(int option) return true; } -bool command_channel::cmd_set_wakeup(int wakeup) -{ - cpacket *packet; - cmd_set_wakeup_t *cmd_set_wakeup; - cmd_done_t *cmd_done; - - packet = new(std::nothrow) cpacket(sizeof(cmd_set_wakeup_t)); - retvm_if(!packet, false, "Failed to allocate memory"); - - packet->set_cmd(CMD_SET_WAKEUP); - - cmd_set_wakeup = (cmd_set_wakeup_t*)packet->data(); - cmd_set_wakeup->wakeup = wakeup; - - _I("%s send cmd_set_wakeup(client_id=%d, %s, wakeup=%d)", - get_client_name(), m_client_id, get_sensor_name(m_sensor_id), wakeup); - - if (!command_handler(packet, (void **)&cmd_done)) { - _E("Client %s failed to send/receive command for sensor[%s] with client_id [%d], wakeup[%d]", - get_client_name(), get_sensor_name(m_sensor_id), m_client_id, wakeup); - delete packet; - return false; - } - - if (cmd_done->value < 0) { - _E("Client %s got error[%d] from server for sensor[%s] with client_id [%d], wakeup[%d]", - get_client_name(), cmd_done->value, get_sensor_name(m_sensor_id), m_client_id, wakeup); - - delete[] (char *)cmd_done; - delete packet; - return false; - } - - delete[] (char *)cmd_done; - delete packet; - - return true; -} - bool command_channel::cmd_register_event(unsigned int event_type) { cpacket *packet; diff --git a/src/client/command_channel.h b/src/client/command_channel.h index faa3837..b99891b 100644 --- a/src/client/command_channel.h +++ b/src/client/command_channel.h @@ -40,7 +40,6 @@ public: bool cmd_start(void); bool cmd_stop(void); bool cmd_set_option(int option); - bool cmd_set_wakeup(int wakeup); bool cmd_register_event(unsigned int event_type); bool cmd_register_events(event_type_vector &event_vec); bool cmd_unregister_event(unsigned int event_type); diff --git a/src/client/sensor_client_info.cpp b/src/client/sensor_client_info.cpp index 684cd52..ded2acc 100644 --- a/src/client/sensor_client_info.cpp +++ b/src/client/sensor_client_info.cpp @@ -524,38 +524,6 @@ bool sensor_client_info::get_sensor_state(int handle, int &sensor_state) return true; } -bool sensor_client_info::get_sensor_wakeup(int handle, int &sensor_wakeup) -{ - AUTOLOCK(m_handle_info_lock); - - auto it_handle = m_sensor_handle_infos.find(handle); - - if (it_handle == m_sensor_handle_infos.end()) { - _E("Handle[%d] is not found for client %s", handle, get_client_name()); - return false; - } - - sensor_wakeup = it_handle->second.m_sensor_wakeup; - - return true; -} - -bool sensor_client_info::set_sensor_wakeup(int handle, int sensor_wakeup) -{ - AUTOLOCK(m_handle_info_lock); - - auto it_handle = m_sensor_handle_infos.find(handle); - - if (it_handle == m_sensor_handle_infos.end()) { - _E("Handle[%d] is not found for client %s", handle, get_client_name()); - return false; - } - - it_handle->second.m_sensor_wakeup = sensor_wakeup; - - return true; -} - void sensor_client_info::get_active_event_types(sensor_id_t sensor, event_type_vector &active_event_types) { event_type_vector event_types; diff --git a/src/client/sensor_client_info.h b/src/client/sensor_client_info.h index e3869d2..47a4adf 100644 --- a/src/client/sensor_client_info.h +++ b/src/client/sensor_client_info.h @@ -89,8 +89,6 @@ public: bool get_sensor_id(int handle, sensor_id_t &sensor_id); bool get_sensor_state(int handle, int &state); - bool get_sensor_wakeup(int handle, int &sensor_wakeup); - bool set_sensor_wakeup(int handle, int sensor_wakeup); bool has_client_id(void); int get_client_id(void); diff --git a/src/client/sensor_handle_info.cpp b/src/client/sensor_handle_info.cpp index 6d9e429..9ea4d0d 100644 --- a/src/client/sensor_handle_info.cpp +++ b/src/client/sensor_handle_info.cpp @@ -30,7 +30,6 @@ sensor_handle_info::sensor_handle_info() , m_sensor_id(UNKNOWN_SENSOR) , m_sensor_state(SENSOR_STATE_UNKNOWN) , m_sensor_option(SENSOR_OPTION_DEFAULT) -, m_sensor_wakeup(SENSOR_WAKEUP_OFF) , m_bad_accuracy(false) , m_accuracy(-1) , m_accuracy_cb(NULL) diff --git a/src/client/sensor_handle_info.h b/src/client/sensor_handle_info.h index f56da67..fa0fb4c 100644 --- a/src/client/sensor_handle_info.h +++ b/src/client/sensor_handle_info.h @@ -35,7 +35,6 @@ public: sensor_id_t m_sensor_id; int m_sensor_state; int m_sensor_option; - int m_sensor_wakeup; int m_bad_accuracy; int m_accuracy; sensor_accuracy_changed_cb_t m_accuracy_cb; diff --git a/src/client/sensor_internal.h b/src/client/sensor_internal.h index b16e086..94a05b5 100644 --- a/src/client/sensor_internal.h +++ b/src/client/sensor_internal.h @@ -312,18 +312,7 @@ bool sensord_change_event_maincontext(int handle, unsigned int event_type, GMain */ bool sensord_set_option(int handle, int option); -/** - * @brief Change the wakeup mode of a connected sensor. - * - * @param[in] handle a handle represensting a connected sensor. - * @param[in] wakeup either one of SENSOR_WAKEUP_OFF and SENSOR_WAKEUP_ON. - * with SENSOR_WAKEUP_OFF, it stops to listening events when AP is asleep. - * with SENSOR_WAKEUP_ON, it continues to listening events even when AP is asleep. - * @return true on success, otherwise false. - */ -bool sensord_set_wakeup(int handle, int wakeup); - -/** +/* * @brief Set the attribute to a connected sensor * * @param[in] handle a handle represensting a connected sensor. diff --git a/src/server/client_info_manager.cpp b/src/server/client_info_manager.cpp index 068778b..536f164 100644 --- a/src/server/client_info_manager.cpp +++ b/src/server/client_info_manager.cpp @@ -136,22 +136,6 @@ bool client_info_manager::set_option(int client_id, sensor_id_t sensor_id, int o return true; } -bool client_info_manager::set_wakeup(int client_id, sensor_id_t sensor_id, int wakeup) -{ - AUTOLOCK(m_mutex); - - auto it_record = m_clients.find(client_id); - - if (it_record == m_clients.end()) { - _E("Client[%d] is not found", client_id); - return false; - } - - if(!it_record->second.set_wakeup(sensor_id, wakeup)) - return false; - - return true; -} bool client_info_manager::set_start(int client_id, sensor_id_t sensor_id, bool start) { diff --git a/src/server/client_info_manager.h b/src/server/client_info_manager.h index 7a9dde6..e790534 100644 --- a/src/server/client_info_manager.h +++ b/src/server/client_info_manager.h @@ -53,7 +53,6 @@ public: 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_wakeup(int client_id, sensor_id_t sensor_id, int wakeup); bool set_start(int client_id, sensor_id_t sensor_id, bool start); bool is_started(int client_id, sensor_id_t sensor_id); diff --git a/src/server/client_sensor_record.cpp b/src/server/client_sensor_record.cpp index c7ee8e1..58fde54 100644 --- a/src/server/client_sensor_record.cpp +++ b/src/server/client_sensor_record.cpp @@ -88,20 +88,6 @@ bool client_sensor_record::set_option(sensor_id_t sensor_id, int option) return true; } -bool client_sensor_record::set_wakeup(sensor_id_t sensor_id, int wakeup) -{ - auto it_usage = m_sensor_usages.find(sensor_id); - - if (it_usage == m_sensor_usages.end()) { - sensor_usage usage; - usage.m_wakeup = wakeup; - m_sensor_usages.insert(pair(sensor_id, usage)); - } else { - it_usage->second.m_wakeup = wakeup; - } - - return true; -} bool client_sensor_record::set_start(sensor_id_t sensor_id, bool start) { diff --git a/src/server/client_sensor_record.h b/src/server/client_sensor_record.h index 9386507..defc3d9 100644 --- a/src/server/client_sensor_record.h +++ b/src/server/client_sensor_record.h @@ -48,7 +48,6 @@ public: 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_wakeup(sensor_id_t sensor_id, int wakeup); bool set_start(sensor_id_t sensor_id, bool start); bool is_started(sensor_id_t sensor_id); diff --git a/src/server/command_worker.cpp b/src/server/command_worker.cpp index 0423eab..b99ba0f 100644 --- a/src/server/command_worker.cpp +++ b/src/server/command_worker.cpp @@ -82,7 +82,6 @@ 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_WAKEUP] = &command_worker::cmd_set_wakeup; 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_GET_DATA] = &command_worker::cmd_get_data; @@ -698,36 +697,6 @@ out: return true; } -bool command_worker::cmd_set_wakeup(void *payload) -{ - cmd_set_wakeup_t *cmd; - long ret_value = OP_ERROR; - - cmd = (cmd_set_wakeup_t*)payload; - - if (!is_permission_allowed()) { - _E("Permission denied to set wakeup for client [%d], for sensor [0x%llx] with wakeup [%d] to client info manager", - m_client_id, m_sensor_id, cmd->wakeup); - ret_value = OP_ERROR; - goto out; - } - - if (!get_client_info_manager().set_wakeup(m_client_id, m_sensor_id, cmd->wakeup)) { - _E("Failed to set wakeup for client [%d], for sensor [0x%llx] with wakeup [%d] to client info manager", - m_client_id, m_sensor_id, cmd->wakeup); - ret_value = OP_ERROR; - goto out; - } - - ret_value = m_module->add_wakeup(m_client_id, cmd->wakeup); - -out: - if (!send_cmd_done(ret_value)) - _E("Failed to send cmd_done to a client"); - - return true; -} - bool command_worker::cmd_get_data(void *payload) { const unsigned int GET_DATA_MIN_INTERVAL = 10; diff --git a/src/server/command_worker.h b/src/server/command_worker.h index d03d4a3..c3ce538 100644 --- a/src/server/command_worker.h +++ b/src/server/command_worker.h @@ -70,7 +70,6 @@ private: bool cmd_set_batch(void *payload); bool cmd_unset_batch(void *payload); bool cmd_set_option(void *payload); - bool cmd_set_wakeup(void *payload); bool cmd_get_data(void *payload); bool cmd_set_attribute_int(void *payload); bool cmd_set_attribute_str(void *payload); diff --git a/src/server/physical_sensor.cpp b/src/server/physical_sensor.cpp index 83efec8..49858f4 100644 --- a/src/server/physical_sensor.cpp +++ b/src/server/physical_sensor.cpp @@ -172,11 +172,6 @@ int physical_sensor::set_attribute(int32_t attribute, char *value, int value_len return OP_SUCCESS; } -bool physical_sensor::set_wakeup(int wakeup) -{ - return false; -} - bool physical_sensor::on_start() { AUTOLOCK(m_mutex); diff --git a/src/server/physical_sensor.h b/src/server/physical_sensor.h index a35edc8..7bad87d 100644 --- a/src/server/physical_sensor.h +++ b/src/server/physical_sensor.h @@ -54,7 +54,6 @@ private: virtual bool set_batch_latency(unsigned long latency); virtual int set_attribute(int32_t attribute, int32_t value); virtual int set_attribute(int32_t attribute, char *value, int value_len); - virtual bool set_wakeup(int wakeup); virtual bool on_start(void); virtual bool on_stop(void); virtual bool get_sensor_info(sensor_info &info); diff --git a/src/server/sensor_base.cpp b/src/server/sensor_base.cpp index 4fefeff..f339533 100644 --- a/src/server/sensor_base.cpp +++ b/src/server/sensor_base.cpp @@ -266,61 +266,6 @@ unsigned int sensor_base::get_batch(int client_id) return m_sensor_info_list.get_batch(client_id); } -bool sensor_base::add_wakeup(int client_id, int wakeup) -{ - int prev_wakeup, cur_wakeup; - - AUTOLOCK(m_sensor_info_list_mutex); - - prev_wakeup = m_sensor_info_list.is_wakeup_on(); - - if (!m_sensor_info_list.add_wakeup(client_id, wakeup)) - return false; - - cur_wakeup = m_sensor_info_list.is_wakeup_on(); - - if ((cur_wakeup == SENSOR_WAKEUP_ON) && (prev_wakeup < SENSOR_WAKEUP_ON)) { - _I("Wakeup for sensor[0x%llx] is changed from %d to %d by client[%d] adding wakeup", - get_id(), prev_wakeup, cur_wakeup, client_id); - set_wakeup(SENSOR_WAKEUP_ON); - } - - return true; -} - -bool sensor_base::delete_wakeup(int client_id) -{ - int prev_wakeup, cur_wakeup; - AUTOLOCK(m_sensor_info_list_mutex); - - prev_wakeup = m_sensor_info_list.is_wakeup_on(); - - if (!m_sensor_info_list.delete_wakeup(client_id)) - return false; - - cur_wakeup = m_sensor_info_list.is_wakeup_on(); - - if ((cur_wakeup < SENSOR_WAKEUP_ON) && (prev_wakeup == SENSOR_WAKEUP_ON)) { - _I("Wakeup for sensor[0x%llx] is changed from %d to %d by client[%d] deleting wakeup", - get_id(), prev_wakeup, cur_wakeup, client_id); - set_wakeup(SENSOR_WAKEUP_OFF); - } - - return true; -} - -int sensor_base::get_wakeup(int client_id) -{ - AUTOLOCK(m_sensor_info_list_mutex); - - return m_sensor_info_list.is_wakeup_on(); -} - -bool sensor_base::is_wakeup_supported(void) -{ - return false; -} - int sensor_base::get_permission(void) { return m_permission; @@ -352,11 +297,6 @@ bool sensor_base::set_batch_latency(unsigned long latency) return false; } -bool sensor_base::set_wakeup(int wakeup) -{ - return false; -} - bool sensor_base::on_start() { return false; diff --git a/src/server/sensor_base.h b/src/server/sensor_base.h index 0260119..95ea6c5 100644 --- a/src/server/sensor_base.h +++ b/src/server/sensor_base.h @@ -60,7 +60,7 @@ public: bool stop(void); bool is_started(void); - /* interval / batch / wakeup */ + /* interval / batch */ virtual bool add_interval(int client_id, unsigned int interval, bool is_processor); virtual bool delete_interval(int client_id, bool is_processor); unsigned int get_interval(int client_id, bool is_processor); @@ -69,11 +69,6 @@ public: virtual bool delete_batch(int client_id); unsigned int get_batch(int client_id); - virtual bool add_wakeup(int client_id, int wakeup); - virtual bool delete_wakeup(int client_id); - int get_wakeup(int client_id); - bool is_wakeup_supported(void); - bool push(sensor_event_t *event); /* permission(privilege) */ @@ -95,7 +90,6 @@ private: virtual bool set_interval(unsigned long interval); virtual bool set_batch_latency(unsigned long latency); - virtual bool set_wakeup(int wakeup); virtual bool on_start(void); virtual bool on_stop(void); diff --git a/src/server/sensor_info_list.cpp b/src/server/sensor_info_list.cpp index 21e6f62..8cbc879 100644 --- a/src/server/sensor_info_list.cpp +++ b/src/server/sensor_info_list.cpp @@ -33,12 +33,6 @@ batch_info::batch_info(int client_id, unsigned int latency) this->latency = latency; } -wakeup_info::wakeup_info(int client_id, int wakeup) -{ - this->client_id = client_id; - this->wakeup = wakeup; -} - bool sensor_info_list::comp_interval_info(interval_info a, interval_info b) { return a.interval < b.interval; @@ -77,20 +71,6 @@ batch_info_iterator sensor_info_list::find_if_batch_info(int client_id) return iter; } -wakeup_info_iterator sensor_info_list::find_if_wakeup_info(int client_id) -{ - auto iter = m_wakeup_info_list.begin(); - - while (iter != m_wakeup_info_list.end()) { - if (iter->client_id == client_id) - break; - - ++iter; - } - - return iter; -} - bool sensor_info_list::add_interval(int client_id, unsigned int interval, bool is_processor) { auto iter = find_if_interval_info(client_id, is_processor); @@ -179,54 +159,3 @@ unsigned int sensor_info_list::get_max_batch(void) return iter->latency; } -bool sensor_info_list::add_wakeup(int client_id, int wakeup) -{ - auto iter = find_if_wakeup_info(client_id); - - if (iter != m_wakeup_info_list.end()) - *iter = wakeup_info(client_id, wakeup); - else - m_wakeup_info_list.push_back(wakeup_info(client_id, wakeup)); - - return true; -} - -bool sensor_info_list::delete_wakeup(int client_id) -{ - auto iter = find_if_wakeup_info(client_id); - - if (iter == m_wakeup_info_list.end()) - return false; - - m_wakeup_info_list.erase(iter); - - return true; -} - -int sensor_info_list::get_wakeup(int client_id) -{ - auto iter = find_if_wakeup_info(client_id); - - if (iter == m_wakeup_info_list.end()) - return -1; - - return iter->wakeup; -} - -int sensor_info_list::is_wakeup_on(void) -{ - if (m_wakeup_info_list.empty()) - return -1; - - auto iter = m_wakeup_info_list.begin(); - - while (iter != m_wakeup_info_list.end()) { - if (iter->wakeup == true) - break; - - ++iter; - } - - return iter->wakeup; -} - diff --git a/src/server/sensor_info_list.h b/src/server/sensor_info_list.h index fc253aa..0edb0fa 100644 --- a/src/server/sensor_info_list.h +++ b/src/server/sensor_info_list.h @@ -41,15 +41,6 @@ public: typedef std::list::iterator batch_info_iterator; -class wakeup_info { -public: - wakeup_info(int client_id, int wakeup); - int client_id; - int wakeup; -}; - -typedef std::list::iterator wakeup_info_iterator; - class sensor_info_list { public: bool add_interval(int client_id, unsigned int interval, bool is_processor); @@ -62,11 +53,6 @@ public: unsigned int get_batch(int client_id); unsigned int get_max_batch(void); - bool add_wakeup(int client_id, int wakeup); - bool delete_wakeup(int client_id); - int get_wakeup(int client_id); - int is_wakeup_on(void); - private: static bool comp_interval_info(interval_info a, interval_info b); interval_info_iterator find_if_interval_info(int client_id, bool is_processor); @@ -74,10 +60,7 @@ private: static bool comp_batch_info(batch_info a, batch_info b); batch_info_iterator find_if_batch_info(int client_id); - wakeup_info_iterator find_if_wakeup_info(int client_id); - std::list m_interval_info_list; std::list m_batch_info_list; - std::list m_wakeup_info_list; }; #endif /* _SENSOR_INFO_LIST_H_ */ diff --git a/src/server/sensor_usage.cpp b/src/server/sensor_usage.cpp index 8f4e758..4b6c881 100644 --- a/src/server/sensor_usage.cpp +++ b/src/server/sensor_usage.cpp @@ -26,7 +26,6 @@ sensor_usage::sensor_usage() : m_interval(POLL_MAX_HZ_MS) , m_latency(0) , m_option(SENSOR_OPTION_DEFAULT) -, m_wakeup(SENSOR_WAKEUP_OFF) , m_start(false) { diff --git a/src/server/sensor_usage.h b/src/server/sensor_usage.h index f13018d..91c4571 100644 --- a/src/server/sensor_usage.h +++ b/src/server/sensor_usage.h @@ -30,7 +30,6 @@ public: unsigned int m_interval; unsigned int m_latency; int m_option; - int m_wakeup; reg_event_vector m_reg_events; bool m_start; diff --git a/src/server/virtual_sensor.h b/src/server/virtual_sensor.h index a0adbcc..a1d4363 100644 --- a/src/server/virtual_sensor.h +++ b/src/server/virtual_sensor.h @@ -52,8 +52,6 @@ protected: private: virtual bool set_interval(unsigned long interval) = 0; virtual bool set_batch_latency(unsigned long latency) = 0; - virtual bool set_wakeup(int wakeup) = 0; - virtual bool on_start(void) = 0; virtual bool on_stop(void) = 0; }; diff --git a/src/shared/command_common.h b/src/shared/command_common.h index bb67f70..0e2a5ac 100644 --- a/src/shared/command_common.h +++ b/src/shared/command_common.h @@ -41,7 +41,6 @@ enum packet_type_t { CMD_REG, CMD_UNREG, CMD_SET_OPTION, - CMD_SET_WAKEUP, CMD_SET_BATCH, CMD_UNSET_BATCH, CMD_GET_DATA, @@ -115,9 +114,6 @@ typedef struct { int option; } cmd_set_option_t; -typedef struct { - int wakeup; -} cmd_set_wakeup_t; typedef struct { int attribute; diff --git a/src/shared/sensor_common.h b/src/shared/sensor_common.h index 7ba2a89..40b95b8 100644 --- a/src/shared/sensor_common.h +++ b/src/shared/sensor_common.h @@ -71,12 +71,6 @@ enum sensor_option_t { typedef enum sensor_option_t sensor_option_e; #endif -enum sensor_wakeup_t { - SENSOR_WAKEUP_UNKNOWN = -1, - SENSOR_WAKEUP_OFF = 0, - SENSOR_WAKEUP_ON = 1, -}; - enum poll_interval_t { POLL_100HZ_MS = 10, POLL_50HZ_MS = 20, -- 2.7.4 From cac600307aea5d48f6e073eece3dc9b3e8ce318e Mon Sep 17 00:00:00 2001 From: "kibak.yoon" Date: Tue, 15 Mar 2016 09:58:54 +0900 Subject: [PATCH 12/16] hal: add/sync sensor device types Change-Id: I5b0b6eb2a5cdc9e81be1b2e47a24864c4400fc9a Signed-off-by: kibak.yoon --- src/hal/sensor_hal.h | 54 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 10 deletions(-) diff --git a/src/hal/sensor_hal.h b/src/hal/sensor_hal.h index 8d89f75..c52f25d 100644 --- a/src/hal/sensor_hal.h +++ b/src/hal/sensor_hal.h @@ -21,8 +21,8 @@ #include #include -#define SENSOR_HAL_VERSION(maj,min) \ - ((((maj) & 0xffff) << 24) | ((min) & 0xffff)) +#define SENSOR_HAL_VERSION(maj, min) \ + ((((maj) & 0xFFFF) << 24) | ((min) & 0xFFFF)) #ifdef __cplusplus extern "C" @@ -74,6 +74,7 @@ typedef enum { SENSOR_DEVICE_FUSION = 0x900, SENSOR_DEVICE_AUTO_ROTATION, + SENSOR_DEVICE_AUTO_BRIGHTNESS, SENSOR_DEVICE_CONTEXT = 0x1000, SENSOR_DEVICE_MOTION, @@ -86,16 +87,33 @@ typedef enum { SENSOR_DEVICE_HRM_RAW, SENSOR_DEVICE_TILT, SENSOR_DEVICE_ROTATION_VECTOR_RAW, - - SENSOR_DEVICE_ACTIVITY_STATIONARY = 0x1100, - SENSOR_DEVICE_ACTIVITY_WALK, - SENSOR_DEVICE_ACTIVITY_RUN, - SENSOR_DEVICE_ACTIVITY_IN_VEHICLE, - SENSOR_DEVICE_ACTIVITY_ON_BICYCLE, + SENSOR_DEVICE_EXERCISE, + SENSOR_DEVICE_GSR, + SENSOR_DEVICE_SIMSENSE, + SENSOR_DEVICE_PPG, SENSOR_DEVICE_GESTURE_MOVEMENT = 0x1200, SENSOR_DEVICE_GESTURE_WRIST_UP, SENSOR_DEVICE_GESTURE_WRIST_DOWN, + SENSOR_DEVICE_GESTURE_MOVEMENT_STATE, + + SENSOR_DEVICE_WEAR_STATUS = 0x1A00, + SENSOR_DEVICE_WEAR_ON_MONITOR, + SENSOR_DEVICE_GPS_BATCH, + SENSOR_DEVICE_ACTIVITY_TRACKER, + SENSOR_DEVICE_SLEEP_DETECTOR, + SENSOR_DEVICE_NO_MOVE_DETECTOR = 0x1A80, + SENSOR_DEVICE_HRM_CTRL, + SENSOR_DEVICE_EXERCISE_COACH, + SENSOR_DEVICE_EXERCISE_HR, + SENSOR_DEVICE_RESTING_HR, + SENSOR_DEVICE_STEP_LEVEL_MONITOR, + SENSOR_DEVICE_ACTIVITY_LEVEL_MONITOR, + SENSOR_DEVICE_CYCLE_MONITOR, + SENSOR_DEVICE_STRESS_MONITOR, + SENSOR_DEVICE_AUTOSESSION_EXERCISE, + SENSOR_DEVICE_STAIR_TRACKER, + } sensor_device_type; /* @@ -141,8 +159,24 @@ typedef struct sensor_data_t { typedef struct sensorhub_data_t { int accuracy; unsigned long long timestamp; - int value_count; - char values[SENSORHUB_DATA_VALUE_SIZE]; + + /* + * Use "value_count" instead of "hub_data_size" + * which is going to be removed soon + */ + union { + int value_count; + int hub_data_size; /* deprecated */ + }; + + /* + * Use "values" instead of "hub_data" + * which is going to be removed soon + */ + union { + char values[SENSORHUB_DATA_VALUE_SIZE]; + char hub_data[SENSORHUB_DATA_VALUE_SIZE]; /* deprecated */ + }; } sensorhub_data_t; /* -- 2.7.4 From 0e91f9a6b372f3cfb7a2881d4303f2e7a93d38b8 Mon Sep 17 00:00:00 2001 From: "kibak.yoon" Date: Tue, 15 Mar 2016 11:33:20 +0900 Subject: [PATCH 13/16] sensord: sync/clean up sensord source code Change-Id: I3fa2c377700e828443ec747e226f89c6249d541f Signed-off-by: kibak.yoon --- src/client/CMakeLists.txt | 2 +- src/client/client.cpp | 6 +++--- src/client/client_common.h | 1 + src/client/sensor_event_listener.cpp | 12 ++---------- src/client/sensor_event_listener.h | 1 - src/client/sensor_handle_info.cpp | 2 +- src/server/command_worker.cpp | 4 ++-- src/server/physical_sensor.h | 14 ++++++++------ src/server/sensor_event_dispatcher.cpp | 4 ++-- src/server/sensor_event_poller.cpp | 5 ++++- src/server/sensor_loader.cpp | 4 ++-- src/server/sensor_usage.cpp | 2 +- src/shared/command_common.h | 4 ++-- 13 files changed, 29 insertions(+), 32 deletions(-) diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt index 0ad7db0..2f32b9c 100644 --- a/src/client/CMakeLists.txt +++ b/src/client/CMakeLists.txt @@ -1,7 +1,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(sensor CXX) -SET(DEPENDENTS "vconf glib-2.0 dlog") +SET(DEPENDENTS "vconf glib-2.0 gio-2.0 dlog") SET(VERSION ${FULLVER}) SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(EXEC_PREFIX "${CMAKE_INSTALL_PREFIX}/bin") diff --git a/src/client/client.cpp b/src/client/client.cpp index 4366792..0a3024e 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -18,6 +18,7 @@ */ #include +#include #include #include #include @@ -543,7 +544,7 @@ API int sensord_connect(sensor_t sensor) atexit(good_bye); handle = sensor_client_info::get_instance().create_handle(sensor_id); - if (handle == MAX_HANDLE_REACHED) { + if (handle == MAX_HANDLE) { _E("Maximum number of handles reached, sensor: %s in client %s", get_sensor_name(sensor_id), get_client_name()); return OP_ERROR; } @@ -1108,11 +1109,10 @@ API bool sensord_get_data(int handle, unsigned int data_id, sensor_data_t* senso return false; } - if(!cmd_channel->cmd_get_data(data_id, sensor_data)) { + if (!cmd_channel->cmd_get_data(data_id, sensor_data)) { _E("cmd_get_data(%d, %d, 0x%x) failed for %s", client_id, data_id, sensor_data, get_client_name()); return false; } return true; - } diff --git a/src/client/client_common.h b/src/client/client_common.h index 8b5ec8e..ff6eb2c 100644 --- a/src/client/client_common.h +++ b/src/client/client_common.h @@ -27,6 +27,7 @@ #include #define BASE_GATHERING_INTERVAL 100 + #define CLIENT_NAME_SIZE NAME_MAX+10 struct log_attr { diff --git a/src/client/sensor_event_listener.cpp b/src/client/sensor_event_listener.cpp index 778392d..c71b9cd 100644 --- a/src/client/sensor_event_listener.cpp +++ b/src/client/sensor_event_listener.cpp @@ -47,14 +47,6 @@ sensor_event_listener::~sensor_event_listener() stop_event_listener(); } -sensor_event_listener::sensor_event_listener(const sensor_event_listener& listener) -: m_poller(listener.m_poller) -, m_thread_state(listener.m_thread_state) -, m_hup_observer(listener.m_hup_observer) -, m_client_info(listener.m_client_info) -{ -} - sensor_event_listener& sensor_event_listener::get_instance(void) { static sensor_event_listener inst; @@ -409,7 +401,7 @@ void sensor_event_listener::listen_events(void) bool sensor_event_listener::create_event_channel(void) { int client_id; - event_channel_ready_t event_channel_ready; + channel_ready_t event_channel_ready; if (!m_event_socket.create(SOCK_SEQPACKET)) return false; @@ -437,7 +429,7 @@ bool sensor_event_listener::create_event_channel(void) return false; } - if ((event_channel_ready.magic != EVENT_CHANNEL_MAGIC) || (event_channel_ready.client_id != client_id)) { + if ((event_channel_ready.magic != CHANNEL_MAGIC_NUM) || (event_channel_ready.client_id != client_id)) { _E("Event_channel_ready packet is wrong, magic = 0x%x, client id = %d", event_channel_ready.magic, event_channel_ready.client_id); return false; diff --git a/src/client/sensor_event_listener.h b/src/client/sensor_event_listener.h index 4af7092..fa7b77e 100644 --- a/src/client/sensor_event_listener.h +++ b/src/client/sensor_event_listener.h @@ -102,7 +102,6 @@ private: sensor_event_listener(); ~sensor_event_listener(); - sensor_event_listener(const sensor_event_listener&); sensor_event_listener& operator=(const sensor_event_listener&); bool create_event_channel(void); diff --git a/src/client/sensor_handle_info.cpp b/src/client/sensor_handle_info.cpp index 9ea4d0d..796107f 100644 --- a/src/client/sensor_handle_info.cpp +++ b/src/client/sensor_handle_info.cpp @@ -149,7 +149,7 @@ void sensor_handle_info::get_batch(unsigned int &interval, unsigned int &latency { if (m_reg_event_infos.empty()) { _D("No events are registered for client %s", get_client_name()); - interval = POLL_MAX_HZ_MS; + interval = POLL_1HZ_MS; latency = 0; return; } diff --git a/src/server/command_worker.cpp b/src/server/command_worker.cpp index b99ba0f..c8804d7 100644 --- a/src/server/command_worker.cpp +++ b/src/server/command_worker.cpp @@ -772,7 +772,7 @@ bool command_worker::cmd_set_attribute_int(void *payload) cmd = (cmd_set_attribute_int_t*)payload; if (!is_permission_allowed()) { - _E("Permission denied to set command for client [%d], for sensor [0x%llx] with attribute [%d]", + _E("Permission denied to set attribute for client [%d], for sensor [0x%llx] with attribute [%d]", m_client_id, m_sensor_id, cmd->attribute); ret_value = OP_ERROR; goto out; @@ -797,7 +797,7 @@ bool command_worker::cmd_set_attribute_str(void *payload) cmd = (cmd_set_attribute_str_t*)payload; if (!is_permission_allowed()) { - _E("Permission denied to send sensorhub_data for client [%d], for sensor [0x%llx]", + _E("Permission denied to set attribute for client [%d], for sensor [0x%llx]", m_client_id, m_sensor_id); ret_value = OP_ERROR; goto out; diff --git a/src/server/physical_sensor.h b/src/server/physical_sensor.h index 7bad87d..a2e8763 100644 --- a/src/server/physical_sensor.h +++ b/src/server/physical_sensor.h @@ -43,20 +43,22 @@ public: virtual bool read_fd(std::vector &ids); virtual int get_data(sensor_data_t **data, int *length); virtual bool flush(void); -private: - static cmutex m_mutex; +protected: const sensor_info_t *m_info; sensor_device *m_sensor_device; uint32_t hal_id; - virtual bool set_interval(unsigned long interval); - virtual bool set_batch_latency(unsigned long latency); - virtual int set_attribute(int32_t attribute, int32_t value); - virtual int set_attribute(int32_t attribute, char *value, int value_len); virtual bool on_start(void); virtual bool on_stop(void); + virtual int set_attribute(int32_t attribute, int32_t value); + virtual int set_attribute(int32_t attribute, char *value, int value_len); + virtual bool set_interval(unsigned long interval); + virtual bool set_batch_latency(unsigned long latency); virtual bool get_sensor_info(sensor_info &info); + +private: + static cmutex m_mutex; }; #endif /* _PHYSICAL_SENSOR_H_ */ diff --git a/src/server/sensor_event_dispatcher.cpp b/src/server/sensor_event_dispatcher.cpp index b03a5e4..977a657 100644 --- a/src/server/sensor_event_dispatcher.cpp +++ b/src/server/sensor_event_dispatcher.cpp @@ -53,7 +53,7 @@ bool sensor_event_dispatcher::run(void) void sensor_event_dispatcher::accept_event_channel(csocket client_socket) { int client_id; - event_channel_ready_t event_channel_ready; + channel_ready_t event_channel_ready; client_info_manager& client_info_manager = get_client_info_manager(); client_socket.set_connection_mode(); @@ -71,7 +71,7 @@ void sensor_event_dispatcher::accept_event_channel(csocket client_socket) return; } - event_channel_ready.magic = EVENT_CHANNEL_MAGIC; + event_channel_ready.magic = CHANNEL_MAGIC_NUM; event_channel_ready.client_id = client_id; _I("Event channel is accepted for %s on socket[%d]", diff --git a/src/server/sensor_event_poller.cpp b/src/server/sensor_event_poller.cpp index 0063871..af7d8cd 100644 --- a/src/server/sensor_event_poller.cpp +++ b/src/server/sensor_event_poller.cpp @@ -131,8 +131,11 @@ bool sensor_event_poller::process_event(int fd, const std::vector &ids while (remains > 0) { event = (sensor_event_t *)malloc(sizeof(sensor_event_t)); - remains = sensor->get_data(&data, &data_length); + if (remains < 0) { + _E("Failed to get sensor data"); + break; + } event->sensor_id = sensor->get_id(); event->event_type = sensor->get_event_type(); diff --git a/src/server/sensor_loader.cpp b/src/server/sensor_loader.cpp index 5626214..a050df7 100644 --- a/src/server/sensor_loader.cpp +++ b/src/server/sensor_loader.cpp @@ -141,9 +141,9 @@ void sensor_loader::create_physical_sensors(sensor_type_t type) physical_sensor *sensor; sensor_device *device; - sensor_device_map_t::iterator it = m_devices.begin(); + sensor_device_map_t::iterator it; - for (sensor_device_map_t::iterator it = m_devices.begin(); it != m_devices.end(); ++it) { + for (it = m_devices.begin(); it != m_devices.end(); ++it) { info = it->first; device = it->second; if (m_devices[info] == NULL) diff --git a/src/server/sensor_usage.cpp b/src/server/sensor_usage.cpp index 4b6c881..83ead8d 100644 --- a/src/server/sensor_usage.cpp +++ b/src/server/sensor_usage.cpp @@ -23,7 +23,7 @@ #include sensor_usage::sensor_usage() -: m_interval(POLL_MAX_HZ_MS) +: m_interval(POLL_1HZ_MS) , m_latency(0) , m_option(SENSOR_OPTION_DEFAULT) , m_start(false) diff --git a/src/shared/command_common.h b/src/shared/command_common.h index 0e2a5ac..48dd750 100644 --- a/src/shared/command_common.h +++ b/src/shared/command_common.h @@ -126,12 +126,12 @@ typedef struct { char value[0]; } cmd_set_attribute_str_t; -#define EVENT_CHANNEL_MAGIC 0xCAFECAFE +#define CHANNEL_MAGIC_NUM 0xCAFECAFE typedef struct { unsigned int magic; int client_id; -} event_channel_ready_t; +} channel_ready_t; typedef void *(*cmd_func_t)(void *data, void *cb_data); -- 2.7.4 From 46f32216111080aa6ac4c0e7875d0a30d72ffd88 Mon Sep 17 00:00:00 2001 From: "kibak.yoon" Date: Tue, 15 Mar 2016 11:39:53 +0900 Subject: [PATCH 14/16] sensord: add sensord_flush internal API for batching Change-Id: I9ce1ec8259b7c592ce269451a74a9a018ee5700f Signed-off-by: kibak.yoon --- src/client/client.cpp | 36 ++++++++++++++++++++++++++++++++++++ src/client/command_channel.cpp | 33 +++++++++++++++++++++++++++++++++ src/client/command_channel.h | 2 ++ src/client/sensor_internal.h | 14 ++++++++++++++ src/server/command_worker.cpp | 29 +++++++++++++++++++++++++++++ src/server/command_worker.h | 1 + src/shared/command_common.h | 4 ++++ 7 files changed, 119 insertions(+) diff --git a/src/client/client.cpp b/src/client/client.cpp index 0a3024e..fcd4c0c 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -1116,3 +1116,39 @@ API bool sensord_get_data(int handle, unsigned int data_id, sensor_data_t* senso return true; } + +API bool sensord_flush(int handle) +{ + sensor_id_t sensor_id; + command_channel *cmd_channel; + int sensor_state; + int client_id; + + AUTOLOCK(lock); + + if (!sensor_client_info::get_instance().get_sensor_state(handle, sensor_state) || + !sensor_client_info::get_instance().get_sensor_id(handle, sensor_id)) { + _E("client %s failed to get handle information", get_client_name()); + return false; + } + + if (!sensor_client_info::get_instance().get_command_channel(sensor_id, &cmd_channel)) { + _E("client %s failed to get command channel for %s", get_client_name(), get_sensor_name(sensor_id)); + return false; + } + + client_id = sensor_client_info::get_instance().get_client_id(); + retvm_if ((client_id < 0), false, "Invalid client id : %d, handle: %d, %s, %s", client_id, handle, get_sensor_name(sensor_id), get_client_name()); + + if (sensor_state != SENSOR_STATE_STARTED) { + _E("Sensor %s is not started for client %s with handle: %d, sensor_state: %d", get_sensor_name(sensor_id), get_client_name(), handle, sensor_state); + return false; + } + + if (!cmd_channel->cmd_flush()) { + _E("cmd_flush() failed for %s", get_client_name()); + return false; + } + + return true; +} \ No newline at end of file diff --git a/src/client/command_channel.cpp b/src/client/command_channel.cpp index d1c91c3..ca6b025 100644 --- a/src/client/command_channel.cpp +++ b/src/client/command_channel.cpp @@ -684,3 +684,36 @@ bool command_channel::cmd_set_attribute_str(int attribute, const char* value, in delete packet; return true; } + +bool command_channel::cmd_flush(void) +{ + cpacket *packet; + cmd_done_t *cmd_done; + + packet = new(std::nothrow) cpacket(sizeof(cmd_flush_t)); + retvm_if(!packet, false, "Failed to allocate memory"); + + packet->set_cmd(CMD_FLUSH); + + _I("%s send cmd_flush(client_id=%d)", get_client_name(), m_client_id); + + if (!command_handler(packet, (void **)&cmd_done)) { + _E("%s failed to send flush with client_id [%d]", + get_client_name(), m_client_id); + delete packet; + return false; + } + + if (cmd_done->value < 0) { + _E("%s got error[%d] from server with client_id [%d]", + get_client_name(), cmd_done->value, m_client_id); + + delete [] (char *)cmd_done; + delete packet; + return false; + } + + delete [] (char *)cmd_done; + delete packet; + return true; +} diff --git a/src/client/command_channel.h b/src/client/command_channel.h index b99891b..15b579e 100644 --- a/src/client/command_channel.h +++ b/src/client/command_channel.h @@ -49,6 +49,8 @@ public: bool cmd_get_data(unsigned int type, sensor_data_t *values); bool cmd_set_attribute_int(int attribute, int value); bool cmd_set_attribute_str(int attribute, const char *value, int value_len); + bool cmd_flush(void); + private: csocket m_command_socket; int m_client_id; diff --git a/src/client/sensor_internal.h b/src/client/sensor_internal.h index 94a05b5..cd1db11 100644 --- a/src/client/sensor_internal.h +++ b/src/client/sensor_internal.h @@ -355,6 +355,20 @@ bool sensord_send_command(int handle, const char *command, int command_len); bool sensord_get_data(int handle, unsigned int data_id, sensor_data_t* sensor_data); /** + * @brief flush sensor data from a connected sensor + * + * @param[in] handle a handle represensting a connected context sensor. + * @return true on success, otherwise false. + */ +bool sensord_flush(int handle); + +typedef void (*sensor_external_command_cb_t)(int handle, const char* data, int data_cnt, void *user_data); + +int sensord_external_connect(const char *key, sensor_external_command_cb_t cb, void *user_data); +bool sensord_external_disconnect(int handle); +bool sensord_external_post(int handle, unsigned long long timestamp, const float* data, int data_cnt); + +/** * @} */ diff --git a/src/server/command_worker.cpp b/src/server/command_worker.cpp index c8804d7..1f87342 100644 --- a/src/server/command_worker.cpp +++ b/src/server/command_worker.cpp @@ -87,6 +87,7 @@ void command_worker::init_cmd_handlers(void) m_cmd_handlers[CMD_GET_DATA] = &command_worker::cmd_get_data; m_cmd_handlers[CMD_SET_ATTRIBUTE_INT] = &command_worker::cmd_set_attribute_int; m_cmd_handlers[CMD_SET_ATTRIBUTE_STR] = &command_worker::cmd_set_attribute_str; + m_cmd_handlers[CMD_FLUSH] = &command_worker::cmd_flush; } void command_worker::get_sensor_list(int permissions, cpacket &sensor_list) @@ -812,6 +813,34 @@ out: return true; } +bool command_worker::cmd_flush(void *payload) +{ + long ret_value = OP_ERROR; + + _D("CMD_FLUSH Handler invoked"); + + if (!is_permission_allowed()) { + _E("Permission denied to flush sensor data for client [%d], for sensor [0x%llx]", + m_client_id, m_sensor_id); + ret_value = OP_ERROR; + goto out; + } + + if (!m_module->flush()) { + _E("Failed to flush sensor_data [%d]", m_client_id); + ret_value = OP_ERROR; + goto out; + } + + ret_value = OP_SUCCESS; + +out: + if (!send_cmd_done(ret_value)) + _E("Failed to send cmd_done to a client"); + + return true; +} + void command_worker::get_info(string &info) { const char *client_info = NULL; diff --git a/src/server/command_worker.h b/src/server/command_worker.h index c3ce538..3e01883 100644 --- a/src/server/command_worker.h +++ b/src/server/command_worker.h @@ -73,6 +73,7 @@ private: bool cmd_get_data(void *payload); bool cmd_set_attribute_int(void *payload); bool cmd_set_attribute_str(void *payload); + bool cmd_flush(void *payload); void get_info(std::string &info); diff --git a/src/shared/command_common.h b/src/shared/command_common.h index 48dd750..4a73f1d 100644 --- a/src/shared/command_common.h +++ b/src/shared/command_common.h @@ -46,6 +46,7 @@ enum packet_type_t { CMD_GET_DATA, CMD_SET_ATTRIBUTE_INT, CMD_SET_ATTRIBUTE_STR, + CMD_FLUSH, CMD_CNT, }; @@ -126,6 +127,9 @@ typedef struct { char value[0]; } cmd_set_attribute_str_t; +typedef struct { +} cmd_flush_t; + #define CHANNEL_MAGIC_NUM 0xCAFECAFE typedef struct { -- 2.7.4 From bfba23f53c8b4786f8f99e7292519d4b20c4535e Mon Sep 17 00:00:00 2001 From: "kibak.yoon" Date: Tue, 15 Mar 2016 11:45:34 +0900 Subject: [PATCH 15/16] sensord: call on_event() after invoking sensor event from fd Change-Id: I616af576afe22cb512cfc3f8c5be76c458af7e8d Signed-off-by: kibak.yoon --- src/server/physical_sensor.cpp | 5 +++++ src/server/physical_sensor.h | 2 ++ src/server/sensor_event_poller.cpp | 6 ++++++ 3 files changed, 13 insertions(+) diff --git a/src/server/physical_sensor.cpp b/src/server/physical_sensor.cpp index 49858f4..7964065 100644 --- a/src/server/physical_sensor.cpp +++ b/src/server/physical_sensor.cpp @@ -77,6 +77,11 @@ int physical_sensor::get_poll_fd() return m_sensor_device->get_poll_fd(); } +bool physical_sensor::on_event(const sensor_data_t *data, int remains) +{ + return true; +} + bool physical_sensor::read_fd(std::vector &ids) { AUTOLOCK(m_mutex); diff --git a/src/server/physical_sensor.h b/src/server/physical_sensor.h index a2e8763..393e4d7 100644 --- a/src/server/physical_sensor.h +++ b/src/server/physical_sensor.h @@ -40,6 +40,8 @@ public: int get_poll_fd(); + virtual bool on_event(const sensor_data_t *data, int remains); + virtual bool read_fd(std::vector &ids); virtual int get_data(sensor_data_t **data, int *length); virtual bool flush(void); diff --git a/src/server/sensor_event_poller.cpp b/src/server/sensor_event_poller.cpp index af7d8cd..a7ec9a4 100644 --- a/src/server/sensor_event_poller.cpp +++ b/src/server/sensor_event_poller.cpp @@ -137,6 +137,12 @@ bool sensor_event_poller::process_event(int fd, const std::vector &ids break; } + if (!sensor->on_event(data, remains)) { + free(event); + free(data); + break; + } + event->sensor_id = sensor->get_id(); event->event_type = sensor->get_event_type(); event->data_length = data_length; -- 2.7.4 From df57020c8580d24ed361b67be6a613153a09bb44 Mon Sep 17 00:00:00 2001 From: "kibak.yoon" Date: Tue, 15 Mar 2016 11:52:42 +0900 Subject: [PATCH 16/16] sensord: enable hrm/gravity/linear accel sensors Change-Id: I9595bbcb4a0f194b06b1d1f458fb410f179afcd6 Signed-off-by: kibak.yoon --- src/sensor/CMakeLists.txt | 6 +- src/sensor/fusion_util.cpp | 56 ++ src/sensor/fusion_util.h | 34 ++ src/sensor/gravity/gravity_sensor.cpp | 669 ++++++++++++++---------- src/sensor/gravity/gravity_sensor.h | 79 +-- src/sensor/hrm/hrm_sensor.cpp | 34 ++ src/sensor/hrm/hrm_sensor.h | 32 ++ src/sensor/linear_accel/linear_accel_sensor.cpp | 457 +++++----------- src/sensor/linear_accel/linear_accel_sensor.h | 64 +-- src/server/sensor_fusion.cpp | 106 ++++ src/server/sensor_fusion.h | 59 +++ src/server/sensor_loader.cpp | 25 +- 12 files changed, 961 insertions(+), 660 deletions(-) create mode 100644 src/sensor/fusion_util.cpp create mode 100644 src/sensor/fusion_util.h create mode 100644 src/sensor/hrm/hrm_sensor.cpp create mode 100644 src/sensor/hrm/hrm_sensor.h create mode 100644 src/server/sensor_fusion.cpp create mode 100644 src/server/sensor_fusion.h diff --git a/src/sensor/CMakeLists.txt b/src/sensor/CMakeLists.txt index b37f7bf..0e83c6d 100644 --- a/src/sensor/CMakeLists.txt +++ b/src/sensor/CMakeLists.txt @@ -2,11 +2,11 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(sensors CXX) INCLUDE(GNUInstallDirs) -SET(HRM "OFF") +SET(HRM "ON") SET(HRM_VIRT "OFF") SET(AUTO_ROTATION "ON") -SET(GRAVITY "OFF") -SET(LINEAR_ACCEL "OFF") +SET(GRAVITY "ON") +SET(LINEAR_ACCEL "ON") SET(ORIENTATION "OFF") SET(FUSION "OFF") SET(MOTION "OFF") diff --git a/src/sensor/fusion_util.cpp b/src/sensor/fusion_util.cpp new file mode 100644 index 0000000..1f2692d --- /dev/null +++ b/src/sensor/fusion_util.cpp @@ -0,0 +1,56 @@ +/* + * sensord + * + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include +#include + +int quat_to_matrix(const float *quat, float *R) +{ + if(quat == NULL || R == NULL) + return -1; + + float q0 = quat[3]; + float q1 = quat[0]; + float q2 = quat[1]; + float q3 = quat[2]; + + float sq_q1 = 2 * q1 * q1; + float sq_q2 = 2 * q2 * q2; + float sq_q3 = 2 * q3 * q3; + float q1_q2 = 2 * q1 * q2; + float q3_q0 = 2 * q3 * q0; + float q1_q3 = 2 * q1 * q3; + float q2_q0 = 2 * q2 * q0; + float q2_q3 = 2 * q2 * q3; + float q1_q0 = 2 * q1 * q0; + + R[0] = 1 - sq_q2 - sq_q3; + R[1] = q1_q2 - q3_q0; + R[2] = q1_q3 + q2_q0; + R[3] = q1_q2 + q3_q0; + R[4] = 1 - sq_q1 - sq_q3; + R[5] = q2_q3 - q1_q0; + R[6] = q1_q3 - q2_q0; + R[7] = q2_q3 + q1_q0; + R[8] = 1 - sq_q1 - sq_q2; + + return 0; +} + diff --git a/src/sensor/fusion_util.h b/src/sensor/fusion_util.h new file mode 100644 index 0000000..b4d2bc2 --- /dev/null +++ b/src/sensor/fusion_util.h @@ -0,0 +1,34 @@ +/* + * sensord + * + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _FUSION_UTIL_H_ +#define _FUSION_UTIL_H_ + +#ifdef __cplusplus +extern "C" +{ +#endif + +int quat_to_matrix(const float *quat, float *R); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _FUSION_UTIL_H_ */ diff --git a/src/sensor/gravity/gravity_sensor.cpp b/src/sensor/gravity/gravity_sensor.cpp index d81242a..49147a6 100644 --- a/src/sensor/gravity/gravity_sensor.cpp +++ b/src/sensor/gravity/gravity_sensor.cpp @@ -25,367 +25,498 @@ #include #include #include + #include +#include + +#include +#include #include #include -#include +#include -using std::string; -using std::vector; +#define SENSOR_NAME "GRAVITY_SENSOR" -#define INITIAL_VALUE -1 #define GRAVITY 9.80665 -#define DEVIATION 0.1 - -#define PI 3.141593 -#define AZIMUTH_OFFSET_DEGREES 360 -#define AZIMUTH_OFFSET_RADIANS (2 * PI) +#define PHASE_ACCEL_READY 0x01 +#define PHASE_GYRO_READY 0x02 +#define PHASE_FUSION_READY 0x03 +#define US_PER_SEC 1000000 +#define MS_PER_SEC 1000 +#define INV_ANGLE -1000 +#define TAU_LOW 0.4 +#define TAU_MID 0.75 +#define TAU_HIGH 0.99 -#define SENSOR_NAME "GRAVITY_SENSOR" -#define SENSOR_TYPE_GRAVITY "GRAVITY" -#define SENSOR_TYPE_ORIENTATION "ORIENTATION" - -#define MS_TO_US 1000 -#define MIN_DELIVERY_DIFF_FACTOR 0.75f - -#define ELEMENT_NAME "NAME" -#define ELEMENT_VENDOR "VENDOR" -#define ELEMENT_RAW_DATA_UNIT "RAW_DATA_UNIT" -#define ELEMENT_DEFAULT_SAMPLING_TIME "DEFAULT_SAMPLING_TIME" -#define ELEMENT_GRAVITY_SIGN_COMPENSATION "GRAVITY_SIGN_COMPENSATION" -#define ELEMENT_ORIENTATION_DATA_UNIT "RAW_DATA_UNIT" -#define ELEMENT_PITCH_ROTATION_COMPENSATION "PITCH_ROTATION_COMPENSATION" -#define ELEMENT_ROLL_ROTATION_COMPENSATION "ROLL_ROTATION_COMPENSATION" -#define ELEMENT_AZIMUTH_ROTATION_COMPENSATION "AZIMUTH_ROTATION_COMPENSATION" +#define DEG2RAD(x) ((x) * M_PI / 180.0) +#define NORM(x, y, z) sqrt((x)*(x) + (y)*(y) + (z)*(z)) +#define ARCTAN(x, y) ((x) == 0 ? 0 : (y) != 0 ? atan2((x),(y)) : (x) > 0 ? M_PI/2.0 : -M_PI/2.0) gravity_sensor::gravity_sensor() -: m_accel_sensor(NULL) +: m_fusion(NULL) +, m_accel_sensor(NULL) , m_gyro_sensor(NULL) -, m_magnetic_sensor(NULL) -, m_fusion_sensor(NULL) +, m_fusion_phase(0) +, m_x(-1) +, m_y(-1) +, m_z(-1) +, m_accuracy(-1) , m_time(0) { - virtual_sensor_config &config = virtual_sensor_config::get_instance(); +} - sensor_hal *fusion_sensor_hal = sensor_loader::get_instance().get_sensor_hal(SENSOR_HAL_TYPE_FUSION); - if (!fusion_sensor_hal) - m_hardware_fusion = false; - else - m_hardware_fusion = true; +gravity_sensor::~gravity_sensor() +{ + _I("gravity_sensor is destroyed!\n"); +} - m_name = std::string(SENSOR_NAME); - register_supported_event(GRAVITY_RAW_DATA_EVENT); +bool gravity_sensor::init() +{ + /* Acc (+ Gyro) fusion */ + m_accel_sensor = sensor_loader::get_instance().get_sensor(ACCELEROMETER_SENSOR); - if (!config.get(SENSOR_TYPE_GRAVITY, ELEMENT_VENDOR, m_vendor)) { - _E("[VENDOR] is empty\n"); - throw ENXIO; + if (!m_accel_sensor) { + _E("cannot load accelerometer sensor_hal[%s]", get_name()); + return false; } - _I("m_vendor = %s", m_vendor.c_str()); + m_gyro_sensor = sensor_loader::get_instance().get_sensor(GYROSCOPE_SENSOR); + + _I("%s (%s) is created!\n", get_name(), m_gyro_sensor ? "Acc+Gyro Fusion" : "LowPass Acc"); + return true; +} - if (!config.get(SENSOR_TYPE_ORIENTATION, ELEMENT_ORIENTATION_DATA_UNIT, m_orientation_data_unit)) { - _E("[ORIENTATION_DATA_UNIT] is empty\n"); - throw ENXIO; - } +sensor_type_t gravity_sensor::get_type(void) +{ + return GRAVITY_SENSOR; +} - _I("m_orientation_data_unit = %s", m_orientation_data_unit.c_str()); +unsigned int gravity_sensor::get_event_type(void) +{ + return GRAVITY_EVENT_RAW_DATA_REPORT_ON_TIME; +} - if (!config.get(SENSOR_TYPE_GRAVITY, ELEMENT_RAW_DATA_UNIT, m_raw_data_unit)) { - _E("[RAW_DATA_UNIT] is empty\n"); - throw ENXIO; - } +const char* gravity_sensor::get_name(void) +{ + return SENSOR_NAME; +} - _I("m_raw_data_unit = %s", m_raw_data_unit.c_str()); +bool gravity_sensor::get_sensor_info(sensor_info &info) +{ + info.set_type(get_type()); + info.set_id(get_id()); + info.set_privilege(SENSOR_PRIVILEGE_PUBLIC); // FIXME + info.set_name("Gravity Sensor"); + info.set_vendor("Samsung Electronics"); + info.set_min_range(-19.6); + info.set_max_range(19.6); + info.set_resolution(0.01); + info.set_min_interval(1); + info.set_fifo_count(0); + info.set_max_batch_count(0); + info.set_supported_event(get_event_type()); + info.set_wakeup_supported(false); - if (!config.get(SENSOR_TYPE_GRAVITY, ELEMENT_DEFAULT_SAMPLING_TIME, &m_default_sampling_time)) { - _E("[DEFAULT_SAMPLING_TIME] is empty\n"); - throw ENXIO; - } + return true; +} - _I("m_default_sampling_time = %d", m_default_sampling_time); +void gravity_sensor::synthesize(const sensor_event_t& event) +{ + /* If the rotation vector sensor is available */ + if (m_fusion) { + synthesize_rv(event); + return; + } - if (!config.get(SENSOR_TYPE_GRAVITY, ELEMENT_GRAVITY_SIGN_COMPENSATION, m_gravity_sign_compensation, 3)) { - _E("[GRAVITY_SIGN_COMPENSATION] is empty\n"); - throw ENXIO; + /* If both Acc & Gyro are available */ + if (m_gyro_sensor) { + synthesize_fusion(event); + return; } - _I("m_gravity_sign_compensation = (%d, %d, %d)", m_gravity_sign_compensation[0], m_gravity_sign_compensation[1], m_gravity_sign_compensation[2]); + /* If only Acc is available */ + synthesize_lowpass(event); +} + +void gravity_sensor::synthesize_rv(const sensor_event_t& event) +{ + if (!m_fusion->is_data_ready()) + return; + + sensor_event_t *gravity_event; + float gravity[3]; + float x, y, z, w, heading_accuracy; + int accuracy; - if (!config.get(SENSOR_TYPE_ORIENTATION, ELEMENT_AZIMUTH_ROTATION_COMPENSATION, &m_azimuth_rotation_compensation)) { - _E("[AZIMUTH_ROTATION_COMPENSATION] is empty\n"); - throw ENXIO; + if (!m_fusion->get_rotation_vector(x, y, z, w, heading_accuracy, accuracy)) { + _E("Failed to get rotation vector"); + return; } - _I("m_azimuth_rotation_compensation = %d", m_azimuth_rotation_compensation); + unsigned long long timestamp = m_fusion->get_data_timestamp(); + + if (!check_sampling_time(timestamp)) + return; + + float rotation[4] = {x, y, z, w}; - if (!config.get(SENSOR_TYPE_ORIENTATION, ELEMENT_PITCH_ROTATION_COMPENSATION, &m_pitch_rotation_compensation)) { - _E("[PITCH_ROTATION_COMPENSATION] is empty\n"); - throw ENXIO; + rotation_to_gravity(rotation, gravity); + + gravity_event = (sensor_event_t *)malloc(sizeof(sensor_event_t)); + if (!gravity_event) { + _E("Failed to allocate memory"); + return; + } + gravity_event->data = (sensor_data_t *)malloc(sizeof(sensor_data_t)); + if (!gravity_event->data) { + _E("Failed to allocate memory"); + return; } - _I("m_pitch_rotation_compensation = %d", m_pitch_rotation_compensation); + gravity_event->sensor_id = get_id(); + gravity_event->event_type = GRAVITY_EVENT_RAW_DATA_REPORT_ON_TIME; + gravity_event->data_length = sizeof(sensor_data_t); + gravity_event->data->accuracy = accuracy; + gravity_event->data->timestamp = m_fusion->get_data_timestamp(); + gravity_event->data->value_count = 3; + gravity_event->data->values[0] = gravity[0]; + gravity_event->data->values[1] = gravity[1]; + gravity_event->data->values[2] = gravity[2]; + push(gravity_event); + + m_time = event.data->timestamp; + m_x = gravity[0]; + m_y = gravity[1]; + m_z = gravity[2]; + m_accuracy = accuracy; +} - if (!config.get(SENSOR_TYPE_ORIENTATION, ELEMENT_ROLL_ROTATION_COMPENSATION, &m_roll_rotation_compensation)) { - _E("[ROLL_ROTATION_COMPENSATION] is empty\n"); - throw ENXIO; +void gravity_sensor::synthesize_lowpass(const sensor_event_t& event) +{ + sensor_event_t *gravity_event; + float x, y, z, norm, alpha, tau, err; + + norm = NORM(event.data->values[0], event.data->values[1], event.data->values[2]); + x = event.data->values[0] / norm * GRAVITY; + y = event.data->values[1] / norm * GRAVITY; + z = event.data->values[2] / norm * GRAVITY; + + if (m_time > 0) { + err = fabs(norm - GRAVITY) / GRAVITY; + tau = (err < 0.1 ? TAU_LOW : err > 0.9 ? TAU_HIGH : TAU_MID); + alpha = tau / (tau + (float)(event.data->timestamp - m_time) / US_PER_SEC); + x = alpha * m_x + (1 - alpha) * x; + y = alpha * m_y + (1 - alpha) * y; + z = alpha * m_z + (1 - alpha) * z; + norm = NORM(x, y, z); + x = x / norm * GRAVITY; + y = y / norm * GRAVITY; + z = z / norm * GRAVITY; } - _I("m_roll_rotation_compensation = %d", m_roll_rotation_compensation); + gravity_event = (sensor_event_t *)malloc(sizeof(sensor_event_t)); + if (!gravity_event) { + _E("Failed to allocate memory"); + return; + } + gravity_event->data = (sensor_data_t *)malloc(sizeof(sensor_data_t)); + if (!gravity_event->data) { + _E("Failed to allocate memory"); + return; + } - m_interval = m_default_sampling_time * MS_TO_US; + gravity_event->sensor_id = get_id(); + gravity_event->event_type = GRAVITY_EVENT_RAW_DATA_REPORT_ON_TIME; + gravity_event->data_length = sizeof(sensor_data_t); + gravity_event->data->accuracy = event.data->accuracy; + gravity_event->data->timestamp = event.data->timestamp; + gravity_event->data->value_count = 3; + gravity_event->data->values[0] = x; + gravity_event->data->values[1] = y; + gravity_event->data->values[2] = z; + push(gravity_event); + + m_time = event.data->timestamp; + m_x = x; + m_y = y; + m_z = z; + m_accuracy = event.data->accuracy; } -gravity_sensor::~gravity_sensor() +void gravity_sensor::synthesize_fusion(const sensor_event_t& event) { - _I("gravity_sensor is destroyed!\n"); + sensor_event_t *gravity_event; + + if (event.event_type == ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME) { + fusion_set_accel(event); + m_fusion_phase |= PHASE_ACCEL_READY; + } else if (event.event_type == GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME) { + fusion_set_gyro(event); + m_fusion_phase |= PHASE_GYRO_READY; + } + + if (m_fusion_phase != PHASE_FUSION_READY) + return; + + m_fusion_phase = 0; + + fusion_update_angle(); + fusion_get_gravity(); + + gravity_event = (sensor_event_t *)malloc(sizeof(sensor_event_t)); + if (!gravity_event) { + _E("Failed to allocate memory"); + return; + } + gravity_event->data = (sensor_data_t *)malloc(sizeof(sensor_data_t)); + if (!gravity_event->data) { + _E("Failed to allocate memory"); + return; + } + + gravity_event->sensor_id = get_id(); + gravity_event->event_type = GRAVITY_EVENT_RAW_DATA_REPORT_ON_TIME; + gravity_event->data_length = sizeof(sensor_data_t); + gravity_event->data->accuracy = m_accuracy; + gravity_event->data->timestamp = m_time; + gravity_event->data->value_count = 3; + gravity_event->data->values[0] = m_x; + gravity_event->data->values[1] = m_y; + gravity_event->data->values[2] = m_z; + push(gravity_event); } -bool gravity_sensor::init() +void gravity_sensor::fusion_set_accel(const sensor_event_t& event) { - m_accel_sensor = sensor_loader::get_instance().get_sensor(ACCELEROMETER_SENSOR); - m_gyro_sensor = sensor_loader::get_instance().get_sensor(GYROSCOPE_SENSOR); - m_magnetic_sensor = sensor_loader::get_instance().get_sensor(GEOMAGNETIC_SENSOR); + double x = event.data->values[0]; + double y = event.data->values[1]; + double z = event.data->values[2]; - m_fusion_sensor = sensor_loader::get_instance().get_sensor(FUSION_SENSOR); + m_accel_mag = NORM(x, y, z); - if (!m_accel_sensor || !m_gyro_sensor || !m_magnetic_sensor || !m_fusion_sensor) { - _E("Failed to load sensors, accel: 0x%x, gyro: 0x%x, mag: 0x%x, fusion: 0x%x", - m_accel_sensor, m_gyro_sensor, m_magnetic_sensor, m_fusion_sensor); - return false; - } + m_angle_n[0] = ARCTAN(z, y); + m_angle_n[1] = ARCTAN(x, z); + m_angle_n[2] = ARCTAN(y, x); - _I("%s is created!", sensor_base::get_name()); - return true; + m_time_new = event.data->timestamp; + + _D("AccIn: (%f, %f, %f)", x/m_accel_mag, y/m_accel_mag, z/m_accel_mag); } -void gravity_sensor::get_types(vector &types) +void gravity_sensor::fusion_set_gyro(const sensor_event_t& event) { - types.push_back(GRAVITY_SENSOR); + m_velocity[0] = -DEG2RAD(event.data->values[0]); + m_velocity[1] = -DEG2RAD(event.data->values[1]); + m_velocity[2] = -DEG2RAD(event.data->values[2]); + + m_time_new = event.data->timestamp; } -bool gravity_sensor::on_start(void) +void gravity_sensor::fusion_update_angle() { - AUTOLOCK(m_mutex); + _D("AngleIn: (%f, %f, %f)", m_angle_n[0], m_angle_n[1], m_angle_n[2]); + _D("AngAccl: (%f, %f, %f)", m_velocity[0], m_velocity[1], m_velocity[2]); + _D("Angle : (%f, %f, %f)", m_angle[0], m_angle[1], m_angle[2]); + + if (m_angle[0] == INV_ANGLE) { + /* 1st iteration */ + m_angle[0] = m_angle_n[0]; + m_angle[1] = m_angle_n[1]; + m_angle[2] = m_angle_n[2]; + } else { + complementary(m_time_new - m_time); + } - if (!m_hardware_fusion) { - m_accel_sensor->add_client(ACCELEROMETER_RAW_DATA_EVENT); - m_accel_sensor->add_interval((intptr_t)this, (m_interval/MS_TO_US), false); - m_accel_sensor->start(); - m_gyro_sensor->add_client(GYROSCOPE_RAW_DATA_EVENT); - m_gyro_sensor->add_interval((intptr_t)this, (m_interval/MS_TO_US), false); - m_gyro_sensor->start(); - m_magnetic_sensor->add_client(GEOMAGNETIC_RAW_DATA_EVENT); - m_magnetic_sensor->add_interval((intptr_t)this, (m_interval/MS_TO_US), false); - m_magnetic_sensor->start(); + _D("Angle' : (%f, %f, %f)", m_angle[0], m_angle[1], m_angle[2]); +} + +void gravity_sensor::fusion_get_gravity() +{ + double x = 0, y = 0, z = 0; + double norm; + double vec[3][3]; + + /* Rotating along y-axis then z-axis */ + vec[0][2] = cos(m_angle[1]); + vec[0][0] = sin(m_angle[1]); + vec[0][1] = vec[0][0] * tan(m_angle[2]); + + /* Rotating along z-axis then x-axis */ + vec[1][0] = cos(m_angle[2]); + vec[1][1] = sin(m_angle[2]); + vec[1][2] = vec[1][1] * tan(m_angle[0]); + + /* Rotating along x-axis then y-axis */ + vec[2][1] = cos(m_angle[0]); + vec[2][2] = sin(m_angle[0]); + vec[2][0] = vec[2][2] * tan(m_angle[1]); + + /* Normalize */ + for (int i = 0; i < 3; ++i) { + norm = NORM(vec[i][0], vec[i][1], vec[i][2]); + vec[i][0] /= norm; + vec[i][1] /= norm; + vec[i][2] /= norm; + x += vec[i][0]; + y += vec[i][1]; + z += vec[i][2]; } - m_fusion_sensor->register_supported_event(FUSION_EVENT); - m_fusion_sensor->register_supported_event(FUSION_ORIENTATION_ENABLED); - m_fusion_sensor->add_client(FUSION_EVENT); - m_fusion_sensor->add_interval((intptr_t)this, (m_interval/MS_TO_US), false); - m_fusion_sensor->start(); + norm = NORM(x, y, z); - activate(); - return true; + m_x = x / norm * GRAVITY; + m_y = y / norm * GRAVITY; + m_z = z / norm * GRAVITY; + m_time = m_time_new; } -bool gravity_sensor::on_stop(void) +void gravity_sensor::complementary(unsigned long long time_diff) { - AUTOLOCK(m_mutex); + double err = fabs(m_accel_mag - GRAVITY) / GRAVITY; + double tau = (err < 0.1 ? TAU_LOW : err > 0.9 ? TAU_HIGH : TAU_MID); + double delta_t = (double)time_diff/ US_PER_SEC; + double alpha = tau / (tau + delta_t); - if (!m_hardware_fusion) { - m_accel_sensor->delete_client(ACCELEROMETER_RAW_DATA_EVENT); - m_accel_sensor->delete_interval((intptr_t)this, false); - m_accel_sensor->stop(); - m_gyro_sensor->delete_client(GYROSCOPE_RAW_DATA_EVENT); - m_gyro_sensor->delete_interval((intptr_t)this, false); - m_gyro_sensor->stop(); - m_magnetic_sensor->delete_client(GEOMAGNETIC_RAW_DATA_EVENT); - m_magnetic_sensor->delete_interval((intptr_t)this, false); - m_magnetic_sensor->stop(); - } + _D("mag, err, tau, dt, alpha = %f, %f, %f, %f, %f", m_accel_mag, err, tau, delta_t, alpha); - m_fusion_sensor->delete_client(FUSION_EVENT); - m_fusion_sensor->delete_interval((intptr_t)this, false); - m_fusion_sensor->unregister_supported_event(FUSION_EVENT); - m_fusion_sensor->unregister_supported_event(FUSION_ORIENTATION_ENABLED); - m_fusion_sensor->stop(); + m_angle[0] = complementary(m_angle[0], m_angle_n[0], m_velocity[0], delta_t, alpha); + m_angle[1] = complementary(m_angle[1], m_angle_n[1], m_velocity[1], delta_t, alpha); + m_angle[2] = complementary(m_angle[2], m_angle_n[2], m_velocity[2], delta_t, alpha); +} - deactivate(); - return true; +double gravity_sensor::complementary(double angle, double angle_in, double vel, double delta_t, double alpha) +{ + double s, c; + angle = angle + vel * delta_t; + s = alpha * sin(angle) + (1 - alpha) * sin(angle_in); + c = alpha * cos(angle) + (1 - alpha) * cos(angle_in); + return ARCTAN(s, c); } -bool gravity_sensor::add_interval(int client_id, unsigned int interval) +int gravity_sensor::get_data(sensor_data_t **data, int *length) { - AUTOLOCK(m_mutex); - if (!m_hardware_fusion) { - m_accel_sensor->add_interval(client_id, interval, false); - m_gyro_sensor->add_interval(client_id, interval, false); - m_magnetic_sensor->add_interval(client_id, interval, false); - } + /* if It is batch sensor, remains can be 2+ */ + int remains = 1; - m_fusion_sensor->add_interval(client_id, interval, false); + sensor_data_t *sensor_data; + sensor_data = (sensor_data_t *)malloc(sizeof(sensor_data_t)); - return sensor_base::add_interval(client_id, interval, false); + sensor_data->accuracy = m_accuracy; + sensor_data->timestamp = m_time; + sensor_data->value_count = 3; + sensor_data->values[0] = m_x; + sensor_data->values[1] = m_y; + sensor_data->values[2] = m_z; + + *data = sensor_data; + *length = sizeof(sensor_data_t); + + return --remains; } -bool gravity_sensor::delete_interval(int client_id) +bool gravity_sensor::set_batch_latency(unsigned long latency) { - AUTOLOCK(m_mutex); - if (!m_hardware_fusion) { - m_accel_sensor->delete_interval(client_id, false); - m_gyro_sensor->delete_interval(client_id, false); - m_magnetic_sensor->delete_interval(client_id, false); - } + return false; +} - m_fusion_sensor->delete_interval(client_id, false); +bool gravity_sensor::set_wakeup(int wakeup) +{ + return false; +} + +bool gravity_sensor::on_start(void) +{ + if (m_fusion) + m_fusion->start(); + + if (m_accel_sensor) + m_accel_sensor->start(); - return sensor_base::delete_interval(client_id, false); + if (m_gyro_sensor) + m_gyro_sensor->start(); + + m_time = 0; + m_fusion_phase = 0; + m_angle[0] = INV_ANGLE; + + return activate(); } -void gravity_sensor::synthesize(const sensor_event_t &event, vector &outs) +bool gravity_sensor::on_stop(void) { - sensor_event_t gravity_event; - float pitch, roll, azimuth; - unsigned long long diff_time; - float azimuth_offset; - - if (event.event_type == FUSION_EVENT) { - diff_time = event.data.timestamp - m_time; - - if (m_time && (diff_time < m_interval * MIN_DELIVERY_DIFF_FACTOR)) - return; - - quaternion quat(event.data.values[0], event.data.values[1], - event.data.values[2], event.data.values[3]); - - euler_angles euler = quat2euler(quat); - - if(m_orientation_data_unit == "DEGREES") { - euler = rad2deg(euler); - azimuth_offset = AZIMUTH_OFFSET_DEGREES; - } - else { - azimuth_offset = AZIMUTH_OFFSET_RADIANS; - } - - euler.m_ang.m_vec[0] *= m_pitch_rotation_compensation; - euler.m_ang.m_vec[1] *= m_roll_rotation_compensation; - euler.m_ang.m_vec[2] *= m_azimuth_rotation_compensation; - - pitch = euler.m_ang.m_vec[0]; - roll = euler.m_ang.m_vec[1]; - if (euler.m_ang.m_vec[2] >= 0) - azimuth = euler.m_ang.m_vec[2]; - else - azimuth = euler.m_ang.m_vec[2] + azimuth_offset; - - if(m_orientation_data_unit == "DEGREES") { - azimuth *= DEG2RAD; - pitch *= DEG2RAD; - roll *= DEG2RAD; - } - - m_time = get_timestamp(); - gravity_event.sensor_id = get_id(); - gravity_event.event_type = GRAVITY_RAW_DATA_EVENT; - - if ((roll >= (M_PI/2)-DEVIATION && roll <= (M_PI/2)+DEVIATION) || - (roll >= -(M_PI/2)-DEVIATION && roll <= -(M_PI/2)+DEVIATION)) { - gravity_event.data.values[0] = m_gravity_sign_compensation[0] * GRAVITY * sin(roll) * cos(azimuth); - gravity_event.data.values[1] = m_gravity_sign_compensation[1] * GRAVITY * sin(azimuth); - gravity_event.data.values[2] = m_gravity_sign_compensation[2] * GRAVITY * cos(roll); - } else if ((pitch >= (M_PI/2)-DEVIATION && pitch <= (M_PI/2)+DEVIATION) || - (pitch >= -(M_PI/2)-DEVIATION && pitch <= -(M_PI/2)+DEVIATION)) { - gravity_event.data.values[0] = m_gravity_sign_compensation[0] * GRAVITY * sin(azimuth); - gravity_event.data.values[1] = m_gravity_sign_compensation[1] * GRAVITY * sin(pitch) * cos(azimuth); - gravity_event.data.values[2] = m_gravity_sign_compensation[2] * GRAVITY * cos(pitch); - } else { - gravity_event.data.values[0] = m_gravity_sign_compensation[0] * GRAVITY * sin(roll); - gravity_event.data.values[1] = m_gravity_sign_compensation[1] * GRAVITY * sin(pitch); - gravity_event.data.values[2] = m_gravity_sign_compensation[2] * GRAVITY * cos(roll) * cos(pitch); - } - gravity_event.data.value_count = 3; - gravity_event.data.timestamp = m_time; - gravity_event.data.accuracy = SENSOR_ACCURACY_GOOD; - - push(gravity_event); - } + if (m_fusion) + m_fusion->stop(); + + if (m_accel_sensor) + m_accel_sensor->stop(); - return; + if (m_gyro_sensor) + m_gyro_sensor->stop(); + + m_time = 0; + + return deactivate(); } -int gravity_sensor::get_sensor_data(const unsigned int event_type, sensor_data_t &data) +bool gravity_sensor::add_interval(int client_id, unsigned int interval, bool is_processor) { - sensor_data_t fusion_data; - float azimuth_offset; - float pitch, roll, azimuth; + if (m_fusion) + m_fusion->set_interval(FUSION_EVENT_AGM, client_id, interval); - if (event_type != GRAVITY_RAW_DATA_EVENT) - return -1; + if (m_accel_sensor) + m_accel_sensor->add_interval(client_id, interval, true); - m_fusion_sensor->get_sensor_data(FUSION_ORIENTATION_ENABLED, fusion_data); + if (m_gyro_sensor) + m_gyro_sensor->add_interval(client_id, interval, true); - quaternion quat(fusion_data.values[0], fusion_data.values[1], - fusion_data.values[2], fusion_data.values[3]); + return sensor_base::add_interval(client_id, interval, is_processor); +} - euler_angles euler = quat2euler(quat); +bool gravity_sensor::delete_interval(int client_id, bool is_processor) +{ + if (m_fusion) + m_fusion->unset_interval(FUSION_EVENT_AGM, client_id); - if(m_orientation_data_unit == "DEGREES") { - euler = rad2deg(euler); - azimuth_offset = AZIMUTH_OFFSET_DEGREES; - } - else { - azimuth_offset = AZIMUTH_OFFSET_RADIANS; - } + if (m_accel_sensor) + m_accel_sensor->delete_interval(client_id, true); - pitch = euler.m_ang.m_vec[0]; - roll = euler.m_ang.m_vec[1]; + if (m_gyro_sensor) + m_gyro_sensor->delete_interval(client_id, true); - if (euler.m_ang.m_vec[2] >= 0) - azimuth = euler.m_ang.m_vec[2]; - else - azimuth = euler.m_ang.m_vec[2] + azimuth_offset; + return sensor_base::delete_interval(client_id, is_processor); +} - if(m_orientation_data_unit == "DEGREES") { - azimuth *= DEG2RAD; - pitch *= DEG2RAD; - roll *= DEG2RAD; - } +bool gravity_sensor::set_interval(unsigned long interval) +{ + m_interval = interval; + return true; +} - data.accuracy = SENSOR_ACCURACY_GOOD; - data.timestamp = get_timestamp(); - if ((roll >= (M_PI/2)-DEVIATION && roll <= (M_PI/2)+DEVIATION) || - (roll >= -(M_PI/2)-DEVIATION && roll <= -(M_PI/2)+DEVIATION)) { - data.values[0] = m_gravity_sign_compensation[0] * GRAVITY * sin(roll) * cos(azimuth); - data.values[1] = m_gravity_sign_compensation[1] * GRAVITY * sin(azimuth); - data.values[2] = m_gravity_sign_compensation[2] * GRAVITY * cos(roll); - } else if ((pitch >= (M_PI/2)-DEVIATION && pitch <= (M_PI/2)+DEVIATION) || - (pitch >= -(M_PI/2)-DEVIATION && pitch <= -(M_PI/2)+DEVIATION)) { - data.values[0] = m_gravity_sign_compensation[0] * GRAVITY * sin(azimuth); - data.values[1] = m_gravity_sign_compensation[1] * GRAVITY * sin(pitch) * cos(azimuth); - data.values[2] = m_gravity_sign_compensation[2] * GRAVITY * cos(pitch); - } else { - data.values[0] = m_gravity_sign_compensation[0] * GRAVITY * sin(roll); - data.values[1] = m_gravity_sign_compensation[1] * GRAVITY * sin(pitch); - data.values[2] = m_gravity_sign_compensation[2] * GRAVITY * cos(roll) * cos(pitch); - } - data.value_count = 3; +bool gravity_sensor::rotation_to_gravity(const float *rotation, float *gravity) +{ + float R[9]; - return 0; + if (quat_to_matrix(rotation, R) < 0) + return false; + + gravity[0] = R[6] * GRAVITY; + gravity[1] = R[7] * GRAVITY; + gravity[2] = R[8] * GRAVITY; + + return true; } -bool gravity_sensor::get_properties(sensor_type_t sensor_type, sensor_properties_s &properties) +bool gravity_sensor::check_sampling_time(unsigned long long timestamp) { - properties.min_range = -GRAVITY; - properties.max_range = GRAVITY; - properties.resolution = 0.000001; - properties.vendor = m_vendor; - properties.name = SENSOR_NAME; - properties.fifo_count = 0; - properties.max_batch_count = 0; - properties.min_interval = 1; + const float MIN_DELIVERY_DIFF_FACTOR = 0.75f; + const int MS_TO_US = 1000; + long long diff_time; + + diff_time = timestamp - m_time; + + if (m_time && (diff_time < m_interval * MS_TO_US * MIN_DELIVERY_DIFF_FACTOR)) + return false; return true; } diff --git a/src/sensor/gravity/gravity_sensor.h b/src/sensor/gravity/gravity_sensor.h index b5114ee..c9ed7d7 100644 --- a/src/sensor/gravity/gravity_sensor.h +++ b/src/sensor/gravity/gravity_sensor.h @@ -20,52 +20,71 @@ #ifndef _GRAVITY_SENSOR_H_ #define _GRAVITY_SENSOR_H_ -#include #include -#include +#include +#include class gravity_sensor : public virtual_sensor { public: gravity_sensor(); virtual ~gravity_sensor(); - bool init(); - virtual void get_types(std::vector &types); + /* initialize sensor */ + bool init(void); - void synthesize(const sensor_event_t& event, std::vector &outs); + /* sensor info */ + virtual sensor_type_t get_type(void); + virtual unsigned int get_event_type(void); + virtual const char* get_name(void); - bool add_interval(int client_id, unsigned int interval); - bool delete_interval(int client_id); + virtual bool get_sensor_info(sensor_info &info); - 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); + /* synthesize event */ + virtual void synthesize(const sensor_event_t& event); + + bool add_interval(int client_id, unsigned int interval, bool is_processor); + bool delete_interval(int client_id, bool is_processor); + /* get data */ + virtual int get_data(sensor_data_t **data, int *length); private: + sensor_fusion *m_fusion; sensor_base *m_accel_sensor; sensor_base *m_gyro_sensor; - sensor_base *m_magnetic_sensor; - sensor_base *m_fusion_sensor; - - sensor_data m_accel; - sensor_data m_gyro; - sensor_data m_magnetic; - - cmutex m_value_mutex; + int m_fusion_phase; + float m_x; + float m_y; + float m_z; int m_accuracy; unsigned long long m_time; - unsigned int m_interval; - - 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; - int m_pitch_rotation_compensation; - int m_roll_rotation_compensation; - - bool on_start(void); - bool on_stop(void); + unsigned long m_interval; + + double m_angle[3]; + double m_angle_n[3]; + double m_accel_mag; + double m_velocity[3]; + unsigned long long m_time_new; + + virtual bool set_interval(unsigned long interval); + virtual bool set_batch_latency(unsigned long latency); + virtual bool set_wakeup(int wakeup); + + virtual bool on_start(void); + virtual bool on_stop(void); + + bool rotation_to_gravity(const float *rotation, float *gravity); + bool check_sampling_time(unsigned long long timestamp); + + void synthesize_rv(const sensor_event_t& event); + void synthesize_lowpass(const sensor_event_t& event); + void synthesize_fusion(const sensor_event_t& event); + + void fusion_set_accel(const sensor_event_t& event); + void fusion_set_gyro(const sensor_event_t& event); + void fusion_update_angle(); + void fusion_get_gravity(); + double complementary(double angle, double angle_in, double vel, double delta_t, double alpha); + void complementary(unsigned long long time_diff); }; #endif /* _GRAVITY_SENSOR_H_ */ diff --git a/src/sensor/hrm/hrm_sensor.cpp b/src/sensor/hrm/hrm_sensor.cpp new file mode 100644 index 0000000..908f1b5 --- /dev/null +++ b/src/sensor/hrm/hrm_sensor.cpp @@ -0,0 +1,34 @@ +/* + * sensord + * + * Copyright (c) 2016 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 +#include +#include "hrm_sensor.h" + +hrm_sensor::hrm_sensor() +{ + set_permission(SENSOR_PERMISSION_BIO); + + _I("hrm_sensor is created : 0x%x", this); +} + +hrm_sensor::~hrm_sensor() +{ + +} diff --git a/src/sensor/hrm/hrm_sensor.h b/src/sensor/hrm/hrm_sensor.h new file mode 100644 index 0000000..1c64bc5 --- /dev/null +++ b/src/sensor/hrm/hrm_sensor.h @@ -0,0 +1,32 @@ +/* + * sensord + * + * Copyright (c) 2016 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 _HRM_SENSOR_H_ +#define _HRM_SENSOR_H_ + +#include + +class hrm_sensor : public physical_sensor { +public: + hrm_sensor(); + virtual ~hrm_sensor(); +}; + +#endif /* _HRM_SENSOR_H_ */ + diff --git a/src/sensor/linear_accel/linear_accel_sensor.cpp b/src/sensor/linear_accel/linear_accel_sensor.cpp index 67095f8..33d1548 100644 --- a/src/sensor/linear_accel/linear_accel_sensor.cpp +++ b/src/sensor/linear_accel/linear_accel_sensor.cpp @@ -25,145 +25,32 @@ #include #include #include + #include +#include + +#include +#include #include #include -#include - -using std::string; -using std::vector; +#include #define SENSOR_NAME "LINEAR_ACCEL_SENSOR" -#define SENSOR_TYPE_LINEAR_ACCEL "LINEAR_ACCEL" -#define SENSOR_TYPE_GRAVITY "GRAVITY" -#define SENSOR_TYPE_ORIENTATION "ORIENTATION" - -#define ELEMENT_NAME "NAME" -#define ELEMENT_VENDOR "VENDOR" -#define ELEMENT_RAW_DATA_UNIT "RAW_DATA_UNIT" -#define ELEMENT_DEFAULT_SAMPLING_TIME "DEFAULT_SAMPLING_TIME" -#define ELEMENT_ACCEL_STATIC_BIAS "ACCEL_STATIC_BIAS" -#define ELEMENT_ACCEL_ROTATION_DIRECTION_COMPENSATION "ACCEL_ROTATION_DIRECTION_COMPENSATION" -#define ELEMENT_ACCEL_SCALE "ACCEL_SCALE" -#define ELEMENT_LINEAR_ACCEL_SIGN_COMPENSATION "LINEAR_ACCEL_SIGN_COMPENSATION" -#define ELEMENT_ORIENTATION_DATA_UNIT "RAW_DATA_UNIT" -#define ELEMENT_GRAVITY_SIGN_COMPENSATION "GRAVITY_SIGN_COMPENSATION" -#define ELEMENT_PITCH_ROTATION_COMPENSATION "PITCH_ROTATION_COMPENSATION" -#define ELEMENT_ROLL_ROTATION_COMPENSATION "ROLL_ROTATION_COMPENSATION" -#define ELEMENT_AZIMUTH_ROTATION_COMPENSATION "AZIMUTH_ROTATION_COMPENSATION" - -#define INITIAL_VALUE -1 -#define GRAVITY 9.80665 -#define DEVIATION 0.1 - -#define PI 3.141593 -#define AZIMUTH_OFFSET_DEGREES 360 -#define AZIMUTH_OFFSET_RADIANS (2 * PI) - -#define MS_TO_US 1000 -#define MIN_DELIVERY_DIFF_FACTOR 0.75f -#define ACCELEROMETER_ENABLED 0x01 -#define GRAVITY_ENABLED 0x02 -#define LINEAR_ACCEL_ENABLED 3 +#define GRAVITY 9.80665 linear_accel_sensor::linear_accel_sensor() : m_accel_sensor(NULL) -, m_gyro_sensor(NULL) -, m_magnetic_sensor(NULL) -, m_fusion_sensor(NULL) +, m_gravity_sensor(NULL) +, m_x(0) +, m_y(0) +, m_z(0) +, m_gx(0) +, m_gy(0) +, m_gz(0) +, m_accuracy(0) , m_time(0) { - virtual_sensor_config &config = virtual_sensor_config::get_instance(); - - m_name = string(SENSOR_NAME); - m_enable_linear_accel = 0; - register_supported_event(LINEAR_ACCEL_RAW_DATA_EVENT); - - sensor_hal *fusion_sensor_hal = sensor_loader::get_instance().get_sensor_hal(SENSOR_HAL_TYPE_FUSION); - if (!fusion_sensor_hal) - m_hardware_fusion = false; - else - m_hardware_fusion = true; - - - if (!config.get(SENSOR_TYPE_LINEAR_ACCEL, ELEMENT_VENDOR, m_vendor)) { - _E("[VENDOR] is empty\n"); - throw ENXIO; - } - - _I("m_vendor = %s", m_vendor.c_str()); - - if (!config.get(SENSOR_TYPE_LINEAR_ACCEL, ELEMENT_RAW_DATA_UNIT, m_raw_data_unit)) { - _E("[RAW_DATA_UNIT] is empty\n"); - throw ENXIO; - } - - _I("m_raw_data_unit = %s", m_raw_data_unit.c_str()); - - if (!config.get(SENSOR_TYPE_ORIENTATION, ELEMENT_ORIENTATION_DATA_UNIT, m_orientation_data_unit)) { - _E("[ORIENTATION_DATA_UNIT] is empty\n"); - throw ENXIO; - } - - _I("m_orientation_data_unit = %s", m_orientation_data_unit.c_str()); - - if (!config.get(SENSOR_TYPE_LINEAR_ACCEL, ELEMENT_DEFAULT_SAMPLING_TIME, &m_default_sampling_time)) { - _E("[DEFAULT_SAMPLING_TIME] is empty\n"); - throw ENXIO; - } - - _I("m_default_sampling_time = %d", m_default_sampling_time); - - if (!config.get(SENSOR_TYPE_LINEAR_ACCEL, ELEMENT_ACCEL_STATIC_BIAS, m_accel_static_bias, 3)) { - _E("[ACCEL_STATIC_BIAS] is empty\n"); - throw ENXIO; - } - - if (!config.get(SENSOR_TYPE_LINEAR_ACCEL, ELEMENT_ACCEL_ROTATION_DIRECTION_COMPENSATION, m_accel_rotation_direction_compensation, 3)) { - _E("[ACCEL_ROTATION_DIRECTION_COMPENSATION] is empty\n"); - throw ENXIO; - } - - _I("m_accel_rotation_direction_compensation = (%d, %d, %d)", m_accel_rotation_direction_compensation[0], m_accel_rotation_direction_compensation[1], m_accel_rotation_direction_compensation[2]); - - if (!config.get(SENSOR_TYPE_GRAVITY, ELEMENT_GRAVITY_SIGN_COMPENSATION, m_gravity_sign_compensation, 3)) { - _E("[GRAVITY_SIGN_COMPENSATION] is empty\n"); - throw ENXIO; - } - - _I("m_gravity_sign_compensation = (%d, %d, %d)", m_gravity_sign_compensation[0], m_gravity_sign_compensation[1], m_gravity_sign_compensation[2]); - - if (!config.get(SENSOR_TYPE_LINEAR_ACCEL, ELEMENT_LINEAR_ACCEL_SIGN_COMPENSATION, m_linear_accel_sign_compensation, 3)) { - _E("[LINEAR_ACCEL_SIGN_COMPENSATION] is empty\n"); - throw ENXIO; - } - - _I("m_linear_accel_sign_compensation = (%d, %d, %d)", m_linear_accel_sign_compensation[0], m_linear_accel_sign_compensation[1], m_linear_accel_sign_compensation[2]); - - if (!config.get(SENSOR_TYPE_ORIENTATION, ELEMENT_AZIMUTH_ROTATION_COMPENSATION, &m_azimuth_rotation_compensation)) { - _E("[AZIMUTH_ROTATION_COMPENSATION] is empty\n"); - throw ENXIO; - } - - _I("m_azimuth_rotation_compensation = %d", m_azimuth_rotation_compensation); - - if (!config.get(SENSOR_TYPE_ORIENTATION, ELEMENT_PITCH_ROTATION_COMPENSATION, &m_pitch_rotation_compensation)) { - _E("[PITCH_ROTATION_COMPENSATION] is empty\n"); - throw ENXIO; - } - - _I("m_pitch_rotation_compensation = %d", m_pitch_rotation_compensation); - - if (!config.get(SENSOR_TYPE_ORIENTATION, ELEMENT_ROLL_ROTATION_COMPENSATION, &m_roll_rotation_compensation)) { - _E("[ROLL_ROTATION_COMPENSATION] is empty\n"); - throw ENXIO; - } - - _I("m_roll_rotation_compensation = %d", m_roll_rotation_compensation); - - m_interval = m_default_sampling_time * MS_TO_US; - } linear_accel_sensor::~linear_accel_sensor() @@ -174,249 +61,177 @@ linear_accel_sensor::~linear_accel_sensor() bool linear_accel_sensor::init() { m_accel_sensor = sensor_loader::get_instance().get_sensor(ACCELEROMETER_SENSOR); - m_gyro_sensor = sensor_loader::get_instance().get_sensor(GYROSCOPE_SENSOR); - m_magnetic_sensor = sensor_loader::get_instance().get_sensor(GEOMAGNETIC_SENSOR); - m_fusion_sensor = sensor_loader::get_instance().get_sensor(FUSION_SENSOR); + if (!m_accel_sensor) { + _E("cannot load accelerometer sensor_hal[%s]", get_name()); + return false; + } + + m_gravity_sensor = sensor_loader::get_instance().get_sensor(GRAVITY_SENSOR); - if (!m_accel_sensor || !m_gyro_sensor || !m_magnetic_sensor || !m_fusion_sensor) { - _E("Failed to load sensors, accel: 0x%x, gyro: 0x%x, mag: 0x%x, fusion: 0x%x", - m_accel_sensor, m_gyro_sensor, m_magnetic_sensor, m_fusion_sensor); + if (!m_gravity_sensor) { + _E("cannot load gravity sensor_hal[%s]", get_name()); return false; } - _I("%s is created!", sensor_base::get_name()); + _I("%s is created!\n", get_name()); + return true; } -void linear_accel_sensor::get_types(vector &types) +sensor_type_t linear_accel_sensor::get_type(void) { - types.push_back(LINEAR_ACCEL_SENSOR); + return LINEAR_ACCEL_SENSOR; } -bool linear_accel_sensor::on_start(void) +unsigned int linear_accel_sensor::get_event_type(void) { - AUTOLOCK(m_mutex); - - m_accel_sensor->add_client(ACCELEROMETER_RAW_DATA_EVENT); - m_accel_sensor->add_interval((intptr_t)this, (m_interval/MS_TO_US), false); - m_accel_sensor->start(); - - if (!m_hardware_fusion) { - m_gyro_sensor->add_client(GYROSCOPE_RAW_DATA_EVENT); - m_gyro_sensor->add_interval((intptr_t)this, (m_interval/MS_TO_US), false); - m_gyro_sensor->start(); - m_magnetic_sensor->add_client(GEOMAGNETIC_RAW_DATA_EVENT); - m_magnetic_sensor->add_interval((intptr_t)this, (m_interval/MS_TO_US), false); - m_magnetic_sensor->start(); - } - - m_fusion_sensor->register_supported_event(FUSION_EVENT); - m_fusion_sensor->register_supported_event(FUSION_ORIENTATION_ENABLED); - m_fusion_sensor->add_client(FUSION_EVENT); - m_fusion_sensor->add_interval((intptr_t)this, (m_interval/MS_TO_US), false); - m_fusion_sensor->start(); - - activate(); - return true; + return LINEAR_ACCEL_EVENT_RAW_DATA_REPORT_ON_TIME; } -bool linear_accel_sensor::on_stop(void) +const char* linear_accel_sensor::get_name(void) { - AUTOLOCK(m_mutex); - m_accel_sensor->delete_client(ACCELEROMETER_RAW_DATA_EVENT); - m_accel_sensor->delete_interval((intptr_t)this, false); - m_accel_sensor->stop(); - - if (!m_hardware_fusion) { - m_gyro_sensor->delete_client(GYROSCOPE_RAW_DATA_EVENT); - m_gyro_sensor->delete_interval((intptr_t)this, false); - m_gyro_sensor->stop(); - m_magnetic_sensor->delete_client(GEOMAGNETIC_RAW_DATA_EVENT); - m_magnetic_sensor->delete_interval((intptr_t)this, false); - m_magnetic_sensor->stop(); - } + return SENSOR_NAME; +} - m_fusion_sensor->delete_client(FUSION_EVENT); - m_fusion_sensor->delete_interval((intptr_t)this, false); - m_fusion_sensor->unregister_supported_event(FUSION_EVENT); - m_fusion_sensor->unregister_supported_event(FUSION_ORIENTATION_ENABLED); - m_fusion_sensor->stop(); +bool linear_accel_sensor::get_sensor_info(sensor_info &info) +{ + info.set_type(get_type()); + info.set_id(get_id()); + info.set_privilege(SENSOR_PRIVILEGE_PUBLIC); // FIXME + info.set_name("Linear Accelerometer Sensor"); + info.set_vendor("Samsung Electronics"); + info.set_min_range(-19.6); + info.set_max_range(19.6); + info.set_resolution(0.01); + info.set_min_interval(1); + info.set_fifo_count(0); + info.set_max_batch_count(0); + info.set_supported_event(get_event_type()); + info.set_wakeup_supported(false); - deactivate(); return true; } -bool linear_accel_sensor::add_interval(int client_id, unsigned int interval) +void linear_accel_sensor::synthesize(const sensor_event_t& event) { - AUTOLOCK(m_mutex); - m_accel_sensor->add_interval(client_id, interval, false); - - if (!m_hardware_fusion) { - m_gyro_sensor->add_interval(client_id, interval, false); - m_magnetic_sensor->add_interval(client_id, interval, false); - } + if (event.event_type == GRAVITY_EVENT_RAW_DATA_REPORT_ON_TIME) { + m_gx = event.data->values[0]; + m_gy = event.data->values[1]; + m_gz = event.data->values[2]; + return; + } + + if (event.event_type == ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME) { + m_time = event.data->timestamp; + m_x = event.data->values[0] - m_gx; + m_y = event.data->values[1] - m_gy; + m_z = event.data->values[2] - m_gz; + + sensor_event_t *linear_accel_event; + sensor_data_t *linear_accel_data; + int data_length; + int remains; + + linear_accel_event = (sensor_event_t *)malloc(sizeof(sensor_event_t)); + if (!linear_accel_event) { + _E("Failed to allocate memory"); + return; + } - m_fusion_sensor->add_interval(client_id, interval, false); + remains = get_data(&linear_accel_data, &data_length); - return sensor_base::add_interval(client_id, interval, false); -} + if (remains < 0) + return; -bool linear_accel_sensor::delete_interval(int client_id) -{ - AUTOLOCK(m_mutex); - m_accel_sensor->delete_interval(client_id, false); + linear_accel_event->sensor_id = get_id(); + linear_accel_event->event_type = LINEAR_ACCEL_EVENT_RAW_DATA_REPORT_ON_TIME; + linear_accel_event->data_length = data_length; + linear_accel_event->data = linear_accel_data; - if (!m_hardware_fusion) { - m_gyro_sensor->delete_interval(client_id, false); - m_magnetic_sensor->delete_interval(client_id, false); + push(linear_accel_event); } - - m_fusion_sensor->delete_interval(client_id, false); - - return sensor_base::delete_interval(client_id, false); } -sensor_data_t linear_accel_sensor::calculate_gravity(sensor_data_t data) +int linear_accel_sensor::get_data(sensor_data_t **data, int *length) { - sensor_data_t gravity_data; - float pitch, roll, azimuth; - float azimuth_offset; + /* if It is batch sensor, remains can be 2+ */ + int remains = 1; - quaternion quat(data.values[0], data.values[1], - data.values[2], data.values[3]); + sensor_data_t *sensor_data; + sensor_data = (sensor_data_t *)malloc(sizeof(sensor_data_t)); - euler_angles euler = quat2euler(quat); - - if(m_orientation_data_unit == "DEGREES") { - euler = rad2deg(euler); - azimuth_offset = AZIMUTH_OFFSET_DEGREES; - } - else { - azimuth_offset = AZIMUTH_OFFSET_RADIANS; - } - - euler.m_ang.m_vec[0] *= m_pitch_rotation_compensation; - euler.m_ang.m_vec[1] *= m_roll_rotation_compensation; - euler.m_ang.m_vec[2] *= m_azimuth_rotation_compensation; - - pitch = euler.m_ang.m_vec[0]; - roll = euler.m_ang.m_vec[1]; - if (euler.m_ang.m_vec[2] >= 0) - azimuth = euler.m_ang.m_vec[2]; - else - azimuth = euler.m_ang.m_vec[2] + azimuth_offset; - - if(m_orientation_data_unit == "DEGREES") { - azimuth *= DEG2RAD; - pitch *= DEG2RAD; - roll *= DEG2RAD; - } + sensor_data->accuracy = SENSOR_ACCURACY_GOOD; + sensor_data->timestamp = m_time; + sensor_data->value_count = 3; + sensor_data->values[0] = m_x; + sensor_data->values[1] = m_y; + sensor_data->values[2] = m_z; + *data = sensor_data; + *length = sizeof(sensor_data_t); - if ((roll >= (M_PI/2)-DEVIATION && roll <= (M_PI/2)+DEVIATION) || - (roll >= -(M_PI/2)-DEVIATION && roll <= -(M_PI/2)+DEVIATION)) { - gravity_data.values[0] = m_gravity_sign_compensation[0] * GRAVITY * sin(roll) * cos(azimuth); - gravity_data.values[1] = m_gravity_sign_compensation[1] * GRAVITY * sin(azimuth); - gravity_data.values[2] = m_gravity_sign_compensation[2] * GRAVITY * cos(roll); - } else if ((pitch >= (M_PI/2)-DEVIATION && pitch <= (M_PI/2)+DEVIATION) || - (pitch >= -(M_PI/2)-DEVIATION && pitch <= -(M_PI/2)+DEVIATION)) { - gravity_data.values[0] = m_gravity_sign_compensation[0] * GRAVITY * sin(azimuth); - gravity_data.values[1] = m_gravity_sign_compensation[1] * GRAVITY * sin(pitch) * cos(azimuth); - gravity_data.values[2] = m_gravity_sign_compensation[2] * GRAVITY * cos(pitch); - } else { - gravity_data.values[0] = m_gravity_sign_compensation[0] * GRAVITY * sin(roll); - gravity_data.values[1] = m_gravity_sign_compensation[1] * GRAVITY * sin(pitch); - gravity_data.values[2] = m_gravity_sign_compensation[2] * GRAVITY * cos(roll) * cos(pitch); - } - gravity_data.value_count = 3; - gravity_data.timestamp = m_time; - gravity_data.accuracy = SENSOR_ACCURACY_GOOD; - - return gravity_data; + return --remains; } -void linear_accel_sensor::synthesize(const sensor_event_t &event, vector &outs) +bool linear_accel_sensor::add_interval(int client_id, unsigned int interval, bool is_processor) { - sensor_event_t lin_accel_event; - sensor_data_t gravity_data; + if (m_accel_sensor) + m_accel_sensor->add_interval(client_id, interval, true); - unsigned long long diff_time; + if (m_gravity_sensor) + m_gravity_sensor->add_interval(client_id, interval, true); - if (event.event_type == ACCELEROMETER_RAW_DATA_EVENT) { - diff_time = event.data.timestamp - m_time; + return sensor_base::add_interval(client_id, interval, is_processor); +} - if (m_time && (diff_time < m_interval * MIN_DELIVERY_DIFF_FACTOR)) - return; +bool linear_accel_sensor::delete_interval(int client_id, bool is_processor) +{ + if (m_accel_sensor) + m_accel_sensor->delete_interval(client_id, true); - m_accel.m_data.m_vec[0] = m_accel_rotation_direction_compensation[0] * (event.data.values[0] - m_accel_static_bias[0]) / ACCEL_SCALE; - m_accel.m_data.m_vec[1] = m_accel_rotation_direction_compensation[1] * (event.data.values[1] - m_accel_static_bias[1]) / ACCEL_SCALE; - m_accel.m_data.m_vec[2] = m_accel_rotation_direction_compensation[2] * (event.data.values[2] - m_accel_static_bias[2]) / ACCEL_SCALE; + if (m_gravity_sensor) + m_gravity_sensor->delete_interval(client_id, true); - m_accel.m_time_stamp = event.data.timestamp; + return sensor_base::delete_interval(client_id, is_processor); +} - m_enable_linear_accel |= ACCELEROMETER_ENABLED; - } - else if (event.event_type == FUSION_EVENT) { - diff_time = event.data.timestamp - m_time; +bool linear_accel_sensor::set_interval(unsigned long interval) +{ + m_interval = interval; + return true; +} - if (m_time && (diff_time < m_interval * MIN_DELIVERY_DIFF_FACTOR)) - return; +bool linear_accel_sensor::set_batch_latency(unsigned long latency) +{ + return false; +} - gravity_data = calculate_gravity(event.data); +bool linear_accel_sensor::set_wakeup(int wakeup) +{ + return false; +} - m_enable_linear_accel |= GRAVITY_ENABLED; - } +bool linear_accel_sensor::on_start(void) +{ + if (m_accel_sensor) + m_accel_sensor->start(); - if (m_enable_linear_accel == LINEAR_ACCEL_ENABLED) { - m_enable_linear_accel = 0; - - m_time = get_timestamp(); - lin_accel_event.sensor_id = get_id(); - lin_accel_event.event_type = LINEAR_ACCEL_RAW_DATA_EVENT; - lin_accel_event.data.value_count = 3; - lin_accel_event.data.timestamp = m_time; - lin_accel_event.data.accuracy = SENSOR_ACCURACY_GOOD; - lin_accel_event.data.values[0] = m_linear_accel_sign_compensation[0] * (m_accel.m_data.m_vec[0] - gravity_data.values[0]); - lin_accel_event.data.values[1] = m_linear_accel_sign_compensation[1] * (m_accel.m_data.m_vec[1] - gravity_data.values[1]); - lin_accel_event.data.values[2] = m_linear_accel_sign_compensation[2] * (m_accel.m_data.m_vec[2] - gravity_data.values[2]); - push(lin_accel_event); - } + if (m_gravity_sensor) + m_gravity_sensor->start(); - return; + m_time = 0; + return activate(); } -int linear_accel_sensor::get_sensor_data(const unsigned int event_type, sensor_data_t &data) +bool linear_accel_sensor::on_stop(void) { - sensor_data_t gravity_data, accel_data, fusion_data; - m_fusion_sensor->get_sensor_data(FUSION_ORIENTATION_ENABLED, fusion_data); - m_accel_sensor->get_sensor_data(ACCELEROMETER_RAW_DATA_EVENT, accel_data); - - gravity_data = calculate_gravity(fusion_data); - - accel_data.values[0] = m_accel_rotation_direction_compensation[0] * (accel_data.values[0] - m_accel_static_bias[0]) / ACCEL_SCALE; - accel_data.values[1] = m_accel_rotation_direction_compensation[1] * (accel_data.values[1] - m_accel_static_bias[1]) / ACCEL_SCALE; - accel_data.values[2] = m_accel_rotation_direction_compensation[2] * (accel_data.values[2] - m_accel_static_bias[2]) / ACCEL_SCALE; - - if (event_type != LINEAR_ACCEL_RAW_DATA_EVENT) - return -1; - - data.accuracy = SENSOR_ACCURACY_GOOD; - data.timestamp = get_timestamp(); - data.values[0] = m_linear_accel_sign_compensation[0] * (accel_data.values[0] - gravity_data.values[0]); - data.values[1] = m_linear_accel_sign_compensation[1] * (accel_data.values[1] - gravity_data.values[1]); - data.values[2] = m_linear_accel_sign_compensation[2] * (accel_data.values[2] - gravity_data.values[2]); - data.value_count = 3; - return 0; -} + if (m_accel_sensor) + m_accel_sensor->stop(); -bool linear_accel_sensor::get_properties(sensor_type_t sensor_type, sensor_properties_s &properties) -{ - m_accel_sensor->get_properties(ACCELEROMETER_SENSOR, properties); - properties.name = "Linear Acceleration Sensor"; - properties.vendor = m_vendor; - properties.resolution = 0.000001; + if (m_gravity_sensor) + m_gravity_sensor->stop(); - return true; + m_time = 0; + return deactivate(); } - diff --git a/src/sensor/linear_accel/linear_accel_sensor.h b/src/sensor/linear_accel/linear_accel_sensor.h index a9219cd..1c2be40 100644 --- a/src/sensor/linear_accel/linear_accel_sensor.h +++ b/src/sensor/linear_accel/linear_accel_sensor.h @@ -20,57 +20,51 @@ #ifndef _LINEAR_ACCEL_SENSOR_H_ #define _LINEAR_ACCEL_SENSOR_H_ -#include #include -#include +#include class linear_accel_sensor : public virtual_sensor { public: linear_accel_sensor(); virtual ~linear_accel_sensor(); - bool init(); - virtual void get_types(std::vector &types); + /* initialize sensor */ + bool init(void); - void synthesize(const sensor_event_t& event, std::vector &outs); + /* sensor info */ + virtual sensor_type_t get_type(void); + virtual unsigned int get_event_type(void); + virtual const char* get_name(void); - bool add_interval(int client_id, unsigned int interval); - bool delete_interval(int client_id); + virtual bool get_sensor_info(sensor_info &info); - 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); + /* synthesize event */ + virtual void synthesize(const sensor_event_t& event); + + bool add_interval(int client_id, unsigned int interval, bool is_processor); + bool delete_interval(int client_id, bool is_processor); + /* get data */ + virtual int get_data(sensor_data_t **data, int *length); private: sensor_base *m_accel_sensor; - sensor_base *m_gyro_sensor; - sensor_base *m_magnetic_sensor; - sensor_base *m_fusion_sensor; - - sensor_data m_accel; - sensor_data m_gyro; - sensor_data m_magnetic; - - cmutex m_value_mutex; + sensor_base *m_gravity_sensor; + float m_x; + float m_y; + float m_z; + float m_gx; + float m_gy; + float m_gz; + int m_accuracy; unsigned long long m_time; - unsigned int m_interval; - - unsigned int m_enable_linear_accel; + unsigned long m_interval; - 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]; - int m_linear_accel_sign_compensation[3]; - int m_gravity_sign_compensation[3]; - int m_azimuth_rotation_compensation; - int m_pitch_rotation_compensation; - int m_roll_rotation_compensation; + virtual bool set_interval(unsigned long interval); + virtual bool set_batch_latency(unsigned long latency); + virtual bool set_wakeup(int wakeup); - bool on_start(void); - bool on_stop(void); - sensor_data_t calculate_gravity(sensor_data_t data); + virtual bool on_start(void); + virtual bool on_stop(void); }; #endif diff --git a/src/server/sensor_fusion.cpp b/src/server/sensor_fusion.cpp new file mode 100644 index 0000000..b6379f1 --- /dev/null +++ b/src/server/sensor_fusion.cpp @@ -0,0 +1,106 @@ +/* + * sensord + * + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +sensor_fusion::sensor_fusion() +{ + +} + +sensor_fusion::~sensor_fusion() +{ + +} + +bool sensor_fusion::is_fusion(void) +{ + return true; +} + +bool sensor_fusion::is_virtual(void) +{ + return false; +} + +bool sensor_fusion::is_data_ready(void) +{ + return true; +} + +void sensor_fusion::clear_data(void) +{ + return; +} + +bool sensor_fusion::get_rotation_matrix(arr33_t &rot, int &accuracy) +{ + return false; +} + +bool sensor_fusion::get_attitude(float &x, float &y, float &z, float &w) +{ + return false; +} + +bool sensor_fusion::get_gyro_bias(float &x, float &y, float &z) +{ + return false; +} + +bool sensor_fusion::get_rotation_vector(float &x, float &y, float &z, float &w, float &heading_accuracy, int &accuracy) +{ + return false; +} + +bool sensor_fusion::get_linear_acceleration(float &x, float &y, float &z, int &accuracy) +{ + return false; +} + +bool sensor_fusion::get_gravity(float &x, float &y, float &z, int &accuracy) +{ + return false; +} + +bool sensor_fusion::get_rotation_vector_6axis(float &x, float &y, float &z, float &w, float &heading_accuracy, int &accuracy) +{ + return false; +} + +bool sensor_fusion::get_geomagnetic_rotation_vector(float &x, float &y, float &z, float &w, int &accuracy) +{ + return false; +} + +bool sensor_fusion::get_orientation(float &azimuth, float &pitch, float &roll, int &accuracy) +{ + return false; +} + +bool sensor_fusion::set_interval(unsigned int event_type, int client_id, unsigned int interval) +{ + return sensor_base::add_interval(client_id, interval, true); +} + +bool sensor_fusion::unset_interval(unsigned int event_type, int client_id) +{ + return sensor_base::delete_interval(client_id, true); +} + diff --git a/src/server/sensor_fusion.h b/src/server/sensor_fusion.h new file mode 100644 index 0000000..ec9701d --- /dev/null +++ b/src/server/sensor_fusion.h @@ -0,0 +1,59 @@ +/* + * sensord + * + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _SENSOR_FUSION_H_ +#define _SENSOR_FUSION_H_ + +#include +#include + +enum fusion_event_type { + FUSION_EVENT_AG = (FUSION_SENSOR << 16) | 0x0001, + FUSION_EVENT_AM = (FUSION_SENSOR << 16) | 0x0002, + FUSION_EVENT_AGM = (FUSION_SENSOR << 16) | 0x0004, +}; + +typedef std::array ,3> arr33_t; + +class sensor_fusion : public sensor_base { +public: + sensor_fusion(); + virtual ~sensor_fusion(); + + virtual void fuse(const sensor_event_t& event) = 0; + bool is_fusion(void); + bool is_virtual(void); + virtual bool is_data_ready(void); + virtual void clear_data(void); + virtual bool set_interval(unsigned int event_type, int client_id, unsigned int interval); + virtual bool unset_interval(unsigned int event_type, int client_id); + virtual unsigned long long get_data_timestamp(void) = 0; + + virtual bool get_rotation_matrix(arr33_t &rot, int &accuracy); + virtual bool get_attitude(float &x, float &y, float &z, float &w); + virtual bool get_gyro_bias(float &x, float &y, float &z); + virtual bool get_rotation_vector(float &x, float &y, float &z, float &w, float &heading_accuracy, int &accuracy); + virtual bool get_linear_acceleration(float &x, float &y, float &z, int &accuracy); + virtual bool get_gravity(float &x, float &y, float &z, int &accuracy); + virtual bool get_rotation_vector_6axis(float &x, float &y, float &z, float &w, float &heading_accuracy, int &accuracy); + virtual bool get_geomagnetic_rotation_vector(float &x, float &y, float &z, float &w, int &accuracy); + virtual bool get_orientation(float &azimuth, float &pitch, float &roll, int &accuracy); +}; + +#endif diff --git a/src/server/sensor_loader.cpp b/src/server/sensor_loader.cpp index a050df7..dfc8f26 100644 --- a/src/server/sensor_loader.cpp +++ b/src/server/sensor_loader.cpp @@ -29,10 +29,17 @@ #include #include -#include +#include + #ifdef ENABLE_AUTO_ROTATION #include #endif +#ifdef ENABLE_GRAVITY +#include +#endif +#ifdef ENABLE_LINEAR_ACCEL +#include +#endif using std::vector; using std::string; @@ -127,10 +134,24 @@ bool sensor_loader::load_sensor_devices(const string &path, void* &handle) void sensor_loader::create_sensors(void) { - create_physical_sensors(ACCELEROMETER_SENSOR); + /* HRM sensors need SENSOR_PERMISSION_BIO */ + create_physical_sensors(HRM_RAW_SENSOR); + create_physical_sensors(HRM_SENSOR); + create_physical_sensors(HRM_LED_GREEN_SENSOR); + create_physical_sensors(HRM_LED_IR_SENSOR); + create_physical_sensors(HRM_LED_RED_SENSOR); + create_physical_sensors(UNKNOWN_SENSOR); +#ifdef ENABLE_AUTO_ROTATION create_virtual_sensors("Auto Rotation"); +#endif +#ifdef ENABLE_GRAVITY + create_virtual_sensors("Gravity"); +#endif +#ifdef ENABLE_LINEAR_ACCEL + create_virtual_sensors("Linear Accel"); +#endif } template -- 2.7.4