1 /* 2 * Copyright (C) 2022 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 #ifndef I_NFCC_HOST_H 16 #define I_NFCC_HOST_H 17 18 #include <memory> 19 #include <string> 20 #include <vector> 21 22 #include "itag_host.h" 23 24 namespace OHOS { 25 namespace NFC { 26 namespace NCI { 27 class INfccHost { 28 public: 29 class INfccHostListener { 30 public: ~INfccHostListener()31 virtual ~INfccHostListener() {} 32 virtual void OnTagDiscovered(std::shared_ptr<NCI::ITagHost> tagHost) = 0; 33 virtual void FieldActivated() = 0; 34 virtual void FieldDeactivated() = 0; 35 }; 36 ~INfccHost()37 virtual ~INfccHost() {} 38 virtual void SetNfccHostListener(std::weak_ptr<INfccHostListener> listener) = 0; 39 /** 40 * @brief Turn on NFC 41 * @return True if ok 42 */ 43 virtual bool Initialize() = 0; 44 /** 45 * @brief Turn off NFC 46 * @return True if ok 47 */ 48 virtual bool Deinitialize() = 0; 49 /** 50 * @brief Start polling and listening 51 * @param techMask bitmask of the technologies 52 * @param enableReaderMode if enable tag polling 53 * @param enableHostRouting if enable host routing 54 * @param restart if need restart 55 */ 56 virtual void EnableDiscovery(uint16_t techMask, bool enableReaderMode, bool enableHostRouting, bool restart) = 0; 57 /** 58 * @brief Stop polling and listening 59 */ 60 virtual void DisableDiscovery() = 0; 61 /** 62 * @brief Send a raw frame 63 * @param rawData raw frame 64 * @return True if ok 65 */ 66 virtual bool SendRawFrame(std::string& rawData) = 0; 67 /** 68 * @brief Send screen statue 69 * @param screenStateMask bitmask of the screen state 70 * @return True if ok 71 */ 72 virtual bool SetScreenStatus(unsigned char screenStateMask) = 0; 73 /** 74 * @brief Get Nci version 75 * @return Nci version 76 */ 77 virtual int GetNciVersion() = 0; 78 /** 79 * @brief Set Secure Nfc 80 * @param secure if need secure nfc 81 * @return True if ok 82 */ 83 virtual bool SetSecureNfc(bool secure) = 0; 84 /** 85 * @brief Get maximum tranceive length 86 * @return max length 87 */ 88 virtual int GetIsoDepMaxTransceiveLength() = 0; 89 virtual int RegisterT3tIdentifier(std::string& t3tIdentifier) = 0; 90 virtual void DeregisterT3tIdentifier(std::string& t3tIdentifier) = 0; 91 virtual void ClearT3tIdentifiersCache() = 0; 92 virtual int GetLfT3tMax() = 0; 93 virtual int GetLastError() = 0; 94 virtual void Abort() = 0; 95 /** 96 * @brief Download firmware 97 * @return True if ok 98 */ 99 virtual bool CheckFirmware() = 0; 100 virtual void Dump(int fd) = 0; 101 virtual void FactoryReset() = 0; 102 virtual void Shutdown() = 0; 103 virtual bool AddAidRouting(std::string& aid, int route, int aidInfo) = 0; 104 virtual bool RemoveAidRouting(std::string& aid) = 0; 105 virtual bool CommitRouting() = 0; 106 virtual bool ComputeRoutingParams() = 0; 107 virtual int GetAidRoutingTableSize() = 0; 108 virtual int GetDefaultRoute() = 0; 109 virtual int GetDefaultOffHostRoute() = 0; 110 virtual std::vector<int> GetOffHostUiccRoute() = 0; 111 virtual std::vector<int> GetOffHostEseRoute() = 0; 112 virtual int GetAidMatchingMode() = 0; 113 virtual int GetDefaultIsoDepRouteDestination() = 0; 114 virtual bool CanMakeReadOnly(int ndefType) = 0; 115 virtual bool GetExtendedLengthApdusSupported() = 0; 116 virtual bool ClearAidTable() = 0; 117 virtual int GetRemainRoutingTableSize() = 0; 118 }; 119 } // namespace NCI 120 } // namespace NFC 121 } // namespace OHOS 122 #endif // I_NFCC_HOST_H 123