Windows 8.1 : How to use Near-Field Proximity API without NFC hardware
Did you know that you don’t need any NFC-capable device to develop againt the Near-Field Proximity API ? You can install a sample driver (Near-Field Proximity Sample Driver (UMDF Version 1)) that will emulate the hardware layer for you with a TCP connection.
The bad news is you will need to accomplish a number of downloads, compiling, deploying, creating certificate, configuring, …and that will take hours (trust me !).
The good news is that I did that boring stuff just before you, so I will give you the driver binaries, tools, certificate and hints to accomplish that much quicker.
You will still need to:
- Get the zip file and extract it
- Import the driver certificate
- Install the driver (.bat)
- Add a firewall rule
(screenshots are in French, but very recognizable)
1. Download the zip
So instead of downloading the Windows Driver Kit, the driver samples, and the WDK redistribuable components, get each component in the right place, build and target appropriatly the virtual Proximity driver, get the binaries, create a test certificate, blabla…, you can just download the following zip. It contains everything you need to install the driver on a Windows 8.1 x64 machine.
Extract it anywhere on the disk of all the PC’s that will be using the Proximity API.
2. Import the certificate to your computer’s store
The zip contains a test signing certificate NetNfpCertExport that you will have to import to be able to use the driver.
Right-click on it and select “Install PFX”
Just follow the wizard to put the certificate in the Trusted Root Certification Authorities.
Select local computer and click next
Enter the password : “P@ssw0rd”
Browse to choose the certificate location as the Trusted Root Certification Authorities:
Click Next and that’s it
You can check if everything is ok now with the driver security catalog : it will be used during the installation to be trusted. Just open it.
The no red warning on the page, the security catalog is valid : good job !
3. Install the driver
Now start a cmd.exe as administrator, and go to the folder you extracted the zip to.
Launch install.bat.
The driver should install successfully.
If the driver does not install properly, you can check the error log here : c:\Windows\inf\setupapi.dev.log
If you get that kind of error message :
dvi: {Update Device Driver - ROOT\PROXIMITY\0000}
dvi: {Build Driver List} 11:36:16.465
dvi: Searching for hardware ID(s):
dvi: wudf\netnfpprovider
sig: {_VERIFY_FILE_SIGNATURE} 11:36:16.486
sig: Key = netnfpprovider.inf
sig: FilePath = c:\temp\netnfpprovider.inf
sig: Catalog = c:\temp\nfp.cat
! sig: Verifying file against specific (valid) catalog failed! (0x800b0109)
! sig: Error 0x800b0109: A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
It means that you didn’t install the certificate properly, please refer to the previous chapter.
If it fails like this:
>>> [Device Install (UpdateDriverForPlugAndPlayDevices) - WUDF\NetNfpProvider]
>>> Section start 2013/11/19 11:08:51.377
cmd: "C:\temp\devcon.exe" install NetNfpProvider.inf WUDF\NetNfpProvider
dvi: {Update Device Driver - ROOT\PROXIMITY\0000}
dvi: {Build Driver List} 11:08:51.439
dvi: Searching for hardware ID(s):
dvi: wudf\netnfpprovider
dvi: {Build Driver List - exit(0x00000000)} 11:08:51.467
dvi: {DIF_SELECTBESTCOMPATDRV} 11:08:51.473
dvi: No class installer for 'Périphériques de proximité'
dvi: No CoInstallers found
dvi: Default installer: Enter 11:08:51.495
dvi: {Select Best Driver}
! dvi: Selecting driver failed(0xe0000228)
dvi: {Select Best Driver - exit(0xe0000228)}
! dvi: Default installer: failed!
! dvi: Error 0xe0000228: There are no compatible drivers for this device.
dvi: {DIF_SELECTBESTCOMPATDRV - exit(0xe0000228)} 11:08:51.539
It means that the driver (here for Windows 8.1 x64) is not compatible with your machine. In that case, you will have to do the complete process I explained in the introduction. So, you will be able to build and get the binaries adapted to your target OS and hardware.
See what your driver enabled
Now you can see you are NFC-capable in the Devices charms, and in the device manager :
4. Add an exception to the firewall
Update the firewall on the PC’s which will have the driver installed.
Click Advanced Parameters and add a new rule for the incoming traffic:
Select Port:
Select TCP and enter the port used by the driver : 9299 (the driver will use a TCP connection on this port to simulate the NFC communication)
Allow the connection (default)
Allow the rule for any type of network
Enter a name for the rule
You’re done !
Testing with an NFC-enabled sample application
We will use the Proximity sample application available on MSDN.
Using the first scenario, just click on Advertise. See the green information : Tap another device to connect to a peer : that’s what we’ll do with our NFC simulated driver.
The NetNfpControl application allows to control the sample driver.
Just launch NetNfpControl.exe <hostname or IPv6 address for the other peer you want to connect to> (in my case, it’s stephetablet7).
This will simulate a “Tap” action.
Magic : you will experience “Tap and Launch” resulting in a toast notification appearing on the PC you connected to, inviting you to start the same application.
According to MSDN : For connections triggered by a tap, if the peer application is not running in the foreground on the target computer, then proximity invites the user to activate the app on the target machine. If the peer app is not installed on the target computer, then proximity invites the user on the target computer to install the app from the Windows Store. For more details on activating apps with a tap gesture, see "Activating apps using Proximity" in Supporting proximity and tapping.
It’s not the subject of this article, but of course other use cases are available (see below). I will certainly go deeper into some of them in a future article.
You can now start coding with NFC !
Comments
Anonymous
April 06, 2014
hi I have encountered a problem in the installation H:>cd nfp H:NFP>install H:NFP>devcon.exe install NetNfpProvider.inf WUDFNetNfpProvider Cette version de H:NFPdevcon.exe n'est pas compatible avec la version de Windo ws actuellement exécutée. Vérifiez dans les informations système de votre ordina teur, puis contactez l'éditeur de logiciel. H:NFP>Anonymous
April 07, 2014
Hello yacine, can you check the Windows version you are executing ? The binaries provided here are for Win 8.1 x64. You can get the binaries for other versions, but you have to do all the get source file and compile work in first place, with the appropriate target platform selected in Visual Studio before building (check my 1st chapter).Anonymous
June 24, 2014
You just saved mine 500 GB Bandwidth for downloading WDK and time for compiling :) it's working perfectly on windows 8.1 64 bit ThanksAnonymous
September 03, 2014
After successful installation, I am getting the following error when trying the following command: NetNfpControl.exe S1-10589322 It shows: Attempting Connect: 'S1-10589322' . . . BeginProximity() failed: 0x80072af9 I have completed the total installation process for both PC's. Both PC has Windows8.1 Professional OS of 64 bit.Anonymous
September 15, 2014
Hi Stéphanie. Great Job ! I just wonder if this is possible to run the demo sample application on the same computer, or do I absolutely need 2 separated computers connected to the same network. Could you please advise me on this because I've not read yet your source code. I am skilled in NFC controllers and RFID, but I am really starting with UMDF Proximity API's (Dummy).Anonymous
September 15, 2014
Hello François, You need 2 separate computers as NFP allows data sharing between 2 instances of the same app. You can't launch 2 instances of the same app on 1 device.Anonymous
September 17, 2014
Hi Stéphanie, I come back again towards you for further explanations. I've created a VM with Hyper-V with Windows 8.1 Professional 64 bits, and I've installed on the driver you gave to us. Everything worked fine, I've also created the firewall rules, and I've installed also the proximity sample application. Then, on my main operating system (Windows 8.1 64 bits) and my VM (Windows 8.1 64 bits), the driver is install and configured, and the network between both works too (ping MainPC works, and ping VMPC works too). I've launched on both side the Proximity sample application and on the MainPC I've launched NetNfpControl.exe VMPC and on the other side (VM) I've launched NetNfpControl.exe MainPC, but nothing happens ! Could you please advise me on how to fix this, please ? Regards, François.Anonymous
March 15, 2015
Thanks, everything worked great... except at the end I dont get a Tap notification! I can tell the Proximity is working because if I go to "Display ProximityDevice events" in the Proximity C# app, and I run NetNfpControl.exe, it prints "Proximity device arrived" and then when I close it, it says "Proximity device departed". But I don't get the Tap Notification :/ Any ideas?Anonymous
July 21, 2015
If I scan an RFID tag, is there a way to get the tag id using the proximity api? Thanks.