Change the name of header files 51/277451/2
authorTaeminYeom <taemin.yeom@samsung.com>
Thu, 7 Jul 2022 06:09:25 +0000 (15:09 +0900)
committerTaeminYeom <taemin.yeom@samsung.com>
Thu, 7 Jul 2022 07:19:45 +0000 (16:19 +0900)
Fix the style of name sensor-xxx.h
Merge sensor_internal.h into sensor-internal.h

Change-Id: I7beddf55788172884670b978ee431c8ea4892eb5
Signed-off-by: TaeminYeom <taemin.yeom@samsung.com>
42 files changed:
include/sensor-internal.h
include/sensor-log.h [new file with mode: 0644]
include/sensor-private.h [new file with mode: 0644]
include/sensor-types.h [new file with mode: 0644]
include/sensor_internal.h [deleted file]
include/sensor_log.h [deleted file]
include/sensor_private.h [deleted file]
include/sensor_types.h [deleted file]
src/api/sensor-internal.cpp
src/api/sensor.cpp
src/api/sensor_internal.cpp [deleted file]
src/api/sensor_listener.cpp
src/api/sensor_listener.h
src/api/sensor_manager.cpp
src/api/sensor_manager.h
src/api/sensor_manager_channel_handler.cpp
src/api/sensor_manager_channel_handler.h
src/api/sensor_provider.cpp
src/api/sensor_provider_channel_handler.cpp
src/api/sensor_provider_channel_handler.h
src/api/sensor_provider_internal.cpp
src/api/sensor_provider_internal.h
src/api/sensor_reader.cpp
src/api/sensor_recorder/sensor_recorder.cpp
src/api/sensor_recorder/sensor_recorder_dummy.cpp
src/shared/accept_event_handler.cpp
src/shared/cbase_lock.cpp
src/shared/channel.cpp
src/shared/channel_event_handler.cpp
src/shared/cmutex.cpp
src/shared/command_types.h
src/shared/event_loop.cpp
src/shared/ipc_client.cpp
src/shared/ipc_server.cpp
src/shared/message.cpp
src/shared/sensor_info.cpp
src/shared/sensor_info.h
src/shared/sensor_utils.cpp
src/shared/sensor_utils.h
src/shared/seqpacket_socket.cpp
src/shared/socket.cpp
src/shared/stream_socket.cpp

index 04ef69a7048e41d829f5b847d5962daa2a7cb9b7..bb32f54b38685615431848646e3862f253e671d2 100644 (file)
 #ifndef __SENSOR_INTERNAL_H__
 #define __SENSOR_INTERNAL_H__
 
+#ifndef API
+#define API __attribute__((visibility("default")))
+#endif
+
+#include <stdbool.h>
+#include <sys/types.h>
+#include <limits.h>
+
+/*header for common sensor type*/
+#include <sensor-types.h>
 #include <sensor.h>
 #include <hal-sensor-types.h>
 
+#define SENSOR_BATCH_LATENCY_DEFAULT UINT_MAX
+
 #ifdef __cplusplus
 extern "C"
 {
@@ -29,6 +41,496 @@ typedef enum {
        SENSOR_LIDAR = 1000,
 } sensor_type_internel_e;
 
+typedef void (*sensor_cb_t)(sensor_t sensor, unsigned int event_type, sensor_data_t *data, void *user_data);
+typedef void (*sensor_events_cb_t)(sensor_t sensor, unsigned int event_type, sensor_data_t events[], int events_count, void *user_data);
+typedef void (*sensorhub_cb_t)(sensor_t sensor, unsigned int event_type, sensorhub_data_t *data, void *user_data);
+typedef void (*sensor_accuracy_changed_cb_t) (sensor_t sensor, unsigned long long timestamp, int accuracy, void *user_data);
+typedef void (*sensor_attribute_int_changed_cb_t)(sensor_t sensor, int attribute, int value, void *user_data);
+typedef void (*sensor_attribute_str_changed_cb_t)(sensor_t sensor, int attribute, const char *value, int len, void *user_data);
+
+/**
+ * @brief Get the list of available sensors of a certain type,  use ALL_SENSOR to get all the sensors.
+ *
+ * @param[in] type the type of sensors requested.
+ * @param[out] list the list of sensors matching the asked type,  the caller should explicitly free this list.
+ * @param[out] sensor count the count of sensors contained in the list.
+ * @return true on success, otherwise false.
+ */
+bool sensord_get_sensor_list(sensor_type_t type, sensor_t **list, int *sensor_count);
+
+/**
+ * @brief Get the default sensor for a given type.
+ *
+ * @param[in] type the type of a sensor requested.
+ * @return the default sensor matching the asked type on success, otherwise NULL.
+ */
+sensor_t sensord_get_sensor(sensor_type_t type);
+
+/**
+ * @brief Get the list of available sensors of a certain type,  use ALL_SENSOR to get all the sensors.
+ *
+ * @param[in] type the type of sensors requested.
+ * @param[out] list the list of sensors matching the asked type,  the caller should explicitly free this list.
+ * @param[out] sensor count the count of sensors contained in the list.
+ * @return 0 on success, otherwise a negative error value
+ * @retval 0 Successful
+ * @retval -EPERM Operation not permitted
+ * @retval -EACCES Permission denied
+ * @retval -ENODATA NO sensor available
+ */
+int sensord_get_sensors(sensor_type_t type, sensor_t **list, int *sensor_count);
+
+/**
+ * @brief Get the default sensor for a given type.
+ *
+ * @param[in] type the type of a sensor requested.
+ * @param[out] a sensor matching the asked type.
+ * @return 0 on success, otherwise a negative error value
+ * @retval 0 Successful
+ * @retval -EPERM Operation not permitted
+ * @retval -EACCES Permission denied
+ */
+int sensord_get_default_sensor(sensor_type_t type, sensor_t *sensor);
+
+/**
+ * @brief Get the type of this sensor.
+ *
+ * @param[in] sensor a sensor to get type.
+ * @param[out] type the type of this sensor.
+ * @return return true on success, otherwise false.
+ */
+bool sensord_get_type(sensor_t sensor, sensor_type_t *type);
+
+/**
+ * @brief Get the URI string of this sensor.
+ *
+ * @param[in] sensor a sensor to get uri.
+ * @return the name string of this sensor on success, otherwise NULL.
+ */
+const char* sensord_get_uri(sensor_t sensor);
+
+/**
+ * @brief Get the name string of this sensor.
+ *
+ * @param[in] sensor a sensor to get name.
+ * @return the name string of this sensor on success, otherwise NULL.
+ */
+const char* sensord_get_name(sensor_t sensor);
+
+/**
+ * @brief Get the vendor string of this sensor.
+ *
+ * @param[in] sensor a sensor to get vendor.
+ * @return the vendor string of this sensor on success, otherwise NULL.
+ */
+const char* sensord_get_vendor(sensor_t sensor);
+
+/**
+ * @brief Get the privilege of this sensor.
+ *
+ * @param[in] sensor a sensor to get privilege.
+ * @param[out] privilege the privilege of this sensor.
+ * @return true on success, otherwise false.
+ */
+bool sensord_get_privilege(sensor_t sensor, sensor_privilege_t *privilege);
+
+/**
+ * @brief Get the minimum range of this sensor in the sensor's unit.
+ *
+ * @param[in] sensor a sensor to get minimum range.
+ * @param[out] min_range the minimum range of this sensor in the sensor's unit.
+ * @return true on success, otherwise false.
+ */
+bool sensord_get_min_range(sensor_t sensor, float *min_range);
+
+/**
+ * @brief Get the maximum range of this sensor in the sensor's unit.
+ *
+ * @param[in] sensor a sensor to get maximum range.
+ * @param[out] max_range the maximum range of this sensor in the sensor's unit.
+ * @return true on success, otherwise false.
+ */
+bool sensord_get_max_range(sensor_t sensor, float *max_range);
+
+/**
+ * @brief Get the resolution of this sensor in the sensor's unit.
+ *
+ * @param[in] sensor a sensor to get resolution.
+ * @param[out] resolution the resolution of this sensor in the sensor's unit.
+ * @return true on success, otherwise false.
+ */
+bool sensord_get_resolution(sensor_t sensor, float *resolution);
+
+/**
+ * @brief Get the minimum interval allowed between two events in microsecond or zero if this sensor only returns a value when the data it's measuring changes.
+ *
+ * @param[in] sensor a sensor to get minimum interval.
+ * @param[out] min_interval the minimum interval of this sensor.
+ * @return true on success, otherwise false.
+ */
+bool sensord_get_min_interval(sensor_t sensor, int *min_interval);
+
+/**
+ * @brief Get the number of events reserved for this sensor in the batch mode FIFO.
+ *
+ * @param[in] sensor a sensor to get the number of fifo count
+ * @param[out] fifo_count the number of events reserved for this sensor in the batch mode FIFO
+ * @return true on success, otherwise false
+ */
+bool sensord_get_fifo_count(sensor_t sensor, int *fifo_count);
+
+/**
+ * @brief Get the maximum number of events of this sensor that could be batched. If this value is zero it indicates that batch mode is not supported for this sensor.
+ *
+ * @param[in] sensor a sensor to the maximum number of events that could be batched.
+ * @param[out] max_batch_count the maximum number of events of this sensor that could be batched.
+ * @return true on success, otherwise false.
+ */
+bool sensord_get_max_batch_count(sensor_t sensor, int *max_batch_count);
+
+/**
+ * @brief Get the supported event types of this sensor.
+ *
+ * @param[in] sensor a sensor to get the supported event types.
+ * @param[out] event_types the array containing supported event types of this sensor, the caller should explicitly free this array.
+ * @param[out] count the count of the supported event types of this sensor.
+ * @return true on success, otherwise false.
+ */
+bool sensord_get_supported_event_types(sensor_t sensor, unsigned int **event_types, int *count);
+
+/**
+ * @brief Check a given event type is supporeted by this sensor.
+ *
+ * @param[in] sensor a sensor to check a given event type is supporeted.
+ * @param[out] event_type an event type to be checked whether supported or not.
+ * @param[out] supported whether a given event is supported or not in this sensor.
+ * @return true on success, otherwise false.
+ */
+bool sensord_is_supported_event_type(sensor_t sensor, unsigned int event_type, bool *supported);
+
+/**
+ * @brief Check a wakeup supported or not by this sensor.
+ *
+ * @param[in] sensor a sensor to check a given event type is supporeted.
+ * @return true on success, otherwise false.
+ */
+bool sensord_is_wakeup_supported(sensor_t sensor);
+
+/**
+ * @brief Connect a given sensor and get a handle of a given sensor.
+ *
+ * @param[in] sensor a sensor to connect
+ * @return a handle of a given sensor on success, otherwise negative value
+ */
+int sensord_connect(sensor_t sensor);
+
+/**
+ * @brief Disconnect a given sensor.
+ *
+ * @param[in] handle a handle to disconnect.
+ * @return true on success, otherwise false.
+ */
+bool sensord_disconnect(int handle);
+
+/**
+ * @brief Register a callback with a connected sensor for a given event_type. This callback will be called when a given event occurs in a connected sensor.
+ *
+ * @param[in] handle a handle represensting a connected sensor.
+ * @param[in] event_type an event type  to register
+ * @param[in] interval The desired interval between two consecutive events in microseconds. This is only a hint to the system so events may be received faster or slower than the specified interval.
+ *                                  It can be one of SENSOR_INTERVAL_NORMAL,  SENSOR_INTERVAL_FASTEST or the interval in microseconds.
+ * @param[in] max_batch_latency An event in the batch can be delayed by at most max_batch_latency microseconds. If this is set to zero, batch mode is disabled.
+ * @param[in] cb a callback which is called when a given event occurs
+ * @param[in] user_data the callback is called with user_data
+ * @return true on success, otherwise false.
+ */
+bool sensord_register_event(int handle, unsigned int event_type, unsigned int interval, unsigned int max_batch_latency, sensor_cb_t cb, void *user_data);
+
+/**
+ * @brief Register a callback with a connected sensor for a given event_type. This callback will be called when a given event occurs in a connected sensor.
+ *
+ * @param[in] handle a handle represensting a connected sensor.
+ * @param[in] event_type an event type  to register
+ * @param[in] max_batch_latency An event in the batch can be delayed by at most max_batch_latency microseconds. If this is set to zero, batch mode is disabled.
+ * @param[in] cb a callback which is called when a given event occurs
+ * @param[in] user_data the callback is called with user_data
+ * @return true on success, otherwise false.
+ */
+bool sensord_register_events(int handle, unsigned int event_type, unsigned int max_batch_latency, sensor_events_cb_t cb, void *user_data);
+
+/**
+ * @brief Register a callback with a connected context sensor for a given event_type. This callback will be called when a given event occurs in a connected context sensor.
+ *
+ * @param[in] handle a handle represensting a connected context sensor.
+ * @param[in] event_type an event type to register
+ * @param[in] interval The desired interval between two consecutive events in microseconds. This is only a hint to the system so events may be received faster or slower than the specified interval.
+ *                                   It can be one of SENSOR_INTERVAL_NORMAL,  SENSOR_INTERVAL_FASTEST or the interval in microseconds.
+ * @param[in] max_batch_latency An event in the batch can be delayed by at most max_batch_latency microseconds. If this is set to zero, batch mode is disabled.
+ * @param[in] cb a callback which is called when a given event occurs
+ * @param[in] user_data the callback is called with user_data
+ * @return true on success, otherwise false.
+ */
+bool sensord_register_hub_event(int handle, unsigned int event_type, unsigned int interval, unsigned int max_batch_latency, sensorhub_cb_t cb, void *user_data);
+
+/**
+ * @brief Unregister a event with a connected sensor.  After unregistering, that event will not be sent.
+ *
+ * @param[in] handle a handle represensting a connected sensor.
+ * @param[in] event_type an event type to unregister.
+ * @return true on success, otherwise false.
+ */
+bool sensord_unregister_event(int handle, unsigned int event_type);
+
+/**
+ * @brief Unregister a event with a connected sensor.  After unregistering, that event will not be sent.
+ *
+ * @param[in] handle a handle represensting a connected sensor.
+ * @param[in] event_type an event type to unregister.
+ * @return true on success, otherwise false.
+ */
+bool sensord_unregister_events(int handle, unsigned int event_type);
+
+/**
+ * @brief Register a callback with a connected sensor. This callback will be called when the accuracy of a sensor has changed.
+ *
+ * @param[in] handle a handle represensting a connected sensor.
+ * @param[in] cb a callback which is called when he accuracy of a sensor has changed.
+ * @param[in] user_data the callback is called with user_data
+ * @return true on success, otherwise false.
+ */
+bool sensord_register_accuracy_cb(int handle, sensor_accuracy_changed_cb_t cb, void *user_data);
+
+/**
+ * @brief Unregister a callback with a connected sensor.  After unregistering,  sensor_accuray_change_cb will not be called.
+ *
+ * @param[in] handle a handle represensting a connected sensor.
+ * @return true on success, otherwise false.
+ */
+bool sensord_unregister_accuracy_cb(int handle);
+
+/**
+ * @brief Register a callback with a connected sensor. This callback will be called when attributes of a sensor has changed.
+ *
+ * @param[in] handle a handle represensting a connected sensor.
+ * @param[in] cb a callback which is called when he attributes of a sensor has changed.
+ * @param[in] user_data the callback is called with user_data
+ * @return true on success, otherwise false.
+ */
+bool sensord_register_attribute_int_changed_cb(int handle, sensor_attribute_int_changed_cb_t cb, void *user_data);
+
+/**
+ * @brief Unregister a callback with a connected sensor. After unregistering, sensor_attribute_int_changed_cb will not be called.
+ *
+ * @param[in] handle a handle represensting a connected sensor.
+ * @return true on success, otherwise false.
+ */
+bool sensord_unregister_attribute_int_changed_cb(int handle);
+
+/**
+ * @brief Register a callback with a connected sensor. This callback will be called when attributes of a sensor has changed.
+ *
+ * @param[in] handle a handle represensting a connected sensor.
+ * @param[in] cb a callback which is called when he attributes of a sensor has changed.
+ * @param[in] user_data the callback is called with user_data
+ * @return true on success, otherwise false.
+ */
+bool sensord_register_attribute_str_changed_cb(int handle, sensor_attribute_str_changed_cb_t cb, void *user_data);
+
+/**
+ * @brief Unregister a callback with a connected sensor. After unregistering, sensor_attribute_str_changed_cb will not be called.
+ *
+ * @param[in] handle a handle represensting a connected sensor.
+ * @return true on success, otherwise false.
+ */
+bool sensord_unregister_attribute_str_changed_cb(int handle);
+
+/**
+ * @brief Start listening events with a connected sensor.
+ *
+ * @param[in] handle a handle represensting a connected sensor.
+ * @param[in] option either one of SENSOR_OPTION_DEFAULT and  SENSOR_OPTION_ALWAYS_ON.
+ *                                with SENSOR_OPTION_DEFAULT, it stops to listening events when LCD is off or in power save mode.
+ *                                with SENSOR_OPTION_ALWAYS_ON, it continues to listening events even when LCD is off or in power save mode.
+ * @return true on success, otherwise false.
+ */
+bool sensord_start(int handle, int option);
+
+/**
+ * @brief Stop listening events with a connected sensor.
+ *
+ * @param[in] handle a handle represensting a connected sensor.
+ * @return true on success, otherwise false.
+ */
+bool sensord_stop(int handle);
+
+/**
+ * @brief Change the interval of a specifed event type in a connected sensor.
+ *
+ * @param[in] handle a handle represensting a connected sensor.
+ * @param[in] event_type an event type to change interval.
+ * @param[in] interval The desired interval between two consecutive events in microseconds. This is only a hint to the system so events may be received faster or slower than the specified interval.
+ *                                   It can be one of SENSOR_INTERVAL_NORMAL,  SENSOR_INTERVAL_FASTEST or the interval in microseconds.
+ * @return true on success, otherwise false.
+ */
+bool sensord_change_event_interval(int handle, unsigned int event_type, unsigned int interval);
+
+/**
+ * @brief Change the max batch latency of a specifed event type in a connected sensor.
+ *
+ * @param[in] handle a handle represensting a connected sensor.
+ * @param[in] event_type an event type to change max batch latency
+ * @param[in] max_batch_latency an event in the batch can be delayed by at most max_batch_latency microseconds. If this is set to zero, batch mode is disabled.
+ * @return true on success, otherwise false.
+ */
+bool sensord_change_event_max_batch_latency(int handle, unsigned int event_type, unsigned int max_batch_latency);
+
+/**
+ * @brief Change the option of a connected sensor.
+ *
+ * @param[in] handle a handle represensting a connected sensor.
+ * @param[in] option either one of SENSOR_OPTION_DEFAULT and  SENSOR_OPTION_ALWAYS_ON.
+ *                                with SENSOR_OPTION_DEFAULT, it stops to listening events when LCD is off or in power save mode.
+ *                                with SENSOR_OPTION_ALWAYS_ON, it continues to listening events even when LCD is off or in power save mode.
+ * @return true on success, otherwise false.
+ */
+bool sensord_set_option(int handle, int option);
+
+/*
+ * @brief Set the attribute to a connected sensor
+ *
+ * @param[in] handle a handle represensting a connected sensor.
+ * @param[in] attribute an attribute to change
+ * @param[in] value an attribute value
+ * @return 0 on success, otherwise a negative error value
+ * @retval 0 Successful
+ * @retval -EINVAL Invalid parameter
+ * @retval -EPERM Operation not permitted
+ */
+int sensord_set_attribute_int(int handle, int attribute, int value);
+
+/*
+ * @brief Get the attribute to a connected sensor
+ *
+ * @param[in] handle a handle represensting a connected sensor.
+ * @param[in] attribute an attribute to get value
+ * @param[out] value an attribute value
+ * @return 0 on success, otherwise a negative error value
+ * @retval 0 Successful
+ * @retval -EINVAL Invalid parameter
+ * @retval -EPERM Operation not permitted
+ */
+int sensord_get_attribute_int(int handle, int attribute, int* value);
+
+/**
+ * @brief Set the attribute to a connected sensor
+ *
+ * @param[in] handle a handle represensting a connected sensor.
+ * @param[in] attribute an attribute to change
+ * @param[in] value an attribute value
+ * @param[in] value_len the length of value
+ * @return 0 on success, otherwise a negative error value
+ * @retval 0 Successful
+ * @retval -EINVAL Invalid parameter
+ * @retval -EPERM Operation not permitted
+ */
+int sensord_set_attribute_str(int handle, int attribute, const char *value, int len);
+
+/**
+ * @brief Get the attribute to a connected sensor
+ *
+ * @param[in] handle a handle represensting a connected sensor.
+ * @param[in] attribute an attribute to get value
+ * @param[out] value an attribute value, the caller should explicitly free this value
+ * @param[out] len the length of value
+ * @return 0 on success, otherwise a negative error value
+ * @retval 0 Successful
+ * @retval -EINVAL Invalid parameter
+ * @retval -EPERM Operation not permitted
+ */
+int sensord_get_attribute_str(int handle, int attribute, char **value, int *len);
+
+/**
+ * @brief Send data to sensorhub
+ *
+ * @param[in] handle a handle represensting a connected context sensor.
+ * @param[in] data it holds data to send to sensorhub
+ * @param[in] data_len the length of data
+ * @return true on success, otherwise false.
+ */
+bool sensord_send_sensorhub_data(int handle, const char *data, int data_len);
+bool sensord_send_command(int handle, const char *command, int command_len);
+
+/**
+ * @brief get sensor data from a connected sensor
+ *
+ * @param[in] handle a handle represensting a connected context sensor.
+ * @param[in] data_id it specifies data to get
+ * @param[out] sensor_data data from connected sensor
+ * @return true on success, otherwise false.
+ */
+bool sensord_get_data(int handle, unsigned int data_id, sensor_data_t* sensor_data);
+
+/**
+ * @brief get sensor data from a connected sensor
+ *
+ * @param[in] handle a handle represensting a connected context sensor.
+ * @param[in] data_id it specifies data to get
+ * @param[out] sensor_data the data list from connected sensor, the caller should explicitly free this list.
+ * @param[out] count the count of data contained in the list.
+ * @return true on success, otherwise false.
+ */
+bool sensord_get_data_list(int handle, unsigned int data_id, sensor_data_t** sensor_data, int* count);
+
+/**
+ * @brief flush sensor data from a connected sensor
+ *
+ * @param[in] handle a handle represensting a connected context sensor.
+ * @return true on success, otherwise false.
+ */
+bool sensord_flush(int handle);
+
+bool sensord_set_passive_mode(int handle, bool passive);
+
+
+/* Sensor Internal API using URI */
+int sensord_get_default_sensor_by_uri(const char *uri, sensor_t *sensor);
+int sensord_get_sensors_by_uri(const char *uri, sensor_t **list, int *sensor_count);
+
+typedef void (*sensord_added_cb)(const char *uri, void *user_data);
+int sensord_add_sensor_added_cb(sensord_added_cb callback, void *user_data);
+int sensord_remove_sensor_added_cb(sensord_added_cb callback);
+
+typedef void (*sensord_removed_cb)(const char *uri, void *user_data);
+int sensord_add_sensor_removed_cb(sensord_removed_cb callback, void *user_data);
+int sensord_remove_sensor_removed_cb(sensord_removed_cb callback);
+
+/* Sensor provider */
+typedef void *sensord_provider_h;
+int sensord_create_provider(const char *uri, sensord_provider_h *provider);
+int sensord_destroy_provider(sensord_provider_h provider);
+int sensord_add_provider(sensord_provider_h provider);
+int sensord_remove_provider(sensord_provider_h provider);
+
+int sensord_provider_set_name(sensord_provider_h provider, const char *name);
+int sensord_provider_set_vendor(sensord_provider_h provider, const char *vendor);
+int sensord_provider_set_range(sensord_provider_h provider, float min_range, float max_range);
+int sensord_provider_set_resolution(sensord_provider_h provider, float resolution);
+
+typedef void (*sensord_provider_start_cb)(sensord_provider_h provider, void *user_data);
+int sensord_provider_set_start_cb(sensord_provider_h provider, sensord_provider_start_cb callback, void *user_data);
+
+typedef void (*sensord_provider_stop_cb)(sensord_provider_h provider, void *user_data);
+int sensord_provider_set_stop_cb(sensord_provider_h provider, sensord_provider_stop_cb callback, void *user_data);
+
+typedef void (*sensord_provider_interval_changed_cb)(sensord_provider_h provider, unsigned int interval_ms, void *user_data);
+int sensord_provider_set_interval_changed_cb(sensord_provider_h provider, sensord_provider_interval_changed_cb callback, void *user_data);
+
+typedef void (*sensord_provider_attribute_str_cb)(sensord_provider_h provider, int attribute, const char *value, int count, void *user_data);
+int sensord_provider_set_attribute_str_cb(sensord_provider_h provider, sensord_provider_attribute_str_cb callback, void *user_data);
+
+int sensord_provider_publish(sensord_provider_h provider, sensor_data_t data);
+int sensord_provider_publish_events(sensord_provider_h provider, sensor_data_t events[], int count);
+
 /**
  * @brief Set the attribute to a connected sensor
  *
@@ -55,6 +557,12 @@ int sensor_util_set_attribute_int(sensor_type_e type, sensor_attribute_e attr, i
  */
 int sensor_util_get_attribute_int(sensor_type_e type, sensor_attribute_e attr, int *value);
 
+/* Deprecated */
+typedef void (*sensor_external_command_cb_t)(int handle, const char* data, int data_cnt, void *user_data);
+int sensord_external_connect(const char *key, sensor_external_command_cb_t cb, void *user_data);
+bool sensord_external_disconnect(int handle);
+bool sensord_external_post(int handle, unsigned long long timestamp, const float* data, int data_cnt);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/include/sensor-log.h b/include/sensor-log.h
new file mode 100644 (file)
index 0000000..3904e13
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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_
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <dlog/dlog.h>
+#include <sys/types.h>
+
+#ifdef LOG_TAG
+       #undef LOG_TAG
+#endif
+#define LOG_TAG        "TIZEN_SYSTEM_SENSOR"
+
+/* Logging and Error Handling */
+#define _I SLOGI
+#define _D SLOGD
+#define _W SLOGW
+#define _E SLOGE
+#define _SI SECURE_SLOGI
+#define _SD SECURE_SLOGD
+#define _SW SECURE_SLOGW
+#define _SE SECURE_SLOGE
+
+#define _ERRNO(errno, tag, fmt, arg...) \
+       do { \
+               char buf[1024]; \
+               char *error = strerror_r(errno, buf, 1024); \
+               if (!error) { \
+                       _E("Failed to strerror_r()"); \
+                       break; \
+               } \
+               tag(fmt" (%s[%d])", ##arg, error, errno); \
+       } while (0)
+
+#define warn_if(expr, fmt, arg...) \
+       do { if (expr) { _E(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) { _E(fmt, ##arg); return; } } while (0)
+
+#define retvm_if(expr, val, fmt, arg...) \
+       do { if (expr) { _E(fmt, ##arg); return (val); } } while (0)
+
+#define LOG_DUMP(fp, fmt, arg...) \
+       do { if (fp) fprintf(fp, fmt, ##arg); else _E(fmt, ##arg); } while (0)
+
+#define log_oom() ({ \
+       _E("Out of memory"); \
+       -ENOMEM;})
+
+
+#define _MSG_SENSOR_ERROR_IO_ERROR "Io Error"
+#define _MSG_SENSOR_ERROR_INVALID_PARAMETER "Invalid Parameter"
+#define _MSG_SENSOR_ERROR_OUT_OF_MEMORY "Out of Memory"
+#define _MSG_SENSOR_ERROR_NOT_NEED_CALIBRATION "Not need calibration"
+#define _MSG_SENSOR_ERROR_NOT_SUPPORTED "Not supported"
+#define _MSG_SENSOR_ERROR_OPERATION_FAILED "Operation failed"
+
+#define _E_MSG(err) SLOGE(_MSG_##err "(0x%08x)", (err))
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SENSOR_LOG_H_ */
diff --git a/include/sensor-private.h b/include/sensor-private.h
new file mode 100644 (file)
index 0000000..7d99272
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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_PRIVATE_H__
+#define __SENSOR_PRIVATE_H__
+
+struct sensor_listener_s {
+       int id;
+       int type;
+       int pause;
+       unsigned int batch_latency;
+       unsigned int magic;
+       void *sensor;
+       void *callback;
+       void *user_data;
+       void *accu_callback;
+       void *accu_user_data;
+};
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+float clamp(float v);
+int getAngleChange(float *R, float *prevR, float *angleChange);
+int quatToMatrix(float *quat, float *R);
+int matrixToQuat(float *mat, float *q);
+int getRotationMatrix(float *accel, float *geo, float *R, float *I);
+int remapCoordinateSystem(float *inR, int X, int Y, float *outR);
+int getDeclination(float *decl);
+int getInclination(float *incl);
+int setCoordinate(float latitude, float longitude, float altitude, float *declination, float *inclination, int option);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __SENSOR_PRIVATE_H__
diff --git a/include/sensor-types.h b/include/sensor-types.h
new file mode 100644 (file)
index 0000000..a2028d3
--- /dev/null
@@ -0,0 +1,294 @@
+/*
+ * sensord
+ *
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __SENSOR_TYPES_H__
+#define __SENSOR_TYPES_H__
+
+/* TODO: It is for compatibility with capi-system-sensor */
+#define __SENSOR_COMMON_H__
+
+#include <stddef.h>
+#include <stdint.h>
+#include <hal/hal-sensor-types.h>
+
+#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)
+
+#define SENSOR_UNKNOWN_TYPE "http://tizen.org/sensor/unknown"
+#define SENSOR_UNKNOWN_NAME "Unknown"
+
+typedef int64_t sensor_id_t;
+typedef void *sensor_t;
+
+typedef enum sensor_type_t {
+       UNKNOWN_SENSOR = -2,
+       ALL_SENSOR = -1,
+       ACCELEROMETER_SENSOR = 0,
+       GRAVITY_SENSOR,
+       LINEAR_ACCEL_SENSOR,
+       GEOMAGNETIC_SENSOR,
+       ROTATION_VECTOR_SENSOR,
+       ORIENTATION_SENSOR,
+       GYROSCOPE_SENSOR,
+       LIGHT_SENSOR,
+       PROXIMITY_SENSOR,
+       PRESSURE_SENSOR,
+       ULTRAVIOLET_SENSOR,
+       TEMPERATURE_SENSOR,
+       HUMIDITY_SENSOR,
+       HRM_SENSOR,
+       BIO_HRM_SENSOR = HRM_SENSOR,
+       HRM_LED_GREEN_SENSOR,
+       BIO_LED_GREEN_SENSOR = HRM_LED_GREEN_SENSOR,
+       HRM_LED_IR_SENSOR,
+       BIO_LED_IR_SENSOR = HRM_LED_IR_SENSOR,
+       HRM_LED_RED_SENSOR,
+       BIO_LED_RED_SENSOR = HRM_LED_RED_SENSOR,
+       GYROSCOPE_UNCAL_SENSOR,
+       GEOMAGNETIC_UNCAL_SENSOR,
+       GYROSCOPE_RV_SENSOR,
+       GEOMAGNETIC_RV_SENSOR,
+
+       GYROSCOPE_ORIENTATION_SENSOR = 100,
+       GEOMAGNETIC_ORIENTATION_SENSOR = 105,
+
+       SIGNIFICANT_MOTION_SENSOR = 0x100, //256
+
+       HRM_BATCH_SENSOR = 0x200, //512
+       HRM_LED_GREEN_BATCH_SENSOR,
+
+       HUMAN_PEDOMETER_SENSOR = 0x300, //768
+       HUMAN_SLEEP_MONITOR_SENSOR,
+       HUMAN_SLEEP_DETECTOR_SENSOR,
+       SLEEP_DETECTOR_SENSOR = HUMAN_SLEEP_DETECTOR_SENSOR,
+       HUMAN_STRESS_MONITOR_SENSOR,
+       STRESS_MONITOR_SENSOR = HUMAN_STRESS_MONITOR_SENSOR,
+
+       LIDAR_SENSOR = 1000,
+
+       EXERCISE_WALKING_SENSOR = 0x400, //1024
+       EXERCISE_RUNNING_SENSOR,
+       EXERCISE_HIKING_SENSOR,
+       EXERCISE_CYCLING_SENSOR,
+       EXERCISE_ELLIPTICAL_SENSOR,
+       EXERCISE_INDOOR_CYCLING_SENSOR,
+       EXERCISE_ROWING_SENSOR,
+       EXERCISE_STEPPER_SENSOR,
+
+       DATA_JOURNAL_SENSOR = 0x500,
+       // 0x500~0x600 Reserved (1280 ~ 1536)
+
+       EXTERNAL_EXERCISE_SENSOR = 0x800, //2048
+       EXERCISE_SENSOR = EXTERNAL_EXERCISE_SENSOR,
+
+       FUSION_SENSOR = 0x900, //2304
+       AUTO_ROTATION_SENSOR,
+       AUTO_BRIGHTNESS_SENSOR,
+       MYOTEST_SENSOR,
+
+       GESTURE_MOVEMENT_SENSOR = 0x1200, //4608
+       GESTURE_WRIST_UP_SENSOR,
+       GESTURE_WRIST_DOWN_SENSOR,
+       GESTURE_MOVEMENT_STATE_SENSOR,
+       GESTURE_PICK_UP_SENSOR,
+       GESTURE_FACE_DOWN_SENSOR,
+
+       ACTIVITY_TRACKER_SENSOR = 0x1A00, //6656
+       ACTIVITY_LEVEL_MONITOR_SENSOR,
+       GPS_BATCH_SENSOR,
+       PPG_BATCH_SENSOR,
+       GPS_TIMESYNC_SENSOR,
+
+       HRM_CTRL_SENSOR = 0x1A80, //6784
+       REG_CTRL_SENSOR,
+       GPS_CTRL_SENSOR,
+
+       WEAR_STATUS_SENSOR = 0x2000, //8192
+       WEAR_ON_MONITOR_SENSOR,
+       NO_MOVE_DETECTOR_SENSOR,
+       RESTING_HR_SENSOR,
+       STEP_LEVEL_MONITOR_SENSOR,
+       EXERCISE_STANDALONE_SENSOR,
+       EXERCISE_COACH_SENSOR = EXERCISE_STANDALONE_SENSOR,
+       EXERCISE_HR_SENSOR,
+       WORKOUT_SENSOR,
+       AUTOSESSION_EXERCISE_SENSOR = WORKOUT_SENSOR,
+       CYCLE_MONITOR_SENSOR,
+       STAIR_TRACKER_SENSOR,
+       PRESSURE_INDICATOR_SENSOR,
+       PRESSURE_ALERT_SENSOR,
+       HR_CALORIE_SENSOR,
+       SWIMMING_TRACKER_SENSOR,
+       STRESS_TRACKER_SENSOR,
+       FAKE_MOTION_SENSOR,
+       GEOFENCE_SENSOR,
+       SWIMMING_OUTDOOR_SENSOR,
+       AUTO_SWIMMING_SENSOR,
+       INACTIVITY_DETECTOR_SENSOR,
+       HRM_BP_SENSOR,
+       ECG_SENSOR,
+       FALL_DETECTION_SENSOR,
+
+       CONTEXT_SENSOR = 0x7000, //28,672
+       MOTION_SENSOR,
+       PIR_SENSOR,
+       PIR_LONG_SENSOR,
+       DUST_SENSOR,
+       THERMOMETER_SENSOR,
+       PEDOMETER_SENSOR,
+       FLAT_SENSOR,
+       HRM_RAW_SENSOR,
+       BIO_SENSOR = HRM_RAW_SENSOR,
+       TILT_SENSOR,
+       RV_RAW_SENSOR,
+       GSR_SENSOR,
+       SIMSENSE_SENSOR,
+       PPG_SENSOR,
+
+       CUSTOM_SENSOR = 0X9000, //36,864
+} sensor_type_t;
+
+typedef struct sensor_info2_t {
+       uint32_t id;
+       sensor_type_t type;
+       const char *uri;
+       const char *vendor;
+       float min_range;
+       float max_range;
+       float resolution;
+       int min_interval;
+       int max_interval;
+       int max_batch_count;
+       bool wakeup_supported;
+       const char *privilege;
+       void *reserved[8];
+} sensor_info2_t;
+
+typedef enum sensor_privilege_t {
+       SENSOR_PRIVILEGE_PUBLIC = 0,
+} 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,
+       // 0x50~0x80 Reserved
+};
+
+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,
+};
+
+#define DEFAULT_INTERVAL POLL_10HZ_MS
+
+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,
+};
+
+enum auto_rotation_state {
+       AUTO_ROTATION_DEGREE_UNKNOWN = 0,
+       AUTO_ROTATION_DEGREE_0,
+       AUTO_ROTATION_DEGREE_90,
+       AUTO_ROTATION_DEGREE_180,
+       AUTO_ROTATION_DEGREE_270,
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SENSOR_TYPES_H__ */
diff --git a/include/sensor_internal.h b/include/sensor_internal.h
deleted file mode 100644 (file)
index 477c8d7..0000000
+++ /dev/null
@@ -1,545 +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 __SENSORD_INTERNAL_H__
-#define __SENSORD_INTERNAL_H__
-
-#ifndef API
-#define API __attribute__((visibility("default")))
-#endif
-
-#include <stdbool.h>
-#include <sys/types.h>
-#include <limits.h>
-
-/*header for common sensor type*/
-#include <sensor_types.h>
-
-#define SENSOR_BATCH_LATENCY_DEFAULT UINT_MAX
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-typedef void (*sensor_cb_t)(sensor_t sensor, unsigned int event_type, sensor_data_t *data, void *user_data);
-typedef void (*sensor_events_cb_t)(sensor_t sensor, unsigned int event_type, sensor_data_t events[], int events_count, void *user_data);
-typedef void (*sensorhub_cb_t)(sensor_t sensor, unsigned int event_type, sensorhub_data_t *data, void *user_data);
-typedef void (*sensor_accuracy_changed_cb_t) (sensor_t sensor, unsigned long long timestamp, int accuracy, void *user_data);
-typedef void (*sensor_attribute_int_changed_cb_t)(sensor_t sensor, int attribute, int value, void *user_data);
-typedef void (*sensor_attribute_str_changed_cb_t)(sensor_t sensor, int attribute, const char *value, int len, void *user_data);
-
-/**
- * @brief Get the list of available sensors of a certain type,  use ALL_SENSOR to get all the sensors.
- *
- * @param[in] type the type of sensors requested.
- * @param[out] list the list of sensors matching the asked type,  the caller should explicitly free this list.
- * @param[out] sensor count the count of sensors contained in the list.
- * @return true on success, otherwise false.
- */
-bool sensord_get_sensor_list(sensor_type_t type, sensor_t **list, int *sensor_count);
-
-/**
- * @brief Get the default sensor for a given type.
- *
- * @param[in] type the type of a sensor requested.
- * @return the default sensor matching the asked type on success, otherwise NULL.
- */
-sensor_t sensord_get_sensor(sensor_type_t type);
-
-/**
- * @brief Get the list of available sensors of a certain type,  use ALL_SENSOR to get all the sensors.
- *
- * @param[in] type the type of sensors requested.
- * @param[out] list the list of sensors matching the asked type,  the caller should explicitly free this list.
- * @param[out] sensor count the count of sensors contained in the list.
- * @return 0 on success, otherwise a negative error value
- * @retval 0 Successful
- * @retval -EPERM Operation not permitted
- * @retval -EACCES Permission denied
- * @retval -ENODATA NO sensor available
- */
-int sensord_get_sensors(sensor_type_t type, sensor_t **list, int *sensor_count);
-
-/**
- * @brief Get the default sensor for a given type.
- *
- * @param[in] type the type of a sensor requested.
- * @param[out] a sensor matching the asked type.
- * @return 0 on success, otherwise a negative error value
- * @retval 0 Successful
- * @retval -EPERM Operation not permitted
- * @retval -EACCES Permission denied
- */
-int sensord_get_default_sensor(sensor_type_t type, sensor_t *sensor);
-
-/**
- * @brief Get the type of this sensor.
- *
- * @param[in] sensor a sensor to get type.
- * @param[out] type the type of this sensor.
- * @return return true on success, otherwise false.
- */
-bool sensord_get_type(sensor_t sensor, sensor_type_t *type);
-
-/**
- * @brief Get the URI string of this sensor.
- *
- * @param[in] sensor a sensor to get uri.
- * @return the name string of this sensor on success, otherwise NULL.
- */
-const char* sensord_get_uri(sensor_t sensor);
-
-/**
- * @brief Get the name string of this sensor.
- *
- * @param[in] sensor a sensor to get name.
- * @return the name string of this sensor on success, otherwise NULL.
- */
-const char* sensord_get_name(sensor_t sensor);
-
-/**
- * @brief Get the vendor string of this sensor.
- *
- * @param[in] sensor a sensor to get vendor.
- * @return the vendor string of this sensor on success, otherwise NULL.
- */
-const char* sensord_get_vendor(sensor_t sensor);
-
-/**
- * @brief Get the privilege of this sensor.
- *
- * @param[in] sensor a sensor to get privilege.
- * @param[out] privilege the privilege of this sensor.
- * @return true on success, otherwise false.
- */
-bool sensord_get_privilege(sensor_t sensor, sensor_privilege_t *privilege);
-
-/**
- * @brief Get the minimum range of this sensor in the sensor's unit.
- *
- * @param[in] sensor a sensor to get minimum range.
- * @param[out] min_range the minimum range of this sensor in the sensor's unit.
- * @return true on success, otherwise false.
- */
-bool sensord_get_min_range(sensor_t sensor, float *min_range);
-
-/**
- * @brief Get the maximum range of this sensor in the sensor's unit.
- *
- * @param[in] sensor a sensor to get maximum range.
- * @param[out] max_range the maximum range of this sensor in the sensor's unit.
- * @return true on success, otherwise false.
- */
-bool sensord_get_max_range(sensor_t sensor, float *max_range);
-
-/**
- * @brief Get the resolution of this sensor in the sensor's unit.
- *
- * @param[in] sensor a sensor to get resolution.
- * @param[out] resolution the resolution of this sensor in the sensor's unit.
- * @return true on success, otherwise false.
- */
-bool sensord_get_resolution(sensor_t sensor, float *resolution);
-
-/**
- * @brief Get the minimum interval allowed between two events in microsecond or zero if this sensor only returns a value when the data it's measuring changes.
- *
- * @param[in] sensor a sensor to get minimum interval.
- * @param[out] min_interval the minimum interval of this sensor.
- * @return true on success, otherwise false.
- */
-bool sensord_get_min_interval(sensor_t sensor, int *min_interval);
-
-/**
- * @brief Get the number of events reserved for this sensor in the batch mode FIFO.
- *
- * @param[in] sensor a sensor to get the number of fifo count
- * @param[out] fifo_count the number of events reserved for this sensor in the batch mode FIFO
- * @return true on success, otherwise false
- */
-bool sensord_get_fifo_count(sensor_t sensor, int *fifo_count);
-
-/**
- * @brief Get the maximum number of events of this sensor that could be batched. If this value is zero it indicates that batch mode is not supported for this sensor.
- *
- * @param[in] sensor a sensor to the maximum number of events that could be batched.
- * @param[out] max_batch_count the maximum number of events of this sensor that could be batched.
- * @return true on success, otherwise false.
- */
-bool sensord_get_max_batch_count(sensor_t sensor, int *max_batch_count);
-
-/**
- * @brief Get the supported event types of this sensor.
- *
- * @param[in] sensor a sensor to get the supported event types.
- * @param[out] event_types the array containing supported event types of this sensor, the caller should explicitly free this array.
- * @param[out] count the count of the supported event types of this sensor.
- * @return true on success, otherwise false.
- */
-bool sensord_get_supported_event_types(sensor_t sensor, unsigned int **event_types, int *count);
-
-/**
- * @brief Check a given event type is supporeted by this sensor.
- *
- * @param[in] sensor a sensor to check a given event type is supporeted.
- * @param[out] event_type an event type to be checked whether supported or not.
- * @param[out] supported whether a given event is supported or not in this sensor.
- * @return true on success, otherwise false.
- */
-bool sensord_is_supported_event_type(sensor_t sensor, unsigned int event_type, bool *supported);
-
-/**
- * @brief Check a wakeup supported or not by this sensor.
- *
- * @param[in] sensor a sensor to check a given event type is supporeted.
- * @return true on success, otherwise false.
- */
-bool sensord_is_wakeup_supported(sensor_t sensor);
-
-/**
- * @brief Connect a given sensor and get a handle of a given sensor.
- *
- * @param[in] sensor a sensor to connect
- * @return a handle of a given sensor on success, otherwise negative value
- */
-int sensord_connect(sensor_t sensor);
-
-/**
- * @brief Disconnect a given sensor.
- *
- * @param[in] handle a handle to disconnect.
- * @return true on success, otherwise false.
- */
-bool sensord_disconnect(int handle);
-
-/**
- * @brief Register a callback with a connected sensor for a given event_type. This callback will be called when a given event occurs in a connected sensor.
- *
- * @param[in] handle a handle represensting a connected sensor.
- * @param[in] event_type an event type  to register
- * @param[in] interval The desired interval between two consecutive events in microseconds. This is only a hint to the system so events may be received faster or slower than the specified interval.
- *                                  It can be one of SENSOR_INTERVAL_NORMAL,  SENSOR_INTERVAL_FASTEST or the interval in microseconds.
- * @param[in] max_batch_latency An event in the batch can be delayed by at most max_batch_latency microseconds. If this is set to zero, batch mode is disabled.
- * @param[in] cb a callback which is called when a given event occurs
- * @param[in] user_data the callback is called with user_data
- * @return true on success, otherwise false.
- */
-bool sensord_register_event(int handle, unsigned int event_type, unsigned int interval, unsigned int max_batch_latency, sensor_cb_t cb, void *user_data);
-
-/**
- * @brief Register a callback with a connected sensor for a given event_type. This callback will be called when a given event occurs in a connected sensor.
- *
- * @param[in] handle a handle represensting a connected sensor.
- * @param[in] event_type an event type  to register
- * @param[in] max_batch_latency An event in the batch can be delayed by at most max_batch_latency microseconds. If this is set to zero, batch mode is disabled.
- * @param[in] cb a callback which is called when a given event occurs
- * @param[in] user_data the callback is called with user_data
- * @return true on success, otherwise false.
- */
-bool sensord_register_events(int handle, unsigned int event_type, unsigned int max_batch_latency, sensor_events_cb_t cb, void *user_data);
-
-/**
- * @brief Register a callback with a connected context sensor for a given event_type. This callback will be called when a given event occurs in a connected context sensor.
- *
- * @param[in] handle a handle represensting a connected context sensor.
- * @param[in] event_type an event type to register
- * @param[in] interval The desired interval between two consecutive events in microseconds. This is only a hint to the system so events may be received faster or slower than the specified interval.
- *                                   It can be one of SENSOR_INTERVAL_NORMAL,  SENSOR_INTERVAL_FASTEST or the interval in microseconds.
- * @param[in] max_batch_latency An event in the batch can be delayed by at most max_batch_latency microseconds. If this is set to zero, batch mode is disabled.
- * @param[in] cb a callback which is called when a given event occurs
- * @param[in] user_data the callback is called with user_data
- * @return true on success, otherwise false.
- */
-bool sensord_register_hub_event(int handle, unsigned int event_type, unsigned int interval, unsigned int max_batch_latency, sensorhub_cb_t cb, void *user_data);
-
-/**
- * @brief Unregister a event with a connected sensor.  After unregistering, that event will not be sent.
- *
- * @param[in] handle a handle represensting a connected sensor.
- * @param[in] event_type an event type to unregister.
- * @return true on success, otherwise false.
- */
-bool sensord_unregister_event(int handle, unsigned int event_type);
-
-/**
- * @brief Unregister a event with a connected sensor.  After unregistering, that event will not be sent.
- *
- * @param[in] handle a handle represensting a connected sensor.
- * @param[in] event_type an event type to unregister.
- * @return true on success, otherwise false.
- */
-bool sensord_unregister_events(int handle, unsigned int event_type);
-
-/**
- * @brief Register a callback with a connected sensor. This callback will be called when the accuracy of a sensor has changed.
- *
- * @param[in] handle a handle represensting a connected sensor.
- * @param[in] cb a callback which is called when he accuracy of a sensor has changed.
- * @param[in] user_data the callback is called with user_data
- * @return true on success, otherwise false.
- */
-bool sensord_register_accuracy_cb(int handle, sensor_accuracy_changed_cb_t cb, void *user_data);
-
-/**
- * @brief Unregister a callback with a connected sensor.  After unregistering,  sensor_accuray_change_cb will not be called.
- *
- * @param[in] handle a handle represensting a connected sensor.
- * @return true on success, otherwise false.
- */
-bool sensord_unregister_accuracy_cb(int handle);
-
-/**
- * @brief Register a callback with a connected sensor. This callback will be called when attributes of a sensor has changed.
- *
- * @param[in] handle a handle represensting a connected sensor.
- * @param[in] cb a callback which is called when he attributes of a sensor has changed.
- * @param[in] user_data the callback is called with user_data
- * @return true on success, otherwise false.
- */
-bool sensord_register_attribute_int_changed_cb(int handle, sensor_attribute_int_changed_cb_t cb, void *user_data);
-
-/**
- * @brief Unregister a callback with a connected sensor. After unregistering, sensor_attribute_int_changed_cb will not be called.
- *
- * @param[in] handle a handle represensting a connected sensor.
- * @return true on success, otherwise false.
- */
-bool sensord_unregister_attribute_int_changed_cb(int handle);
-
-/**
- * @brief Register a callback with a connected sensor. This callback will be called when attributes of a sensor has changed.
- *
- * @param[in] handle a handle represensting a connected sensor.
- * @param[in] cb a callback which is called when he attributes of a sensor has changed.
- * @param[in] user_data the callback is called with user_data
- * @return true on success, otherwise false.
- */
-bool sensord_register_attribute_str_changed_cb(int handle, sensor_attribute_str_changed_cb_t cb, void *user_data);
-
-/**
- * @brief Unregister a callback with a connected sensor. After unregistering, sensor_attribute_str_changed_cb will not be called.
- *
- * @param[in] handle a handle represensting a connected sensor.
- * @return true on success, otherwise false.
- */
-bool sensord_unregister_attribute_str_changed_cb(int handle);
-
-/**
- * @brief Start listening events with a connected sensor.
- *
- * @param[in] handle a handle represensting a connected sensor.
- * @param[in] option either one of SENSOR_OPTION_DEFAULT and  SENSOR_OPTION_ALWAYS_ON.
- *                                with SENSOR_OPTION_DEFAULT, it stops to listening events when LCD is off or in power save mode.
- *                                with SENSOR_OPTION_ALWAYS_ON, it continues to listening events even when LCD is off or in power save mode.
- * @return true on success, otherwise false.
- */
-bool sensord_start(int handle, int option);
-
-/**
- * @brief Stop listening events with a connected sensor.
- *
- * @param[in] handle a handle represensting a connected sensor.
- * @return true on success, otherwise false.
- */
-bool sensord_stop(int handle);
-
-/**
- * @brief Change the interval of a specifed event type in a connected sensor.
- *
- * @param[in] handle a handle represensting a connected sensor.
- * @param[in] event_type an event type to change interval.
- * @param[in] interval The desired interval between two consecutive events in microseconds. This is only a hint to the system so events may be received faster or slower than the specified interval.
- *                                   It can be one of SENSOR_INTERVAL_NORMAL,  SENSOR_INTERVAL_FASTEST or the interval in microseconds.
- * @return true on success, otherwise false.
- */
-bool sensord_change_event_interval(int handle, unsigned int event_type, unsigned int interval);
-
-/**
- * @brief Change the max batch latency of a specifed event type in a connected sensor.
- *
- * @param[in] handle a handle represensting a connected sensor.
- * @param[in] event_type an event type to change max batch latency
- * @param[in] max_batch_latency an event in the batch can be delayed by at most max_batch_latency microseconds. If this is set to zero, batch mode is disabled.
- * @return true on success, otherwise false.
- */
-bool sensord_change_event_max_batch_latency(int handle, unsigned int event_type, unsigned int max_batch_latency);
-
-/**
- * @brief Change the option of a connected sensor.
- *
- * @param[in] handle a handle represensting a connected sensor.
- * @param[in] option either one of SENSOR_OPTION_DEFAULT and  SENSOR_OPTION_ALWAYS_ON.
- *                                with SENSOR_OPTION_DEFAULT, it stops to listening events when LCD is off or in power save mode.
- *                                with SENSOR_OPTION_ALWAYS_ON, it continues to listening events even when LCD is off or in power save mode.
- * @return true on success, otherwise false.
- */
-bool sensord_set_option(int handle, int option);
-
-/*
- * @brief Set the attribute to a connected sensor
- *
- * @param[in] handle a handle represensting a connected sensor.
- * @param[in] attribute an attribute to change
- * @param[in] value an attribute value
- * @return 0 on success, otherwise a negative error value
- * @retval 0 Successful
- * @retval -EINVAL Invalid parameter
- * @retval -EPERM Operation not permitted
- */
-int sensord_set_attribute_int(int handle, int attribute, int value);
-
-/*
- * @brief Get the attribute to a connected sensor
- *
- * @param[in] handle a handle represensting a connected sensor.
- * @param[in] attribute an attribute to get value
- * @param[out] value an attribute value
- * @return 0 on success, otherwise a negative error value
- * @retval 0 Successful
- * @retval -EINVAL Invalid parameter
- * @retval -EPERM Operation not permitted
- */
-int sensord_get_attribute_int(int handle, int attribute, int* value);
-
-/**
- * @brief Set the attribute to a connected sensor
- *
- * @param[in] handle a handle represensting a connected sensor.
- * @param[in] attribute an attribute to change
- * @param[in] value an attribute value
- * @param[in] value_len the length of value
- * @return 0 on success, otherwise a negative error value
- * @retval 0 Successful
- * @retval -EINVAL Invalid parameter
- * @retval -EPERM Operation not permitted
- */
-int sensord_set_attribute_str(int handle, int attribute, const char *value, int len);
-
-/**
- * @brief Get the attribute to a connected sensor
- *
- * @param[in] handle a handle represensting a connected sensor.
- * @param[in] attribute an attribute to get value
- * @param[out] value an attribute value, the caller should explicitly free this value
- * @param[out] len the length of value
- * @return 0 on success, otherwise a negative error value
- * @retval 0 Successful
- * @retval -EINVAL Invalid parameter
- * @retval -EPERM Operation not permitted
- */
-int sensord_get_attribute_str(int handle, int attribute, char **value, int *len);
-
-/**
- * @brief Send data to sensorhub
- *
- * @param[in] handle a handle represensting a connected context sensor.
- * @param[in] data it holds data to send to sensorhub
- * @param[in] data_len the length of data
- * @return true on success, otherwise false.
- */
-bool sensord_send_sensorhub_data(int handle, const char *data, int data_len);
-bool sensord_send_command(int handle, const char *command, int command_len);
-
-/**
- * @brief get sensor data from a connected sensor
- *
- * @param[in] handle a handle represensting a connected context sensor.
- * @param[in] data_id it specifies data to get
- * @param[out] sensor_data data from connected sensor
- * @return true on success, otherwise false.
- */
-bool sensord_get_data(int handle, unsigned int data_id, sensor_data_t* sensor_data);
-
-/**
- * @brief get sensor data from a connected sensor
- *
- * @param[in] handle a handle represensting a connected context sensor.
- * @param[in] data_id it specifies data to get
- * @param[out] sensor_data the data list from connected sensor, the caller should explicitly free this list.
- * @param[out] count the count of data contained in the list.
- * @return true on success, otherwise false.
- */
-bool sensord_get_data_list(int handle, unsigned int data_id, sensor_data_t** sensor_data, int* count);
-
-/**
- * @brief flush sensor data from a connected sensor
- *
- * @param[in] handle a handle represensting a connected context sensor.
- * @return true on success, otherwise false.
- */
-bool sensord_flush(int handle);
-
-bool sensord_set_passive_mode(int handle, bool passive);
-
-
-/* Sensor Internal API using URI */
-int sensord_get_default_sensor_by_uri(const char *uri, sensor_t *sensor);
-int sensord_get_sensors_by_uri(const char *uri, sensor_t **list, int *sensor_count);
-
-typedef void (*sensord_added_cb)(const char *uri, void *user_data);
-int sensord_add_sensor_added_cb(sensord_added_cb callback, void *user_data);
-int sensord_remove_sensor_added_cb(sensord_added_cb callback);
-
-typedef void (*sensord_removed_cb)(const char *uri, void *user_data);
-int sensord_add_sensor_removed_cb(sensord_removed_cb callback, void *user_data);
-int sensord_remove_sensor_removed_cb(sensord_removed_cb callback);
-
-/* Sensor provider */
-typedef void *sensord_provider_h;
-int sensord_create_provider(const char *uri, sensord_provider_h *provider);
-int sensord_destroy_provider(sensord_provider_h provider);
-int sensord_add_provider(sensord_provider_h provider);
-int sensord_remove_provider(sensord_provider_h provider);
-
-int sensord_provider_set_name(sensord_provider_h provider, const char *name);
-int sensord_provider_set_vendor(sensord_provider_h provider, const char *vendor);
-int sensord_provider_set_range(sensord_provider_h provider, float min_range, float max_range);
-int sensord_provider_set_resolution(sensord_provider_h provider, float resolution);
-
-typedef void (*sensord_provider_start_cb)(sensord_provider_h provider, void *user_data);
-int sensord_provider_set_start_cb(sensord_provider_h provider, sensord_provider_start_cb callback, void *user_data);
-
-typedef void (*sensord_provider_stop_cb)(sensord_provider_h provider, void *user_data);
-int sensord_provider_set_stop_cb(sensord_provider_h provider, sensord_provider_stop_cb callback, void *user_data);
-
-typedef void (*sensord_provider_interval_changed_cb)(sensord_provider_h provider, unsigned int interval_ms, void *user_data);
-int sensord_provider_set_interval_changed_cb(sensord_provider_h provider, sensord_provider_interval_changed_cb callback, void *user_data);
-
-typedef void (*sensord_provider_attribute_str_cb)(sensord_provider_h provider, int attribute, const char *value, int count, void *user_data);
-int sensord_provider_set_attribute_str_cb(sensord_provider_h provider, sensord_provider_attribute_str_cb callback, void *user_data);
-
-int sensord_provider_publish(sensord_provider_h provider, sensor_data_t data);
-int sensord_provider_publish_events(sensord_provider_h provider, sensor_data_t events[], int count);
-
-/* Deprecated */
-typedef void (*sensor_external_command_cb_t)(int handle, const char* data, int data_cnt, void *user_data);
-int sensord_external_connect(const char *key, sensor_external_command_cb_t cb, void *user_data);
-bool sensord_external_disconnect(int handle);
-bool sensord_external_post(int handle, unsigned long long timestamp, const float* data, int data_cnt);
-
-/**
-  * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __SENSORD_INTERNAL_H__ */
diff --git a/include/sensor_log.h b/include/sensor_log.h
deleted file mode 100644 (file)
index 3904e13..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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_
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#include <dlog/dlog.h>
-#include <sys/types.h>
-
-#ifdef LOG_TAG
-       #undef LOG_TAG
-#endif
-#define LOG_TAG        "TIZEN_SYSTEM_SENSOR"
-
-/* Logging and Error Handling */
-#define _I SLOGI
-#define _D SLOGD
-#define _W SLOGW
-#define _E SLOGE
-#define _SI SECURE_SLOGI
-#define _SD SECURE_SLOGD
-#define _SW SECURE_SLOGW
-#define _SE SECURE_SLOGE
-
-#define _ERRNO(errno, tag, fmt, arg...) \
-       do { \
-               char buf[1024]; \
-               char *error = strerror_r(errno, buf, 1024); \
-               if (!error) { \
-                       _E("Failed to strerror_r()"); \
-                       break; \
-               } \
-               tag(fmt" (%s[%d])", ##arg, error, errno); \
-       } while (0)
-
-#define warn_if(expr, fmt, arg...) \
-       do { if (expr) { _E(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) { _E(fmt, ##arg); return; } } while (0)
-
-#define retvm_if(expr, val, fmt, arg...) \
-       do { if (expr) { _E(fmt, ##arg); return (val); } } while (0)
-
-#define LOG_DUMP(fp, fmt, arg...) \
-       do { if (fp) fprintf(fp, fmt, ##arg); else _E(fmt, ##arg); } while (0)
-
-#define log_oom() ({ \
-       _E("Out of memory"); \
-       -ENOMEM;})
-
-
-#define _MSG_SENSOR_ERROR_IO_ERROR "Io Error"
-#define _MSG_SENSOR_ERROR_INVALID_PARAMETER "Invalid Parameter"
-#define _MSG_SENSOR_ERROR_OUT_OF_MEMORY "Out of Memory"
-#define _MSG_SENSOR_ERROR_NOT_NEED_CALIBRATION "Not need calibration"
-#define _MSG_SENSOR_ERROR_NOT_SUPPORTED "Not supported"
-#define _MSG_SENSOR_ERROR_OPERATION_FAILED "Operation failed"
-
-#define _E_MSG(err) SLOGE(_MSG_##err "(0x%08x)", (err))
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _SENSOR_LOG_H_ */
diff --git a/include/sensor_private.h b/include/sensor_private.h
deleted file mode 100644 (file)
index 7d99272..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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_PRIVATE_H__
-#define __SENSOR_PRIVATE_H__
-
-struct sensor_listener_s {
-       int id;
-       int type;
-       int pause;
-       unsigned int batch_latency;
-       unsigned int magic;
-       void *sensor;
-       void *callback;
-       void *user_data;
-       void *accu_callback;
-       void *accu_user_data;
-};
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-float clamp(float v);
-int getAngleChange(float *R, float *prevR, float *angleChange);
-int quatToMatrix(float *quat, float *R);
-int matrixToQuat(float *mat, float *q);
-int getRotationMatrix(float *accel, float *geo, float *R, float *I);
-int remapCoordinateSystem(float *inR, int X, int Y, float *outR);
-int getDeclination(float *decl);
-int getInclination(float *incl);
-int setCoordinate(float latitude, float longitude, float altitude, float *declination, float *inclination, int option);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // __SENSOR_PRIVATE_H__
diff --git a/include/sensor_types.h b/include/sensor_types.h
deleted file mode 100644 (file)
index a2028d3..0000000
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * sensord
- *
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef __SENSOR_TYPES_H__
-#define __SENSOR_TYPES_H__
-
-/* TODO: It is for compatibility with capi-system-sensor */
-#define __SENSOR_COMMON_H__
-
-#include <stddef.h>
-#include <stdint.h>
-#include <hal/hal-sensor-types.h>
-
-#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)
-
-#define SENSOR_UNKNOWN_TYPE "http://tizen.org/sensor/unknown"
-#define SENSOR_UNKNOWN_NAME "Unknown"
-
-typedef int64_t sensor_id_t;
-typedef void *sensor_t;
-
-typedef enum sensor_type_t {
-       UNKNOWN_SENSOR = -2,
-       ALL_SENSOR = -1,
-       ACCELEROMETER_SENSOR = 0,
-       GRAVITY_SENSOR,
-       LINEAR_ACCEL_SENSOR,
-       GEOMAGNETIC_SENSOR,
-       ROTATION_VECTOR_SENSOR,
-       ORIENTATION_SENSOR,
-       GYROSCOPE_SENSOR,
-       LIGHT_SENSOR,
-       PROXIMITY_SENSOR,
-       PRESSURE_SENSOR,
-       ULTRAVIOLET_SENSOR,
-       TEMPERATURE_SENSOR,
-       HUMIDITY_SENSOR,
-       HRM_SENSOR,
-       BIO_HRM_SENSOR = HRM_SENSOR,
-       HRM_LED_GREEN_SENSOR,
-       BIO_LED_GREEN_SENSOR = HRM_LED_GREEN_SENSOR,
-       HRM_LED_IR_SENSOR,
-       BIO_LED_IR_SENSOR = HRM_LED_IR_SENSOR,
-       HRM_LED_RED_SENSOR,
-       BIO_LED_RED_SENSOR = HRM_LED_RED_SENSOR,
-       GYROSCOPE_UNCAL_SENSOR,
-       GEOMAGNETIC_UNCAL_SENSOR,
-       GYROSCOPE_RV_SENSOR,
-       GEOMAGNETIC_RV_SENSOR,
-
-       GYROSCOPE_ORIENTATION_SENSOR = 100,
-       GEOMAGNETIC_ORIENTATION_SENSOR = 105,
-
-       SIGNIFICANT_MOTION_SENSOR = 0x100, //256
-
-       HRM_BATCH_SENSOR = 0x200, //512
-       HRM_LED_GREEN_BATCH_SENSOR,
-
-       HUMAN_PEDOMETER_SENSOR = 0x300, //768
-       HUMAN_SLEEP_MONITOR_SENSOR,
-       HUMAN_SLEEP_DETECTOR_SENSOR,
-       SLEEP_DETECTOR_SENSOR = HUMAN_SLEEP_DETECTOR_SENSOR,
-       HUMAN_STRESS_MONITOR_SENSOR,
-       STRESS_MONITOR_SENSOR = HUMAN_STRESS_MONITOR_SENSOR,
-
-       LIDAR_SENSOR = 1000,
-
-       EXERCISE_WALKING_SENSOR = 0x400, //1024
-       EXERCISE_RUNNING_SENSOR,
-       EXERCISE_HIKING_SENSOR,
-       EXERCISE_CYCLING_SENSOR,
-       EXERCISE_ELLIPTICAL_SENSOR,
-       EXERCISE_INDOOR_CYCLING_SENSOR,
-       EXERCISE_ROWING_SENSOR,
-       EXERCISE_STEPPER_SENSOR,
-
-       DATA_JOURNAL_SENSOR = 0x500,
-       // 0x500~0x600 Reserved (1280 ~ 1536)
-
-       EXTERNAL_EXERCISE_SENSOR = 0x800, //2048
-       EXERCISE_SENSOR = EXTERNAL_EXERCISE_SENSOR,
-
-       FUSION_SENSOR = 0x900, //2304
-       AUTO_ROTATION_SENSOR,
-       AUTO_BRIGHTNESS_SENSOR,
-       MYOTEST_SENSOR,
-
-       GESTURE_MOVEMENT_SENSOR = 0x1200, //4608
-       GESTURE_WRIST_UP_SENSOR,
-       GESTURE_WRIST_DOWN_SENSOR,
-       GESTURE_MOVEMENT_STATE_SENSOR,
-       GESTURE_PICK_UP_SENSOR,
-       GESTURE_FACE_DOWN_SENSOR,
-
-       ACTIVITY_TRACKER_SENSOR = 0x1A00, //6656
-       ACTIVITY_LEVEL_MONITOR_SENSOR,
-       GPS_BATCH_SENSOR,
-       PPG_BATCH_SENSOR,
-       GPS_TIMESYNC_SENSOR,
-
-       HRM_CTRL_SENSOR = 0x1A80, //6784
-       REG_CTRL_SENSOR,
-       GPS_CTRL_SENSOR,
-
-       WEAR_STATUS_SENSOR = 0x2000, //8192
-       WEAR_ON_MONITOR_SENSOR,
-       NO_MOVE_DETECTOR_SENSOR,
-       RESTING_HR_SENSOR,
-       STEP_LEVEL_MONITOR_SENSOR,
-       EXERCISE_STANDALONE_SENSOR,
-       EXERCISE_COACH_SENSOR = EXERCISE_STANDALONE_SENSOR,
-       EXERCISE_HR_SENSOR,
-       WORKOUT_SENSOR,
-       AUTOSESSION_EXERCISE_SENSOR = WORKOUT_SENSOR,
-       CYCLE_MONITOR_SENSOR,
-       STAIR_TRACKER_SENSOR,
-       PRESSURE_INDICATOR_SENSOR,
-       PRESSURE_ALERT_SENSOR,
-       HR_CALORIE_SENSOR,
-       SWIMMING_TRACKER_SENSOR,
-       STRESS_TRACKER_SENSOR,
-       FAKE_MOTION_SENSOR,
-       GEOFENCE_SENSOR,
-       SWIMMING_OUTDOOR_SENSOR,
-       AUTO_SWIMMING_SENSOR,
-       INACTIVITY_DETECTOR_SENSOR,
-       HRM_BP_SENSOR,
-       ECG_SENSOR,
-       FALL_DETECTION_SENSOR,
-
-       CONTEXT_SENSOR = 0x7000, //28,672
-       MOTION_SENSOR,
-       PIR_SENSOR,
-       PIR_LONG_SENSOR,
-       DUST_SENSOR,
-       THERMOMETER_SENSOR,
-       PEDOMETER_SENSOR,
-       FLAT_SENSOR,
-       HRM_RAW_SENSOR,
-       BIO_SENSOR = HRM_RAW_SENSOR,
-       TILT_SENSOR,
-       RV_RAW_SENSOR,
-       GSR_SENSOR,
-       SIMSENSE_SENSOR,
-       PPG_SENSOR,
-
-       CUSTOM_SENSOR = 0X9000, //36,864
-} sensor_type_t;
-
-typedef struct sensor_info2_t {
-       uint32_t id;
-       sensor_type_t type;
-       const char *uri;
-       const char *vendor;
-       float min_range;
-       float max_range;
-       float resolution;
-       int min_interval;
-       int max_interval;
-       int max_batch_count;
-       bool wakeup_supported;
-       const char *privilege;
-       void *reserved[8];
-} sensor_info2_t;
-
-typedef enum sensor_privilege_t {
-       SENSOR_PRIVILEGE_PUBLIC = 0,
-} 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,
-       // 0x50~0x80 Reserved
-};
-
-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,
-};
-
-#define DEFAULT_INTERVAL POLL_10HZ_MS
-
-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,
-};
-
-enum auto_rotation_state {
-       AUTO_ROTATION_DEGREE_UNKNOWN = 0,
-       AUTO_ROTATION_DEGREE_0,
-       AUTO_ROTATION_DEGREE_90,
-       AUTO_ROTATION_DEGREE_180,
-       AUTO_ROTATION_DEGREE_270,
-};
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __SENSOR_TYPES_H__ */
index 514b95ff5833e71fb877806d469564db21563d17..8e764f109a3ffe75dbe3711be29defb0b39037d6 100644 (file)
  * limitations under the License.
  */
 
-#include <sensor-internal.h>
-
 #include <errno.h>
+
+#include <sensor-internal.h>
 #include <sensor.h>
-#include <sensor_internal.h>
+#include <sensor-types.h>
+#include <sensor_types_private.h>
+#include <sensor_utils.h>
+#include <channel_handler.h>
+#include <sensor_manager.h>
+#include <sensor_listener.h>
+#include <sensor_provider_internal.h>
+#include <sensor-log.h>
+#include <cmutex.h>
+#include <command_types.h>
+#include "sensor_reader.h"
+
+#include <unordered_map>
+#include <regex>
+#include <thread>
+
+#define CONVERT_OPTION_TO_PAUSE_POLICY(option) ((option) ^ 0b11)
+#define MAX_LISTENER 100
+#define MAX_PROVIDER 20
+
+using namespace sensor;
+
+typedef struct {
+       int listener_id;
+       sensor_info *sensor;
+       void* cb;
+       char* data;
+       size_t data_size;
+       void *user_data;
+} callback_info_s;
+
+typedef GSourceFunc callback_dispatcher_t;
+
+static sensor::sensor_manager manager;
+static std::unordered_map<int, sensor::sensor_listener *> listeners;
+static cmutex lock;
+static uint providerCnt = 0;
+
+static gboolean sensor_events_callback_dispatcher(gpointer data)
+{
+       int event_type = 0;
+       callback_info_s *info = (callback_info_s *)data;
+
+       AUTOLOCK(lock);
+
+       if (info->sensor)
+               event_type = CONVERT_TYPE_EVENT(info->sensor->get_type());
+
+       if (info->cb && info->sensor && listeners.find(info->listener_id) != listeners.end()) {
+               size_t element_size =  sizeof(sensor_data_t);
+               size_t count = info->data_size / element_size;
+               ((sensor_events_cb_t)info->cb)(info->sensor, event_type, (sensor_data_t*)info->data, count, info->user_data);
+       }
+
+       delete [] info->data;
+       delete info;
+       return FALSE;
+}
+
+static gboolean sensor_event_callback_dispatcher(gpointer data)
+{
+       int event_type = 0;
+       callback_info_s *info = (callback_info_s *)data;
+
+       AUTOLOCK(lock);
+
+       if (info->sensor)
+               event_type = CONVERT_TYPE_EVENT(info->sensor->get_type());
+
+       if (info->cb && info->sensor && listeners.find(info->listener_id) != listeners.end()) {
+               ((sensor_cb_t)info->cb)(info->sensor, event_type, (sensor_data_t*)info->data, info->user_data);
+       }
+
+       delete [] info->data;
+       delete info;
+       return FALSE;
+}
+
+static gboolean sensor_accuracy_changed_callback_dispatcher(gpointer data)
+{
+       callback_info_s *info = (callback_info_s *)data;
+
+       AUTOLOCK(lock);
+
+       if (info->cb && info->sensor && listeners.find(info->listener_id) != listeners.end()) {
+               sensor_data_t * sensor_data = (sensor_data_t *)info->data;
+               ((sensor_accuracy_changed_cb_t)info->cb)(info->sensor, sensor_data->timestamp, sensor_data->accuracy, info->user_data);
+       }
+
+       delete [] info->data;
+       delete info;
+       return FALSE;
+}
+
+static gboolean sensor_attribute_int_changed_callback_dispatcher(gpointer data)
+{
+       callback_info_s *info = (callback_info_s *)data;
+
+       AUTOLOCK(lock);
+
+       if (info->cb && info->sensor && listeners.find(info->listener_id) != listeners.end()) {
+               cmd_listener_attr_int_t *d = (cmd_listener_attr_int_t *)info->data;
+               ((sensor_attribute_int_changed_cb_t)info->cb)(info->sensor, d->attribute, d->value, info->user_data);
+       }
+
+       delete [] info->data;
+       delete info;
+       return FALSE;
+}
+
+static gboolean sensor_attribute_str_changed_callback_dispatcher(gpointer data)
+{
+       callback_info_s *info = (callback_info_s *)data;
+
+       AUTOLOCK(lock);
+
+       if (info->cb && info->sensor && listeners.find(info->listener_id) != listeners.end()) {
+               cmd_listener_attr_str_t *d = (cmd_listener_attr_str_t *)info->data;
+               ((sensor_attribute_str_changed_cb_t)info->cb)(info->sensor, d->attribute, d->value, d->len, info->user_data);
+       }
+
+       delete [] info->data;
+       delete info;
+       return FALSE;
+}
+
+class sensor_listener_channel_handler : public ipc::channel_handler
+{
+public:
+       sensor_listener_channel_handler(int id, sensor_t sensor, void* cb, void *user_data, callback_dispatcher_t dispatcher)
+       : m_listener_id(id)
+       , m_sensor(reinterpret_cast<sensor_info *>(sensor))
+       , m_cb(cb)
+       , m_user_data(user_data)
+       , m_dispatcher(dispatcher)
+       {}
+
+       void connected(ipc::channel *ch) {}
+       void disconnected(ipc::channel *ch) {}
+       void read(ipc::channel *ch, ipc::message &msg)
+       {
+               callback_info_s *info;
+               auto size = msg.size();
+               char *data = new(std::nothrow) char[size];
+               if (data == NULL)
+                       return;
+               memcpy(data, msg.body(), size);
+
+               info = new(std::nothrow) callback_info_s();
+               info->listener_id = m_listener_id;
+               info->cb = m_cb;
+               info->sensor = m_sensor;
+               info->data = data;
+               info->data_size = size;
+               info->user_data = m_user_data;
+
+               g_idle_add(m_dispatcher, info);
+       }
+
+       void read_complete(ipc::channel *ch) {}
+       void error_caught(ipc::channel *ch, int error) {}
+       void set_handler(int num, ipc::channel_handler* handler) {}
+       void disconnect(void) {}
+
+private:
+       int m_listener_id;
+       sensor_info *m_sensor;
+       void* m_cb;
+       void *m_user_data;
+       callback_dispatcher_t m_dispatcher;
+};
+
+/*
+ * TO-DO-LIST:
+ * 1. power save option / lcd vconf : move to server
+ * 2. thread-safe : ipc_client
+ */
+
+API int sensord_get_sensors(sensor_type_t type, sensor_t **list, int *count)
+{
+       return sensord_get_sensors_by_uri(utils::get_uri(type), list, count);
+}
+
+API int sensord_get_default_sensor(sensor_type_t type, sensor_t *sensor)
+{
+       return sensord_get_default_sensor_by_uri(utils::get_uri(type), sensor);
+}
+
+API bool sensord_get_type(sensor_t sensor, sensor_type_t *type)
+{
+       retvm_if(!type, false, "Invalid type");
+       retvm_if(!manager.connect(), false, "Failed to connect");
+       retvm_if(!manager.is_supported(sensor), false,
+                       "Invalid sensor[%p]", sensor);
+
+       *type = static_cast<sensor_info *>(sensor)->get_type();
+
+       return true;
+}
+
+API const char* sensord_get_uri(sensor_t sensor)
+{
+       retvm_if(!manager.connect(), NULL, "Failed to connect");
+       retvm_if(!manager.is_supported(sensor), NULL,
+                       "Invalid sensor[%p]", sensor);
+
+       return static_cast<sensor_info *>(sensor)->get_uri().c_str();
+}
+
+API const char* sensord_get_name(sensor_t sensor)
+{
+       retvm_if(!manager.connect(), NULL, "Failed to connect");
+       retvm_if(!manager.is_supported(sensor), NULL,
+                       "Invalid sensor[%p]", sensor);
+
+       return static_cast<sensor_info *>(sensor)->get_model().c_str();
+}
+
+API const char* sensord_get_vendor(sensor_t sensor)
+{
+       retvm_if(!manager.connect(), NULL, "Failed to connect");
+       retvm_if(!manager.is_supported(sensor), NULL,
+                       "Invalid sensor[%p]", sensor);
+
+       return static_cast<sensor_info *>(sensor)->get_vendor().c_str();
+}
+
+API bool sensord_get_min_range(sensor_t sensor, float *min_range)
+{
+       retvm_if(!min_range, false, "Invalid paramter");
+       retvm_if(!manager.connect(), false, "Failed to connect");
+       retvm_if(!manager.is_supported(sensor), false,
+                       "Invalid sensor[%p]", sensor);
+
+       *min_range = static_cast<sensor_info *>(sensor)->get_min_range();
+
+       return true;
+}
+
+API bool sensord_get_max_range(sensor_t sensor, float *max_range)
+{
+       retvm_if(!max_range, false, "Invalid parameter");
+       retvm_if(!manager.connect(), false, "Failed to connect");
+       retvm_if(!manager.is_supported(sensor), false,
+                       "Invalid sensor[%p]", sensor);
+
+       *max_range = static_cast<sensor_info *>(sensor)->get_max_range();
+
+       return true;
+}
+
+API bool sensord_get_resolution(sensor_t sensor, float *resolution)
+{
+       retvm_if(!resolution, false, "Invalid parameter");
+       retvm_if(!manager.connect(), false, "Failed to connect");
+       retvm_if(!manager.is_supported(sensor), false,
+                       "Invalid sensor[%p]", sensor);
+
+       *resolution = static_cast<sensor_info *>(sensor)->get_resolution();
+
+       return true;
+}
+
+API bool sensord_get_min_interval(sensor_t sensor, int *min_interval)
+{
+       retvm_if(!min_interval, false, "Invalid parameter");
+       retvm_if(!manager.connect(), false, "Failed to connect");
+       retvm_if(!manager.is_supported(sensor), false,
+                       "Invalid sensor[%p]", sensor);
+
+       *min_interval = static_cast<sensor_info *>(sensor)->get_min_interval();
+
+       return true;
+}
+
+API bool sensord_get_fifo_count(sensor_t sensor, int *fifo_count)
+{
+       retvm_if(!fifo_count, false, "Invalid parameter");
+       retvm_if(!manager.connect(), false, "Failed to connect");
+       retvm_if(!manager.is_supported(sensor), false,
+                       "Invalid sensor[%p]", sensor);
+
+       *fifo_count = 0;
+
+       return true;
+}
+
+API bool sensord_get_max_batch_count(sensor_t sensor, int *max_batch_count)
+{
+       retvm_if(!max_batch_count, false, "Invalid parameter");
+       retvm_if(!manager.connect(), false, "Failed to connect");
+       retvm_if(!manager.is_supported(sensor), false,
+                       "Invalid sensor[%p]", sensor);
+
+       *max_batch_count = static_cast<sensor_info *>(sensor)->get_max_batch_count();
+
+       return true;
+}
+
+API bool sensord_is_wakeup_supported(sensor_t sensor)
+{
+       retvm_if(!manager.connect(), false, "Failed to connect");
+       retvm_if(!manager.is_supported(sensor), false,
+                       "Invalid sensor[%p]", sensor);
+
+       return static_cast<sensor_info *>(sensor)->is_wakeup_supported();
+}
+
+API int sensord_connect(sensor_t sensor)
+{
+       AUTOLOCK(lock);
+
+       retvm_if(!manager.connect(), -EIO, "Failed to connect");
+       retvm_if(!manager.is_supported(sensor), -EINVAL,
+                       "Invalid sensor[%p]", sensor);
+       retvm_if(listeners.size() > MAX_LISTENER, -EPERM, "Exceeded the maximum listener");
+
+       sensor::sensor_listener *listener;
+       static sensor_reader reader;
+
+       listener = new(std::nothrow) sensor::sensor_listener(sensor, reader.get_event_loop());
+       retvm_if(!listener, -ENOMEM, "Failed to allocate memory");
+
+       listeners[listener->get_id()] = listener;
+
+       _D("Connect[%d]", listener->get_id());
+
+       return listener->get_id();
+}
+
+API bool sensord_disconnect(int handle)
+{
+       sensor::sensor_listener *listener;
+
+       AUTOLOCK(lock);
+
+       auto it = listeners.find(handle);
+       retvm_if(it == listeners.end(), false, "Invalid handle[%d]", handle);
+
+       listener = it->second;
+       retvm_if(!listener, false, "Invalid handle[%d]", handle);
+
+       _D("Disconnect[%d]", listener->get_id());
+
+       delete listener;
+       listeners.erase(handle);
+
+       if (listeners.empty())
+               manager.disconnect();
+
+       return true;
+}
+
+static inline bool sensord_register_event_impl(int handle, unsigned int event_type,
+               unsigned int interval, unsigned int max_batch_latency, void* cb, bool is_events_callback, void *user_data)
+{
+       sensor::sensor_listener *listener;
+       int prev_interval;
+       int prev_max_batch_latency;
+       sensor_listener_channel_handler *handler;
+
+       AUTOLOCK(lock);
+
+       auto it = listeners.find(handle);
+       retvm_if(it == listeners.end(), false, "Invalid handle[%d]", handle);
+
+       listener = it->second;
+
+       prev_interval = listener->get_interval();
+       prev_max_batch_latency = listener->get_max_batch_latency();
+
+       if (listener->set_interval(interval) < 0) {
+               _E("Failed to set interval");
+               return false;
+       }
+
+       if (listener->set_max_batch_latency(max_batch_latency) < 0) {
+               listener->set_interval(prev_interval);
+               _E("Failed to set max_batch_latency");
+               return false;
+       }
+
+       if (is_events_callback) {
+               handler = new(std::nothrow)sensor_listener_channel_handler(handle, listener->get_sensor(), (void *)cb, user_data, sensor_events_callback_dispatcher);
+       } else {
+               handler = new(std::nothrow)sensor_listener_channel_handler(handle, listener->get_sensor(), (void *)cb, user_data, sensor_event_callback_dispatcher);
+       }
+
+       if (!handler) {
+               listener->set_max_batch_latency(prev_max_batch_latency);
+               listener->set_interval(prev_interval);
+               _E("Failed to allocate memory");
+               return false;
+       }
+
+       listener->set_event_handler(handler);
+
+       _D("Register event[%d]", listener->get_id());
+
+       return true;
+}
+
+API bool sensord_register_event(int handle, unsigned int event_type,
+               unsigned int interval, unsigned int max_batch_latency, sensor_cb_t cb, void *user_data)
+{
+       return sensord_register_event_impl(handle, event_type, interval, max_batch_latency, (void*)cb, false, user_data);
+}
+
+static inline bool sensord_unregister_event_imple(int handle)
+{
+       sensor::sensor_listener *listener;
+
+       AUTOLOCK(lock);
+
+       auto it = listeners.find(handle);
+       retvm_if(it == listeners.end(), false, "Invalid handle[%d]", handle);
+
+       listener = it->second;
+
+       listener->unset_event_handler();
+
+       _D("Unregister event[%d]", listener->get_id());
+
+       return true;
+}
+
+API bool sensord_unregister_event(int handle, unsigned int event_type)
+{
+       return sensord_unregister_event_imple(handle);
+}
+
+API bool sensord_register_events(int handle, unsigned int event_type, unsigned int max_batch_latency, sensor_events_cb_t cb, void *user_data)
+{
+       return sensord_register_event_impl(handle, event_type, 0, max_batch_latency, (void*)cb, true, user_data);
+}
+
+API bool sensord_unregister_events(int handle, unsigned int event_type)
+{
+       return sensord_unregister_event_imple(handle);
+}
+
+API bool sensord_register_accuracy_cb(int handle, sensor_accuracy_changed_cb_t cb, void *user_data)
+{
+       sensor::sensor_listener *listener;
+       sensor_listener_channel_handler *handler;
+
+       AUTOLOCK(lock);
+
+       auto it = listeners.find(handle);
+       retvm_if(it == listeners.end(), false, "Invalid handle[%d]", handle);
+
+       listener = it->second;
+
+       handler = new(std::nothrow) sensor_listener_channel_handler(handle, listener->get_sensor(), (void *)cb, user_data, sensor_accuracy_changed_callback_dispatcher);
+       retvm_if(!handler, false, "Failed to allocate memory");
+
+       listener->set_accuracy_handler(handler);
+
+       return true;
+}
+
+API bool sensord_unregister_accuracy_cb(int handle)
+{
+       sensor::sensor_listener *listener;
+
+       AUTOLOCK(lock);
+
+       auto it = listeners.find(handle);
+       retvm_if(it == listeners.end(), false, "Invalid handle[%d]", handle);
+
+       listener = it->second;
+
+       listener->unset_accuracy_handler();
+
+       return true;
+}
+
+API bool sensord_register_attribute_int_changed_cb(int handle, sensor_attribute_int_changed_cb_t cb, void *user_data)
+{
+       sensor::sensor_listener *listener;
+       sensor_listener_channel_handler *handler;
+
+       AUTOLOCK(lock);
+
+       auto it = listeners.find(handle);
+       retvm_if(it == listeners.end(), false, "Invalid handle[%d]", handle);
+
+       listener = it->second;
+
+       handler = new(std::nothrow) sensor_listener_channel_handler(handle, listener->get_sensor(), (void *)cb, user_data, sensor_attribute_int_changed_callback_dispatcher);
+       retvm_if(!handler, false, "Failed to allocate memory");
+
+       listener->set_attribute_int_changed_handler(handler);
+
+       return true;
+}
+
+API bool sensord_unregister_attribute_int_changed_cb(int handle)
+{
+       sensor::sensor_listener *listener;
+
+       AUTOLOCK(lock);
+
+       auto it = listeners.find(handle);
+       retvm_if(it == listeners.end(), false, "Invalid handle[%d]", handle);
+
+       listener = it->second;
+
+       listener->unset_attribute_int_changed_handler();
+
+       return true;
+}
+
+API bool sensord_register_attribute_str_changed_cb(int handle, sensor_attribute_str_changed_cb_t cb, void *user_data)
+{
+       sensor::sensor_listener *listener;
+       sensor_listener_channel_handler *handler;
+
+       AUTOLOCK(lock);
+
+       auto it = listeners.find(handle);
+       retvm_if(it == listeners.end(), false, "Invalid handle[%d]", handle);
+
+       listener = it->second;
+
+       handler = new(std::nothrow) sensor_listener_channel_handler(handle, listener->get_sensor(), (void *)cb, user_data, sensor_attribute_str_changed_callback_dispatcher);
+       retvm_if(!handler, false, "Failed to allocate memory");
+
+       listener->set_attribute_str_changed_handler(handler);
+
+       return true;
+}
+
+API bool sensord_unregister_attribute_str_changed_cb(int handle)
+{
+       sensor::sensor_listener *listener;
+
+       AUTOLOCK(lock);
+
+       auto it = listeners.find(handle);
+       retvm_if(it == listeners.end(), false, "Invalid handle[%d]", handle);
+
+       listener = it->second;
+
+       listener->unset_attribute_str_changed_handler();
+
+       return true;
+}
+
+API bool sensord_start(int handle, int option)
+{
+       sensor::sensor_listener *listener;
+       int prev_pause;
+       int pause;
+       int interval, batch_latency;
+
+       AUTOLOCK(lock);
+
+       auto it = listeners.find(handle);
+       retvm_if(it == listeners.end(), false, "Invalid handle[%d]", handle);
+
+       listener = it->second;
+
+       pause = CONVERT_OPTION_TO_PAUSE_POLICY(option);
+       prev_pause = listener->get_pause_policy();
+
+       if (listener->set_attribute(SENSORD_ATTRIBUTE_PAUSE_POLICY, pause) < 0) {
+               _E("Failed to set pause policy[%d]", pause);
+               return false;
+       }
+
+       if (listener->start() < 0) {
+               listener->set_attribute(SENSORD_ATTRIBUTE_PAUSE_POLICY, prev_pause);
+               _E("Failed to start listener");
+               return false;
+       }
+
+       interval = listener->get_interval();
+       if (interval > 0)
+               listener->set_interval(interval);
+
+       batch_latency = listener->get_max_batch_latency();
+       if (batch_latency != SENSOR_BATCH_LATENCY_DEFAULT)
+               listener->set_max_batch_latency(batch_latency);
+
+       _D("Start[%d] with the interval[%d] batch_latency[%d]",
+               listener->get_id(), interval, batch_latency);
+
+       return true;
+}
+
+API bool sensord_stop(int handle)
+{
+       int ret;
+       sensor::sensor_listener *listener;
+
+       AUTOLOCK(lock);
+
+       auto it = listeners.find(handle);
+       retvm_if(it == listeners.end(), false, "Invalid handle[%d]", handle);
+
+       listener = it->second;
+
+       ret = listener->stop();
+
+       if (ret == -EAGAIN || ret == OP_SUCCESS)
+               return true;
+
+       _D("Stop[%d]", listener->get_id());
+
+       return false;
+}
+
+API bool sensord_change_event_interval(int handle, unsigned int event_type, unsigned int interval)
+{
+       sensor::sensor_listener *listener;
+
+       AUTOLOCK(lock);
+
+       auto it = listeners.find(handle);
+       retvm_if(it == listeners.end(), false, "Invalid handle[%d]", handle);
+
+       listener = it->second;
+
+       if (listener->set_interval(interval) < 0) {
+               _E("Failed to set interval to listener");
+               return false;
+       }
+
+       _D("Set interval[%d, %d]", listener->get_id(), interval);
+
+       return true;
+}
+
+API bool sensord_change_event_max_batch_latency(int handle, unsigned int event_type, unsigned int max_batch_latency)
+{
+       sensor::sensor_listener *listener;
+
+       AUTOLOCK(lock);
+
+       auto it = listeners.find(handle);
+       retvm_if(it == listeners.end(), false, "Invalid handle[%d]", handle);
+
+       listener = it->second;
+
+       if (listener->set_max_batch_latency(max_batch_latency) < 0) {
+               _E("Failed to set max_batch_latency to listener");
+               return false;
+       }
+
+       _D("Set max batch latency[%d, %u]", listener->get_id(), max_batch_latency);
+
+       return true;
+}
+
+API bool sensord_set_option(int handle, int option)
+{
+       sensor::sensor_listener *listener;
+       int pause;
+
+       AUTOLOCK(lock);
+
+       auto it = listeners.find(handle);
+       retvm_if(it == listeners.end(), false, "Invalid handle[%d]", handle);
+
+       listener = it->second;
+
+       pause = CONVERT_OPTION_TO_PAUSE_POLICY(option);
+
+       if (listener->set_attribute(SENSORD_ATTRIBUTE_PAUSE_POLICY, pause) < 0) {
+               _E("Failed to set option[%d(%d)] to listener", option, pause);
+               return false;
+       }
+
+       _D("Set pause option[%d, %d]", listener->get_id(), pause);
+
+       return true;
+}
+
+API int sensord_set_attribute_int(int handle, int attribute, int value)
+{
+       sensor::sensor_listener *listener;
+
+       auto it = listeners.find(handle);
+       retvm_if(it == listeners.end(), -EINVAL, "Invalid handle[%d]", handle);
+
+       listener = it->second;
+
+       if (listener->set_attribute(attribute, value) < 0) {
+               _E("Failed to set attribute[%d, %d]", attribute, value);
+               return -EIO;
+       }
+
+       _D("Set attribute[%d, %d, %d]", listener->get_id(), attribute, value);
+
+       return OP_SUCCESS;
+}
+
+API int sensord_get_attribute_int(int handle, int attribute, int* value)
+{
+       sensor::sensor_listener *listener;
+
+       auto it = listeners.find(handle);
+       retvm_if(it == listeners.end(), -EINVAL, "Invalid handle[%d]", handle);
+
+       listener = it->second;
+
+       if (listener->get_attribute(attribute, value) < 0) {
+               _E("Failed to get attribute[%d]", attribute);
+               return -EIO;
+       }
+
+       _D("Get attribute[%d, %d, %d]", listener->get_id(), attribute, *value);
+
+       return OP_SUCCESS;
+}
+
+API int sensord_set_attribute_str(int handle, int attribute, const char *value, int len)
+{
+       sensor::sensor_listener *listener;
+
+       auto it = listeners.find(handle);
+       retvm_if(it == listeners.end(), -EINVAL, "Invalid handle[%d]", handle);
+
+       listener = it->second;
+
+       if (listener->set_attribute(attribute, value, len) < 0) {
+               _E("Failed to set attribute[%d, %s]", attribute, value);
+               return -EIO;
+       }
+       _D("Set attribute ID[%d], attr[%d], len[%d]", listener->get_id(), attribute, len);
+
+       return OP_SUCCESS;
+}
+
+API int sensord_get_attribute_str(int handle, int attribute, char **value, int* len)
+{
+       sensor::sensor_listener *listener;
+
+       auto it = listeners.find(handle);
+       retvm_if(it == listeners.end(), -EINVAL, "Invalid handle[%d]", handle);
+
+       listener = it->second;
+
+       if (listener->get_attribute(attribute, value, len) < 0) {
+               _E("Failed to get attribute[%d]", attribute);
+               return -EIO;
+       }
+       _D("Get attribute ID[%d], attr[%d], len[%d]", listener->get_id(), attribute, *len);
+
+       return OP_SUCCESS;
+}
+
+API bool sensord_get_data(int handle, unsigned int data_id, sensor_data_t* sensor_data)
+{
+       sensor::sensor_listener *listener;
+
+       AUTOLOCK(lock);
+
+       auto it = listeners.find(handle);
+       retvm_if(it == listeners.end(), false, "Invalid handle[%d]", handle);
+
+       listener = it->second;
+
+       if (listener->get_sensor_data(sensor_data) < 0) {
+               _E("Failed to get sensor data from listener");
+               return false;
+       }
+
+       return true;
+}
+
+API bool sensord_get_data_list(int handle, unsigned int data_id, sensor_data_t** sensor_data, int* count)
+{
+       sensor::sensor_listener *listener;
+
+       AUTOLOCK(lock);
+
+       auto it = listeners.find(handle);
+       retvm_if(it == listeners.end(), false, "Invalid handle[%d]", handle);
+
+       listener = it->second;
+
+       if (listener->get_sensor_data_list(sensor_data, count) < 0) {
+               _E("Failed to get sensor data from listener");
+               return false;
+       }
+
+       return true;
+}
+
+API bool sensord_flush(int handle)
+{
+       sensor::sensor_listener *listener;
+
+       AUTOLOCK(lock);
+
+       auto it = listeners.find(handle);
+       retvm_if(it == listeners.end(), false, "Invalid handle[%d]", handle);
+
+       listener = it->second;
+
+       if (listener->flush() < 0) {
+               _E("Failed to flush sensor");
+               return false;
+       }
+
+       return true;
+}
+
+API bool sensord_set_passive_mode(int handle, bool passive)
+{
+       sensor::sensor_listener *listener;
+
+       AUTOLOCK(lock);
+
+       auto it = listeners.find(handle);
+       retvm_if(it == listeners.end(), false, "Invalid handle[%d]", handle);
+
+       listener = it->second;
+
+       if (listener->set_passive_mode(passive) < 0) {
+               _E("Failed to set passive mode");
+               return false;
+       }
+
+       return true;
+}
+
+/* Sensor Internal API using URI */
+API int sensord_get_default_sensor_by_uri(const char *uri, sensor_t *sensor)
+{
+       retvm_if(!sensor, -EINVAL, "Invalid parameter");
+       retvm_if(!manager.connect(), -EIO, "Failed to connect");
+
+       return manager.get_sensor(uri, sensor);
+}
+
+API int sensord_get_sensors_by_uri(const char *uri, sensor_t **list, int *count)
+{
+       retvm_if((!list || !count), -EINVAL, "Invalid parameter");
+       retvm_if(!manager.connect(), -EIO, "Failed to connect");
+
+       return manager.get_sensors(uri, list, count);
+}
+
+API int sensord_add_sensor_added_cb(sensord_added_cb callback, void *user_data)
+{
+       retvm_if(!callback, -EINVAL, "Invalid paramter");
+       retvm_if(!manager.connect(), -EIO, "Failed to connect");
+
+       manager.add_sensor_added_cb(callback, user_data);
+       return OP_SUCCESS;
+}
+
+API int sensord_remove_sensor_added_cb(sensord_added_cb callback)
+{
+       retvm_if(!callback, -EINVAL, "Invalid paramter");
+       retvm_if(!manager.connect(), -EIO, "Failed to connect");
+
+       manager.remove_sensor_added_cb(callback);
+       return OP_SUCCESS;
+}
+
+API int sensord_add_sensor_removed_cb(sensord_removed_cb callback, void *user_data)
+{
+       retvm_if(!callback, -EINVAL, "Invalid paramter");
+       retvm_if(!manager.connect(), -EIO, "Failed to connect");
+
+       manager.add_sensor_removed_cb(callback, user_data);
+       return OP_SUCCESS;
+}
+
+API int sensord_remove_sensor_removed_cb(sensord_removed_cb callback)
+{
+       retvm_if(!callback, -EINVAL, "Invalid paramter");
+       retvm_if(!manager.connect(), -EIO, "Failed to connect");
+
+       manager.remove_sensor_removed_cb(callback);
+       return OP_SUCCESS;
+}
+
+/* Sensor provider */
+API int sensord_create_provider(const char *uri, sensord_provider_h *provider)
+{
+       retvm_if(providerCnt >= MAX_PROVIDER, -EPERM, "Exceeded the maximum provider");
+       retvm_if(!provider, -EINVAL, "Invalid paramter");
+
+       std::string str_uri(uri);
+       retvm_if(str_uri.find(PREDEFINED_TYPE_URI) != std::string::npos,
+                       -EINVAL, "Invalid URI format[%s]", uri);
+
+       static std::regex uri_regex(SENSOR_URI_REGEX, std::regex::optimize);
+       retvm_if(!std::regex_match(uri, uri_regex),
+                       -EINVAL, "Invalid URI format[%s]", uri);
+
+       sensor_provider *p;
+
+       p = new(std::nothrow) sensor_provider(uri);
+       retvm_if(!p, -ENOMEM, "Failed to allocate memory");
+
+       *provider = static_cast<sensord_provider_h>(p);
+       providerCnt++;
+       return OP_SUCCESS;
+}
+
+API int sensord_destroy_provider(sensord_provider_h provider)
+{
+       retvm_if(!provider, -EINVAL, "Invalid paramter");
+
+       delete static_cast<sensor::sensor_provider *>(provider);
+       providerCnt--;
+       return OP_SUCCESS;
+}
+
+API int sensord_add_provider(sensord_provider_h provider)
+{
+       retvm_if(!provider, -EINVAL, "Invalid paramter");
+       retvm_if(!manager.connect(), -EIO, "Failed to connect");
+
+       int ret;
+       sensor_provider *p = static_cast<sensor_provider *>(provider);
+
+       ret = p->connect();
+       retv_if(ret < 0, ret);
+
+       ret = manager.add_sensor(p);
+       if (ret < 0) {
+               p->disconnect();
+               return ret;
+       }
+
+       return OP_SUCCESS;
+}
+
+API int sensord_remove_provider(sensord_provider_h provider)
+{
+       retvm_if(!provider, -EINVAL, "Invalid paramter");
+       retvm_if(!manager.connect(), -EIO, "Failed to connect");
+
+       int ret;
+       sensor_provider *p = static_cast<sensor_provider *>(provider);
+
+       if (!p->disconnect())
+               return OP_ERROR;
+
+       ret = manager.remove_sensor(p);
+       if (ret < 0) {
+               p->connect();
+               return OP_ERROR;
+       }
+
+       return OP_SUCCESS;
+}
+
+API int sensord_provider_set_name(sensord_provider_h provider, const char *name)
+{
+       retvm_if(!provider, -EINVAL, "Invalid paramter");
+
+       sensor_provider *p = static_cast<sensor_provider *>(provider);
+
+       sensor_info *info = p->get_sensor_info();
+       info->set_model(name);
+
+       return OP_SUCCESS;
+}
+
+API int sensord_provider_set_vendor(sensord_provider_h provider, const char *vendor)
+{
+       retvm_if(!provider, -EINVAL, "Invalid paramter");
+
+       sensor_provider *p = static_cast<sensor_provider *>(provider);
+
+       sensor_info *info = p->get_sensor_info();
+       info->set_vendor(vendor);
+
+       return OP_SUCCESS;
+}
+
+API int sensord_provider_set_range(sensord_provider_h provider, float min_range, float max_range)
+{
+       retvm_if(!provider, -EINVAL, "Invalid paramter");
+
+       sensor_provider *p = static_cast<sensor_provider *>(provider);
+
+       sensor_info *info = p->get_sensor_info();
+       info->set_min_range(min_range);
+       info->set_max_range(max_range);
+
+       return OP_SUCCESS;
+}
+
+API int sensord_provider_set_resolution(sensord_provider_h provider, float resolution)
+{
+       retvm_if(!provider, -EINVAL, "Invalid paramter");
+
+       sensor_provider *p = static_cast<sensor_provider *>(provider);
+
+       sensor_info *info = p->get_sensor_info();
+       info->set_resolution(resolution);
+
+       return OP_SUCCESS;
+}
+
+API int sensord_provider_set_start_cb(sensord_provider_h provider, sensord_provider_start_cb callback, void *user_data)
+{
+       retvm_if(!provider, -EINVAL, "Invalid paramter");
+       retvm_if(!callback, -EINVAL, "Invalid paramter");
+
+       sensor_provider *p = static_cast<sensor_provider *>(provider);
+
+       p->set_start_cb(callback, user_data);
+
+       return OP_SUCCESS;
+}
+
+API int sensord_provider_set_stop_cb(sensord_provider_h provider, sensord_provider_stop_cb callback, void *user_data)
+{
+       retvm_if(!provider, -EINVAL, "Invalid paramter");
+       retvm_if(!callback, -EINVAL, "Invalid paramter");
+
+       sensor_provider *p = static_cast<sensor_provider *>(provider);
+
+       p->set_stop_cb(callback, user_data);
+
+       return OP_SUCCESS;
+}
+
+API int sensord_provider_set_interval_changed_cb(sensord_provider_h provider, sensord_provider_interval_changed_cb callback, void *user_data)
+{
+       retvm_if(!provider, -EINVAL, "Invalid paramter");
+       retvm_if(!callback, -EINVAL, "Invalid paramter");
+
+       sensor_provider *p = static_cast<sensor_provider *>(provider);
+
+       p->set_interval_cb(callback, user_data);
+
+       return OP_SUCCESS;
+}
+
+API int sensord_provider_set_attribute_str_cb(sensord_provider_h provider, sensord_provider_attribute_str_cb callback, void *user_data)
+{
+       retvm_if(!provider, -EINVAL, "Invalid paramter");
+       retvm_if(!callback, -EINVAL, "Invalid paramter");
+
+       sensor_provider *p = static_cast<sensor_provider *>(provider);
+
+       p->set_attribute_str_cb(callback, user_data);
+
+       return OP_SUCCESS;
+}
+
+API int sensord_provider_publish(sensord_provider_h provider, sensor_data_t data)
+{
+       retvm_if(!provider, -EINVAL, "Invalid paramter");
+
+       sensor_provider *p = static_cast<sensor_provider *>(provider);
+
+       /* TODO: synchronous call is enough? */
+       return p->publish(data);
+}
+
+API int sensord_provider_publish_events(sensord_provider_h provider, sensor_data_t events[], int count)
+{
+       retvm_if(!provider, -EINVAL, "Invalid paramter");
+
+       sensor_provider *p = static_cast<sensor_provider *>(provider);
+
+       return p->publish(events, count);
+};
+
+/* deperecated */
+API sensor_t sensord_get_sensor(sensor_type_t type)
+{
+       sensor_t sensor;
+
+       if (sensord_get_default_sensor(type, &sensor) < 0)
+               return NULL;
+
+       return sensor;
+}
+
+/* deprecated */
+API bool sensord_get_sensor_list(sensor_type_t type, sensor_t **list, int *sensor_count)
+{
+       return (sensord_get_sensors(type, list, sensor_count) == OP_SUCCESS);
+}
+
+/* deprecated */
+API bool sensord_register_hub_event(int handle, unsigned int event_type,
+               unsigned int interval, unsigned int max_batch_latency, sensorhub_cb_t cb, void *user_data)
+{
+       return false;
+}
+
+/* deprecated */
+API bool sensord_get_supported_event_types(sensor_t sensor, unsigned int **event_types, int *count)
+{
+       /*
+        * 1. check parameter
+        * 2. if there is no sensor, return false
+        * 3. memory allocation
+        */
+       return true;
+}
+
+/* deprecated(BUT it is used in C-API....) */
+API bool sensord_is_supported_event_type(sensor_t sensor, unsigned int event_type, bool *supported)
+{
+       if (!manager.is_supported(sensor))
+               *supported = false;
+       else
+               *supported = true;
+
+       return true;
+}
+
+/* deprecated */
+API bool sensord_send_sensorhub_data(int handle, const char *data, int data_len)
+{
+       return (sensord_set_attribute_str(handle, 0, data, data_len) == OP_SUCCESS);
+}
+
+/* deprecated */
+API bool sensord_send_command(int handle, const char *command, int command_len)
+{
+       return (sensord_set_attribute_str(handle, 0, command, command_len) == OP_SUCCESS);
+}
+
+/* deprecated */
+API bool sensord_get_privilege(sensor_t sensor, sensor_privilege_t *privilege)
+{
+       *privilege = SENSOR_PRIVILEGE_PUBLIC;
+
+       return true;
+}
+
+/* deprecated */
+API int sensord_external_connect(const char *key, sensor_external_command_cb_t cb, void *user_data)
+{
+       /*
+        * 1. check parameter
+        * 2. create handle in this client
+        * 3. first connection(client)
+        * 4. cmd_connect for external sensor with key
+        */
+       retvm_if(!key, -EINVAL, "Invalid key");
+       return 0;
+}
+
+/* deprecated */
+API bool sensord_external_disconnect(int handle)
+{
+       /*
+        * 1. check parameter
+        * 2. create handle in this client
+        * 3. first connection(client)
+        * 4. cmd_connect for external sensor with key
+        * 5. disconnect this handle
+        * 6. if there is no active sensor, remove client id and stop listener
+        */
+       return true;
+}
+
+/* deprecated */
+API bool sensord_external_post(int handle, unsigned long long timestamp, const float* data, int data_cnt)
+{
+       /*
+        * 1. check parameter
+        * 1.1 (data_cnt <= 0) || (data_cnt > POST_DATA_LEN_MAX)), return false
+        * 2. cmd_post
+        */
+
+       return true;
+}
 
 int sensor_util_set_attribute_int(sensor_type_e type, sensor_attribute_e attr, int value)
 {
index 287af046aa34dad3fbb5bd10d649619058547f4b..db1d8ecde51630b527e4b33e59cdeab599a9aaa7 100644 (file)
 #include <string.h>
 #include <sys/time.h>
 #include <limits.h>
-
-#include <sensor_internal.h>
-#include <sensor.h>
-#include <sensor_private.h>
 #include <libgen.h>
 #include <memory>
-#include "include/sensor_log.h"
+
+#include <sensor.h>
+#include <sensor-internal.h>
+#include <sensor-private.h>
+#include <sensor-log.h>
 
 #define RETURN_VAL_IF(expr, err) \
        do { \
diff --git a/src/api/sensor_internal.cpp b/src/api/sensor_internal.cpp
deleted file mode 100644 (file)
index 2c9b833..0000000
+++ /dev/null
@@ -1,1197 +0,0 @@
-/*
- * sensord
- *
- * Copyright (c) 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * 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_internal.h>
-#include <sensor_types.h>
-#include <sensor_types_private.h>
-#include <sensor_utils.h>
-
-#include <channel_handler.h>
-#include <sensor_manager.h>
-#include <sensor_listener.h>
-#include <sensor_provider_internal.h>
-#include <sensor_log.h>
-#include <unordered_map>
-#include <regex>
-#include <thread>
-#include <cmutex.h>
-#include <command_types.h>
-
-#include "sensor_reader.h"
-
-#define CONVERT_OPTION_TO_PAUSE_POLICY(option) ((option) ^ 0b11)
-#define MAX_LISTENER 100
-#define MAX_PROVIDER 20
-
-using namespace sensor;
-
-typedef struct {
-       int listener_id;
-       sensor_info *sensor;
-       void* cb;
-       char* data;
-       size_t data_size;
-       void *user_data;
-} callback_info_s;
-
-typedef GSourceFunc callback_dispatcher_t;
-
-static sensor::sensor_manager manager;
-static std::unordered_map<int, sensor::sensor_listener *> listeners;
-static cmutex lock;
-static uint providerCnt = 0;
-
-static gboolean sensor_events_callback_dispatcher(gpointer data)
-{
-       int event_type = 0;
-       callback_info_s *info = (callback_info_s *)data;
-
-       AUTOLOCK(lock);
-
-       if (info->sensor)
-               event_type = CONVERT_TYPE_EVENT(info->sensor->get_type());
-
-       if (info->cb && info->sensor && listeners.find(info->listener_id) != listeners.end()) {
-               size_t element_size =  sizeof(sensor_data_t);
-               size_t count = info->data_size / element_size;
-               ((sensor_events_cb_t)info->cb)(info->sensor, event_type, (sensor_data_t*)info->data, count, info->user_data);
-       }
-
-       delete [] info->data;
-       delete info;
-       return FALSE;
-}
-
-static gboolean sensor_event_callback_dispatcher(gpointer data)
-{
-       int event_type = 0;
-       callback_info_s *info = (callback_info_s *)data;
-
-       AUTOLOCK(lock);
-
-       if (info->sensor)
-               event_type = CONVERT_TYPE_EVENT(info->sensor->get_type());
-
-       if (info->cb && info->sensor && listeners.find(info->listener_id) != listeners.end()) {
-               ((sensor_cb_t)info->cb)(info->sensor, event_type, (sensor_data_t*)info->data, info->user_data);
-       }
-
-       delete [] info->data;
-       delete info;
-       return FALSE;
-}
-
-static gboolean sensor_accuracy_changed_callback_dispatcher(gpointer data)
-{
-       callback_info_s *info = (callback_info_s *)data;
-
-       AUTOLOCK(lock);
-
-       if (info->cb && info->sensor && listeners.find(info->listener_id) != listeners.end()) {
-               sensor_data_t * sensor_data = (sensor_data_t *)info->data;
-               ((sensor_accuracy_changed_cb_t)info->cb)(info->sensor, sensor_data->timestamp, sensor_data->accuracy, info->user_data);
-       }
-
-       delete [] info->data;
-       delete info;
-       return FALSE;
-}
-
-static gboolean sensor_attribute_int_changed_callback_dispatcher(gpointer data)
-{
-       callback_info_s *info = (callback_info_s *)data;
-
-       AUTOLOCK(lock);
-
-       if (info->cb && info->sensor && listeners.find(info->listener_id) != listeners.end()) {
-               cmd_listener_attr_int_t *d = (cmd_listener_attr_int_t *)info->data;
-               ((sensor_attribute_int_changed_cb_t)info->cb)(info->sensor, d->attribute, d->value, info->user_data);
-       }
-
-       delete [] info->data;
-       delete info;
-       return FALSE;
-}
-
-static gboolean sensor_attribute_str_changed_callback_dispatcher(gpointer data)
-{
-       callback_info_s *info = (callback_info_s *)data;
-
-       AUTOLOCK(lock);
-
-       if (info->cb && info->sensor && listeners.find(info->listener_id) != listeners.end()) {
-               cmd_listener_attr_str_t *d = (cmd_listener_attr_str_t *)info->data;
-               ((sensor_attribute_str_changed_cb_t)info->cb)(info->sensor, d->attribute, d->value, d->len, info->user_data);
-       }
-
-       delete [] info->data;
-       delete info;
-       return FALSE;
-}
-
-class sensor_listener_channel_handler : public ipc::channel_handler
-{
-public:
-       sensor_listener_channel_handler(int id, sensor_t sensor, void* cb, void *user_data, callback_dispatcher_t dispatcher)
-       : m_listener_id(id)
-       , m_sensor(reinterpret_cast<sensor_info *>(sensor))
-       , m_cb(cb)
-       , m_user_data(user_data)
-       , m_dispatcher(dispatcher)
-       {}
-
-       void connected(ipc::channel *ch) {}
-       void disconnected(ipc::channel *ch) {}
-       void read(ipc::channel *ch, ipc::message &msg)
-       {
-               callback_info_s *info;
-               auto size = msg.size();
-               char *data = new(std::nothrow) char[size];
-               if (data == NULL)
-                       return;
-               memcpy(data, msg.body(), size);
-
-               info = new(std::nothrow) callback_info_s();
-               info->listener_id = m_listener_id;
-               info->cb = m_cb;
-               info->sensor = m_sensor;
-               info->data = data;
-               info->data_size = size;
-               info->user_data = m_user_data;
-
-               g_idle_add(m_dispatcher, info);
-       }
-
-       void read_complete(ipc::channel *ch) {}
-       void error_caught(ipc::channel *ch, int error) {}
-       void set_handler(int num, ipc::channel_handler* handler) {}
-       void disconnect(void) {}
-
-private:
-       int m_listener_id;
-       sensor_info *m_sensor;
-       void* m_cb;
-       void *m_user_data;
-       callback_dispatcher_t m_dispatcher;
-};
-
-/*
- * TO-DO-LIST:
- * 1. power save option / lcd vconf : move to server
- * 2. thread-safe : ipc_client
- */
-
-API int sensord_get_sensors(sensor_type_t type, sensor_t **list, int *count)
-{
-       return sensord_get_sensors_by_uri(utils::get_uri(type), list, count);
-}
-
-API int sensord_get_default_sensor(sensor_type_t type, sensor_t *sensor)
-{
-       return sensord_get_default_sensor_by_uri(utils::get_uri(type), sensor);
-}
-
-API bool sensord_get_type(sensor_t sensor, sensor_type_t *type)
-{
-       retvm_if(!type, false, "Invalid type");
-       retvm_if(!manager.connect(), false, "Failed to connect");
-       retvm_if(!manager.is_supported(sensor), false,
-                       "Invalid sensor[%p]", sensor);
-
-       *type = static_cast<sensor_info *>(sensor)->get_type();
-
-       return true;
-}
-
-API const char* sensord_get_uri(sensor_t sensor)
-{
-       retvm_if(!manager.connect(), NULL, "Failed to connect");
-       retvm_if(!manager.is_supported(sensor), NULL,
-                       "Invalid sensor[%p]", sensor);
-
-       return static_cast<sensor_info *>(sensor)->get_uri().c_str();
-}
-
-API const char* sensord_get_name(sensor_t sensor)
-{
-       retvm_if(!manager.connect(), NULL, "Failed to connect");
-       retvm_if(!manager.is_supported(sensor), NULL,
-                       "Invalid sensor[%p]", sensor);
-
-       return static_cast<sensor_info *>(sensor)->get_model().c_str();
-}
-
-API const char* sensord_get_vendor(sensor_t sensor)
-{
-       retvm_if(!manager.connect(), NULL, "Failed to connect");
-       retvm_if(!manager.is_supported(sensor), NULL,
-                       "Invalid sensor[%p]", sensor);
-
-       return static_cast<sensor_info *>(sensor)->get_vendor().c_str();
-}
-
-API bool sensord_get_min_range(sensor_t sensor, float *min_range)
-{
-       retvm_if(!min_range, false, "Invalid paramter");
-       retvm_if(!manager.connect(), false, "Failed to connect");
-       retvm_if(!manager.is_supported(sensor), false,
-                       "Invalid sensor[%p]", sensor);
-
-       *min_range = static_cast<sensor_info *>(sensor)->get_min_range();
-
-       return true;
-}
-
-API bool sensord_get_max_range(sensor_t sensor, float *max_range)
-{
-       retvm_if(!max_range, false, "Invalid parameter");
-       retvm_if(!manager.connect(), false, "Failed to connect");
-       retvm_if(!manager.is_supported(sensor), false,
-                       "Invalid sensor[%p]", sensor);
-
-       *max_range = static_cast<sensor_info *>(sensor)->get_max_range();
-
-       return true;
-}
-
-API bool sensord_get_resolution(sensor_t sensor, float *resolution)
-{
-       retvm_if(!resolution, false, "Invalid parameter");
-       retvm_if(!manager.connect(), false, "Failed to connect");
-       retvm_if(!manager.is_supported(sensor), false,
-                       "Invalid sensor[%p]", sensor);
-
-       *resolution = static_cast<sensor_info *>(sensor)->get_resolution();
-
-       return true;
-}
-
-API bool sensord_get_min_interval(sensor_t sensor, int *min_interval)
-{
-       retvm_if(!min_interval, false, "Invalid parameter");
-       retvm_if(!manager.connect(), false, "Failed to connect");
-       retvm_if(!manager.is_supported(sensor), false,
-                       "Invalid sensor[%p]", sensor);
-
-       *min_interval = static_cast<sensor_info *>(sensor)->get_min_interval();
-
-       return true;
-}
-
-API bool sensord_get_fifo_count(sensor_t sensor, int *fifo_count)
-{
-       retvm_if(!fifo_count, false, "Invalid parameter");
-       retvm_if(!manager.connect(), false, "Failed to connect");
-       retvm_if(!manager.is_supported(sensor), false,
-                       "Invalid sensor[%p]", sensor);
-
-       *fifo_count = 0;
-
-       return true;
-}
-
-API bool sensord_get_max_batch_count(sensor_t sensor, int *max_batch_count)
-{
-       retvm_if(!max_batch_count, false, "Invalid parameter");
-       retvm_if(!manager.connect(), false, "Failed to connect");
-       retvm_if(!manager.is_supported(sensor), false,
-                       "Invalid sensor[%p]", sensor);
-
-       *max_batch_count = static_cast<sensor_info *>(sensor)->get_max_batch_count();
-
-       return true;
-}
-
-API bool sensord_is_wakeup_supported(sensor_t sensor)
-{
-       retvm_if(!manager.connect(), false, "Failed to connect");
-       retvm_if(!manager.is_supported(sensor), false,
-                       "Invalid sensor[%p]", sensor);
-
-       return static_cast<sensor_info *>(sensor)->is_wakeup_supported();
-}
-
-API int sensord_connect(sensor_t sensor)
-{
-       AUTOLOCK(lock);
-
-       retvm_if(!manager.connect(), -EIO, "Failed to connect");
-       retvm_if(!manager.is_supported(sensor), -EINVAL,
-                       "Invalid sensor[%p]", sensor);
-       retvm_if(listeners.size() > MAX_LISTENER, -EPERM, "Exceeded the maximum listener");
-
-       sensor::sensor_listener *listener;
-       static sensor_reader reader;
-
-       listener = new(std::nothrow) sensor::sensor_listener(sensor, reader.get_event_loop());
-       retvm_if(!listener, -ENOMEM, "Failed to allocate memory");
-
-       listeners[listener->get_id()] = listener;
-
-       _D("Connect[%d]", listener->get_id());
-
-       return listener->get_id();
-}
-
-API bool sensord_disconnect(int handle)
-{
-       sensor::sensor_listener *listener;
-
-       AUTOLOCK(lock);
-
-       auto it = listeners.find(handle);
-       retvm_if(it == listeners.end(), false, "Invalid handle[%d]", handle);
-
-       listener = it->second;
-       retvm_if(!listener, false, "Invalid handle[%d]", handle);
-
-       _D("Disconnect[%d]", listener->get_id());
-
-       delete listener;
-       listeners.erase(handle);
-
-       if (listeners.empty())
-               manager.disconnect();
-
-       return true;
-}
-
-static inline bool sensord_register_event_impl(int handle, unsigned int event_type,
-               unsigned int interval, unsigned int max_batch_latency, void* cb, bool is_events_callback, void *user_data)
-{
-       sensor::sensor_listener *listener;
-       int prev_interval;
-       int prev_max_batch_latency;
-       sensor_listener_channel_handler *handler;
-
-       AUTOLOCK(lock);
-
-       auto it = listeners.find(handle);
-       retvm_if(it == listeners.end(), false, "Invalid handle[%d]", handle);
-
-       listener = it->second;
-
-       prev_interval = listener->get_interval();
-       prev_max_batch_latency = listener->get_max_batch_latency();
-
-       if (listener->set_interval(interval) < 0) {
-               _E("Failed to set interval");
-               return false;
-       }
-
-       if (listener->set_max_batch_latency(max_batch_latency) < 0) {
-               listener->set_interval(prev_interval);
-               _E("Failed to set max_batch_latency");
-               return false;
-       }
-
-       if (is_events_callback) {
-               handler = new(std::nothrow)sensor_listener_channel_handler(handle, listener->get_sensor(), (void *)cb, user_data, sensor_events_callback_dispatcher);
-       } else {
-               handler = new(std::nothrow)sensor_listener_channel_handler(handle, listener->get_sensor(), (void *)cb, user_data, sensor_event_callback_dispatcher);
-       }
-
-       if (!handler) {
-               listener->set_max_batch_latency(prev_max_batch_latency);
-               listener->set_interval(prev_interval);
-               _E("Failed to allocate memory");
-               return false;
-       }
-
-       listener->set_event_handler(handler);
-
-       _D("Register event[%d]", listener->get_id());
-
-       return true;
-}
-
-API bool sensord_register_event(int handle, unsigned int event_type,
-               unsigned int interval, unsigned int max_batch_latency, sensor_cb_t cb, void *user_data)
-{
-       return sensord_register_event_impl(handle, event_type, interval, max_batch_latency, (void*)cb, false, user_data);
-}
-
-static inline bool sensord_unregister_event_imple(int handle)
-{
-       sensor::sensor_listener *listener;
-
-       AUTOLOCK(lock);
-
-       auto it = listeners.find(handle);
-       retvm_if(it == listeners.end(), false, "Invalid handle[%d]", handle);
-
-       listener = it->second;
-
-       listener->unset_event_handler();
-
-       _D("Unregister event[%d]", listener->get_id());
-
-       return true;
-}
-
-API bool sensord_unregister_event(int handle, unsigned int event_type)
-{
-       return sensord_unregister_event_imple(handle);
-}
-
-API bool sensord_register_events(int handle, unsigned int event_type, unsigned int max_batch_latency, sensor_events_cb_t cb, void *user_data)
-{
-       return sensord_register_event_impl(handle, event_type, 0, max_batch_latency, (void*)cb, true, user_data);
-}
-
-API bool sensord_unregister_events(int handle, unsigned int event_type)
-{
-       return sensord_unregister_event_imple(handle);
-}
-
-API bool sensord_register_accuracy_cb(int handle, sensor_accuracy_changed_cb_t cb, void *user_data)
-{
-       sensor::sensor_listener *listener;
-       sensor_listener_channel_handler *handler;
-
-       AUTOLOCK(lock);
-
-       auto it = listeners.find(handle);
-       retvm_if(it == listeners.end(), false, "Invalid handle[%d]", handle);
-
-       listener = it->second;
-
-       handler = new(std::nothrow) sensor_listener_channel_handler(handle, listener->get_sensor(), (void *)cb, user_data, sensor_accuracy_changed_callback_dispatcher);
-       retvm_if(!handler, false, "Failed to allocate memory");
-
-       listener->set_accuracy_handler(handler);
-
-       return true;
-}
-
-API bool sensord_unregister_accuracy_cb(int handle)
-{
-       sensor::sensor_listener *listener;
-
-       AUTOLOCK(lock);
-
-       auto it = listeners.find(handle);
-       retvm_if(it == listeners.end(), false, "Invalid handle[%d]", handle);
-
-       listener = it->second;
-
-       listener->unset_accuracy_handler();
-
-       return true;
-}
-
-API bool sensord_register_attribute_int_changed_cb(int handle, sensor_attribute_int_changed_cb_t cb, void *user_data)
-{
-       sensor::sensor_listener *listener;
-       sensor_listener_channel_handler *handler;
-
-       AUTOLOCK(lock);
-
-       auto it = listeners.find(handle);
-       retvm_if(it == listeners.end(), false, "Invalid handle[%d]", handle);
-
-       listener = it->second;
-
-       handler = new(std::nothrow) sensor_listener_channel_handler(handle, listener->get_sensor(), (void *)cb, user_data, sensor_attribute_int_changed_callback_dispatcher);
-       retvm_if(!handler, false, "Failed to allocate memory");
-
-       listener->set_attribute_int_changed_handler(handler);
-
-       return true;
-}
-
-API bool sensord_unregister_attribute_int_changed_cb(int handle)
-{
-       sensor::sensor_listener *listener;
-
-       AUTOLOCK(lock);
-
-       auto it = listeners.find(handle);
-       retvm_if(it == listeners.end(), false, "Invalid handle[%d]", handle);
-
-       listener = it->second;
-
-       listener->unset_attribute_int_changed_handler();
-
-       return true;
-}
-
-API bool sensord_register_attribute_str_changed_cb(int handle, sensor_attribute_str_changed_cb_t cb, void *user_data)
-{
-       sensor::sensor_listener *listener;
-       sensor_listener_channel_handler *handler;
-
-       AUTOLOCK(lock);
-
-       auto it = listeners.find(handle);
-       retvm_if(it == listeners.end(), false, "Invalid handle[%d]", handle);
-
-       listener = it->second;
-
-       handler = new(std::nothrow) sensor_listener_channel_handler(handle, listener->get_sensor(), (void *)cb, user_data, sensor_attribute_str_changed_callback_dispatcher);
-       retvm_if(!handler, false, "Failed to allocate memory");
-
-       listener->set_attribute_str_changed_handler(handler);
-
-       return true;
-}
-
-API bool sensord_unregister_attribute_str_changed_cb(int handle)
-{
-       sensor::sensor_listener *listener;
-
-       AUTOLOCK(lock);
-
-       auto it = listeners.find(handle);
-       retvm_if(it == listeners.end(), false, "Invalid handle[%d]", handle);
-
-       listener = it->second;
-
-       listener->unset_attribute_str_changed_handler();
-
-       return true;
-}
-
-API bool sensord_start(int handle, int option)
-{
-       sensor::sensor_listener *listener;
-       int prev_pause;
-       int pause;
-       int interval, batch_latency;
-
-       AUTOLOCK(lock);
-
-       auto it = listeners.find(handle);
-       retvm_if(it == listeners.end(), false, "Invalid handle[%d]", handle);
-
-       listener = it->second;
-
-       pause = CONVERT_OPTION_TO_PAUSE_POLICY(option);
-       prev_pause = listener->get_pause_policy();
-
-       if (listener->set_attribute(SENSORD_ATTRIBUTE_PAUSE_POLICY, pause) < 0) {
-               _E("Failed to set pause policy[%d]", pause);
-               return false;
-       }
-
-       if (listener->start() < 0) {
-               listener->set_attribute(SENSORD_ATTRIBUTE_PAUSE_POLICY, prev_pause);
-               _E("Failed to start listener");
-               return false;
-       }
-
-       interval = listener->get_interval();
-       if (interval > 0)
-               listener->set_interval(interval);
-
-       batch_latency = listener->get_max_batch_latency();
-       if (batch_latency != SENSOR_BATCH_LATENCY_DEFAULT)
-               listener->set_max_batch_latency(batch_latency);
-
-       _D("Start[%d] with the interval[%d] batch_latency[%d]",
-               listener->get_id(), interval, batch_latency);
-
-       return true;
-}
-
-API bool sensord_stop(int handle)
-{
-       int ret;
-       sensor::sensor_listener *listener;
-
-       AUTOLOCK(lock);
-
-       auto it = listeners.find(handle);
-       retvm_if(it == listeners.end(), false, "Invalid handle[%d]", handle);
-
-       listener = it->second;
-
-       ret = listener->stop();
-
-       if (ret == -EAGAIN || ret == OP_SUCCESS)
-               return true;
-
-       _D("Stop[%d]", listener->get_id());
-
-       return false;
-}
-
-API bool sensord_change_event_interval(int handle, unsigned int event_type, unsigned int interval)
-{
-       sensor::sensor_listener *listener;
-
-       AUTOLOCK(lock);
-
-       auto it = listeners.find(handle);
-       retvm_if(it == listeners.end(), false, "Invalid handle[%d]", handle);
-
-       listener = it->second;
-
-       if (listener->set_interval(interval) < 0) {
-               _E("Failed to set interval to listener");
-               return false;
-       }
-
-       _D("Set interval[%d, %d]", listener->get_id(), interval);
-
-       return true;
-}
-
-API bool sensord_change_event_max_batch_latency(int handle, unsigned int event_type, unsigned int max_batch_latency)
-{
-       sensor::sensor_listener *listener;
-
-       AUTOLOCK(lock);
-
-       auto it = listeners.find(handle);
-       retvm_if(it == listeners.end(), false, "Invalid handle[%d]", handle);
-
-       listener = it->second;
-
-       if (listener->set_max_batch_latency(max_batch_latency) < 0) {
-               _E("Failed to set max_batch_latency to listener");
-               return false;
-       }
-
-       _D("Set max batch latency[%d, %u]", listener->get_id(), max_batch_latency);
-
-       return true;
-}
-
-API bool sensord_set_option(int handle, int option)
-{
-       sensor::sensor_listener *listener;
-       int pause;
-
-       AUTOLOCK(lock);
-
-       auto it = listeners.find(handle);
-       retvm_if(it == listeners.end(), false, "Invalid handle[%d]", handle);
-
-       listener = it->second;
-
-       pause = CONVERT_OPTION_TO_PAUSE_POLICY(option);
-
-       if (listener->set_attribute(SENSORD_ATTRIBUTE_PAUSE_POLICY, pause) < 0) {
-               _E("Failed to set option[%d(%d)] to listener", option, pause);
-               return false;
-       }
-
-       _D("Set pause option[%d, %d]", listener->get_id(), pause);
-
-       return true;
-}
-
-API int sensord_set_attribute_int(int handle, int attribute, int value)
-{
-       sensor::sensor_listener *listener;
-
-       auto it = listeners.find(handle);
-       retvm_if(it == listeners.end(), -EINVAL, "Invalid handle[%d]", handle);
-
-       listener = it->second;
-
-       if (listener->set_attribute(attribute, value) < 0) {
-               _E("Failed to set attribute[%d, %d]", attribute, value);
-               return -EIO;
-       }
-
-       _D("Set attribute[%d, %d, %d]", listener->get_id(), attribute, value);
-
-       return OP_SUCCESS;
-}
-
-API int sensord_get_attribute_int(int handle, int attribute, int* value)
-{
-       sensor::sensor_listener *listener;
-
-       auto it = listeners.find(handle);
-       retvm_if(it == listeners.end(), -EINVAL, "Invalid handle[%d]", handle);
-
-       listener = it->second;
-
-       if (listener->get_attribute(attribute, value) < 0) {
-               _E("Failed to get attribute[%d]", attribute);
-               return -EIO;
-       }
-
-       _D("Get attribute[%d, %d, %d]", listener->get_id(), attribute, *value);
-
-       return OP_SUCCESS;
-}
-
-API int sensord_set_attribute_str(int handle, int attribute, const char *value, int len)
-{
-       sensor::sensor_listener *listener;
-
-       auto it = listeners.find(handle);
-       retvm_if(it == listeners.end(), -EINVAL, "Invalid handle[%d]", handle);
-
-       listener = it->second;
-
-       if (listener->set_attribute(attribute, value, len) < 0) {
-               _E("Failed to set attribute[%d, %s]", attribute, value);
-               return -EIO;
-       }
-       _D("Set attribute ID[%d], attr[%d], len[%d]", listener->get_id(), attribute, len);
-
-       return OP_SUCCESS;
-}
-
-API int sensord_get_attribute_str(int handle, int attribute, char **value, int* len)
-{
-       sensor::sensor_listener *listener;
-
-       auto it = listeners.find(handle);
-       retvm_if(it == listeners.end(), -EINVAL, "Invalid handle[%d]", handle);
-
-       listener = it->second;
-
-       if (listener->get_attribute(attribute, value, len) < 0) {
-               _E("Failed to get attribute[%d]", attribute);
-               return -EIO;
-       }
-       _D("Get attribute ID[%d], attr[%d], len[%d]", listener->get_id(), attribute, *len);
-
-       return OP_SUCCESS;
-}
-
-API bool sensord_get_data(int handle, unsigned int data_id, sensor_data_t* sensor_data)
-{
-       sensor::sensor_listener *listener;
-
-       AUTOLOCK(lock);
-
-       auto it = listeners.find(handle);
-       retvm_if(it == listeners.end(), false, "Invalid handle[%d]", handle);
-
-       listener = it->second;
-
-       if (listener->get_sensor_data(sensor_data) < 0) {
-               _E("Failed to get sensor data from listener");
-               return false;
-       }
-
-       return true;
-}
-
-API bool sensord_get_data_list(int handle, unsigned int data_id, sensor_data_t** sensor_data, int* count)
-{
-       sensor::sensor_listener *listener;
-
-       AUTOLOCK(lock);
-
-       auto it = listeners.find(handle);
-       retvm_if(it == listeners.end(), false, "Invalid handle[%d]", handle);
-
-       listener = it->second;
-
-       if (listener->get_sensor_data_list(sensor_data, count) < 0) {
-               _E("Failed to get sensor data from listener");
-               return false;
-       }
-
-       return true;
-}
-
-API bool sensord_flush(int handle)
-{
-       sensor::sensor_listener *listener;
-
-       AUTOLOCK(lock);
-
-       auto it = listeners.find(handle);
-       retvm_if(it == listeners.end(), false, "Invalid handle[%d]", handle);
-
-       listener = it->second;
-
-       if (listener->flush() < 0) {
-               _E("Failed to flush sensor");
-               return false;
-       }
-
-       return true;
-}
-
-API bool sensord_set_passive_mode(int handle, bool passive)
-{
-       sensor::sensor_listener *listener;
-
-       AUTOLOCK(lock);
-
-       auto it = listeners.find(handle);
-       retvm_if(it == listeners.end(), false, "Invalid handle[%d]", handle);
-
-       listener = it->second;
-
-       if (listener->set_passive_mode(passive) < 0) {
-               _E("Failed to set passive mode");
-               return false;
-       }
-
-       return true;
-}
-
-/* Sensor Internal API using URI */
-API int sensord_get_default_sensor_by_uri(const char *uri, sensor_t *sensor)
-{
-       retvm_if(!sensor, -EINVAL, "Invalid parameter");
-       retvm_if(!manager.connect(), -EIO, "Failed to connect");
-
-       return manager.get_sensor(uri, sensor);
-}
-
-API int sensord_get_sensors_by_uri(const char *uri, sensor_t **list, int *count)
-{
-       retvm_if((!list || !count), -EINVAL, "Invalid parameter");
-       retvm_if(!manager.connect(), -EIO, "Failed to connect");
-
-       return manager.get_sensors(uri, list, count);
-}
-
-API int sensord_add_sensor_added_cb(sensord_added_cb callback, void *user_data)
-{
-       retvm_if(!callback, -EINVAL, "Invalid paramter");
-       retvm_if(!manager.connect(), -EIO, "Failed to connect");
-
-       manager.add_sensor_added_cb(callback, user_data);
-       return OP_SUCCESS;
-}
-
-API int sensord_remove_sensor_added_cb(sensord_added_cb callback)
-{
-       retvm_if(!callback, -EINVAL, "Invalid paramter");
-       retvm_if(!manager.connect(), -EIO, "Failed to connect");
-
-       manager.remove_sensor_added_cb(callback);
-       return OP_SUCCESS;
-}
-
-API int sensord_add_sensor_removed_cb(sensord_removed_cb callback, void *user_data)
-{
-       retvm_if(!callback, -EINVAL, "Invalid paramter");
-       retvm_if(!manager.connect(), -EIO, "Failed to connect");
-
-       manager.add_sensor_removed_cb(callback, user_data);
-       return OP_SUCCESS;
-}
-
-API int sensord_remove_sensor_removed_cb(sensord_removed_cb callback)
-{
-       retvm_if(!callback, -EINVAL, "Invalid paramter");
-       retvm_if(!manager.connect(), -EIO, "Failed to connect");
-
-       manager.remove_sensor_removed_cb(callback);
-       return OP_SUCCESS;
-}
-
-/* Sensor provider */
-API int sensord_create_provider(const char *uri, sensord_provider_h *provider)
-{
-       retvm_if(providerCnt >= MAX_PROVIDER, -EPERM, "Exceeded the maximum provider");
-       retvm_if(!provider, -EINVAL, "Invalid paramter");
-
-       std::string str_uri(uri);
-       retvm_if(str_uri.find(PREDEFINED_TYPE_URI) != std::string::npos,
-                       -EINVAL, "Invalid URI format[%s]", uri);
-
-       static std::regex uri_regex(SENSOR_URI_REGEX, std::regex::optimize);
-       retvm_if(!std::regex_match(uri, uri_regex),
-                       -EINVAL, "Invalid URI format[%s]", uri);
-
-       sensor_provider *p;
-
-       p = new(std::nothrow) sensor_provider(uri);
-       retvm_if(!p, -ENOMEM, "Failed to allocate memory");
-
-       *provider = static_cast<sensord_provider_h>(p);
-       providerCnt++;
-       return OP_SUCCESS;
-}
-
-API int sensord_destroy_provider(sensord_provider_h provider)
-{
-       retvm_if(!provider, -EINVAL, "Invalid paramter");
-
-       delete static_cast<sensor::sensor_provider *>(provider);
-       providerCnt--;
-       return OP_SUCCESS;
-}
-
-API int sensord_add_provider(sensord_provider_h provider)
-{
-       retvm_if(!provider, -EINVAL, "Invalid paramter");
-       retvm_if(!manager.connect(), -EIO, "Failed to connect");
-
-       int ret;
-       sensor_provider *p = static_cast<sensor_provider *>(provider);
-
-       ret = p->connect();
-       retv_if(ret < 0, ret);
-
-       ret = manager.add_sensor(p);
-       if (ret < 0) {
-               p->disconnect();
-               return ret;
-       }
-
-       return OP_SUCCESS;
-}
-
-API int sensord_remove_provider(sensord_provider_h provider)
-{
-       retvm_if(!provider, -EINVAL, "Invalid paramter");
-       retvm_if(!manager.connect(), -EIO, "Failed to connect");
-
-       int ret;
-       sensor_provider *p = static_cast<sensor_provider *>(provider);
-
-       if (!p->disconnect())
-               return OP_ERROR;
-
-       ret = manager.remove_sensor(p);
-       if (ret < 0) {
-               p->connect();
-               return OP_ERROR;
-       }
-
-       return OP_SUCCESS;
-}
-
-API int sensord_provider_set_name(sensord_provider_h provider, const char *name)
-{
-       retvm_if(!provider, -EINVAL, "Invalid paramter");
-
-       sensor_provider *p = static_cast<sensor_provider *>(provider);
-
-       sensor_info *info = p->get_sensor_info();
-       info->set_model(name);
-
-       return OP_SUCCESS;
-}
-
-API int sensord_provider_set_vendor(sensord_provider_h provider, const char *vendor)
-{
-       retvm_if(!provider, -EINVAL, "Invalid paramter");
-
-       sensor_provider *p = static_cast<sensor_provider *>(provider);
-
-       sensor_info *info = p->get_sensor_info();
-       info->set_vendor(vendor);
-
-       return OP_SUCCESS;
-}
-
-API int sensord_provider_set_range(sensord_provider_h provider, float min_range, float max_range)
-{
-       retvm_if(!provider, -EINVAL, "Invalid paramter");
-
-       sensor_provider *p = static_cast<sensor_provider *>(provider);
-
-       sensor_info *info = p->get_sensor_info();
-       info->set_min_range(min_range);
-       info->set_max_range(max_range);
-
-       return OP_SUCCESS;
-}
-
-API int sensord_provider_set_resolution(sensord_provider_h provider, float resolution)
-{
-       retvm_if(!provider, -EINVAL, "Invalid paramter");
-
-       sensor_provider *p = static_cast<sensor_provider *>(provider);
-
-       sensor_info *info = p->get_sensor_info();
-       info->set_resolution(resolution);
-
-       return OP_SUCCESS;
-}
-
-API int sensord_provider_set_start_cb(sensord_provider_h provider, sensord_provider_start_cb callback, void *user_data)
-{
-       retvm_if(!provider, -EINVAL, "Invalid paramter");
-       retvm_if(!callback, -EINVAL, "Invalid paramter");
-
-       sensor_provider *p = static_cast<sensor_provider *>(provider);
-
-       p->set_start_cb(callback, user_data);
-
-       return OP_SUCCESS;
-}
-
-API int sensord_provider_set_stop_cb(sensord_provider_h provider, sensord_provider_stop_cb callback, void *user_data)
-{
-       retvm_if(!provider, -EINVAL, "Invalid paramter");
-       retvm_if(!callback, -EINVAL, "Invalid paramter");
-
-       sensor_provider *p = static_cast<sensor_provider *>(provider);
-
-       p->set_stop_cb(callback, user_data);
-
-       return OP_SUCCESS;
-}
-
-API int sensord_provider_set_interval_changed_cb(sensord_provider_h provider, sensord_provider_interval_changed_cb callback, void *user_data)
-{
-       retvm_if(!provider, -EINVAL, "Invalid paramter");
-       retvm_if(!callback, -EINVAL, "Invalid paramter");
-
-       sensor_provider *p = static_cast<sensor_provider *>(provider);
-
-       p->set_interval_cb(callback, user_data);
-
-       return OP_SUCCESS;
-}
-
-API int sensord_provider_set_attribute_str_cb(sensord_provider_h provider, sensord_provider_attribute_str_cb callback, void *user_data)
-{
-       retvm_if(!provider, -EINVAL, "Invalid paramter");
-       retvm_if(!callback, -EINVAL, "Invalid paramter");
-
-       sensor_provider *p = static_cast<sensor_provider *>(provider);
-
-       p->set_attribute_str_cb(callback, user_data);
-
-       return OP_SUCCESS;
-}
-
-API int sensord_provider_publish(sensord_provider_h provider, sensor_data_t data)
-{
-       retvm_if(!provider, -EINVAL, "Invalid paramter");
-
-       sensor_provider *p = static_cast<sensor_provider *>(provider);
-
-       /* TODO: synchronous call is enough? */
-       return p->publish(data);
-}
-
-API int sensord_provider_publish_events(sensord_provider_h provider, sensor_data_t events[], int count)
-{
-       retvm_if(!provider, -EINVAL, "Invalid paramter");
-
-       sensor_provider *p = static_cast<sensor_provider *>(provider);
-
-       return p->publish(events, count);
-};
-
-/* deperecated */
-API sensor_t sensord_get_sensor(sensor_type_t type)
-{
-       sensor_t sensor;
-
-       if (sensord_get_default_sensor(type, &sensor) < 0)
-               return NULL;
-
-       return sensor;
-}
-
-/* deprecated */
-API bool sensord_get_sensor_list(sensor_type_t type, sensor_t **list, int *sensor_count)
-{
-       return (sensord_get_sensors(type, list, sensor_count) == OP_SUCCESS);
-}
-
-/* deprecated */
-API bool sensord_register_hub_event(int handle, unsigned int event_type,
-               unsigned int interval, unsigned int max_batch_latency, sensorhub_cb_t cb, void *user_data)
-{
-       return false;
-}
-
-/* deprecated */
-API bool sensord_get_supported_event_types(sensor_t sensor, unsigned int **event_types, int *count)
-{
-       /*
-        * 1. check parameter
-        * 2. if there is no sensor, return false
-        * 3. memory allocation
-        */
-       return true;
-}
-
-/* deprecated(BUT it is used in C-API....) */
-API bool sensord_is_supported_event_type(sensor_t sensor, unsigned int event_type, bool *supported)
-{
-       if (!manager.is_supported(sensor))
-               *supported = false;
-       else
-               *supported = true;
-
-       return true;
-}
-
-/* deprecated */
-API bool sensord_send_sensorhub_data(int handle, const char *data, int data_len)
-{
-       return (sensord_set_attribute_str(handle, 0, data, data_len) == OP_SUCCESS);
-}
-
-/* deprecated */
-API bool sensord_send_command(int handle, const char *command, int command_len)
-{
-       return (sensord_set_attribute_str(handle, 0, command, command_len) == OP_SUCCESS);
-}
-
-/* deprecated */
-API bool sensord_get_privilege(sensor_t sensor, sensor_privilege_t *privilege)
-{
-       *privilege = SENSOR_PRIVILEGE_PUBLIC;
-
-       return true;
-}
-
-/* deprecated */
-API int sensord_external_connect(const char *key, sensor_external_command_cb_t cb, void *user_data)
-{
-       /*
-        * 1. check parameter
-        * 2. create handle in this client
-        * 3. first connection(client)
-        * 4. cmd_connect for external sensor with key
-        */
-       retvm_if(!key, -EINVAL, "Invalid key");
-       return 0;
-}
-
-/* deprecated */
-API bool sensord_external_disconnect(int handle)
-{
-       /*
-        * 1. check parameter
-        * 2. create handle in this client
-        * 3. first connection(client)
-        * 4. cmd_connect for external sensor with key
-        * 5. disconnect this handle
-        * 6. if there is no active sensor, remove client id and stop listener
-        */
-       return true;
-}
-
-/* deprecated */
-API bool sensord_external_post(int handle, unsigned long long timestamp, const float* data, int data_cnt)
-{
-       /*
-        * 1. check parameter
-        * 1.1 (data_cnt <= 0) || (data_cnt > POST_DATA_LEN_MAX)), return false
-        * 2. cmd_post
-        */
-
-       return true;
-}
-
index 7c3ab4b2e58eaf23043ed724645dd464749668f7..c0953bf23aa980b247343c6a78b79a75b5746b66 100644 (file)
@@ -20,8 +20,8 @@
 #include "sensor_listener.h"
 
 #include <channel_handler.h>
-#include <sensor_log.h>
-#include <sensor_types.h>
+#include <sensor-log.h>
+#include <sensor-types.h>
 #include <command_types.h>
 #include <ipc_client.h>
 
index aed8b116204c5aa1af2a990e6578c383c8039ef9..98b6787382bcb362542379b5951d581d928fcf40 100644 (file)
@@ -25,7 +25,7 @@
 #include <channel_handler.h>
 #include <event_loop.h>
 #include <sensor_info.h>
-#include <sensor_types.h>
+#include <sensor-types.h>
 #include <cmutex.h>
 #include <map>
 #include <atomic>
index cec62609570553be5d12e33e396a0f5a9383d334..89504f66859073af1db7c5c1a702c5c390da38d5 100644 (file)
@@ -19,7 +19,7 @@
 
 #include "sensor_manager.h"
 
-#include <sensor_log.h>
+#include <sensor-log.h>
 #include <sensor_info.h>
 #include <sensor_utils.h>
 #include <command_types.h>
index a825f3e01faad0a59c8967cfad32fb73ad64feac..770b80d9ec72a2f7a5d5162e6552b4475034a2fd 100644 (file)
@@ -27,7 +27,7 @@
 #include <list>
 #include <atomic>
 
-#include "sensor_internal.h"
+#include "sensor-internal.h"
 #include "sensor_provider_internal.h"
 
 namespace sensor {
index 3feed82f2d86675b994a3ed08006c1ff133c941d..32d5d445a5836dcd57bd6a2000b9f68754e8e8f7 100644 (file)
@@ -19,7 +19,7 @@
 
 #include "sensor_manager_channel_handler.h"
 
-#include <sensor_log.h>
+#include <sensor-log.h>
 #include <command_types.h>
 #include "sensor_manager.h"
 
index 99f76ed17b67b8069e7fdbe0d7d9e12e73dda28c..024c6f49f52142d858dba04cf204b41b7ce488c3 100644 (file)
@@ -20,7 +20,7 @@
 #ifndef __SENSOR_MANAGER_CHANNEL_HANDLER__
 #define __SENSOR_MANAGER_CHANNEL_HANDLER__
 
-#include <sensor_internal.h>
+#include <sensor-internal.h>
 #include <sensor_manager.h>
 #include <channel_handler.h>
 #include <map>
index 1f0dc264c71327131012933ae8f4ca20e268dcc4..f590388de831b08fc940af379dbe3d83d6b3db44 100644 (file)
  */
 
 #include <sensor.h>
-#include <sensor_private.h>
-#include <sensor_internal.h>
+#include <sensor-private.h>
+#include <sensor-internal.h>
 #include <new>
 #include <map>
 
-#include "include/sensor_log.h"
+#include "include/sensor-log.h"
 
 #define RETV_IF(expr, val) \
        do { if (expr) { return (val); } } while (0)
@@ -201,4 +201,4 @@ int sensor_provider_publish_events(sensor_provider_h provider, sensor_event_s ev
        RETV_IF(result < 0, SENSOR_ERROR_OPERATION_FAILED);
 
        return SENSOR_ERROR_NONE;
-}
\ No newline at end of file
+}
index b39573b93687be8ac94d39795fdebb7b3da34309..c0aa88f3e1c2abdb365c3bbfaf5f68080e59090a 100644 (file)
@@ -20,7 +20,7 @@
 #include "sensor_provider_channel_handler.h"
 
 #include <command_types.h>
-#include <sensor_log.h>
+#include <sensor-log.h>
 #include "sensor_provider_internal.h"
 
 using namespace sensor;
index aa33006f07bc664c3775fc98d7e79e394e4fb51c..9f8bfeb9d1033d5a6bdc7531a89e8c75740ff89f 100644 (file)
@@ -21,7 +21,7 @@
 #define __SENSOR_PROVIDER_CHANNEL_HANDLER__
 
 #include <channel_handler.h>
-#include <sensor_internal.h>
+#include <sensor-internal.h>
 #include "sensor_provider_internal.h"
 
 namespace sensor {
index 30762c4ad294ef5e05f8538a64ef1dfc697b1b09..c0471d8ee7718d6715818cc060bd023fc04e3ce0 100644 (file)
@@ -21,8 +21,8 @@
 
 #include <message.h>
 #include <channel.h>
-#include <sensor_log.h>
-#include <sensor_types.h>
+#include <sensor-log.h>
+#include <sensor-types.h>
 #include <sensor_utils.h>
 #include <ipc_client.h>
 #include <command_types.h>
index e694b0eaf49337134ea784e22349ddb0c84dbd09..66e14b13daffda8796239786dc0207cac972e397 100644 (file)
@@ -24,9 +24,9 @@
 #include <channel.h>
 #include <channel_handler.h>
 #include <event_loop.h>
-#include <sensor_internal.h>
+#include <sensor-internal.h>
 #include <sensor_info.h>
-#include <sensor_types.h>
+#include <sensor-types.h>
 #include <map>
 #include <atomic>
 
index bc3a7a191dbab636ab0801fab2a507603200d360..ddfb0e990cad125e6cc4f62945bc13a704e58599 100644 (file)
@@ -19,8 +19,8 @@
 
 #include "sensor_reader.h"
 
-#include <sensor_log.h>
-#include <sensor_types.h>
+#include <sensor-log.h>
+#include <sensor-types.h>
 #include <chrono>
 
 using namespace sensor;
index 3139bc17f6f643a412278ab84801526785b73936..a20486bd490ce21371c297de9d8cb6cc4a0f1d19 100644 (file)
@@ -16,7 +16,7 @@
 
 #include <stdlib.h>
 #include <sensor.h>
-#include <sensor_log.h>
+#include <sensor-log.h>
 #include <sensor_recorder_internal.h>
 #include <map>
 #include <string>
index 669afaea2cec23ceaa532832bfb14ca3803e1ef1..6eadce32c403d4c14ee34ffa6594eacafc7e9138 100644 (file)
@@ -16,7 +16,7 @@
 
 #include <stdlib.h>
 #include <sensor.h>
-#include <sensor_log.h>
+#include <sensor-log.h>
 
 int sensor_recorder_is_supported(sensor_type_e type, bool *supported)
 {
index 419d91271f45c89db8982738c3a319dece8ad6ed..2030abc3d32885fd607dbe876f33741390769900 100644 (file)
@@ -19,7 +19,7 @@
 
 #include "accept_event_handler.h"
 
-#include "sensor_log.h"
+#include "sensor-log.h"
 #include "ipc_server.h"
 
 using namespace ipc;
index eafd601fc0697a4df3749a7228ff051f5c534544..02026f183f104bf1563cd448e7449a15b892f2bf 100644 (file)
@@ -22,7 +22,7 @@
 #include <errno.h>
 #include <sys/time.h>
 #include <cbase_lock.h>
-#include <sensor_log.h>
+#include <sensor-log.h>
 
 using namespace sensor;
 
index 26b654c54ea233b280cb7dc2c97f7381d580484e..11b1ba9b3ac972e557cdb7af57a8dd52888a07ba 100644 (file)
@@ -24,7 +24,7 @@
 #include <memory>
 #include <algorithm>
 
-#include "sensor_log.h"
+#include "sensor-log.h"
 #include "channel_event_handler.h"
 
 #define SYSTEMD_SOCK_BUF_SIZE (128*1024)
index 460b6a019509fa62d6c400e76ea2ef8cbbd07b1b..4d9ef073b5abca6703a85df4c249ed33e7f1b582 100644 (file)
@@ -21,7 +21,7 @@
 
 #include "channel.h"
 #include "channel_handler.h"
-#include "sensor_log.h"
+#include "sensor-log.h"
 
 using namespace ipc;
 
index d3d19dd5679d1cf5bf0edadc0edb0520ed0afb4e..0ffc28d372f0846a4b02cf881018e1d6a13cbded 100644 (file)
@@ -18,7 +18,7 @@
  */
 
 #include <cmutex.h>
-#include <sensor_log.h>
+#include <sensor-log.h>
 
 using namespace sensor;
 
index 29aaf86ffafb443eeaf16041dbe18614d10da5f6..1e2218c1df680fc21e048588861f788ef14b9129 100644 (file)
@@ -20,7 +20,7 @@
 #ifndef __COMMAND_TYPES_H__
 #define __COMMAND_TYPES_H__
 
-#include <sensor_types.h>
+#include <sensor-types.h>
 #include "sensor_info.h"
 
 #define SENSOR_CHANNEL_PATH            "/run/.sensord.socket"
index 720687b8c38ab8ab2bb0ee66fe6fb7c5e6d131f6..6185ba2190a3c4f1230cb1d45f30af7224c9a291 100644 (file)
@@ -30,7 +30,7 @@
 #include <queue>
 
 #include "channel_event_handler.h"
-#include "sensor_log.h"
+#include "sensor-log.h"
 #include "event_handler.h"
 #include "channel.h"
 
index 26c20a3cace6a498876ca0760c4d73e5d7459e75..5af28529cf642408f8659d5df8e895b15a1df96c 100644 (file)
@@ -19,7 +19,7 @@
 
 #include "ipc_client.h"
 
-#include "sensor_log.h"
+#include "sensor-log.h"
 #include "stream_socket.h"
 #include "event_handler.h"
 #include "channel_event_handler.h"
index d25a562ba70c913cae445be146589a6519fa13f7..9d204e840b5459bc231854f38f055fdb46e7422c 100644 (file)
@@ -20,7 +20,7 @@
 #include "ipc_server.h"
 
 #include "channel.h"
-#include "sensor_log.h"
+#include "sensor-log.h"
 #include "event_loop.h"
 #include "channel_event_handler.h"
 #include "accept_event_handler.h"
index 5f12d233651d9041985837d9f7e5f3497632197e..8d4bbe673876495c770f3716f20e835d78623847 100644 (file)
@@ -19,7 +19,7 @@
 
 #include "message.h"
 
-#include <sensor_log.h>
+#include <sensor-log.h>
 #include <atomic>
 
 using namespace ipc;
index f0600834bbaafecde01d040ba71d3434c6f1a952..b6de3ff79231901dae14a8ab63b741573ac78316 100644 (file)
@@ -19,9 +19,9 @@
 
 #include "sensor_info.h"
 
-#include <sensor_types.h>
+#include <sensor-types.h>
 #include <sensor_types_private.h>
-#include <sensor_log.h>
+#include <sensor-log.h>
 #include <cfloat>
 #include <algorithm>
 #include <string>
index cbd54066f784235773ff18a8eeae276993159a62..dd816cdfaa8c577dbda6cf27bbe2962309d39995 100644 (file)
@@ -24,7 +24,7 @@
 #include <string>
 #include <vector>
 #include <hal/hal-sensor-types.h>
-#include <sensor_types.h>
+#include <sensor-types.h>
 
 namespace sensor {
 
index 58a5978372dfeb7e1c50c6216444dcaa3fe078dc..9bd178d8725e14ff5284505670b22c20003a1d31 100644 (file)
@@ -28,8 +28,8 @@
 #include <stddef.h>
 #include <map>
 
-#include <sensor_log.h>
-#include <sensor_types.h>
+#include <sensor-log.h>
+#include <sensor-types.h>
 #include <sensor_types_private.h>
 
 #ifndef PATH_MAX
index 3497dc73db44465aac9b3f958feea9c0e9817ae5..b5bd95ae3aabb95daaba1aba0f66e5137ca8172a 100644 (file)
@@ -21,7 +21,7 @@
 #define __SENSOR_UTILS_H__
 
 #include <time.h>
-#include <sensor_types.h>
+#include <sensor-types.h>
 #include <string>
 #include <vector>
 
index ad273947a89f0451606ca88f8363cecfe661bda1..cd0ea08a7a31ce2ec7eefc6e8e53a914e16e24b0 100644 (file)
@@ -22,7 +22,7 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 
-#include "sensor_log.h"
+#include "sensor-log.h"
 
 using namespace ipc;
 
index 6d11076914172b02b0dc84c4f91cae570116efbc..bbf4c8dfb984b650bcd74dca58032514b6f07cf3 100644 (file)
@@ -27,7 +27,7 @@
 #include <sys/ioctl.h>
 #include <systemd/sd-daemon.h>
 
-#include "sensor_log.h"
+#include "sensor-log.h"
 
 #define SOCK_TIMEOUT 10
 
index e583f26dbf3ac2c11cb2c4c2d441158092264617..18df444fd353860905916293527a943b6c198584 100644 (file)
@@ -22,7 +22,7 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 
-#include "sensor_log.h"
+#include "sensor-log.h"
 
 #define SLEEP_10_MS usleep(10000)