cmd_send_sensorhub_data = (cmd_send_sensorhub_data_t*)packet->data();
cmd_send_sensorhub_data->data_len = data_len;
- cmd_send_sensorhub_data->data = atoi(buffer);
+ memcpy(cmd_send_sensorhub_data->data, buffer, data_len);
INFO("%s send cmd_send_sensorhub_data(client_id=%d, data_len = %d, buffer = 0x%x)",
get_client_name(), m_client_id, data_len, buffer);
goto out;
}
- ret_value = m_module->set_attribute(cmd->data, cmd->data_len);
+ ret_value = m_module->set_attribute(cmd->data, cmd->data, cmd->data_len);
out:
if (!send_cmd_done(ret_value))
m_handle.name = handle.name;
m_handle.type = handle.type;
m_handle.event_type = handle.event_type;
- m_handle.info = handle.info;
+ m_handle.model_name = handle.model_name;
+ m_handle.vendor = handle.vendor;
+ m_handle.min_range = handle.min_range;
+ m_handle.max_range = handle.max_range;
+ m_handle.resolution = handle.resolution;
+ m_handle.min_interval = handle.min_interval;
+ m_handle.max_batch_count = handle.max_batch_count;
+ m_handle.wakeup_supported = handle.wakeup_supported;
}
void physical_sensor::set_sensor_device(sensor_device *device)
return m_sensor_device->set_attribute(m_handle.id, attribute, value);
}
+int physical_sensor::set_attribute(char *attribute, char *value, int value_len)
+{
+ AUTOLOCK(m_mutex);
+
+ if (!m_sensor_device)
+ return false;
+
+ return m_sensor_device->set_attribute_str(m_handle.id, attribute, value, value_len);
+}
+
bool physical_sensor::set_wakeup(int wakeup)
{
return false;
info.set_type(get_type());
info.set_id(get_id());
info.set_privilege(SENSOR_PRIVILEGE_PUBLIC); // FIXME
- info.set_name(m_handle.info.model_name);
- info.set_vendor(m_handle.info.vendor);
- info.set_min_range(m_handle.info.min_range);
- info.set_max_range(m_handle.info.max_range);
- info.set_resolution(m_handle.info.resolution);
- info.set_min_interval(m_handle.info.min_interval);
+ info.set_name(m_handle.model_name);
+ info.set_vendor(m_handle.vendor);
+ info.set_min_range(m_handle.min_range);
+ info.set_max_range(m_handle.max_range);
+ info.set_resolution(m_handle.resolution);
+ info.set_min_interval(m_handle.min_interval);
info.set_fifo_count(0); // FIXME
- info.set_max_batch_count(m_handle.info.max_batch_count);
+ info.set_max_batch_count(m_handle.max_batch_count);
info.set_supported_event(get_event_type());
- info.set_wakeup_supported(m_handle.info.wakeup_supported);
+ info.set_wakeup_supported(m_handle.wakeup_supported);
return true;
}
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(char *attribute, char *value, int value_len);
virtual bool set_wakeup(int wakeup);
virtual bool on_start(void);
virtual bool on_stop(void);
return -1;
}
+int sensor_base::set_attribute(char *attribute, char *value, int value_size)
+{
+ return -1;
+}
+
bool sensor_base::start()
{
AUTOLOCK(m_client_mutex);
virtual bool flush(void);
virtual int set_attribute(int32_t attribute, int32_t value);
+ virtual int set_attribute(char *attribute, char *value, int value_size);
/* start/stop */
bool start(void);
/*
- * libsensord-share
- *
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * 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.
SENSOR_DEVICE_ROTATION_VECTOR_RAW,
} sensor_device_type;
-typedef struct sensor_info_t {
- const char *model_name;
- const char *vendor;
- float min_range;
- float max_range;
- float resolution;
- int min_interval;
- int max_batch_count;
- bool wakeup_supported;
-} sensor_info_t;
-
/*
* A platform sensor handler is generated based on this handle
* ID can be assigned from HAL developer. so it has to be unique in HAL.
const char *name;
sensor_device_type type;
unsigned int event_type; // for Internal API
- sensor_info_t info;
+ const char *model_name;
+ const char *vendor;
+ float min_range;
+ float max_range;
+ float resolution;
+ int min_interval;
+ int max_batch_count;
+ bool wakeup_supported;
} sensor_handle_t;
enum sensor_accuracy_t {
float values[SENSOR_DATA_VALUE_SIZE];
} sensor_data_t;
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
+#define SENSORHUB_DATA_VALUE_SIZE 4096
+
+#if 0
+/* sensorhub_data_t */
+typedef struct sensorhub_data_t {
+ int accuracy;
+ unsigned long long timestamp;
+ int value_count;
+ char values[SENSORHUB_DATA_VALUE_SIZE];
+} sensorhub_data_t;
+#endif
-#ifdef __cplusplus
/*
* Create devices
*/
typedef void *sensor_device_t;
typedef int (*create_t)(sensor_device_t **devices);
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#ifdef __cplusplus
/*
* Sensor device interface
* 1 device must be abstracted from 1 device event node
virtual bool set_interval(uint16_t id, unsigned long val) = 0;
virtual bool set_batch_latency(uint16_t id, unsigned long val) = 0;
virtual bool set_attribute(uint16_t id, int32_t attribute, int32_t value) = 0;
+ virtual bool set_attribute_str(uint16_t id, char *attribute, char *value, int value_len) = 0;
virtual int read_fd(uint16_t **ids) = 0;
virtual int get_data(uint16_t id, sensor_data_t **data, int *length) = 0;
typedef struct {
int data_len;
- int data;
+ char data[0];
} cmd_send_sensorhub_data_t;
#define EVENT_CHANNEL_MAGIC 0xCAFECAFE