• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 #ifndef SENSOR_DEVICE_TYPE_H
10 #define SENSOR_DEVICE_TYPE_H
11 
12 #include "hdf_base.h"
13 
14 #define SENSOR_INFO_NAME_MAX_LEN      32
15 #define SENSOR_INFO_VERSION_MAX_LEN   16
16 
17 enum SensorAccuracyMode {
18     SENSOR_ACCURACY_NO     = 0,
19     SENSOR_ACCURACY_LOW    = 1,
20     SENSOR_ACCURACY_MEDIUM = 2,
21     SENSOR_ACCURACY_HIGH   = 3,
22     SENSOR_ACCURACY_MAX,
23 };
24 
25 enum SensorRangeLevel {
26     SENSOR_RANGE_LEVEL_1 = 0,
27     SENSOR_RANGE_LEVEL_2 = 1,
28     SENSOR_RANGE_LEVEL_3 = 2,
29 };
30 
31 enum SensorWorkMode {
32     SENSOR_WORK_MODE_DEFAULT   = 0,
33     SENSOR_WORK_MODE_REALTIME  = 1,
34     SENSOR_WORK_MODE_ON_CHANGE = 2,
35     SENSOR_WORK_MODE_ONE_SHOT  = 3,
36     SENSOR_WORK_MODE_FIFO      = 4,
37     SENSOR_WORK_MODE_MAX,
38 };
39 
40 enum SensorTag {
41     SENSOR_TAG_NONE                = 0,   /**< No sensor type for sensor test */
42     SENSOR_TAG_ACCELEROMETER       = 1,   /**< Acceleration sensor */
43     SENSOR_TAG_GYROSCOPE           = 2,   /**< Gyroscope sensor */
44     SENSOR_TAG_PHOTOPLETHYSMOGRAPH = 3,   /**< Photoplethysmography sensor */
45     SENSOR_TAG_ELECTROCARDIOGRAPH  = 4,   /**< Electrocardiogram sensor */
46     SENSOR_TAG_AMBIENT_LIGHT       = 5,   /**< Ambient light sensor */
47     SENSOR_TAG_MAGNETIC_FIELD      = 6,   /**< Magnetic field sensor */
48     SENSOR_TAG_CAPACITIVE          = 7,   /**< Capacitance sensor */
49     SENSOR_TAG_BAROMETER           = 8,   /**< Barometric pressure sensor */
50     SENSOR_TAG_TEMPERATURE         = 9,   /**< Temperature sensor */
51     SENSOR_TAG_HALL                = 10,  /**< Hall effect sensor */
52     SENSOR_TAG_GESTURE             = 11,  /**< Gesture sensor */
53     SENSOR_TAG_PROXIMITY           = 12,  /**< Proximity sensor */
54     SENSOR_TAG_HUMIDITY            = 13,  /**< Humidity sensor */
55     SENSOR_TAG_PHYSICAL_MAX        = 255, /**< Maximum type of a physical sensor */
56     SENSOR_TAG_ORIENTATION         = 256, /**< Orientation sensor */
57     SENSOR_TAG_GRAVITY             = 257, /**< Gravity sensor */
58     SENSOR_TAG_LINEAR_ACCELERATION = 258, /**< Linear acceleration sensor */
59     SENSOR_TAG_ROTATION_VECTOR     = 259, /**< Rotation vector sensor */
60     SENSOR_TAG_AMBIENT_TEMPERATURE = 260, /**< Ambient temperature sensor */
61     SENSOR_TAG_MAGNETIC_FIELD_UNCALIBRATED = 261,   /**< Uncalibrated magnetic field sensor */
62     SENSOR_TAG_GAME_ROTATION_VECTOR        = 262,   /**< Game rotation vector sensor */
63     SENSOR_TAG_GYROSCOPE_UNCALIBRATED      = 263,   /**< Uncalibrated gyroscope sensor */
64     SENSOR_TAG_SIGNIFICANT_MOTION          = 264,   /**< Significant motion sensor */
65     SENSOR_TAG_PEDOMETER_DETECTION         = 265,   /**< Pedometer detection sensor */
66     SENSOR_TAG_PEDOMETER                   = 266,   /**< Pedometer sensor */
67     SENSOR_TAG_GEOMAGNETIC_ROTATION_VECTOR = 277,   /**< Geomagnetic rotation vector sensor */
68     SENSOR_TAG_HEART_RATE                  = 278,   /**< Heart rate sensor */
69     SENSOR_TAG_DEVICE_ORIENTATION          = 279,   /**< Device orientation sensor */
70     SENSOR_TAG_WEAR_DETECTION              = 280,   /**< Wear detection sensor */
71     SENSOR_TAG_ACCELEROMETER_UNCALIBRATED  = 281,   /**< Uncalibrated acceleration sensor */
72     SENSOR_TAG_MAX                         = 0xFFF, /**< Maximum number of sensor types */
73 };
74 
75 /**
76  * @brief Defines the basic description of a sensor.
77  *
78  * The basic description of the sensor includes its vendor, version, type, ID,
79  * measurement range, accuracy, and power consumption.
80  */
81 struct SensorBasicInfo {
82     char sensorName[SENSOR_INFO_NAME_MAX_LEN]; /**< Sensor name */
83     char vendorName[SENSOR_INFO_NAME_MAX_LEN]; /**< Sensor vendor */
84     char firmwareVersion[SENSOR_INFO_VERSION_MAX_LEN]; /**< Sensor firmware version */
85     char hardwareVersion[SENSOR_INFO_VERSION_MAX_LEN]; /**< Sensor hardware version */
86     int32_t sensorTypeId; /**< Sensor type ID (described in {@link SensorTypeTag}) */
87     int32_t sensorId;     /**< Sensor ID, defined by the sensor driver developer */
88     int32_t maxRange;     /**< Maximum measurement range of the sensor */
89     int32_t accuracy;     /**< Sensor accuracy */
90     int32_t power;        /**< Sensor power */
91     int64_t minDelay;     /**< Minimum sample period allowed in nanoseconds */
92     int64_t maxDelay;     /**< Maxmum sample period allowed in nanoseconds */
93 };
94 
95 struct SensorReportEvent {
96     int32_t sensorId;  /**< Sensor ID */
97     int32_t version;   /**< Sensor algorithm version */
98     uint64_t timestamp; /**< Time when sensor data was generated */
99     uint32_t option;   /**< Sensor data options, including the measurement range and accuracy */
100     int32_t mode;      /**< Sensor data reporting mode */
101     uint8_t *data;     /**< Sensor data address */
102     uint32_t dataLen;  /**< Sensor data length */
103 };
104 
105 #endif /* SENSOR_DEVICE_TYPE_H */
106