blatann.gap.scanning module

class blatann.gap.scanning.ScanParameters(interval_ms, window_ms, timeout_s, active=True)

Bases: BLEGapScanParams

Class which holds scanning parameters

validate()
update(window_ms, interval_ms, timeout_s, active)
class blatann.gap.scanning.Scanner(ble_device)

Bases: object

property on_scan_received: Event[Scanner, ScanReport]

Event that is raised whenever a scan report is received

property on_scan_timeout: Event[Scanner, ScanReportCollection]

Event that is raised when scanning completes/times out

property is_scanning: bool

Read Only

Current state of scanning

set_default_scan_params(interval_ms=200, window_ms=150, timeout_seconds=10, active_scanning=True)

Sets the default scan parameters so they do not have to be specified each time a scan is started. Reference the Bluetooth specification for valid ranges for parameters.

Parameters
  • interval_ms (float) – The interval which to scan for advertising packets, in milliseconds

  • window_ms (float) – How long within a single scan interval to be actively listening for advertising packets, in milliseconds

  • timeout_seconds (int) – How long to advertise for, in seconds

  • active_scanning (bool) – Whether or not to fetch scan response packets from advertisers

start_scan(scan_parameters=None, clear_scan_reports=True)

Starts a scan and returns a waitable for when the scan completes

Parameters
  • scan_parameters (Optional[ScanParameters]) – Optional scan parameters. Uses default if not specified

  • clear_scan_reports – Flag to clear out previous scan reports

Return type

ScanFinishedWaitable

Returns

A Waitable which will trigger once the scan finishes based on the timeout specified. Waitable returns a ScanReportCollection of the advertising packets found

stop()

Stops scanning