ESPHome 2025.5.0
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 {
13namespace nfc {
14
15static const uint8_t MAX_NDEF_RECORDS = 4;
16
18 public:
19 NdefMessage() = default;
20 NdefMessage(std::vector<uint8_t> &data);
22 records_.reserve(msg.records_.size());
23 for (const auto &r : msg.records_) {
24 records_.emplace_back(r->clone());
25 }
26 }
27
28 const std::vector<std::shared_ptr<NdefRecord>> &get_records() { return this->records_; };
29
30 bool add_record(std::unique_ptr<NdefRecord> record);
31 bool add_text_record(const std::string &text);
32 bool add_text_record(const std::string &text, const std::string &encoding);
33 bool add_uri_record(const std::string &uri);
34
35 std::vector<uint8_t> encode();
36
37 protected:
38 std::vector<std::shared_ptr<NdefRecord>> records_;
39};
40
41} // namespace nfc
42} // namespace esphome
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()
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7