Skip to content

pb_client.service.Service.scanning async

scanning(*, seconds=10.0, name=None, transport=None)

Scan, reporting each hub as it is seen rather than at the end.

The iterator yields one item per advertisement, so the same hub arrives many times over a scan with its signal strength as it is now. That is the point: a hub's signal is how someone works out which of two identically named hubs is the one on the desk in front of them. Callers that only want a list should use scan.

Leaving the block early stops the scan, so a caller can take the first hub it likes and get on with it.

Parameters:

Name Type Description Default
seconds float | None

How long the service should look, or None to keep looking until the block is left. Use None when a person is reading the results, since a deadline on a person only ever expires at the worst moment.

10.0
name str | None

Only report hubs with this name.

None
transport str | None

Only look on this transport, such as "usb" or "ble". Left out, every transport the service has is used.

None

Yields:

Type Description
AsyncGenerator[AsyncIterator[DeviceInfo], None]

An iterator over the hubs seen, ending when the scan does -- which,

AsyncGenerator[AsyncIterator[DeviceInfo], None]

with no time limit, means when the block is left.

Raises:

Type Description
RuntimeError

If this connection has no notification router, which would leave the iterator silently empty.