{
}
-void physical_sensor::set_sensor_handle(const sensor_handle_t *handle)
+void physical_sensor::set_sensor_info(const sensor_info_t *info)
{
- m_handle = handle;
+ m_info = info;
}
void physical_sensor::set_sensor_device(sensor_device *device)
sensor_type_t physical_sensor::get_type(void)
{
- return static_cast<sensor_type_t>(m_handle->type);
+ return static_cast<sensor_type_t>(m_info->type);
}
unsigned int physical_sensor::get_event_type(void)
{
- return m_handle->event_type;
+ return m_info->event_type;
}
const char* physical_sensor::get_name(void)
{
- if (!m_handle->name)
+ if (!m_info->name)
return UNKNOWN_NAME;
- return m_handle->name;
+ return m_info->name;
}
uint32_t physical_sensor::get_hal_id(void)
{
- return m_handle->id;
+ return m_info->id;
}
int physical_sensor::get_poll_fd()
return -1;
int remains = 0;
- remains = m_sensor_device->get_data(m_handle->id, data, length);
+ remains = m_sensor_device->get_data(m_info->id, data, length);
if (*length < 0) {
_E("Failed to get sensor event");
if (!m_sensor_device)
return false;
- return m_sensor_device->flush(m_handle->id);
+ return m_sensor_device->flush(m_info->id);
}
bool physical_sensor::set_interval(unsigned long interval)
_I("Polling interval is set to %dms", interval);
- return m_sensor_device->set_interval(m_handle->id, interval);
+ return m_sensor_device->set_interval(m_info->id, interval);
}
bool physical_sensor::set_batch_latency(unsigned long latency)
_I("Polling interval is set to %dms", latency);
- return m_sensor_device->set_batch_latency(m_handle->id, latency);
+ return m_sensor_device->set_batch_latency(m_info->id, latency);
}
int physical_sensor::set_attribute(int32_t attribute, int32_t value)
if (!m_sensor_device)
return false;
- return m_sensor_device->set_attribute_int(m_handle->id, attribute, value);
+ return m_sensor_device->set_attribute_int(m_info->id, attribute, value);
}
int physical_sensor::set_attribute(int32_t attribute, char *value, int value_len)
if (!m_sensor_device)
return false;
- return m_sensor_device->set_attribute_str(m_handle->id, attribute, value, value_len);
+ return m_sensor_device->set_attribute_str(m_info->id, attribute, value, value_len);
}
bool physical_sensor::set_wakeup(int wakeup)
if (!m_sensor_device)
return false;
- return m_sensor_device->enable(m_handle->id);
+ return m_sensor_device->enable(m_info->id);
}
bool physical_sensor::on_stop()
if (!m_sensor_device)
return false;
- return m_sensor_device->disable(m_handle->id);
+ return m_sensor_device->disable(m_info->id);
}
bool physical_sensor::get_sensor_info(sensor_info &info)
info.set_type(get_type());
info.set_id(get_id());
info.set_privilege(SENSOR_PRIVILEGE_PUBLIC); // FIXME
- 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_name(m_info->model_name);
+ info.set_vendor(m_info->vendor);
+ info.set_min_range(m_info->min_range);
+ info.set_max_range(m_info->max_range);
+ info.set_resolution(m_info->resolution);
+ info.set_min_interval(m_info->min_interval);
info.set_fifo_count(0); // FIXME
- info.set_max_batch_count(m_handle->max_batch_count);
+ info.set_max_batch_count(m_info->max_batch_count);
info.set_supported_event(get_event_type());
- info.set_wakeup_supported(m_handle->wakeup_supported);
+ info.set_wakeup_supported(m_info->wakeup_supported);
return true;
}
{
sensor_device_t *_devices = NULL;
sensor_device *device;
- const sensor_handle_t *handles;
+ const sensor_info_t *infos;
_I("load device: [%s]", path.c_str());
for (int i = 0; i < device_size; ++i) {
device = static_cast<sensor_device *>(_devices[i]);
- int handle_size = device->get_sensors(&handles);
- for (int j = 0; j < handle_size; ++j)
- m_devices[&handles[j]] = device;
+ int info_size = device->get_sensors(&infos);
+ for (int j = 0; j < info_size; ++j)
+ m_devices[&infos[j]] = device;
}
handle = _handle;
void sensor_loader::create_physical_sensors(sensor_type_t type)
{
int32_t index;
- const sensor_handle_t *handle;
+ const sensor_info_t *info;
physical_sensor *sensor;
sensor_device *device;
sensor_device_map_t::iterator it = m_devices.begin();
for (sensor_device_map_t::iterator it = m_devices.begin(); it != m_devices.end(); ++it) {
- handle = it->first;
+ info = it->first;
device = it->second;
- if (m_devices[handle] == NULL)
+ if (m_devices[info] == NULL)
continue;
if (type != UNKNOWN_SENSOR) {
- if (type != (sensor_type_t)(handle->type))
+ if (type != (sensor_type_t)(info->type))
continue;
}
sensor = reinterpret_cast<physical_sensor *>(create_sensor<_sensor>());
if (!sensor) {
- _E("Memory allocation failed[%s]", handle->name);
+ _E("Memory allocation failed[%s]", info->name);
return;
}
- sensor_type_t _type = (sensor_type_t)handle->type;
+ sensor_type_t _type = (sensor_type_t)info->type;
index = (int32_t)m_sensors.count(_type);
sensor->set_id(((int64_t)_type << SENSOR_TYPE_SHIFT) | index);
- sensor->set_sensor_handle(handle);
+ sensor->set_sensor_info(info);
sensor->set_sensor_device(device);
std::shared_ptr<sensor_base> sensor_ptr(sensor);
_I("created [%s] sensor", sensor->get_name());
- m_devices[handle] = NULL;
+ m_devices[info] = NULL;
}
return;
}