The Basics of NFC
NFC is derived from a subset of the RFID standard. It is used for wireless, request-response based communication between two devices, where one acts as the poller and the other as the listener. Unlike Bluetooth Low Energy or WiFi, NFC only works with low data rates over short distances of a few centimeters. It is standardized by the NFC Forum.
To outline the stack from top to bottom: NFC uses its own message format at the application layer called NFC Data Exchange Format (NDEF) that is used for the fundamental operating modes:
- NFC tag reading/writing
- NFC tag emulation
- NFC peer-to-peer communication
The first two modes are used in combination: the poller acts as a reader/writer and the listener as a tag. Even for NFC P2P communication one device acts as the poller and the other as a listener. However, higher protocols make sure that equal data exchange between both sides is possible.
The bottom layer of the NFC protocol stack is defined by NFC technologies. The NFC Forum defines four of them:
- NFC-A - most common, used almost everywhere
- NFC-B - less common and rarely used for everyday applications these days
- NFC-F - used in Japan
- NFC-V - used for inventory management because it allows for higher ranges
I won’t go into the details what sets the NFC technologies apart, but they are mostly incompatible and come from different historical RFID standards.
My work
My thesis was about developing an NFC library for the open source operating systems for the IoT RIOT OS. The library comes with NDEF serialization and parsing. Read/write support is implemented for the following tag technologies:
- NFC Forum Type 2 Tags (T2T)
- NFC Forum Type 4 Tags (T4T)
- MIFARE Classic Tags
Tag emulation is also supported for T2Ts and T4Ts.
The library comes with 4 newly written drivers for the PN7160 and the ST25R3916B. The existing drivers for the nrf52840dk and the PN532 were modified to comply with my generic NFC driver interface.
The library was tested against the existing NFC libraries libnfc and nfcpy. My library manged to match their performance in memory and speed metrics.
My master’s thesis can be found here.
