CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(sensor CXX)
-SET(DEPENDENTS "vconf glib-2.0 dlog")
+SET(DEPENDENTS "vconf glib-2.0 gio-2.0 dlog")
SET(VERSION ${FULLVER})
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
SET(EXEC_PREFIX "${CMAKE_INSTALL_PREFIX}/bin")
*/
#include <sensor_common.h>
+#include <sensor_internal_deprecated.h>
#include <sensor_internal.h>
#include <sensor_event_listener.h>
#include <sensor_client_info.h>
atexit(good_bye);
handle = sensor_client_info::get_instance().create_handle(sensor_id);
- if (handle == MAX_HANDLE_REACHED) {
+ if (handle == MAX_HANDLE) {
_E("Maximum number of handles reached, sensor: %s in client %s", get_sensor_name(sensor_id), get_client_name());
return OP_ERROR;
}
return false;
}
- if(!cmd_channel->cmd_get_data(data_id, sensor_data)) {
+ if (!cmd_channel->cmd_get_data(data_id, sensor_data)) {
_E("cmd_get_data(%d, %d, 0x%x) failed for %s", client_id, data_id, sensor_data, get_client_name());
return false;
}
return true;
-
}
#include <sensor_log.h>
#define BASE_GATHERING_INTERVAL 100
+
#define CLIENT_NAME_SIZE NAME_MAX+10
struct log_attr {
stop_event_listener();
}
-sensor_event_listener::sensor_event_listener(const sensor_event_listener& listener)
-: m_poller(listener.m_poller)
-, m_thread_state(listener.m_thread_state)
-, m_hup_observer(listener.m_hup_observer)
-, m_client_info(listener.m_client_info)
-{
-}
-
sensor_event_listener& sensor_event_listener::get_instance(void)
{
static sensor_event_listener inst;
bool sensor_event_listener::create_event_channel(void)
{
int client_id;
- event_channel_ready_t event_channel_ready;
+ channel_ready_t event_channel_ready;
if (!m_event_socket.create(SOCK_SEQPACKET))
return false;
return false;
}
- if ((event_channel_ready.magic != EVENT_CHANNEL_MAGIC) || (event_channel_ready.client_id != client_id)) {
+ if ((event_channel_ready.magic != CHANNEL_MAGIC_NUM) || (event_channel_ready.client_id != client_id)) {
_E("Event_channel_ready packet is wrong, magic = 0x%x, client id = %d",
event_channel_ready.magic, event_channel_ready.client_id);
return false;
sensor_event_listener();
~sensor_event_listener();
- sensor_event_listener(const sensor_event_listener&);
sensor_event_listener& operator=(const sensor_event_listener&);
bool create_event_channel(void);
{
if (m_reg_event_infos.empty()) {
_D("No events are registered for client %s", get_client_name());
- interval = POLL_MAX_HZ_MS;
+ interval = POLL_1HZ_MS;
latency = 0;
return;
}
cmd = (cmd_set_attribute_int_t*)payload;
if (!is_permission_allowed()) {
- _E("Permission denied to set command for client [%d], for sensor [0x%llx] with attribute [%d]",
+ _E("Permission denied to set attribute for client [%d], for sensor [0x%llx] with attribute [%d]",
m_client_id, m_sensor_id, cmd->attribute);
ret_value = OP_ERROR;
goto out;
cmd = (cmd_set_attribute_str_t*)payload;
if (!is_permission_allowed()) {
- _E("Permission denied to send sensorhub_data for client [%d], for sensor [0x%llx]",
+ _E("Permission denied to set attribute for client [%d], for sensor [0x%llx]",
m_client_id, m_sensor_id);
ret_value = OP_ERROR;
goto out;
virtual bool read_fd(std::vector<uint32_t> &ids);
virtual int get_data(sensor_data_t **data, int *length);
virtual bool flush(void);
-private:
- static cmutex m_mutex;
+protected:
const sensor_info_t *m_info;
sensor_device *m_sensor_device;
uint32_t hal_id;
- virtual bool set_interval(unsigned long interval);
- virtual bool set_batch_latency(unsigned long latency);
- virtual int set_attribute(int32_t attribute, int32_t value);
- virtual int set_attribute(int32_t attribute, char *value, int value_len);
virtual bool on_start(void);
virtual bool on_stop(void);
+ virtual int set_attribute(int32_t attribute, int32_t value);
+ virtual int set_attribute(int32_t attribute, char *value, int value_len);
+ virtual bool set_interval(unsigned long interval);
+ virtual bool set_batch_latency(unsigned long latency);
virtual bool get_sensor_info(sensor_info &info);
+
+private:
+ static cmutex m_mutex;
};
#endif /* _PHYSICAL_SENSOR_H_ */
void sensor_event_dispatcher::accept_event_channel(csocket client_socket)
{
int client_id;
- event_channel_ready_t event_channel_ready;
+ channel_ready_t event_channel_ready;
client_info_manager& client_info_manager = get_client_info_manager();
client_socket.set_connection_mode();
return;
}
- event_channel_ready.magic = EVENT_CHANNEL_MAGIC;
+ event_channel_ready.magic = CHANNEL_MAGIC_NUM;
event_channel_ready.client_id = client_id;
_I("Event channel is accepted for %s on socket[%d]",
while (remains > 0) {
event = (sensor_event_t *)malloc(sizeof(sensor_event_t));
-
remains = sensor->get_data(&data, &data_length);
+ if (remains < 0) {
+ _E("Failed to get sensor data");
+ break;
+ }
event->sensor_id = sensor->get_id();
event->event_type = sensor->get_event_type();
physical_sensor *sensor;
sensor_device *device;
- sensor_device_map_t::iterator it = m_devices.begin();
+ sensor_device_map_t::iterator it;
- for (sensor_device_map_t::iterator it = m_devices.begin(); it != m_devices.end(); ++it) {
+ for (it = m_devices.begin(); it != m_devices.end(); ++it) {
info = it->first;
device = it->second;
if (m_devices[info] == NULL)
#include <sensor_log.h>
sensor_usage::sensor_usage()
-: m_interval(POLL_MAX_HZ_MS)
+: m_interval(POLL_1HZ_MS)
, m_latency(0)
, m_option(SENSOR_OPTION_DEFAULT)
, m_start(false)
char value[0];
} cmd_set_attribute_str_t;
-#define EVENT_CHANNEL_MAGIC 0xCAFECAFE
+#define CHANNEL_MAGIC_NUM 0xCAFECAFE
typedef struct {
unsigned int magic;
int client_id;
-} event_channel_ready_t;
+} channel_ready_t;
typedef void *(*cmd_func_t)(void *data, void *cb_data);