Reading a Mifare tag using Windows Phone 8 NFC?

A-student picture A-student · Nov 3, 2012 · Viewed 20k times · Source

Does Windows Phone 8 NFC support Mifare Ultralight/Classic based tags? I use this code to access NFC device on Nokia Lumia 920 (code example was taken from NDEF Tag Reader – NFC NDEF Tag Reader)

public partial class MainPage : PhoneApplicationPage
{
    public MainPage()
    {
        InitializeComponent();
        ProximityDevice device = ProximityDevice.GetDefault();
        device.DeviceArrived += DeviceArrived;
        device.DeviceDeparted += DeviceDeparted;
        device.SubscribeForMessage("NDEF", MessageReceived);
    }

    private void DeviceArrived(ProximityDevice sender)
    {
        // this event occurs when I am tapping any of my tags (tried 5 different Mifare Ultralight/Classic)
    }

    private void DeviceDeparted(ProximityDevice sender)
    {
        // this event occurs when I am moving away any tag
    }

    private void MessageReceived(ProximityDevice sender, ProximityMessage message)
    {
        // this event is never fired!!! :(
    }
}

Is NFC on WP8 defective or is this code wrong?

Update: From this document NFC Forum Type Tags you can find that Mifare Ultralight is compatible with NDEF. Android devices can read tags of this type easily.

Answer

JustinAngel picture JustinAngel · Nov 5, 2012

Mifrare is supported on WP8 and on the Lumia 920. I'm guessing here, but it's likely your Mifare NFC tag isn't formatted/initialized to NDEF. You can ask your NFC tags to be NDEF formatted when you buy NFC tags.

The Lumia 920 chip (NXP PN544 family) supports the following tag types (at least):

  • Type 1: Topaz family
  • Type 2: Mifare Ultralight family, my-d-move, NTag
  • Type 3: Felica family
  • Type 4: Desfire family
  • Non standardized: Mifare Standard

Regarding NFC tags NDEF formating:

  • WP8 only supports NDEF level access to these tags, which means that the tag needs to be NDEF formatted or have an exsiting NDEF message to it (can be an empty one). If you try to use the APIs on a non-formatted NFC tags they won’t work (as WP8 lacks support for low level Tag Type specific commands/access)
  • If you want to NDEF format your tags you have the following options: when ordering tags request them to be NDEF formatted (or/and contain an empty NDEF message and the tag to be unlocked), use an NFC USB Reader/Writer HW for PC or use an Symbian/MeeGo/Android NFC device with an NFC writing app

Sincerely,
-- Justin Angel
Principal Engineer for Windows Phone Developer Experience at Nokia