1/* 2 * Copyright (c) 2023 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#ifndef OHOS_HDI_NFC_V1_1_INFCINTERFACE_H 17#define OHOS_HDI_NFC_V1_1_INFCINTERFACE_H 18 19#include <stdint.h> 20#include <vector> 21#include <hdf_base.h> 22#include <hdi_base.h> 23#include "nfc/v1_0/infc_interface.h" 24#include "nfc/v1_0/nfc_types.h" 25#include "nfc/v1_1/nfc_types.h" 26 27#ifndef HDI_BUFF_MAX_SIZE 28#define HDI_BUFF_MAX_SIZE (1024 * 200) 29#endif 30 31#ifndef HDI_CHECK_VALUE_RETURN 32#define HDI_CHECK_VALUE_RETURN(lv, compare, rv, ret) do { \ 33 if ((lv) compare (rv)) { \ 34 return ret; \ 35 } \ 36} while (false) 37#endif 38 39#ifndef HDI_CHECK_VALUE_RET_GOTO 40#define HDI_CHECK_VALUE_RET_GOTO(lv, compare, rv, ret, value, table) do { \ 41 if ((lv) compare (rv)) { \ 42 ret = value; \ 43 goto table; \ 44 } \ 45} while (false) 46#endif 47 48namespace OHOS { 49namespace HDI { 50namespace Nfc { 51namespace V1_1 { 52using namespace OHOS; 53using namespace OHOS::HDI; 54using namespace OHOS::HDI::Nfc::V1_0; 55 56enum { 57 CMD_NFC_INTERFACE_GET_VENDOR_CONFIG = 9, 58 CMD_NFC_INTERFACE_DO_FACTORY_RESET = 10, 59 CMD_NFC_INTERFACE_SHUTDOWN = 11, 60 CMD_NFC_INTERFACE_IOCTL_WITH_RESPONSE = 12, 61}; 62 63class INfcInterface : public OHOS::HDI::Nfc::V1_0::INfcInterface { 64public: 65 DECLARE_HDI_DESCRIPTOR(u"ohos.hdi.nfc.v1_1.INfcInterface"); 66 67 virtual ~INfcInterface() = default; 68 69 static sptr<OHOS::HDI::Nfc::V1_1::INfcInterface> Get(bool isStub = false); 70 static sptr<OHOS::HDI::Nfc::V1_1::INfcInterface> Get(const std::string &serviceName, bool isStub = false); 71 72 static sptr<OHOS::HDI::Nfc::V1_1::INfcInterface> CastFrom(const sptr<OHOS::HDI::Nfc::V1_0::INfcInterface> &parent); 73 74 virtual int32_t GetVendorConfig(OHOS::HDI::Nfc::V1_1::NfcVendorConfig& config, 75 OHOS::HDI::Nfc::V1_0::NfcStatus& status) = 0; 76 77 virtual int32_t DoFactoryReset(OHOS::HDI::Nfc::V1_0::NfcStatus& status) = 0; 78 79 virtual int32_t Shutdown(OHOS::HDI::Nfc::V1_0::NfcStatus& status) = 0; 80 81 virtual int32_t IoctlWithResponse(OHOS::HDI::Nfc::V1_0::NfcCommand cmd, const std::vector<uint8_t>& data, 82 std::vector<uint8_t>& response, OHOS::HDI::Nfc::V1_0::NfcStatus& status) = 0; 83 84 int32_t GetVersion(uint32_t& majorVer, uint32_t& minorVer) override 85 { 86 majorVer = 1; 87 minorVer = 1; 88 return HDF_SUCCESS; 89 } 90 91 const std::u16string GetDesc() override 92 { 93 return metaDescriptor_; 94 } 95}; 96} // V1_1 97} // Nfc 98} // HDI 99} // OHOS 100 101#endif // OHOS_HDI_NFC_V1_1_INFCINTERFACE_H 102 103