diff --git a/bumble/smp.py b/bumble/smp.py index c055e715..37031048 100644 --- a/bumble/smp.py +++ b/bumble/smp.py @@ -1839,7 +1839,7 @@ def on_smp_pairing_public_key_command( if self.is_initiator: if self.pairing_method == PairingMethod.OOB: self.send_pairing_random_command() - else: + elif self.pairing_method == PairingMethod.PASSKEY: self.send_pairing_confirm_command() else: if self.pairing_method == PairingMethod.PASSKEY: diff --git a/bumble/transport/common.py b/bumble/transport/common.py index f2c7fcb7..13176375 100644 --- a/bumble/transport/common.py +++ b/bumble/transport/common.py @@ -370,11 +370,13 @@ async def pump_packets() -> None: self.parser.feed_data(packet) except asyncio.CancelledError: logger.debug('source pump task done') - self.terminated.set_result(None) + if not self.terminated.done(): + self.terminated.set_result(None) break except Exception as error: logger.warning(f'exception while waiting for packet: {error}') - self.terminated.set_exception(error) + if not self.terminated.done(): + self.terminated.set_exception(error) break self.pump_task = asyncio.create_task(pump_packets())