• 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 NFCC_HOST_H
16 #define NFCC_HOST_H
17 
18 #include <memory>
19 #include <string>
20 
21 #include "infc_nci.h"
22 #include "infcc_host.h"
23 #include "itag_host.h"
24 
25 namespace OHOS {
26 namespace NFC {
27 namespace NCI {
28 /* The maximum length of a default IsoDep frame consists of:
29  * CLA, INS, P1, P2, LC, LE + 255 payload bytes = 261 bytes
30  */
31 constexpr int ISO_DEP_FRAME_MAX_LEN = 261;
32 
33 class NfccHost : public INfccHost {
34 public:
35     explicit NfccHost(std::weak_ptr<INfccHostListener> listener);
36     ~NfccHost() override;
37     void SetNfccHostListener(std::weak_ptr<INfccHostListener> listener) override;
38     bool Initialize() override;
39     bool Deinitialize() override;
40     void EnableDiscovery(uint16_t techMask, bool enableReaderMode, bool enableHostRouting, bool restart) override;
41     void DisableDiscovery() override;
42     bool SendRawFrame(std::string& rawData) override;
43     bool SetScreenStatus(unsigned char screenStateMask) override;
44     int GetNciVersion() override;
45     bool SetSecureNfc(bool secure) override;
46     int GetIsoDepMaxTransceiveLength() override;
47     int RegisterT3tIdentifier(std::string& t3tIdentifier) override;
48     void DeregisterT3tIdentifier(std::string& t3tIdentifier) override;
49     void ClearT3tIdentifiersCache() override;
50     int GetLfT3tMax() override;
51     int GetLastError() override;
52     void Abort() override;
53     bool CheckFirmware() override;
54     void Dump(int fd) override;
55     void FactoryReset() override;
56     void Shutdown() override;
57     bool AddAidRouting(std::string& aid, int route, int aidInfo) override;
58     bool RemoveAidRouting(std::string& aid) override;
59     bool CommitRouting() override;
60     int GetAidRoutingTableSize() override;
61     int GetDefaultRoute() override;
62     int GetDefaultOffHostRoute() override;
63     std::vector<int> GetOffHostUiccRoute() override;
64     std::vector<int> GetOffHostEseRoute() override;
65     int GetAidMatchingMode() override;
66     int GetDefaultIsoDepRouteDestination() override;
67     bool CanMakeReadOnly(int ndefType) override;
68     bool GetExtendedLengthApdusSupported() override;
69     void SetNciAdaptation(std::shared_ptr<INfcNci> nciAdaptation);
70     static void RemoteFieldActivated();
71     static void RemoteFieldDeactivated();
72     static void HostCardEmulationActivated(int technology);
73     static void HostCardEmulationDeactivated(int technology);
74     static void HostCardEmulationDataReceived(int technology, std::string& data);
75     static void TagDiscovered(std::shared_ptr<NCI::ITagHost> tagHost);
76     static void OffHostTransactionEvent(std::string& aid, std::string& data, std::string& seName);
77     static void EeUpdate();
78     bool ClearAidTable() override;
79     int GetRemainRoutingTableSize() override;
80 
81 private:
82     static std::weak_ptr<INfccHostListener> nfccHostListener_;
83 };
84 }  // namespace NCI
85 }  // namespace NFC
86 }  // namespace OHOS
87 #endif /* NFCC_HOST_H */
88