How do I test connecting to a BLE peripheral in Linux?

Answer

To activate BT, list controller information and scan for BT/BLE devices:

 # bluetoothctl Agent registered [bluetooth]# power on Changing power on succeeded [bluetooth]# list Controller C0:EE:40:50:00:00 summit [default] [bluetooth]# scan on

To connect to a device acting as a peripheral:

 [bluetooth]# scan on Discovery started [CHG] Controller C0:EE:40:50:00:00 Discovering: yes [NEW] Device 4C:90:DE:92:00:00 Pixel XL [CHG] Device 4C:90:DE:92:00:00 RSSI: -68 [CHG] Device 4C:90:DE:92:00:00 RSSI: -58 ... [NEW] Device 4C:90:DE:92:00:00 Pixel XL [bluetooth]# scan off Discovery stopped [CHG] Controller C0:EE:40:50:00:00 Discovering: no [CHG] Device 4C:90:DE:92:00:00 TxPower is nil [CHG] Device 4C:90:DE:92:00:00 RSSI is nil [bluetooth]# pair 4C:90:DE:92:00:00 Attempting to pair with 4C:90:DE:92:00:00 [CHG] Device 4C:90:DE:92:00:00 Connected: yes [NEW] Primary Service         /org/bluez/hci0/dev_4C_90_DE_92_00_00/service0001         00001801-0000-1000-8000-00805f9b34fb         Generic Attribute Profile [NEW] Characteristic         /org/bluez/hci0/dev_4C_90_DE_92_00_00/service0001/char0002         00002a05-0000-1000-8000-00805f9b34fb ... [NEW] Characteristic         /org/bluez/hci0/dev_4C_90_DE_92_00_00/service003a/char003b         00002a8a-0000-1000-8000-00805f9b34fb         First Name [NEW] Characteristic         /org/bluez/hci0/dev_4C_90_DE_92_00_00/service003a/char003d         00002a90-0000-1000-8000-00805f9b34fb         Last Name [NEW] Characteristic         /org/bluez/hci0/dev_4C_90_DE_92_00_00/service003a/char003f         00002a8c-0000-1000-8000-00805f9b34fb         Gender ... [CHG] Device 4C:90:DE:92:00:00 UUIDs: 0000181c-0000-1000-8000-00805f9b34fb [CHG] Device 4C:90:DE:92:00:00 UUIDs: 0000aaa0-0000-1000-8000-aabbccddeeff [CHG] Device 4C:90:DE:92:00:00 ServicesResolved: yes Request confirmation [agent] Confirm passkey 210165 (yes/no): yes [Pixel XL]# trust 4C:90:DE:92:00:00 [CHG] Device 4C:90:DE:92:00:00 Trusted: yes Changing 4C:90:DE:92:00:00 trust succeeded

The peripheral device is a Google Pixel XL running Android 10 using Nordic’s nRF app with an advertising profile setup with dummy information. If you pair with a device that does not have some kind of service running, it will disconnect, as BT/BLE has nothing to do.