An NFC-enabled device can be a mobile device or a tag. An NFC device operates in one of two modes of communication:
- Active mode: In active mode, an NFC-enabled device generates a radio frequency (RF) field and acts as the initiator. The initiator detects other NFC devices that are in passive mode, which are often referred to as targets.
- Passive mode: In passive mode, the NFC-enabled device doesn't generate an RF field, though it may use the RF field generated by another device whose field it encounters to draw energy from. An NFC tag, for example, works in passive mode, waiting to be detected by an active NFC device such as a BlackBerry 10 device.
An NFC-enabled mobile device typically runs in active mode and supports the following three roles defined by the NFC Forum:
- Reader/writer mode: The NFC-enabled device acts as the reader or writer to the NFC tag, and operates in active mode while the NFC tag is in passive mode. In this mode, the NFC device can detect an NFC tag and either read from or write to the tag.
- Peer-to-peer mode: Two NFC-enabled devices interact with each other, both operating in active mode. In this mode, one device can initiate communication with, or respond to a request from another NFC-enabled device.
- NFC card emulation mode: The NFC-enabled device emulates a card, acting in passive mode, while the external card reader acts in active mode. In this mode, the NFC device can act as an NFC tag or a smart card. As an NFC tag, it responds to a tag reader, while as a smart card, it performs card transactions such as those required for a payment operation.
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.
- ISO 14443-based NFC tag: The NFC Forum defines four types of tags, known as Type 1, Type 2, Type 3, and Type 4. The differences between the types include their maximum storage capacity and supported protocols. Types 1-3 allow communication only at layer 3 of the ISO 14443 NFC protocol stack. A Type 4 tag supports layer 4, so you can use ISO 7816-4 Application Protocol Data Units (APDUs) to communicate with a Type 4 tag. A tag can be programmed to be read-only or rewritable.
- ISO 15693 tag: A tag based on the ISO 15693 standard. The ISO 15693 tag can be read from a greater distance than an ISO 14443-based NFC tag, providing more flexibility to the user. These tags operate at a lower speed than ISO 14443-based NFC tags and typically carry non-NDEF data in a series of bytes.
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.
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.
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.
Last modified: 2015-07-24