ESPHome 2026.5.0b1
Loading...
Searching...
No Matches
ndef_record_text.h
Go to the documentation of this file.
1#pragma once
2
4#include "esphome/core/log.h"
5#include "ndef_record.h"
6
7#include <vector>
8
9namespace esphome::nfc {
10
11class NdefRecordText : public NdefRecord {
12 public:
14 NdefRecordText(const std::vector<uint8_t> &payload);
15 NdefRecordText(const std::string &language_code, const std::string &text) {
16 this->tnf_ = TNF_WELL_KNOWN;
17 this->type_ = "T";
18 this->language_code_ = language_code;
19 this->text_ = text;
20 };
21 NdefRecordText(const std::string &language_code, const std::string &text, const std::string &id) {
22 this->tnf_ = TNF_WELL_KNOWN;
23 this->type_ = "T";
24 this->language_code_ = language_code;
25 this->text_ = text;
26 this->id_ = id;
27 };
28 NdefRecordText(const NdefRecordText &) = default;
29
30 std::unique_ptr<NdefRecord> clone() const override { return make_unique<NdefRecordText>(*this); };
31
32 std::vector<uint8_t> get_encoded_payload() override;
33
34 const std::string &get_payload() const override { return this->text_; };
35
36 protected:
37 std::string text_;
38 std::string language_code_;
39};
40
41} // namespace esphome::nfc
NdefRecordText(const std::string &language_code, const std::string &text, const std::string &id)
NdefRecordText(const NdefRecordText &)=default
NdefRecordText(const std::string &language_code, const std::string &text)
const std::string & get_payload() const override
std::unique_ptr< NdefRecord > clone() const override
std::vector< uint8_t > get_encoded_payload() override
uint16_t id