• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 OHOS_CJ_SENSOR_FFI_H
17 #define OHOS_CJ_SENSOR_FFI_H
18 
19 #include "cj_sensor_visibility.h"
20 #include "sensor_agent_type.h"
21 
22 #ifdef __cplusplus
23 #if __cplusplus
24 extern "C" {
25 #endif
26 #endif
27 
28 typedef struct {
29     float latitude;
30     float longitude;
31     float altitude;
32 } CLocationOptions;
33 
34 typedef struct {
35     float x;
36     float y;
37     float z;
38     float geomagneticDip;
39     float deflectionAngle;
40     float levelIntensity;
41     float totalIntensity;
42 } CGeomagneticData;
43 
44 typedef struct {
45     float *head;
46     int64_t size;
47 } CArrFloat32;
48 
49 typedef struct {
50     int32_t x;
51     int32_t y;
52 } CCoordinatesOptions;
53 
54 typedef struct {
55     CArrFloat32 rotation;
56     CArrFloat32 inclination;
57 } CRotationMatrixResponse;
58 
59 typedef struct CSensor {
60     char *sensorName;
61     char *vendorName;
62     char *firmwareVersion;
63     char *hardwareVersion;
64     int32_t sensorTypeId;
65     float maxRange;
66     int64_t minSamplePeriod;
67     int64_t maxSamplePeriod;
68     float precision;
69     float power;
70 } CSensor;
71 
72 typedef struct {
73     CSensor *head;
74     int64_t size;
75 } CSensorArray;
76 
77 SENSOR_FFI_EXPORT int32_t FfiSensorSubscribeSensor(int32_t sensorId, int64_t interval,
78                                                    void (*callback)(SensorEvent *event));
79 
80 SENSOR_FFI_EXPORT int32_t FfiSensorUnSubscribeSensor(int32_t sensorId);
81 SENSOR_FFI_EXPORT CGeomagneticData FfiSensorGetGeomagneticInfo(CLocationOptions location, int64_t timeMillis);
82 SENSOR_FFI_EXPORT int32_t FfiSensorGetDeviceAltitude(float seaPressure, float currentPressure, float *altitude);
83 SENSOR_FFI_EXPORT int32_t FfiSensorGetInclination(CArrFloat32 inclinationMatrix, float *inclination);
84 SENSOR_FFI_EXPORT int32_t FfiSensorGetAngleVariation(CArrFloat32 currentRotationMatrix, CArrFloat32 preRotationMatrix,
85                                                      CArrFloat32 *angleChange);
86 SENSOR_FFI_EXPORT int32_t FfiSensorGetRotationMatrix(CArrFloat32 rotationVector, CArrFloat32 *rotation);
87 SENSOR_FFI_EXPORT int32_t FfiSensorTransformRotationMatrix(CArrFloat32 inRotationVector,
88                                                            CCoordinatesOptions coordinates,
89                                                            CArrFloat32 *rotationMatrix);
90 SENSOR_FFI_EXPORT int32_t FfiSensorGetQuaternion(CArrFloat32 rotationVector, CArrFloat32 *quaternion);
91 SENSOR_FFI_EXPORT int32_t FfiSensorGetOrientation(CArrFloat32 rotationMatrix, CArrFloat32 *rotationAngle);
92 SENSOR_FFI_EXPORT int32_t FfiSensorGetRotationMatrixByGravityAndGeomagnetic(CArrFloat32 gravity,
93                                                                             CArrFloat32 geomagnetic,
94                                                                             CRotationMatrixResponse *rotationMaxtrix);
95 SENSOR_FFI_EXPORT int32_t FfiSensorGetAllSensors(CSensorArray *sensors);
96 
97 #ifdef __cplusplus
98 #if __cplusplus
99 }
100 #endif
101 #endif
102 #endif /* OHOS_CJ_SENSOR_FFI_H */
103 /**< @} */
104