INCLUDE(FindPkgConfig)
PKG_CHECK_MODULES(server_pkgs REQUIRED glib-2.0 gio-2.0 dlog libsystemd-daemon libxml-2.0 cynara-client cynara-creds-socket cynara-session)
-add_subdirectory(plugins)
+#add_subdirectory(plugins)
add_definitions(${PLUGIN_DEFS})
+++ /dev/null
-/*
- * sensord
- *
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <sensor_logs.h>
-#include <sf_common.h>
-
-#include <accel_sensor.h>
-#include <sensor_plugin_loader.h>
-#include <algorithm>
-
-using std::bind1st;
-using std::mem_fun;
-using std::string;
-using std::vector;
-
-#define GRAVITY 9.80665
-#define G_TO_MG 1000
-
-#define RAW_DATA_TO_G_UNIT(X) (((float)(X))/((float)G_TO_MG))
-#define RAW_DATA_TO_METRE_PER_SECOND_SQUARED_UNIT(X) (GRAVITY * (RAW_DATA_TO_G_UNIT(X)))
-
-#define SENSOR_NAME "ACCELEROMETER_SENSOR"
-
-accel_sensor::accel_sensor()
-: m_sensor_hal(NULL)
-, m_raw_data_unit(0.0f)
-, m_interval(POLL_1HZ_MS)
-{
- m_name = string(SENSOR_NAME);
-
- vector<unsigned int> supported_events = {
- ACCELEROMETER_RAW_DATA_EVENT,
- ACCELEROMETER_UNPROCESSED_DATA_EVENT,
- };
-
- for_each(supported_events.begin(), supported_events.end(),
- bind1st(mem_fun(&sensor_base::register_supported_event), this));
-
- physical_sensor::set_poller(accel_sensor::working, this);
-}
-
-accel_sensor::~accel_sensor()
-{
- INFO("accel_sensor is destroyed!\n");
-}
-
-bool accel_sensor::init()
-{
- m_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(SENSOR_HAL_TYPE_ACCELEROMETER);
-
- if (!m_sensor_hal) {
- ERR("cannot load sensor_hal[%s]", sensor_base::get_name());
- return false;
- }
-
- sensor_properties_s properties;
-
- if (m_sensor_hal->get_properties(properties) == false) {
- ERR("sensor->get_properties() is failed!\n");
- return false;
- }
-
- m_raw_data_unit = properties.resolution / GRAVITY * G_TO_MG;
-
- INFO("m_raw_data_unit accel : [%f]\n", m_raw_data_unit);
-
- INFO("%s is created!\n", sensor_base::get_name());
- return true;
-}
-
-void accel_sensor::get_types(vector<sensor_type_t> &types)
-{
- types.push_back(ACCELEROMETER_SENSOR);
-}
-
-bool accel_sensor::working(void *inst)
-{
- accel_sensor *sensor = (accel_sensor*)inst;
- return sensor->process_event();
-}
-
-bool accel_sensor::process_event(void)
-{
- sensor_event_t base_event;
-
- if (!m_sensor_hal->is_data_ready())
- return true;
-
- m_sensor_hal->get_sensor_data(base_event.data);
-
- AUTOLOCK(m_mutex);
- AUTOLOCK(m_client_info_mutex);
-
- if (get_client_cnt(ACCELEROMETER_UNPROCESSED_DATA_EVENT)) {
- base_event.sensor_id = get_id();
- base_event.event_type = ACCELEROMETER_UNPROCESSED_DATA_EVENT;
- push(base_event);
- }
-
- if (get_client_cnt(ACCELEROMETER_RAW_DATA_EVENT)) {
- base_event.sensor_id = get_id();
- base_event.event_type = ACCELEROMETER_RAW_DATA_EVENT;
- raw_to_base(base_event.data);
- push(base_event);
- }
-
- return true;
-}
-
-bool accel_sensor::on_start(void)
-{
- if (!m_sensor_hal->enable()) {
- ERR("m_sensor_hal start fail\n");
- return false;
- }
-
- return start_poll();
-}
-
-bool accel_sensor::on_stop(void)
-{
- if (!m_sensor_hal->disable()) {
- ERR("m_sensor_hal stop fail\n");
- return false;
- }
-
- return stop_poll();
-}
-
-bool accel_sensor::get_properties(sensor_type_t sensor_type, sensor_properties_s &properties)
-{
- return m_sensor_hal->get_properties(properties);
-}
-
-int accel_sensor::get_sensor_data(unsigned int type, sensor_data_t &data)
-{
- if (m_sensor_hal->get_sensor_data(data) < 0) {
- ERR("Failed to get sensor data");
- return -1;
- }
-
- if (type == ACCELEROMETER_RAW_DATA_EVENT) {
- raw_to_base(data);
- } else {
- ERR("Does not support type: 0x%x", type);
- return -1;
- }
-
- return 0;
-}
-
-bool accel_sensor::set_interval(unsigned long interval)
-{
- AUTOLOCK(m_mutex);
-
- m_interval = interval;
-
- INFO("Polling interval is set to %dms", interval);
-
- return m_sensor_hal->set_interval(interval);
-}
-
-void accel_sensor::raw_to_base(sensor_data_t &data)
-{
- data.value_count = 3;
- data.values[0] = RAW_DATA_TO_METRE_PER_SECOND_SQUARED_UNIT(data.values[0] * m_raw_data_unit);
- data.values[1] = RAW_DATA_TO_METRE_PER_SECOND_SQUARED_UNIT(data.values[1] * m_raw_data_unit);
- data.values[2] = RAW_DATA_TO_METRE_PER_SECOND_SQUARED_UNIT(data.values[2] * m_raw_data_unit);
-}
+++ /dev/null
-/*
- * sensord
- *
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef _ACCEL_SENSOR_H_
-#define _ACCEL_SENSOR_H_
-
-#include <sensor_common.h>
-
-#include <physical_sensor.h>
-#include <sensor_hal.h>
-
-class accel_sensor : public physical_sensor {
-public:
- accel_sensor();
- virtual ~accel_sensor();
-
- bool init();
- virtual void get_types(std::vector<sensor_type_t> &types);
-
- static bool working(void *inst);
- virtual bool set_interval(unsigned long interval);
- virtual int get_sensor_data(unsigned int type, sensor_data_t &data);
- virtual bool get_properties(sensor_type_t sensor_type, sensor_properties_s &properties);
-
-private:
- sensor_hal *m_sensor_hal;
- cmutex m_value_mutex;
-
- float m_raw_data_unit;
-
- unsigned long m_interval;
-
- virtual bool on_start(void);
- virtual bool on_stop(void);
- void raw_to_base(sensor_data_t &data);
- bool process_event(void);
-};
-
-#endif
+++ /dev/null
-/*
- * sensord
- *
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <sensor_logs.h>
-#include <sf_common.h>
-
-#include <bio_led_red_sensor.h>
-#include <sensor_plugin_loader.h>
-#include <algorithm>
-
-using std::bind1st;
-using std::mem_fun;
-using std::string;
-using std::vector;
-
-#define SENSOR_NAME "BIO_LED_RED_SENSOR"
-
-bio_led_red_sensor::bio_led_red_sensor()
-: m_sensor_hal(NULL)
-{
- m_name = string(SENSOR_NAME);
-
- register_supported_event(BIO_LED_RED_RAW_DATA_EVENT);
-
- physical_sensor::set_poller(bio_led_red_sensor::working, this);
-}
-
-bio_led_red_sensor::~bio_led_red_sensor()
-{
- INFO("bio_led_red_sensor is destroyed!");
-}
-
-bool bio_led_red_sensor::init()
-{
- m_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(SENSOR_HAL_TYPE_BIO_LED_RED);
-
- if (!m_sensor_hal) {
- ERR("cannot load sensor_hal[%s]", sensor_base::get_name());
- return false;
- }
-
- INFO("%s is created!", sensor_base::get_name());
-
- return true;
-}
-
-void bio_led_red_sensor::get_types(vector<sensor_type_t> &types)
-{
- types.push_back(BIO_LED_RED_SENSOR);
-}
-
-bool bio_led_red_sensor::working(void *inst)
-{
- bio_led_red_sensor *sensor = (bio_led_red_sensor*)inst;
- return sensor->process_event();
-}
-
-bool bio_led_red_sensor::process_event(void)
-{
- sensor_event_t event;
-
- if (!m_sensor_hal->is_data_ready())
- return true;
-
- m_sensor_hal->get_sensor_data(event.data);
-
- AUTOLOCK(m_client_info_mutex);
-
- if (get_client_cnt(BIO_LED_RED_RAW_DATA_EVENT)) {
- event.sensor_id = get_id();
- event.event_type = BIO_LED_RED_RAW_DATA_EVENT;
- raw_to_base(event.data);
- push(event);
- }
-
- return true;
-}
-
-bool bio_led_red_sensor::on_start(void)
-{
- if (!m_sensor_hal->enable()) {
- ERR("m_sensor_hal start fail\n");
- return false;
- }
-
- return start_poll();
-}
-
-bool bio_led_red_sensor::on_stop(void)
-{
- if (!m_sensor_hal->disable()) {
- ERR("m_sensor_hal stop fail\n");
- return false;
- }
-
- return stop_poll();
-}
-
-bool bio_led_red_sensor::get_properties(sensor_type_t sensor_type, sensor_properties_s &properties)
-{
- return m_sensor_hal->get_properties(properties);
-}
-
-int bio_led_red_sensor::get_sensor_data(unsigned int type, sensor_data_t &data)
-{
- int ret;
-
- ret = m_sensor_hal->get_sensor_data(data);
-
- if (ret < 0)
- return -1;
-
- return -1;
-}
-
-bool bio_led_red_sensor::set_interval(unsigned long interval)
-{
- AUTOLOCK(m_mutex);
-
- INFO("Polling interval is set to %dms", interval);
-
- return m_sensor_hal->set_interval(interval);
-}
-
-void bio_led_red_sensor::raw_to_base(sensor_data_t &data)
-{
-
-}
+++ /dev/null
-/*
- * sensord
- *
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef _HRM_RED_SENSOR_H_
-#define _HRM_RED_SENSOR_H_
-
-#include <sensor_common.h>
-
-#include <physical_sensor.h>
-#include <sensor_hal.h>
-
-class bio_led_red_sensor : public physical_sensor {
-public:
- bio_led_red_sensor();
- virtual ~bio_led_red_sensor();
-
- bool init();
- virtual void get_types(std::vector<sensor_type_t> &types);
-
- static bool working(void *inst);
- virtual bool set_interval(unsigned long interval);
- virtual bool get_properties(sensor_type_t sensor_type, sensor_properties_s &properties);
- virtual int get_sensor_data(unsigned int type, sensor_data_t &data);
-private:
- sensor_hal *m_sensor_hal;
-
- virtual bool on_start(void);
- virtual bool on_stop(void);
- bool process_event(void);
- void raw_to_base(sensor_data_t &data);
-};
-
-#endif
-
+++ /dev/null
-/*
- * sensord
- *
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <sensor_logs.h>
-#include <sf_common.h>
-
-#include <geo_sensor.h>
-#include <sensor_plugin_loader.h>
-
-using std::string;
-using std::vector;
-
-#define SENSOR_NAME "GEOMAGNETIC_SENSOR"
-
-geo_sensor::geo_sensor()
-: m_sensor_hal(NULL)
-, m_resolution(0.0f)
-{
- m_name = string(SENSOR_NAME);
-
- register_supported_event(GEOMAGNETIC_RAW_DATA_EVENT);
- register_supported_event(GEOMAGNETIC_UNPROCESSED_DATA_EVENT);
-
- physical_sensor::set_poller(geo_sensor::working, this);
-}
-
-geo_sensor::~geo_sensor()
-{
- INFO("geo_sensor is destroyed!\n");
-}
-
-bool geo_sensor::init()
-{
- m_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(SENSOR_HAL_TYPE_GEOMAGNETIC);
-
- if (!m_sensor_hal) {
- ERR("cannot load sensor_hal[%s]", sensor_base::get_name());
- return false;
- }
-
- sensor_properties_s properties;
-
- if (m_sensor_hal->get_properties(properties) == false) {
- ERR("sensor->get_properties() is failed!\n");
- return false;
- }
-
- m_resolution = properties.resolution;
-
- INFO("%s is created!\n", sensor_base::get_name());
-
- return true;
-}
-
-void geo_sensor::get_types(vector<sensor_type_t> &types)
-{
- types.push_back(GEOMAGNETIC_SENSOR);
-}
-
-bool geo_sensor::working(void *inst)
-{
- geo_sensor *sensor = (geo_sensor*)inst;
- return sensor->process_event();
-}
-
-bool geo_sensor::process_event(void)
-{
- sensor_event_t event;
-
- if (!m_sensor_hal->is_data_ready())
- return true;
-
- m_sensor_hal->get_sensor_data(event.data);
-
- AUTOLOCK(m_client_info_mutex);
- AUTOLOCK(m_mutex);
-
- if (get_client_cnt(GEOMAGNETIC_UNPROCESSED_DATA_EVENT)) {
- event.sensor_id = get_id();
- event.event_type = GEOMAGNETIC_UNPROCESSED_DATA_EVENT;
- push(event);
- }
-
- if (get_client_cnt(GEOMAGNETIC_RAW_DATA_EVENT)) {
- event.sensor_id = get_id();
- event.event_type = GEOMAGNETIC_RAW_DATA_EVENT;
- raw_to_base(event.data);
- push(event);
- }
-
- return true;
-}
-
-bool geo_sensor::on_start(void)
-{
- if (!m_sensor_hal->enable()) {
- ERR("m_sensor_hal start fail\n");
- return false;
- }
-
- return start_poll();
-}
-
-bool geo_sensor::on_stop(void)
-{
- if (!m_sensor_hal->disable()) {
- ERR("m_sensor_hal stop fail\n");
- return false;
- }
-
- return stop_poll();
-}
-
-bool geo_sensor::get_properties(sensor_type_t sensor_type, sensor_properties_s &properties)
-{
- return m_sensor_hal->get_properties(properties);
-}
-
-int geo_sensor::get_sensor_data(unsigned int type, sensor_data_t &data)
-{
- int state;
-
- if (type != GEOMAGNETIC_RAW_DATA_EVENT)
- return -1;
-
- state = m_sensor_hal->get_sensor_data(data);
- raw_to_base(data);
-
- if (state < 0) {
- ERR("m_sensor_hal get struct_data fail\n");
- return -1;
- }
-
- return 0;
-}
-
-bool geo_sensor::set_interval(unsigned long interval)
-{
- AUTOLOCK(m_mutex);
-
- INFO("Polling interval is set to %dms", interval);
-
- return m_sensor_hal->set_interval(interval);
-}
-
-void geo_sensor::raw_to_base(sensor_data_t &data)
-{
- data.value_count = 3;
- data.values[0] = data.values[0] * m_resolution;
- data.values[1] = data.values[1] * m_resolution;
- data.values[2] = data.values[2] * m_resolution;
-}
+++ /dev/null
-/*
- * sensord
- *
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef _GEO_SENSOR_H_
-#define _GEO_SENSOR_H_
-
-#include <sensor_common.h>
-
-#include <physical_sensor.h>
-#include <sensor_hal.h>
-
-class geo_sensor : public physical_sensor {
-public:
- geo_sensor();
- virtual ~geo_sensor();
-
- virtual bool init();
- virtual void get_types(std::vector<sensor_type_t> &types);
-
- static bool working(void *inst);
-
- virtual bool set_interval(unsigned long interval);
- int get_sensor_data(unsigned int type, sensor_data_t &data);
- virtual bool get_properties(sensor_type_t sensor_type, sensor_properties_s &properties);
-private:
- sensor_hal *m_sensor_hal;
-
- float m_resolution;
-
- virtual bool on_start(void);
- virtual bool on_stop(void);
- bool process_event(void);
- void raw_to_base(sensor_data_t &data);
-};
-
-#endif
-
+++ /dev/null
-/*
- * sensord
- *
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <sensor_logs.h>
-#include <sf_common.h>
-
-#include <gyro_sensor.h>
-#include <sensor_plugin_loader.h>
-
-using std::string;
-using std::vector;
-
-#define MS_TO_US 1000
-#define DPS_TO_MDPS 1000
-#define RAW_DATA_TO_DPS_UNIT(X) ((float)(X)/((float)DPS_TO_MDPS))
-
-#define SENSOR_NAME "GYROSCOPE_SENSOR"
-
-gyro_sensor::gyro_sensor()
-: m_sensor_hal(NULL)
-, m_resolution(0.0f)
-{
- m_name = string(SENSOR_NAME);
-
- register_supported_event(GYROSCOPE_RAW_DATA_EVENT);
- register_supported_event(GYROSCOPE_UNPROCESSED_DATA_EVENT);
-
- physical_sensor::set_poller(gyro_sensor::working, this);
-}
-
-gyro_sensor::~gyro_sensor()
-{
- INFO("gyro_sensor is destroyed!\n");
-}
-
-bool gyro_sensor::init()
-{
- m_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(SENSOR_HAL_TYPE_GYROSCOPE);
-
- if (!m_sensor_hal) {
- ERR("cannot load sensor_hal[%s]", sensor_base::get_name());
- return false;
- }
-
- sensor_properties_s properties;
-
- if (m_sensor_hal->get_properties(properties) == false) {
- ERR("sensor->get_properties() is failed!\n");
- return false;
- }
-
- m_resolution = properties.resolution;
-
- INFO("%s is created!\n", sensor_base::get_name());
-
- return true;
-}
-
-void gyro_sensor::get_types(vector<sensor_type_t> &types)
-{
- types.push_back(GYROSCOPE_SENSOR);
-}
-
-bool gyro_sensor::working(void *inst)
-{
- gyro_sensor *sensor = (gyro_sensor*)inst;
- return sensor->process_event();;
-}
-
-bool gyro_sensor::process_event(void)
-{
- sensor_event_t event;
-
- if (m_sensor_hal->is_data_ready() == false)
- return true;
-
- m_sensor_hal->get_sensor_data(event.data);
-
- AUTOLOCK(m_client_info_mutex);
-
- if (get_client_cnt(GYROSCOPE_UNPROCESSED_DATA_EVENT)) {
- event.sensor_id = get_id();
- event.event_type = GYROSCOPE_UNPROCESSED_DATA_EVENT;
- push(event);
- }
-
- if (get_client_cnt(GYROSCOPE_RAW_DATA_EVENT)) {
- event.sensor_id = get_id();
- event.event_type = GYROSCOPE_RAW_DATA_EVENT;
- raw_to_base(event.data);
- push(event);
- }
-
- return true;
-}
-
-bool gyro_sensor::on_start(void)
-{
- if (!m_sensor_hal->enable()) {
- ERR("m_sensor_hal start fail\n");
- return false;
- }
-
- return start_poll();
-}
-
-bool gyro_sensor::on_stop(void)
-{
- if (!m_sensor_hal->disable()) {
- ERR("m_sensor_hal stop fail\n");
- return false;
- }
-
- return stop_poll();
-}
-
-bool gyro_sensor::get_properties(sensor_type_t sensor_type, sensor_properties_s &properties)
-{
- return m_sensor_hal->get_properties(properties);
-}
-
-int gyro_sensor::get_sensor_data(unsigned int type, sensor_data_t &data)
-{
- int state;
-
- if (type != GYROSCOPE_RAW_DATA_EVENT)
- return -1;
-
- state = m_sensor_hal->get_sensor_data(data);
-
- if (state < 0) {
- ERR("m_sensor_hal get struct_data fail\n");
- return -1;
- }
-
- raw_to_base(data);
-
- return 0;
-}
-
-bool gyro_sensor::set_interval(unsigned long interval)
-{
- AUTOLOCK(m_mutex);
-
- INFO("Polling interval is set to %dms", interval);
-
- return m_sensor_hal->set_interval(interval);
-}
-
-void gyro_sensor::raw_to_base(sensor_data_t &data)
-{
- data.value_count = 3;
- data.values[0] = data.values[0] * m_resolution;
- data.values[1] = data.values[1] * m_resolution;
- data.values[2] = data.values[2] * m_resolution;
-}
+++ /dev/null
-/*
- * sensord
- *
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef _GYRO_SENSOR_H_
-#define _GYRO_SENSOR_H_
-
-#include <sensor_common.h>
-
-#include <physical_sensor.h>
-#include <sensor_hal.h>
-
-class gyro_sensor : public physical_sensor {
-public:
- gyro_sensor();
- virtual ~gyro_sensor();
-
- virtual bool init();
- virtual void get_types(std::vector<sensor_type_t> &types);
-
- static bool working(void *inst);
-
- virtual bool set_interval(unsigned long interval);
- int get_sensor_data(unsigned int type, sensor_data_t &data);
- virtual bool get_properties(sensor_type_t sensor_type, sensor_properties_s &properties);
-private:
- sensor_hal *m_sensor_hal;
- float m_resolution;
-
- virtual bool on_start(void);
- virtual bool on_stop(void);
- void raw_to_base(sensor_data_t &data);
- bool process_event(void);
-};
-
-#endif
+++ /dev/null
-/*
- * sensord
- *
- * Copyright (c) 2015 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
-#include <math.h>
-#include <time.h>
-#include <sys/types.h>
-#include <dlfcn.h>
-#include <sensor_logs.h>
-#include <sf_common.h>
-#include <gyroscope_uncal_sensor.h>
-#include <sensor_plugin_loader.h>
-#include <orientation_filter.h>
-#include <cvirtual_sensor_config.h>
-
-using std::vector;
-using std::string;
-
-#define SENSOR_NAME "GYROSCOPE_UNCAL_SENSOR"
-#define SENSOR_TYPE_GYROSCOPE_UNCAL "GYROSCOPE_UNCAL"
-
-#define GYROSCOPE_ENABLED 0x01
-#define GYRO_BIAS_ENABLED 0x02
-#define GYROSCOPE_UNCAL_BIAS_ENABLED 3
-
-#define INITIAL_VALUE -1
-
-#define MS_TO_US 1000
-#define MIN_DELIVERY_DIFF_FACTOR 0.75f
-
-#define PI 3.141593
-#define AZIMUTH_OFFSET_DEGREES 360
-#define AZIMUTH_OFFSET_RADIANS (2 * PI)
-
-#define ELEMENT_NAME "NAME"
-#define ELEMENT_VENDOR "VENDOR"
-#define ELEMENT_RAW_DATA_UNIT "RAW_DATA_UNIT"
-#define ELEMENT_DEFAULT_SAMPLING_TIME "DEFAULT_SAMPLING_TIME"
-
-gyroscope_uncal_sensor::gyroscope_uncal_sensor()
-: m_accel_sensor(NULL)
-, m_magnetic_sensor(NULL)
-, m_gyro_sensor(NULL)
-, m_fusion_sensor(NULL)
-, m_time(0)
-{
- cvirtual_sensor_config &config = cvirtual_sensor_config::get_instance();
-
- sensor_hal *fusion_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(SENSOR_HAL_TYPE_FUSION);
- if (!fusion_sensor_hal)
- m_hardware_fusion = false;
- else
- m_hardware_fusion = true;
-
- m_name = string(SENSOR_NAME);
- register_supported_event(GYROSCOPE_UNCAL_RAW_DATA_EVENT);
-
- if (!config.get(SENSOR_TYPE_GYROSCOPE_UNCAL, ELEMENT_VENDOR, m_vendor)) {
- ERR("[VENDOR] is empty\n");
- throw ENXIO;
- }
-
- INFO("m_vendor = %s", m_vendor.c_str());
-
- if (!config.get(SENSOR_TYPE_GYROSCOPE_UNCAL, ELEMENT_RAW_DATA_UNIT, m_raw_data_unit)) {
- ERR("[RAW_DATA_UNIT] is empty\n");
- throw ENXIO;
- }
-
- INFO("m_raw_data_unit = %s", m_raw_data_unit.c_str());
-
- if (!config.get(SENSOR_TYPE_GYROSCOPE_UNCAL, ELEMENT_DEFAULT_SAMPLING_TIME, &m_default_sampling_time)) {
- ERR("[DEFAULT_SAMPLING_TIME] is empty\n");
- throw ENXIO;
- }
-
- INFO("m_default_sampling_time = %d", m_default_sampling_time);
-
- m_interval = m_default_sampling_time * MS_TO_US;
-}
-
-gyroscope_uncal_sensor::~gyroscope_uncal_sensor()
-{
- INFO("gyroscope_uncal_sensor is destroyed!\n");
-}
-
-bool gyroscope_uncal_sensor::init(void)
-{
- m_accel_sensor = sensor_plugin_loader::get_instance().get_sensor(ACCELEROMETER_SENSOR);
- m_gyro_sensor = sensor_plugin_loader::get_instance().get_sensor(GYROSCOPE_SENSOR);
- m_magnetic_sensor = sensor_plugin_loader::get_instance().get_sensor(GEOMAGNETIC_SENSOR);
-
- m_fusion_sensor = sensor_plugin_loader::get_instance().get_sensor(FUSION_SENSOR);
-
- if (!m_accel_sensor || !m_gyro_sensor || !m_magnetic_sensor || !m_fusion_sensor) {
- ERR("Failed to load sensors, accel: 0x%x, gyro: 0x%x, mag: 0x%x, fusion: 0x%x",
- m_accel_sensor, m_gyro_sensor, m_magnetic_sensor, m_fusion_sensor);
- return false;
- }
-
- INFO("%s is created!\n", sensor_base::get_name());
-
- return true;
-}
-
-void gyroscope_uncal_sensor::get_types(vector<sensor_type_t> &types)
-{
- types.push_back(GYROSCOPE_UNCAL_SENSOR);
-}
-
-bool gyroscope_uncal_sensor::on_start(void)
-{
- AUTOLOCK(m_mutex);
-
- if (!m_hardware_fusion) {
- m_accel_sensor->add_client(ACCELEROMETER_RAW_DATA_EVENT);
- m_accel_sensor->add_interval((intptr_t)this, (m_interval/MS_TO_US), false);
- m_accel_sensor->start();
- m_gyro_sensor->add_client(GYROSCOPE_RAW_DATA_EVENT);
- m_gyro_sensor->add_interval((intptr_t)this, (m_interval/MS_TO_US), false);
- m_gyro_sensor->start();
- m_magnetic_sensor->add_client(GEOMAGNETIC_RAW_DATA_EVENT);
- m_magnetic_sensor->add_interval((intptr_t)this, (m_interval/MS_TO_US), false);
- m_magnetic_sensor->start();
- }
-
- m_fusion_sensor->register_supported_event(FUSION_GYROSCOPE_UNCAL_EVENT);
- m_fusion_sensor->register_supported_event(FUSION_GYROSCOPE_UNCAL_ENABLED);
- m_fusion_sensor->add_client(FUSION_GYROSCOPE_UNCAL_EVENT);
- m_fusion_sensor->add_interval((intptr_t)this, (m_interval/MS_TO_US), false);
- m_fusion_sensor->start();
-
- activate();
- return true;
-}
-
-bool gyroscope_uncal_sensor::on_stop(void)
-{
- AUTOLOCK(m_mutex);
-
- if (!m_hardware_fusion) {
- m_accel_sensor->delete_client(ACCELEROMETER_RAW_DATA_EVENT);
- m_accel_sensor->delete_interval((intptr_t)this, false);
- m_accel_sensor->stop();
- m_gyro_sensor->delete_client(GYROSCOPE_RAW_DATA_EVENT);
- m_gyro_sensor->delete_interval((intptr_t)this, false);
- m_gyro_sensor->stop();
- m_magnetic_sensor->delete_client(GEOMAGNETIC_RAW_DATA_EVENT);
- m_magnetic_sensor->delete_interval((intptr_t)this, false);
- m_magnetic_sensor->stop();
- }
-
- m_fusion_sensor->delete_client(FUSION_GYROSCOPE_UNCAL_EVENT);
- m_fusion_sensor->delete_interval((intptr_t)this, false);
- m_fusion_sensor->unregister_supported_event(FUSION_GYROSCOPE_UNCAL_EVENT);
- m_fusion_sensor->unregister_supported_event(FUSION_GYROSCOPE_UNCAL_ENABLED);
- m_fusion_sensor->stop();
-
- deactivate();
- return true;
-}
-
-bool gyroscope_uncal_sensor::add_interval(int client_id, unsigned int interval)
-{
- AUTOLOCK(m_mutex);
-
- if (!m_hardware_fusion) {
- m_accel_sensor->add_interval(client_id, interval, false);
- m_gyro_sensor->add_interval(client_id, interval, false);
- m_magnetic_sensor->add_interval(client_id, interval, false);
- }
-
- m_fusion_sensor->add_interval(client_id, interval, false);
-
- return sensor_base::add_interval(client_id, interval, false);
-}
-
-bool gyroscope_uncal_sensor::delete_interval(int client_id)
-{
- AUTOLOCK(m_mutex);
-
- if (!m_hardware_fusion) {
- m_accel_sensor->delete_interval(client_id, false);
- m_gyro_sensor->delete_interval(client_id, false);
- m_magnetic_sensor->delete_interval(client_id, false);
- }
-
- m_fusion_sensor->delete_interval(client_id, false);
-
- return sensor_base::delete_interval(client_id, false);
-}
-
-void gyroscope_uncal_sensor::synthesize(const sensor_event_t &event, vector<sensor_event_t> &outs)
-{
- sensor_event_t gyroscope_uncal_event;
- unsigned long long diff_time;
-
- if (event.event_type == GYROSCOPE_RAW_DATA_EVENT) {
- diff_time = event.data.timestamp - m_time;
-
- if (m_time && (diff_time < m_interval * MIN_DELIVERY_DIFF_FACTOR))
- return;
-
- m_gyro.m_data.m_vec[0] = event.data.values[0];
- m_gyro.m_data.m_vec[1] = event.data.values[1];
- m_gyro.m_data.m_vec[2] = event.data.values[2];
-
- m_gyro.m_time_stamp = event.data.timestamp;
-
- m_enable_gyroscope_uncal |= GYROSCOPE_ENABLED;
- }
-
- if (event.event_type == FUSION_GYROSCOPE_UNCAL_EVENT) {
- diff_time = event.data.timestamp - m_time;
-
- if (m_time && (diff_time < m_interval * MIN_DELIVERY_DIFF_FACTOR))
- return;
-
- m_fusion.m_data.m_vec[0] = event.data.values[0];
- m_fusion.m_data.m_vec[1] = event.data.values[1];
- m_fusion.m_data.m_vec[2] = event.data.values[2];
-
- m_fusion.m_time_stamp = event.data.timestamp;
-
- m_enable_gyroscope_uncal |= GYRO_BIAS_ENABLED;
- }
-
- if (m_enable_gyroscope_uncal == GYROSCOPE_UNCAL_BIAS_ENABLED) {
- m_enable_gyroscope_uncal = 0;
-
- m_time = get_timestamp();
- gyroscope_uncal_event.sensor_id = get_id();
- gyroscope_uncal_event.event_type = GYROSCOPE_UNCAL_RAW_DATA_EVENT;
- gyroscope_uncal_event.data.value_count = 6;
- gyroscope_uncal_event.data.timestamp = m_time;
- gyroscope_uncal_event.data.accuracy = SENSOR_ACCURACY_GOOD;
- gyroscope_uncal_event.data.values[0] = m_gyro.m_data.m_vec[0];
- gyroscope_uncal_event.data.values[1] = m_gyro.m_data.m_vec[1];
- gyroscope_uncal_event.data.values[2] = m_gyro.m_data.m_vec[2];
-
- gyroscope_uncal_event.data.values[3] = m_fusion.m_data.m_vec[0];
- gyroscope_uncal_event.data.values[4] = m_fusion.m_data.m_vec[1];
- gyroscope_uncal_event.data.values[5] = m_fusion.m_data.m_vec[2];
-
- push(gyroscope_uncal_event);
- }
-
- return;
-}
-
-int gyroscope_uncal_sensor::get_sensor_data(const unsigned int event_type, sensor_data_t &data)
-{
- sensor_data_t fusion_data, gyro_data;
-
- if (event_type != GYROSCOPE_UNCAL_RAW_DATA_EVENT)
- return -1;
-
- m_fusion_sensor->get_sensor_data(FUSION_GYROSCOPE_UNCAL_ENABLED, fusion_data);
- m_gyro_sensor->get_sensor_data(GYROSCOPE_RAW_DATA_EVENT, gyro_data);
-
- data.accuracy = fusion_data.accuracy;
- data.timestamp = get_timestamp();
- data.value_count = 6;
- data.values[0] = gyro_data.values[0];
- data.values[1] = gyro_data.values[1];
- data.values[2] = gyro_data.values[2];
- data.values[3] = fusion_data.values[0];
- data.values[4] = fusion_data.values[1];
- data.values[5] = fusion_data.values[2];
-
- return 0;
-}
-
-bool gyroscope_uncal_sensor::get_properties(sensor_type_t sensor_type, sensor_properties_s &properties)
-{
- properties.resolution = 0.000001;
- properties.vendor = m_vendor;
- properties.name = SENSOR_NAME;
- properties.min_interval = 1;
- properties.fifo_count = 0;
- properties.max_batch_count = 0;
-
- return true;
-}
+++ /dev/null
-/*
- * sensord
- *
- * Copyright (c) 2015 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef _GYROSCOPE_UNCAL_SENSOR_H_
-#define _GYROSCOPE_UNCAL_SENSOR_H_
-
-#include <sensor_internal.h>
-#include <virtual_sensor.h>
-#include <orientation_filter.h>
-
-class gyroscope_uncal_sensor : public virtual_sensor {
-public:
- gyroscope_uncal_sensor();
- virtual ~gyroscope_uncal_sensor();
-
- bool init(void);
-
- void synthesize(const sensor_event_t &event, vector<sensor_event_t> &outs);
-
- bool add_interval(int client_id, unsigned int interval);
- bool delete_interval(int client_id);
- virtual bool get_properties(sensor_type_t sensor_type, sensor_properties_s &properties);
- virtual void get_types(std::vector<sensor_type_t> &types);
-
- int get_sensor_data(const unsigned int event_type, sensor_data_t &data);
-
-private:
- sensor_base *m_accel_sensor;
- sensor_base *m_magnetic_sensor;
- sensor_base *m_gyro_sensor;
- sensor_base *m_fusion_sensor;
-
- sensor_data<float> m_fusion;
- sensor_data<float> m_gyro;
-
- cmutex m_value_mutex;
-
- unsigned int m_enable_gyroscope_uncal;
-
- unsigned long long m_time;
- unsigned int m_interval;
-
- std::string m_vendor;
- std::string m_raw_data_unit;
- int m_default_sampling_time;
- float m_gyro_static_bias[3];
- int m_gyro_rotation_direction_compensation[3];
- float m_gyro_scale;
-
- bool on_start(void);
- bool on_stop(void);
-};
-
-#endif /*_GYROSCOPE_UNCAL_SENSOR_H_*/
+++ /dev/null
-/*
- * sensord
- *
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <sensor_logs.h>
-#include <sf_common.h>
-#include <light_sensor.h>
-#include <sensor_plugin_loader.h>
-#include <algorithm>
-#include <string>
-
-using std::bind1st;
-using std::mem_fun;
-using std::string;
-using std::vector;
-
-#define SENSOR_NAME "LIGHT_SENSOR"
-
-#define INITIAL_VALUE -1
-const int light_sensor::m_light_level[] = {0, 1, 165, 288, 497, 869, 1532, 2692, 4692, 8280, 21428, 65535, 137852};
-
-light_sensor::light_sensor()
-: m_sensor_hal(NULL)
-, m_level(INITIAL_VALUE)
-{
- m_name = string(SENSOR_NAME);
-
- vector<unsigned int> supported_events = {
- LIGHT_CHANGE_LEVEL_EVENT,
- LIGHT_LEVEL_DATA_EVENT,
- LIGHT_LUX_DATA_EVENT,
- };
-
- for_each(supported_events.begin(), supported_events.end(),
- bind1st(mem_fun(&sensor_base::register_supported_event), this));
-
- physical_sensor::set_poller(light_sensor::working, this);
-}
-
-light_sensor::~light_sensor()
-{
- INFO("light_sensor is destroyed!");
-}
-
-bool light_sensor::init()
-{
- m_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(SENSOR_HAL_TYPE_LIGHT);
-
- if (!m_sensor_hal) {
- ERR("cannot load sensor_hal[%s]", sensor_base::get_name());
- return false;
- }
-
- INFO("%s is created!", sensor_base::get_name());
-
- return true;
-}
-
-void light_sensor::get_types(vector<sensor_type_t> &types)
-{
- types.push_back(LIGHT_SENSOR);
-}
-
-bool light_sensor::working(void *inst)
-{
- light_sensor *sensor = (light_sensor *)inst;
- return sensor->process_event();
-}
-
-bool light_sensor::process_event(void)
-{
- sensor_event_t event;
- int level;
-
- if (!m_sensor_hal->is_data_ready())
- return true;
-
- m_sensor_hal->get_sensor_data(event.data);
- level = (int) adc_to_light_level((int)event.data.values[0]);
-
- AUTOLOCK(m_client_info_mutex);
-
- event.sensor_id = get_id();
- if (get_client_cnt(LIGHT_LUX_DATA_EVENT)) {
- event.event_type = LIGHT_LUX_DATA_EVENT;
- push(event);
- }
-
- if (get_client_cnt(LIGHT_LEVEL_DATA_EVENT)) {
- event.event_type = LIGHT_LEVEL_DATA_EVENT;
- raw_to_level(event.data);
- push(event);
- }
-
- if (m_level != level) {
- m_level = level;
-
- if (get_client_cnt(LIGHT_CHANGE_LEVEL_EVENT)) {
- event.event_type = LIGHT_CHANGE_LEVEL_EVENT;
- raw_to_level(event.data);
- push(event);
- }
- }
-
- return true;
-}
-
-int light_sensor::adc_to_light_level(int adc)
-{
- int level_cnt = sizeof(m_light_level) / sizeof(m_light_level[0]) - 1;
-
- for (int i = 0; i < level_cnt; ++i) {
- if (adc >= m_light_level[i] && adc < m_light_level[i + 1])
- return i;
- }
-
- return -1;
-}
-
-bool light_sensor::on_start(void)
-{
- if (!m_sensor_hal->enable()) {
- ERR("m_sensor_hal start fail");
- return false;
- }
-
- return start_poll();
-}
-
-bool light_sensor::on_stop(void)
-{
- if (!m_sensor_hal->disable()) {
- ERR("m_sensor_hal stop fail");
- return false;
- }
-
- return stop_poll();
-}
-
-bool light_sensor::get_properties(sensor_type_t sensor_type, sensor_properties_s &properties)
-{
- m_sensor_hal->get_properties(properties);
- return true;
-}
-
-int light_sensor::get_sensor_data(unsigned int type, sensor_data_t &data)
-{
- int ret;
- ret = m_sensor_hal->get_sensor_data(data);
-
- if (ret < 0)
- return -1;
-
- if (type == LIGHT_LUX_DATA_EVENT)
- return 0;
-
- if (type == LIGHT_LEVEL_DATA_EVENT) {
- raw_to_level(data);
- return 0;
- }
-
- return -1;
-}
-
-bool light_sensor::set_interval(unsigned long interval)
-{
- AUTOLOCK(m_mutex);
-
- INFO("Polling interval is set to %dms", interval);
-
- return m_sensor_hal->set_interval(interval);
-}
-
-void light_sensor::raw_to_level(sensor_data_t &data)
-{
- data.values[0] = (int) adc_to_light_level((int)data.values[0]);
- data.value_count = 1;
-}
+++ /dev/null
-/*
- * sensord
- *
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef _LIGHT_SENSOR_H_
-#define _LIGHT_SENSOR_H_
-
-#include <sensor_common.h>
-#include <physical_sensor.h>
-#include <sensor_hal.h>
-
-class light_sensor : public physical_sensor {
-public:
- light_sensor();
- virtual ~light_sensor();
-
- virtual bool init();
- virtual void get_types(std::vector<sensor_type_t> &types);
-
- static bool working(void *inst);
-
- virtual bool set_interval(unsigned long interval);
- int get_sensor_data(const unsigned int type, sensor_data_t &data);
- virtual bool get_properties(sensor_type_t sensor_type, sensor_properties_s &properties);
-private:
- static const int m_light_level[];
-
- sensor_hal *m_sensor_hal;
- int m_level;
-
- virtual bool on_start(void);
- virtual bool on_stop(void);
-
- bool process_event(void);
- int adc_to_light_level(int adc);
-
- void raw_to_level(sensor_data_t &data);
- void raw_to_state(sensor_data_t &data);
-};
-#endif /*_LIGHT_SENSOR_H_*/
+++ /dev/null
-/*
- * sensord
- *
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <sensor_logs.h>
-#include <sf_common.h>
-#include <pressure_sensor.h>
-#include <sensor_plugin_loader.h>
-
-using std::bind1st;
-using std::mem_fun;
-using std::string;
-using std::vector;
-
-#define SENSOR_NAME "PRESSURE_SENSOR"
-#define SENSOR_TYPE_PRESSURE "PRESSURE"
-#define ELEMENT_NAME "NAME"
-#define ELEMENT_VENDOR "VENDOR"
-#define ATTR_VALUE "value"
-
-pressure_sensor::pressure_sensor()
-: m_sensor_hal(NULL)
-, m_pressure(0.0f)
-, m_resolution(0.0f)
-{
- m_name = string(SENSOR_NAME);
-
- register_supported_event(PRESSURE_RAW_DATA_EVENT);
-
- physical_sensor::set_poller(pressure_sensor::working, this);
-}
-
-pressure_sensor::~pressure_sensor()
-{
- INFO("pressure_sensor is destroyed!");
-}
-
-bool pressure_sensor::init()
-{
- m_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(SENSOR_HAL_TYPE_PRESSURE);
-
- if (!m_sensor_hal) {
- ERR("cannot load sensor_hal[%s]", sensor_base::get_name());
- return false;
- }
-
- sensor_properties_s properties;
-
- if (!m_sensor_hal->get_properties(properties)) {
- ERR("sensor->get_properties() is failed!\n");
- return false;
- }
-
- m_resolution = properties.resolution;
-
- string model_id = m_sensor_hal->get_model_id();
-
- INFO("%s is created!", sensor_base::get_name());
-
- return true;
-}
-
-void pressure_sensor::get_types(vector<sensor_type_t> &types)
-{
- types.push_back(PRESSURE_SENSOR);
-}
-
-bool pressure_sensor::working(void *inst)
-{
- pressure_sensor *sensor = (pressure_sensor*)inst;
- return sensor->process_event();
-}
-
-bool pressure_sensor::process_event(void)
-{
- sensor_event_t event;
-
- if (!m_sensor_hal->is_data_ready())
- return true;
-
- m_sensor_hal->get_sensor_data(event.data);
-
- AUTOLOCK(m_client_info_mutex);
-
- if (get_client_cnt(PRESSURE_RAW_DATA_EVENT)) {
- event.sensor_id = get_id();
- event.event_type = PRESSURE_RAW_DATA_EVENT;
- push(event);
- }
-
- return true;
-}
-
-bool pressure_sensor::on_start(void)
-{
- if (!m_sensor_hal->enable()) {
- ERR("m_sensor_hal start fail\n");
- return false;
- }
-
- return start_poll();
-}
-
-bool pressure_sensor::on_stop(void)
-{
- if (!m_sensor_hal->disable()) {
- ERR("m_sensor_hal stop fail\n");
- return false;
- }
-
- return stop_poll();
-}
-
-bool pressure_sensor::get_properties(sensor_type_t sensor_type, sensor_properties_s &properties)
-{
- return m_sensor_hal->get_properties(properties);
-}
-
-int pressure_sensor::get_sensor_data(unsigned int type, sensor_data_t &data)
-{
- return m_sensor_hal->get_sensor_data(data);
-}
-
-bool pressure_sensor::set_interval(unsigned long interval)
-{
- AUTOLOCK(m_mutex);
-
- INFO("Polling interval is set to %dms", interval);
-
- return m_sensor_hal->set_interval(interval);
-}
+++ /dev/null
-/*
- * sensord
- *
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef _PRESSURE_SENSOR_H_
-#define _PRESSURE_SENSOR_H_
-
-#include <sensor_common.h>
-
-#include <physical_sensor.h>
-#include <sensor_hal.h>
-
-class pressure_sensor : public physical_sensor {
-public:
- pressure_sensor();
- virtual ~pressure_sensor();
-
- bool init();
- virtual void get_types(std::vector<sensor_type_t> &types);
-
- static bool working(void *inst);
-
- bool set_interval(unsigned long interval);
- int get_sensor_data(unsigned int type, sensor_data_t &data);
- virtual bool get_properties(sensor_type_t sensor_type, sensor_properties_s &properties);
-
-private:
- sensor_hal *m_sensor_hal;
- float m_pressure;
- float m_resolution;
-
- virtual bool on_start(void);
- virtual bool on_stop(void);
- bool process_event(void);
-
-};
-
-#endif
+++ /dev/null
-/*
- * sensord
- *
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <sensor_logs.h>
-#include <sf_common.h>
-#include <proxi_sensor.h>
-#include <sensor_plugin_loader.h>
-
-using std::string;
-using std::vector;
-
-#define SENSOR_NAME "PROXI_SENSOR"
-
-proxi_sensor::proxi_sensor()
-: m_sensor_hal(NULL)
-, m_state(PROXIMITY_STATE_FAR)
-{
- m_name = string(SENSOR_NAME);
-
- register_supported_event(PROXIMITY_CHANGE_STATE_EVENT);
- register_supported_event(PROXIMITY_STATE_EVENT);
- register_supported_event(PROXIMITY_DISTANCE_DATA_EVENT);
-
- physical_sensor::set_poller(proxi_sensor::working, this);
-}
-
-proxi_sensor::~proxi_sensor()
-{
- INFO("proxi_sensor is destroyed!\n");
-}
-
-bool proxi_sensor::init()
-{
- m_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(SENSOR_HAL_TYPE_PROXIMITY);
-
- if (!m_sensor_hal) {
- ERR("cannot load sensor_hal[%s]", sensor_base::get_name());
- return false;
- }
-
- INFO("%s is created!\n", sensor_base::get_name());
- return true;
-}
-
-void proxi_sensor::get_types(vector<sensor_type_t> &types)
-{
- types.push_back(PROXIMITY_SENSOR);
-}
-
-bool proxi_sensor::working(void *inst)
-{
- proxi_sensor *sensor = (proxi_sensor*)inst;
- return sensor->process_event();
-}
-
-bool proxi_sensor::process_event(void)
-{
- sensor_event_t event;
- int state;
-
- if (!m_sensor_hal->is_data_ready())
- return true;
-
- m_sensor_hal->get_sensor_data(event.data);
-
- AUTOLOCK(m_client_info_mutex);
- AUTOLOCK(m_mutex);
-
- if (event.data.values[0] == PROXIMITY_NODE_STATE_FAR) {
- INFO("PROXIMITY_STATE_FAR state occured\n");
- event.data.values[0] = PROXIMITY_STATE_FAR;
- } else if (event.data.values[0] == PROXIMITY_NODE_STATE_NEAR) {
- INFO("PROXIMITY_STATE_NEAR state occured\n");
- event.data.values[0] = PROXIMITY_STATE_NEAR;
- } else {
- ERR("PROXIMITY_STATE Unknown: %d\n",event.data.values[0]);
- return false;
- }
-
- event.sensor_id = get_id();
- if (get_client_cnt(PROXIMITY_DISTANCE_DATA_EVENT)) {
- event.event_type = PROXIMITY_DISTANCE_DATA_EVENT;
- raw_to_base(event.data);
- push(event);
- }
-
- state = event.data.values[0];
-
- if (m_state != state) {
- AUTOLOCK(m_value_mutex);
- m_state = state;
-
- if (get_client_cnt(PROXIMITY_CHANGE_STATE_EVENT)) {
- event.event_type = PROXIMITY_CHANGE_STATE_EVENT;
- raw_to_base(event.data);
- push(event);
- }
- }
-
- return true;
-}
-
-bool proxi_sensor::on_start(void)
-{
- if (!m_sensor_hal->enable()) {
- ERR("m_sensor_hal start fail\n");
- return false;
- }
-
- return start_poll();
-}
-
-bool proxi_sensor::on_stop(void)
-{
- if (!m_sensor_hal->disable()) {
- ERR("m_sensor_hal stop fail\n");
- return false;
- }
-
- return stop_poll();
-}
-
-bool proxi_sensor::get_properties(sensor_type_t sensor_type, sensor_properties_s &properties)
-{
- m_sensor_hal->get_properties(properties);
-
- properties.min_range = properties.min_range * 5;
- properties.max_range = properties.max_range * 5;
-
- return true;
-}
-
-int proxi_sensor::get_sensor_data(unsigned int type, sensor_data_t &data)
-{
- int state;
-
- if ((type != PROXIMITY_CHANGE_STATE_EVENT) && (type != PROXIMITY_STATE_EVENT))
- return -1;
-
- state = m_sensor_hal->get_sensor_data(data);
-
- if (state < 0) {
- ERR("m_sensor_hal get struct_data fail\n");
- return -1;
- }
-
- raw_to_base(data);
-
- return 0;
-}
-
-void proxi_sensor::raw_to_base(sensor_data_t &data)
-{
- data.values[0] = (float)(data.values[0] * 5);
- data.value_count = 1;
-}
-
+++ /dev/null
-/*
- * sensord
- *
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef _PROXI_SENSOR_H_
-#define _PROXI_SENSOR_H_
-
-#include <sensor_common.h>
-#include <physical_sensor.h>
-#include <sensor_hal.h>
-
-class proxi_sensor : public physical_sensor {
-public:
- enum proxi_node_state_event_t { //changed as per Input Event Method definitions
- PROXIMITY_NODE_STATE_NEAR = 0,
- PROXIMITY_NODE_STATE_FAR = 1,
- PROXIMITY_NODE_STATE_UNKNOWN = -1,
- };
-
-// In case of IIO input method, use the following definitions as the values returned by sensor are different.
-// enum proxi_node_state_event_t { //changed as per IIO Method definitions
-// PROXIMITY_NODE_STATE_NEAR = 1,
-// PROXIMITY_NODE_STATE_FAR = 2,
-// PROXIMITY_NODE_STATE_UNKNOWN = 0,
-// };
-
- proxi_sensor();
- virtual ~proxi_sensor();
-
- bool init();
- virtual void get_types(std::vector<sensor_type_t> &types);
-
- static bool working(void *inst);
-
- int get_sensor_data(unsigned int type, sensor_data_t &data);
- virtual bool get_properties(sensor_type_t sensor_type, sensor_properties_s &properties);
-private:
- sensor_hal *m_sensor_hal;
-
- int m_state;
-
- cmutex m_value_mutex;
-
-
- virtual bool on_start(void);
- virtual bool on_stop(void);
-
- void raw_to_base(sensor_data_t &data);
- void raw_to_state(sensor_data_t &data);
- bool process_event(void);
-};
-
-#endif // _PROXI_SENSOR_H_
+++ /dev/null
-/*
- * sensord
- *
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <sensor_logs.h>
-#include <sf_common.h>
-#include <sensor_internal.h>
-#include <rv_raw_sensor.h>
-#include <sensor_plugin_loader.h>
-
-using std::string;
-using std::vector;
-
-#define SENSOR_NAME "RV_RAW_SENSOR"
-
-rv_raw_sensor::rv_raw_sensor()
-: m_sensor_hal(NULL)
-{
- m_name = string(SENSOR_NAME);
-
- register_supported_event(RV_RAW_RAW_DATA_EVENT);
-
- physical_sensor::set_poller(rv_raw_sensor::working, this);
-}
-
-rv_raw_sensor::~rv_raw_sensor()
-{
- INFO("rv_raw_sensor is destroyed!\n");
-}
-
-bool rv_raw_sensor::init()
-{
- m_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(SENSOR_HAL_TYPE_RV_RAW);
-
- if (!m_sensor_hal) {
- ERR("cannot load sensor_hal[%s]", sensor_base::get_name());
- return false;
- }
-
- sensor_properties_s properties;
-
- if (!m_sensor_hal->get_properties(properties)) {
- ERR("sensor->get_properties() is failed!\n");
- return false;
- }
-
- set_privilege(SENSOR_PRIVILEGE_INTERNAL);
-
- INFO("%s is created!\n", sensor_base::get_name());
-
- return true;
-}
-
-void rv_raw_sensor::get_types(vector<sensor_type_t> &types)
-{
- types.push_back(RV_RAW_SENSOR);
-}
-
-bool rv_raw_sensor::working(void *inst)
-{
- rv_raw_sensor *sensor = (rv_raw_sensor*)inst;
- return sensor->process_event();;
-}
-
-bool rv_raw_sensor::process_event(void)
-{
- sensor_event_t event;
-
- if (!m_sensor_hal->is_data_ready())
- return true;
-
- m_sensor_hal->get_sensor_data(event.data);
-
- AUTOLOCK(m_client_info_mutex);
- AUTOLOCK(m_mutex);
-
- if (get_client_cnt(RV_RAW_RAW_DATA_EVENT)) {
- event.sensor_id = get_id();
- event.event_type = RV_RAW_RAW_DATA_EVENT;
- push(event);
- }
-
- return true;
-}
-
-bool rv_raw_sensor::on_start(void)
-{
- if (!m_sensor_hal->enable()) {
- ERR("m_sensor_hal start fail\n");
- return false;
- }
-
- return start_poll();
-}
-
-bool rv_raw_sensor::on_stop(void)
-{
- if (!m_sensor_hal->disable()) {
- ERR("m_sensor_hal stop fail\n");
- return false;
- }
-
- return stop_poll();
-}
-
-bool rv_raw_sensor::get_properties(sensor_type_t sensor_type, sensor_properties_s &properties)
-{
- return m_sensor_hal->get_properties(properties);
-}
-
-int rv_raw_sensor::get_sensor_data(unsigned int type, sensor_data_t &data)
-{
- int state;
-
- if (type != RV_RAW_RAW_DATA_EVENT)
- return -1;
-
- state = m_sensor_hal->get_sensor_data(data);
-
- if (state < 0) {
- ERR("m_sensor_hal get struct_data fail\n");
- return -1;
- }
-
- return 0;
-}
-
-bool rv_raw_sensor::set_interval(unsigned long interval)
-{
- AUTOLOCK(m_mutex);
-
- INFO("Polling interval is set to %dms", interval);
-
- return m_sensor_hal->set_interval(interval);
-}
+++ /dev/null
-/*
- * sensord
- *
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef _RV_RAW_SENSOR_H_
-#define _RV_RAW_SENSOR_H_
-
-#include <sensor_common.h>
-
-#include <physical_sensor.h>
-#include <sensor_hal.h>
-
-class rv_raw_sensor : public physical_sensor {
-public:
- rv_raw_sensor();
- virtual ~rv_raw_sensor();
-
- virtual bool init();
- virtual void get_types(std::vector<sensor_type_t> &types);
-
- static bool working(void *inst);
-
- virtual bool set_interval(unsigned long interval);
- int get_sensor_data(unsigned int type, sensor_data_t &data);
- virtual bool get_properties(sensor_type_t sensor_type, sensor_properties_s &properties);
-private:
- sensor_hal *m_sensor_hal;
-
- virtual bool on_start(void);
- virtual bool on_stop(void);
-
- bool process_event(void);
-};
-
-#endif /*_RV_RAW_SENSOR_H_*/
+++ /dev/null
-/*
- * sensord
- *
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <sensor_logs.h>
-#include <sf_common.h>
-#include <temperature_sensor.h>
-#include <sensor_plugin_loader.h>
-
-using std::string;
-using std::vector;
-
-#define SENSOR_NAME "TEMPERATURE_SENSOR"
-
-temperature_sensor::temperature_sensor()
-: m_sensor_hal(NULL)
-, m_temperature(0.0f)
-, m_resolution(0.0f)
-{
- m_name = string(SENSOR_NAME);
-
- register_supported_event(TEMPERATURE_RAW_DATA_EVENT);
-
- physical_sensor::set_poller(temperature_sensor::working, this);
-}
-
-temperature_sensor::~temperature_sensor()
-{
- INFO("temperature_sensor is destroyed!");
-}
-
-bool temperature_sensor::init()
-{
- m_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(SENSOR_HAL_TYPE_TEMPERATURE);
-
- if (!m_sensor_hal) {
- ERR("cannot load sensor_hal[%s]", sensor_base::get_name());
- return false;
- }
-
- sensor_properties_s properties;
-
- if (!m_sensor_hal->get_properties(properties)) {
- ERR("sensor->get_properties() is failed!\n");
- return false;
- }
-
- m_resolution = properties.resolution;
-
- INFO("%s is created!", sensor_base::get_name());
-
- return true;
-}
-
-void temperature_sensor::get_types(vector<sensor_type_t> &types)
-{
- types.push_back(TEMPERATURE_SENSOR);
-}
-
-bool temperature_sensor::working(void *inst)
-{
- temperature_sensor *sensor = (temperature_sensor*)inst;
- return sensor->process_event();
-}
-
-bool temperature_sensor::process_event(void)
-{
- sensor_event_t event;
-
- if (!m_sensor_hal->is_data_ready())
- return true;
-
- m_sensor_hal->get_sensor_data(event.data);
-
- AUTOLOCK(m_client_info_mutex);
-
- if (get_client_cnt(TEMPERATURE_RAW_DATA_EVENT)) {
- event.sensor_id = get_id();
- event.event_type = TEMPERATURE_RAW_DATA_EVENT;
- raw_to_base(event.data);
- push(event);
- }
-
- return true;
-}
-
-bool temperature_sensor::on_start(void)
-{
- if (!m_sensor_hal->enable()) {
- ERR("m_sensor_hal start fail\n");
- return false;
- }
-
- return start_poll();
-}
-
-bool temperature_sensor::on_stop(void)
-{
- if (!m_sensor_hal->disable()) {
- ERR("m_sensor_hal stop fail\n");
- return false;
- }
-
- return stop_poll();
-}
-
-bool temperature_sensor::get_properties(sensor_type_t sensor_type, sensor_properties_s &properties)
-{
- return m_sensor_hal->get_properties(properties);
-}
-
-int temperature_sensor::get_sensor_data(unsigned int type, sensor_data_t &data)
-{
- int ret;
-
- ret = m_sensor_hal->get_sensor_data(data);
-
- if (ret < 0)
- return -1;
-
- if (type == TEMPERATURE_RAW_DATA_EVENT) {
- raw_to_base(data);
- return 0;
- }
-
- return -1;
-}
-
-bool temperature_sensor::set_interval(unsigned long interval)
-{
- AUTOLOCK(m_mutex);
-
- INFO("Polling interval is set to %dms", interval);
-
- return m_sensor_hal->set_interval(interval);
-}
-
-void temperature_sensor::raw_to_base(sensor_data_t &data)
-{
- data.values[0] = data.values[0] * m_resolution;
- data.value_count = 1;
-}
+++ /dev/null
-/*
- * sensord
- *
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef _TEMPERATURE_SENSOR_H_
-#define _TEMPERATURE_SENSOR_H_
-
-#include <sensor_common.h>
-
-#include <physical_sensor.h>
-#include <sensor_hal.h>
-
-class temperature_sensor : public physical_sensor {
-public:
- temperature_sensor();
- virtual ~temperature_sensor();
-
- bool init();
- virtual void get_types(std::vector<sensor_type_t> &types);
-
- static bool working(void *inst);
-
- bool set_interval(unsigned long interval);
- int get_sensor_data(unsigned int type, sensor_data_t &data);
- virtual bool get_properties(sensor_type_t sensor_type, sensor_properties_s &properties);
-
-private:
- sensor_hal *m_sensor_hal;
- float m_temperature;
- float m_resolution;
-
- virtual bool on_start(void);
- virtual bool on_stop(void);
- bool process_event(void);
- void raw_to_base(sensor_data_t &data);
-};
-
-#endif
+++ /dev/null
-/*
- * sensord
- *
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <sensor_logs.h>
-#include <sf_common.h>
-
-#include <ultraviolet_sensor.h>
-#include <sensor_plugin_loader.h>
-#include <algorithm>
-
-using std::bind1st;
-using std::mem_fun;
-using std::string;
-using std::vector;
-
-#define SENSOR_NAME "ULTRAVIOLET_SENSOR"
-
-ultraviolet_sensor::ultraviolet_sensor()
-: m_sensor_hal(NULL)
-{
- m_name = string(SENSOR_NAME);
-
- register_supported_event(ULTRAVIOLET_RAW_DATA_EVENT);
-
- physical_sensor::set_poller(ultraviolet_sensor::working, this);
-}
-
-ultraviolet_sensor::~ultraviolet_sensor()
-{
- INFO("ultraviolet_sensor is destroyed!");
-}
-
-bool ultraviolet_sensor::init()
-{
- m_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(SENSOR_HAL_TYPE_ULTRAVIOLET);
-
- if (!m_sensor_hal) {
- ERR("cannot load sensor_hal[%s]", sensor_base::get_name());
- return false;
- }
-
- sensor_properties_s properties;
-
- if (m_sensor_hal->get_properties(properties) == false) {
- ERR("sensor->get_properties() is failed!\n");
- return false;
- }
-
- INFO("%s is created!", sensor_base::get_name());
-
- return true;
-}
-
-void ultraviolet_sensor::get_types(vector<sensor_type_t> &types)
-{
- types.push_back(ULTRAVIOLET_SENSOR);
-}
-
-bool ultraviolet_sensor::working(void *inst)
-{
- ultraviolet_sensor *sensor = (ultraviolet_sensor*)inst;
- return sensor->process_event();
-}
-
-bool ultraviolet_sensor::process_event(void)
-{
- sensor_event_t event;
-
- if (!m_sensor_hal->is_data_ready())
- return true;
-
- m_sensor_hal->get_sensor_data(event.data);
-
-
- AUTOLOCK(m_client_info_mutex);
-
- if (get_client_cnt(ULTRAVIOLET_RAW_DATA_EVENT)) {
- event.sensor_id = get_id();
- event.event_type = ULTRAVIOLET_RAW_DATA_EVENT;
- raw_to_base(event.data);
- push(event);
- }
-
- return true;
-}
-
-bool ultraviolet_sensor::on_start(void)
-{
- if (!m_sensor_hal->enable()) {
- ERR("m_sensor_hal start fail\n");
- return false;
- }
-
- return start_poll();
-}
-
-bool ultraviolet_sensor::on_stop(void)
-{
- if (!m_sensor_hal->disable()) {
- ERR("m_sensor_hal stop fail\n");
- return false;
- }
-
- return stop_poll();
-}
-
-bool ultraviolet_sensor::get_properties(sensor_type_t sensor_type, sensor_properties_s &properties)
-{
- return m_sensor_hal->get_properties(properties);
-}
-
-int ultraviolet_sensor::get_sensor_data(unsigned int type, sensor_data_t &data)
-{
- int ret;
-
- ret = m_sensor_hal->get_sensor_data(data);
-
- if (ret < 0)
- return -1;
-
- if (type == ULTRAVIOLET_RAW_DATA_EVENT) {
- raw_to_base(data);
- return 0;
- }
-
- return -1;
-}
-
-bool ultraviolet_sensor::set_interval(unsigned long interval)
-{
- AUTOLOCK(m_mutex);
-
- INFO("Polling interval is set to %dms", interval);
-
- return m_sensor_hal->set_interval(interval);
-}
-
-void ultraviolet_sensor::raw_to_base(sensor_data_t &data)
-{
-
-}
+++ /dev/null
-/*
- * sensord
- *
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef _ULTRAVIOLET_SENSOR_H_
-#define _ULTRAVIOLET_SENSOR_H_
-
-#include <sensor_common.h>
-
-#include <physical_sensor.h>
-#include <sensor_hal.h>
-
-class ultraviolet_sensor : public physical_sensor {
-public:
- ultraviolet_sensor();
- virtual ~ultraviolet_sensor();
-
- bool init();
- virtual void get_types(std::vector<sensor_type_t> &types);
-
- static bool working(void *inst);
- virtual bool set_interval(unsigned long interval);
- virtual bool get_properties(sensor_type_t sensor_type, sensor_properties_s &properties);
- virtual int get_sensor_data(unsigned int type, sensor_data_t &data);
-private:
- sensor_hal *m_sensor_hal;
-
- virtual bool on_start(void);
- virtual bool on_stop(void);
- bool process_event(void);
- void raw_to_base(sensor_data_t &data);
-};
-
-#endif
-