ESPHome 2026.5.0b1
Loading...
Searching...
No Matches
ndef_message.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <vector>
5
7#include "esphome/core/log.h"
8#include "ndef_record.h"
9#include "ndef_record_text.h"
10#include "ndef_record_uri.h"
11
12namespace esphome::nfc {
13
14static constexpr uint8_t MAX_NDEF_RECORDS = 4;
15
17 public:
18 NdefMessage() = default;
19 NdefMessage(std::vector<uint8_t> &data);
21 records_.reserve(msg.records_.size());
22 for (const auto &r : msg.records_) {
23 records_.emplace_back(r->clone());
24 }
25 }
26
27 const std::vector<std::shared_ptr<NdefRecord>> &get_records() { return this->records_; };
28
29 bool add_record(std::unique_ptr<NdefRecord> record);
30 bool add_text_record(const std::string &text);
31 bool add_text_record(const std::string &text, const std::string &encoding);
32 bool add_uri_record(const std::string &uri);
33
34 std::vector<uint8_t> encode();
35
36 protected:
37 std::vector<std::shared_ptr<NdefRecord>> records_;
38};
39
40} // namespace esphome::nfc
const std::vector< std::shared_ptr< NdefRecord > > & get_records()
NdefMessage(const NdefMessage &msg)
bool add_uri_record(const std::string &uri)
std::vector< std::shared_ptr< NdefRecord > > records_
bool add_text_record(const std::string &text)
bool add_record(std::unique_ptr< NdefRecord > record)
std::vector< uint8_t > encode()