Can an Android Device Act as an Ibeacon

Can an Android device act as an iBeacon?

YES This is possible on Android 5+, and you can find open-source code for transmitting as a beacon in the Android Beacon Library. There is also a full-featured version of a beacon transmitter in the Beacon Scope app in the Google Play Store.

Here's an example of transmitting iBeacon with the Android Beacon Library:

Beacon beacon = new Beacon.Builder()
.setId1("2f234454-cf6d-4a0f-adf2-f4911ba9ffa6")
.setId2("1")
.setId3("2")
.setManufacturer(0x004c)
.setTxPower(-59)
.build();
BeaconParser beaconParser = new BeaconParser()
.setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24");
BeaconTransmitter beaconTransmitter = new BeaconTransmitter(getApplicationContext(), beaconParser);
beaconTransmitter.startAdvertising(beacon);

You can also transmit as a beacon on rooted Android 4.4.3 devices, but it requires an app installed with system privileges.

Android 4.3 devices with BluetoothLE can see iBeacons but not act as iBeacons, because Android 4.3 does not support peripheral mode. Samsung Android devices contain a separate proprietary SDK but it also does not allow devices to act as iBeacons. See: Make Samsung Android device advertise as an iBeacon) iOS devices, however, can act as iBeacons.

Normally, iBeacon technologies are not intended for phones to see other phones. But you could do what you suggest on iOS by making a custom app that makes phones act as an iBeacon and look for other iBeacons around them. This would allow anybody with the app to see others with the same app nearby. All phones would need Bluetooth turned on.

To answer your second question, yes, a mobile device, both Android or iOS, must have an app installed to take advantage of iBeacons. Neither operating system currently does anything when it sees an iBeacon unless an app is installed that is specifically programmed to do something. So customers who arrive in a store must have an app already installed or they cannot interact with iBeacons.

Android Device to Act as Beacon

A few points:

  • Yes, you can make a beacon app that sends both an iBeacon and/or an Eddystone beacon transmission from an Android device. You need a device with Android 5.0+ that supports transmission (not all do). You can see a list of such devices here. The Android Beacon Library shows how to code transmission here. There is also an off-the-shelf Locate app that supports transmission here.

  • It is also possible to make a transmitter beacon app on iOS, but iOS only supports transmission of iBeacon packets (you cannot transmit Eddystone on iOS), and iOS cannot transmit when the app is in the background. Android can.

  • If you want your client app to detect quickly in the background on iOS, you are better off with iBeacon than Eddystone. Detection of iBeacon signals is optimized in the background on iOS and is built-in. Detection of Eddystone requires extra software and is not as fast.

  • To send a notification on beacon discovery you simply write code in the client app that detects the unique beacon identifier then creates a local notification message keyed off the beacon identifier and sends it to the user. The important part to understand us that the client code does all of the message sending locally. All the beacon app does is transmit a unique identifier that the client app receives.

To illustrate the point about how you send local notifications based on beacon identifiers, here is some sample code for iOS. This code runs on the client app. The Beacon simply sends out a transmission with specific beacon identifiers, and the client app reads them and acts appropriately.

var lastNotificationTime = NSDate(timeIntervalSince1970: 0) // Initialize last Notification time to a long time ago

func locationManager(manager: CLLocationManager, didRangeBeacons beacons: [CLBeacon], inRegion region: CLBeaconRegion) {
// Only send notification if we have not done so in the last hour (3600 seconds)
if (lastNotificationTime.timeIntervalSinceNow < -3600.0) {
for beacon in beacons {
// Send a 20% off notification for beacon with identifiers major 1, minor 2
if beacon.major.intValue == 1 && beacon.minor.intValue == 2 {
let localNotification = UILocalNotification()
localNotification.alertTitle = "Discount 20% on all items"
dispatch_async(dispatch_get_main_queue()) {
UIApplication.sharedApplication().presentLocalNotificationNow(localNotification)
}
}
}
}
}

Full Disclosure: I am the lead developer on the Android Beacon Library open source project and the author of the Locate app.

Can an Android device act as an iBeacon, with Flag?

Unfortunately, Android's Java BLE APIs expose no way of doing this. I researched this topic to answer the Android Beacon Library Issue you referenced. The Java APIs only let you advertise either service data or manufacturer data. They are simply not flexible enough to let you specify any other advertising PDUs. This has not changed as of May 2016.

You might be able to do what you want by dropping down to a lower level and talking to C BlueDroid APIs. But doing this would require a rooted device and perhaps installing a custom Android OS image to give you access.

Do turning bluetooth on with Android makes it a beacon?

No. Turning on bluetooth does not make mobile devices -- neither Android nor iOS -- advertise as beacons. If you want to make either platform advertise as a beacon, you must install a custom app that is programmed to start the advertising. The Android Beacon Library has tools to do this on Android. On iOS you can use built-in CoreLocation and CoreBluetooth.

On both iOS and Android, if you turn on Bluetooth from the settings screen and leave the settings screen up, it will emit both BLE and Bluetooth Classic packets to make it discoverable by external bluetooth scanning apps. But these advertisements will absolutely not be BLE Beacon advertisements in the strict sense. It is still possible to detect these non-beacon packets with some scanning apps.

Just enabling bluetooth on either platform might make it detectable based on what the other apps are doing. There may be pre-existing apps on the phones that emit BLE beacon advertisements, BLE GATT service advertisements, or similar. However, you cannot predict whether any individual device will do this because you can't predict what apps are installed. Nor can you know what advertisements random apps will emit in a way that is predictable. If you want to be able to rely on detecting another device with BLE in a predictable way you must get an app installed on that device.

Can an Android 4.4 device act as an iBeacon?

Yes, this is possible on 4.4.3, but the critical API methods startAdvertising(), stopAdvertising() and getAdvScanData() (which allows you to read and write the raw information sent out in the advertisement) are blocked from use unless an app has android.permission.BLUETOOTH_PRIVILEGED. This is a system-level permission, so the only way to get this is for your custom app is to root your phone, and install your app in the /system/priv-app directory.

If you can accomplish that, the basic code to do this is:

byte[] advertisingBytes;
advertisingBytes = new byte[] {
(byte) 0x18, (byte) 0x01, // Radius Networks manufacturer ID
(byte) 0xbe, (byte) 0xac, // AltBeacon advertisement identifier
// 16-byte Proximity UUID follows
(byte) 0x2F, (byte) 0x23, (byte) 0x44, (byte) 0x54, (byte) 0xCF, (byte) 0x6D, (byte) 0x4a, (byte) 0x0F,
(byte) 0xAD, (byte) 0xF2, (byte) 0xF4, (byte) 0x91, (byte) 0x1B, (byte) 0xA9, (byte) 0xFF, (byte) 0xA6,
(byte) 0x00, (byte) 0x01, // major: 1
(byte) 0x00, (byte) 0x02 }; // minor: 2
BluetoothManagerbluetoothManager = (BluetoothManager) this.getApplicationContext().getSystemService(Context.BLUETOOTH_SERVICE);
BluetoothAdapter bluetoothAdapter = bluetoothManager.getAdapter();
BluetoothAdvScanData scanData = bluetoothAdapter.getAdvScanData();
scanData.removeManufacturerCodeAndData(0x01);
scanData.setManufacturerData((int) 0x01, advertisingBytes);
scanData.setServiceData(new byte[]{}); // clear out service data.
bluetoothAdapter.startAdvertising(advertiseCallback);

The above code shows you how to transmit an open source AltBeacon. But you can transmit other beacon types by changing the byte pattern.

Another important restriction in Android 4.4 is that a bug prevents you from advertising more than 24 bytes of data, instead of the 26 that should be allowed. This means that beacon advertisements may be truncated if they require more than 24 bytes. AltBeacon, for example, uses the second of those last two bytes to store the calibrated transmitter power. Because this cannot be sent, that means distance estimates are not possible using the Android Beacon Library's standard APIs.

You can see a description of how this is done here

Is Android L device act as a Beacon Now?

Yes, it is now possible. We have an app available in Google Play and sample code in the Android Beacon Library.

See here for more info:

http://developer.radiusnetworks.com/2014/11/18/beacon-transmission-with-android-5.html

Phone act as beacon

This Cordova plugin supports detection on both iOS and Android:

https://github.com/petermetz/cordova-plugin-ibeacon

It only supports transmission on iOS, but the underlying native Android Beacon Library it uses supports transmission:

http://altbeacon.github.io/android-beacon-library/beacon-transmitter.html

It should be reasonably simple to add the missing Cordova bindings for Android so that platform works to transmission as well.



Related Topics



Leave a reply



Submit