Quantcast
Viewing all articles
Browse latest Browse all 29128

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”

Image may be NSFW.
Clik here to view.
image

Just follow the wizard to put the certificate in the Trusted Root Certification Authorities.

Image may be NSFW.
Clik here to view.
image

Select local computer and click next

Image may be NSFW.
Clik here to view.
image

Enter the password : “P@ssw0rd

Image may be NSFW.
Clik here to view.
image

Image may be NSFW.
Clik here to view.
image

Browse to choose the certificate location as the Trusted Root Certification Authorities:

Image may be NSFW.
Clik here to view.
image

Click Next and that’s it

Image may be NSFW.
Clik here to view.
image

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.

Image may be NSFW.
Clik here to view.
image

Image may be NSFW.
Clik here to view.
image

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.

Image may be NSFW.
Clik here to view.
image

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 :

Image may be NSFW.
Clik here to view.
image
 

Image may be NSFW.
Clik here to view.
image

4. Add an exception to the firewall

Update the firewall on the PC’s which will have the driver installed.

Image may be NSFW.
Clik here to view.
image

Click Advanced Parameters and add a new rule for the incoming traffic:

Image may be NSFW.
Clik here to view.
image

Select Port:

Image may be NSFW.
Clik here to view.
image

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)

Image may be NSFW.
Clik here to view.
image

Allow the connection (default)

Image may be NSFW.
Clik here to view.
image

Allow the rule for any type of network

Image may be NSFW.
Clik here to view.
image

Enter a name for the rule

Image may be NSFW.
Clik here to view.
image

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.

Image may be NSFW.
Clik here to view.
image
 

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.

Image may be NSFW.
Clik here to view.
image

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.

Image may be NSFW.
Clik here to view.
Untitled

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.

Image may be NSFW.
Clik here to view.
image

You can now start coding with NFC !

Image may be NSFW.
Clik here to view.

Viewing all articles
Browse latest Browse all 29128

Trending Articles