Parser for Connection Handover records
This library provides a parser for Connection Handover records that can be used to decode NDEF records generated by the Connection Handover messages and 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 Connection Handover messages and 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 Connection 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 Connection Handover Records contains the local NDEF message with the Connection Handover Local NDEF Records, use this library to first check their type and next parse them and print their content.
The following code sample demonstrates how to use this module:
static void ndef_ch_rec_analyze(const struct nfc_ndef_record_desc *ndef_rec_desc)
{
int err;
uint8_t hs_buf[NFC_NDEF_REC_PARSER_BUFF_SIZE];
uint32_t hs_buf_len = sizeof(hs_buf);
uint8_t ac_buf[NFC_NDEF_REC_PARSER_BUFF_SIZE];
uint32_t ac_buf_len = sizeof(ac_buf);
struct nfc_ndef_ch_rec *ch_rec;
struct nfc_ndef_ch_ac_rec *ac_rec;
err = nfc_ndef_ch_rec_parse(ndef_rec_desc, hs_buf, &hs_buf_len);
if (err) {
printk("Error during parsing Handover Select record: %d\n",
err);
return;
}
ch_rec = (struct nfc_ndef_ch_rec *)hs_buf;
printk("Handover Select Record payload");
nfc_ndef_ch_rec_printout(ch_rec);
for (size_t i = 0; i < ch_rec->local_records->record_count; i++) {
if (nfc_ndef_ch_ac_rec_check(ch_rec->local_records->record[i])) {
err = nfc_ndef_ch_ac_rec_parse(ch_rec->local_records->record[i],
ac_buf, &ac_buf_len);
if (err) {
printk("Error during parsing AC record: %d\n",
err);
return;
}
ac_rec = (struct nfc_ndef_ch_ac_rec *)ac_buf;
nfc_ndef_ac_rec_printout(ac_rec);
}
}
}
This library is used in the NFC: Tag reader sample.
API documentation
include/nfc/ndef/ch_rec_parser.h
subsys/nfc/ndef/ch_rec_parser.c