Export to GitHub

android-developer-preview - issue #1570

BLE advertise mode not working


Posted on Oct 18, 2014 by Happy Horse

In the first Developer Preview, I could use my Nexus 5 to advertise Bluetooth 4.0 Low Energy packets, broadcasting up to 4 or 5 virtual BLE devices at the same time.

In the latest preview, this does not work anymore. Why? Without having any kind of 3rd party apps that might screw this up (like maybe using the BT chipd for scanning, I don't know?), this happens now:

  • the new API isMultipleAdvertisementSupported() returns false!
  • the getBluetoothLeAdvertiser() now returns null!

I would like to be able to make the Nexus 5 actually being able to use the new BleAdvertise features introduced in API 21. Right now it's DOA.

* Which version of the SDK are you using? 21 * Which Android build are you using? (e.g. LPX13D) LPX13D * What device are you using? Nexus 5 * What steps will reproduce the problem? (Please provide the minimal reproducible test case.) BluetoothManager btManager = (BluetoothManager) getSystemService(BLUETOOTH_SERVICE); BluetoothAdapter btAdapter = btManager.getAdapter(); if (btAdapter.isEnabled()) { if (btAdapter.isMultipleAdvertisementSupported()) { // this is never true }

        // this will always return NULL
        mBleAdvertiser = btAdapter.getBluetoothLeAdvertiser();
    }

* How frequently does the issue occur? (e.g. 100% of the time, 10% of the time) 100% * What is the expected output? If Bluetooth is on and permissions are set, and we don't have any apps interfering (like scanning, for example), we should be able to advertise. * What do you see instead? Cannot use the device for BLE advertisement mode. * Relevant logcat output. No logcat errors or warnings related to Bluetooth. * Captured Android bug report (i.e using adb bugreport.) Be wary of leaking private information!

* Optional: Link to your APK or Google Play listing.

* Optional: Screenshot of the issue. Be wary of leaking private information!

* Optional: Other information that would be helpful in resolving the issue.

Comment #1

Posted on Oct 18, 2014 by Quick Rhino

I have also reproduced this same issue on the same device with the same build. See here:

http://stackoverflow.com/questions/26441785/does-bluetoothleadvertiser-work-on-a-nexus-5-with-android-5-0/26441948#26441948

Comment #2

Posted on Oct 18, 2014 by Grumpy Rhino

Since BluetoothAdapter.isMultipleAdvertisementSupported() returns false, getBluetoothLeAdvertiser will always return null (Android source). What the heck even is Multiple Advertisement?

public BluetoothLeAdvertiser getBluetoothLeAdvertiser() {
    if (getState() != STATE_ON) {
        return null;
    }
    if (!isMultipleAdvertisementSupported()) {
        return null;
    }
    synchronized(mLock) {
        if (sBluetoothLeAdvertiser == null) {
            sBluetoothLeAdvertiser = new BluetoothLeAdvertiser(mManagerService);
        }
    }
    return sBluetoothLeAdvertiser;
}

Comment #3

Posted on Oct 19, 2014 by Swift Lion

Does this new Android behavior imply Central and Peripheral Bluetooth LE operation have different hardware requirements?

Lo'd please let this be a defect...

Comment #4

Posted on Oct 20, 2014 by Happy Giraffe

Thank you for reporting this issue. We have passed this on to the development team and will update this issue with more information as it becomes available.

Comment #5

Posted on Oct 20, 2014 by Happy Giraffe

Issue 1571 has been merged into this issue.

Comment #6

Posted on Oct 20, 2014 by Helpful Monkey

I'm seeing the same issue with LPX13D on a Nexus 5.

BluetoothAdapter.getBluetoothLeAdvertiser() always returns null.

This worked with the pre-release build.

Comment #7

Posted on Oct 20, 2014 by Quick Lion

I am able to reproduce this as well. I had a working prototype of my app in the previous revision but advertising no longer works on the Nexus 5. Plan to test the new Nexus 7 build shortly, however it FAILED to advertise in the previous build.

Comment #8

Posted on Oct 22, 2014 by Grumpy Bird

I have reproduced this issue on a Nexus 7 as well using the lpx13d image.

Comment #9

Posted on Oct 25, 2014 by Happy Bird

I'm seeing the same issue with LPX13D on my Nexus 5, this is a BUG???

Comment #10

Posted on Oct 28, 2014 by Happy Rabbit

This is a production showstopper for Bluetooth Low Energy product development support for Android.

I reproduced this on Nexus5 and 7 with latest Android 5 developer preview.

Comment #11

Posted on Oct 28, 2014 by Swift Panda

I also could reproduce this in Nexus-5. Surprised to see such a basic feature broken in android. Please let us know if anyone found a workaround.

Comment #12

Posted on Oct 28, 2014 by Grumpy Ox

I had the same result on my Nexus 7 2013. Where may I find an older system image with BLE advertising working?

Comment #13

Posted on Oct 28, 2014 by Swift Panda

Comment deleted

Comment #14

Posted on Oct 28, 2014 by Grumpy Ox

Already tried, but it fails with ADVERTISE_FAILED_FEATURE_UNSUPPORTED (5) on the Nexus 7 2013.

Comment #15

Posted on Oct 28, 2014 by Quick Rhino

Does the reflective workaround advertise successfully on a Nexus 5?

Comment #16

Posted on Oct 28, 2014 by Happy Panda

Not for me

Comment #17

Posted on Oct 28, 2014 by Happy Horse

The reflection solution is useless, because even if it gets a pointer to an advertiser object, calling startAdvertising() on that will again call isMultipleAdvertisementSupported() internally. Unless someone also hacks out some reflection from the remaining of that function (after this check) we can only wait for a native bluetooth library fix (it's the native service that returns false for isMultipleAdvertisementSupported()).

Comment #18

Posted on Oct 28, 2014 by Swift Panda

Comment deleted

Comment #19

Posted on Oct 28, 2014 by Swift Kangaroo

Does this mean Android L will not be supporting peripheral BLE mode in the Nexus 5/7/4... Any Googlers care to elaborate on this topic? This has a huge impact on product developers that were depending on it.

Comment #20

Posted on Oct 30, 2014 by Happy Wombat

in the Nexus 6, can Android 5.0 support peripheral BLE mode ?

Comment #21

Posted on Oct 30, 2014 by Quick Rhino

I also reproduced this problem in Nexus5 under the version LPX13D of android 5.0.

Comment #22

Posted on Oct 31, 2014 by Happy Bird

If this issue will not be resolved, i have to buy nexus 6.

Comment #23

Posted on Oct 31, 2014 by Swift Kangaroo

Will the Nexus 6 support BLE advertising?

Comment #24

Posted on Nov 4, 2014 by Grumpy Rhino

This commit indicates it disables Bluetooth for the Nexus 5: https://android.googlesource.com/device/lge/hammerhead/+/8ab3b68

I think they're still posting code so we'll see what happens when the final build is released.

Comment #25

Posted on Nov 9, 2014 by Happy Bird

What a pity, nexus 5 is no longer support LE peripheral mode.

Comment #26

Posted on Nov 12, 2014 by Swift Giraffe

I was also able to reproduce this issue on Nexus 5 build version LPX13D. I am really hoping Nexus 5 will support BLE Advertising.

Comment #27

Posted on Nov 12, 2014 by Happy Elephant

Could someone give a feedback on Build LRX21O for the Nexus 5: https://developers.google.com/android/nexus/images#hammerheadlrx21o

Comment #28

Posted on Nov 12, 2014 by Happy Ox

The LRX21O build is returning false for isMultipleAdvertisementSupported(). The problem is not fixed.

Comment #29

Posted on Nov 12, 2014 by Quick Rhino

Does anybody have a Nexus 6 or a Nexus 9 to test those builds?

Comment #30

Posted on Nov 12, 2014 by Quick Lion

Nexus 9 works fine. Seems to be isolated to 5 and 7. Nexus 4 I haven't tested.

Comment #31

Posted on Nov 12, 2014 by Happy Horse

So, question for Google: every time a new API is added and the hardware supports it, I have to buy a new phone? Nexus 7 (2012) supports BLE but the API says it doesn't. Nexus 5 (2013) supports BLE peripheral, but the API says it doesn't. This feature was requested for almost an year so existing hardware can be able to transmit as iBeacons or even more recently as a Google's own WebBeacon. However requiring to buy either a new Nexus 6 or Nexus 9 seems just stupid. Every single app idea or platform that was derived from waiting for this feature to work on EXISTING phones, not 2015 phones, is now DEAD. Making the first developer preview actually support thea feature, and then just killing it without any sort of explanation whatsoever, says a lot about a company's seriousitu towards the people that help it go forward. And that is us, the developers.

Thanks, Google, for killing our ideas.

Comment #32

Posted on Nov 12, 2014 by Happy Panda

And wasting our time, maybe?

Comment #33

Posted on Nov 12, 2014 by Grumpy Horse

I'm not convinced they're leaving it out entirely for these phones - hopefully they're still working it out. It worked on the first build for the N5, and it's not like Google to block a feature just because.

Comment #34

Posted on Nov 13, 2014 by Quick Rhino

Comment deleted

Comment #35

Posted on Nov 13, 2014 by Quick Rhino

Advertise not working on my Nexus 5 running LRX21O. isMultipleAdvertisementSupported returns false, getBluetoothLeAdvertiser returns null. Shame...this is the feature I really wanted!

Comment #36

Posted on Nov 13, 2014 by Helpful Rabbit

same with nexus 7 (2013) running LRX21P: isMultipleAdvertisementSupported returns false, getBluetoothLeAdvertiser returns null. maybe in the next update?

Comment #37

Posted on Nov 13, 2014 by Quick Bird

Please enable BLE Peripheral mode Google! We have many cool use cases in waiting

Comment #38

Posted on Nov 13, 2014 by Helpful Camel

Comment deleted

Comment #39

Posted on Nov 13, 2014 by Helpful Camel

I've checked AOSP source code, and it seems like driver or BT stack on Nexus5 doesn't support peripheral mode. The function named BTM_BleGetVendorCapabilities() says that Nexus5 supports zero (0) advertise instance.

Comment #40

Posted on Nov 13, 2014 by Helpful Camel

Correct. The problem is, HW features are no updated, but the other functions still reference it. For this problem "mNumOfAdvertisementInstancesSupported" is never initialized, so it's value remains at 0.

For some reason, "/packages/apps/Bluetooth/src/com/android/bluetooth/btservice/JniCallbacks.java" is not working, but others rely on it.

Comment #41

Posted on Nov 13, 2014 by Grumpy Horse

Oh how wonderful and I've just baugth a N5 for this a couple of days ago... Anyone knows if the Moto G is working properly on this issue?

Comment #42

Posted on Nov 13, 2014 by Grumpy Rabbit

So, can we move this to the Android (non-preview)??? This is still a very serious issue.

Comment #43

Posted on Nov 13, 2014 by Swift Lion

I've built a flashable package of android-5.0.0_r3 for Nexus 5 with BLE peripheral enabled. It's just a simple revert of this infamous commit: https://android.googlesource.com/device/lge/hammerhead/+/8ab3b68

With these images my test application seems to perform BLE peripheral functions properly.

Download: https://s3.amazonaws.com/dbro/n5_ble_peripheral/hammerhead-lrx21o-bleperipheral.zip

SHA-1 : 2b6de1333211576a522f5ca1bf335192b7160e9f

Comment #44

Posted on Nov 13, 2014 by Happy Horse

Can we flash only some file on a rooted device to enable this, instead of a full system image? Like just replacing the bluetooth driver module or something?

Oh, and is Mr. Prerepa Viswanadham going to just leave it to "Disable peripheral mode in N5"? Like he was just having a bad day and decided to screw over with the AOSP and watch us scream?

Comment #45

Posted on Nov 14, 2014 by Swift Lion

44 : I suppose you could comment out all but the below line in ./flash-all.sh:

# ./flash-all.sh
fastboot flash system ./image-hammerhead-lrx21o-bleperipheral/system.img

Remember you must invoke 'adb reboot bootloader' and wait for your device's bootloader interface to appear on screen before running flash-all.sh.

I have no idea if this would work, and would expect it not to work if you're currently running anything other than the lrx21o factory image.

Comment #46

Posted on Nov 14, 2014 by Grumpy Rhino

43: I probably shouldn't flash some random dude's ROM on my phone but yep, advertising works. Thanks!

And I wouldn't be too hard on the developers. A feature has to be production ready to be released, and apparently they couldn't fix a bug (apparently bug 16545864, whatever that is) in time for release, so they just disabled advertisement. I'm curious what that bug is.

45: I tried flashing just the system and I get a Play store error, so I just went whole hog and flashed the whole thing.

This is my daily driver so now I gotta get recovery and gapps on there.

Comment #47

Posted on Nov 14, 2014 by Helpful Rhino

43: I also confirmed that this system image successfully enables and provides BLE advertisement and BLE GATT functionalities in N5. Many thanks to you!

Now we just wait for official developers to revert the commit in question and release an official N5 factory image!

Comment #48

Posted on Nov 14, 2014 by Happy Rabbit

43 this build only advertise once per second no matter how the mode is set:

advSetBuilder.setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_LOW_POWER) // This used to be 1 sec in Android 'Looser' advSetBuilder.setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_BALANCED) // This used to be aproximately 1/4 sec in Android 'Looser' advSetBuilder.setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_LOW_LATENCY) // This used to be aproximately 1/10 sec in Android 'Looser'

(although in one preview LOW_LATENCY and LOW_POWER were swapped)

Google: ALL Android 5 with BT should have BLE Peripheral mode or it's utterly useless compared to KitKat. Even Galaxy S2 has a BLE capable chipset (same as ip4S?) If not then please bring back BlueZ.

Comment #49

Posted on Nov 14, 2014 by Massive Lion

could you please share files (and signature) to upload them on rooted device, I suppose it's just couple of files. Because it's overkill to flash whole firmware.

Comment #50

Posted on Nov 14, 2014 by Grumpy Horse

43 thanks for the effort!

I've also flashed my N5 with this image for testing. But i could not get this to work with following code:

http://pastebin.com/2JMMBAHz Do i miss something?

47 would you mind to share your working ble ad code with us?

Comment #51

Posted on Nov 14, 2014 by Happy Rabbit

This code works for me.

(But add a call to stopAdvertisements(); when exiting or pressing a button)

package com.gilvader.bleadvertiser;

import java.util.ArrayList; import java.util.List;

import android.app.Activity; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothManager; import android.bluetooth.le.*; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.os.Bundle; import android.os.ParcelUuid; import android.util.Log; import android.widget.Button;

/** * Main activity, with button to toggle phone calls detection on and off. */ public class MainActivity extends Activity {

private BluetoothAdapter mBluetoothAdapter;
private BluetoothManager bluetoothManager;
private android.bluetooth.le.BluetoothLeAdvertiser mLeAdvertiser;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    enableBluetooth(true);

    bluetoothManager = (BluetoothManager) this.getSystemService(Context.BLUETOOTH_SERVICE);
    mBluetoothAdapter = bluetoothManager.getAdapter();
    if (bluetoothManager == null) Log.e("onCreate", "bluetoothManager service is NULL!!!!");
    if (mBluetoothAdapter == null) Log.e("onCreate", "mBluetoothAdapter is NULL!!!!!");

    if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {
        Log.d("onCreate", "BLE feature is NOT available");
    } else {
        Log.d("onCreate", "BLE feature is available");
        startAdvertising();
    }
}

public static boolean isIntentAvailable(Context context, String action) {
    final PackageManager packageManager = context.getPackageManager();
    final Intent intent = new Intent(action);
    List<ResolveInfo> list =
    packageManager.queryIntentActivities(intent,
    PackageManager.MATCH_DEFAULT_ONLY);
    return list.size() > 0;
}

public static void enableBluetooth(boolean enable){
      BluetoothAdapter bluetoothAdapter=BluetoothAdapter.getDefaultAdapter();
      if (bluetoothAdapter == null) {
        Log.e("enableBluetooth", "Not switching bluetooth since its not present");
        return;
      }
      if (bluetoothAdapter.isEnabled() == enable) {
        Log.e("enableBluetooth", "BT is enabled");
        if (bluetoothAdapter.isMultipleAdvertisementSupported()) {
            Log.d("Capability", "Multiple Advertisements supported");
        } else {
            Log.d("Capability", "Multiple Advertisements NOT supported!");
        }
        return;
      }
      if (enable) {
        bluetoothAdapter.enable();
      }
     else {
        bluetoothAdapter.disable();
      }
      Log.i("enableBluetooth", "Switched bluetooth to " + enable);
    }

private void startAdvertising() {
    ParcelUuid mAdvParcelUUID = ParcelUuid.fromString("0000FEFF-0000-1000-8000-00805F9B34FB");

    mLeAdvertiser = (BluetoothLeAdvertiser)((BluetoothAdapter)((BluetoothManager)this.getSystemService(Context.BLUETOOTH_SERVICE)).getAdapter()).getBluetoothLeAdvertiser();
    if (mLeAdvertiser == null)
    {
        Log.e("startAdvertising", "didn't get a bluetooth le advertiser");
        return;
    }

    AdvertiseSettings.Builder mLeAdvSettingsBuilder =
            new AdvertiseSettings.Builder().setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_HIGH);
    mLeAdvSettingsBuilder.setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_LOW_POWER);
    mLeAdvSettingsBuilder.setConnectable(false);
    AdvertiseData.Builder mLeAdvDataBuilder = new AdvertiseData.Builder();

    List<ParcelUuid> myUUIDs = new ArrayList<ParcelUuid>();
    myUUIDs.add(ParcelUuid.fromString("0000FE00-0000-1000-8000-00805F9B34FB"));
    byte mServiceData[] = { (byte)0xff, (byte)0xfe, (byte)0x00, (byte)0x01, (byte)0x02, (byte)0x03, (byte)0x04 };
    mLeAdvDataBuilder.addServiceData(mAdvParcelUUID, mServiceData);

    AdvertiseSettings.Builder advSetBuilder = new AdvertiseSettings.Builder();
    advSetBuilder.setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_LOW_LATENCY);
    advSetBuilder.setConnectable(false);
    advSetBuilder.setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_MEDIUM);
    advSetBuilder.setTimeout(10000);
    Log.d("advBuild", "settings:" + advSetBuilder.build());

    AdvertiseData.Builder advDataBuilder = new AdvertiseData.Builder();
    advDataBuilder.setIncludeDeviceName(false);
    advDataBuilder.setIncludeTxPowerLevel(true);
    advDataBuilder.addServiceData(mAdvParcelUUID, mServiceData);
    mLeAdvertiser.startAdvertising(mLeAdvSettingsBuilder.build(), mLeAdvDataBuilder.build(), mLeAdvCallback);
}

/**
 * Stop Advertisements
 */
public void stopAdvertisements() {
    if (mLeAdvertiser != null) {
        mLeAdvertiser.stopAdvertising(mLeAdvCallback);
    }
}

private final AdvertiseCallback mLeAdvCallback = new AdvertiseCallback() {
    public void onStartSuccess (AdvertiseSettings settingsInEffect) {
        Log.d("AdvertiseCallback", "onStartSuccess:" + settingsInEffect);
    }

    public void onStartFailure(int errorCode) {
        String description = "";
        if (errorCode == AdvertiseCallback.ADVERTISE_FAILED_FEATURE_UNSUPPORTED) description = "ADVERTISE_FAILED_FEATURE_UNSUPPORTED";
        else if (errorCode == AdvertiseCallback.ADVERTISE_FAILED_TOO_MANY_ADVERTISERS) description = "ADVERTISE_FAILED_TOO_MANY_ADVERTISERS";
        else if (errorCode == AdvertiseCallback.ADVERTISE_FAILED_ALREADY_STARTED) description = "ADVERTISE_FAILED_ALREADY_STARTED";
        else if (errorCode == AdvertiseCallback.ADVERTISE_FAILED_DATA_TOO_LARGE) description = "ADVERTISE_FAILED_DATA_TOO_LARGE";
        else if (errorCode == AdvertiseCallback.ADVERTISE_FAILED_INTERNAL_ERROR) description = "ADVERTISE_FAILED_INTERNAL_ERROR";
        else description = "unknown";
        Log.e("AdvertiseCB", "onFailure error:" + errorCode + " " + description);
    }
};

}

Comment #52

Posted on Nov 15, 2014 by Helpful Wombat

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.

Comment #53

Posted on Nov 15, 2014 by Grumpy Rhino

Well alrighty then! Thanks for closing this out.

Comment #54

Posted on Nov 15, 2014 by Swift Lion

52 : Just to be clear it appears the Nexus Player is shipping with BLE peripheral mode support as well. Is this correct?

Pardon me if I'm mistaken, but the Broadcom chipset (BCM4339) in the Nexus 5 does support BLE peripheral mode AFAIK. I'd be most appreciative if you could share any more specific information as to why this decision was made. Understanding your process would greatly help developers better asses the platform landscape.

Appreciate all your work!

Comment #55

Posted on Nov 15, 2014 by Swift Panda

Doesn't make sense that there is a hardware chipset dependency issue since nexus 5 worked fine in peripheral mode using first release of L preview. Please explain.

Comment #56

Posted on Nov 17, 2014 by Happy Dog

52 : we were working on peripheral mode for the last one month with Android L preview Image we were success to advertise the packets. I cannot understand how my device Nexus 5 conflicting chipset dependency between Android 5.0 and L preview. Eagerly waiting for your reply.

Appreciating all your work!!!

Comment #57

Posted on Nov 18, 2014 by Grumpy Ox

Is anybody experiencing stopAdvertising() not working on Nexus 9? startAdvertising() works as expected, but the device stops advertising only when the process dies.

Comment #58

Posted on Nov 18, 2014 by Happy Wombat

57: Have you tried disable/enable Bluetooth adapter instead of stopAdvertising()?

Comment #59

Posted on Nov 18, 2014 by Grumpy Ox

I have not tried since this would stop any Bluetooth existing service (e.g., audio) and should be avoided unless explicitly required by the user.

Comment #60

Posted on Nov 19, 2014 by Quick Rhino

I can confirm that you can start and stop advertising successfully on the Nexus 9. It is critical to pass the same callback object instance when stopping advertising. If you have questions, please open a question on Stackoverflow.com as this ticket about the Nexus 5 is not the right forum for troubleshooting the Nexus 9. See reference code here: https://github.com/AltBeacon/android-beacon-library/blob/android-l-apis/src/main/java/org/altbeacon/beacon/BeaconTransmitter.java#L179

Comment #61

Posted on Nov 19, 2014 by Happy Rabbit

Can also confirm that it works to stop on Nexus 9 as well on Nexus 5 with the AOSP build from #43. mLeAdvertiser.stopAdvertising(mLeAdvCallback); The important thing is to pass the right Callback which was used when starting advertising.

Comment #62

Posted on Nov 19, 2014 by Grumpy Ox

@david: you're right, sorry for the off topic

@henrik: tank you for the listener suggestion

On Wed, Nov 19, 2014 at 8:16 AM, wrote:

Comment #63

Posted on Nov 20, 2014 by Helpful Monkey

Also having this error (#1) on a Nexus 5 - LRX210 build. Would love more details about #52

Comment #64

Posted on Nov 25, 2014 by Happy Rhino

I believe that this is caused by HW. Nexus 6 / 9 both have Bluetooth 4.1 chipset And the one of the major change in Bluetooth 4.1 is that to allow both central and peripheral role co-exist in the same time in the same chip.

I think the reason why Google waive the support of peripheral mode of Nexus 4/5/7 is to avoid the scenario that both central and peripheral role co-exist in BT 4.0 chip which may cause unpredictable bug and the framework could not handle it well now?

Comment #65

Posted on Nov 25, 2014 by Grumpy Wombat

@nevil: Thanks for you info. However, it is can be avoid by only enable one role at the same time.

I believe there will be better solution than showdown the peripheral mode on Nexus devices (4/5/7).

Comment #66

Posted on Nov 25, 2014 by Helpful Giraffe

@george - I don't think limiting to one role at a time is an OK solution. For example Android Wear requires your phone to be in central mode at all times. An app shouldn't be able to come along and disable your watch (or any other bluetooth communications for that matter).

If this is indeed the case why Google disabled peripheral mode in the final version, then it is a good reason. However I'm quite annoyed that they wouldn't communicate this to their developer community.

Comment #67

Posted on Nov 25, 2014 by Helpful Rhino

64 Yeah, I also speculated that difference of BT specs between v4.0 and v4.1 (especially the big changes in the network topology) might be the cause of N5 support drop, and reported it back to my superior.

But it's simply a speculation, and it's not fit to be brought up to a business meeting to explain "This is why N5 was dropped for BLE peripheral mode". I need an official reason why N5 was dropped.

Comment #68

Posted on Dec 17, 2014 by Happy Kangaroo

64, #67

In bluedroid source code, we can find this macro: HCI_LE_STATES_INIT_MASTER_SLAVE_SUPPORTED(x), which is used to detect if both master role and slave role can coexist or not.

However, I cannot find any other references from bluedroid repository. It seems the HCI definition is already there, but none is using it; also I cannot find the code on checking if the controller could support this feature.

65 and #66, Limiting to one role at a time is not necessary because even BT v4.0 core spec allows multiple state machines in link layer. the HCI_LE_STATES_INIT_MASTER_SLAVE_SUPPORTED(x) macro is one suitable checkpoint to enable the Nexus devices to support variable features.

Of course, I think the BLE advertise mode should be supported on earlier Nexus devices, and I don't understand why Google refuses to enable it. Google might think the Android developers are so many that he can drive us away to the iOS platform, ... joke..

Comment #69

Posted on Jan 7, 2015 by Happy Bear

2015 CES exhibition has a new BT 4.0 use, and there is a house/door/car door lock manufacturer called Unikey, which allows you to unlock your house with your phone and very seamlessly. Called Unikey with an app called Kevo, you walk up to the door, tap the lock and it initiates with the phone over 4.0 BLE and unlocks the door. It can sense what side of the door you are on as well. There will likely be meetings and plans to put this door lock tech into vehicles as well. unikey.com

Anyways, since the iPhone 4S, Apple has supported BT 4.0 BLE. There is a Kevo app for the iPhone right now. Nothing for my Nexus 5.

Comment #70

Posted on Jan 8, 2015 by Happy Cat

Comment deleted

Comment #71

Posted on Jan 8, 2015 by Quick Wombat

What about wearable devices? Is there any wearable device that supports BLE peripheral mode?

Comment #72

Posted on Jan 9, 2015 by Swift Ox

Hi there, that's pretty annoying indeed, what I'm reading here. Does someone know if such problem is observed on Samsung Galaxy S5 for example? Definitely it doesn't work on LG G3. The question here is ( as this is not stated ), is it a problem because of BT 4.0 chips and 4.1 would solve the problem? Has anyone tried different devices?

Comment #73

Posted on Jan 9, 2015 by Quick Wombat

I have tried it on a Samsung Galaxy Gear Live and it doesn't work.

Comment #74

Posted on Jan 15, 2015 by Grumpy Ox

Is there a way to make the peripheral app take more than one connection simultanously ?

Comment #75

Posted on Jan 20, 2015 by Happy Giraffe

Hi, i tried getting an instance of BluetoothLeAdvertiser with Samsung Galaxy S3 (Custom Rom) and HTC one m8 (GPE) - both running Android 5.0.1 - without success. Actually im very frustrated because i need this function and can not afford a Nexus 9! I think there is a lack of information. Is there any list of devices running Android 5.0 for which BLE advertising / transmitting works?

Comment #76

Posted on Jan 20, 2015 by Happy Kangaroo

Check the device hw spec, and see if it supports BT4.1 or not. right now, seems only nexus 6 and 9 are.

Comment #77

Posted on Jan 20, 2015 by Swift Lion

I've had success working with the BLE APIs using the $99 Nexus Player.

On Tue, Jan 20, 2015, 5:04 AM null wrote:

Comment #78

Posted on Jan 24, 2015 by Massive Monkey

Can anyone tell me which mobile devices are readily feasible to work with Physical web beacons as a Central and Peripheral Mode without any updation in ready-made image of mobile. 1. Is it Nexus-6 and Nexus-9 directly supporting as a Central and Peripheral Mode in latest phones. 2. Or either I need to do some updations in the image of N6 and N9 to work as Central and Peripheral Mode.

Comment #79

Posted on Jan 25, 2015 by Happy Giraffe

From the presentation of Dave Smith (NewCircle Inc.) at the AnDevCon in San Francisco:

"Not all devices will support this new feature (peripheral mode) with the update (to lollipop), as Google has defined this as a HAL-enabled feature, which means manufacturer's must add a driver for it at the integration level. Developers should first check BluetoothAdapter.isMultipleAdvertisementSupported() on the device."

Source: https://thenewcircle.com/s/post/1697/android_lollipop_bluetooth_andevcon?utm_source=Android+Weekly&utm_campaign=d5e640f30e-Android_Weekly_137&utm_medium=email&utm_term=0_4eb677ad19-d5e640f30e-337824497

Comment #80

Posted on Jan 25, 2015 by Quick Rhino

Here is a list of devices that are known to support/not support advertising:

http://altbeacon.github.io/android-beacon-library/beacon-transmitter.html

This list is updated periodically from reports of folks who have tried the beacon transmitter feature in Locate: https://play.google.com/store/apps/details?id=com.radiusnetworks.locate

Comment #81

Posted on Jan 25, 2015 by Massive Monkey

Thanks for your valuable inputs !!!

Comment #82

Posted on Jan 28, 2015 by Happy Ox

Any news about Xiaomi Mi Note?

Comment #83

Posted on Feb 2, 2015 by Happy Horse

I went ahead and recompiled the Android 5.0.1 hammerhead tree from AOSP, adding back the removed line that enabled BLE advertising on Nexus 5. Even though the full build failed after 8 hours due to WebKit not compiling for some reason, I ended up with the two Bluetooth libraries which I suspected to be the only ones required:

/system/lib/hw/bluetooth.default.so /system/lib/libbluetooth_jni.so

I flashed these, and only these, on my Nexus 5 using the custom TWRP recovery, and then setting back the original files owner and permissions through an adb shell, and guess what? I made my Nexus 5 able to advertise again, just like it did in the first L developer preview! However, I think I now know why it was disabled. It looks like the downside is that while you have advertising running, the phone can not scan for BLE in the same time. So it's one or the other at anytime. But I am very pleased that I can now make my phone to act as virtually any type of beacon that I want, instead of having to buy a Nexus 6 just for this :)

Now, let's see what we can fit in those 31 bytes...

Comment #84

Posted on Feb 3, 2015 by Grumpy Lion

Comment deleted

Comment #85

Posted on Feb 3, 2015 by Grumpy Lion

BluetoothLE peripheral mode does not work on the Galaxy S5 in Lollipop.

getBluetoothLeAdvertiser() returns null

Comment #86

Posted on Feb 3, 2015 by Happy Wombat

Actually. S5 with Lollipop works fine here. We can become a beacon. Using German S5 phone with the update provided by Samsung.

Comment #87

Posted on Feb 3, 2015 by Happy Giraffe

Same here. I did some tests last week and i can confirm that peripheral mode with Samsung Galaxy S5 (original samsung stock - german version too) works fine.

Comment #88

Posted on Feb 9, 2015 by Happy Bird

Hello,

Advertising as a beacon is one thing and doing connectable-advertising is another. Connectable advertising would allow other devices which are central to connect to the Android devices.

Do we have an info on whether the nexus devices would have connectable advertising feature as well? or any other android devices that would allow connections?

Comment #89

Posted on Feb 12, 2015 by Happy Ox

Advertising mode not working with MotoX 2014 Lollipop build LXE22.46-11 and even Nexus 5 Lollipop. Using code above in the thread, bluetoothAdapter.isMultipleAdvertisementSupported() returns false.

Any workarounds??

Comment #90

Posted on Feb 13, 2015 by Swift Horse

I have been working on this issue too, and am able to simulate the ble advertisement by using a remote computation. While we await android to fix up their act with ble - you can contact me if you like to to piggyback on my solution.

One additional and related thing I need help with is - the api has many versions, and I have code which works with the different api versions abstracted away using a factory pattern. I was wondering if there is a way to instrument ant to create several apks - one each for a range of sdk versions?

Thanks! https://twitter.com/vpathak

Comment #91

Posted on Feb 13, 2015 by Quick Rhino

Hey numede, any way you can send me the files /system/lib/hw/bluetooth.default.so /system/lib/libbluetooth_jni.so ? Thanks so much!

Comment #92

Posted on Feb 23, 2015 by Massive Rhino

Het numede and julian.p, is there any way I can have those files too? I'd really appreciate it. Thanks! :)

Comment #93

Posted on Mar 4, 2015 by Helpful Hippo

Hey numede, julian.p and adrianod. I need the files too. Could you please send me?

Comment #94

Posted on Mar 4, 2015 by Helpful Elephant

Guys, I'd love them either. Maybe you can upload them somewhere.

Comment #95

Posted on Mar 4, 2015 by Grumpy Rhino

I just picked up a Moto E 4G LTE (that's the 2nd gen) and verified that BLE advertising works, Android 5.0.2.

Comment #96

Posted on Mar 8, 2015 by Grumpy Rhino

Following up on #83 -

For my Nexus 5, I followed the instructions in this XDA thread and can advertise and be connected to: http://forum.xda-developers.com/android/apps-games/how-to-kevo-to-nexus-5-running-loillipop-t3041092

Here are links to the 2 files: http://forum.xda-developers.com/devdb/project/dl/?id=11281 http://forum.xda-developers.com/devdb/project/dl/?id=11282

Good luck!

Comment #97

Posted on Mar 23, 2015 by Happy Ox

@Google Team: Are there any updates regarding fixing this bug for on Nexus 5 without the need to change the source code?.

Please provide more details about the status of this bug

Thanks

Comment #98

Posted on Apr 14, 2015 by Happy Horse

Hey guys, I just tested the MOTO G2 which shipped with 5.0.2, the advertising still no working, the worse, the receiving adv function seems also broken, once you scanned a adv, the onScanResult(int, ScanResult) will never report this adv anymore. BTW, I'll report another case of OnePlus One, CM12 ROM, still no working for both, the receiving adv callback is extremely slow (or say dead).

Android really disappointed me!

Comment #99

Posted on Apr 20, 2015 by Happy Horse

Hello, guys. I have the same issue with nexus 4 as my testing device. Following up on #96, those 2 files apparently can only be used on nexus 5 device, although the download information says that it's applicable to all devices. Do you guys know where can i get the files for nexus 4? Or maybe a way to build it myself without resorting to building the entire android system?

Thank you.

Comment #100

Posted on Apr 24, 2015 by Happy Kangaroo

80 Thanks for your information.

Comment #101

Posted on May 31, 2015 by Happy Lion

99 That is a different device, please file a different bug.

Comment #102

Posted on Jun 14, 2015 by Helpful Monkey

Comment deleted

Comment #103

Posted on Jul 16, 2015 by Quick Bird

Comment deleted

Comment #104

Posted on Jul 28, 2015 by Happy Horse

If anyone is still interested here is the the recompiled bluetooth.default.so file for Nexus 5's latest Android 5.1.1, since I discovered it's the only file required to enable BLE peripheral mode. However this is only useful for testing, since central and peripheral modes seem to not work simultaneously on Nexus 5 (probably the reason for being disabled). * WARNING * This is ONLY for Nexus 5 with Android 5.1.1 (LMY-48B) https://drive.google.com/folderview?id=0B85G4PM1NSJEfk1PeWNNNmNDNFRjQUsyak1IUjhPY0RYMUpYSWZMNjRrSkVDMlh5ZV91Mjg&usp=sharing

After you overwrite the file and set back the correct owner/permissions you can restart the phone and check if BLE advertisement works. Some apps that will do this: https://play.google.com/store/apps/details?id=com.uriio (up to 4 virtual BLE beacons) https://play.google.com/store/apps/details?id=com.radiusnetworks.locate

Comment #105

Posted on Aug 5, 2015 by Grumpy Bear

Last solution worked for me. Big thanks man.

Comment #106

Posted on Aug 10, 2015 by Happy Rhino

Comment deleted

Comment #107

Posted on Aug 10, 2015 by Happy Rhino

Please up vote a request to update the documentation. It's annoying Google still has issues with good developer docs, let alone misleading ones. https://code.google.com/p/android/issues/detail?id=182365&thanks=182365&ts=1439225370

Comment #108

Posted on Aug 17, 2015 by Helpful Hippo

Could somebody please publish a manual how to recompile bluetooth.default.so for other devices to enable BLE peripheral mode? I am interested in Sony Z3 Compact. Thanks in advance.

Comment #109

Posted on Aug 23, 2015 by Happy Lion

Hi everyone, great responses and info here. I am trying to make my device as a BLE sensor that advertises himself(peripheral mode).

Changed the needed fix in the file, compiled and burned to my android device. Still getting the: false from isMultipleAdvertisementSupported()

Any additional changes needed?

Status: WontFix

Labels:
Type-Defect BLE bluetooth 18048468