LibLogicalAccess  2.5.0
An Open Source RFID Library
Loading...
Searching...
No Matches
ndefmessage.hpp
Go to the documentation of this file.
1
7#ifndef LOGICALACCESS_NDEFMESSAGE_HPP
8#define LOGICALACCESS_NDEFMESSAGE_HPP
9
14
15namespace logicalaccess
16{
17 #define NDEF_MESSAGE 0x03
19{
20 Text = 0x54,
21 Uri = 0x55
22};
23
24class LLA_CORE_API NdefMessage : public NfcData
25{
26 public:
28 explicit NdefMessage(const ByteVector &data);
29 virtual ~NdefMessage()
30 {
31 }
32
33 ByteVector encode();
34
35 void addRecord(std::shared_ptr<NdefRecord> record)
36 {
37 m_records.push_back(record);
38 }
39 void removeRecord(unsigned int i);
40 void addTextRecord(std::string text, std::string language, UTF utf = UTF_8);
41 void addEmptyRecord();
42 void addUriRecord(std::string uri, UriType uritype);
43 void addMimeMediaRecord(std::string mimeType, ByteVector payload);
44
45 size_t getRecordCount() const
46 {
47 return m_records.size();
48 }
49 std::vector<std::shared_ptr<NdefRecord>> &getRecords()
50 {
51 return m_records;
52 }
53
54 void serialize(boost::property_tree::ptree &parentNode) override;
55 void unSerialize(boost::property_tree::ptree &node) override;
56 std::string getDefaultXmlNodeName() const override;
57
58 static std::shared_ptr<NdefMessage> TLVToNdefMessage(ByteVector tlv);
59
60 static ByteVector NdefMessageToTLV(std::shared_ptr<NdefMessage> record);
61
62 private:
63 std::vector<std::shared_ptr<NdefRecord>> m_records;
64};
65}
66
67#endif
Definition: ndefmessage.hpp:25
void addRecord(std::shared_ptr< NdefRecord > record)
Definition: ndefmessage.hpp:35
virtual ~NdefMessage()
Definition: ndefmessage.hpp:29
std::vector< std::shared_ptr< NdefRecord > > & getRecords()
Definition: ndefmessage.hpp:49
size_t getRecordCount() const
Definition: ndefmessage.hpp:45
std::vector< std::shared_ptr< NdefRecord > > m_records
Definition: ndefmessage.hpp:63
Definition: nfcdata.hpp:16
std::vector< uint8_t > ByteVector
Definition: lla_fwd.hpp:80
Definition: asn1.hpp:9
NdefType
Definition: ndefmessage.hpp:19
@ Uri
Definition: ndefmessage.hpp:21
@ Text
Definition: ndefmessage.hpp:20
UriType
Definition: urirecord.hpp:18
UTF
Definition: textrecord.hpp:15
Text Record.
URI Record.