IanHarvey / bluepy

Python interface to Bluetooth LE on Linux
Other
1.6k stars 490 forks source link

Add support for getting local OOB and setting OOB for a remote device #302

Closed scourc closed 5 years ago

scourc commented 6 years ago

Hi, I faced the issue that if helper is started without argument, the mgmt is not setup. I think in this case the mgmt should be setup for the default index (0).

Thorsten-Sick commented 5 years ago

@scourc : As soon as I have a reliable OBB bluetooth device to test this I'll test. But it could still be weeks...so if you already tested: do not wait for me to merge it !

I am looking forward to this feature. Thanks

scourc commented 5 years ago

Hi all, I just pushed new modifications. With these, I could read local LE OOB data on a Raspberry Pi 3 with LE and Secure Connections active, then provide the OOB data to a BLE device. After that, issuing a pairing command on the Raspberry to pair with the BLE node worked, and I could check with btmon that indeed OOB Secure Connections is used properly. @Thorsten-Sick : That's what I have tested until now. As for merging, it needs to be reviewed and (possibly) merged by someone with write access ;-)

IanHarvey commented 5 years ago

Just merged this - thanks.

I don't really have anything to test this with, so it would be handy if you can confirm that the merged version (b212b67) does what you expect.

The code is looking like it's Python 2 only, as it's using ord() on the returned data, which is a bytes type in Python 3, not a string. I've generally been using struct.unpack() rather than ord() to parse returned data, as it works across Python versions. If you get the chance to make it work on 3, I'd be grateful for a patch.

Thanks Ian

scourc commented 5 years ago

Hi Ian, Thanks for merging !

I just tested that my test case works after the merge, in python 2. As a reminder, my test case is:

Concerning support for python 3, I have a patch where I replaced the ord with struct.unpack_from, and my test also (still) works as expected in Python 2. However I cannot yet test on Python 3 because the framework I am using on top is python 2 only...

I'll tell you when I have tested in python 3. But in any case, I'll submit the patch removing the ord.

Thanks again