3

I try to make a Raspberry Pi 3B+ act as a BLE peripheral.

I downloaded latest version (5.50) of bluez stack here : https://git.kernel.org/pub/scm/bluetooth/bluez.git. I execute provided examples in /test/ directory.

When I run "example-advertisement" and "example-gatt-server" under root with python 2.7 or python 3.5, I can see the new BLE peripheral with Linux Mint, Win10, IOS and Android devices. However, although Linux, IOS and Win10 succeed in connecting and retrieving services and characteristics list, Android (4.4, 5.1 or 7.0) can't connect to the device.

I saw this topic : Bluetooth low energy gatt services not found on Android but I'm not using my own app for the moment. Even various BLE scanning applications we can find on Play Store don't manage to connect and retrieve service list.

Do someone have an idea ?

Thanks.

fdamien12
  • 49
  • 4

4 Answers4

1

"Android" is a broad family of devices, each with different BT hardware and drivers, and as a result with different behavior and quirks. If you own a device from a major brand, searching or asking about this specific device will bring more relevant results than just searching or asking about "Andoroid 7.0".

Having said that, there is a couple of generic things you can try:

  • Disable WiFi while doing BT. A lot of BT problems come from radio interference between the two wireless protocols, or from the buggy dual-function radios unable to share a single antenna between WiFi and BT.

  • Collect btsnoop_hci.log as described here and check it for obvious anomalies. The firs thing I would try to understand is what protocols are able to get through between the Android device and the RPi.

Dmitry Grigoryev
  • 28,277
  • 6
  • 54
  • 147
1

I have found to get reliable connection to Android phones it is best to put the controller into le only mode. This is done in the /etc/bluetooth/main.conf file. Ensure that it contains the following:

ControllerMode = le

That means from /etc/bluetooth/main.conf:

Restricts all controllers to the specified transport. Default value is "dual", i.e. both BR/EDR and LE enabled (when supported by the HW).` Possible values: "dual", "bredr", "le"

You might also be able to do this from the command line with:

sudo btmgmt power off
sudo btmgmt le on
sudo btmgmt bredr off
sudo btmgmt power on

although I haven't proved that conclusively.

ukBaz
  • 1,548
  • 1
  • 7
  • 23
0

For those who are interested in this issue, I give additional information here : https://superuser.com/questions/1453894/bluez-in-ble-peripheral-mode-android-cant-retrieve-services-list-ok-with-iph/1455666 but I give up, I didn't managed to get everything working.

Thanks.

fdamien12
  • 49
  • 4
0

It seems like you gave up on this a long time ago, but I was having the exact same issue.

Solution: I called BluetoothDevice.createBond() after connecting and before discovering.

I also have delays between all of these calls, although I'm not sure if that's required.