Fix connectable Bluetooth devices not being seen if the nearest scanner is non-connectable (#80388)
If we saw the non-connectable scanner advertisement first we would reject the connectable scanner advertisement because it had worse signal strength. In this case we need to check both
This commit is contained in:
parent
d38d21ab3a
commit
f70f972d88
3 changed files with 118 additions and 13 deletions
|
@ -336,3 +336,51 @@ async def test_switching_adapters_based_on_rssi_connectable_to_non_connectable(
|
|||
bluetooth.async_ble_device_from_address(hass, address, True)
|
||||
is switchbot_device_poor_signal
|
||||
)
|
||||
|
||||
|
||||
async def test_connectable_advertisement_can_be_retrieved_with_best_path_is_non_connectable(
|
||||
hass, enable_bluetooth
|
||||
):
|
||||
"""Test we can still get a connectable BLEDevice when the best path is non-connectable.
|
||||
|
||||
In this case the the device is closer to a non-connectable scanner, but the
|
||||
at least one connectable scanner has the device in range.
|
||||
"""
|
||||
|
||||
address = "44:44:33:11:23:45"
|
||||
now = time.monotonic()
|
||||
switchbot_device_good_signal = BLEDevice(address, "wohand_good_signal")
|
||||
switchbot_adv_good_signal = generate_advertisement_data(
|
||||
local_name="wohand_good_signal", service_uuids=[], rssi=-60
|
||||
)
|
||||
inject_advertisement_with_time_and_source_connectable(
|
||||
hass,
|
||||
switchbot_device_good_signal,
|
||||
switchbot_adv_good_signal,
|
||||
now,
|
||||
"hci1",
|
||||
False,
|
||||
)
|
||||
|
||||
assert (
|
||||
bluetooth.async_ble_device_from_address(hass, address, False)
|
||||
is switchbot_device_good_signal
|
||||
)
|
||||
assert bluetooth.async_ble_device_from_address(hass, address, True) is None
|
||||
|
||||
switchbot_device_poor_signal = BLEDevice(address, "wohand_poor_signal")
|
||||
switchbot_adv_poor_signal = generate_advertisement_data(
|
||||
local_name="wohand_poor_signal", service_uuids=[], rssi=-100
|
||||
)
|
||||
inject_advertisement_with_time_and_source_connectable(
|
||||
hass, switchbot_device_poor_signal, switchbot_adv_poor_signal, now, "hci0", True
|
||||
)
|
||||
|
||||
assert (
|
||||
bluetooth.async_ble_device_from_address(hass, address, False)
|
||||
is switchbot_device_good_signal
|
||||
)
|
||||
assert (
|
||||
bluetooth.async_ble_device_from_address(hass, address, True)
|
||||
is switchbot_device_poor_signal
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue