1. TrainScanner
from intelino.trainlib_async import TrainScanner
- class trainlib_async.TrainScanner(device_identifier: str | None = None, timeout: float = 5.0)
Obtaining a
Train
object using theasync with
statement.- __init__(device_identifier: str | None = None, timeout: float = 5.0)
- Parameters:
device_identifier (str) – The Bluetooth/UUID address of the Bluetooth peripheral sought. If not specified, it will return the first found intelino train.
timeout (float) – Optional timeout to wait for detection of specified peripheral before giving up. Defaults to 5.0 seconds.
- await get_train(connect: bool = True, **kwargs) Train
Get a train instance asynchronously.
- Parameters:
connect (bool) – Whether to auto-connect to the found train. Defaults to True.
- Keyword Arguments:
adapter (str) – Bluetooth adapter to use for discovery.
- Raises:
TrainNotFoundError – If no train is found.
- Returns:
A
Train
instance.
- await get_trains(count: int | None = None, connect: bool = True, **kwargs) List[Train]
Get a list of train instances asynchronously.
- Parameters:
count (int) – Optional detection limit. If ommited or 0, it searches for all trains in the vicinity until it timeouts.
connect (bool) – Whether to auto-connect to the found trains. Defaults to True.
- Keyword Arguments:
at_most (int) – Connect to at most N trains. No exception is raised if the count argument is omitted.
adapter (str) – Bluetooth adapter to use for discovery.
- Raises:
TrainNotFoundError – If no train is found.
- Returns:
A list of
Train
instances.