8000 aioble: Add l2cap channel disconnected(). · andrewleech/micropython-lib@3ea7486 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 3ea7486

Browse files
jimmodpgeorge
authored andcommitted
aioble: Add l2cap channel disconnected().
Allows `await channel.disconnected()`. This also fixes a bug where connection._l2cap_channel wasn't being set to None on disconnect. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
1 parent dd9b783 commit 3ea7486

File tree

1 file changed

+5
-1
lines changed
  • micropython/bluetooth/aioble/aioble

1 file changed

+5
-1
lines changed

micropython/bluetooth/aioble/aioble/l2cap.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def _l2cap_irq(event, data):
4444
_, _, psm, status = data
4545
channel._status = status
4646
channel._cid = None
47+
connection._l2cap_channel = None
4748
elif event == _IRQ_L2CAP_RECV:
4849
channel._data_ready = True
4950
elif event == _IRQ_L2CAP_SEND_READY:
@@ -155,8 +156,11 @@ async def disconnect(self, timeout_ms=1000):
155156
return
156157

157158
# Wait for the cid to be cleared by the disconnect IRQ.
159+
ble.l2cap_disconnect(self._connection._conn_handle, self._cid)
160+
await self.disconnected(timeout_ms)
161+
162+
async def disconnected(self, timeout_ms=1000):
158163
with self._connection.timeout(timeout_ms):
159-
ble.l2cap_disconnect(self._connection._conn_handle, self._cid)
160164
while self._cid is not None:
161165
await self._event.wait()
162166

0 commit comments

Comments
 (0)
0