From ef202fc2eadb0b7cf80c0635c62c7f5e2c32d999 Mon Sep 17 00:00:00 2001 From: zhaoyi Date: Fri, 15 Apr 2022 10:52:33 +0800 Subject: [PATCH] add hdi nfc idl interfaces Signed-off-by: zhaoyi --- nfc/nfc_core/v1_0/BUILD.gn | 27 ++++++ nfc/nfc_core/v1_0/INfcCallback.idl | 61 +++++++++++++ nfc/nfc_core/v1_0/INfcInterface.idl | 137 ++++++++++++++++++++++++++++ nfc/nfc_core/v1_0/NfcTypes.idl | 79 ++++++++++++++++ 4 files changed, 304 insertions(+) create mode 100644 nfc/nfc_core/v1_0/BUILD.gn create mode 100644 nfc/nfc_core/v1_0/INfcCallback.idl create mode 100644 nfc/nfc_core/v1_0/INfcInterface.idl create mode 100644 nfc/nfc_core/v1_0/NfcTypes.idl diff --git a/nfc/nfc_core/v1_0/BUILD.gn b/nfc/nfc_core/v1_0/BUILD.gn new file mode 100644 index 00000000..96062351 --- /dev/null +++ b/nfc/nfc_core/v1_0/BUILD.gn @@ -0,0 +1,27 @@ +# Copyright (c) 2022 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("nfc_core") { + module_name = "nfc_core_service" + + sources = [ + "INfcCallback.idl", + "INfcInterface.idl", + "NfcTypes.idl", + ] + + language = "cpp" + subsystem_name = "hdf" + part_name = "nfc" +} \ No newline at end of file diff --git a/nfc/nfc_core/v1_0/INfcCallback.idl b/nfc/nfc_core/v1_0/INfcCallback.idl new file mode 100644 index 00000000..6f2a27f1 --- /dev/null +++ b/nfc/nfc_core/v1_0/INfcCallback.idl @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2022 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 HdiNfc + * @{ + * + * @brief Provides unified APIs for nfc services to access nfc drivers. + * + * An nfc service can obtain an nfc driver object or agent and then call APIs provided by this object or agent to + * access nfc devices, thereby obtaining enabling or disabling an nfc controller, initializing an nfc core, + * writing NCI data to an nfc driver, starting configuration for RF discovery of nfc remote endpoints, + * sending nfc commands to an nfc driver for IO control. + * + * @version 1.0 + */ + + +package ohos.hdi.nfc.nfc_core.v1_0; + +import ohos.hdi.nfc.nfc_core.v1_0.NfcTypes; + +/** + * @brief Declares callbacks for reporting data and events from the nfc chip to the nfc stack. + * + * @since 2.2 + * @version 1.0 + */ +[callback] interface INfcCallback { + /** + * @brief Defines the function for reporting nfc data from the nfc chip. + * + * @param data Indicates the reporting data from nfc chip. + * + * @since 2.2 + */ + onData([in] List data); + + /** + * @brief Defines the function for reporting nfc events from the nfc chip. + * + * @param event Indicates the reporting event ID defined in NfcEvent. + * @param status Indicates the reporting nfc status defined in NfcStatus. For details, + * see {@link NfcTypes}. + * + * @since 2.2 + */ + onEvent([in] NfcEvent event, [in] NfcStatus status); +} diff --git a/nfc/nfc_core/v1_0/INfcInterface.idl b/nfc/nfc_core/v1_0/INfcInterface.idl new file mode 100644 index 00000000..d10a3334 --- /dev/null +++ b/nfc/nfc_core/v1_0/INfcInterface.idl @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2022 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 HdiNfc + * @{ + * + * @brief Provides unified APIs for nfc services to access nfc drivers. + * + * An nfc service can obtain an nfc driver object or agent and then call APIs provided by this object or agent to + * access nfc devices, thereby obtaining enabling or disabling an nfc controller, initializing an nfc core, + * writing NCI data to an nfc driver, starting configuration for RF discovery of nfc remote endpoints, + * sending nfc commands to an nfc driver for IO control. + * + * @version 1.0 + */ + +package ohos.hdi.nfc.nfc_core.v1_0; + +import ohos.hdi.nfc.nfc_core.v1_0.NfcTypes; +import ohos.hdi.nfc.nfc_core.v1_0.INfcCallback; + +/** + * @brief Declares the APIs provided by the nfc module for obtaining nfc controller operations, enabling or + * disabling an nfc controller, initializing an nfc core, writing NCI data to an nfc driver, starting + * configuration for RF discovery of nfc remote endpoints, sending nfc commands to an nfc driver for IO control. + * + * @since 2.2 + * @version 1.0 + */ + +interface INfcInterface { + /** + * @brief Enables the nfc controller and initialize the nfc core. + * + * @param callbackObj Indicates the callback to obtain the data and events that sent to nfc stack by the nfc chip. + * @return Returns 0 if the operation is succeed, otherwise marks the reason of failure. + * For details, see {@link NfcTypes}. + * + * @since 2.2 + * @version 1.0 + */ + open([in] INfcCallback callbackObj, [out] enum NfcStatus status); + + /** + * @brief Configures the nfc chip after initializing the nfc core. + * + * @param callbackObj Indicates the callback to obtain the data and events that sent to nfc stack by the nfc chip. + * @return Returns 0 if the operation is succeed, otherwise marks the reason of failure. + * For details, see {@link NfcTypes}. + * + * @since 2.2 + * @version 1.0 + */ + coreInitialized([in] INfcCallback callbackObj, [out] enum NfcStatus status); + + /** + * @brief Specifically configures the nfc chip before starting RF discovering. + * + * @return Returns 0 if the operation is succeed, otherwise marks the reason of failure. + * For details, see {@link NfcTypes}. + * + * @since 2.2 + * @version 1.0 + */ + prediscover([out] enum NfcStatus status); + + /** + * @brief Writes NCI data to the nfc core. + * + * @param data the NCI data sending to the nfc controller interface. + * @return Returns 0 if the operation is succeed, otherwise marks the reason of failure. + * For details, see {@link NfcTypes}. + * + * @since 2.2 + * @version 1.0 + */ + write([in] List data, [out] enum NfcStatus status); + + /** + * @brief Sets the HDF to allow to send NCI data. + * + * @return Returns 0 if the operation is succeed, otherwise marks the reason of failure. + * For details, see {@link NfcTypes}. + * + * @since 2.2 + * @version 1.0 + */ + controlGranted([out] enum NfcStatus status); + + /** + * @brief Restarts the nfc controller according to each power cycle. + * + * @return Returns 0if the operation is succeed, otherwise marks the reason of failure. + * For details, see {@link NfcTypes}. + * + * @since 2.2 + * @version 1.0 + */ + powerCycle([out] enum NfcStatus status); + + /** + * @brief Disables the nfc controller and releases the resource. + * + * @return Returns 0 if the operation is succeed, otherwise marks the reason of failure. + * For details, see {@link NfcTypes}. + * + * @since 2.2 + * @version 1.0 + */ + close([out] enum NfcStatus status); + + /** + * @brief Sends I/O control commands and data from the nfc stack to HDI. + * + * @param cmd Indicates the commands that defined in NfcCommand in {@link NfcTypes}. + * @param data Indicates the data that sent to HDI. + * @return Returns 0 if the operation is succeed, otherwise marks the reason of failure. + * For details, see {@link NfcTypes}. + * + * @since 2.2 + * @version 1.0 + */ + ioctl([in] enum NfcCommand cmd, [in] List data, [out] enum NfcStatus status); +} diff --git a/nfc/nfc_core/v1_0/NfcTypes.idl b/nfc/nfc_core/v1_0/NfcTypes.idl new file mode 100644 index 00000000..a0673bdf --- /dev/null +++ b/nfc/nfc_core/v1_0/NfcTypes.idl @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2022 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 HdiNfc + * @{ + * + * @brief Provides unified APIs for nfc services to access nfc drivers. + * + * An nfc service can obtain an nfc driver object or agent and then call APIs provided by this object or agent to + * access nfc devices, thereby obtaining enabling or disabling an nfc controller, initializing an nfc core, + * writing NCI data to an nfc driver, starting configuration for RF discovery of nfc remote endpoints, + * sending nfc commands to an nfc driver for IO control. + * + * @version 1.0 + */ + +/** + * @file NfcType.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 2.2 + * @version 1.0 + */ + +package ohos.hdi.nfc.nfc_core.v1_0; + +/** + * @brief Enumerates return values of the Nfc Event. + * + * @since 2.2 + */ +enum NfcEvent { + OPEN_CPLT = 0, + CLOSE_CPLT = 1, + POST_INIT_CPLT = 2, + PRE_DISCOVER_CPLT = 3, + REQUEST_CONTROL = 4, + RELEASE_CONTROL = 5, + ERROR = 6, + HCI_NETWORK_RESET = 7, +}; + +/** + * @brief Enumerates return values of the Nfc status. + * + * @since 2.2 + */ +enum NfcStatus { + OK = 0, + FAILED = 1, + ERR_TRANSPORT = 2, + ERR_CMD_TIMEOUT = 3, + REFUSED = 4, +}; + +/** + * @brief Enumerates return values of the Nfc command. + * + * @since 2.2 + */ +enum NfcCommand { + CMD_INVALID = 0, +}; -- Gitee