Skip to content

Commit 913498e

Browse files
pi-anldpgeorge
authored andcommitted
aioble-l2cap: Raise correct error if l2cap disconnects during send.
If BLE disconnects in the middle of a send process, this change makes the code raise `L2CAPDisconnectedError` rather than `TypeError` due to `_cid` being `None`. Signed-off-by: Andrew Leech <[email protected]>
1 parent 6e24cff commit 913498e

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

micropython/bluetooth/aioble-l2cap/manifest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
metadata(version="0.2.0")
1+
metadata(version="0.2.1")
22

33
require("aioble-core")
44

micropython/bluetooth/aioble/aioble/l2cap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,14 @@ def available(self):
133133
# Waits until the channel is free and then sends buf.
134134
# If the buffer is larger than the MTU it will be sent in chunks.
135135
async def send(self, buf, timeout_ms=None, chunk_size=None):
136-
self._assert_connected()
137136
offset = 0
138137
chunk_size = min(self.our_mtu * 2, self.peer_mtu, chunk_size or self.peer_mtu)
139138
mv = memoryview(buf)
140139
while offset < len(buf):
141140
if self._stalled:
142141
await self.flush(timeout_ms)
143142
# l2cap_send returns True if you can send immediately.
143+
self._assert_connected()
144144
self._stalled = not ble.l2cap_send(
145145
self._connection._conn_handle,
146146
self._cid,

micropython/bluetooth/aioble/manifest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# code. This allows (for development purposes) all the files to live in the
44
# one directory.
55

6-
metadata(version="0.6.0")
6+
metadata(version="0.6.1")
77

88
# Default installation gives you everything. Install the individual
99
# components (or a combination of them) if you want a more minimal install.

0 commit comments

Comments
 (0)