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.
The Read error message may appear if NFC is enabled and your Xperia device is in contact with another device or object that responds to NFC, such as a credit card, NFC tag or metro card. To prevent this message from appearing, turn off the NFC function when you don't need to use it.
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):
Regarding NFC tags NDEF formating:
Sincerely,
-- Justin Angel
Principal Engineer for Windows Phone Developer Experience at Nokia
The code you posted is supposed to read NDEF messages from a NFC tag.
Whereas Mifare is also used with NFC tags, that's where the similarity ends: it's a completely different protocol with its own (proprietary) data format.
So, this code isn't really wrong (nor is NFC on WP8 generally 'defective'), but if you expect it to read Mifare tags, this approach won't work for you.
I don't know if it's possible to read Mifare tags with WP8: this depends on the hardware (as Mifare uses some non-ISO frames) as well as the API support. A quick Google search suggests that the Java SDK for older Nokia phones does support Mifare, so the hardware support may be there. Didn't find anything for WP8, though, so this will most likely require some extensive coding, if it works at all.
To give you some idea of what's needed: after you get your DeviceArrived event (which means that the reader detected an ISO NFC tag), you need to obtain the UID of the card. This should be pretty easy, as that's standard ISO functionality.
Next, you need the ability to directly send Mifare authentication and read/write sector commands to the tag. Since these commands aren't ISO-standard, this is where things get more tricky and reader-dependent. Getting past this stage really required protocol documentation and a working Mifare test tool for your phone. Finally, most Mifare cards are completely unreadable unless you at least know one sector key, and the application data format is proprietary (specific to the card issuer) as well, so even after all that work, it's not guaranteed you can get useful information off the card...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With