WiFi-Buddy: An Android Library to Handle Peer-to-Peer Functionality

517 views
Skip to first unread message

Brendan

unread,
Aug 12, 2016, 8:17:36 AM8/12/16
to wi-fi-...@googlegroups.com

For Android developers who find the Wi-Fi Direct API to be unreliable or difficult to use, WiFi-Buddy is an open-source library that handles Wi-Fi Direct functionality, making it easy to use peer-to-peer communication in apps without having to understand the entire API. Wi-Fi Direct is a technology that allows most smartphones to quickly connect and transfer data at long distances, without connecting to a network. My RIT SE Senior Project team, the Crash Test Buddies, has been working with Android Wi-Fi Direct since the beginning of this year, hoping to connect drivers and pedestrians. We quickly learned that the framework can be confusing, unstable, and difficult to use, and our research confirmed that. Many developers find that the framework is either too unreliable or isn’t robust enough to meet their needs. Since developers don’t use the technology often, Android may not have much incentive to improve the framework. Wi-Fi Direct is an incredible technology that could eliminate the need for networks in countless scenarios, and it’s unfortunate that it isn’t used more often.


We created the open-source WiFi-Buddy library to address this problem. Developers can use this library to handle Wi-Fi Direct in their Android applications much more easily than using just the Wi-Fi Direct API. Unlike many other attempts at abstracting the peer-to-peer functionality, Wi-Fi Buddy is a background service that isn’t bound to only one Activity. It also offers other unique features like continuously discovering services after the timeout would normally stop it, and removing persistent groups. Simply declare WiFi-Buddy as a dependency, register a BroadcastReceiver to listen for Intents that we broadcast, and create a ServiceConnection to run the WiFi-Buddy service in the background. All setup instructions are provided here. Instead of having to understand all of the details of Wi-Fi Direct, developers can just call our public functions to handle P2P events, such as registering a local service or discovering services. WiFi-Buddy handles a lot of the functionality and logs many of the important P2P events to the console, to make it easier for developers to understand what happens behind the scenes, without having to actually implement everything.


wifi-direct-tester is a demo application that utilizes WiFi-Buddy to handle Wi-Fi Direct functionality. This app shows how the library can be used to easily discover, connect, and transfer data between phones without connecting to a network. Android has a similar Service Discovery demo, but may be difficult to follow when first learning Wi-Fi Direct. The wifi-direct-tester app can be used to easily test P2P between phones, since it logs a lot of useful information.


Another app that the Crash Test Buddies created is DataCollectionTests. This app uses WiFi-Buddy to test Wi-Fi direct. From our experience and research, Service Discovery can be very unstable on Android. Sometimes phones discover each other nearly instantly, and other times they take much longer to discover. We have also noticed that some phones never successfully discover each other. This data collection and testing app was used to determine what factors affect Service Discovery. We were able to confidently conclude that the presence of network activity and Service Discovery between different brand phones likely have negative effects on Service Discovery. The testing results are discussed in more detail here.


The goal of this project is to promote the use of Wi-Fi Direct on Android and make it easier for developers to use it in their apps. My team created a library to handle the complex functionality, created demo applications, and documented FAQs to prevent developers from having to do as much research as we did to understand and use Wi-Fi Direct. We also created a Wi-Fi Direct Google Group earlier this year to share resources, ask questions, and have general discussions around Wi-Fi Direct. WiFi-Buddy and the other apps mentioned in this post are located in our GitHub Organization, and contributions are welcome!


WiFi-Buddy: https://github.com/Crash-Test-Buddies/WiFi-Buddy GitHub Organization: https://github.com/Crash-Test-Buddies Google Group: https://groups.google.com/forum/#!forum/wi-fi-direct

Kundan Kale

unread,
Nov 10, 2017, 5:14:46 AM11/10/17
to Wi-Fi Direct
This library supports file transfer ? I mean file transfer over socket?

Kundan Kale

unread,
Nov 12, 2017, 11:47:55 PM11/12/17
to Wi-Fi Direct
I am developing data transfer application , in which i am using Wifi-Direct for pairing devices.Once Pairing done, I am sending files over socket between two android devices. The problem is some time if i try to send huge amount of data ( 10/12 GB) socket connection is reset. i.e. pairing between devices is terminated.
How should i handle this?
Reply all
Reply to author
Forward
0 new messages