Today's Mobile & Modern Monday project will help you built NFC (Near Field Communication) based Windows Phone 8 app's. Imagine you want to create the next cool NFC app, an app that connects two devices. But you only have one device! How are you going to test your app?
What you need is a NFC emulator/simulator (and wouldn't it be cool if the source for that emulator/simulator's source were available?)
One of the more interesting features of Windows Phone 8 is its Proximity Framework for Near-field communications (NFC). Both Nokia and Microsoft have heavily invested in this area. The Proximity API provides you the controls needed to innovate on NFC technology, but at the moment Windows Phone SDK default emulator does not simulate NFC. That means you have to use real WP8 devices to test and debug NFC-related features. If you’re developing a feature to be used between NFC-enabled devices, you’ll need to have at least two devices in hand. In addition, there are often physical movements required to perform NFC interactions while debugging.
The good news is that there is an open source project called “Proximity Tapper” (http://proximitytapper.codeplex.com/) which offers NFC simulation on top of the emulators WP8 SDK provides. The project is generously Apache 2.0 licensed. Proximity Tapper can simulate a wide variety of NFC scenarios, such as tapping one WP8 device with another, tapping a WP8 device with a tag, and tapping a WP8 device with Windows 8 device. The use cases that Proximity Tapper cannot perform include tag writing, “Tap+Send” system integration (due to lack of Bluetooth capability), and Wallet integration. Also, it currently does not support tapping between a real WP8 device and an emulator. According to discussion on project webpage, mixing real WP8 device with emulator seems to be too much work.
From the Proximity Tapper UI, you first add devices. WP8 Emulators can be automatically discovered. Also other devices such as Windows 8 devices can be added manually using IP, hostname, or MAC addresses
Proximity Tapper can be a pretty handy tool for NFC development on Windows Phone 8. It allows you to focus more on the content of messages to be published/subscribed. Using the emulator to test NFC is not only cost-efficient but also saves you the hassle of moving between real devices and keyboard while developing NFC features. It’s also perfect for demonstrating your app during presentations.
Proximity Tapper is a developer tool for working with NFC on both Windows Phone and Windows, and allows you to build NFC apps in the Windows Phone emulator.
The Windows Phone 8 emulator does not currently have any built-in official support for emulator NFC (Near Field Communication), but the Proximity Tapper tool plugs into the Windows Phone 8 emulator to simulate NFC and make it possible to test and develop NFC/Proximity-enabled Windows Phone 8 apps without phone hardware. The tapper tool supports "tapping" a pair of Windows Phone 8 emulators together as if they had physically been tapped, injecting NDEF messages into the connection (and allowing for "tapping" just a single emulator), as well as displaying all message traffic for diagnostic purposes.
Note that the Proximity Tapper tool is not officially supported, and it does not always accurately simulate the behavior of true NFC hardware.
Quick StartVERY IMPORTANT: When first launching the tapper tool you will get a Windows Firewall prompt, you MUST select ALL 3 checkboxes and allow the tool through the firewall otherwise it will silently not work
- After launching the quick start installer, make sure you follow the above instruction to select all 3 checkboxes on the firewall prompt. Also, the tapper tool must be installed and used on the same physical host machine as the Windows Phone emulators.
- The tapper tool has 3 sections:
- The top left lists the devices available. Any running Windows Phone emulators (must be running on the same physical host machine) should automatically show up in the list, for Windows machines running the simulator driver you may type the IP address or hostname in the textbox and click "add" to manually add them to the list.
- The bottom left lists the active connections (taps). When you tap a pair of devices together (or a single device) the connection representing that tap is listed, but when you untap (equivalent of pulling the devices apart and breaking the NFC connection) the connection will disappear.
- The right half of the screen is the message log and will show the transcript of all messages sent or received over the currently selected connection (select it in the list on the bottom left).
- Tap a Pair of Phone Emulators Together
- Tap a Phone Emulator to a Simulated NFC "tag"
- Tap With a Windows 8 Device
Getting Started Writing Proximity/NFC Apps
- The APIs for Proximity/NFC are mostly identical between Windows 8 and Windows Phone 8. They're Windows RT-based which means you can use them from either C# or native C++ (and WWA on Windows 8)
- Getting started guide to Proximity/NFC APIs: http://msdn.microsoft.com/en-us/library/windows/apps/xaml/Hh465221(v=win.10).aspx
- Proximity code sample: http://code.msdn.microsoft.com/windowsapps/Proximity-Sample-88129731
- Windows 8 NFC Driver Spec (contains useful information about message types and formats): http://msdn.microsoft.com/en-us/library/windows/hardware/hh770524.aspx
Here's a snap of the Solution, based on the latest source check-in (Dec 11, 2012);
You'll not he Warning icons... As you download it, it won't compile, complaining about not being able to find the certificate in the Cert Store. Don't sweat it. To the Project Properties, Signing tab and uncheck the Sign the ClickOnce manifests (or click on the Create Test Certificate)
Now the program should compile and run (at least it did on my machine).
So if you're interested in building and testing WP8/W8 NFC app's or just checking out some interesting code... Proximity Tapper.
Comments have been closed since this content was published more than 30 days ago, but if you'd like to send us feedback you can Contact Us.