ESPHome 2025.5.0
Loading...
Searching...
No Matches
ndef_record_text.h
Go to the documentation of this file.
1#pragma once
2
3#include "esphome/core/log.h"
5#include "ndef_record.h"
6
7#include <vector>
8
9namespace esphome {
10namespace nfc {
11
12class NdefRecordText : public NdefRecord {
13 public:
15 NdefRecordText(const std::vector<uint8_t> &payload);
16 NdefRecordText(const std::string &language_code, const std::string &text) {
17 this->tnf_ = TNF_WELL_KNOWN;
18 this->type_ = "T";
19 this->language_code_ = language_code;
20 this->text_ = text;
21 };
22 NdefRecordText(const std::string &language_code, const std::string &text, const std::string &id) {
23 this->tnf_ = TNF_WELL_KNOWN;
24 this->type_ = "T";
25 this->language_code_ = language_code;
26 this->text_ = text;
27 this->id_ = id;
28 };
29 NdefRecordText(const NdefRecordText &) = default;
30
31 std::unique_ptr<NdefRecord> clone() const override { return make_unique<NdefRecordText>(*this); };
32
33 std::vector<uint8_t> get_encoded_payload() override;
34
35 const std::string &get_payload() const override { return this->text_; };
36
37 protected:
38 std::string text_;
39 std::string language_code_;
40};
41
42} // namespace nfc
43} // namespace esphome
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
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
std::unique_ptr< T > make_unique(Args &&...args)
Definition helpers.h:85
T id(T value)
Helper function to make id(var) known from lambdas work in custom components.
Definition helpers.h:798