• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 - 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 #ifndef I_TAG_SESSION_H
16 #define I_TAG_SESSION_H
17 
18 #include "element_name.h"
19 #include "foreground_callback_stub.h"
20 #include "iremote_broker.h"
21 #include "nfc_sdk_common.h"
22 #include "parcel.h"
23 
24 namespace OHOS {
25 namespace NFC {
26 namespace TAG {
27 class ITagSession : public OHOS::IRemoteBroker {
28 public:
29     DECLARE_INTERFACE_DESCRIPTOR(u"ohos.nfc.TAG.ITagSession");
30 
~ITagSession()31     virtual ~ITagSession() {}
32     /**
33      * @brief To connect the tagRfDiscId by technology.
34      * @param tagRfDiscId the rf disc id of tag
35      * @param technology the tag technology
36      * @return the result to connect the tag
37      */
38     virtual int Connect(int tagRfDiscId, int technology) = 0;
39     /**
40      * @brief To reconnect the tagRfDiscId.
41      * @param tagRfDiscId the rf disc id of tag
42      * @return the result to reconnect the tag
43      */
44     virtual int Reconnect(int tagRfDiscId) = 0;
45     /**
46      * @brief To disconnect the tagRfDiscId.
47      * @param tagRfDiscId the rf disc id of tag
48      */
49     virtual void Disconnect(int tagRfDiscId) = 0;
50     /**
51      * @brief Set the Timeout for tag operations
52      *
53      * @param timeout the timeout value to set for tag operations
54      * @param technology the tag technology
55      * @return the tatus code for function calling.
56      */
57     virtual int SetTimeout(int timeout, int technology) = 0;
58     /**
59      * @brief Get the Timeout value of tag operations
60      *
61      * @param technology the tag technology
62      * @param timeout the output argument to read the timeout.
63      * @return the tatus code for function calling.
64      */
65     virtual int GetTimeout(int technology, int &timeout) = 0;
66     /**
67      * @brief Get the TechList of the tagRfDiscId.
68      * @param tagRfDiscId the rf disc id of tag
69      * @return TechList
70      */
71     virtual std::vector<int> GetTechList(int tagRfDiscId) = 0;
72     /**
73      * @brief Checking the tagRfDiscId is field on.
74      * @param tagRfDiscId the rf disc id of tag
75      * @return true - Presnet; the other - No Presnet
76      */
77     virtual bool IsTagFieldOn(int tagRfDiscId) = 0;
78     /**
79      * @brief Checking the tagRfDiscId is a Ndef Tag.
80      * @param tagRfDiscId the rf disc id of tag
81      * @return true - Ndef Tag; the other - No Ndef Tag
82      */
83     virtual bool IsNdef(int tagRfDiscId) = 0;
84     /**
85      * @brief To send the data to the tagRfDiscId.
86      * @param tagRfDiscId the rf disc id of tag
87      * @param hexCmdData the sent data
88      * @param hexRespData the response hex data.
89      * @param raw to send whether original data or un-original data
90      * @return the error code of calling function.
91      */
92     virtual int SendRawFrame(int tagRfDiscId, std::string hexCmdData, bool raw, std::string &hexRespData) = 0;
93     /**
94      * @brief Reading from the host tag
95      * @param tagRfDiscId the rf disc id of tag
96      * @return the read data
97      */
98     virtual std::string NdefRead(int tagRfDiscId) = 0;
99     /**
100      * @brief Writing the data into the host tag.
101      * @param tagRfDiscId the rf disc id of tag
102      * @param msg the wrote data
103      * @return the Writing Result
104      */
105     virtual int NdefWrite(int tagRfDiscId, std::string msg) = 0;
106     /**
107      * @brief Making the host tag to read only.
108      * @param tagRfDiscId the rf disc id of tag
109      * @return the making result
110      */
111     virtual int NdefMakeReadOnly(int tagRfDiscId) = 0;
112     /**
113      * @brief format the tag by Ndef
114      * @param tagRfDiscId the rf disc id of tag
115      * @param key the format key
116      * @return the format result
117      */
118     virtual int FormatNdef(int tagRfDiscId, const std::string& key) = 0;
119     /**
120      * @brief Checking the host tag is Read only
121      * @param ndefType the ndef type.
122      * @param canSetReadOnly the output for read only or not.
123      * @return the error code of calling function.
124      */
125     virtual int CanMakeReadOnly(int ndefType, bool &canSetReadOnly) = 0;
126     /**
127      * @brief Get Max Transceive Length
128      * @param technology the tag technology
129      * @return Max Transceive Length
130      */
131     virtual int GetMaxTransceiveLength(int technology, int &maxSize) = 0;
132     /**
133      * @brief Checking the NfccHost whether It supported the extended Apdus
134      * @param isSupported the output for checking supportting extended apdu or not.
135      * @return the error code of calling function.
136      */
137     virtual int IsSupportedApdusExtended(bool &isSupported) = 0;
138 
139     /**
140      * @brief register foreground dispatch
141      *
142      * @param element the element name of the hap that request to register foreground dispatch.
143      * @param discTech the tag technologies in int array the the hap wants to discover.
144      * @param callback the callback to be registered
145      * @return The status code for register operation.
146      */
147     virtual KITS::ErrorCode RegForegroundDispatch(AppExecFwk::ElementName element,
148         std::vector<uint32_t> &discTech, const sptr<KITS::IForegroundCallback> &callback) = 0;
149 
150     /**
151      * @brief unregister foreground dispatch
152      *
153      * @param element the element name of the hap that request to unregister foreground dispatch.
154      * @return The status code for unregister operation.
155      */
156     virtual KITS::ErrorCode UnregForegroundDispatch(AppExecFwk::ElementName element) = 0;
157 private:
158 };
159 }  // namespace TAG
160 }  // namespace NFC
161 }  // namespace OHOS
162 #endif  // I_TAG_SESSION_H
163