nRF5 SDK v15.3.0
URI message generation

URI messages contain exactly one URI record, which in turn contains an address that an NFC polling device can open. In the most typical use case, the URI record contains a web address like "http://www.nordicsemi.com" that the polling device opens in a web browser.

URI records consist of a URI field (the actual address) and a URI identifier that specifies the protocol of the URI and is prepended to the URI. See nfc_uri_id_t for the available protocols.

The URI records module provides functions for creating the record, and the URI messages module provides functions for creating and encoding the message.

The following code snippets show how to generate a URI message. First, define the URI string and create a buffer for the message:

static const uint8_t m_url[] =
{'n', 'o', 'r', 'd', 'i', 'c', 's', 'e', 'm', 'i', '.', 'c', 'o', 'm'}; //URL "nordicsemi.com"
uint8_t m_ndef_msg_buf[256];

Then create the URI message with one URI record. As parameters, provide the URI identifier code (NFC_URI_HTTP_WWW in this example), the URI string, the length of the URI string, the message buffer, and the size of the available memory in the buffer:

/* Provide information about available buffer size to encoding function */
uint32_t len = sizeof(m_ndef_msg_buf);
/* Encode URI message into buffer */
m_url,
sizeof(m_url),
m_ndef_msg_buf,
&len);
APP_ERROR_CHECK(err_code);

Documentation feedback | Developer Zone | Subscribe | Updated