/*
- * accel_device
- *
- * Copyright (c) 2014 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.
* limitations under the License.
*
*/
+
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <linux/input.h>
#include <util.h>
-#include <macro.h>
#include <sensor_logs.h>
+
#include "accel.h"
#define GRAVITY 9.80665
#define SENSORHUB_ACCELEROMETER_ENABLE_BIT 0
-static const sensor_info_t accel_info = {
- model_name : MODEL_NAME,
- vendor : VENDOR,
- min_range : MIN_RANGE(RESOLUTION) * RAW_DATA_TO_METRE_PER_SECOND_SQUARED_UNIT(RAW_DATA_UNIT),
- max_range : MAX_RANGE(RESOLUTION) * RAW_DATA_TO_METRE_PER_SECOND_SQUARED_UNIT(RAW_DATA_UNIT),
- resolution : RAW_DATA_TO_METRE_PER_SECOND_SQUARED_UNIT(RAW_DATA_UNIT),
- min_interval : MIN_INTERVAL,
- max_batch_count : MAX_BATCH_COUNT,
- wakeup_supported : false,
-};
-
-static const sensor_handle_t handles[] = {
- {
- id: 0x1,
- name: "Accelerometer",
- type: SENSOR_DEVICE_ACCELEROMETER,
- event_type: (SENSOR_DEVICE_ACCELEROMETER << 16) | 0x0001,
- info : accel_info
- },
- {
- id: 0x2,
- name: "Accelerometer RAW",
- type: SENSOR_DEVICE_ACCELEROMETER,
- event_type: (SENSOR_DEVICE_ACCELEROMETER << 16) | 0x0002,
- info : accel_info
- }
+static const sensor_handle_t handle = {
+ id: 0x1,
+ name: "Accelerometer",
+ type: SENSOR_DEVICE_ACCELEROMETER,
+ event_type: (SENSOR_DEVICE_ACCELEROMETER << 16) | 0x0001,
+ model_name: MODEL_NAME,
+ vendor: VENDOR,
+ min_range: MIN_RANGE(RESOLUTION) * RAW_DATA_TO_METRE_PER_SECOND_SQUARED_UNIT(RAW_DATA_UNIT),
+ max_range: MAX_RANGE(RESOLUTION) * RAW_DATA_TO_METRE_PER_SECOND_SQUARED_UNIT(RAW_DATA_UNIT),
+ resolution: RAW_DATA_TO_METRE_PER_SECOND_SQUARED_UNIT(RAW_DATA_UNIT),
+ min_interval: MIN_INTERVAL,
+ max_batch_count: MAX_BATCH_COUNT,
+ wakeup_supported: false
};
-static uint16_t event_ids[] = {
- 0x1,
- 0x2,
-};
+std::vector<uint16_t> accel_device::event_ids;
accel_device::accel_device()
: m_node_handle(-1)
int accel_device::get_sensors(const sensor_handle_t **sensors)
{
- int size = ARRAY_SIZE(handles);
- *sensors = handles;
+ *sensors = &handle;
- return size;
+ return 1;
}
bool accel_device::enable(uint16_t id)
return false;
}
+bool accel_device::set_attribute_str(uint16_t id, char *attribute, char *value, int value_len)
+{
+ return false;
+}
+
bool accel_device::update_value_input_event(void)
{
int accel_raw[3] = {0,};
int accel_device::read_fd(uint16_t **ids)
{
- int size;
-
if (!update_value_input_event()) {
DBG("Failed to update value");
return false;
}
- size = ARRAY_SIZE(event_ids);
+ event_ids.clear();
+ event_ids.push_back(handle.id);
- *ids = event_ids;
+ *ids = &event_ids[0];
- return size;
+ return event_ids.size();
}
int accel_device::get_data(uint16_t id, sensor_data_t **data, int *length)
/*
- * accel_device
- *
- * Copyright (c) 2014 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.
#include <sensor_hal.h>
#include <string>
+#include <vector>
class accel_device : public sensor_device {
public:
bool set_interval(uint16_t id, unsigned long val);
bool set_batch_latency(uint16_t id, unsigned long val);
bool set_attribute(uint16_t id, int32_t attribute, int32_t value);
+ bool set_attribute_str(uint16_t id, char *attribute, char *value, int value_len);
int read_fd(uint16_t **ids);
int get_data(uint16_t id, sensor_data_t **data, int *length);
std::string m_enable_node;
std::string m_interval_node;
+ static std::vector<uint16_t> event_ids;
+
bool update_value_input_event(void);
void raw_to_base(sensor_data_t *data);
};
/*
- * libsensord-share
- *
- * Copyright (c) 2014 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.
/*
- * 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 {
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;
/*
- * libsensord-share
- *
- * Copyright (c) 2014 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.
/*
- * libsensord-share
- *
- * Copyright (c) 2014 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.
return true;
}
-
/*
- * libsensord-share
- *
- * Copyright (c) 2014 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.