edrosten / libblepp

Modern clean C++ Bluetooth Low Energy on Linux without the Bluez DBUS API
Other
239 stars 62 forks source link

connect with security level #30

Closed greymfm closed 6 years ago

greymfm commented 6 years ago

I have an BLE device that requires bonding (encrypted connections). How could that work with libblepp?

From PyGattlib I can see a function call 'l2cap_set' with parameter 'opts->sec_level' which later calls function 'setsockopt' (and l2cap_set_lm, rfcomm_set_lm) inside function 'set_sec_level' - could this be the key for an encrypted connection?

https://github.com/nccgroup/BLESuite/blob/58574a2e480893512e1e3afc889f5acf09bda20e/PyGattlib/src/bluez/btio/btio.c#L1487

https://github.com/nccgroup/BLESuite/blob/58574a2e480893512e1e3afc889f5acf09bda20e/PyGattlib/src/bluez/btio/btio.c#L449

And a quote I found [...'Although setting a security level using setsockopt(BT_SECURITY) is optional for LE sockets (it will default to doing unencrypted/unauthenticated connection), it is a common operation and it is done by BlueZ daemon and some tools.'...]

Maybe we can add setting the security level during connecting? :)

denysvitali commented 5 years ago

May I ask you why did you close the issue on the same day you've posted it?
Is it solved?

greymfm commented 5 years ago

Actually, my problem was not related to security - Linux had paired the device and actually the existing pairing was my problem, not security... so problem solved now.

denysvitali commented 5 years ago

I'm glad your issue is solved Thanks for sharing!