Friday, October 2, 2020

NFC card reader on Surface Go 2 with C#/UWP app and ProximityDevice Class to read MIFARE

I tried to read NFC MIFARE cards from an UWP C# App on a Micrsoft Surface Go 2. But even with the Sample App "ProximitySensor"  by Microsoft (https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/ProximitySensor) I did not get it to work. The sample app kept telling me "No proximity sensor found".


How-I-fixed it?

There are two things necessary to get this solved.

The first one is, to have the right version of the Surface Go 2. The first one I got, was the "Consumer" version (so far I did not know, there is another one out there). This one does NOT have an NFC reader built in at all (or at least no driver to make it working).

What you need is a Surface Go 2 for Business. Only this one has an NFC sensor built in and registered in the devices.


Opening up the Device Manager on this one, it showed me a "Proximity Device" (an NXP something...). 👍

So far, so good. Trying the sample app, I still got "No proximity sensor found".  Here's the trick to get this solved: 

The Windows API has two different classes for accessing NFC (they call it proximity) devices. 

The first one is the ProximitySensor Class, which was used in the Sample app and did NOT work on the Surface Go 2.

The other one is ProximityDevice Class, which is part of the Networking Namespace-. This one is working on the Surface Go 2. Here's some sample code how to use it. Got it to read the content my MIFARE card OK. 👍




3 comments:

  1. Hey, thanks for the write-up! I'm trying to get the ProximityDevice Class sample to work as instructed (using the Windows 8 build), but I get an error where this file can't be found - Scenario2_PeerWatcher.g.hpp. Any tips would be appreciated! Do you have a deployed executable of this project I can run on my Surface Go 2 Business?

    ReplyDelete
  2. RIBS Technologies offers the best contactless business card and is renowned as a leading provider of digital business card solutions.

    RIBS Technologies stands out as the go-to company for customizable NFC business card. Clients have the flexibility to personalize their cards with unique designs, logos, and contact information, ensuring a professional and memorable representation of their brand.

    ReplyDelete
  3. Hi, i got this running in a .Net6 WorkerService, but the MessageReceived event is not fired. THe device is detected and initialized. Any suggestions on that?

    ReplyDelete