hbldh / bleak

A cross platform Bluetooth Low Energy Client for Python using asyncio
MIT License
1.58k stars 277 forks source link

backends/winrt: add address acquisition process when advertising data is None #1571

Closed kaz399 closed 2 weeks ago

kaz399 commented 3 weeks ago

In some situations, device.details has the scan response data only and advertising data is None.

Since the ble address cannot be obtained from device.details.adv this time, the ble address is obtained from the device.details.scan (scan response data).

dlech commented 3 weeks ago

Thanks for the PR!

Can you please add a changelog entry?

Also, I'm wondering if we could write this in a way that is a bit less verbose. Maybe something like this?

data = address_or_ble_device.details
self._device_info = (data.adv or data.scan).bluetooth_address

And it would be good to fix the type hint at https://github.com/hbldh/bleak/blob/181467f7d7e09e0a7130962a0f7f8db4510ddc59/bleak/backends/winrt/scanner.py#L53 while we are at it. (Should be Optional[BluetoothLEAdvertisementReceivedEventArgs].)

kaz399 commented 3 weeks ago

Thanks for the suggestion for a more concise description! It is very clear and good.

I modify the type hints and update the changelog.

dlech commented 2 weeks ago

Thanks for updating!