Does Android KitKat allows devices that support Bluetooth LE to act as a peripheral device?
Asked Answered
R

3

16

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?

Rountree answered 31/10, 2013 at 22:46 Comment(4)
Not yet I guess: code.google.com/p/android/issues/detail?id=59693Inefficacy
Thanks buddy. That request was before the release of 4.4. I also commented on that hoping to see some changes it in 4.4. Do you know if any alternative way is possible ?Rountree
Not sure you can work around it unfortunately, peripheral is more network architecture/hardware related. Maybe you can look into GATT server/client stuff and try to hack something up(not really recommended but hey desperate times right :)) . But looks bleak until they get it outInefficacy
In BLE the central decides the timing and the peripheral just have to follow orders (master/slave). So a device (with only one radio) cannot be both a slave and a master. Makes it a bit harder to create an API that supports both.Emotionalism
R
11

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.

Rountree answered 29/8, 2014 at 2:2 Comment(0)
E
18

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>
Earthly answered 13/12, 2013 at 14:39 Comment(1)
Do you know how can we read that value (for example: config_bluetooth_le_peripheral_mode_supported) from config.xml file?Grimona
R
11

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.

Rountree answered 29/8, 2014 at 2:2 Comment(0)
T
7

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 .

Triiodomethane answered 1/11, 2013 at 3:54 Comment(2)
Thanks reTs. Can you answer the second part please. Is their any alternative way to do the same of which you know or can there be?Rountree
Shameless plug, but we've done some work to enable this, but it requires a custom ROM, maybe some of the work could be ported to an NDK based solution: blog.cozybit.com/enabling-peripheral-mode-in-android-kitkat-4-4 -- you'll note that at the bottom, we point out that AOSP master already has support for this, so Android 4.5/5.0 will have support for this.Ministerial

© 2022 - 2024 — McMap. All rights reserved.