From eea60200663ffc257e49b6e4c01bc24b1c4c3340 Mon Sep 17 00:00:00 2001 From: "kibak.yoon" Date: Tue, 4 Apr 2017 17:06:05 +0900 Subject: [PATCH] sensord: remove sensor_common.h - sensor_common.h is not really meaningful. - move definitions from sensor_common.h to sensor_types.h. Change-Id: I458bd6f9400ccef31063c524e9a74555f234f84d Signed-off-by: kibak.yoon --- include/sensor_common.h | 159 ----------------------------- include/sensor_internal.h | 1 - include/sensor_internal_deprecated.h | 4 +- include/sensor_types.h | 106 +++++++++++++++++++ src/client-dummy/client_dummy.cpp | 2 +- src/client-dummy/external_client_dummy.cpp | 2 +- src/shared/command_common.h | 2 +- src/shared/sensor_info.h | 1 - src/shared/sensor_log.cpp | 1 - 9 files changed, 110 insertions(+), 168 deletions(-) delete mode 100644 include/sensor_common.h diff --git a/include/sensor_common.h b/include/sensor_common.h deleted file mode 100644 index d308549..0000000 --- a/include/sensor_common.h +++ /dev/null @@ -1,159 +0,0 @@ -/* - * 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_COMMON_H__ -#define __SENSOR_COMMON_H__ - -#include -#include -#include -#include - -#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_EVENT_SHIFT 16 -#define SENSOR_INDEX_MASK 0xFFFFFFFF - -#define CONVERT_ID_TYPE(id) ((id) >> SENSOR_TYPE_SHIFT) -#define CONVERT_TYPE_EVENT(type) ((type) << SENSOR_EVENT_SHIFT | 0x1) - -#ifndef NAME_MAX -#define NAME_MAX 256 -#endif - -#ifdef __cplusplus -extern "C" -{ -#endif - -/* -typedef union { - struct { - sensor_type_t type; - int32_t id; - } __attribute__((packed)); - int64_t id; -} sensor_id_t; -*/ -typedef int64_t sensor_id_t; - -typedef void *sensor_t; - -/* - * To prevent naming confliction as using same enums as sensor CAPI use - */ -#ifndef __SENSOR_H__ -enum sensor_option_t { - SENSOR_OPTION_DEFAULT = 0, - SENSOR_OPTION_ON_IN_SCREEN_OFF = 1, - SENSOR_OPTION_ON_IN_POWERSAVE_MODE = 2, - SENSOR_OPTION_ALWAYS_ON = SENSOR_OPTION_ON_IN_SCREEN_OFF | SENSOR_OPTION_ON_IN_POWERSAVE_MODE, - SENSOR_OPTION_END -}; - -typedef enum sensor_option_t sensor_option_e; -#endif - -enum sensord_attribute_e { - SENSORD_ATTRIBUTE_AXIS_ORIENTATION = 1, - SENSORD_ATTRIBUTE_PAUSE_POLICY, -}; - -enum sensord_axis_e { - SENSORD_AXIS_DEVICE_ORIENTED = 1, - SENSORD_AXIS_DISPLAY_ORIENTED, -}; - -enum sensord_pause_e { - SENSORD_PAUSE_NONE = 0, - SENSORD_PAUSE_ON_DISPLAY_OFF = 1, - SENSORD_PAUSE_ON_POWERSAVE_MODE = 2, - SENSORD_PAUSE_ALL = 3, - SENSORD_PAUSE_END, -}; - -enum poll_interval_t { - POLL_100HZ_MS = 10, - POLL_50HZ_MS = 20, - POLL_25HZ_MS = 40, - POLL_20HZ_MS = 50, - POLL_10HZ_MS = 100, - POLL_5HZ_MS = 200, - POLL_1HZ_MS = 1000, - POLL_MAX_HZ_MS = 255000, -}; - -enum sensor_interval_t { - SENSOR_INTERVAL_FASTEST = POLL_100HZ_MS, - SENSOR_INTERVAL_NORMAL = POLL_5HZ_MS, -}; - -typedef enum { - CONDITION_NO_OP, - CONDITION_EQUAL, - CONDITION_GREAT_THAN, - CONDITION_LESS_THAN, -} condition_op_t; - -enum sensor_state_t { - SENSOR_STATE_UNKNOWN = -1, - SENSOR_STATE_STOPPED = 0, - SENSOR_STATE_STARTED = 1, - SENSOR_STATE_PAUSED = 2 -}; - -typedef enum { - SENSOR_PRIVILEGE_PUBLIC, - SENSOR_PRIVILEGE_INTERNAL, -} sensor_privilege_t; - -enum sensor_permission_t { - SENSOR_PERMISSION_NONE = 0, - SENSOR_PERMISSION_STANDARD = (1 << 0), - SENSOR_PERMISSION_BIO = (1 << 1) -}; - -enum client_type_t { - CLIENT_TYPE_SENSOR_CLIENT = 1, - CLIENT_TYPE_EXTERNAL_SOURCE, -}; - -typedef struct sensor_event_t { - unsigned int event_type; - sensor_id_t sensor_id; - unsigned int data_length; - sensor_data_t *data; -} sensor_event_t; - -#ifdef __cplusplus -} -#endif - -#ifdef __cplusplus -#include - -typedef std::vector event_type_vector; -#endif /* __cplusplus */ - -#endif /* __SENSOR_COMMON_H__ */ diff --git a/include/sensor_internal.h b/include/sensor_internal.h index b7e9469..506c869 100644 --- a/include/sensor_internal.h +++ b/include/sensor_internal.h @@ -28,7 +28,6 @@ #include /*header for common sensor type*/ -#include #include #include #include diff --git a/include/sensor_internal_deprecated.h b/include/sensor_internal_deprecated.h index 851ccbc..2288686 100644 --- a/include/sensor_internal_deprecated.h +++ b/include/sensor_internal_deprecated.h @@ -25,11 +25,9 @@ #endif #include - #include /*header for common sensor type*/ -#include #include #include @@ -39,7 +37,7 @@ extern "C" #endif typedef struct { - condition_op_t cond_op; + int cond_op; /* TODO: change it from int to condition_op_t */ float cond_value1; } event_condition_t; diff --git a/include/sensor_types.h b/include/sensor_types.h index 5b752af..c244943 100644 --- a/include/sensor_types.h +++ b/include/sensor_types.h @@ -20,11 +20,46 @@ #ifndef __SENSOR_TYPES_H__ #define __SENSOR_TYPES_H__ +/* TODO: It is for compatibility with capi-system-sensor */ +#define __SENSOR_COMMON_H__ + +#include +#include +#include + #ifdef __cplusplus extern "C" { #endif +#ifndef OP_SUCCESS +#define OP_SUCCESS 0 +#endif +#ifndef OP_ERROR +#define OP_ERROR -1 +#endif +#ifndef OP_DEFAULT +#define OP_DEFAULT 1 +#endif +#ifndef OP_CONTINUE +#define OP_CONTINUE 2 +#endif +#ifndef NAME_MAX +#define NAME_MAX 256 +#endif + +#define SENSOR_TYPE_SHIFT 32 +#define SENSOR_EVENT_SHIFT 16 +#define SENSOR_INDEX_MASK 0xFFFFFFFF + +#define CONVERT_ID_TYPE(id) ((id) >> SENSOR_TYPE_SHIFT) +#define CONVERT_TYPE_EVENT(type) ((type) << SENSOR_EVENT_SHIFT | 0x1) + +#define MICROSECONDS(tv) ((tv.tv_sec * 1000000ll) + tv.tv_usec) + +typedef int64_t sensor_id_t; +typedef void *sensor_t; + typedef enum sensor_type_t { UNKNOWN_SENSOR = -2, ALL_SENSOR = -1, @@ -124,6 +159,77 @@ typedef enum sensor_type_t { CUSTOM_SENSOR = 0X9000, } sensor_type_t; + +typedef enum sensor_permission_t { + SENSOR_PERMISSION_NONE = 0, + SENSOR_PERMISSION_STANDARD = 1, + SENSOR_PERMISSION_HEALTH_INFO = 2, +} sensor_permission_t; + +typedef enum sensor_privilege_t { + SENSOR_PRIVILEGE_PUBLIC = 1, +} sensor_privilege_t; + +typedef struct sensor_event_t { + unsigned int event_type; + sensor_id_t sensor_id; + unsigned int data_length; + sensor_data_t *data; +} sensor_event_t; + +/* + * To prevent naming confliction as using same enums as sensor CAPI use + */ +#ifndef __SENSOR_H__ +enum sensor_option_t { + SENSOR_OPTION_DEFAULT = 0, + SENSOR_OPTION_ON_IN_SCREEN_OFF = 1, + SENSOR_OPTION_ON_IN_POWERSAVE_MODE = 2, + SENSOR_OPTION_ALWAYS_ON = SENSOR_OPTION_ON_IN_SCREEN_OFF | SENSOR_OPTION_ON_IN_POWERSAVE_MODE, + SENSOR_OPTION_END +}; + +typedef enum sensor_option_t sensor_option_e; +#endif + +enum sensord_attribute_e { + SENSORD_ATTRIBUTE_AXIS_ORIENTATION = 1, + SENSORD_ATTRIBUTE_PAUSE_POLICY, + SENSORD_ATTRIBUTE_INTERVAL = 0x10, + SENSORD_ATTRIBUTE_MAX_BATCH_LATENCY, + SENSORD_ATTRIBUTE_PASSIVE_MODE, + SENSORD_ATTRIBUTE_FLUSH, +}; + +enum sensord_axis_e { + SENSORD_AXIS_DEVICE_ORIENTED = 1, + SENSORD_AXIS_DISPLAY_ORIENTED, +}; + +enum sensord_pause_e { + SENSORD_PAUSE_NONE = 0, + SENSORD_PAUSE_ON_DISPLAY_OFF = 1, + SENSORD_PAUSE_ON_POWERSAVE_MODE = 2, + SENSORD_PAUSE_ALL = 3, + SENSORD_PAUSE_END, +}; + +enum poll_interval_t { + POLL_100HZ_MS = 10, + POLL_50HZ_MS = 20, + POLL_25HZ_MS = 40, + POLL_20HZ_MS = 50, + POLL_10HZ_MS = 100, + POLL_5HZ_MS = 200, + POLL_1HZ_MS = 1000, + POLL_MAX_HZ_MS = 255000, +}; + +enum sensor_interval_t { + SENSOR_INTERVAL_FASTEST = POLL_100HZ_MS, + SENSOR_INTERVAL_NORMAL = POLL_5HZ_MS, +}; + enum proxi_change_state { PROXIMITY_STATE_NEAR = 0, PROXIMITY_STATE_FAR = 1, diff --git a/src/client-dummy/client_dummy.cpp b/src/client-dummy/client_dummy.cpp index 574079a..0baf94e 100644 --- a/src/client-dummy/client_dummy.cpp +++ b/src/client-dummy/client_dummy.cpp @@ -18,7 +18,7 @@ */ #include -#include +#include #include #include diff --git a/src/client-dummy/external_client_dummy.cpp b/src/client-dummy/external_client_dummy.cpp index 8eb9221..5648bad 100644 --- a/src/client-dummy/external_client_dummy.cpp +++ b/src/client-dummy/external_client_dummy.cpp @@ -18,7 +18,7 @@ */ #include -#include +#include #include #include diff --git a/src/shared/command_common.h b/src/shared/command_common.h index 679bf08..ccbba3c 100644 --- a/src/shared/command_common.h +++ b/src/shared/command_common.h @@ -20,7 +20,7 @@ #ifndef _COMMAND_COMMON_H_ #define _COMMAND_COMMON_H_ -#include +#include #include #include diff --git a/src/shared/sensor_info.h b/src/shared/sensor_info.h index e2e9e57..8a50d64 100644 --- a/src/shared/sensor_info.h +++ b/src/shared/sensor_info.h @@ -21,7 +21,6 @@ #define _SENSOR_INFO_H_ #include -#include #include #include #include diff --git a/src/shared/sensor_log.cpp b/src/shared/sensor_log.cpp index 0026801..f657883 100644 --- a/src/shared/sensor_log.cpp +++ b/src/shared/sensor_log.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #define PATH_MAX 256 -- 2.7.4