Problem definition:
I've been trying to use BLE proximity profile for Bluetooth LE on Android. Some of the devices like new generation Google Nexus tablet with 4.3 Android support BLE and can act as a central device.
I read the Android official documentation of the Bluetooth LE but their doesn't seems any support for that. Is their any workaround to implement our own proximity profile?
Questions which talk about proximity profile on Android but are of no help
Reading Bluetooth RSSI for BLE proximity profile in Android.
How to use the profile of PROXIMITY PROFILE,IMMEDIATE ALERT SERVICE and Find Me Profile in android 4.3 BLE?
BTLE (Bluetooth Low energy) development kit - must have proximity profile
Any help is appreciated. Thanks.
June 2014:
Thanks everyone for the answers. Just to update, as of June 2014, BLE Peripheral mode is offered in the Android L Developer preview. So now Android devices can act both in peripheral and central role. Hope to see it in the Android L official release. Quoting from their blog New in Android: L Developer Preview and Google Play Services 5.0:
The L Developer Preview, lets you explore many of the new features and capabilities of the next version of Android, and offers everything you need to get started developing and testing on the new platform. Here are a few of the highlights for developers:
BLE Peripheral Mode — Android devices can now function in Bluetooth Low Energy (BLE) peripheral mode. Apps can use this capability to broadcast their presence to nearby devices — for example, you can now build apps that let a device to function as a pedometer or health monitor and transmit data to another BLE device.
Update 16th October 2014:
Its out now! Checkout Android 5.0 wireless changes page.
Update 8th December 2014:
The bad new is that BLE Peripheral mode will only work on the newer Android devices (as per the date), viz Nexus 6 and Nexus 9. It won't work on Nexus 4/ Nexus 5/nexus 7/ nexus 10 even if you update it to Android 5.0. You can read the comment by one of the Android Project manager on BLE advertise mode not working ticket. He says:
We introduced BLE peripheral mode in Android 5.0 Lollipop. Nexus 6 and Nexus 9 are the first two production Nexus devices that support BLE peripheral mode. Due to hardware chipset dependency, older Nexus devices (4/5/7) will not have access to the feature on Lollipop.
Thanks to Rob Anderson for informing.
To elaborate on shubhams's answer:
Unfortunately there is no way for Android devices to act as a peripheral. He can creates GATT servers, services and charachteristics but there is no way to make the advertising.
(https://stackoverflow.com/a/18020153/3061383)
Since Android does not (yet) support advertising no other BLE device is able to initiate a connection to an Android device. As of now the Android device must initiate the connection.
Unfortunately, the android can only act as central not peripheral. So custom profiling is not possible at this point of time. Rather you can use the profile which are being provided by gatt.
For example: Temperature Monitor profile. Instead you can make the custom service and characteristics on iPhone and make it work as beacon.
Also if you are using hardware device of Estimote and other companies, you can reply back the data from android device i.e Services and characteristics have the properties such as Read, Write and Notify. But when you are making iPhone as Beacon, then you won't be able to receive the value from android device.
Related
I am going to start GATT server on my mobile phone for sharing some data to nearby devices. From official documentation API for working with LE Bluetooth was introduced in Android 4.3(18 API level).
I found some samples witch show how to run server. All of them use BluetoothLeAdvertiser which was added in Android 5.0(21 API level).
So I built two client/server sample applications and easy found my "SERVER DEVICE" in "CLIENT DEVICE", but how can I achieve that without BluetoothLeAdvertiser? In other words how can I connect to BluetoothGattServer and do not use BluetoothLeAdvertiser? It is critical for me, because my application has minSdk=19(Android 4.4).
Thanks for help!
Even with Bluetooth Low Energy being available in Android API level 18, you will not be able to use an Android phone in peripheral mode with API level lower than 21.
As seen in Android Lolipop release notes:
Android 4.3 introduced platform support for Bluetooth Low Energy
(Bluetooth LE) in the central role. In Android 5.0, an Android device
can now act as a Bluetooth LE peripheral device.
Also, not all Android devices that have Lollipop support the peripheral mode. This list shows what device models are able to transmit as the server.
You are able to use your app as the client side, there is a code example in the Android Bluetooth Low Energy documentation page.
In Android 4.3, i understood as an Android devices can't act as a Beacons because of not supporting for BLE Peripheral mode. But, Android L comes with supporting for BLE Peripheral Mode. So, Is it possible to the Android Devices now act as a Beacons? If yes, Please let me know
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
Has anybody used Samsung's Bluetooth LE APIs to make a Samsung Android device advertise as an iBeacon? This should be possible, but I do not have access to a device to try it.
If anybody has used it to make a Samsung Android device advertise as any other Bluetooth LE peripheral, I would like to know that, too.
EDIT: This is now possible on Android L. See here.
EDIT: this answer is about older Samsung phones with Android 4.2. Samsung devices with Android 5.0+ can advertise beacons successfully.
Unfortunately, #reTs and #duncan-c are right (+1 for each of them). The Samsung BLE SDK cannot send out real BLE advertisements as is required for iBeacons.
I was holding out hope because their documentation says "allowing applications to create and advertise Bluetooth smart services and characteristics". I wrote an app to prove whether this actually worked, and learned that their documentation is simply misleading. The Samsung BLE SDK will not make Samsung devices transmit advertisements over the radio.
See full details in this blog post.
http://developer.samsung.com/ble
You can view the official "Samsung BLE SDK Guide and Hints" on the above link.
On page 12, point 10, it said :
"The current version of the SDK supports only the GATT central role. Peripheral roles may
be supported in future releases."
I'm told that with the current firmware it's not possible. (I'm not an Android developer so I haven't confirmed this first-hand.)
Till Android 4.3, an Android device with Bluetooth Low Energy support could only act as a central device. As is given in the Android 4.3 Bluetooth LE docs:
Android 4.3 (API Level 18) introduces built-in platform support for Bluetooth Low Energy in the central role and provides APIs that apps can use to discover devices, query for services, and read/write characteristics.
With the introduction of Android 4.4 KitKat, can it also behave as a peripheral device now? I couldn't find any documentation of that. If not, then do we have to wait for Android 4.5 for getting the BTLE peripheral mode on Android device? Or is there any alternative way in which an Android device can be made to act as a peripheral device?
Not in this version but there is evidence that it is coming soon.
If you look in BluetoothGatt.java in the android-19 sources there are new methods listen and setAdvData that weren't there in android-18.
However these are not documented as I don't think native support is complete yet. The last check in on AOSP for peripheral mode was titled "LE: Add peripheral role support (2/4)". Also, setAdvData and listen have this code:
if (mContext == null || !mContext.getResources().getBoolean(com.android.internal.R.bool.config_bluetooth_le_peripheral_mode_supported))
{
throw new UnsupportedOperationException("BluetoothGatt#listen is blocked");
}
Looking in android/platform_frameworks_base/blob/master/core/res/res/values/config.xml from the Android sources you can see this is currently disabled:
<!-- Boolean indicating if current platform supports BLE peripheral mode -->
<bool name="config_bluetooth_le_peripheral_mode_supported">false</bool>
Thanks everyone for the answers. Just to update, as of June 2014, it is offered in the Android L Developer preview. Hope to see it in the Android L official release. From their blog New in Android: L Developer Preview and Google Play Services 5.0:
The L Developer Preview, lets you explore many of the new features and capabilities of the next version of Android, and offers everything you need to get started developing and testing on the new platform. Here are a few of the highlights for developers:
BLE Peripheral Mode — Android devices can now function in Bluetooth Low Energy (BLE) peripheral mode. Apps can use this capability to broadcast their presence to nearby devices — for example, you can now build apps that let a device to function as a pedometer or health monitor and transmit data to another BLE device.
Update:
The bad news is that BLE Peripheral mode will only work on the newer Android devices (as per the date), viz Nexus 6 and Nexus 9. It won't work on Nexus 4/ Nexus 5/nexus 7/ nexus 10 even if you update it to Android 5.0. You can read the comment by one of the Android Project manager on BLE advertise mode not working ticket. He says:
We introduced BLE peripheral mode in Android 5.0 Lollipop. Nexus 6 and Nexus 9 are the first two production Nexus devices that support BLE peripheral mode. Due to hardware chipset dependency, older Nexus devices (4/5/7) will not have access to the feature on Lollipop.
http://developer.android.com/sdk/api_diff/19/changes.html
By looking at the full api difference, the answer in short : NO
==============
To add peripheral role support now you have to get your hands dirty to customize the Bluedroid stack in the OS level, or try your luck on XDA developers to see if anyone has done this before. I am not sure the current Android phone support peripheral role at hardware level,though .
I am currently working on an Android project that requires Bluetooth Low Energy Peripheral mode. As of now, just targeting the Galaxy S4 with 4.2.2 on it Samsung BLE SDK at http://developer.samsung.com/ble
I followed their API docs and programming guide very closely, however broadcasting characteristics or services over Bluetooth Low Energy just doesn't seem to work. Has anyone else had any luck with getting this to work yet? If so, any help would be greatly appreciated!
Thanks a lot.
Because Samsung BLE 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.
What we need is an Android BLE API that allows creation of a peripheral server. Lots of folks were hoping that peripheral role support would be added in 4.4, but it wasn’t. Maybe we can hope for its addition in Android 4.5 or 5.0. There is a feature request asking for this. Add your name to the list!
Source
I am having the exact same issue. I can discover BLE devices and get their rssi values, but when I try to discover services or connect, I never receive a callback. I am using a Verizon Galaxy S4 running 4.2.2. I am using the Samsung BLE SDK 2.0. Apparently some heart rate monitors are working, but I get nothing using my ez430-rf256x TI development kit. I've tried the Keyfob demo and Heart Rate Profile demo in the Bluetopia v1.3 sdk.
Phones/tablets/pc's support(usually) Bluetooth dual mode chip. According to Bluetooth specification dual mode devices can't be a peripheral, but single mode devices do.