1 /*
2  * Copyright (C) 2024 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 
16 #ifndef CONNECTED_NFC_TAG_VENDOR_ADAPTER_H
17 #define CONNECTED_NFC_TAG_VENDOR_ADAPTER_H
18 
19 #include "iconnected_nfc_tag_vendor.h"
20 
21 namespace OHOS {
22 namespace HDI {
23 namespace ConnectedNfcTag {
24 
25 using VendorGetChipType = const char *(*)();
26 
27 struct NfcTagHalInterface {
28     int32_t (*init)();
29     int32_t (*unInit)();
30     int32_t (*registerCallBack)(NfcTagChipEventCallbackT *callback);
31     int32_t (*writeNdefData)(const uint8_t *writeData, uint32_t writeLen);
32     int32_t (*readNdefData)(uint8_t *readData, uint32_t *readLen);
33 };
34 
35 class ConnectedNfcTagVendorAdapter : public IConnectedNfcTagVendor {
36 public:
37     ConnectedNfcTagVendorAdapter();
38     ~ConnectedNfcTagVendorAdapter() override;
39     int32_t Init() override;
40     int32_t UnInit() override;
41     int32_t RegisterCallBack(NfcTagChipEventCallbackT *callback) override;
42     int32_t WriteNdefData(const std::vector<uint8_t>& ndefData) override;
43     int32_t ReadNdefData(std::vector<uint8_t>& ndefData) override;
44 private:
45     int32_t GetInterfaceFromHal();
46 private:
47     void *halHandle; // handle of nfc hal so
48     NfcTagHalInterface infHandle;
49 };
50 
51 } // ConnectedNfcTag
52 } // HDI
53 } // OHOS
54 
55 #endif // CONNECTED_NFC_TAG_VENDOR_ADAPTER_H
56