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