Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 09f0e47

Browse files
pi-anljimmo
authored andcommitted
aioble: Add timeout to device.exchange_mtu.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
1 parent c3f4779 commit 09f0e47

File tree

1 file changed

+3
-2
lines changed
  • micropython/bluetooth/aioble/aioble

1 file changed

+3
-2
lines changed

‎micropython/bluetooth/aioble/aioble/device.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ def is_connected(self):
262262
def timeout(self, timeout_ms):
263263
return DeviceTimeout(self, timeout_ms)
264264

265-
async def exchange_mtu(self, mtu=None):
265+
async def exchange_mtu(self, mtu=None, timeout_ms=1000):
266266
if not self.is_connected():
267267
raise ValueError("Not connected")
268268

@@ -271,7 +271,8 @@ async def exchange_mtu(self, mtu=None):
271271

272272
self._mtu_event = self._mtu_event or asyncio.ThreadSafeFlag()
273273
ble.gattc_exchange_mtu(self._conn_handle)
274-
await self._mtu_event.wait()
274+
with self.timeout(timeout_ms):
275+
await self._mtu_event.wait()
275276
return self.mtu
276277

277278
# Wait for a connection on an L2CAP connection-oriented-channel.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /