Skip to content

Instantly share code, notes, and snippets.

@yaronyg
Created March 8, 2016 15:31
Show Gist options
  • Save yaronyg/9ff7a619958691504698 to your computer and use it in GitHub Desktop.
Save yaronyg/9ff7a619958691504698 to your computer and use it in GitHub Desktop.
A small doc that when typing at the end causing StackEdit to jump around
---
title: Android Wireless Issues
layout: page-fullwidth
permalink: "/androidWirelessIssues/"
categories:
- documentation
header:
image_fullwidth: "header.png"
---
Getting peer to peer working on Android has been and continues to be a heck of a challenge. This document outlines a number of major areas where we had issues/challenges with Android and explains our rationale for how we dealt with them.
# Discovery - Wi-Fi Direct vs BLE
One of the first problems we ran into is - how should two Android phones discover each other as a prelude to communicating? Originally we adopted Wi-Fi Direct's discovery infrastructure. Wi-Fi Direct discovery is a two phase process. First there is peer discovery in which a phone advertises its MAC, a phone type ID and a phone identifier (that we can't set programmatically). This is then followed by Wi-Fi Direct Service Discovery where a phone can advertise what services it uses. We like Wi-Fi Direct because support for Wi-Fi Direct has been in Android for quite some time and so in theory using Wi-Fi Direct meant we could perform discovery using older handsets.
After literally months of testing Wi-Fi Direct's discovery infrastructure against numerous Android phones we came to two conclusions:
1. Wi-Fi Direct Peer discovery works pretty well
2. Wi-Fi Direct Service discovery doesn't work very well at all
We ran into endless problem with Wi-Fi Direct Service discovery including but not limited to:
* Phones from different manufacturers were highly likely to either never find each other over Wi-Fi Direct Service Discovery or if they did find each other it could take many minutes
* The Wi-Fi Direct Service Discovery stack had a habit of just stopping to work after some period of time. And once it stopped working the only way to get it working against was to reboot the phone.
* We encountered random disruptions in the working of the main Wi-Fi stack when we used Wi-Fi Direct Service discovery for any extended period of time.
So while Wi-Fi Direct Service discover was perfect for our needs in theory, in practice it wasn't going to work.
Now we could have fallen back to Wi-Fi Direct Peer Discovery. But this wasn't a good solution either because the instability we saw in the Wi-Fi stack appeared to also apply to Wi-Fi Direct Peer Discovery. Also Wi-Fi Direct Peer Discovery made ad-hoc connections impossible. For example,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment