CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(sensor CXX)
-SET(DEPENDENTS "vconf glib-2.0")
+SET(DEPENDENTS "vconf glib-2.0 dlog")
SET(VERSION ${FULLVER})
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
SET(EXEC_PREFIX "${CMAKE_INSTALL_PREFIX}/bin")
*
*/
-#include <sf_common.h>
#include <sensor_internal_deprecated.h>
#include <sensor_internal.h>
#include <sensor_event_listener.h>
static void good_bye(void)
{
- _D("Good bye! %s\n", get_client_name());
+ DBG("Good bye! %s\n", get_client_name());
clean_up();
}
static void set_power_save_state_cb(void)
{
if (g_power_save_state_cb_cnt < 0)
- _E("g_power_save_state_cb_cnt(%d) is wrong", g_power_save_state_cb_cnt);
+ ERR("g_power_save_state_cb_cnt(%d) is wrong", g_power_save_state_cb_cnt);
++g_power_save_state_cb_cnt;
if (g_power_save_state_cb_cnt == 1) {
- _D("Power save callback is registered");
+ DBG("Power save callback is registered");
g_power_save_state = get_power_save_state();
- _D("power_save_state = [%d]", g_power_save_state);
+ DBG("power_save_state = [%d]", g_power_save_state);
vconf_notify_key_changed(VCONFKEY_PM_STATE, power_save_state_cb, NULL);
}
}
--g_power_save_state_cb_cnt;
if (g_power_save_state_cb_cnt < 0)
- _E("g_power_save_state_cb_cnt(%d) is wrong", g_power_save_state_cb_cnt);
+ ERR("g_power_save_state_cb_cnt(%d) is wrong", g_power_save_state_cb_cnt);
if (g_power_save_state_cb_cnt == 0) {
- _D("Power save callback is unregistered");
+ DBG("Power save callback is unregistered");
vconf_ignore_key_changed(VCONFKEY_PM_STATE, power_save_state_cb);
}
}
auto it_handle = handles.begin();
while (it_handle != handles.end()) {
- sf_disconnect(*it_handle);
+ sensord_disconnect(*it_handle);
++it_handle;
}
}
cur_power_save_state = get_power_save_state();
if (cur_power_save_state == g_power_save_state) {
- _T("g_power_save_state NOT changed : [%d]", cur_power_save_state);
+ DBG("g_power_save_state NOT changed : [%d]", cur_power_save_state);
return;
}
g_power_save_state = cur_power_save_state;
- _D("power_save_state: %d noti to %s", g_power_save_state, get_client_name());
+ DBG("power_save_state: %d noti to %s", g_power_save_state, get_client_name());
client_info.get_listening_sensors(sensors);
{
AUTOLOCK(lock);
- _I("Trying to restore session for %s", get_client_name());
+ INFO("Trying to restore session for %s", get_client_name());
command_channel *cmd_channel;
int client_id;
retm_if (!cmd_channel, "Failed to allocate memory");
if (!cmd_channel->create_channel()) {
- _E("%s failed to create command channel for %s", get_client_name(), get_sensor_name(*it_sensor));
+ ERR("%s failed to create command channel for %s", get_client_name(), get_sensor_name(*it_sensor));
delete cmd_channel;
goto FAILED;
}
if (first_connection) {
first_connection = false;
if (!cmd_channel->cmd_get_id(client_id)) {
- _E("Failed to get client id");
+ ERR("Failed to get client id");
goto FAILED;
}
cmd_channel->set_client_id(client_id);
if (!cmd_channel->cmd_hello(*it_sensor)) {
- _E("Sending cmd_hello(%s, %d) failed for %s", get_sensor_name(*it_sensor), client_id, get_client_name());
+ ERR("Sending cmd_hello(%s, %d) failed for %s", get_sensor_name(*it_sensor), client_id, get_client_name());
goto FAILED;
}
client_info.get_sensor_rep(*it_sensor, cur_rep);
if (!change_sensor_rep(*it_sensor, prev_rep, cur_rep)) {
- _E("Failed to change rep(%s) for %s", get_sensor_name(*it_sensor), get_client_name());
+ ERR("Failed to change rep(%s) for %s", get_sensor_name(*it_sensor), get_client_name());
goto FAILED;
}
++it_sensor;
}
- _I("Succeeded to restore session for %s", get_client_name());
+ INFO("Succeeded to restore session for %s", get_client_name());
return;
FAILED:
event_listener.clear();
- _E("Failed to restore session for %s", get_client_name());
+ ERR("Failed to restore session for %s", get_client_name());
}
static bool get_events_diff(event_type_vector &a_vec, event_type_vector &b_vec, event_type_vector &add_vec, event_type_vector &del_vec)
#include <stdlib.h>
#include <command_channel.h>
#include <client_common.h>
-#include <sf_common.h>
+#include <command_common.h>
#include <sensor_info.h>
#include <sensor_info_manager.h>
#ifndef _COMMAND_CHANNEL_H_
#define _COMMAND_CHANNEL_H_
-#include <sf_common.h>
+#include <command_common.h>
#include <sensor_internal.h>
#include <cpacket.h>
#include <csocket.h>
#ifndef _REG_EVENT_INFO_H_
#define _REG_EVENT_INFO_H_
-#include <sensor_internal.h>
-#include <sf_common.h>
+#include <glib.h>
+#include <sensor_common.h>
typedef enum {
SENSOR_EVENT_CB,
#include <sensor_event_listener.h>
#include <client_common.h>
-#include <sf_common.h>
#include <sensor_info_manager.h>
#include <thread>
#include <unistd.h>
#include <csocket.h>
#include <string.h>
-#include <sf_common.h>
#include <algorithm>
#include <sstream>
#include <unordered_map>
#include <sensor_event_listener.h>
#include <client_common.h>
-#include <sf_common.h>
#include <sensor_info_manager.h>
#include <thread>
if (m_thread_state != THREAD_STATE_TERMINATE) {
m_thread_state = THREAD_STATE_STOP;
- _D("%s is waiting listener thread[state: %d] to be terminated", get_client_name(), m_thread_state);
+ DBG("%s is waiting listener thread[state: %d] to be terminated", get_client_name(), m_thread_state);
if (m_thread_cond.wait_for(u, std::chrono::seconds(THREAD_TERMINATING_TIMEOUT))
== std::cv_status::timeout)
- _E("Fail to stop listener thread after waiting %d seconds", THREAD_TERMINATING_TIMEOUT);
+ ERR("Fail to stop listener thread after waiting %d seconds", THREAD_TERMINATING_TIMEOUT);
else
- _D("Listener thread for %s is terminated", get_client_name());
+ DBG("Listener thread for %s is terminated", get_client_name());
}
}
#include <cmutex.h>
#include <poller.h>
-#include <sf_common.h>
#include <sensor_handle_info.h>
#include <sensor_client_info.h>
#include <command_channel.h>
#include <string.h>
#include <unordered_map>
#include <glib.h>
+#include <sensor_internal.h>
typedef std::unordered_map<unsigned int,reg_event_info> event_info_map;
*
*/
+#include <command_common.h>
#include <client_info_manager.h>
#include <sensor_logs.h>
#include <csocket.h>
#define _CLIENT_SENSOR_RECORD_H_
#include <sensor_internal.h>
-#include <sf_common.h>
#include <sensor_usage.h>
#include <csocket.h>
#include <unordered_map>
*
*/
-#include <command_worker.h>
+#include <command_common.h>
#include <sensor_loader.h>
#include <sensor_info.h>
#include <sensor_types.h>
#include <string>
#include <vector>
#include <utility>
-#include <permission_checker.h>
#include <set>
+#include <permission_checker.h>
+#include <command_worker.h>
using std::string;
using std::vector;
#ifndef _COMMAND_WORKER_H_
#define _COMMAND_WORKER_H_
+#include <command_common.h>
#include <worker_thread.h>
#include <client_info_manager.h>
#include <sensor_event_dispatcher.h>
#include <cynara-creds-socket.h>
#include <cynara-session.h>
#include <permission_checker.h>
-#include <sf_common.h>
#include <sensor_logs.h>
#include <sensor_loader.h>
#include <sensor_base.h>
#define _PHYSICAL_SENSOR_H_
#include <sensor_base.h>
-#include <sf_common.h>
#include <worker_thread.h>
class physical_sensor : public sensor_base {
#include <dlfcn.h>
#include <sensor_logs.h>
-#include <sf_common.h>
#include <virtual_sensor.h>
#include <auto_rotation_sensor.h>
#include <sys/types.h>
#include <dlfcn.h>
#include <sensor_logs.h>
-#include <sf_common.h>
#include <fusion_sensor.h>
#include <sensor_loader.h>
#include <orientation_filter.h>
#include <sys/types.h>
#include <dlfcn.h>
#include <sensor_logs.h>
-#include <sf_common.h>
#include <gravity_sensor.h>
#include <sensor_loader.h>
#include <virtual_sensor_config.h>
#include <sys/types.h>
#include <dlfcn.h>
#include <sensor_logs.h>
-#include <sf_common.h>
#include <linear_accel_sensor.h>
#include <sensor_loader.h>
#include <virtual_sensor_config.h>
#include <sys/types.h>
#include <dlfcn.h>
#include <sensor_logs.h>
-#include <sf_common.h>
#include <orientation_sensor.h>
#include <sensor_loader.h>
#include <orientation_filter.h>
#include <sys/types.h>
#include <dlfcn.h>
#include <sensor_logs.h>
-#include <sf_common.h>
#include <gaming_rv_sensor.h>
#include <sensor_loader.h>
#include <orientation_filter.h>
#include <sys/types.h>
#include <dlfcn.h>
#include <sensor_logs.h>
-#include <sf_common.h>
#include <geomagnetic_rv_sensor.h>
#include <sensor_loader.h>
#include <orientation_filter.h>
#include <sys/types.h>
#include <dlfcn.h>
#include <sensor_logs.h>
-#include <sf_common.h>
#include <rv_sensor.h>
#include <sensor_loader.h>
#include <orientation_filter.h>
#include <rv_raw_sensor.h>
#endif
-#include <sf_common.h>
-
extern "C" sensor_module* create(void)
{
sensor_module *module = new(std::nothrow) sensor_module;
#include <sys/types.h>
#include <dlfcn.h>
#include <sensor_logs.h>
-#include <sf_common.h>
#include <tilt_sensor.h>
#include <sensor_loader.h>
#include <orientation_filter.h>
*
*/
+#include <command_common.h>
#include <sensor_event_dispatcher.h>
#include <sensor_logs.h>
-#include <sf_common.h>
#include <thread>
using std::thread;
while (true) {
void *seed_event = get_event_queue().pop();
- unsigned int event_type = *((unsigned int *)(seed_event));
vector<void *> sensor_events;
sensor_events.push_back(seed_event);
#ifndef _SENSOR_EVENT_DISPATCHER_H_
#define _SENSOR_EVENT_DISPATCHER_H_
-#include <sf_common.h>
#include <sensor_event_queue.h>
#include <client_info_manager.h>
#include <csocket.h>
#ifndef _SENSOR_EVENT_QUEUE_H_
#define _SENSOR_EVENT_QUEUE_H_
-#include <sf_common.h>
#include <cstring>
#include <utility>
#include <queue>
#include <mutex>
#include <condition_variable>
#include <set>
+#include <sensor_common.h>
extern std::set<unsigned int> priority_list;
#ifndef _SENSOR_USAGE_H_
#define _SENSOR_USAGE_H_
-#include <sf_common.h>
#include <algorithm>
#include <vector>
#include <systemd/sd-daemon.h>
#include <server.h>
#include <sensor_loader.h>
+#include <command_common.h>
#include <command_worker.h>
#include <thread>
#include <sys/epoll.h>
{
if (m_trans_func[index] != NULL) {
if(!m_trans_func[index](m_context)) {
- _T("Transition[%d] function returning false", index);
+ ERR("Transition[%d] function returning false", index);
return false;
}
}
lock l(m_mutex);
if (m_state == WORKER_STATE_WORKING) {
- _T("Worker thread is already working");
+ INFO("Worker thread is already working");
return true;
}
return true;
}
- _T("Failed to start, because current state(%d) is not for START", m_state);
+ ERR("Failed to start, because current state(%d) is not for START", m_state);
return false;
}
lock l(m_mutex);
if (m_state == WORKER_STATE_STOPPED) {
- _T("Worker thread is already stopped");
+ INFO("Worker thread is already stopped");
return true;
}
return true;
}
- _T("Failed to stop, because current state(%d) is not for STOP", m_state);
+ ERR("Failed to stop, because current state(%d) is not for STOP", m_state);
return false;
}
lock l(m_mutex);
if (m_state == WORKER_STATE_PAUSED) {
- _T("Worker thread is already paused");
+ INFO("Worker thread is already paused");
return true;
}
return true;
}
- _T("Failed to pause, because current state(%d) is not for PAUSE", m_state);
+ ERR("Failed to pause, because current state(%d) is not for PAUSE", m_state);
return false;
lock l(m_mutex);
if (m_state == WORKER_STATE_WORKING) {
- _T("Worker thread is already working");
+ INFO("Worker thread is already working");
return true;
}
return true;
}
- _T("Failed to resume, because current state(%d) is not for RESUME", m_state);
+ ERR("Failed to resume, because current state(%d) is not for RESUME", m_state);
return false;
}
void worker_thread::main(void)
{
- _T("Worker thread(0x%x) is created", std::this_thread::get_id());
+ DBG("Worker thread(0x%x) is created", std::this_thread::get_id());
transition_function(STARTED);
if (state == WORKER_STATE_WORKING) {
if (!transition_function(WORKING)) {
m_state = WORKER_STATE_STOPPED;
- _T("Worker thread(0x%x) exits from working state", std::this_thread::get_id());
+ DBG("Worker thread(0x%x) exits from working state", std::this_thread::get_id());
m_thread_created = false;
transition_function(STOPPED);
break;
if (m_state == WORKER_STATE_PAUSED) {
transition_function(PAUSED);
- _T("Worker thread(0x%x) is paused", std::this_thread::get_id());
+ DBG("Worker thread(0x%x) is paused", std::this_thread::get_id());
m_cond_working.wait(u);
if (m_state == WORKER_STATE_WORKING) {
transition_function(RESUMED);
- _T("Worker thread(0x%x) is resumed", std::this_thread::get_id());
+ DBG("Worker thread(0x%x) is resumed", std::this_thread::get_id());
} else if (m_state == WORKER_STATE_STOPPED) {
m_thread_created = false;
transition_function(STOPPED);
break;
}
}
- _T("Worker thread(0x%x)'s main is terminated", std::this_thread::get_id());
+ INFO("Worker thread(0x%x)'s main is terminated", std::this_thread::get_id());
}
void worker_thread::set_started(trans_func_t func)
*
*/
-#ifndef _SF_COMMON_H_
-#define _SF_COMMON_H_
+#ifndef _COMMAND_COMMON_H_
+#define _COMMAND_COMMON_H_
-#include <unistd.h>
#include <sensor_common.h>
-#include <string>
-#include <vector>
-#include <sensor_logs.h>
#define COMMAND_CHANNEL_PATH "/tmp/sensord_command_socket"
#define EVENT_CHANNEL_PATH "/tmp/sensord_event_socket"
#define MAX_HANDLE 256
#define MAX_HANDLE_REACHED -2
-#define CLIENT_ID_INVALID -1
-
enum packet_type_t {
CMD_NONE = 0,
CMD_GET_ID,
CMD_CNT,
};
-enum sensor_state_t {
- SENSOR_STATE_UNKNOWN = -1,
- SENSOR_STATE_STOPPED = 0,
- SENSOR_STATE_STARTED = 1,
- SENSOR_STATE_PAUSED = 2
-};
-
-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 = POLL_1HZ_MS,
-};
-
typedef struct {
char name[NAME_MAX];
} cmd_get_id_t;
int client_id;
} event_channel_ready_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;
-
typedef void *(*cmd_func_t)(void *data, void *cb_data);
-typedef std::vector<unsigned int> event_type_vector;
-
-enum sensor_permission_t {
- SENSOR_PERMISSION_NONE = 0,
- SENSOR_PERMISSION_STANDARD = (1 << 0),
- SENSOR_PERMISSION_BIO = (1 << 1),
-};
-
-#define BIO_SENSOR_PRIVELEGE_NAME "sensord::bio"
-#define BIO_SENSOR_ACCESS_RIGHT "rw"
-
-#endif /* _SF_COMMON_H_ */
+#endif /* _COMMAND_COMMON_H_ */
#include <new>
#include <sensor_logs.h>
#include <cpacket.h>
-#include <sf_common.h>
+#include <command_common.h>
cpacket::cpacket()
{
* limitations under the License.
*
*/
+#include <errno.h>
+#include <string.h>
#include <sensor_logs.h>
#include <poller.h>
-#include <sf_common.h>
#define EPOLL_MAX 32
#include <sensor_types.h>
#include <stdint.h>
-#ifndef DEPRECATED
-#define DEPRECATED __attribute__((deprecated))
+#define CLIENT_ID_INVALID -1
+
+#ifndef NAME_MAX
+#define NAME_MAX 256
#endif
#ifdef __cplusplus
typedef void *sensor_t;
-typedef enum {
- SENSOR_PRIVILEGE_PUBLIC,
- SENSOR_PRIVILEGE_INTERNAL,
-} sensor_privilege_t;
-
/*
* To prevent naming confliction as using same enums as sensor CAPI use
*/
typedef enum sensor_option_t sensor_option_e;
#endif
-/*
- * To prevent naming confliction as using same enums as sensor CAPI use
- */
-#ifndef __SENSOR_H__
enum sensor_wakeup_t {
SENSOR_WAKEUP_UNKNOWN = -1,
SENSOR_WAKEUP_OFF = 0,
SENSOR_WAKEUP_ON = 1,
};
-typedef enum sensor_wakeup_t sensor_wakeup_e;
-#endif
+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 = POLL_1HZ_MS,
+};
enum sensor_interval_t {
- SENSOR_INTERVAL_FASTEST = 0,
- SENSOR_INTERVAL_NORMAL = 200,
+ SENSOR_INTERVAL_FASTEST = POLL_100HZ_MS,
+ SENSOR_INTERVAL_NORMAL = POLL_5HZ_MS,
};
typedef enum {
CONDITION_LESS_THAN,
} condition_op_t;
+enum sensor_state_t {
+ SENSOR_STATE_UNKNOWN = -1,
+ SENSOR_STATE_STOPPED = 0,
+ SENSOR_STATE_STARTED = 1,
+ SENSOR_STATE_PAUSED = 2
+};
+
+typedef enum {
+ SENSOR_PRIVILEGE_PUBLIC,
+ SENSOR_PRIVILEGE_INTERNAL,
+} sensor_privilege_t;
+
+enum sensor_permission_t {
+ SENSOR_PERMISSION_NONE = 0,
+ SENSOR_PERMISSION_STANDARD = (1 << 0),
+ SENSOR_PERMISSION_BIO = (1 << 1)
+};
+
+typedef struct sensor_event_t {
+ unsigned int event_type;
+ sensor_id_t sensor_id;
+ unsigned int data_length;
+ sensor_data_t *data;
+} sensor_event_t;
+
#ifdef __cplusplus
}
#endif
+#ifdef __cplusplus
+#include <vector>
+
+typedef std::vector<unsigned int> event_type_vector;
+#endif
#endif /* __SENSOR_COMMON_H__ */
#define _SENSOR_INFO_H_
#include <stdint.h>
-#include <sf_common.h>
#include <sensor_common.h>
#include <sensor_types.h>
#include <string>
#ifndef __SENSOR_INTERNAL_H__
#define __SENSOR_INTERNAL_H__
-#ifndef DEPRECATED
-#define DEPRECATED __attribute__((deprecated))
-#endif
-
#ifndef API
#define API __attribute__((visibility("default")))
#endif
float sensor_resolution;
} sensor_data_properties_t;
-int sf_is_sensor_event_available(sensor_type_t sensor_type , unsigned int event_type);
+DEPRECATED int sf_is_sensor_event_available(sensor_type_t sensor_type , unsigned int event_type);
-int sf_get_data_properties(unsigned int data_id, sensor_data_properties_t *return_data_properties);
+DEPRECATED int sf_get_data_properties(unsigned int data_id, sensor_data_properties_t *return_data_properties);
-int sf_get_properties(sensor_type_t sensor_type, sensor_properties_t *return_properties);
+DEPRECATED int sf_get_properties(sensor_type_t sensor_type, sensor_properties_t *return_properties);
-int sf_check_rotation(unsigned long *rotation);
+DEPRECATED int sf_check_rotation(unsigned long *rotation);
/**
* @fn int sf_connect(sensor_type_t sensor)
* @param[in] sensor_type your desired sensor type
* @return if it succeed, it return handle value( >=0 ) , otherwise negative value return
*/
-int sf_connect(sensor_type_t sensor_type);
+DEPRECATED int sf_connect(sensor_type_t sensor_type);
/**
* @fn int sf_disconnect(int handle)
* @param[in] handle received handle value by sf_connect()
* @return if it succeed, it return zero value , otherwise negative value return
*/
-int sf_disconnect(int handle);
+DEPRECATED int sf_disconnect(int handle);
/**
* @fn int sf_start(int handle , int option)
* @param[in] option With SENSOR_OPTION_DEFAULT, it stops to sense when LCD is off, and with SENSOR_OPTION_ALWAYS_ON, it continues to sense even when LCD is off
* @return if it succeed, it return zero value , otherwise negative value return
*/
-int sf_start(int handle , int option);
+DEPRECATED int sf_start(int handle , int option);
/**
* @fn int sf_stop(int handle)
* @param[in] handle received handle value by sf_connect()
* @return if it succeed, it return zero value , otherwise negative value return
*/
-int sf_stop(int handle);
+DEPRECATED int sf_stop(int handle);
/**
* @fn int sf_register_event(int handle , unsigned int event_type , event_conditon_t *event_condition , sensor_callback_func_t cb , void *user_data )
* @param[in] user_data your option data that will be send when your define callback function called. if you don't have any option data, just use a NULL value
* @return if it succeed, it return zero value , otherwise negative value return
*/
-int sf_register_event(int handle , unsigned int event_type , event_condition_t *event_condition , sensor_callback_func_t cb , void *user_data );
+DEPRECATED int sf_register_event(int handle , unsigned int event_type , event_condition_t *event_condition , sensor_callback_func_t cb , void *user_data );
/**
* @fn int sf_unregister_event(int handle, unsigned int event_type)
* @param[in] event_type your desired event_type that you want to unregister event
* @return if it succeed, it return zero value , otherwise negative value return
*/
-int sf_unregister_event(int handle, unsigned int event_type);
+DEPRECATED int sf_unregister_event(int handle, unsigned int event_type);
/**
* @fn int sf_get_data(int handle , unsigned int data_id , sensor_data_t* values)
* @param[out] values return values
* @return if it succeed, it return zero value , otherwise negative value return
*/
-int sf_get_data(int handle , unsigned int data_id , sensor_data_t* values);
+DEPRECATED int sf_get_data(int handle , unsigned int data_id , sensor_data_t* values);
/**
* @fn int sf_change_event_condition(int handle, unsigned int event_type, event_condition_t *event_condition)
* @param[in] event_condition your desired event condition that you want to change event
* @return if it succeed, it return zero value , otherwise negative value return
*/
-int sf_change_event_condition(int handle, unsigned int event_type, event_condition_t *event_condition);
+DEPRECATED int sf_change_event_condition(int handle, unsigned int event_type, event_condition_t *event_condition);
/**
* @fn int sf_change_sensor_option(int handle, int option)
* @return if it succeed, it return zero value , otherwise negative value return
*/
-int sf_change_sensor_option(int handle, int option);
+DEPRECATED int sf_change_sensor_option(int handle, int option);
/**
* @fn int sf_send_sensorhub_data(int handle, const char* buffer, int data_len)
* @param[in] data_len the length of data
* @return if it succeed, it returns zero, otherwise negative value
*/
-int sf_send_sensorhub_data(int handle, const char* data, int data_len);
+DEPRECATED int sf_send_sensorhub_data(int handle, const char* data, int data_len);
#ifdef __cplusplus
*
*/
-#include <syslog.h>
#include <fcntl.h>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <string.h>
#include <dlog.h>
-#include <stdarg.h>
-#include <stddef.h>
+#include <sensor_common.h>
#include "sensor_logs.h"
-#ifndef EXTAPI
-#define EXTAPI __attribute__((visibility("default")))
-#endif
-
-#define SF_SERVER_MSG_LOG_FILE "/var/log/messages"
-#define FILE_LENGTH 255
-
-static int sf_debug_file_fd;
-static char sf_debug_file_buf[FILE_LENGTH];
-
-EXTAPI void sf_log(int type , int priority , const char *tag , const char *fmt , ...)
-{
- va_list ap;
- va_start(ap, fmt);
-
- switch (type) {
- case SF_LOG_PRINT_FILE:
- sf_debug_file_fd = open(SF_SERVER_MSG_LOG_FILE, O_WRONLY|O_CREAT|O_APPEND, 0644);
- if (sf_debug_file_fd != -1) {
- vsnprintf(sf_debug_file_buf,255, fmt , ap );
- int total_bytes_written = 0;
- while (total_bytes_written < (int) strlen(sf_debug_file_buf)){
- int bytes_written = write(sf_debug_file_fd, (sf_debug_file_buf + total_bytes_written), strlen(sf_debug_file_buf) - total_bytes_written);
- if (bytes_written == -1)
- break;
- total_bytes_written = total_bytes_written + bytes_written;
- }
- close(sf_debug_file_fd);
- }
- break;
-
- case SF_LOG_SYSLOG:
- int syslog_prio;
- switch (priority) {
- case SF_LOG_ERR:
- syslog_prio = LOG_ERR|LOG_DAEMON;
- break;
- case SF_LOG_WARN:
- syslog_prio = LOG_WARNING|LOG_DAEMON;
- break;
-
- case SF_LOG_DBG:
- syslog_prio = LOG_DEBUG|LOG_DAEMON;
- break;
-
- case SF_LOG_INFO:
- syslog_prio = LOG_INFO|LOG_DAEMON;
- break;
-
- default:
- syslog_prio = priority;
- break;
- }
-
- vsyslog(syslog_prio, fmt, ap);
- break;
-
- case SF_LOG_DLOG:
- if (tag) {
- switch (priority) {
- case SF_LOG_ERR:
- SLOG_VA(LOG_ERROR, tag ? tag : "NULL" , fmt ? fmt : "NULL" , ap);
- break;
-
- case SF_LOG_WARN:
- SLOG_VA(LOG_WARN, tag ? tag : "NULL" , fmt ? fmt : "NULL" , ap);
- break;
-
- case SF_LOG_DBG:
- SLOG_VA(LOG_DEBUG, tag ? tag : "NULL", fmt ? fmt : "NULL" , ap);
- break;
-
- case SF_LOG_INFO:
- SLOG_VA(LOG_INFO, tag ? tag : "NULL" , fmt ? fmt : "NULL" , ap);
- break;
- }
- }
- break;
- }
-
- va_end(ap);
-}
+#define PATH_MAX 256
#if defined(_DEBUG)
bool get_proc_name(pid_t pid, char *process_name)
#ifndef _SENSOR_LOGS_H_
#define _SENSOR_LOGS_H_
-#ifndef __cplusplus
-#include <stdbool.h>
-#endif /* !__cplusplus */
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
+#include <dlog.h>
#include <sys/types.h>
-#include <unistd.h>
-
-#if !defined(PATH_MAX)
-#define PATH_MAX 256
-#endif
-
-#if !defined(NAME_MAX)
-#define NAME_MAX 256
-#endif
-
#define EVENT_TYPE_SHIFT 16
#define SENSOR_TYPE_SHIFT 32
-#define USE_DLOG_LOG
-
-enum sf_log_type {
- SF_LOG_PRINT_FILE = 1,
- SF_LOG_SYSLOG = 2,
- SF_LOG_DLOG = 3,
-};
-
-enum sf_priority_type {
- SF_LOG_ERR = 1,
- SF_LOG_DBG = 2,
- SF_LOG_INFO = 3,
- SF_LOG_WARN = 4,
-};
-
-void sf_log(int type , int priority , const char *tag , const char *fmt , ...);
-
#define MICROSECONDS(tv) ((tv.tv_sec * 1000000ll) + tv.tv_usec)
-#ifndef __MODULE__
-#include <string.h>
-#define __MODULE__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
-#endif
-
-//for new log system - dlog
#ifdef LOG_TAG
#undef LOG_TAG
#endif
#define LOG_TAG "SENSOR"
-#if defined(_DEBUG) || defined(USE_FILE_DEBUG)
-
-#define DbgPrint(fmt, arg...) do { sf_log(SF_LOG_PRINT_FILE, 0, LOG_TAG , " [SF_MSG_PRT][%s:%d] " fmt"\n",__MODULE__, __LINE__, ##arg); } while(0)
-
-#endif
-
-#if defined(USE_SYSLOG_DEBUG)
-
-#define ERR(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_ERR, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0)
-#define WARN(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_WARN, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0)
-#define INFO(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_INFO, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0)
-#define DBG(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_DBG, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0)
-
-#define _E(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_ERR, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0)
-#define _W(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_WARN, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0)
-#define _I(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_INFO, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0)
-#define _D(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_DBG, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0)
-#define _T(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_DBG, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0)
-
-
-#elif defined(_DEBUG) || defined(USE_DLOG_DEBUG)
-
-#define ERR(fmt, arg...) do { sf_log(SF_LOG_DLOG, SF_LOG_ERR, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0)
-#define WARN(fmt, arg...) do { sf_log(SF_LOG_DLOG, SF_LOG_WARN, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0)
-#define INFO(fmt, arg...) do { sf_log(SF_LOG_DLOG, SF_LOG_INFO, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0)
-#define DBG(fmt, arg...) do { sf_log(SF_LOG_DLOG, SF_LOG_DBG, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0)
-
-#define _E(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_ERR, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0)
-#define _W(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_WARN, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0)
-#define _I(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_INFO, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0)
-#define _D(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_DBG, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0)
-#define _T(fmt, arg...) do { sf_log(SF_LOG_SYSLOG, SF_LOG_DBG, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0)
-
-#elif defined(USE_FILE_DEBUG)
-
-#define ERR(fmt, arg...) do { sf_log(SF_LOG_PRINT_FILE, 0, LOG_TAG, "[SF_MSG_ERR][%s:%d] " fmt"\n",__MODULE__, __LINE__, ##arg); } while(0)
-#define WARN(fmt, arg...) do { sf_log(SF_LOG_PRINT_FILE, 0, LOG_TAG, "[SF_MSG_WARN][%s:%d] " fmt"\n",__MODULE__, __LINE__, ##arg); } while(0)
-#define DBG(fmt, arg...) do { sf_log(SF_LOG_PRINT_FILE, 0, LOG_TAG, "[SF_MSG_DBG][%s:%d] " fmt"\n",__MODULE__, __LINE__, ##arg); } while(0)
-#define INFO(fmt, arg...) do { sf_log(SF_LOG_PRINT_FILE, 0, LOG_TAG, "[SF_MSG_INFO][%s:%d] " fmt"\n",__MODULE__, __LINE__, ##arg); } while(0)
-
-#define _E(fmt, arg...) do { sf_log(SF_LOG_PRINT_FILE, 0, LOG_TAG ,"[SF_MSG_ERR][%s:%d] " fmt"\n",__MODULE__, __LINE__, ##arg); } while(0)
-#define _W(fmt, arg...) do { sf_log(SF_LOG_PRINT_FILE, 0, LOG_TAG ,"[SF_MSG_WARN][%s:%d] " fmt"\n",__MODULE__, __LINE__, ##arg); } while(0)
-#define _I(fmt, arg...) do { sf_log(SF_LOG_PRINT_FILE, 0, LOG_TAG ,"[SF_MSG_INFO][%s:%d] " fmt"\n",__MODULE__, __LINE__, ##arg); } while(0)
-#define _D(fmt, arg...) do { sf_log(SF_LOG_PRINT_FILE, 0, LOG_TAG ,"[SF_MSG_DBG][%s:%d] " fmt"\n",__MODULE__, __LINE__, ##arg); } while(0)
-#define _T(fmt, arg...) do { sf_log(SF_LOG_PRINT_FILE, 0, LOG_TAG ,"[SF_MSG_TEMP][%s:%d] " fmt"\n",__MODULE__, __LINE__, ##arg); } while(0)
-
-#elif defined(USE_DLOG_LOG)
-
-#define ERR(fmt, arg...) do { sf_log(SF_LOG_DLOG, SF_LOG_ERR, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0)
-#define WARN(fmt, arg...) do { sf_log(SF_LOG_DLOG, SF_LOG_WARN, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0)
-#define INFO(fmt, arg...) do { sf_log(SF_LOG_DLOG, SF_LOG_INFO, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0)
-
-#define DBG(...) do{} while(0)
-#define DbgPrint(...) do{} while(0)
-
-
-#define _E(fmt, arg...) do { sf_log(SF_LOG_DLOG, SF_LOG_ERR, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0)
-#define _W(fmt, arg...) do { sf_log(SF_LOG_DLOG, SF_LOG_WARN, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0)
-#define _I(fmt, arg...) do { sf_log(SF_LOG_DLOG, SF_LOG_INFO, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0)
-#define _D(fmt, arg...) do { sf_log(SF_LOG_DLOG, SF_LOG_DBG, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0)
-#define _T(...)
-
+#ifdef _DEBUG
+#define DBG SLOGD
#else
-#define ERR(fmt, arg...) do { sf_log(SF_LOG_DLOG, SF_LOG_ERR, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0)
-#define WARN(...) do{} while(0)
-#define DbgPrint(...) do{} while(0)
#define DBG(...) do{} while(0)
-#define INFO(...) do{} while(0)
-
-#define _E(fmt, arg...) do { sf_log(SF_LOG_DLOG, SF_LOG_ERR, LOG_TAG, "%s:%s(%d)> " fmt, __MODULE__, __func__, __LINE__, ##arg); } while(0)
-#define _W(...) do{} while(0)
-#define _I(...) do{} while(0)
-#define _D(...) do{} while(0)
-#define _T(...) do{} while(0)
-
#endif
+#define ERR SLOGE
+#define WARN SLOGW
+#define INFO SLOGI
+#define _E ERR
+#define _W WARN
+#define _I INFO
+#define _D DBG
#if defined(_DEBUG)
# define warn_if(expr, fmt, arg...) do { \
#endif
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
const char* get_client_name(void);
bool get_proc_name(pid_t pid, char *process_name);