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 BASIC_TAG_SESSION_H
16 #define BASIC_TAG_SESSION_H
17 
18 #include "itag_session.h"
19 #include "taginfo.h"
20 
21 namespace OHOS {
22 namespace NFC {
23 namespace KITS {
24 class BasicTagSession {
25 public:
26     explicit BasicTagSession(std::weak_ptr<TagInfo> tagInfo, KITS::TagTechnology technology);
~BasicTagSession()27     virtual ~BasicTagSession() {}
28 
29     int Connect();
30     bool IsConnected();
31     int Close();
32     int SetTimeout(int timeout);
33     int GetTimeout(int &timeout);
34     void ResetTimeout();
35     std::string GetTagUid();
36     int SendCommand(std::string& hexCmdData, bool raw, std::string &hexRespData);
37     int GetMaxSendCommandLength(int &maxSize);
38     std::weak_ptr<TagInfo> GetTagInfo() const;
39 
40 protected:
41     OHOS::sptr<TAG::ITagSession> GetTagSessionProxy();
42     int GetTagRfDiscId() const;
43     void SetConnectedTagTech(KITS::TagTechnology tech) const;
44     KITS::TagTechnology GetConnectedTagTech() const;
45 
46 private:
47     std::weak_ptr<TagInfo> tagInfo_;
48     OHOS::sptr<TAG::ITagSession> tagSessionProxy_;
49     KITS::TagTechnology tagTechnology_;
50 };
51 }  // namespace KITS
52 }  // namespace NFC
53 }  // namespace OHOS
54 #endif  // BASIC_TAG_SESSION_H
55