diff --git a/sensor/bundle.json b/sensor/bundle.json index 1394cdea28b9ed03a0701e797769b0f87fedee9f..34857b186c3c8be643732cd891f50d51a1c2407f 100644 --- a/sensor/bundle.json +++ b/sensor/bundle.json @@ -27,7 +27,8 @@ }, "build": { "sub_component": [ - "//drivers/interface/sensor/v2_0:sensor_idl_target" + "//drivers/interface/sensor/v2_0:sensor_idl_target", + "//drivers/interface/sensor/v2_1:sensor_idl_target" ], "test": [ ], @@ -55,6 +56,22 @@ ], "header_base": "//drivers/interface/sensor" } + }, + { + "name": "//drivers/interface/sensor/v2_1:libsensor_proxy_2.1", + "header": { + "header_files": [ + ], + "header_base": "//drivers/interface/sensor" + } + }, + { + "name": "//drivers/interface/sensor/v2_1:libsensor_stub_2.1", + "header": { + "header_files": [ + ], + "header_base": "//drivers/interface/sensor" + } } ] } diff --git a/sensor/v2_1/BUILD.gn b/sensor/v2_1/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..13dcd572320812a0a3712ae99264e3137c097ad5 --- /dev/null +++ b/sensor/v2_1/BUILD.gn @@ -0,0 +1,39 @@ +# 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. + +import("//build/config/components/hdi/hdi.gni") +if (defined(ohos_lite)) { + group("libsensor_proxy_2.1") { + deps = [] + public_configs = [] + } +} else { + hdi("sensor") { + module_name = "sensor_service" + + sources = [ + "ISensorCallback.idl", + "ISensorInterface.idl", + "SensorTypes.idl", + ] + + deps = [ + "//drivers/interface/sensor/v2_0:libsensor_proxy_2.0", + "//drivers/interface/sensor/v2_0:libsensor_stub_2.0", + ] + + language = "cpp" + subsystem_name = "hdf" + part_name = "drivers_interface_sensor" + } +} diff --git a/sensor/v2_1/ISensorCallback.idl b/sensor/v2_1/ISensorCallback.idl new file mode 100644 index 0000000000000000000000000000000000000000..d184f72c9e752e0103633a3fd4fa27a762e3fa25 --- /dev/null +++ b/sensor/v2_1/ISensorCallback.idl @@ -0,0 +1,50 @@ +/* + * 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. + * + * @version 2.0 + */ + +package ohos.hdi.sensor.v2_1; + +import ohos.hdi.sensor.v2_0.SensorTypes; +import ohos.hdi.sensor.v2_0.ISensorCallback; + +/** + * @brief Defines the callback for reporting sensor data. This callback needs to be registered when + * a sensor user subscribes to sensor data. Only after the sensor is enabled, the sensor data subscriber can receive + * sensor data. For details, see {@link ISensorInterface}. + * + * @since 5.1 + */ +[callback] interface ISensorCallback extends ohos.hdi.sensor.v2_0.ISensorCallback { + /** + * @brief Defines the function for reporting sensor data. + * @param event Indicates the information about sensor event in the system. + * + * @since 1.0 + */ + [oneway] OnDataEventOneWay([in] struct HdfSensorEvents event); +} diff --git a/sensor/v2_1/ISensorInterface.idl b/sensor/v2_1/ISensorInterface.idl new file mode 100644 index 0000000000000000000000000000000000000000..1540f92d5f4947ba02652782cb66615e0f6fd398 --- /dev/null +++ b/sensor/v2_1/ISensorInterface.idl @@ -0,0 +1,87 @@ +/* + * 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 2.1 + */ + +package ohos.hdi.sensor.v2_0; + +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 + */ + RegisterOneWay([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 + */ + UnregisterOneWay([in] int groupId, [in] ISensorCallback callbackObj); +}