kevincar / bless

Cross-platform Bluetooth Low Energy Server Python Library
MIT License
78 stars 26 forks source link

How to know that a ble dongle is fully ble5 compliant? #93

Open WouterJD opened 1 year ago

WouterJD commented 1 year ago

The problem Function add_gatt() object has no attribute 'add-advertisement-status-changed'.

I got this error on BLE4 dongles before, a user now reports it now occurs on his ble5 dongle. See https://github.com/WouterJD/FortiusANT/issues/389#issuecomment-1287838339

Reproduction Occurs always on same system

Expected behavior How can I detect a dongle is really ble5 compliant;I recall there are inferior dongles that state compliancy but are not.

Screenshots See black console in https://user-images.githubusercontent.com/69309725/197349798-2273ad49-6f32-438f-86e2-c39a27cebaa2.PNG

Desktop (please complete the following information):

Additional context I will ask user dongle details.

WouterJD commented 1 year ago

A driver update solved the problem See https://github.com/WouterJD/FortiusANT/issues/389#issuecomment-1288150709

The question (how to detect) remains open.

kevincar commented 1 year ago

This may be driver dependent. One way to check on Windows is to checkout the device on device manager and confirm that the device driver specifies that "peripheral role is supported".

Are you wanting to have bless implement a way to detect this?

WouterJD commented 1 year ago

Hi @kevincar Thanks for response. Yes, it would be very helpful and avoid issues and debugging to detect.

I can then implement the check and provide a decent message to the users.

kevincar commented 1 year ago

I think this would be a nice feature. However, this may take some time as I'd like to ensure bless can work cross-platform, which would mean we'd ideally enable this across all platforms.

In your case for Windows implementation, we should be able to accomplish this by Enumerating appropriate device drivers, then checking the PeripheralRoleSupported Property.

Linux should be straight forward, but macOS will likely pose the biggest challenge as obtaining information on available Bluetooth controllers (particularly external devices) is not so obvious.

We can create a feature branch of bless to get this going and slowly work on the other parts. Would be great to get your help on this, otherwise the turn around time may be a bit slow.

WouterJD commented 1 year ago

The source of the issue was that some installation did not work (on raspberry) which first triggered the idea that the BLE interface would be incompatible (see https://github.com/WouterJD/FortiusANT/issues/402#issuecomment-1320887551).

Since that's not the case, if "object has no attribute" in exceptionMsg: self.Message += "BLE-5 required." may be enough.

kevincar commented 1 year ago

I'm actively looking into this issue (though slowly) since it may be helpful for us to enumerate devices and select specified bluetooth module if multiple are available (see this issue). Currently, you can actually enumerate and select the adapter when using bless on Linux, but I'd like to extend that to the other platforms. So I'm hoping this feature will eventually be available. Currently still in the works for now.