Skip to content

Commit e7d7463

Browse files
committed
aioble/peripheral: Handle immediate disconnect.
If the client disconnects immediately after connection, the irq can be run before the initial connect handler has finished.
1 parent cdd260f commit e7d7463

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

micropython/bluetooth/aioble/aioble/peripheral.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ def _peripheral_irq(event, data):
6060
conn_handle, _, _ = data
6161
if connection := DeviceConnection._connected.get(conn_handle, None):
6262
# Tell the device_task that it should terminate.
63+
if connection._event is None:
64+
connection._event = asyncio.ThreadSafeFlag()
6365
connection._event.set()
6466

6567

0 commit comments

Comments
 (0)