I want to connect my phone using BLE to a Pi 3A+. For testing I have set up a Bluetooth server using this code. I have tried connecting with nRF Connect on both a Motorola Moto e5 (Android 8.0) and a Huawei P20 Lite (Android 9.1). On both devices, it fails to connect on most attempts, although finding the Pi has never been an issue. I have also tried a 3B. It works somewhat more often, but connecting still often fails.
Debug log from nRF:
nRF Connect, 2020-11-06 Thermometer (B8:27:EB:7C:F0:0F) V 11:24:52.201 Connecting to B8:27:EB:7C:F0:0F... D 11:24:52.201 gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, preferred PHY = LE 1M) D 11:25:02.527 [Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED D 11:25:02.550 [Callback] Connection state changed with status: 0 and new state: CONNECTED (2) I 11:25:02.552 Connected to B8:27:EB:7C:F0:0F V 11:25:02.577 Discovering services... D 11:25:02.577 gatt.discoverServices() W 11:25:07.528 Connection parameters update failed with status 8 (interval: 48.75ms, latency: 0, timeout: 5000ms) E 11:25:07.528 Error 8 (0x8): GATT INSUF AUTHORIZATION D 11:25:07.530 [Callback] Connection state changed with status: 8 and new state: DISCONNECTED (0) E 11:25:07.530 Error 8 (0x8): GATT CONN TIMEOUT I 11:25:07.531 Disconnected D 11:25:07.600 [Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED
The log on the Huawei is similar, though the GATT INSUF AUTHORIZATION error is not thrown. To me, it seems that it connects but then fails to discover the services.
On the Pi:
$ dpkg -l | grep bluez ii bluez 5.50-1.2~deb10u1+rpt2 armhf Bluetooth tools and daemons ii bluez-firmware 1.2-4+rpt6 all Firmware for Bluetooth devices