How can I make my Android application to act as a Beacon? - android

I want to develop two Android applications out of which one application should act as a Beacon. That is, one of my application installed in one device should listen certain events from the other app installed in other device and should broadcast some information on listening those events.
I read many articles and I found that the Android device must have Bluetooth LE hardware and it must have peripheral mode enabled by the device manufacturer. But most of the manufacturer as well as Google itself has disabled peripheral mode.
So my question is there a way (a Beacon library available?), so that I can make my application to act as Beacon.
Thanks in Advance.

You can use the Android Beacon Library to make a device both transmit as a beacon and detect/decode beacon transmissions.
It is true that devices must have BLE hardware for this to work, Android 4.3+ to detect beacons and Android 5.x+ to transmit as beacons. While not all devices with 5.x+ support peripheral mode needed to transmit, most popular devices do. Google has not disabled this, and their newer Nexus and Pixel devices support transmission as well.
The library linked above has a list of devices known to support transmission, and includes example code showing how to determine this at runtime on a specific device.
If a device does not support peripheral mode, there is nothing you can do short of rooting the device and trying to write a new Bluetooth driver yourself.

Related

Android bluetooth settings show duplicate names for same bluetooth device

I am working with a firmware team that writes firmware on a QCC3056 Qualcomm chipset that supports earbuds and I develop an android application that supports the BLE earbud Bluetooth device. The earbuds also support google fast pair and this feature requires the BLE mac address to be rotated every 15 min.
So the issue I am seeing here is the android Bluetooth settings recognize two Bluetooth devices with the same name(one is classic and the other one is BLE). I can tell by the mac addresses that one belongs to classic and the other belongs to the BLE address. We are able to connect to the classic instance. However, we are unable to connect to the BLE instance. We would like just one name to show up and the user should be able to connect to it. The firmware team thinks this is expected behavior(two names showing up). As far as I know, from the android end, we don't have any control over the Bluetooth settings. So I wanted to understand if this behavior is expected. I have tested this scenario with SONY WF-1000XM3 which supports Google Fast Pair and I have noticed only one name showing up.
It would be great if anyone can suggest the best possible approach I can take here.

BLE Supported Android Phones

I want to know if we can detect android phones as well with BLE Scan. I am trying to develop an android app which can scan nearby Bluetooth Android devices.
I checked both android devices are compatible with BLE with this app: https://play.google.com/store/apps/details?id=com.myan.michaelyanyoga.bluetoothchecker
Note: I am using this code to develop my scanner app: https://github.com/kaviles/BLE_Tutorials. I am able to see my laptop Bluetooth on this list but not other android phones(which supports BLE).
To detect Android phones using BLE, the other device needs to:-
Have Bluetooth turned on.
Be advertising
Unfortunately, most devices are not doing this by default, which means you may not be able to use BLE for your intended purposes. You can test this by doing the following:-
Download the nRF Connect Android app.
Go to ADVERTISER from the top menu.
Toggle the "Test" advertiser.
After this you should begin to see your Android device via Bluetooth.
I hope this helps.

Android Wear Device as iBeacon

Is it possible to use an Android Wear device as a Bluetooth Low Energy beacon, separately from its connection to the phone?
I'm working with iBeacons that connect to both iOS and Android devices, and the iBeacon (Bluetooth Low Energy) capabilities of various mobile devices vary widely.
Most of Apple's devices (iPhones, recent iPads, and laptop/desktop devices) can transmit as an iBeacon. Only certain recent Android devices can do so, e.g. the Nexus 6 and Nexus 9.
I just purchased a Moto 360 to play around with and it does use BLE to transmit to the paired device, but I'm curious if I can write an app that will cause it to transmit arbitrary packets and an arbitrary UUID. Has anyone done that? It seems as though it should be possible. I've gone through the Android Wear developer's site but have not found any discussion of this topic.
Thanks for any ideas, links to web sites, etc.
UPDATE:
I just test my answer below and it seems like the Android.Bluetooth.LE namespace is not available for Android Wear. I'm afraid I have to say that (currently) it is not possible for an Android Wear device to broadcast as a beacon using native java Android.
EXPLANATION:
You can perform that test yourself. You mentioned you have a Moto 360. Just deploy a test app to it that gets the Bluetooth system service as BluetoothManager and test wether the adapters BluetoothLeAdvertiser property is not null.
((BluetoothManager) this.getSystemService(Context.BLUETOOTH_SERVICE))
.getAdapter().getBluetoothLeAdvertiser() == null
((BluetoothManager) this.getSystemService(Context.BLUETOOTH_SERVICE))
.getAdapter().isMultipleAdvertisementSupported() == null
You can use Android's native beacon broadcasting libraries or use a 3rd party library like AltBeacon to broadcast arbitrary beacon data.

Possible to hack BLE peripheral mode support in Android?

This blog post from radius networks discusses how Android devices can not yet be used as iBeacons (AKA: BLE peripheral mode) even if the device's hardware supports BLE, because Android has no APIs for BLE peripheral mode.
NOTE: BLE means Bluetooth Low Energy
After reading this section, I am gonna suggest something stupid
Because their SDK only supports the central role, “advertising” a
service as a central server means sitting their quietly, only
revealing (or “advertising”) its service characteristics to another
device in peripheral mode after a connection is already established.
This connection establishment requires another device to do the actual
radio advertising first. Samsung’s SDK isn’t going to do it.
Is it possible to trick the device in central mode (the Samsung phone) into thinking another device in peripheral mode has established a connection to it and then get the central mode to "advertise". Can you trick the phone by faking the connection in software?
Probably a stupid idea, probably it's possible to trick the device in central mode, but the "advertisement" is not the BLE peripheral mode advertisement and would not resemble an iBeacon in peripheral mode.
I very much need BLE peripheral mode support from Android and for the moment I would be ok with hacking something, in the hopes that Android is going to eventually support this feature-set, which BTW is already a feature request
I don't think this technique will work, even if it is possible to "trick" Android into thinking it has a connection to another BLE device. Although this question is about the Samsung BLE SDK, I think the same answer applies to the dedicated Android BLE APIs (android.bluetooth.BluetoothAdapter) that shipped starting with Android 4.3.
Let's put aside the tricking part for a minute -- even if Android's actually does have a connection to another BLE device, can you make it advertise? If by "advertising" you mean revealing its services to the other device, the answer is yes. But this radio transmission is over a private channel between the two devices, and could not be picked up by a BLE scan in the same way that iBeacon advertisements are. It really isn't an advertisement at all -- which is why I said in the blog post that the Samsung documentation is misleading. So if you can't do this with a real connection, then tricking a connection won't work either.
My understanding of bluetooth stacks is limited, but I think that the actual radio broadcast advertisements that scans can pick up are controlled by the hardware BLE chipset, which means you have to have access to the parts of the bluetooth stack that tell the hardware to make this happen. I don't think there is anything in Samsung BLE SDK or the Android SDK that intentionally allows this.
An alternative may be to make direct JNI calls to the BlueDroid stack. I'm not sure if Android permissions allow this, or if advertising is even implemented in the BlueDroid stack.
UPDATE: Transmitting as a pheripheral now possible in Android 4.4.3 and Android L. See here.

Is it possible to use a BLE enabled Android/iPhone as a BLE beacon?

I'm working on a BLE proximity sensing feature based on Android and need some information.
Currently I see there are no BLE beacons manufacturers for android. I found 2 so far for iPhone.
1) http://www.estimote.com
2) http://www.gimbal.com
Estimote claims that their devices are generic but mainly they are publicized for iBeacons. So I'm not sure whether I should order them for a feature on Android.
Secondly gimbal explicitly mentions that their devices won't be enabled for android for proximity sensing.
So if any of you know where can I order BLE beacons compatible with Android please let me know.
Another thing, for prototype testing I was wondering whether I could use a Android BLE capable tablet or smartphone as a beacon to emit BLE signals?
Till now the documentation for android only suggests how to detect a beacon, But I'm not sure whether an Android device can be used as a beacon.
Any insights?
There is a BLE Beacon manufacturer for Android: Radius Networks
You can detect any standard iBeacon on Android using our Android iBeacon Library.
You can try it out yourself with our free iBeacon Locate app, which is based on this library. My company also sells both software and hardware iBeacons that I guarantee work with Android. But again, any standard iBeacon will work, too. Don't take my word for it -- just download our free app and use it to see one of our iBeacons. (We even have a free virtual machine you can use!)
It is currently not possible to make an iBeacon out of a stock Android device because the Bluetooth LE APIs, introduced in Android 4.3, do not support the peripheral mode needed to transmit advertisements like an iBeacon.
EDIT: It is now possible to make rooted Android 4.4.3 devices transmit as an iBeacon. See here.
I tried simple BLE scan app on Android, but the callback for LeDevices always returned null for UUID[]. Also, finding based on know UUID didnot work.
To add to David's reply. I have tried Radius Networks SDK, pretty clean. I like it.
Also, Estimotes has released their Android SDK today(1/7), which is good. The sample App shows notification, Distance, Major-Minor. I tested with 3 Estimotes & also with iPhone's app (making the iPhone as iBeacon). It works well, give it a try.
Note that you have to modify the code
change the ESTIMOTE_PROXIMITY_UUID value to the UUID that you are watching for.
Hope it helps.

Categories

Resources