4 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
20 #include "sensor_manager.h"
31 char name[NAME_MAX_TEST];
34 static struct sensor_info sensor_infos[] = {
38 {ACCELEROMETER_SENSOR, "accelerometer"},
39 {GRAVITY_SENSOR, "gravity"},
40 {LINEAR_ACCEL_SENSOR, "linear_accel"},
41 {GEOMAGNETIC_SENSOR, "magnetic"},
42 {ROTATION_VECTOR_SENSOR, "rotation_vector"},
43 {ORIENTATION_SENSOR, "orientation"},
44 {GYROSCOPE_SENSOR, "gyroscope"},
45 {LIGHT_SENSOR, "light"},
46 {PROXIMITY_SENSOR, "proximity"},
47 {PRESSURE_SENSOR, "pressure"},
48 {ULTRAVIOLET_SENSOR, "uv"},
49 {TEMPERATURE_SENSOR, "temperature"},
50 {HUMIDITY_SENSOR, "humidity"},
52 {HRM_RAW_SENSOR, "hrm_raw"},
53 {HRM_LED_GREEN_SENSOR, "hrm_led_green"},
54 {HRM_LED_IR_SENSOR, "hrm_led_ir"},
55 {HRM_LED_RED_SENSOR, "hrm_led_red"},
56 {GYROSCOPE_UNCAL_SENSOR, "gyro_uncal"},
57 {GEOMAGNETIC_UNCAL_SENSOR, "mag_uncal"},
58 {GYROSCOPE_RV_SENSOR, "gyro_rv"},
59 {GEOMAGNETIC_RV_SENSOR, "mag_rv"},
61 {HUMAN_PEDOMETER_SENSOR, "pedo"},
62 {HUMAN_SLEEP_MONITOR_SENSOR, "sleep_monitor"},
64 {AUTO_ROTATION_SENSOR, "rotation"},
65 //{AUTO_BRIGHTENESS_SENSOR, "auto_brighteness"},
66 {MOTION_SENSOR, "motion"},
67 {CONTEXT_SENSOR, "context"},
69 {GESTURE_MOVEMENT_SENSOR, "movement"},
70 {GESTURE_WRIST_UP_SENSOR, "wristup"},
71 {GESTURE_WRIST_DOWN_SENSOR, "wristdown"},
72 {GESTURE_MOVEMENT_STATE_SENSOR, "movement_state"},
74 {WEAR_STATUS_SENSOR, "wear_status"},
75 {WEAR_ON_MONITOR_SENSOR, "wear_on"},
76 {GPS_BATCH_SENSOR, "gps"},
77 {ACTIVITY_TRACKER_SENSOR, "activity"},
78 {SLEEP_DETECTOR_SENSOR, "sleep_detector"},
81 sensor_manager::~sensor_manager()
85 bool sensor_manager::run(int argc, char *argv[])
90 void sensor_manager::stop(void)
94 sensor_type_t sensor_manager::get_sensor_type(const char *name)
99 if (util::is_hex(name))
100 return (sensor_type_t) (strtol(name, NULL, 16));
102 if (util::is_number(name))
103 return (sensor_type_t) (atoi(name));
105 count = ARRAY_SIZE(sensor_infos);
107 for (index = 0; index < count; ++index) {
108 if (!strcmp(sensor_infos[index].name, name))
112 if (index == count) {
113 _E("Invaild sensor name\n");
115 return UNKNOWN_SENSOR;
117 return sensor_infos[index].type;
120 void sensor_manager::usage_sensors(void)
122 _N("The sensor types are:\n");
123 int sensor_count = ARRAY_SIZE(sensor_infos);
125 for (int i = 0; i < sensor_count; ++i)
126 _N("%3d: %s(%#x)\n", i, sensor_infos[i].name, sensor_infos[i].type);