From 9a78edaf31ac0f5f158bf49a299ca87a76c2a04e Mon Sep 17 00:00:00 2001 From: yangjunrui Date: Fri, 17 Dec 2021 11:34:42 +0800 Subject: [PATCH] feat : add sensor hdi ipc service implementation Signed-off-by: yangjunrui --- hdi/sensor/v1_0/BUILD.gn | 28 ++++++++++++++++++++ hdi/sensor/v1_0/ISensorCallback.idl | 22 ++++++++++++++++ hdi/sensor/v1_0/ISensorInterface.idl | 30 ++++++++++++++++++++++ hdi/sensor/v1_0/SensorTypes.idl | 38 ++++++++++++++++++++++++++++ 4 files changed, 118 insertions(+) create mode 100644 hdi/sensor/v1_0/BUILD.gn create mode 100644 hdi/sensor/v1_0/ISensorCallback.idl create mode 100644 hdi/sensor/v1_0/ISensorInterface.idl create mode 100644 hdi/sensor/v1_0/SensorTypes.idl diff --git a/hdi/sensor/v1_0/BUILD.gn b/hdi/sensor/v1_0/BUILD.gn new file mode 100644 index 00000000..f84fb995 --- /dev/null +++ b/hdi/sensor/v1_0/BUILD.gn @@ -0,0 +1,28 @@ +# Copyright (c) 2021 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("//drivers/adapter/uhdf2/hdi.gni") + +hdi("sensor") { + package = "hdi.sensor.v1_0" + + mode_name = "sensor_service" + + sources = [ + "ISensorCallback.idl", + "ISensorInterface.idl", + "SensorTypes.idl", + ] + + language = "cpp" +} diff --git a/hdi/sensor/v1_0/ISensorCallback.idl b/hdi/sensor/v1_0/ISensorCallback.idl new file mode 100644 index 00000000..3a36590f --- /dev/null +++ b/hdi/sensor/v1_0/ISensorCallback.idl @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2021 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. + */ + +package hdi.sensor.v1_0; + +import hdi.sensor.v1_0.SensorTypes; + +[callback] interface ISensorCallback { + OnDataEvent([in] struct HdfSensorEvents event); +} diff --git a/hdi/sensor/v1_0/ISensorInterface.idl b/hdi/sensor/v1_0/ISensorInterface.idl new file mode 100644 index 00000000..5a9a4f83 --- /dev/null +++ b/hdi/sensor/v1_0/ISensorInterface.idl @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2021 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. + */ + +package hdi.sensor.v1_0; + +import hdi.sensor.v1_0.SensorTypes; +import hdi.sensor.v1_0.ISensorCallback; + +interface ISensorInterface { + GetAllSensorInfo([out] struct HdfSensorInformation[] info); + Enable([in] int sensorId); + Disable([in] int sensorId); + SetBatch([in] int sensorId,[in] long samplingInterval, [in] long reportInterval); + SetMode([in] int sensorId, [in] int mode); + SetOption([in] int sensorId, [in] unsigned int option); + Register([in] ISensorCallback callbackObj); + Unregister(); +} diff --git a/hdi/sensor/v1_0/SensorTypes.idl b/hdi/sensor/v1_0/SensorTypes.idl new file mode 100644 index 00000000..d6f440cd --- /dev/null +++ b/hdi/sensor/v1_0/SensorTypes.idl @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2021 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. + */ + +package hdi.sensor.v1_0; + +struct HdfSensorInformation { + String sensorName; + String vendorName; + String firmwareVersion; + String hardwareVersion; + int sensorTypeId; + int sensorId; + float maxRange; + float accuracy; + float power; +}; + +struct HdfSensorEvents { + int sensorId; + int version; + int timestamp; + unsigned int option; + int mode; + unsigned char[] data; + unsigned int dataLen; +}; -- Gitee