Hi Olivier,

Thanks for including the error message.  I should have looked more closely before responding.

HCI commands are implemented in the controller (TI), not in the Bluetooth stack.

Jakub's answer is more complete, so I'll stop writing now :)

Thanks,
Myles

On Wed, Mar 8, 2017 at 5:24 AM, Olivier MARTIN <olivier@labapart.com> wrote:

Thanks Miles, yes the functionality I am looking is exposed in the Java API but the issue is Hikey does not support it. For instance for the example "android-BluetoothAdvertisements", it returns "Bluetooth Advertisements are not supported on this device."
That's why I started to go down the stack to see how I could enable this support in the BSP.

I am making some progress in my understandings of Bluetooth stack. Fluoride (new name for Bluedroid since Android 6.0) located in `https://android.googlesource.com/platform/system/bt` plays the role of HAL module.
To add BLE peripheral support to a chipset (for instance Hikey's TI WL1835MOD chipset), I would need to implement the HCI commands.
I have not still figured out where these HCI are implemented.

I found TI chipset support in:
- https://android.googlesource.com/platform/hardware/ti/wpan/ (last change more than 3 years ago)
- https://android.googlesource.com/device/linaro/hikey/+/master/wpan/
- https://android.googlesource.com/kernel/hikey-linaro/+/android-hikey-linaro-4.4
... but no trace of Android Fluoride HCI commands.

For instance, one of the commands needed for BLE Peripheral role is LE_Multi_Advt_Command (OCF:0x154). But I cannot find any drivers implementing it.


On 08.03.2017 13:52, Myles Watson wrote:

Hi Olivier,
 
 
I think the functionality you are looking for is exposed in the Java APIs.  You shouldn't need to send HCI commands directly or implement any low-level GATT code.
 
Thanks,
Myles

On Wed, Mar 8, 2017 at 2:33 AM, Olivier MARTIN <olivier@labapart.com> wrote:
Hi all,
for one of my projects I need my Android device to act as a Bluetooth LE peripheral device. I noticed this feature has been added in Android 5.0 (https://developer.android.com/about/versions/android-5.0.html). Unfortunately my Nexus 4 is unlikely to get this feature (https://altbeacon.github.io/android-beacon-library/beacon-transmitter-devices.html). But I also have a 96Board Hikey board that has become an official platform in AOSP.

Is there a plan to support Bluetooth LE peripheral role to Hikey? If yes, any idea of the ETA?
I would not necessary excited to do it but if there is no plan I would add the support myself. I am familiar with GATT (Bluez), JNI, Linux Kernel, Android application. I know the Hikey is capable of BLE peripheral as I already used Bluez and its DBus interface to make Hikey appears a BLE peripheral.

I am new to AOSP world. So I am a bit lost in the various components. I already read these pages:
- https://source.android.com/devices/index.html: Android Interfaces and Architecture
- https://source.android.com/devices/bluetooth.html: Bluetooth
- https://source.android.com/devices/Android-6.0-Bluetooth-HCI-Reqs.pdf: Android 6.0 Bluetooth HCI Requirements

I understand the HAL peripheral support is generally divided in module (defined by hw_module_t) and device (defined by hw_device_t).
I saw HAL interfaces are defined by libhardware and potentially the one that would interest me is `bt_gatt_server.h`.
But I am a bit unclear by the link between Android Bluetooth HCI and `bt_gatt_server.h`.
If I wanted to add GATT Server to Hikey what should I do?

Sorry if you have nothing to do with this issue. I collected emails around repositories and web resources. I am not sure who is the best person to answer this question.

Thanks in advance,
Olivier