1c5e268c6Sopenharmony_ci/*
2c5e268c6Sopenharmony_ci * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
3c5e268c6Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4c5e268c6Sopenharmony_ci * you may not use this file except in compliance with the License.
5c5e268c6Sopenharmony_ci * You may obtain a copy of the License at
6c5e268c6Sopenharmony_ci *
7c5e268c6Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8c5e268c6Sopenharmony_ci *
9c5e268c6Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10c5e268c6Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11c5e268c6Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12c5e268c6Sopenharmony_ci * See the License for the specific language governing permissions and
13c5e268c6Sopenharmony_ci * limitations under the License.
14c5e268c6Sopenharmony_ci */
15c5e268c6Sopenharmony_ci
16c5e268c6Sopenharmony_ci/**
17c5e268c6Sopenharmony_ci * @addtogroup HdiSensor
18c5e268c6Sopenharmony_ci * @{
19c5e268c6Sopenharmony_ci *
20c5e268c6Sopenharmony_ci * @brief Provides unified APIs for sensor services to access sensor drivers.
21c5e268c6Sopenharmony_ci *
22c5e268c6Sopenharmony_ci * A sensor service can obtain a sensor driver object or agent and then call APIs provided by this object or agent to
23c5e268c6Sopenharmony_ci * access different types of sensor devices based on the sensor IDs, thereby obtaining sensor information,
24c5e268c6Sopenharmony_ci * subscribing to or unsubscribing from sensor data, enabling or disabling a sensor,
25c5e268c6Sopenharmony_ci * setting the sensor data reporting mode, and setting sensor options such as the accuracy and measurement range.
26c5e268c6Sopenharmony_ci *
27c5e268c6Sopenharmony_ci * @since 4.1
28c5e268c6Sopenharmony_ci */
29c5e268c6Sopenharmony_ci
30c5e268c6Sopenharmony_ci/**
31c5e268c6Sopenharmony_ci * @file ISensorInterface.idl
32c5e268c6Sopenharmony_ci *
33c5e268c6Sopenharmony_ci * @brief Declares the APIs provided by the sensor module for obtaining sensor information, subscribing to or
34c5e268c6Sopenharmony_ci * unsubscribing from sensor data, enabling or disabling a sensor, setting the sensor data reporting mode,
35c5e268c6Sopenharmony_ci * and setting sensor options such as the accuracy and measurement range.
36c5e268c6Sopenharmony_ci *
37c5e268c6Sopenharmony_ci * @since 4.1
38c5e268c6Sopenharmony_ci * @version 2.0
39c5e268c6Sopenharmony_ci */
40c5e268c6Sopenharmony_ci
41c5e268c6Sopenharmony_cipackage ohos.hdi.sensor.v2_0;
42c5e268c6Sopenharmony_ci
43c5e268c6Sopenharmony_ciimport ohos.hdi.sensor.v2_0.SensorTypes;
44c5e268c6Sopenharmony_ciimport ohos.hdi.sensor.v2_0.ISensorCallback;
45c5e268c6Sopenharmony_ci
46c5e268c6Sopenharmony_ci/**
47c5e268c6Sopenharmony_ci * @brief Defines the functions for performing basic operations on sensors.
48c5e268c6Sopenharmony_ci *
49c5e268c6Sopenharmony_ci * The operations include obtaining sensor information, subscribing to or unsubscribing from sensor data,
50c5e268c6Sopenharmony_ci * enabling or disabling a sensor, setting the sensor data reporting mode, and setting sensor options such as
51c5e268c6Sopenharmony_ci * the accuracy and measurement range.
52c5e268c6Sopenharmony_ci */
53c5e268c6Sopenharmony_ciinterface ISensorInterface {
54c5e268c6Sopenharmony_ci    /**
55c5e268c6Sopenharmony_ci     * @brief Obtains information about all sensors in the system.
56c5e268c6Sopenharmony_ci     *
57c5e268c6Sopenharmony_ci     * @param info Indicates the vector of the information about all sensors in the system.
58c5e268c6Sopenharmony_ci     * The information about a sensor generally includes the sensor name, sensor vendor, firmware version,
59c5e268c6Sopenharmony_ci     * hardware version, sensor type ID, sensor ID, maximum measurement range, accuracy, and power. For details,
60c5e268c6Sopenharmony_ci     * see {@link HdfSensorInformation}.
61c5e268c6Sopenharmony_ci     * @return Returns <b>0</b> if the information is obtained; returns a negative value otherwise.
62c5e268c6Sopenharmony_ci     *
63c5e268c6Sopenharmony_ci     * @since 2.2
64c5e268c6Sopenharmony_ci     * @version 2.0
65c5e268c6Sopenharmony_ci     */
66c5e268c6Sopenharmony_ci    GetAllSensorInfo([out] struct HdfSensorInformation[] info);
67c5e268c6Sopenharmony_ci
68c5e268c6Sopenharmony_ci    /**
69c5e268c6Sopenharmony_ci     * @brief Enables the sensor available in the sensor list based on the specified sensor ID.
70c5e268c6Sopenharmony_ci     * The subscriber can obtain the sensor data only after the sensor is enabled.
71c5e268c6Sopenharmony_ci     *
72c5e268c6Sopenharmony_ci     * @param sensorId Indicates the sensor ID. For details, see {@link SensorTypeTag}.
73c5e268c6Sopenharmony_ci     * @return Returns <b>0</b> if the sensor is successfully enabled; returns a negative value otherwise.
74c5e268c6Sopenharmony_ci     *
75c5e268c6Sopenharmony_ci     * @since 2.2
76c5e268c6Sopenharmony_ci     * @version 1.0
77c5e268c6Sopenharmony_ci     */
78c5e268c6Sopenharmony_ci    Enable([in] int sensorId);
79c5e268c6Sopenharmony_ci
80c5e268c6Sopenharmony_ci    /**
81c5e268c6Sopenharmony_ci     * @brief Disables an enabled sensor.
82c5e268c6Sopenharmony_ci     *
83c5e268c6Sopenharmony_ci     * @param sensorId Indicates the sensor ID. For details, see {@link SensorTypeTag}.
84c5e268c6Sopenharmony_ci     * @return Returns <b>0</b> if the sensor is successfully disabled; returns a negative value otherwise.
85c5e268c6Sopenharmony_ci     *
86c5e268c6Sopenharmony_ci     * @since 2.2
87c5e268c6Sopenharmony_ci     * @version 1.0
88c5e268c6Sopenharmony_ci     */
89c5e268c6Sopenharmony_ci    Disable([in] int sensorId);
90c5e268c6Sopenharmony_ci
91c5e268c6Sopenharmony_ci    /**
92c5e268c6Sopenharmony_ci     * @brief Sets the data sampling interval and data reporting interval for the specified sensor.
93c5e268c6Sopenharmony_ci     *
94c5e268c6Sopenharmony_ci     * @param sensorId Indicates the sensor ID. For details, see {@link SensorTypeTag}.
95c5e268c6Sopenharmony_ci     * @param samplingInterval Indicates the sensor data sampling interval to set, in nanoseconds.
96c5e268c6Sopenharmony_ci     * @param reportInterval Indicates the sensor data reporting interval, in nanoseconds.
97c5e268c6Sopenharmony_ci     * @return Returns <b>0</b> if the setting is successful; returns a negative value otherwise.
98c5e268c6Sopenharmony_ci     *
99c5e268c6Sopenharmony_ci     * @since 2.2
100c5e268c6Sopenharmony_ci     * @version 1.0
101c5e268c6Sopenharmony_ci     */
102c5e268c6Sopenharmony_ci    SetBatch([in] int sensorId,[in] long samplingInterval, [in] long reportInterval);
103c5e268c6Sopenharmony_ci
104c5e268c6Sopenharmony_ci    /**
105c5e268c6Sopenharmony_ci     * @brief Sets the data reporting mode for the specified sensor.
106c5e268c6Sopenharmony_ci     *
107c5e268c6Sopenharmony_ci     * @param sensorId Indicates the sensor ID. For details, see {@link SensorTypeTag}.
108c5e268c6Sopenharmony_ci     * @param mode Indicates the data reporting mode to set. For details, see {@link SensorModeType}.
109c5e268c6Sopenharmony_ci     * @return Returns <b>0</b> if the sensor data reporting mode is successfully set;
110c5e268c6Sopenharmony_ci     * returns a negative value otherwise.
111c5e268c6Sopenharmony_ci     *
112c5e268c6Sopenharmony_ci     * @since 2.2
113c5e268c6Sopenharmony_ci     * @version 1.0
114c5e268c6Sopenharmony_ci     */
115c5e268c6Sopenharmony_ci    SetMode([in] int sensorId, [in] int mode);
116c5e268c6Sopenharmony_ci
117c5e268c6Sopenharmony_ci    /**
118c5e268c6Sopenharmony_ci     * @brief Sets options for the specified sensor, including its measurement range and accuracy.
119c5e268c6Sopenharmony_ci     *
120c5e268c6Sopenharmony_ci     * @param sensorId Indicates the sensor ID. For details, see {@link SensorTypeTag}.
121c5e268c6Sopenharmony_ci     * @param option Indicates the options to set, such as the measurement range and accuracy.
122c5e268c6Sopenharmony_ci     * @return Returns <b>0</b> if the options are successfully set; returns a negative value otherwise.
123c5e268c6Sopenharmony_ci     *
124c5e268c6Sopenharmony_ci     * @since 2.2
125c5e268c6Sopenharmony_ci     * @version 1.0
126c5e268c6Sopenharmony_ci     */
127c5e268c6Sopenharmony_ci    SetOption([in] int sensorId, [in] unsigned int option);
128c5e268c6Sopenharmony_ci
129c5e268c6Sopenharmony_ci    /**
130c5e268c6Sopenharmony_ci     * @brief Registers the callback for reporting sensor data to the subscriber.
131c5e268c6Sopenharmony_ci     *
132c5e268c6Sopenharmony_ci     * @param groupId Indicates the sensor group ID.
133c5e268c6Sopenharmony_ci     * The sensorId enumeration value range is 128-160, which means that the medical sensor service is subscribed.
134c5e268c6Sopenharmony_ci     * It only needs to be subscribed once successfully, and there is no need to subscribe repeatedly.
135c5e268c6Sopenharmony_ci     * The sensorId enumeration value range is not within 128-160, which means that the traditional sensor
136c5e268c6Sopenharmony_ci     * is subscribed, and the subscription is successful once.
137c5e268c6Sopenharmony_ci     * @param callbackObj Indicates the callback to register. For details, see {@link ISensorCallback}.
138c5e268c6Sopenharmony_ci     * @return Returns <b>0</b> if the callback is successfully registered; returns a negative value otherwise.
139c5e268c6Sopenharmony_ci     *
140c5e268c6Sopenharmony_ci     * @since 2.2
141c5e268c6Sopenharmony_ci     * @version 1.0
142c5e268c6Sopenharmony_ci     */
143c5e268c6Sopenharmony_ci    Register([in] int groupId, [in] ISensorCallback callbackObj);
144c5e268c6Sopenharmony_ci
145c5e268c6Sopenharmony_ci    /**
146c5e268c6Sopenharmony_ci     * @brief Deregisters the callback for reporting sensor data.
147c5e268c6Sopenharmony_ci     *
148c5e268c6Sopenharmony_ci     * @param groupId Indicates the sensor group ID.
149c5e268c6Sopenharmony_ci     * The sensorId enumeration value range is 128-160, which means that the medical sensor service is subscribed.
150c5e268c6Sopenharmony_ci     * It only needs to cancel the subscription once successfully, and there is no need to
151c5e268c6Sopenharmony_ci     * cancel the subscription repeatedly. The sensorId enumeration value range is not within 128-160,
152c5e268c6Sopenharmony_ci     * which means that the traditional sensor is subscribed. You can cancel the subscription once successfully.
153c5e268c6Sopenharmony_ci     * @param callbackObj Indicates the callback to deregister. For details, see {@link ISensorCallback}.
154c5e268c6Sopenharmony_ci     * @return Returns <b>0</b> if the callback is successfully deregistered; returns a negative value otherwise.
155c5e268c6Sopenharmony_ci     *
156c5e268c6Sopenharmony_ci     * @since 2.2
157c5e268c6Sopenharmony_ci     * @version 1.0
158c5e268c6Sopenharmony_ci     */
159c5e268c6Sopenharmony_ci    Unregister([in] int groupId, [in] ISensorCallback callbackObj);
160c5e268c6Sopenharmony_ci
161c5e268c6Sopenharmony_ci    /**
162c5e268c6Sopenharmony_ci     * @brief Obtain the sensor event data in the small system.
163c5e268c6Sopenharmony_ci     *
164c5e268c6Sopenharmony_ci     * @param sensorId Indicates the sensor ID. For details, see {@link SensorTypeTag}.
165c5e268c6Sopenharmony_ci     * @param event Indicates the vector of the sensor event data in the system.
166c5e268c6Sopenharmony_ci     * The sensor event data includes the sensor ID, sensor algorithm version, data generation time,
167c5e268c6Sopenharmony_ci     * data options (such as the measurement range and accuracy), data reporting mode, data address, and data length.
168c5e268c6Sopenharmony_ci     * For details, see {@link HdfSensorEvents}.
169c5e268c6Sopenharmony_ci     * @return Returns <b>0</b> if the event data is obtained; returns a negative value otherwise.
170c5e268c6Sopenharmony_ci     *
171c5e268c6Sopenharmony_ci     * @since 4.0
172c5e268c6Sopenharmony_ci     * @version 1.1
173c5e268c6Sopenharmony_ci     */
174c5e268c6Sopenharmony_ci    ReadData([in] int sensorId, [out] struct HdfSensorEvents[] event);
175c5e268c6Sopenharmony_ci
176c5e268c6Sopenharmony_ci    /**
177c5e268c6Sopenharmony_ci     * @brief Obtain the sensor event data in the small system.
178c5e268c6Sopenharmony_ci     *
179c5e268c6Sopenharmony_ci     * @param sensorId Indicates the sensor ID. For details, see {@link SensorTypeTag}.
180c5e268c6Sopenharmony_ci     * @param enabled Indicates if the value is enabled.
181c5e268c6Sopenharmony_ci     * @param rateLevel Indicates rateClass.
182c5e268c6Sopenharmony_ci     * @return Returns <b>0</b> if the event data is obtained; returns a negative value otherwise.
183c5e268c6Sopenharmony_ci     *
184c5e268c6Sopenharmony_ci     * @since 4.1
185c5e268c6Sopenharmony_ci     * @version 2.0
186c5e268c6Sopenharmony_ci     */
187c5e268c6Sopenharmony_ci    SetSdcSensor([in] int sensorId, [in] boolean enabled, [in] int rateLevel);
188c5e268c6Sopenharmony_ci
189c5e268c6Sopenharmony_ci    /**
190c5e268c6Sopenharmony_ci     * @brief Obtain sensor information for SDC
191c5e268c6Sopenharmony_ci     *
192c5e268c6Sopenharmony_ci     * @param sdcSensorInfos Indicates the data of the SDC type.
193c5e268c6Sopenharmony_ci     * @return Returns <b>0</b> if the event data is obtained; returns a negative value otherwise.
194c5e268c6Sopenharmony_ci     *
195c5e268c6Sopenharmony_ci     * @since 4.1
196c5e268c6Sopenharmony_ci     * @version 2.0
197c5e268c6Sopenharmony_ci     */
198c5e268c6Sopenharmony_ci    GetSdcSensorInfo([out] struct SdcSensorInfo[] sdcSensorInfo);
199c5e268c6Sopenharmony_ci}
200