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 <andrew.leech@planetinnovation.com.au>
pull/1006/head
Andrew Leech 2025-05-07 21:19:43 +10:00 zatwierdzone przez Damien George
rodzic 6e24cffe95
commit 913498ef05
3 zmienionych plików z 3 dodań i 3 usunięć

Wyświetl plik

@ -1,4 +1,4 @@
metadata(version="0.2.0")
metadata(version="0.2.1")
require("aioble-core")

Wyświetl plik

@ -133,7 +133,6 @@ class L2CAPChannel:
# Waits until the channel is free and then sends buf.
# If the buffer is larger than the MTU it will be sent in chunks.
async def send(self, buf, timeout_ms=None, chunk_size=None):
self._assert_connected()
offset = 0
chunk_size = min(self.our_mtu * 2, self.peer_mtu, chunk_size or self.peer_mtu)
mv = memoryview(buf)
@ -141,6 +140,7 @@ class L2CAPChannel:
if self._stalled:
await self.flush(timeout_ms)
# l2cap_send returns True if you can send immediately.
self._assert_connected()
self._stalled = not ble.l2cap_send(
self._connection._conn_handle,
self._cid,

Wyświetl plik

@ -3,7 +3,7 @@
# code. This allows (for development purposes) all the files to live in the
# one directory.
metadata(version="0.6.0")
metadata(version="0.6.1")
# Default installation gives you everything. Install the individual
# components (or a combination of them) if you want a more minimal install.