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/** 17 * @addtogroup HdiSensor 18 * @{ 19 * 20 * @brief Provides unified APIs for sensor services to access sensor drivers. 21 * 22 * A sensor service can obtain a sensor driver object or agent and then call APIs provided by this object or agent to 23 * access different types of sensor devices based on the sensor IDs, thereby obtaining sensor information, 24 * subscribing to or unsubscribing from sensor data, enabling or disabling a sensor, 25 * setting the sensor data reporting mode, and setting sensor options such as the accuracy and measurement range. 26 * 27 * @since 5.1 28 */ 29 30/** 31 * @file ISensorInterface.idl 32 * 33 * @brief Declares the APIs provided by the sensor module for obtaining sensor information, subscribing to or 34 * unsubscribing from sensor data, enabling or disabling a sensor, setting the sensor data reporting mode, 35 * and setting sensor options such as the accuracy and measurement range. 36 * 37 * @since 5.1 38 * @version 1.1 39 */ 40 41package ohos.hdi.sensor.v2_1; 42 43import ohos.hdi.sensor.v2_0.SensorTypes; 44import ohos.hdi.sensor.v2_1.ISensorCallback; 45import ohos.hdi.sensor.v2_0.ISensorInterface; 46 47/** 48 * @brief Defines the functions for performing basic operations on sensors. 49 * 50 * The operations include obtaining sensor information, subscribing to or unsubscribing from sensor data, 51 * enabling or disabling a sensor, setting the sensor data reporting mode, and setting sensor options such as 52 * the accuracy and measurement range. 53 */ 54 55interface ISensorInterface extends ohos.hdi.sensor.v2_0.ISensorInterface { 56 /** 57 * @brief Registers the callback for reporting sensor data to the subscriber. 58 * 59 * @param groupId Indicates the sensor group ID. 60 * The sensorId enumeration value range is 128-160, which means that the medical sensor service is subscribed. 61 * It only needs to be subscribed once successfully, and there is no need to subscribe repeatedly. 62 * The sensorId enumeration value range is not within 128-160, which means that the traditional sensor 63 * is subscribed, and the subscription is successful once. 64 * @param callbackObj Indicates the callback to register. For details, see {@link ISensorCallback}. 65 * @return Returns <b>0</b> if the callback is successfully registered; returns a negative value otherwise. 66 * 67 * @since 5.1 68 * @version 1.0 69 */ 70 RegisterAsync([in] int groupId, [in] ISensorCallback callbackObj); 71 72 /** 73 * @brief Deregisters the callback for reporting sensor data. 74 * 75 * @param groupId Indicates the sensor group ID. 76 * The sensorId enumeration value range is 128-160, which means that the medical sensor service is subscribed. 77 * It only needs to cancel the subscription once successfully, and there is no need to 78 * cancel the subscription repeatedly. The sensorId enumeration value range is not within 128-160, 79 * which means that the traditional sensor is subscribed. You can cancel the subscription once successfully. 80 * @param callbackObj Indicates the callback to deregister. For details, see {@link ISensorCallback}. 81 * @return Returns <b>0</b> if the callback is successfully deregistered; returns a negative value otherwise. 82 * 83 * @since 5.1 84 * @version 1.0 85 */ 86 UnregisterAsync([in] int groupId, [in] ISensorCallback callbackObj); 87} 88