Parser for Bluetooth LE OOB records¶
This library provides a parser for Bluetooth LE OOB records that can be used to decode NDEF records generated by the Bluetooth LE OOB records library. The output of this library is a descriptor with the same content as the one that would be used to encode the data with the Bluetooth LE OOB records library.
This library should be used together with the Parser for messages and records in the following way:
Obtain the NDEF message descriptor by parsing raw NDEF message data with the Parser for messages and records.
Search for LE OOB NDEF records inside the NDEF message descriptor.
If there are any such NDEF records, use this library to parse them and print their content.
The following code sample demonstrates how to use this module:
static void ndef_le_oob_rec_analyze(const struct nfc_ndef_record_desc *le_oob_rec_desc)
{
int err;
uint8_t desc_buf[NFC_NDEF_REC_PARSER_BUFF_SIZE];
uint32_t desc_buf_len = sizeof(desc_buf);
err = nfc_ndef_le_oob_rec_parse(le_oob_rec_desc, desc_buf,
&desc_buf_len);
if (err) {
printk("Error during NDEF LE OOB Record parsing, err: %d.\n",
err);
} else {
nfc_ndef_le_oob_rec_printout(
(struct nfc_ndef_le_oob_rec_payload_desc *) desc_buf);
}
}
This library is used in the NFC: Tag reader sample.
API documentation¶
include/nfc/ndef/le_oob_rec_parser.h
subsys/nfc/ndef/le_oob_rec_parser.c
-
group
nfc_ndef_le_oob_rec_parser
Parser for NDEF LE OOB Records.
Functions
-
bool
nfc_ndef_le_oob_rec_check
(const struct nfc_ndef_record_desc *rec_desc)¶ Check if an NDEF Record is the LE OOB Record.
- Parameters
[in] rec_desc
: General NDEF Record descriptor.
- Return Value
true
: If the NDEF Record Type is LE OOBfalse
: If the NDEF Record Type is different.
-
int
nfc_ndef_le_oob_rec_parse
(const struct nfc_ndef_record_desc *rec_desc, uint8_t *result_buf, uint32_t *result_buf_len)¶ Parse an NDEF LE OOB Record.
This function only parses NDEF Record descriptors with LE OOB Record Type. Parsing results are stored in the LE OOB Record descriptor (nfc_ndef_le_oob_rec_payload_desc).
- Parameters
[in] rec_desc
: General NDEF Record descriptor.[out] result_buf
: The buffer that will be used to hold the LE OOB Record descriptor. After parsing is completed successfully, the first address in the buffer is filled by the NDEF Record descriptor (nfc_ndef_le_oob_rec_payload_desc), which provides a full description of the parsed NDEF Record.[inout] result_buf_len
: As input: size of theresult_buf
buffer As output: size of the reserved (used) part of theresult_buf
buffer.
- Return Value
0
: If the operation was successful. Otherwise, a (negative) error code is returned.
-
void
nfc_ndef_le_oob_rec_printout
(const struct nfc_ndef_le_oob_rec_payload_desc *le_oob_rec_desc)¶ Print the parsed contents of an NDEF LE OOB Record.
- Parameters
[in] le_oob_rec_desc
: Descriptor of the LE OOB Record that should be printed.
-
bool