@@ -90,7 +90,7 @@ async def connect(self, **kwargs) -> bool:
9090 """Connect to the specified GATT server.
9191
9292 Keyword Args:
93- timeout (float): Timeout for required ``BleakScanner.find_device_by_address`` call. Defaults to 10.0.
93+ timeout (float): Defaults to 10.0.
9494
9595 Returns:
9696 Boolean representing connection status.
@@ -377,9 +377,12 @@ def _cleanup_all(self) -> None:
377377 self .services = BleakGATTServiceCollection ()
378378 self ._services_resolved = False
379379
380- async def disconnect (self ) -> bool :
380+ async def disconnect (self , ** kwargs ) -> bool :
381381 """Disconnect from the specified GATT server.
382382
383+ Keyword Args:
384+ timeout (float): Defaults to 10.0.
385+
383386 Returns:
384387 Boolean representing if device is disconnected.
385388
@@ -396,10 +399,11 @@ async def disconnect(self) -> bool:
396399 logger .debug (f"already disconnected ({ self ._device_path } )" )
397400 return True
398401
402+ timeout = kwargs .get ("timeout" , self ._timeout )
399403 if self ._disconnecting_event :
400404 # another call to disconnect() is already in progress
401405 logger .debug (f"already in progress ({ self ._device_path } )" )
402- await asyncio .wait_for (self ._disconnecting_event .wait (), timeout = 10 )
406+ await asyncio .wait_for (self ._disconnecting_event .wait (), timeout = timeout )
403407 elif self .is_connected :
404408 self ._disconnecting_event = asyncio .Event ()
405409 try :
@@ -413,7 +417,7 @@ async def disconnect(self) -> bool:
413417 )
414418 )
415419 assert_reply (reply )
416- await asyncio .wait_for (self ._disconnecting_event .wait (), timeout = 10 )
420+ await asyncio .wait_for (self ._disconnecting_event .wait (), timeout = timeout )
417421 finally :
418422 self ._disconnecting_event = None
419423
@@ -575,6 +579,9 @@ def mtu_size(self) -> int:
575579 async def get_services (self , ** kwargs ) -> BleakGATTServiceCollection :
576580 """Get all services registered for this GATT server.
577581
582+ Keyword Args:
583+ timeout (float): Timeout for required ``BleakScanner.find_device_by_address`` call. Defaults to 10.0.
584+
578585 Returns:
579586 A :py:class:`bleak.backends.service.BleakGATTServiceCollection` with this device's services tree.
580587
@@ -585,11 +592,12 @@ async def get_services(self, **kwargs) -> BleakGATTServiceCollection:
585592 if self ._services_resolved :
586593 return self .services
587594
595+ timeout = kwargs .get ("timeout" , self ._timeout )
588596 if not self ._properties ["ServicesResolved" ]:
589597 logger .debug (f"Waiting for ServicesResolved ({ self ._device_path } )" )
590598 self ._services_resolved_event = asyncio .Event ()
591599 try :
592- await asyncio .wait_for (self ._services_resolved_event .wait (), 5 )
600+ await asyncio .wait_for (self ._services_resolved_event .wait (), timeout )
593601 finally :
594602 self ._services_resolved_event = None
595603
0 commit comments