WebBluetoothCG / ble-test-peripheral-android

A BLE Peripheral Simulator App
https://play.google.com/store/apps/details?id=io.github.webbluetoothcg.bletestperipheral
Apache License 2.0
389 stars 129 forks source link

Misuse of mBluetoothAdapter.isMultipleAdvertisementSupported() #67

Open farmazon3000 opened 8 years ago

farmazon3000 commented 8 years ago

In https://github.com/WebBluetoothCG/ble-test-peripheral-android/blob/master/app/src/main/java/io/github/webbluetoothcg/bletestperipheral/Peripheral.java there is:

if (!mBluetoothAdapter.isMultipleAdvertisementSupported()) {
  Toast.makeText(this, R.string.bluetoothAdvertisingNotSupported, Toast.LENGTH_LONG).show();
  Log.e(TAG, "Advertising not supported");
}

And this is misuse of isMultipleAdvertisementSupported, check this https://github.com/AltBeacon/android-beacon-library/issues/266:

It is important to understand that just because isMultipleAdvertisementSupported() returns false does not mean that the device cannot advertise at all -- it means either that it cannot advertise at all OR that it can only transmit one advertisement at a time. Many Motorola devices (Moto X, Moto G) behave this way. The way you are supposed to check if advertising is supported at all is to get an instance of BluetoothLEAdvertiser. If the call to get an instance fails, then it is not supported.

g-ortuno commented 8 years ago

I'm wary of adding code to support one specific vendor. The Android documentation explicitly states that isMultipleAdvertisementSupported() should be used to check for advertising support.

farmazon3000 commented 8 years ago

The Android documentation explicitly states that isMultipleAdvertisementSupported() should be used to check for advertising support

Does it? No it does not.

What it does says is https://developer.android.com/reference/android/bluetooth/BluetoothAdapter.html#isMultipleAdvertisementSupported() Return true if the multi advertisement is supported by the chipset

g-ortuno commented 8 years ago

Should have included a citation in my original response. It is under getBluetoothLeAdvertiser:

Use isMultipleAdvertisementSupported() to check whether LE Advertising is supported on this device before calling this method.

phstudy commented 7 years ago

@g-ortuno I think @farmazon3000 is right. Just checking the response of getBluetoothLeAdvertiser() is null or not, it can determine whether the device supports LE advertising. The comment of getBluetoothLeAdvertiser() is not accurate, you can check the source code of the method. I think the correct comment should be Use isMultipleAdvertisementSupported() to check whether LE *multiple* Advertising is supported on this device before calling this method.

BluetoothAdapter.java in ASOP master

BluetoothAdapter.java in ASOP 7.1_r9

scheib commented 7 years ago

Ok. For BLE Test Peripheral, is this check causing you to not be able to use the tool?

phstudy commented 7 years ago

@scheib Yes. If I can not pass the checking, BLE Test Peripheral will show LE Advertising is not available. Please pair with a device to be discoverable..

AlejandroHCruz commented 6 years ago

Hi, any conclusion on this subject?

nowavewater commented 6 years ago

Actually, it's not required to support multiple advertisement for Android device to act as peripheral role. Check the official example.

I have a device which returns false with isMultipleAdvertisementSupported(), it works just with the official example.

g-ortuno commented 6 years ago

I'm convinced. Feel free to send a CL to change this.

abdoutech93 commented 4 years ago

Actually, it's not required to support multiple advertisement for Android device to act as peripheral role. Check the official example.

I have a device which returns false with isMultipleAdvertisementSupported(), it works just with the official example.

THANKS A LOT, you made my day