toio.scanner.ble module

BLE scanner

Scan toio Core Cubes with internal BLE interface.

async toio.scanner.ble.scan(num: int, sort: Literal['rssi', 'local_name'] | None = 'rssi', timeout: float = 5.0) list[toio.device_interface.CubeInfo][source]

Scan the specified number of toio Core Cubes.

The scan is terminated by a timeout. In the case of a timeout, the number of elements in the returned list is the number of cubes found at the time of the timeout.

Parameters:
  • num (int) – Number of cubes to be found.

  • sort (SortKey, optional) – Key to sort results. Defaults to “rssi”.

  • timeout (float, optional) – Scan timeout. Defaults to DEFAULT_SCAN_TIMEOUT.

Returns:

List of found cubes.

Return type:

list[tuple[BLEDevice, AdvertisementData]]

async toio.scanner.ble.scan_with_id(cube_id: set[str], sort: Literal['rssi', 'local_name'] | None = 'rssi', timeout: float = 5.0) list[toio.device_interface.CubeInfo][source]

Scan toio Core Cubes with specified id.

The scan is terminated by a timeout. In the case of a timeout, the number of elements in the returned list is the number of cubes found at the time of the timeout.

Parameters:
  • cube_id (set[str]) – Set of cube id to be found.

  • sort (SortKey, optional) – Key to sort results. Defaults to “rssi”.

  • timeout (float, optional) – Scan timeout. Defaults to DEFAULT_SCAN_TIMEOUT.

Returns:

List of found cubes.

Return type:

list[tuple[BLEDevice, AdvertisementData]]

async toio.scanner.ble.scan_with_address(address: set[str], sort: Literal['rssi', 'local_name'] | None = 'rssi', timeout: float = 5.0) list[toio.device_interface.CubeInfo][source]

Scan toio Core Cubes with specified BLE address.

The scan is terminated by a timeout. In the case of a timeout, the number of elements in the returned list is the number of cubes found at the time of the timeout.

Parameters:
  • address (set[str]) – Set of BLE address to be found.

  • sort (SortKey, optional) – Key to sort results. Defaults to “rssi”.

  • timeout (float, optional) – Scan timeout. Defaults to DEFAULT_SCAN_TIMEOUT.

Returns:

List of found cubes.

Return type:

list[tuple[BLEDevice, AdvertisementData]]

async toio.scanner.ble.scan_registered_cubes(num: int, sort: Literal['rssi', 'local_name'] | None = 'rssi', timeout: float = 5.0) list[toio.device_interface.CubeInfo][source]

Scan toio Core Cubes registered with Windows

This function only works on Windows platform. On the other platform, this function always returns empty list.

Even if num is greater than the number of registered cubes, the maximum size of the list returned by this function is the number of registered cubes.

Parameters:
  • num (int) – Number of cubes to be found.

  • sort (SortKey, optional) – Key to sort results. Defaults to “rssi”.

  • timeout (float, optional) – Scan timeout. Defaults to DEFAULT_SCAN_TIMEOUT.

Returns:

List of found cubes.

Return type:

list[tuple[BLEDevice, AdvertisementData]]

async toio.scanner.ble.scan_registered_cubes_with_id(cube_id: set[str], sort: Literal['rssi', 'local_name'] | None = 'rssi', timeout: float = 5.0) list[toio.device_interface.CubeInfo][source]

Scan toio Core Cube specified by the cube_id registered with Windows

This function only works on Windows platform. On the other platform, this function always returns empty list.

Parameters:
  • cube_id (set[str]) – Set of cube id to be found.

  • sort (SortKey, optional) – Key to sort results. Defaults to “rssi”.

  • timeout (float, optional) – Scan timeout. Defaults to DEFAULT_SCAN_TIMEOUT.

Returns:

List of found cubes.

Return type:

list[tuple[BLEDevice, AdvertisementData]]