Search code examples
androidwifibeacon

Access information elements in wifi scan from android


WiFi beacons contains several information. For example they contain the name of the network (the bssid), the beaconing time, etc. Moreover they can also contain vendor extensions in the form of Information Elements (IEs).

Is there an API in adroid that allows you to access these IE? An alternatives would be also to have access to the raw wifi beacon as a string of bytes.


Solution

  • Receiving low-level WiFi packets like beacon frames is restricted to system apps using native APIs, so root access would certainly be required to do this. In addition, you may need an external WiFi device connected to the USB port using an OTG adapter to allow you to do this. The folks at Kismet Wireless have developed an app with open source code that does this on Android using the low-level libpcap code. You can access that here: https://www.kismetwireless.net/android-pcap/

    The tool described above captures the WiFi packets (including beacon frames) and writes them to a file on Android. I have modified this code myself to send the raw packets as a byte array to my application, from which I can parse the bytes in the byte array, to extract the fields from a beacon frame.

    Yes, this is a lot of work, and comes with a lot of restrictions in terms of root and the need for an external WiFi device. Obviously this is not the built-in Android API referred to in the question. Unfortunately, I believe this is the closest you can come. Sorry.

    Clarification: This question is about low level WiFi packet beacon frames, and not proximity beacons (e.g. iBeacon, Eddystone) as may be suggested by the beacon StackOverflow tag.