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
  • 39
  • 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
  • 27,928
  • 6
  • 53
  • 144
  • Thank you for your anwser. I tested with various Android devices (4 phones and a tablet) so it's not device specific. Disabling the Wi-Fi doesn't help. I will try to get the log file you're talking about. – fdamien12 Jun 27 '19 at 14:08
  • @fdamien12 Meanwhile, have you seen this question? – Dmitry Grigoryev Jun 27 '19 at 14:10
  • Yes but it's not UART related : i just tried with another single board computer (Variscite DART-6UL, https://www.variscite.com/product/system-on-module-som/cortex-a7/dart-6ul-freescale-imx-6ul/) and I get exactly the same behavior. – fdamien12 Jun 27 '19 at 14:38
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,457
  • 1
  • 6
  • 22
  • What does ControllerMode = le mean? – Ingo Jul 10 '20 at 10:08
  • 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"

    – ukBaz Jul 10 '20 at 11:04
  • 1
    Should be added to the answer ;-) – Ingo Jul 10 '20 at 16:34
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
  • 39
  • 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.