The best way is to try to call startAdvertisng()
Even if Adapter.isMultiAdvertisingSupported() returns true, other apps might have used the advertising instances, and you will be left with no advertising.

You probably don't see the log message because it was added recently, and your image is older.

This means chip vendor must support those commands. If they don't you're left with just one advertising instance. This god standarized in latest spec, and will no longer need vendor-specific extensions.




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

Thanks a lot Jakub! If I ignore `mBluetoothAdapter.isMultipleAdvertisementSupported()` and call `mBluetoothAdapter.getBluetoothLeAdvertiser().startAdvertising()` Hikey board can advertise and I connect to its GATT server using my Nexus 4.

FIY, I use "Images Preview" downloaded from: https://developers.google.com/android/images-preview#hikey
[ro.build.description]: [hikey-userdebug 7.1.1 NYC 3606021 test-keys]

It works but I do not see your log message in logcat (see attached bluetooth.log). It is not really clear which tag is using this "Image Preview".

How can I test if BLE Advertisement support is present on production device? ShouldI use Android version?

Myles, when you said the HCI commands are implemented by the controller. Do you mean these commands are implemented by the binary blob (these binaries https://android.googlesource.com/device/linaro/hikey/+/refs/heads/master/bt-wifi-firmware-util/)?
So, it means there is no one except TI who can add support for Android 6.0 Bluetooth HCI for TI WL1835MOD?


On 08.03.2017 18:17, Jakub Pawłowski wrote:

Hi Oliver,
 
Which exact version of Android are you using in your project ?
Previously, only devices supporting VSC (Vendor SpeifiC HCI) multi-advertising were able to advertise at all. I did modify this code, now depending on controller capabilities you either get regular advertising ("legacy" according to 5.0 spec, just one instance), VSC advertising, or Bluetooth 5.0 advertising sets used.
 
Here is code that pick which version is avaliable:
 
  if (controller_get_interface()->supports_ble_extended_advertising()) {
    LOG(INFO) << "Extended advertising will be in use";
    instance = new BleAdvertiserHciExtendedImpl();
  } else if (BTM_BleMaxMultiAdvInstanceCount()) {
    LOG(INFO) << "VSC advertising will be in use";
    instance = new BleAdvertiserVscHciInterfaceImpl();
    BTM_RegisterForVSEvents(
        BleAdvertiserVscHciInterfaceImpl::VendorSpecificEventCback, true);
  } else {
    LOG(INFO) << "Legacy advertising will be in use";
    instance = new BleAdvertiserLegacyHciInterfaceImpl();
  }
 
 
Even though the Adapter.isMultiAdvertisingSupported() will return false, you should still be able to start one advertising instance on latest source, if you are running latest AOSP code.

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