diff options
author | Mu-Woong Lee <muwoong.lee@samsung.com> | 2016-02-03 16:48:13 +0900 |
---|---|---|
committer | Mu-Woong Lee <muwoong.lee@samsung.com> | 2016-02-03 16:48:13 +0900 |
commit | 902579ece56be0b1170489ffd399a779d2a9c1d8 (patch) | |
tree | ca3af8940740623089cf3777927b2fecf3027e66 | |
parent | 9afa6fb918488d51bf64e2b753aef56bac322c96 (diff) | |
download | sensor-tm1-902579ece56be0b1170489ffd399a779d2a9c1d8.tar.gz sensor-tm1-902579ece56be0b1170489ffd399a779d2a9c1d8.tar.bz2 sensor-tm1-902579ece56be0b1170489ffd399a779d2a9c1d8.zip |
sensor-hal: re-organize build procedure
Change-Id: I7e34d8f61cc69c2c8a021fcb9969f48882aa048e
Signed-off-by: Mu-Woong Lee <muwoong.lee@samsung.com>
-rw-r--r-- | CMakeLists.txt | 97 | ||||
-rw-r--r-- | packaging/sensor-plugins-tm1.spec | 25 | ||||
-rw-r--r-- | src/CMakeLists.txt | 85 | ||||
-rw-r--r--[-rwxr-xr-x] | src/accel/accel_sensor_device.cpp (renamed from src/plugins/accel/accel_sensor_device.cpp) | 2 | ||||
-rw-r--r--[-rwxr-xr-x] | src/accel/accel_sensor_device.h (renamed from src/plugins/accel/accel_sensor_device.h) | 0 | ||||
-rw-r--r-- | src/create.cpp | 98 | ||||
-rw-r--r--[-rwxr-xr-x] | src/gyro/gyro_sensor_hal.cpp (renamed from src/plugins/gyro/gyro_sensor_hal.cpp) | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | src/gyro/gyro_sensor_hal.h (renamed from src/plugins/gyro/gyro_sensor_hal.h) | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | src/hrm_led_red/bio_led_red_sensor_hal.cpp (renamed from src/plugins/bio_led_red/bio_led_red_sensor_hal.cpp) | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | src/hrm_led_red/bio_led_red_sensor_hal.h (renamed from src/plugins/bio_led_red/bio_led_red_sensor_hal.h) | 0 | ||||
-rwxr-xr-x | src/lib/cconfig.cpp | 72 | ||||
-rwxr-xr-x | src/lib/cconfig.h | 41 | ||||
-rw-r--r-- | src/lib/sensor_logs.cpp | 111 | ||||
-rwxr-xr-x | src/lib/sensor_logs.h | 218 | ||||
-rw-r--r--[-rwxr-xr-x] | src/light/light_sensor_hal.cpp (renamed from src/plugins/light/light_sensor_hal.cpp) | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | src/light/light_sensor_hal.h (renamed from src/plugins/light/light_sensor_hal.h) | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | src/magnetic/geo_sensor_hal.cpp (renamed from src/plugins/geo/geo_sensor_hal.cpp) | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | src/magnetic/geo_sensor_hal.h (renamed from src/plugins/geo/geo_sensor_hal.h) | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | src/pressure/pressure_sensor_hal.cpp (renamed from src/plugins/pressure/pressure_sensor_hal.cpp) | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | src/pressure/pressure_sensor_hal.h (renamed from src/plugins/pressure/pressure_sensor_hal.h) | 0 | ||||
-rw-r--r-- | src/proximity/proxi_sensor_device.cpp (renamed from src/plugins/proxi/proxi_sensor_device.cpp) | 2 | ||||
-rw-r--r--[-rwxr-xr-x] | src/proximity/proxi_sensor_device.h (renamed from src/plugins/proxi/proxi_sensor_device.h) | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | src/rotation_vector/rv_raw/rv_raw_sensor_hal.cpp (renamed from src/plugins/rotation_vector/rv_raw/rv_raw_sensor_hal.cpp) | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | src/rotation_vector/rv_raw/rv_raw_sensor_hal.h (renamed from src/plugins/rotation_vector/rv_raw/rv_raw_sensor_hal.h) | 0 | ||||
-rw-r--r-- | src/sensor_common.h (renamed from src/lib/sensor_common.h) | 0 | ||||
-rw-r--r-- | src/sensor_device_base.cpp (renamed from src/interface/sensor_device_base.cpp) | 0 | ||||
-rw-r--r-- | src/sensor_device_base.h (renamed from src/interface/sensor_device_base.h) | 0 | ||||
-rw-r--r-- | src/sensor_device_create.cpp.in | 152 | ||||
-rw-r--r-- | src/sensor_hal.h (renamed from src/interface/sensor_hal.h) | 2 | ||||
-rw-r--r-- | src/sensor_logs.h | 130 | ||||
-rw-r--r--[-rwxr-xr-x] | src/temperature/temperature_sensor_hal.cpp (renamed from src/plugins/temperature/temperature_sensor_hal.cpp) | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | src/temperature/temperature_sensor_hal.h (renamed from src/plugins/temperature/temperature_sensor_hal.h) | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | src/ultraviolet/ultraviolet_sensor_hal.cpp (renamed from src/plugins/ultraviolet/ultraviolet_sensor_hal.cpp) | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | src/ultraviolet/ultraviolet_sensor_hal.h (renamed from src/plugins/ultraviolet/ultraviolet_sensor_hal.h) | 0 |
34 files changed, 326 insertions, 709 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 3e511fe..7d06cdb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,19 @@ -cmake_minimum_required(VERSION 2.6) -project(sensor-plugins CXX) -include(GNUInstallDirs) +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(sensor-plugins-tm1 CXX) +INCLUDE(GNUInstallDirs) + + +SET(ACCEL "ON") +SET(GYRO "OFF") +SET(PROXIMITY "ON") +SET(LIGHT "OFF") +SET(MAGNETIC "OFF") +SET(PRESSURE "OFF") +SET(TEMPERATURE "OFF") +SET(ULTRAVIOLET "OFF") +SET(ROTATION_VECTOR "OFF") +SET(HRM_LED_RED "OFF") + # Common Options SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O2 -omit-frame-pointer -std=gnu++0x") @@ -9,11 +22,77 @@ SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-section -Wl,--pri MESSAGE("FLAGS: ${CMAKE_CXX_FLAGS}") MESSAGE("FLAGS: ${CMAKE_EXE_LINKER_FLAGS}") -add_definitions(-DUSE_DLOG_LOG) -add_definitions(-DLIBDIR="${CMAKE_INSTALL_LIBDIR}") - # Internal Debugging Options -#add_definitions(-Wall -g -D_DEBUG) +#ADD_DEFINITIONS(-Wall -g -D_DEBUG) + +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(plugin_pkgs REQUIRED dlog) + +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_SOURCE_DIR}/src) +FILE(GLOB SRCS src/*.cpp) + +IF("${ACCEL}" STREQUAL "ON") +FILE(GLOB_RECURSE SRCS ${SRCS} src/accel/*.cpp) +ADD_DEFINITIONS(-DENABLE_ACCEL) +ENDIF() + +IF("${GYRO}" STREQUAL "ON") +FILE(GLOB_RECURSE SRCS ${SRCS} src/gyro/*.cpp) +ADD_DEFINITIONS(-DENABLE_GYRO) +ENDIF() + +IF("${PROXIMITY}" STREQUAL "ON") +FILE(GLOB_RECURSE SRCS ${SRCS} src/proximity/*.cpp) +ADD_DEFINITIONS(-DENABLE_PROXIMITY) +ENDIF() + +IF("${LIGHT}" STREQUAL "ON") +FILE(GLOB_RECURSE SRCS ${SRCS} src/light/*.cpp) +ADD_DEFINITIONS(-DENABLE_LIGHT) +ENDIF() + +IF("${MAGNETIC}" STREQUAL "ON") +FILE(GLOB_RECURSE SRCS ${SRCS} src/magnetic/*.cpp) +ADD_DEFINITIONS(-DENABLE_MAGNETIC) +ENDIF() + +IF("${PRESSURE}" STREQUAL "ON") +FILE(GLOB_RECURSE SRCS ${SRCS} src/pressure/*.cpp) +ADD_DEFINITIONS(-DENABLE_PRESSURE) +ENDIF() + +IF("${TEMPERATURE}" STREQUAL "ON") +FILE(GLOB_RECURSE SRCS ${SRCS} src/temperature/*.cpp) +ADD_DEFINITIONS(-DENABLE_TEMPERATURE) +ENDIF() + +IF("${ULTRAVIOLET}" STREQUAL "ON") +FILE(GLOB_RECURSE SRCS ${SRCS} src/ultraviolet/*.cpp) +ADD_DEFINITIONS(-DENABLE_ULTRAVIOLET) +ENDIF() + +IF("${HRM_LED_RED}" STREQUAL "ON") +FILE(GLOB_RECURSE SRCS ${SRCS} src/hrm_led_led/*.cpp) +ADD_DEFINITIONS(-DENABLE_HRM_LED_RED) +ENDIF() + +IF("${ROTATION_VECTOR}" STREQUAL "ON") +FILE(GLOB_RECURSE SRCS ${SRCS} src/rotation_vector/*.cpp) +ADD_DEFINITIONS(-DENABLE_ROTATION_VECTOR) +ENDIF() + +MESSAGE("Sources: ${SRCS}") +ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${plugin_pkgs_LDFLAGS}) -# Sub-directory -add_subdirectory(src) +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}/sensor) diff --git a/packaging/sensor-plugins-tm1.spec b/packaging/sensor-plugins-tm1.spec index 644c42f..c91ca74 100644 --- a/packaging/sensor-plugins-tm1.spec +++ b/packaging/sensor-plugins-tm1.spec @@ -2,7 +2,7 @@ Name: sensor-plugins-tm1 Summary: TM1 Sensor Plugins Version: 1.0.0 Release: 0 -Group: System/Sensor Framework +Group: Service/Sensor License: Apache-2.0 Source0: %{name}-%{version}.tar.gz @@ -15,31 +15,18 @@ ExcludeArch: %{arm} aarch64 %ix86 x86_64 BuildRequires: cmake BuildRequires: pkgconfig(dlog) -%define accel_state ON -%define gyro_state OFF -%define proxi_state ON -%define light_state OFF -%define geo_state OFF -%define pressure_state OFF -%define temperature_state OFF -%define ultraviolet_state OFF -%define rv_state OFF -%define bio_led_red_state OFF - %description TM1 Sensor Plugins %prep %setup -q -cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DACCEL=%{accel_state} \ --DGYRO=%{gyro_state} -DPROXI=%{proxi_state} -DLIGHT=%{light_state} \ --DGEO=%{geo_state} -DPRESSURE=%{pressure_state} -DTEMPERATURE=%{temperature_state} \ --DRV=%{rv_state} -DULTRAVIOLET=%{ultraviolet_state} \ --DBIO_LED_RED=%{bio_led_red_state} \ --DLIBDIR=%{_libdir} -DINCLUDEDIR=%{_includedir} - %build +export CXXFLAGS+=" -Wextra -Wcast-align -Wcast-qual -Wshadow -Wwrite-strings -Wswitch-default" +export CXXFLAGS+=" -Wnon-virtual-dtor -Wno-c++0x-compat -Wno-unused-parameter -Wno-empty-body" +export CXXFLAGS+=" -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-strict-aliasing" +export CXXFLAGS+=" -fno-unroll-loops -fsigned-char -fstrict-overflow" +cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} make %{?jobs:-j%jobs} %install diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt deleted file mode 100644 index 29eb9a6..0000000 --- a/src/CMakeLists.txt +++ /dev/null @@ -1,85 +0,0 @@ -cmake_minimum_required(VERSION 2.6) -project(sensor-plugins-tm1 CXX) - -INCLUDE(FindPkgConfig) -PKG_CHECK_MODULES(plugin_pkgs REQUIRED dlog) - -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_SOURCE_DIR}/src/lib) -include_directories(${CMAKE_SOURCE_DIR}/src/interface) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}) - -IF("${ACCEL}" STREQUAL "ON") -include_directories(${CMAKE_SOURCE_DIR}/src/plugins/accel) -list (APPEND SRCS "plugins/accel/accel_sensor_device.cpp") -add_definitions(-DENABLE_ACCEL) -ENDIF() -IF("${GYRO}" STREQUAL "ON") -include_directories(${CMAKE_SOURCE_DIR}/src/plugins/gyro) -list (APPEND SRCS "plugins/gyro/gyro_sensor_device.cpp") -add_definitions(-DENABLE_GYRO) -ENDIF() -IF("${PROXI}" STREQUAL "ON") -include_directories(${CMAKE_SOURCE_DIR}/src/plugins/proxi) -list (APPEND SRCS "plugins/proxi/proxi_sensor_device.cpp") -add_definitions(-DENABLE_PROXI) -ENDIF() -IF("${LIGHT}" STREQUAL "ON") -include_directories(${CMAKE_SOURCE_DIR}/src/plugins/light) -list (APPEND SRCS "plugins/light/light_sensor_device.cpp") -add_definitions(-DENABLE_LIGHT) -ENDIF() -IF("${GEO}" STREQUAL "ON") -include_directories(${CMAKE_SOURCE_DIR}/src/plugins/geo) -list (APPEND SRCS "plugins/geo/geo_sensor_device.cpp") -add_definitions(-DENABLE_GEO) -ENDIF() -IF("${PRESSURE}" STREQUAL "ON") -include_directories(${CMAKE_SOURCE_DIR}/src/plugins/pressure) -list (APPEND SRCS "plugins/pressure/pressure_sensor_device.cpp") -add_definitions(-DENABLE_PRESSURE) -ENDIF() -IF("${TEMPERATURE}" STREQUAL "ON") -include_directories(${CMAKE_SOURCE_DIR}/src/plugins/temperature) -list (APPEND SRCS "plugins/temperature/temperature_sensor_device.cpp") -add_definitions(-DENABLE_TEMPERATURE) -ENDIF() -IF("${ULTRAVIOLET}" STREQUAL "ON") -include_directories(${CMAKE_SOURCE_DIR}/src/plugins/ultraviolet) -list (APPEND SRCS "plugins/ultraviolet/ultraviolet_sensor_device.cpp") -add_definitions(-DENABLE_ULTRAVIOLET) -ENDIF() -IF("${BIO_LED_RED}" STREQUAL "ON") -include_directories(${CMAKE_SOURCE_DIR}/src/plugins/bio_led_red) -list (APPEND SRCS "plugins/bio_led_red/bio_led_red_sensor_device.cpp") -add_definitions(-DENABLE_BIO_LED_RED) -ENDIF() -IF("${RV}" STREQUAL "ON") -include_directories(${CMAKE_SOURCE_DIR}/src/plugins/rotation_vector/rv_raw) -list (APPEND SRCS "plugins/rotation_vector/rv_raw/rv_raw_sensor_device.cpp") -add_definitions(-DENABLE_RV_RAW) -ENDIF() - -configure_file(sensor_device_create.cpp.in sensor_device_create.cpp) - -add_library(${PROJECT_NAME} SHARED - ${SRCS} - lib/cconfig.cpp - lib/sensor_logs.cpp - interface/sensor_device_base.cpp - interface/sensor_hal.h - sensor_device_create.cpp -) - -target_link_libraries(${PROJECT_NAME} ${plugin_pkgs_LDFLAGS}) - -install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}/sensor) diff --git a/src/plugins/accel/accel_sensor_device.cpp b/src/accel/accel_sensor_device.cpp index 129d454..412bd32 100755..100644 --- a/src/plugins/accel/accel_sensor_device.cpp +++ b/src/accel/accel_sensor_device.cpp @@ -21,8 +21,8 @@ #include <sys/types.h> #include <sys/stat.h> #include <linux/input.h> -#include <accel_sensor_device.h> #include <sys/poll.h> +#include "accel_sensor_device.h" #define GRAVITY 9.80665 #define G_TO_MG 1000 diff --git a/src/plugins/accel/accel_sensor_device.h b/src/accel/accel_sensor_device.h index 8c34ae5..8c34ae5 100755..100644 --- a/src/plugins/accel/accel_sensor_device.h +++ b/src/accel/accel_sensor_device.h diff --git a/src/create.cpp b/src/create.cpp new file mode 100644 index 0000000..e7e6ab8 --- /dev/null +++ b/src/create.cpp @@ -0,0 +1,98 @@ +/* + * sensor-plugins-tm1 + * + * 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 <sensor_common.h> + +#include "accel/accel_sensor_device.h" +//#include "gyro/gyro_sensor_device.h" +//#include "magnetic/geo_sensor_device.h" +#include "proximity/proxi_sensor_device.h" +//#include "light/light_sensor_device.h" +//#include "rotation_vector/rv_raw_sensor_device.h" +//#include "pressure/pressure_sensor_device.h" +//#include "temperature/temperature_sensor_device.h" +//#include "ultraviolet/ultraviolet_sensor_device.h" +//#include "hrm_led_red/bio_led_red_sensor_device.h" + +static sensor_devices *devices = NULL; + +template<typename _sensor> +void create_sensor(const char *name) +{ + sensor_device *instance = NULL; + try { + instance = new _sensor; + } catch (std::exception &e) { + ERR("Failed to create %s sensor device, exception: %s", name, e.what()); + return; + } catch (int err) { + ERR("Failed to create %s sensor device, err: %d, cause: %s", name, err, strerror(err)); + return; + } + + devices->devices.push_back(instance); +} + +extern "C" sensor_devices* create(void) +{ + devices = new(std::nothrow) sensor_devices; + retvm_if(!devices, NULL, "Failed to allocate memory"); + +#ifdef ENABLE_ACCEL + create_sensor<accel_sensor_device>("Accel"); +#endif + +#ifdef ENABLE_GYRO + create_sensor<gyro_sensor_device>("Gyro"); +#endif + +#ifdef ENABLE_MAGNETIC + create_sensor<geo_sensor_device>("Magnetic"); +#endif + +#ifdef ENABLE_PROXIMITY + create_sensor<proxi_sensor_device>("Proximity"); +#endif + +#ifdef ENABLE_LIGHT + create_sensor<light_sensor_device>("Light"); +#endif + +#ifdef ENABLE_ROTATION_VECTOR + create_sensor<rv_raw_sensor_device>("Rotation Vector"); +#endif + +#ifdef ENABLE_PRESSURE + create_sensor<pressure_sensor_device>("Pressure"); +#endif + +#ifdef ENABLE_TEMPERATURE + create_sensor<temperature_sensor_device>("Temperature"); +#endif + +#ifdef ENABLE_ULTRAVIOLET + create_sensor<ultraviolet_sensor_device>("Ultraviolet"); +#endif + +#ifdef ENABLE_HRM_LED_RED + create_sensor<bio_led_red_sensor_device>("HRM Led Red"); +#endif + + return devices; +} diff --git a/src/plugins/gyro/gyro_sensor_hal.cpp b/src/gyro/gyro_sensor_hal.cpp index 8dab83d..8dab83d 100755..100644 --- a/src/plugins/gyro/gyro_sensor_hal.cpp +++ b/src/gyro/gyro_sensor_hal.cpp diff --git a/src/plugins/gyro/gyro_sensor_hal.h b/src/gyro/gyro_sensor_hal.h index aedd640..aedd640 100755..100644 --- a/src/plugins/gyro/gyro_sensor_hal.h +++ b/src/gyro/gyro_sensor_hal.h diff --git a/src/plugins/bio_led_red/bio_led_red_sensor_hal.cpp b/src/hrm_led_red/bio_led_red_sensor_hal.cpp index ff4745e..ff4745e 100755..100644 --- a/src/plugins/bio_led_red/bio_led_red_sensor_hal.cpp +++ b/src/hrm_led_red/bio_led_red_sensor_hal.cpp diff --git a/src/plugins/bio_led_red/bio_led_red_sensor_hal.h b/src/hrm_led_red/bio_led_red_sensor_hal.h index 3a13682..3a13682 100755..100644 --- a/src/plugins/bio_led_red/bio_led_red_sensor_hal.h +++ b/src/hrm_led_red/bio_led_red_sensor_hal.h diff --git a/src/lib/cconfig.cpp b/src/lib/cconfig.cpp deleted file mode 100755 index 14c7f01..0000000 --- a/src/lib/cconfig.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* - * libsensord-share - * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include <cconfig.h> -#include <fstream> -#include <string> - -using std::ifstream; -using std::string; -using std::istringstream; - -cconfig::cconfig(void) -{ - -} - -cconfig::~cconfig(void) -{ - -} - -bool cconfig::get_device_id(void) -{ - const string INFO_INI_PATH = "/etc/info.ini"; - const string START_DELIMETER = "Model="; - const string END_DELIMETER = ";"; - string line; - ifstream in_file; - std::size_t start_pos, end_pos; - bool ret = false; - - in_file.open(INFO_INI_PATH); - - if (!in_file.is_open()) - return false; - - while (!in_file.eof()) { - 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; - } - } - } - - in_file.close(); - - return ret; -} diff --git a/src/lib/cconfig.h b/src/lib/cconfig.h deleted file mode 100755 index ef2802f..0000000 --- a/src/lib/cconfig.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * libsensord-share - * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef _CCONFIG_H_ -#define _CCONFIG_H_ - -#include <string> -#include <unordered_map> -#include <sensor_logs.h> - -class cconfig -{ -protected: - virtual bool load_config(const std::string& config_path) = 0; - - std::string m_device_id; -public: - cconfig(); - virtual ~cconfig(); - - bool get_device_id(void); - -}; - -#endif /* _CCONFIG_H_ */ diff --git a/src/lib/sensor_logs.cpp b/src/lib/sensor_logs.cpp deleted file mode 100644 index 0269835..0000000 --- a/src/lib/sensor_logs.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* - * libsensord-share - * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -/*TODO: clean up header files*/ -#include <syslog.h> -#include <unistd.h> -#include <sys/types.h> -#include <fcntl.h> -#include <stdio.h> -#include <string.h> -#include <dlog.h> -#include "sensor_logs.h" - -#ifndef EXTAPI -#define EXTAPI __attribute__((visibility("default"))) -#endif - -#define SF_SERVER_MSG_LOG_FILE "/var/log/messages" -#define FILE_LENGTH 255 - -static int sf_debug_file_fd; -static char sf_debug_file_buf[FILE_LENGTH]; - -EXTAPI void sf_log(int type , int priority , const char *tag , const char *fmt , ...) -{ - va_list ap; - va_start(ap, fmt); - - switch (type) { - case SF_LOG_PRINT_FILE: - sf_debug_file_fd = open(SF_SERVER_MSG_LOG_FILE, O_WRONLY|O_CREAT|O_APPEND, 0644); - if (sf_debug_file_fd != -1) { - vsnprintf(sf_debug_file_buf,255, fmt , ap ); - int total_bytes_written = 0; - while (total_bytes_written < (int) strlen(sf_debug_file_buf)){ - int bytes_written = write(sf_debug_file_fd, (sf_debug_file_buf + total_bytes_written), strlen(sf_debug_file_buf) - total_bytes_written); - if (bytes_written == -1) - break; - total_bytes_written = total_bytes_written + bytes_written; - } - close(sf_debug_file_fd); - } - break; - - case SF_LOG_SYSLOG: - int syslog_prio; - switch (priority) { - case SF_LOG_ERR: - syslog_prio = LOG_ERR|LOG_DAEMON; - break; - case SF_LOG_WARN: - syslog_prio = LOG_WARNING|LOG_DAEMON; - break; - - case SF_LOG_DBG: - syslog_prio = LOG_DEBUG|LOG_DAEMON; - break; - - case SF_LOG_INFO: - syslog_prio = LOG_INFO|LOG_DAEMON; - break; - - default: - syslog_prio = priority; - break; - } - - vsyslog(syslog_prio, fmt, ap); - break; - - case SF_LOG_DLOG: - if (tag) { - switch (priority) { - case SF_LOG_ERR: - SLOG_VA(LOG_ERROR, tag ? tag : "NULL" , fmt ? fmt : "NULL" , ap); - break; - - case SF_LOG_WARN: - SLOG_VA(LOG_WARN, tag ? tag : "NULL" , fmt ? fmt : "NULL" , ap); - break; - - case SF_LOG_DBG: - SLOG_VA(LOG_DEBUG, tag ? tag : "NULL", fmt ? fmt : "NULL" , ap); - break; - - case SF_LOG_INFO: - SLOG_VA(LOG_INFO, tag ? tag : "NULL" , fmt ? fmt : "NULL" , ap); - break; - } - } - break; - } - - va_end(ap); -} diff --git a/src/lib/sensor_logs.h b/src/lib/sensor_logs.h deleted file mode 100755 index 5e405ff..0000000 --- a/src/lib/sensor_logs.h +++ /dev/null @@ -1,218 +0,0 @@ -/* - * libsensord-share - * - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#if !defined(_COMMON_H_) -#define _COMMON_H_ - -#ifndef __cplusplus -#include <stdbool.h> -#endif /* !__cplusplus */ - -#ifdef __cplusplus -extern "C" -{ -#endif - -#if !defined(PATH_MAX) -#define PATH_MAX 256 -#endif - -#if !defined(NAME_MAX) -#define NAME_MAX 256 -#endif - - -#define SENSOR_TYPE_SHIFT 16 - -enum sf_log_type { - SF_LOG_PRINT_FILE = 1, - SF_LOG_SYSLOG = 2, - SF_LOG_DLOG = 3, -}; - -enum sf_priority_type { - SF_LOG_ERR = 1, - SF_LOG_DBG = 2, - SF_LOG_INFO = 3, - SF_LOG_WARN = 4, -}; - -void sf_log(int type , int priority , const char *tag , const char *fmt , ...); - -#define MICROSECONDS(tv) ((tv.tv_sec * 1000000ll) + tv.tv_usec) - -#ifndef __MODULE__ -#include <string.h> -#define __MODULE__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) -#endif - -//for new log system - dlog -#ifdef LOG_TAG - #undef LOG_TAG -#endif -#define LOG_TAG "SENSOR" - -#if defined(_DEBUG) || defined(USE_FILE_DEBUG) - -#define DbgPrint(fmt, arg...) do { sf_log(SF_LOG_PRINT_FILE, 0, LOG_TAG , " [SF_MSG_PRT][%s:%d] " fmt"\n",__MODULE__, __LINE__, ##arg); } while(0) - -#endif - -#if defined(USE_SYSLOG_DEBUG) - -#define ERR(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_ERR, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define WARN(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_WARN, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define INFO(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_INFO, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define DBG(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_DBG, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) - -#define _E(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_ERR, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define _W(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_WARN, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define _I(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_INFO, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define _D(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_DBG, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define _T(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_DBG, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) - - -#elif defined(_DEBUG) || defined(USE_DLOG_DEBUG) - -#define ERR(fmt, arg...) do { sf_log(SF_LOG_DLOG, SF_LOG_ERR, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define WARN(fmt, arg...) do { sf_log(SF_LOG_DLOG, SF_LOG_WARN, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define INFO(fmt, arg...) do { sf_log(SF_LOG_DLOG, SF_LOG_INFO, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define DBG(fmt, arg...) do { sf_log(SF_LOG_DLOG, SF_LOG_DBG, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) - -#define _E(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_ERR, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define _W(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_WARN, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define _I(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_INFO, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define _D(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_DBG, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define _T(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_DBG, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) - -#elif defined(USE_FILE_DEBUG) - -#define ERR(fmt, arg...) do { sf_log(SF_LOG_PRINT_FILE, 0, LOG_TAG, "[SF_MSG_ERR][%s:%d] " fmt"\n",__MODULE__, __LINE__, ##arg); } while(0) -#define WARN(fmt, arg...) do { sf_log(SF_LOG_PRINT_FILE, 0, LOG_TAG, "[SF_MSG_WARN][%s:%d] " fmt"\n",__MODULE__, __LINE__, ##arg); } while(0) -#define DBG(fmt, arg...) do { sf_log(SF_LOG_PRINT_FILE, 0, LOG_TAG, "[SF_MSG_DBG][%s:%d] " fmt"\n",__MODULE__, __LINE__, ##arg); } while(0) -#define INFO(fmt, arg...) do { sf_log(SF_LOG_PRINT_FILE, 0, LOG_TAG, "[SF_MSG_INFO][%s:%d] " fmt"\n",__MODULE__, __LINE__, ##arg); } while(0) - -#define _E(fmt, arg...) do { sf_log(SF_LOG_PRINT_FILE, 0, LOG_TAG ,"[SF_MSG_ERR][%s:%d] " fmt"\n",__MODULE__, __LINE__, ##arg); } while(0) -#define _W(fmt, arg...) do { sf_log(SF_LOG_PRINT_FILE, 0, LOG_TAG ,"[SF_MSG_WARN][%s:%d] " fmt"\n",__MODULE__, __LINE__, ##arg); } while(0) -#define _I(fmt, arg...) do { sf_log(SF_LOG_PRINT_FILE, 0, LOG_TAG ,"[SF_MSG_INFO][%s:%d] " fmt"\n",__MODULE__, __LINE__, ##arg); } while(0) -#define _D(fmt, arg...) do { sf_log(SF_LOG_PRINT_FILE, 0, LOG_TAG ,"[SF_MSG_DBG][%s:%d] " fmt"\n",__MODULE__, __LINE__, ##arg); } while(0) -#define _T(fmt, arg...) do { sf_log(SF_LOG_PRINT_FILE, 0, LOG_TAG ,"[SF_MSG_TEMP][%s:%d] " fmt"\n",__MODULE__, __LINE__, ##arg); } while(0) - -#elif defined(USE_DLOG_LOG) - -#define ERR(fmt, arg...) do { sf_log(SF_LOG_DLOG, SF_LOG_ERR, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define WARN(fmt, arg...) do { sf_log(SF_LOG_DLOG, SF_LOG_WARN, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define INFO(fmt, arg...) do { sf_log(SF_LOG_DLOG, SF_LOG_INFO, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) - -#define DBG(...) do{} while(0) -#define DbgPrint(...) do{} while(0) - - -#define _E(fmt, arg...) do { sf_log(SF_LOG_DLOG, SF_LOG_ERR, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define _W(fmt, arg...) do { sf_log(SF_LOG_DLOG, SF_LOG_WARN, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define _I(fmt, arg...) do { sf_log(SF_LOG_DLOG, SF_LOG_INFO, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define _D(fmt, arg...) do { sf_log(SF_LOG_DLOG, SF_LOG_DBG, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define _T(...) - -#else -#define ERR(fmt, arg...) do { sf_log(SF_LOG_DLOG, SF_LOG_ERR, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define WARN(...) do{} while(0) -#define DbgPrint(...) do{} while(0) -#define DBG(...) do{} while(0) -#define INFO(...) do{} while(0) - -#define _E(fmt, arg...) do { sf_log(SF_LOG_DLOG, SF_LOG_ERR, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0) -#define _W(...) do{} while(0) -#define _I(...) do{} while(0) -#define _D(...) do{} while(0) -#define _T(...) do{} while(0) - -#endif - - -#if defined(_DEBUG) -# define warn_if(expr, fmt, arg...) do { \ - if(expr) { \ - DBG("(%s) -> " fmt, #expr, ##arg); \ - } \ - } while (0) -# define ret_if(expr) do { \ - if(expr) { \ - DBG("(%s) -> %s() return", #expr, __FUNCTION__); \ - return; \ - } \ - } while (0) -# define retv_if(expr, val) do { \ - if(expr) { \ - DBG("(%s) -> %s() return", #expr, __FUNCTION__); \ - return (val); \ - } \ - } while (0) -# define retm_if(expr, fmt, arg...) do { \ - if(expr) { \ - ERR(fmt, ##arg); \ - DBG("(%s) -> %s() return", #expr, __FUNCTION__); \ - return; \ - } \ - } while (0) -# define retvm_if(expr, val, fmt, arg...) do { \ - if(expr) { \ - ERR(fmt, ##arg); \ - DBG("(%s) -> %s() return", #expr, __FUNCTION__); \ - return (val); \ - } \ - } while (0) - -#else -# define warn_if(expr, fmt, arg...) do { \ - if(expr) { \ - ERR(fmt, ##arg); \ - } \ - } while (0) -# define ret_if(expr) do { \ - if(expr) { \ - return; \ - } \ - } while (0) -# define retv_if(expr, val) do { \ - if(expr) { \ - return (val); \ - } \ - } while (0) -# define retm_if(expr, fmt, arg...) do { \ - if(expr) { \ - ERR(fmt, ##arg); \ - return; \ - } \ - } while (0) -# define retvm_if(expr, val, fmt, arg...) do { \ - if(expr) { \ - ERR(fmt, ##arg); \ - return (val); \ - } \ - } while (0) - -#endif - -#ifdef __cplusplus -} -#endif - -#endif -//! End of a file diff --git a/src/plugins/light/light_sensor_hal.cpp b/src/light/light_sensor_hal.cpp index 4f96c55..4f96c55 100755..100644 --- a/src/plugins/light/light_sensor_hal.cpp +++ b/src/light/light_sensor_hal.cpp diff --git a/src/plugins/light/light_sensor_hal.h b/src/light/light_sensor_hal.h index ff98264..ff98264 100755..100644 --- a/src/plugins/light/light_sensor_hal.h +++ b/src/light/light_sensor_hal.h diff --git a/src/plugins/geo/geo_sensor_hal.cpp b/src/magnetic/geo_sensor_hal.cpp index d88287f..d88287f 100755..100644 --- a/src/plugins/geo/geo_sensor_hal.cpp +++ b/src/magnetic/geo_sensor_hal.cpp diff --git a/src/plugins/geo/geo_sensor_hal.h b/src/magnetic/geo_sensor_hal.h index 99ee935..99ee935 100755..100644 --- a/src/plugins/geo/geo_sensor_hal.h +++ b/src/magnetic/geo_sensor_hal.h diff --git a/src/plugins/pressure/pressure_sensor_hal.cpp b/src/pressure/pressure_sensor_hal.cpp index badd9bd..badd9bd 100755..100644 --- a/src/plugins/pressure/pressure_sensor_hal.cpp +++ b/src/pressure/pressure_sensor_hal.cpp diff --git a/src/plugins/pressure/pressure_sensor_hal.h b/src/pressure/pressure_sensor_hal.h index 677b15d..677b15d 100755..100644 --- a/src/plugins/pressure/pressure_sensor_hal.h +++ b/src/pressure/pressure_sensor_hal.h diff --git a/src/plugins/proxi/proxi_sensor_device.cpp b/src/proximity/proxi_sensor_device.cpp index 29410a6..54dce10 100644 --- a/src/plugins/proxi/proxi_sensor_device.cpp +++ b/src/proximity/proxi_sensor_device.cpp @@ -20,7 +20,7 @@ #include <sys/stat.h> #include <dirent.h> #include <linux/input.h> -#include <proxi_sensor_device.h> +#include "proxi_sensor_device.h" #define MODEL_NAME "K2HH" #define VENDOR "ST Microelectronics" diff --git a/src/plugins/proxi/proxi_sensor_device.h b/src/proximity/proxi_sensor_device.h index 368c0a2..368c0a2 100755..100644 --- a/src/plugins/proxi/proxi_sensor_device.h +++ b/src/proximity/proxi_sensor_device.h diff --git a/src/plugins/rotation_vector/rv_raw/rv_raw_sensor_hal.cpp b/src/rotation_vector/rv_raw/rv_raw_sensor_hal.cpp index 216e04d..216e04d 100755..100644 --- a/src/plugins/rotation_vector/rv_raw/rv_raw_sensor_hal.cpp +++ b/src/rotation_vector/rv_raw/rv_raw_sensor_hal.cpp diff --git a/src/plugins/rotation_vector/rv_raw/rv_raw_sensor_hal.h b/src/rotation_vector/rv_raw/rv_raw_sensor_hal.h index 3a2b0ef..3a2b0ef 100755..100644 --- a/src/plugins/rotation_vector/rv_raw/rv_raw_sensor_hal.h +++ b/src/rotation_vector/rv_raw/rv_raw_sensor_hal.h diff --git a/src/lib/sensor_common.h b/src/sensor_common.h index 5b58340..5b58340 100644 --- a/src/lib/sensor_common.h +++ b/src/sensor_common.h diff --git a/src/interface/sensor_device_base.cpp b/src/sensor_device_base.cpp index 0c4f3fe..0c4f3fe 100644 --- a/src/interface/sensor_device_base.cpp +++ b/src/sensor_device_base.cpp diff --git a/src/interface/sensor_device_base.h b/src/sensor_device_base.h index 45c7d66..45c7d66 100644 --- a/src/interface/sensor_device_base.h +++ b/src/sensor_device_base.h diff --git a/src/sensor_device_create.cpp.in b/src/sensor_device_create.cpp.in deleted file mode 100644 index c840a42..0000000 --- a/src/sensor_device_create.cpp.in +++ /dev/null @@ -1,152 +0,0 @@ -#ifdef ENABLE_ACCEL -#include <accel_sensor_device.h> -#endif -#ifdef ENABLE_BIO_LED_RED -#include <bio_led_red_sensor_device.h> -#endif -#ifdef ENABLE_GEO -#include <geo_sensor_device.h> -#endif -#ifdef ENABLE_GYRO -#include <gyro_sensor_device.h> -#endif -#ifdef ENABLE_LIGHT -#include <light_sensor_device.h> -#endif -#ifdef ENABLE_PRESSURE -#include <pressure_sensor_device.h> -#endif -#ifdef ENABLE_PROXI -#include <proxi_sensor_device.h> -#endif -#ifdef ENABLE_RV_RAW -#include <rv_raw_sensor_device.h> -#endif -#ifdef ENABLE_TEMPERATURE -#include <temperature_sensor_device.h> -#endif -#ifdef ENABLE_ULTRAVIOLET -#include <ultraviolet_sensor_device.h> -#endif - -#include <sensor_common.h> - -extern "C" sensor_devices* create(void) -{ - sensor_devices *devices = new(std::nothrow) sensor_devices; - retvm_if(!devices, NULL, "Failed to allocate memory"); - -#ifdef ENABLE_ACCEL - accel_sensor_device *accel_sensor = NULL; - try { - accel_sensor = new(std::nothrow) accel_sensor_device; - } catch (int err) { - ERR("Failed to create accel_sensor_device devices, err: %d, cause: %s", err, strerror(err)); - } - - if (accel_sensor != NULL) { - devices->devices.push_back(accel_sensor); - } -#endif - -#ifdef ENABLE_BIO_LED_RED - bio_led_red_sensor_device *bio_led_red_sensor = NULL; - try { - bio_led_red_sensor = new(std::nothrow) bio_led_red_sensor_device; - } catch (int err) { - ERR("Failed to create bio_led_red_sensor_device devices, err: %d, cause: %s", err, strerror(err)); - } - if (bio_led_red_sensor != NULL) - devices->devices.push_back(bio_led_red_sensor); -#endif - -#ifdef ENABLE_GEO - geo_sensor_device *geo_sensor = NULL; - try { - geo_sensor = new(std::nothrow) geo_sensor_device; - } catch (int err) { - ERR("Failed to create geo_sensor_device devices, err: %d, cause: %s", err, strerror(err)); - } - if (geo_sensor != NULL) - devices->devices.push_back(geo_sensor); -#endif - -#ifdef ENABLE_GYRO - gyro_sensor_device *gyro_sensor = NULL; - try { - gyro_sensor = new(std::nothrow) gyro_sensor_device; - } catch (int err) { - ERR("Failed to create gyro_sensor_device devices, err: %d, cause: %s", err, strerror(err)); - } - if (gyro_sensor != NULL) - devices->devices.push_back(gyro_sensor); -#endif - -#ifdef ENABLE_LIGHT - light_sensor_device *light_sensor = NULL; - try { - light_sensor = new(std::nothrow) light_sensor_device; - } catch (int err) { - ERR("Failed to create light_sensor_device devices, err: %d, cause: %s", err, strerror(err)); - } - if (light_sensor != NULL) - devices->devices.push_back(light_sensor); -#endif - -#ifdef ENABLE_PRESSURE - pressure_sensor_device *pressure_sensor = NULL; - try { - pressure_sensor = new(std::nothrow) pressure_sensor_device; - } catch (int err) { - ERR("Failed to create pressure_sensor_device devices, err: %d, cause: %s", err, strerror(err)); - } - if (pressure_sensor != NULL) - devices->devices.push_back(pressure_sensor); -#endif - -#ifdef ENABLE_PROXI - proxi_sensor_device *proxi_sensor = NULL; - try { - proxi_sensor = new(std::nothrow) proxi_sensor_device; - } catch (int err) { - ERR("Failed to create proxi_sensor_device devices, err: %d, cause: %s", err, strerror(err)); - } - if (proxi_sensor != NULL) - devices->devices.push_back(proxi_sensor); -#endif - -#ifdef ENABLE_RV_RAW - rv_raw_sensor_device *rv_raw_sensor = NULL; - try { - rv_raw_sensor = new(std::nothrow) rv_raw_sensor_device; - } catch (int err) { - ERR("Failed to create rv_raw_sensor_device devices, err: %d, cause: %s", err, strerror(err)); - } - if (rv_raw_sensor != NULL) - devices->devices.push_back(rv_raw_sensor); -#endif - -#ifdef ENABLE_TEMPERATURE - temperature_sensor_device *temperature_sensor = NULL; - try { - temperature_sensor = new(std::nothrow) temperature_sensor_device; - } catch (int err) { - ERR("Failed to create temperature_sensor_device devices, err: %d, cause: %s", err, strerror(err)); - } - if (temperature_sensor != NULL) - devices->devices.push_back(temperature_sensor); -#endif - -#ifdef ENABLE_ULTRAVIOLET - ultraviolet_sensor_device *ultraviolet_sensor = NULL; - try { - ultraviolet_sensor = new(std::nothrow) ultraviolet_sensor_device; - } catch (int err) { - ERR("Failed to create ultraviolet_sensor_device devices, err: %d, cause: %s", err, strerror(err)); - } - if (ultraviolet_sensor != NULL) - devices->devices.push_back(ultraviolet_sensor); -#endif - - return devices; -} diff --git a/src/interface/sensor_hal.h b/src/sensor_hal.h index 660be01..3dee6a0 100644 --- a/src/interface/sensor_hal.h +++ b/src/sensor_hal.h @@ -116,6 +116,8 @@ typedef struct sensor_handle_t { class sensor_device { public: + virtual ~sensor_device() {} + uint32_t get_hal_version(void) { return SENSOR_HAL_VERSION(1, 0); diff --git a/src/sensor_logs.h b/src/sensor_logs.h new file mode 100644 index 0000000..9682c42 --- /dev/null +++ b/src/sensor_logs.h @@ -0,0 +1,130 @@ +/* + * libsensord-share + * + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _SENSOR_LOG_H_ +#define _SENSOR_LOG_H_ + +#include <dlog.h> + +#if !defined(NAME_MAX) +#define NAME_MAX 256 +#endif + +#define SENSOR_TYPE_SHIFT 16 + +enum sf_log_type { + SF_LOG_PRINT_FILE = 1, + SF_LOG_SYSLOG = 2, + SF_LOG_DLOG = 3, +}; + +enum sf_priority_type { + SF_LOG_ERR = 1, + SF_LOG_DBG = 2, + SF_LOG_INFO = 3, + SF_LOG_WARN = 4, +}; + +#define MICROSECONDS(tv) ((tv.tv_sec * 1000000ll) + tv.tv_usec) + +//for new log system - dlog +#ifdef LOG_TAG + #undef LOG_TAG +#endif +#define LOG_TAG "SENSOR" + +#ifdef _DEBUG +#define DBG SLOGD +#else +#define DBG(...) do{} while(0) +#endif + +#define ERR SLOGE +#define WARN SLOGW +#define INFO SLOGI +#define _E ERR +#define _W WARN +#define _I INFO +#define _D DBG + +#if defined(_DEBUG) +# define warn_if(expr, fmt, arg...) do { \ + if(expr) { \ + DBG("(%s) -> " fmt, #expr, ##arg); \ + } \ + } while (0) +# define ret_if(expr) do { \ + if(expr) { \ + DBG("(%s) -> %s() return", #expr, __FUNCTION__); \ + return; \ + } \ + } while (0) +# define retv_if(expr, val) do { \ + if(expr) { \ + DBG("(%s) -> %s() return", #expr, __FUNCTION__); \ + return (val); \ + } \ + } while (0) +# define retm_if(expr, fmt, arg...) do { \ + if(expr) { \ + ERR(fmt, ##arg); \ + DBG("(%s) -> %s() return", #expr, __FUNCTION__); \ + return; \ + } \ + } while (0) +# define retvm_if(expr, val, fmt, arg...) do { \ + if(expr) { \ + ERR(fmt, ##arg); \ + DBG("(%s) -> %s() return", #expr, __FUNCTION__); \ + return (val); \ + } \ + } while (0) + +#else +# define warn_if(expr, fmt, arg...) do { \ + if(expr) { \ + ERR(fmt, ##arg); \ + } \ + } while (0) +# define ret_if(expr) do { \ + if(expr) { \ + return; \ + } \ + } while (0) +# define retv_if(expr, val) do { \ + if(expr) { \ + return (val); \ + } \ + } while (0) +# define retm_if(expr, fmt, arg...) do { \ + if(expr) { \ + ERR(fmt, ##arg); \ + return; \ + } \ + } while (0) +# define retvm_if(expr, val, fmt, arg...) do { \ + if(expr) { \ + ERR(fmt, ##arg); \ + return (val); \ + } \ + } while (0) + +#endif + +#endif /* _SENSOR_LOG_H_ */ diff --git a/src/plugins/temperature/temperature_sensor_hal.cpp b/src/temperature/temperature_sensor_hal.cpp index e491c6d..e491c6d 100755..100644 --- a/src/plugins/temperature/temperature_sensor_hal.cpp +++ b/src/temperature/temperature_sensor_hal.cpp diff --git a/src/plugins/temperature/temperature_sensor_hal.h b/src/temperature/temperature_sensor_hal.h index 7dd06d6..7dd06d6 100755..100644 --- a/src/plugins/temperature/temperature_sensor_hal.h +++ b/src/temperature/temperature_sensor_hal.h diff --git a/src/plugins/ultraviolet/ultraviolet_sensor_hal.cpp b/src/ultraviolet/ultraviolet_sensor_hal.cpp index 6723e3f..6723e3f 100755..100644 --- a/src/plugins/ultraviolet/ultraviolet_sensor_hal.cpp +++ b/src/ultraviolet/ultraviolet_sensor_hal.cpp diff --git a/src/plugins/ultraviolet/ultraviolet_sensor_hal.h b/src/ultraviolet/ultraviolet_sensor_hal.h index dfe684c..dfe684c 100755..100644 --- a/src/plugins/ultraviolet/ultraviolet_sensor_hal.h +++ b/src/ultraviolet/ultraviolet_sensor_hal.h |