liamw9534 / bt-manager

A library for managing bluetooth devices using Python, Bluez and DBus.
GNU General Public License v3.0
24 stars 14 forks source link

WIP: Add Bluez5 support (see #4), fully Bluez4 retrocompatible. #9

Open gillg opened 7 years ago

gillg commented 7 years ago

Work not finished yet, to add Bluez5 support.

Basic commands (list-adapters / adapter-get / etc..) already tested and functional

liamw9534 commented 7 years ago

I think it makes sense to put this stuff on a separate branch. Since bluez5 is not retrocompatible with bluez4, and projects may still wish to use bluez4, then a separate branch seems the way to go.

gillg commented 7 years ago

I'm according with you. I need to try to make these changes compatibles with both versions. But if I not succeed a branch bluez5 should be the solution (or an archive branch bluez4 with a tag).

gillg commented 7 years ago

Hi !

I see the light ! :) After some long tests lot of things work with bluez 4 or 5. I'm not a good python dev, so I don't know unit tests with python, maybe someone could help me to write some scripts.

I made lot of changes... work is at 0% on agent.py (need probably a new class with new method decorators), but 100% for interface / devices / adapter / manager / audio / media is done. Some other things are not yet tested.

I deprecated some methods for bluez5 such as "adapter.create_paired_device". I don't find any equivalent... With bluez5 you should use AgentManager I think (https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/agent-api.txt).

I create a new audio lib dedicated to bluez5, needed to make new decorators.


Now, in my tests, I need some help to resolve a strage Dbus exception.

On a mailoop, I find adapter > register audio source endpoint > pair device if needed > try to connect with sink audio profile. => I got a dbus error "Input/Output error". In logs, bluez says it received an empty response for method SelectConfiguration().

If I don't try ton connect, and let mainloop run, I connect my device manually with bluetoothctl, SelectConfiguration() is called on my test program, and all is good... So I think I have a conflict between connect method and callback SelectConfiguration. App call bluez for connection (blocking call), and bluez call SelectConfiguration on App wich could not respond. I tried to run endpoint in manloop / in thread and connect device in mainloop / different thred, but nothing works... Have you any idea ?

matbee-eth commented 6 years ago

Any updates on this PR? Possible to make a Pr for a Bluez5 branch?