• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef SENSOR_DATA_EVENT_H
17 #define SENSOR_DATA_EVENT_H
18 
19 namespace OHOS {
20 namespace Sensors {
21 constexpr int32_t RESERVED_DATA_LEN = 3;
22 constexpr int32_t EXTRA_INFO_DATA_LEN = 14;
23 constexpr int32_t DEFAULT_SENSOR_DATA_DIMS = 16;
24 
25 enum {
26     WAKE_UP_SENSOR = 1u,
27     CONTINUOUS_SENSOR = 0u,
28     ON_CHANGE_SENSOR = 2u,
29     ONE_SHOT_SENSOR = 4u,
30 };
31 
32 struct SensorData {
33     float data[DEFAULT_SENSOR_DATA_DIMS];
34     uint32_t reserved[RESERVED_DATA_LEN];
35 };
36 
37 struct ExtraInfo {
38     int32_t sensorId;
39     int32_t type;    // type of payload data, see ExtraInfo
40     int32_t serial;  // sequence number of this frame for this type
41     union {
42         // for each frame, a single data type, either int32_t or float, should be used.
43         int32_t data_int32[EXTRA_INFO_DATA_LEN];
44         float data_float[EXTRA_INFO_DATA_LEN];
45     };
46 };
47 
48 struct ExtraSensorInfo {
49     ExtraInfo additional_info;
50 };
51 }  // namespace Sensors
52 }  // namespace OHOS
53 #endif  // SENSOR_DATA_EVENT_H
54