2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <sensor/sensor_hal.h>
19 #include <sensor_log.h>
22 #include "accel/accel_device.h"
23 #include "gyro/gyro_device.h"
24 #include "pressure/pressure_device.h"
25 #include "light/light_device.h"
26 #include "hrm_raw/hrm_raw_device.h"
27 #include "hrm/hrm_device.h"
29 static std::vector<sensor_device_t> devs;
31 template<typename _sensor>
32 void create_sensor(const char *name)
34 sensor_device *instance = NULL;
36 instance = new _sensor;
37 } catch (std::exception &e) {
38 ERR("Failed to create %s sensor device, exception: %s", name, e.what());
41 _ERRNO(err, _E, "Failed to create %s sensor device", name);
45 devs.push_back(instance);
48 extern "C" int create(sensor_device_t **devices)
50 create_sensor<accel_device>("Accelerometer");
51 create_sensor<gyro_device>("Gyroscope");
52 create_sensor<pressure_device>("Pressure");
53 create_sensor<light_device>("Light");
54 create_sensor<hrm_raw_device>("HRM Raw");
55 create_sensor<hrm_device>("HRM");