From 902579ece56be0b1170489ffd399a779d2a9c1d8 Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Wed, 3 Feb 2016 16:48:13 +0900 Subject: [PATCH] sensor-hal: re-organize build procedure Change-Id: I7e34d8f61cc69c2c8a021fcb9969f48882aa048e Signed-off-by: Mu-Woong Lee --- CMakeLists.txt | 97 ++++++++- packaging/sensor-plugins-tm1.spec | 25 +-- src/CMakeLists.txt | 85 -------- src/{plugins => }/accel/accel_sensor_device.cpp | 2 +- src/{plugins => }/accel/accel_sensor_device.h | 0 src/create.cpp | 98 +++++++++ src/{plugins => }/gyro/gyro_sensor_hal.cpp | 0 src/{plugins => }/gyro/gyro_sensor_hal.h | 0 .../bio_led_red_sensor_hal.cpp | 0 .../bio_led_red_sensor_hal.h | 0 src/lib/cconfig.cpp | 72 ------- src/lib/cconfig.h | 41 ---- src/lib/sensor_logs.cpp | 111 ----------- src/lib/sensor_logs.h | 218 --------------------- src/{plugins => }/light/light_sensor_hal.cpp | 0 src/{plugins => }/light/light_sensor_hal.h | 0 src/{plugins/geo => magnetic}/geo_sensor_hal.cpp | 0 src/{plugins/geo => magnetic}/geo_sensor_hal.h | 0 src/{plugins => }/pressure/pressure_sensor_hal.cpp | 0 src/{plugins => }/pressure/pressure_sensor_hal.h | 0 .../proxi => proximity}/proxi_sensor_device.cpp | 2 +- .../proxi => proximity}/proxi_sensor_device.h | 0 .../rotation_vector/rv_raw/rv_raw_sensor_hal.cpp | 0 .../rotation_vector/rv_raw/rv_raw_sensor_hal.h | 0 src/{lib => }/sensor_common.h | 0 src/{interface => }/sensor_device_base.cpp | 0 src/{interface => }/sensor_device_base.h | 0 src/sensor_device_create.cpp.in | 152 -------------- src/{interface => }/sensor_hal.h | 2 + src/sensor_logs.h | 130 ++++++++++++ .../temperature/temperature_sensor_hal.cpp | 0 .../temperature/temperature_sensor_hal.h | 0 .../ultraviolet/ultraviolet_sensor_hal.cpp | 0 .../ultraviolet/ultraviolet_sensor_hal.h | 0 34 files changed, 326 insertions(+), 709 deletions(-) delete mode 100644 src/CMakeLists.txt rename src/{plugins => }/accel/accel_sensor_device.cpp (99%) mode change 100755 => 100644 rename src/{plugins => }/accel/accel_sensor_device.h (100%) mode change 100755 => 100644 create mode 100644 src/create.cpp rename src/{plugins => }/gyro/gyro_sensor_hal.cpp (100%) mode change 100755 => 100644 rename src/{plugins => }/gyro/gyro_sensor_hal.h (100%) mode change 100755 => 100644 rename src/{plugins/bio_led_red => hrm_led_red}/bio_led_red_sensor_hal.cpp (100%) mode change 100755 => 100644 rename src/{plugins/bio_led_red => hrm_led_red}/bio_led_red_sensor_hal.h (100%) mode change 100755 => 100644 delete mode 100755 src/lib/cconfig.cpp delete mode 100755 src/lib/cconfig.h delete mode 100644 src/lib/sensor_logs.cpp delete mode 100755 src/lib/sensor_logs.h rename src/{plugins => }/light/light_sensor_hal.cpp (100%) mode change 100755 => 100644 rename src/{plugins => }/light/light_sensor_hal.h (100%) mode change 100755 => 100644 rename src/{plugins/geo => magnetic}/geo_sensor_hal.cpp (100%) mode change 100755 => 100644 rename src/{plugins/geo => magnetic}/geo_sensor_hal.h (100%) mode change 100755 => 100644 rename src/{plugins => }/pressure/pressure_sensor_hal.cpp (100%) mode change 100755 => 100644 rename src/{plugins => }/pressure/pressure_sensor_hal.h (100%) mode change 100755 => 100644 rename src/{plugins/proxi => proximity}/proxi_sensor_device.cpp (99%) rename src/{plugins/proxi => proximity}/proxi_sensor_device.h (100%) mode change 100755 => 100644 rename src/{plugins => }/rotation_vector/rv_raw/rv_raw_sensor_hal.cpp (100%) mode change 100755 => 100644 rename src/{plugins => }/rotation_vector/rv_raw/rv_raw_sensor_hal.h (100%) mode change 100755 => 100644 rename src/{lib => }/sensor_common.h (100%) rename src/{interface => }/sensor_device_base.cpp (100%) rename src/{interface => }/sensor_device_base.h (100%) delete mode 100644 src/sensor_device_create.cpp.in rename src/{interface => }/sensor_hal.h (99%) create mode 100644 src/sensor_logs.h rename src/{plugins => }/temperature/temperature_sensor_hal.cpp (100%) mode change 100755 => 100644 rename src/{plugins => }/temperature/temperature_sensor_hal.h (100%) mode change 100755 => 100644 rename src/{plugins => }/ultraviolet/ultraviolet_sensor_hal.cpp (100%) mode change 100755 => 100644 rename src/{plugins => }/ultraviolet/ultraviolet_sensor_hal.h (100%) mode change 100755 => 100644 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 old mode 100755 new mode 100644 similarity index 99% rename from src/plugins/accel/accel_sensor_device.cpp rename to src/accel/accel_sensor_device.cpp index 129d454..412bd32 --- a/src/plugins/accel/accel_sensor_device.cpp +++ b/src/accel/accel_sensor_device.cpp @@ -21,8 +21,8 @@ #include #include #include -#include #include +#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 old mode 100755 new mode 100644 similarity index 100% rename from src/plugins/accel/accel_sensor_device.h rename to 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 + +#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 +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"); +#endif + +#ifdef ENABLE_GYRO + create_sensor("Gyro"); +#endif + +#ifdef ENABLE_MAGNETIC + create_sensor("Magnetic"); +#endif + +#ifdef ENABLE_PROXIMITY + create_sensor("Proximity"); +#endif + +#ifdef ENABLE_LIGHT + create_sensor("Light"); +#endif + +#ifdef ENABLE_ROTATION_VECTOR + create_sensor("Rotation Vector"); +#endif + +#ifdef ENABLE_PRESSURE + create_sensor("Pressure"); +#endif + +#ifdef ENABLE_TEMPERATURE + create_sensor("Temperature"); +#endif + +#ifdef ENABLE_ULTRAVIOLET + create_sensor("Ultraviolet"); +#endif + +#ifdef ENABLE_HRM_LED_RED + create_sensor("HRM Led Red"); +#endif + + return devices; +} diff --git a/src/plugins/gyro/gyro_sensor_hal.cpp b/src/gyro/gyro_sensor_hal.cpp old mode 100755 new mode 100644 similarity index 100% rename from src/plugins/gyro/gyro_sensor_hal.cpp rename to src/gyro/gyro_sensor_hal.cpp diff --git a/src/plugins/gyro/gyro_sensor_hal.h b/src/gyro/gyro_sensor_hal.h old mode 100755 new mode 100644 similarity index 100% rename from src/plugins/gyro/gyro_sensor_hal.h rename to 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 old mode 100755 new mode 100644 similarity index 100% rename from src/plugins/bio_led_red/bio_led_red_sensor_hal.cpp rename to 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 old mode 100755 new mode 100644 similarity index 100% rename from src/plugins/bio_led_red/bio_led_red_sensor_hal.h rename to 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 -#include -#include - -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 -#include -#include - -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 -#include -#include -#include -#include -#include -#include -#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 -#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 -#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 old mode 100755 new mode 100644 similarity index 100% rename from src/plugins/light/light_sensor_hal.cpp rename to src/light/light_sensor_hal.cpp diff --git a/src/plugins/light/light_sensor_hal.h b/src/light/light_sensor_hal.h old mode 100755 new mode 100644 similarity index 100% rename from src/plugins/light/light_sensor_hal.h rename to src/light/light_sensor_hal.h diff --git a/src/plugins/geo/geo_sensor_hal.cpp b/src/magnetic/geo_sensor_hal.cpp old mode 100755 new mode 100644 similarity index 100% rename from src/plugins/geo/geo_sensor_hal.cpp rename to src/magnetic/geo_sensor_hal.cpp diff --git a/src/plugins/geo/geo_sensor_hal.h b/src/magnetic/geo_sensor_hal.h old mode 100755 new mode 100644 similarity index 100% rename from src/plugins/geo/geo_sensor_hal.h rename to src/magnetic/geo_sensor_hal.h diff --git a/src/plugins/pressure/pressure_sensor_hal.cpp b/src/pressure/pressure_sensor_hal.cpp old mode 100755 new mode 100644 similarity index 100% rename from src/plugins/pressure/pressure_sensor_hal.cpp rename to src/pressure/pressure_sensor_hal.cpp diff --git a/src/plugins/pressure/pressure_sensor_hal.h b/src/pressure/pressure_sensor_hal.h old mode 100755 new mode 100644 similarity index 100% rename from src/plugins/pressure/pressure_sensor_hal.h rename to src/pressure/pressure_sensor_hal.h diff --git a/src/plugins/proxi/proxi_sensor_device.cpp b/src/proximity/proxi_sensor_device.cpp similarity index 99% rename from src/plugins/proxi/proxi_sensor_device.cpp rename to 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 #include #include -#include +#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 old mode 100755 new mode 100644 similarity index 100% rename from src/plugins/proxi/proxi_sensor_device.h rename to 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 old mode 100755 new mode 100644 similarity index 100% rename from src/plugins/rotation_vector/rv_raw/rv_raw_sensor_hal.cpp rename to 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 old mode 100755 new mode 100644 similarity index 100% rename from src/plugins/rotation_vector/rv_raw/rv_raw_sensor_hal.h rename to src/rotation_vector/rv_raw/rv_raw_sensor_hal.h diff --git a/src/lib/sensor_common.h b/src/sensor_common.h similarity index 100% rename from src/lib/sensor_common.h rename to src/sensor_common.h diff --git a/src/interface/sensor_device_base.cpp b/src/sensor_device_base.cpp similarity index 100% rename from src/interface/sensor_device_base.cpp rename to src/sensor_device_base.cpp diff --git a/src/interface/sensor_device_base.h b/src/sensor_device_base.h similarity index 100% rename from src/interface/sensor_device_base.h rename to 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 -#endif -#ifdef ENABLE_BIO_LED_RED -#include -#endif -#ifdef ENABLE_GEO -#include -#endif -#ifdef ENABLE_GYRO -#include -#endif -#ifdef ENABLE_LIGHT -#include -#endif -#ifdef ENABLE_PRESSURE -#include -#endif -#ifdef ENABLE_PROXI -#include -#endif -#ifdef ENABLE_RV_RAW -#include -#endif -#ifdef ENABLE_TEMPERATURE -#include -#endif -#ifdef ENABLE_ULTRAVIOLET -#include -#endif - -#include - -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 similarity index 99% rename from src/interface/sensor_hal.h rename to 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 + +#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 old mode 100755 new mode 100644 similarity index 100% rename from src/plugins/temperature/temperature_sensor_hal.cpp rename to src/temperature/temperature_sensor_hal.cpp diff --git a/src/plugins/temperature/temperature_sensor_hal.h b/src/temperature/temperature_sensor_hal.h old mode 100755 new mode 100644 similarity index 100% rename from src/plugins/temperature/temperature_sensor_hal.h rename to src/temperature/temperature_sensor_hal.h diff --git a/src/plugins/ultraviolet/ultraviolet_sensor_hal.cpp b/src/ultraviolet/ultraviolet_sensor_hal.cpp old mode 100755 new mode 100644 similarity index 100% rename from src/plugins/ultraviolet/ultraviolet_sensor_hal.cpp rename to src/ultraviolet/ultraviolet_sensor_hal.cpp diff --git a/src/plugins/ultraviolet/ultraviolet_sensor_hal.h b/src/ultraviolet/ultraviolet_sensor_hal.h old mode 100755 new mode 100644 similarity index 100% rename from src/plugins/ultraviolet/ultraviolet_sensor_hal.h rename to src/ultraviolet/ultraviolet_sensor_hal.h -- 2.7.4