/* * Copyright (c) 2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @addtogroup HdiSensor * @{ * * @brief Provides unified APIs for sensor services to access sensor drivers. * * A sensor service can obtain a sensor driver object or agent and then call APIs provided by this object or agent to * access different types of sensor devices based on the sensor IDs, thereby obtaining sensor information, * subscribing to or unsubscribing from sensor data, enabling or disabling a sensor, * setting the sensor data reporting mode, and setting sensor options such as the accuracy and measurement range. * * @since 5.1 */ /** * @file ISensorInterface.idl * * @brief Declares the APIs provided by the sensor module for obtaining sensor information, subscribing to or * unsubscribing from sensor data, enabling or disabling a sensor, setting the sensor data reporting mode, * and setting sensor options such as the accuracy and measurement range. * * @since 5.1 * @version 1.1 */ package ohos.hdi.sensor.v2_1; import ohos.hdi.sensor.v2_0.SensorTypes; import ohos.hdi.sensor.v2_1.ISensorCallback; import ohos.hdi.sensor.v2_0.ISensorInterface; /** * @brief Defines the functions for performing basic operations on sensors. * * The operations include obtaining sensor information, subscribing to or unsubscribing from sensor data, * enabling or disabling a sensor, setting the sensor data reporting mode, and setting sensor options such as * the accuracy and measurement range. */ interface ISensorInterface extends ohos.hdi.sensor.v2_0.ISensorInterface { /** * @brief Registers the callback for reporting sensor data to the subscriber. * * @param groupId Indicates the sensor group ID. * The sensorId enumeration value range is 128-160, which means that the medical sensor service is subscribed. * It only needs to be subscribed once successfully, and there is no need to subscribe repeatedly. * The sensorId enumeration value range is not within 128-160, which means that the traditional sensor * is subscribed, and the subscription is successful once. * @param callbackObj Indicates the callback to register. For details, see {@link ISensorCallback}. * @return Returns 0 if the callback is successfully registered; returns a negative value otherwise. * * @since 5.1 * @version 1.0 */ RegisterAsync([in] int groupId, [in] ISensorCallback callbackObj); /** * @brief Deregisters the callback for reporting sensor data. * * @param groupId Indicates the sensor group ID. * The sensorId enumeration value range is 128-160, which means that the medical sensor service is subscribed. * It only needs to cancel the subscription once successfully, and there is no need to * cancel the subscription repeatedly. The sensorId enumeration value range is not within 128-160, * which means that the traditional sensor is subscribed. You can cancel the subscription once successfully. * @param callbackObj Indicates the callback to deregister. For details, see {@link ISensorCallback}. * @return Returns 0 if the callback is successfully deregistered; returns a negative value otherwise. * * @since 5.1 * @version 1.0 */ UnregisterAsync([in] int groupId, [in] ISensorCallback callbackObj); }