ESPHome  2024.12.2
ndef_record_text.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "esphome/core/log.h"
4 #include "esphome/core/helpers.h"
5 #include "ndef_record.h"
6 
7 #include <vector>
8 
9 namespace esphome {
10 namespace nfc {
11 
12 class 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
std::unique_ptr< NdefRecord > clone() const override
T id(T value)
Helper function to make id(var) known from lambdas work in custom components.
Definition: helpers.h:728
std::vector< uint8_t > get_encoded_payload() override
NdefRecordText(const std::string &language_code, const std::string &text, const std::string &id)
const std::string & get_payload() const override
NdefRecordText(const std::string &language_code, const std::string &text)
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7