Skip to content

Commit

Permalink
fix: ensure dbus wait always happens on success case (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco committed Nov 27, 2022
1 parent 2b09ff5 commit df8e7e0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/bluetooth_auto_recovery/recover.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,12 @@ async def recover_adapter(hci: int) -> bool:
_LOGGER.warning("Bluetooth adapter hci%i is hard blocked by rfkill!", hci)
return False

return await _power_cycle_adapter(hci) or await _usb_reset_adapter(hci)
if await _power_cycle_adapter(hci) or await _usb_reset_adapter(hci):
# Give Dbus some time to catch up
await asyncio.sleep(DBUS_REGISTER_TIME)
return True

return False


async def _power_cycle_adapter(hci: int) -> bool:
Expand Down Expand Up @@ -350,8 +355,6 @@ async def _execute_reset(adapter: MGMTBluetoothCtl, hci: int) -> bool:
_LOGGER.debug(
"Power state of bluetooth adapter hci%i is ON after power cycle", hci
)
# Give Dbus some time to catch up
await asyncio.sleep(DBUS_REGISTER_TIME)
return True

if pstate_after is False:
Expand Down

0 comments on commit df8e7e0

Please sign in to comment.