Using Wifi-Direct and Proximity API for peer file transfers
- Posted: Jan 03, 2014 at 6:00 AM
- 11,047 Views
- 2 Comments
Loading User Information from Channel 9
Something went wrong getting user information from Channel 9
Loading User Information from MSDN
Something went wrong getting user information from MSDN
Loading Visual Studio Achievements
Something went wrong getting the Visual Studio Achievements
In our first Hardware Friday post of the year, we're going to highlight a project from Stéphanie Hertrich that might help you write code that leverages hardware you might already have...
On Windows 8.1 and WinRT, Wifi-direct enables wireless direct communication scenarios between devices executing the same application. That means you can exchange data between peers in areas without any internet network connectivity. All you need is a device that supports Wifi-Direct technology (Surface RT does, as well as most Windows 8 devices). This is complementary to the Share charm functionnality which helps sharing data between 2 apps on the same machine. Here you will share stuff on different machines that are executing the same app.
Wifi-direct can be a good alternative to NFC for some scenarios : you don’t need any NFC hardware but still can communicate between several close peers without network connectivity. If ever you want to test NFC but you don’t have the appropriate hardware, I wrote an article explaining how to install an NFC simulator driver on Windows 8.1 : Windows 8.1 : How to use Near-Field Proximity API without NFC hardware.
Wifi-direct communication is made possible thanks to the Proximity API (just like NFC does, but with different scenarios).
Here is a small lib providing the Wifi-direct file transfer fonctionnality and its sample demo application so that you can test it.
In this article, you will find:
- how to use the lib and the sample app
- behind the scene : how the Proximity API handles Wifi-direct
- more possibilities for Wifi-direct scenarios
- Start browsing for other peers (Start)
- Send a file to a peer (ConnectAndSendFileAsync)
- Register to the ConnectionRequested event
- Start listening to other peers (Start)
- Receive and save a file once a peer connected to you (ReceiveFileAsync)
More possibilities with the Proximity API
Other scenarios are available, like listening to any proximity event occuring (with PeerFinder.CreateWatcher) or providing an early access to peer’s data during the accept phase. It can be useful to help decide how to handle the peer that is trying to connect or if it should accept the connection or not.
She makes it look pretty easy, doesn't she? Hopefully you're now thinking about how cool you can make the sharing in your app's...