Archive for ‘Uncategorized’

March 22, 2012

Fun with NFC Part One – Reading & Writing NFC Tags

Trying to understand and compare the features of modern mobile phone handsets is a nightmare. The rate at which the various fields of technology are advancing is mind-boggling, and it’s not helped by the seemingly endless list of acronyms used to describe them. My new Sony Xperia S phone, for example, lists among its features: HSDPA, DLNA, WiFi, Bluetooth with 2DP and EDR, SMS, MMS, a radio with RDS, A-GPS and GLONASS, and NFC.

I’m hoping that, by the end of the 24-month contract that I’ve just had to sign to acquire aforementioned handset, I might just have worked out what half of those things are and whether they’re actually of any use to me. And, in this post, I thought I’d start by describing my first experiences with NFC.

NFC, huh – what is it good for?

NFC, or “Near-Field Communication” is, very simply, a method of transferring information over very short distances using radio waves. In that respect, it’s not that dissimilar to Bluetooth or Infrared communication, which have been used to transfer information between electronic devices for some time. What is different about NFC is that, while it can be used to transfer information between two powered electronic devices – a phone and a laptop, or a TV and its remote control, say – it can also be used to transfer information between an active “initiator” and a passive “target”. In such cases, the “initiator” is a device like your mobile phone handset, while the passive target is powered solely by the RF field of the initiator – it needs no batteries or other power supply of its own.

Not only do they not require power, but passive NFC targets are tiny, lightweight, and paper thin – and this means that they can be embedded in a wide variety of materials. In fact, there’s a reasonable chance that you already have one or more NFC targets in your house – they are used in Oyster cards used on the London Underground and some credit cards and passports, for example:

imageimageimage

Of course, the idea of embedding digital information in business cards, posters, and other media to be read by electronic devices is hardly new either. You might be familiar with data matrix or QRcodes, which can encode data similar to the way in which a traditional barcode does:

imageimage

Data matrix, barcodes, and QRcodes like those above are just a way of expressing information in a compact form that is easily read by a device. They are static, and read-only. In contrast, the data contained in an NFC target can be both read and overwritten, again and again, by a simple device such as a mobile phone.

So, time for a play…

NFC and the Sony Xperia S

My Sony Xperia S is unmodified and exactly as supplied on the Vodafone network here in the UK. That means it’s running Android Gingerbread 2.3.7 with Sony’s NXT UI on top.

“Out-of-the-box”, it comes with two installed applications related to NFC:

  • Sony’s own “Xperia SmartTags”
  • The generic Android “Tags”

Before investigating the potential of either application, I first enabled NFC via the Wireless & network settings menu, as shown near the bottom of the screenshot below:

image

Once the NFC capability is enabled, it’s time to try out the applications.

SmartTags

The Sony “Xperia SmartTags” application doesn’t seem to appear in the app launcher list, and nor does it have an icon that can be added to a home screen. It does, however, have a widget as shown below:

image

As the instruction states, rather than being a generic NFC application, the SmartTags widget appears only to be designed to respond to an Xperia SmartTag – a Sony-branded NFC tag. The problem is that, not only did my Xperia S not come supplied with any SmartTags, but nor are they currently available to purchase separately. The Sony UK website describes them merely as “coming soon”:

image

Without either possession of, or the ability to acquire, the hardware necessary to actually make this app do anything, it pretty much dooms “Xperia SmartTags” to be added straight to my list of “useless apps to be deleted”…

Tags

The Xperia also comes with the Android “Tags” application, which can be loaded from the App launcher:

image

There’s not much to see in the default Tags application screen – it just lists tags that have been scanned and, as I haven’t scanned any yet, it’s a big black page. Fortunately, in my wallet I do happen to have both an Oyster card and an NFC-enabled Barclaycard, so I held each one up to the back of the phone for a few seconds to see what happened.

My initial excitement when the phone recognised both cards was slightly reduced when I realised that the Tags application merely recognised them as “Unknown tag type” and couldn’t really do anything else.

screenshot_2012-03-20_2002
Default start screen of Tags application
screenshot_2012-03-20_2005 (2)
Result of scanning an Oyster card or Barclaycard

NFC Apps on the Google Play Shop

Feeling slightly underwhelmed by my achievements with the pre-installed applications, I decided to turn to the “Google Play Shop” (the place to get apps for your Android phone, previously known as the “Android Market”), where I found a couple of alternative NFC applications including some claiming not only to be able to read NFC tags, but also to write them. This sounded a lot more promising, and the first application I decided to try was NXP Tagwriter.

Before getting anywhere with the TagWriter application, I needed to acquire some physical tags to be written. Much though the idea of reprogramming my Barclaycard sounded quite fun, I thought it would be safer to start off with a blank NFC tag, so I turned to Google and found a company called RapidNFC, who supply a variety of different shapes and styles of NFC tag. Not having the slightest idea about whether I wanted a “NTAG203” or an “Ultralight C” tag, I sent them an email asking for advice and got a very prompt and helpful response. The very next day, the postman delivered a package from them containing a sample of several different sorts of NFC tags. If you’re considering doing anything involving NFC tags, I’d definitely be happy to recommend RapidNFC based on my experience (they didn’t also send me the 50p in the picture below – that’s just so you get a sense of scale for the tags!)

image

So, onto programming my new shiny tags. Fire up NXP Tagwriter and you get a screen with a choice to view, create, browse, or share tags. Choosing to create a new tag prompts you to select the type of content this tag will contain – a contact, URL, SMS, or just plain text.

screenshot_2012-03-20_1055 screenshot_2012-03-20_1056_1

I decided to just create a simple plain text message to begin – just enter your text and hold the NFC tag on to the back of the phone for a second or two to write the data to it:

screenshot_2012-03-20_1056_2 tag_1k_formattedandwritten

And that’s it! Once stored, the text can be read back from the NFC tag using either the TagWriter application, or the Tags application. Either application will then display the text message stored on the tag:

screenshot_2012-03-22_1327
Reading the tag in NFC TagWriter
screenshot_2012-03-20_1059
Reading the tag in Tags

I tried three different kinds of tags from RapidNFC – the Ultralight, NTAG203, and 1k – and could write/read them all first time. The difference between the types of tags, as I understand it, is that they have slightly different maximum storage capacities, and can operate at different distances from the initiator device. They’re also slightly different physical sizes.

So that’s the basics of NFC covered. Over the next few posts, I’ll look at doing something more exciting than just writing/reading a text message. Particularly, I want to see how to make my phone perform certain actions in response to scanning a tag (which, I understand, is what Sony’s SmartTags application is meant to do in the first place), and also how to read more detailed information from existing tags. There are already some applications that claim to provide this functionality on the Google Play shop but, if I’ve got time (hah!), I might have a go at programming my own Android NFC app using the Android NFC developer guide.

Tags: , , ,
March 19, 2012

Google own me and my phone

So I’m writing this post on my new mobile phone – a Sony Xperia S. It’s got a lovely screen, which, at 342 pixels per inch I think is the highest pixel density of any handset currently available in the UK. It’s also got a great 12Mpixel camera, which supports 3d and sweep panoramas etc, so perhaps expect to see some more photos appearing on this blog soon.
It supports NFC, but I was a bit disappointed to find out that, unlike some reviews I’d read, it does not come supplied with any NFC tags. I don’t know if this is just the UK/Europe being given a substandard bundle compared to our US cousins (probably) or whether I was just unlucky… it’s a shame, because I was looking forward to playing around with possible uses for NFC – haven’t decided whether it’s going to just be another QRcode thing, which never really achieved its potential. Looks like I might have to pay a visit to http://rapidnfc.com and have a play.

I was already an Android user previously, so I’m fairly familiar with the Google pwnage you expect from running the Android OS, but the number of times I had to consent to Google collecting data about me when configuring the handset for the first time still surprised me. I mean:

  • Expect to have a Google acount in order to use the calendar features or mail features (sure, you can set up other providers, but it’s made a lot easier to use Google).
  • You want to download apps from the Google Play store (the new name for the “Android Market”)? Expect to link that to your Google account too.
  • Select to activate Wi-Fi, and you have to consent for Google to collect usage information.
  • Use GPS satellites for navigation? You have to consent for that data to be collected too.

Seriously, what the heck are Google doing with all this data? They’re sure as hell not using it to make a very good personal profile of me, because the two most recommended apps for me were a “Live Football Scores” app and something about Facebook. Being both a football and Facebook-hater, I don’t think I’ll be making much use of either of them!

January 14, 2012

Hello, Stranger…

Long time no post!

The last few months have presented a number of changes for me, both personally and professionally speaking. In order to deal with them I had to enter a sort of “hibernation mode”, shutting down all non-essential activities, which includes blogging. (FWIW, I also have not been replying to many emails, and shut down my Twitter account).

Hopefully, things have started to calm down now, and I can get back to a (revised) normality again, which means this blog should start up again.

There’s lots of things to write about in the coming weeks – I’ve fallen in love with Mapnik again (but have fallen out somewhat with Bing Maps). SQL Server 2012 is nearly here, and I’ll be sharing some of the content from my new book. I’ve also got some new stuff about using spatial with SQL Azure, more OGR/GDAL goodness, and some real-life example applications I’ve been working on recently, including a nice spatially-enabled dashboard in SQL Server Reporting Services. As usual, if there’s anything you’d like me to write about, just let me know, and stay tuned for some new content soon!

May 27, 2011

Well now, that’s annoying…

So I’ve been using Windows Live Writer to write these blog entries. I quite liked it. UNTIL I CLICKED “PUBLISH” ON MY LAST BLOG ENTRY AND IT OVERWROTE THE PREVIOUSLY PUBLISHED POST. Dammit!

Seriously, that is really annoying. I’ve lost Part 2 of my series of posts on creating an Animation in Bing Maps AJAX v7. When I uploaded Part 3, for some reason it overwrote Part 2 on the WordPress server, adopting the URL of the previous post. So you can now find the content of part 3 at: http://alastaira.wordpress.com/2011/05/25/the-4th-dimension-creating-dynamic-animated-tile-layers-in-bing-maps-ajax-v7-part-2/

But that page, while now showing the content of part 3, has got the comments from the previous part 2 attached to it. And the content of Part 2 I seem to have lost completely – my own local Livewriter copies appear to have automatically synchronised themselves back to the (incorrect) remote server, and my Firefox offline cache already shows the wrong version for that page. So I’m now trying to recover the content from the Google cache of the page, which is wasting a serious amount of time…

…in the meantime, you’ll just to have to believe me when I tell you that I’d written a fascinating discourse about the merits of the tiledownloadcomplete event handler, and various approaches to cycling between different tilelayers – knowledge which may be lost for evermore if I can’t sort this damn thing out. Grrrr….

Follow

Get every new post delivered to your Inbox.

Join 53 other followers