Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion bumble/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,10 @@ async def disconnect(
) -> None:
await self.device.disconnect(self, reason)

@property
def is_connected(self) -> bool:
return self in self.device.sco_links.values()


# -----------------------------------------------------------------------------
class _IsoLink:
Expand Down Expand Up @@ -1644,6 +1648,10 @@ async def disconnect(
) -> None:
await self.device.disconnect(self, reason)

@property
def is_connected(self) -> bool:
return self in self.device.cis_links.values()


# -----------------------------------------------------------------------------
@dataclass
Expand Down Expand Up @@ -1870,7 +1878,11 @@ def is_encrypted(self) -> bool:

@property
def is_incomplete(self) -> bool:
return self.handle is None
return self.handle == 0

@property
def is_connected(self) -> bool:
return self in self.device.connections.values()

def send_l2cap_pdu(self, cid: int, pdu: bytes) -> None:
self.device.send_l2cap_pdu(self.handle, cid, pdu)
Expand Down Expand Up @@ -1913,6 +1925,8 @@ async def switch_role(self, role: hci.Role) -> None:

async def sustain(self, timeout: Optional[float] = None) -> None:
"""Idles the current task waiting for a disconnect or timeout"""
if not self.is_connected:
return

abort = asyncio.get_running_loop().create_future()
self.on(self.EVENT_DISCONNECTION, abort.set_result)
Expand Down
Loading