ESPHome 2026.5.1
Loading...
Searching...
No Matches
ndef_record_uri.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
11static constexpr uint8_t PAYLOAD_IDENTIFIERS_COUNT = 0x23;
12static const char *const PAYLOAD_IDENTIFIERS[] = {"",
13 "http://www.",
14 "https://www.",
15 "http://",
16 "https://",
17 "tel:",
18 "mailto:",
19 "ftp://anonymous:anonymous@",
20 "ftp://ftp.",
21 "ftps://",
22 "sftp://",
23 "smb://",
24 "nfs://",
25 "ftp://",
26 "dav://",
27 "news:",
28 "telnet://",
29 "imap:",
30 "rtsp://",
31 "urn:",
32 "pop:",
33 "sip:",
34 "sips:",
35 "tftp:",
36 "btspp://",
37 "btl2cap://",
38 "btgoep://",
39 "tcpobex://",
40 "irdaobex://",
41 "file://",
42 "urn:epc:id:",
43 "urn:epc:tag:",
44 "urn:epc:pat:",
45 "urn:epc:raw:",
46 "urn:epc:",
47 "urn:nfc:"};
48
49class NdefRecordUri : public NdefRecord {
50 public:
52 NdefRecordUri(const std::vector<uint8_t> &payload);
53 NdefRecordUri(const std::string &uri) {
54 this->tnf_ = TNF_WELL_KNOWN;
55 this->type_ = "U";
56 this->uri_ = uri;
57 };
58 NdefRecordUri(const std::string &uri, const std::string &id) {
59 this->tnf_ = TNF_WELL_KNOWN;
60 this->type_ = "U";
61 this->uri_ = uri;
62 this->id_ = id;
63 };
64 NdefRecordUri(const NdefRecordUri &) = default;
65 std::unique_ptr<NdefRecord> clone() const override { return make_unique<NdefRecordUri>(*this); };
66
67 void set_uri(const std::string &uri) { this->uri_ = uri; };
68
69 std::vector<uint8_t> get_encoded_payload() override;
70 const std::string &get_payload() const override { return this->uri_; };
71
72 protected:
73 std::string uri_;
74};
75
76} // namespace esphome::nfc
NdefRecordUri(const std::string &uri, const std::string &id)
const std::string & get_payload() const override
NdefRecordUri(const std::string &uri)
NdefRecordUri(const NdefRecordUri &)=default
std::vector< uint8_t > get_encoded_payload() override
void set_uri(const std::string &uri)
std::unique_ptr< NdefRecord > clone() const override
uint16_t id