nfc

If you’ve attended one of the Windows 8 developer road shows within Australia over the past 3 months and was paying attention during my hardware and devices sessions you would have heard me passionately rant about the new proximity capabilities found within Windows 8.  Well a few weeks ago during the Windows Phone Summit, Microsoft announced the same (and actually a few bonus) capabilities coming to Windows Phone 8 too.  NFC for me is such a promising technology that I thought I’d blog about what we know so far about both platforms and it’s potential capabilities.

N.B.:  Any statements surrounding Windows Phone 8 are based on information found on websites, I have no access to the Windows Phone product team or have not been involved in any pre-beta testing of the products.

Windows.Networking.Proximity

With the knowledge that Windows 8 and Windows Phone 8 share a common core (NTKernel), and recently disclosures around the fact the common core will also include a common networking stacks. It is relatively easy to hypothesise that Windows Phone 8 will be utilising the Windows.Networking namespace found within Windows 8’s WinRT APIs. The networking stack in Windows 8 is full of all sorts of goodness that we have never seen in the Windows ecosystem until now, including web sockets, push-notifications, low-level connection information and much more.

When we talk about NFC, and the much broader form of proximity based networking we focus on a much smaller segment of the Windows.Networking namespace which is found in Windows.Networking.Proximity. The use of the phrase proximity within this name-spacing is actually key as Microsoft have sneakily wrapped more than just NFC into this – with proximity actually consuming Bluetooth, Wi-fi Direct, and Near Field Communication (NFC).  Each of these technologies are exposed using a common-API available to all languages capable of using WinRT – so currently JS, C#, and C++ and as a quick refresher here is a quick overview of each:

  • Bluetooth 2.0; the radio-based networking mechanism we see commonly in mobile devices and PCs, runs on 2.4-2.5Ghz frequencies with a transfer rate of 2.1 MBit/s. Widely used for connecting peripheral devices, and providing alternatives to WIFI for connectivity to Internet access points.
  • Bluetooth 4LE; the next generation of Bluetooth we are starting to see in recent mobile devices and with more specific uses around smaller profiles devices such as fitness, health, and smart watches. It uses the same radio frequency as Bluetooth 2.0 but the lower power usage means a smaller data transfer rate of less than 1.0MBit/s
  • WIFI Direct; a variation on existing WIFI technologies allowing the connection of devices to one another without the need for a centralised access point (AP). Wi-fi direct utilises the concept of a soft-access point to provided peer-to-peer wireless connections without the need to establish ad-hoc wireless connections. Wifi direct utilises 802.11n with support for speeds up to 130 MBit/s. WIFi direct also has a broader range than Bluetooth so can support slightly longer distances.
  • Near Field Communication (NFC); a lower bandwidth, low power RFID compatible transport mechanism with a transfer rate of only 424 KBit/s and a lower spectrum of 13.56Mhz NFC is designed to be  a close contract (virtually touching) form of data transfer. Based on the relationship to RFID NFC can also communicate with low on non-powered based NFC chips to read and write data to them.

The existence of these technologies in the managed WinRT APIs makes achieving connectivity with the proximity stack a million times easier than life in Windows 7 or before when we relied on independent device manufacturers providing device centrics APIs utilising native code, or Win32 APIs. As a quick comparison here is the code required for utilising a single NFC device within Windows 7:

image

Although you can’t see the details, this is less than a quarter of a single 500 lines C# file responsible for mapping and marshalling calls to an NFC sensor using PInvoke to call into the native assemblies. This is simply the mapping file, and doesn’t take into account any integration into a rich client application or the code provided in the lower-level stacks. In comparison this is the amount of code I require to connect to an NFC device using WinRT in Windows 8 (and hopefully Windows Phone):

Windows.Networking.Proximity.ProximityDevice proximityDevice;

private void InitializeProximityDevice()
{
    proximityDevice = Windows.Networking.Proximity.ProximityDevice.GetDefault();

    if (proximityDevice != null) {
        proximityDevice.DeviceArrived += ProximityDeviceArrived;
        proximityDevice.DeviceDeparted += ProximityDeviceDeparted;

        WriteMessageText("Proximity device initialized.n");
    }
    else
    {
        WriteMessageText("Failed to initialized proximity device.n");
    }
}

private void ProximityDeviceArrived(Windows.Networking.Proximity.ProximityDevice device)
{
    WriteMessageText("Proximate device arrived. id = " + device.DeviceId + "n");
}

private void ProximityDeviceDeparted(Windows.Networking.Proximity.ProximityDevice device)
{
    WriteMessageText("Proximate device departed. id = " + device.DeviceId + "n");
}

// Write a message to MessageBlock on the UI thread.
private Windows.UI.Core.CoreDispatcher messageDispatcher = Window.Current.CoreWindow.Dispatcher;

async private void WriteMessageText(string message, bool overwrite = false)
{
    await messageDispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,
        () =>
        {
            if (overwrite)
                MessageBlock.Text = message;
            else
                MessageBlock.Text += message;
        });
}

N.B – just as a side note  NXP are currently the only NFC/proximity hardware supplier with WinRT/Win8 certified drivers. I’ve tried a few devices including the ACS 122 and other models that have earlier NXP chips and they currently do not work. Currently the only way of experimenting with NFC is with prototype hardware of an SDK directly from NXP.

Why Near Field Communication?

So when you compare the capabilities of the 4 proximity technologies being offered it appears that NFC has the worse technical capabilities of the lot – so why is it so important? One of the main reasons is because NFC capabilities are provided in two different forms:

  • Passive NFC consumption;  this is used in scenarios for reading and writing non-powered NFC chips
  • Active NFC consumption; for communication with a device with a powered NFC capabilities

Each form has its own unique uses– but in addition to simply providing proximity capabilities using its low bandwidth methods – when considering an active NFC connection a better use is an enabler for a Wi-fi direct or Bluetooth connection without the need to manually pair the devices. This scenario lends you to simply tap the devices together and they can connect via a faster more efficient networking stack – perfect for gaming or file transfers. This puts us in interesting scenarios where we can place our phones/tablets on Surfaces and via an app we can start streaming information back and forth via a socket connection. If one of the devices is a touch screen – we could even achieve PixelSense (formerly Surface) style drag-and-drop of information between devices.

When we look at passive NFC we have the ability to read/write 4kb to a tag that required no power at all. The most common use for this type of device is to embed NFC into posters, plastic cards (such as credit cards) or to use for tracking purposes on postage labels. The 4kb of data can consist of anything the developer wishes – however the most common forms are URLs, vCards, and smaller text-based metafile formats used in a similar fashion to QR Codes. Many mobile operating systems, including Windows will then recognise receiving these file formats in a similar fashion to having them beamed via Bluetooth and will simply natively prompt to see if you wish to add the contact, or launch the browser.

And what about payments?

One of the biggest uses of RFID/NFC I have seen has been the roll-out of the Oyster cards in London, and then the wider use of the card as a payment system. Since that time we have gradually seen NFC offer promise as a payment mechanism with the introduction of Google Wallet, Visa Paypass, and the Mastercard equivalent.  If you where paying attention to the news during the Windows Phone summit you’ll of hopefully seen the capability is coming to Windows Phone 8 too – via the new wallet functionality.

The way this is being distributed within the Windows Phone ecosystem (which is slightly different to how Google have built their platform) is by using a secure element embedded on a mobile provider SIM card. This secure element is then used by the network to proxy the banking transactions being created on the phone. By using a secure SIM this means that you are not locked to handsets when setting up the NFC part of the Windows Phone wallet – however it does mean that the infrastructure is not only dependent on the banks, but also the mobile network operators. Currently only Orange in France have signed up as a launch partner.

The combination of both a payment provider, and a rich proximity platform within Windows 8/ Windows Phone 8 does however mean we now have richer and smarter application which allow us to not only think about near-time scenarios, but also mid-term concepts similar to this NFC-vision video shown by Microsoft during the Windows Phone summit:

<Insert Video here>

Conclusion

So really this is just a brain dump, and a start of a series of blogs around Windows 8/Windows Phone 8 and the capabilities we have when we start considering hardware when we build our apps. I’m really excited about the NFC potentials beyond the standard functionality we see in todays marketplace and as soon as we start to see hardware available I’ll be uploading code samples to this blog to demonstrate some of my ideas – but in the mean time if I can help you out with any more details around Windows 8 proximity please get in touch!

Tagged on:         

3 thoughts on “Getting closer to NFC; proximity in Windows 8 & Windows Phone 8

  • Pingback: NFC Gumball machine–merging physical and digital | Lewis Benge

  • December 16, 2012 at 2:14 am
    Permalink

    Thanks for the article. I’m looking at using NFC for contactless access to smartcard from a Windows 8 machine. It is kind of crazy that PC/SC is not supported for Windows Store Apps. Have you been able to use NFC from a Windows store app for real yet?

    Reply
  • January 17, 2013 at 9:55 pm
    Permalink

    Is it possible to make an application that provide communication between one Windows 8 (as a server fo example) device and n (> 1) Windows Phone 8 devices using the Windows 8/WP8 Proximity APIs

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>