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:

  1. Obtain the NDEF message descriptor by parsing raw NDEF message data with the Parser for messages and records.

  2. Search for LE OOB NDEF records inside the NDEF message descriptor.

  3. 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

Header file: include/nfc/ndef/le_oob_rec_parser.h
Source file: 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:
  • rec_desc[in] General NDEF Record descriptor.

Return values:
  • true – If the NDEF Record Type is LE OOB

  • false – 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:
  • rec_desc[in] General NDEF Record descriptor.

  • result_buf[out] 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.

  • result_buf_len[inout] As input: size of the result_buf buffer As output: size of the reserved (used) part of the result_buf buffer.

Return values:

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:
  • le_oob_rec_desc[in] Descriptor of the LE OOB Record that should be printed.