5
votes

Recently I got a iBeacon device with the intention of creating Android Apps than can recognize it and use it. I'm new using bluetooth in Android Apps and there many things than I still don't know. Looking in the Internet and in this forum I found recommendations to use the Radius Networks' Android IBeacon Library but, alas, now it's no longer available:

https://github.com/RadiusNetworks/android-ibeacon-service

So I started by using the code shown in Android Developers' guide about Bluetooth Low Energy: https://developer.android.com/guide/topics/connectivity/bluetooth-le.html

Using this code I can detect the device, even connect to it, but I don't know how to get the Proximity Uuid and the Major and Minor values: the app shows a lot of Uuids from services and characteristics of the device, but none is the Proximity Uuid of the device.

Anyone could tell me how to get that data using the Android Bluetooth LE API, or help me to get the Radius Networks' Android iBeacon library for Eclipse and a guide to use it or sample showing how to use it?

Thank you.

3
Well at least you can get back to the last commit and browse the files there: github.com/RadiusNetworks/android-ibeacon-service/tree/…matcauthon
i have sam problem when i was comparing uuid of which is i am sending from ios application and i am receiving device uuid but but its different id and one more thing is i m not able to get major id and minor id. i am refering this examplebhavesh kaila

3 Answers

2
votes

EDIT/UPDATE:
It gets better.. AltBeacon !
Check the AltBeacon specifications

AltBeacon brings greater transparency to what a beacon transmits and how that data can be used by Android, Windows and other devices.


Why the Android iBeacon Library by RadiusNetworks is no longer available:

Vendors have started complying with guidelines set by Apple and have, as a result, been forced to ‘scrub’ their products of any references or connection between Android devices and their detection of iBeacon protocols.

Read more: Apple cracks down on iBeacon for Android
I think the best bet seems to be from somebody who has been using it, already has it, can share it with you, as from previous commits, you may not get every component - library, sample, service

Also: A note from the CEO for Android iBeacon Lib, RadiusNetworks

Now, coming to Proximity UUID and major, minors:
I have not found a direct way to get it, in terms of a parameter, though you can have a look at read major, minor, uuid of beacons in android and SensorTag using iBeacon Technology. In the latter, there is an indication of major, minor, uuid after iBeacon Service, however TI instruments might be the restriction.

In android, as an identifier.. you can recover the device addressby device.getAddress() of the beacon/for each BluetoothDevice device;.

2
votes

The following two are totally different things, although both are called UUID.

  • UUIDs of GATT services which are hosted on a BLE peripheral device.
  • Proximity UUID of iBeacon.

What you should know about "UUIDs of GATT services":

  1. BLE peripheral devices may implement a GATT server.
  2. A GATT server hosts GATT services.
  3. What the API "android.bluetooth.BluetoothGatt.getServices()" returns is a list of GATT services (List<BluetoothGattService>).
  4. BluetoothGattService.getUuid() returns the ID of the service.

What you should know about "Proximity UUID of iBeacon":

  1. BLE peripheral devices broadcast advertising packets.
  2. The payload part of an advertising packet contains a list of AD structures.
  3. An AD structure consists of (1) Length (1 byte), (2) AD Type (1 byte) and (3) AD Data. The AD structure format is described in "11 ADVERTISING AND SCAN RESPONSE DATA FORMAT" of "Bluetooth Core Specification 4.2".
  4. iBeacon is a kind of AD structures.
  5. AD Type of iBeacon is 0xFF (which means Manufacturer Specific Data).
  6. The first 4 bytes of AD Data of iBeacon are 0x4C, 0x00, 0x02 and 0x15. The first 2 bytes (0x4C, 0x00) mean "Apple, Inc." and the next 2 bytes (0x02, 0x15) mean "iBeacon format".
  7. Proximity UUID (16 bytes), major number (2 bytes in big endian), minor number (2 bytes in big endian), and power (1 byte) follow the first 4 bytes.

So, what you have to do to get iBeacon information (Proximity UUID, major, minor, power) are as follows.

  1. Parse a payload of an advertising packets as a list of AD structures.
  2. For each AD structure, check if AD Type is 0xFF and the first 4 bytes of AD Data are 0x4C, 0x00, 0x02 and 0x15.
  3. When the conditions of 2. are satisfied, parse the remaining bytes as Proximity UUID, major number, minor number, and power.

If you use nv-bluetooth, you can extract iBeacon from an advertising packet like the following:

public void onLeScan(BluetoothDevice device, int rssi, byte[] scanRecord)
{
    // Parse the payload of the advertising packet.
    List<ADStructure> structures =
        ADPayloadParser.getInstance().parse(scanRecord);

    // For each AD structure contained in the advertising packet.
    for (ADStructure structure : structures)
    {
        if (structure instanceof IBeacon)
        {
            // iBeacon was found.
            IBeacon iBeacon = (IBeacon)structure;

            // Proximity UUID, major number, minor number and power.
            UUID uuid = iBeacon.getUUID();
            int major = iBeacon.getMajor();
            int minor = iBeacon.getMinor();
            int power = iBeacon.getPower();

            ........

See "iBeacon as a kind of AD structures" for details.

1
votes

RadiusNetworks has "re-released" the libraries and examples in conjunction with a new cross platform beacon proximity spec.

New AltBeacon Standard Allows Cross-Platform Proximity Apps

Check out altbeacon.org.