About NFC

An NFC-enabled device can be a mobile device or a tag. An NFC device operates in one of two modes of communication:

NFC device

An NFC-enabled mobile device typically runs in active mode and supports the following three roles defined by the NFC Forum:

NFC tag

A tag typically operates in passive mode and stores data to be read by another NFC enabled device. When a tag comes into proximity with an NFC device that acts as a reader, the content of the tag is transferred across the contactless interface to the reader, where it is usually dispatched to an appropriate application for processing.

NDEF

The NFC Data Exchange Format (NDEF) is a data format defined by the NFC Forum for data exchange between NFC-enabled devices.

An NDEF message contains one or more NDEF records, each of which is composed of a header and a payload. The header contains the type of data in the record and the size of the record; the payload holds the application data.

Different record types are defined for NDEF, including the NFC Forum well-known type, the mime media type, the absolute URI type, and the NFC Forum external type. The NFC Forum well-known type defines three commonly used types: Text, URI, and Smart Poster. The NFC Forum external type allows custom definition of a message type. This type is represented by NDEF_TNF_EXTERNAL in the libnfc library. You can use NDEF_TNF_EXTERNAL to define a message type that works only with your application. This helps to avoid a pop-up dialog for the user to choose from multiple candidate applications each time a message is detected.

Details of each NDEF record type are defined in separate specifications, available on the NFC Forum.

Peer-to-peer communication

In peer-to-peer communication, a BlackBerry 10 device can exchange data with another NFC-enabled device using the Simple NDEF Exchange Protocol (SNEP), a client-server-based protocol defined by the NFC Forum.

SNEP is a protocol designed to allow the easy exchange of data in an NDEF format. Like many other protocols, SNEP works in a request-response style. A SNEP client initiates communication by sending a request to a SNEP server. The SNEP server processes the request and returns a response.

When a SNEP client comes into proximity with another NFC-enabled device, it automatically negotiates and establishes a Logical Link Control Protocol (LLCP) connection with the other device. It then uses the LLCP connection to transfer an NDEF message across the contactless interface to the other device. There’s a size limit of approximately 8 KB that applies to NDEF content transferred using SNEP from a BlackBerry 10 device.

LLCP

While SNEP provides an easy mechanism for sending a message in NDEF format from one device to another, LLCP allows lower-level control over the process and can be used for both one-way and bidirectional exchanges of data. The libnfc library provides APIs for establishing and using LLCP connections.

Two types of transport are defined for LLCP: connection-oriented transport and connectionless transport. BlackBerry 10 devices support only connection-oriented LLCP.