PDA

View Full Version : Detect connected state for BLE devices



SwedishWings
15th November 2017, 18:51
I'm trying to find out how to detect if a BLE device is connected in Qt. The setup is as follows;

- Linux 4.12
- Bluez 5.43
- Qt 5.9.2
- One USB BLE 4.1 adapter
- Two or more BLE devices built around nRF52 (custom design)

There are multiple Qt-programs (clients) spawned to connect to each BLE device. Each spawned client locate a free device and connects. However, i can't find any way to decide what devices that are already connected. In the example below (from bluetootctl), the first client have connected to the first device. Note that the first device is connected and the second is not connected.


[EnvSens]# info C5:C4:62:E9:9E:C8
Device C5:C4:62:E9:9E:C8
Name: EnvSens
Alias: EnvSens
Paired: no
Trusted: no
Blocked: no
Connected: yes <=========
LegacyPairing: no
UUID: Vendor specific (0000f00d-1212-efde-1523-785fef13d123)
[EnvSens]# info DE:AB:25:04:9F:D9
Device DE:AB:25:04:9F:D9
Name: EnvSens
Alias: EnvSens
Paired: no
Trusted: no
Blocked: no
Connected: no <=========
LegacyPairing: no
UUID: Vendor specific (0000f00d-1212-efde-1523-785fef13d123)


When i spawn the second client QBluetoothDeviceDiscoveryAgent finds both devices, and tries to connect to the first (already connected) device and breaks connection for the first client and then fails to connect with the message "Cannot connect due to pending active LE connections".

I have looked through all classes that potentially could indicate if a device is connected but can't find any method that does, though, I might be blind.

Any help most welcome!

Thanks in advance,
Mike