NFC tags turned inside out – parse tag contents with the open source Nfc Info app

ajakl | 06 October, 2011 17:35

As a developer or interested end-user, you often want to take a closer look at the contents of NFC tags. The new Nfc Info app is here to provide the corresponding knowledge, given that you have an NFC capable Symbian (Nokia C7 [Astound], 600, 700, 701) or MeeGo phone (Nokia N9). Simply touch a tag and the app will show you plenty of data about the Nfc tag contents. You will see:

  • Generic NFC tag information (e.g., NFC Forum Tag Type 1, its UID and version)
  • The records contained in the NDEF message plus its size (e.g., a custom record + a URL record)
  • For most standardized records also a nice textual overview of the parsed contents (e.g., URI, title, action for a Smart Poster)
     

Internally, this is done using convenience classes that hide the complexity and bit/byte-encodings of the records. Luckily, Qt Mobility already provides those for the most common record type definitions (RTD): text and URI. In the Nfc Info source code, you will now find additional ready-made classes that parse Smart Poster, Mime/Image and vCard (for storing business cards) RTDs.

Best of all, you can easily plug those classes into your own project. It's so simple that I've embedded them into the Nfc Corkboard example within a few minutes, so that also that app now handles Smart Posters and business cards.

Usage of the new classes is simple: first, convert the generic record class into the corresponding derived, specialized class. From now on, you have access to methods that return the individual components of the record, or you can assign components for writing.

A short example, which parses a Smart Poster and adds textual information to a string called tagContents:

QString tagContents;     
if
(record.isRecordType<NdefNfcSpRecord>())

    {
        // Convert to a Smart Poster record type class (urn:nfc:wkt:Sp)
        NdefNfcSpRecord spRecord = NdefNfcSpRecord(record);
        // Uri
        tagContents.append("Uri: " + spRecord.uri().toString() + "\n");
        // Title
        tagContents.append("Title count: " + QString::number(spRecord.titleCount()) + "\n");
        if (spRecord.titleCount() > 0) {
            foreach (QNdefNfcTextRecord curTitle, spRecord.titles()) {
                tagContents.append(curTitle.text());
            }
        }
        // Image
        if (spRecord.imageInUse()) {
            QByteArray imgFormat = spRecord.image().format();
            if (!imgFormat.isEmpty()) {
                tagContents.append("Image format: " + imgFormat + "\n");
            }
        }    
    }


The features of the new classes — including read and write support for all listed properties:

  • Smart Poster (urn:nfc:wkt:Sp): Uri, title(s) & their languages, action, size, type and image. (Note however that most phones currently on the market do not process the last three details listed here in their default phone tag handling UI)
  • Image (MIME, image/[png,gif,jpg,…]): en/decode all image formats supported by Qt (includes png, gif, jpg) or use raw image data. Automatically sets the correct mime type.
  • vCard (MIME, text/x-vCard): parse the versit document and get a list of all contained contacts, already provided in a convenient QContact instance. You can query all details through that class, or go ahead and add it to the phone's address book.
     

To get started, just download the binary of the example (.sis for Symbian, .deb for MeeGo Harmattan). If you're using the C7 [Astound], make sure that you update the device firmware to Symbian Anna in order to enable NFC support. You will also need to install Qt Quick Components, Qt 4.7.4 and the Qt Mobility 1.2 package and from the Qt SDK. See the Nfc Info release notes for more details, or read the "Start NFC Development with the Qt SDK today" blog post for full details. If you should be lucky enough to have Symbian Belle on an NFC phone, you only need to install Qt Quick Components from the Qt SDK (the Smart Installer isn't used in the Nfc Info app at the moment). On the N9, you're good to go with the standard firmware — everything is in place by default.

Happy tag-reading!

Nfc Info on the Nokia N9


RSSComments

which tag types are supported?

void0 | 24/10/2011, 12:43

Hello,
Which tag types are supported by the reader in Nokia N9 NFC?

I have an ISO15693 tag, and it does not seem to work - at least no NFC pop ups I see anywhere.

Re: NFC tags turned inside out – parse tag contents with the open source Nfc Info app

ajakl | 24/10/2011, 20:53

ajakl

Both the N9 and the Symbian phones support the standardized NFC Forum Type 1 - 4 tags, plus Mifare tags. See the NFC Forum website for more details and specifications.

Also check that you have switched on NFC on the N9 in the settings.

However, your ISO 15639 tag is most likely no NFC tag.

tag types supported

void0 | 26/10/2011, 00:19

Hi,
Thank you for replying.

The tag in question may be of interest to you as well:

http://www.eetimes.com/electronics-products/memory-products/4219687/ST-s-M24LR64-wireless-EEPROM-memory-combined-with-NFC-technology-enables-new-consumer-apps

Since ST made some Android app for smartphones to read this tag, my hope is that I can in principle do this too with N9's reader?

Also, a stupid question: can I just get the raw/word read/write to the tag with the phone's RFID reader?
(Would be much comfortable for me :)))

Tag type specific access (low-level)

ajakl | 01/11/2011, 13:01

ajakl

Unfortunately, the Qt NFC implementation on the N9 doesn't support sending tag-specific raw commands to the tags (Known limitation listed as "tag type specific access" here: http://doc.qt.nokia.com/qtmobility-1.2/connectivity-api.html ). Therefore, you can only use the higher-level APIs to read from / write to tags on the N9.

You can use those low-level commands on Symbian devices, however!

You must login to post comments. Login
 
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved