ESPHome
2025.2.2
Main Page
Modules
+
Namespaces
Namespace List
+
Namespace Members
+
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Functions
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
y
+
Variables
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Typedefs
a
b
d
e
f
i
j
l
m
n
p
q
r
s
t
u
v
+
Enumerations
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
z
+
Enumerator
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Data Structures
Data Structures
Data Structure Index
Class Hierarchy
+
Data Fields
+
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
+
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
+
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Typedefs
a
c
d
o
p
s
t
v
w
+
Enumerations
b
c
e
f
i
m
n
p
r
s
t
v
+
Enumerator
a
b
c
d
e
f
g
i
l
m
n
o
p
r
s
t
u
v
w
Related Functions
+
Files
File List
+
Globals
+
All
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
y
+
Functions
_
a
l
m
o
s
t
u
+
Variables
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
y
Typedefs
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Modules
Pages
esphome
esphome
components
nfc
ndef_record_text.cpp
Go to the documentation of this file.
1
#include "
ndef_record_text.h
"
2
#include "
ndef_record.h
"
3
4
namespace
esphome
{
5
namespace
nfc {
6
7
static
const
char
*
const
TAG =
"nfc.ndef_record_text"
;
8
9
NdefRecordText::NdefRecordText
(
const
std::vector<uint8_t> &payload) {
10
if
(payload.empty()) {
11
ESP_LOGE(TAG,
"Record payload too short"
);
12
return
;
13
}
14
15
uint8_t language_code_length = payload[0] & 0b00111111;
// Todo, make use of encoding bit?
16
17
this->
language_code_
= std::string(payload.begin() + 1, payload.begin() + 1 + language_code_length);
18
19
this->
text_
= std::string(payload.begin() + 1 + language_code_length, payload.end());
20
21
this->
tnf_
= TNF_WELL_KNOWN;
22
23
this->
type_
=
"T"
;
24
}
25
26
std::vector<uint8_t>
NdefRecordText::get_encoded_payload
() {
27
std::vector<uint8_t> data;
28
29
uint8_t flag_byte = this->
language_code_
.length() & 0b00111111;
// UTF8 assumed
30
31
data.push_back(flag_byte);
32
33
data.insert(data.end(), this->
language_code_
.begin(), this->
language_code_
.end());
34
35
data.insert(data.end(), this->
text_
.begin(), this->
text_
.end());
36
return
data;
37
}
38
39
}
// namespace nfc
40
}
// namespace esphome
esphome::nfc::NdefRecordText::text_
std::string text_
Definition:
ndef_record_text.h:35
ndef_record_text.h
esphome::nfc::NdefRecord::type_
std::string type_
Definition:
ndef_record.h:51
ndef_record.h
esphome::nfc::NdefRecordText::get_encoded_payload
std::vector< uint8_t > get_encoded_payload() override
Definition:
ndef_record_text.cpp:26
esphome::nfc::NdefRecordText::language_code_
std::string language_code_
Definition:
ndef_record_text.h:39
esphome::nfc::NdefRecordText::NdefRecordText
NdefRecordText()
Definition:
ndef_record_text.h:14
esphome
Implementation of SPI Controller mode.
Definition:
a01nyub.cpp:7
esphome::nfc::NdefRecord::tnf_
uint8_t tnf_
Definition:
ndef_record.h:47
Generated by
1.8.13