Table of Contents

Class DeviceScanner

Namespace
NixUniversalSDK
Assembly
NixUniversalSDK.dll

Class responsible for discovering nearby Nix devices.

public class DeviceScanner : IDeviceScanner, IDeviceScannerEvents
Inheritance
DeviceScanner
Implements
Inherited Members

Fields

DefaultGeneralScanPeriodMs

Scan period in milliseconds (20000) used when no time period is provided to Start(long)

public const long DefaultGeneralScanPeriodMs = 20000

Field Value

long

DefaultSingleDevicePeriodMs

Scan period in milliseconds (10000) used when no time period is provided to SearchForIdAsync(string, long)

public const long DefaultSingleDevicePeriodMs = 10000

Field Value

long

Properties

State

Current state of the IDeviceScanner

public DeviceScannerState State { get; }

Property Value

DeviceScannerState

Methods

InitializeAsync()

Initializes the IDeviceScanner and verifies Bluetooth adapter state in the host PC

public Task<DeviceScannerState> InitializeAsync()

Returns

Task<DeviceScannerState>

DeviceScannerState of the IDeviceScanner after initialization

ListUsbDevicesAsync()

Lists USB attached IDeviceCompat instances without running a Bluetooth search

public Task<IEnumerable<IDeviceCompat>> ListUsbDevicesAsync()

Returns

Task<IEnumerable<IDeviceCompat>>

Task with resulting list of USB attached devices

SearchForIdAsync(string, long)

Searches for a specific Nix device via USB and Bluetooth. The search will run until the specified device is found, or until the specified time interval elapses, whichever is shorter. If no time interval is specified, the search will run for DefaultSingleDevicePeriodMs.

public Task<IDeviceCompat> SearchForIdAsync(string id, long scanPeriodMs)

Parameters

id string

Nix device ID used to filter search results

scanPeriodMs long

Period to run the search in milliseconds. Must be positive

Returns

Task<IDeviceCompat>

Nix device instance, or null if no device is found

Start(long)

Starts a search for nearby Nix devices using Bluetooth for a selected time interval. If no timeout interval is specified, the search will run for DefaultGeneralScanPeriodMs

public void Start(long scanPeriodMs = 20000)

Parameters

scanPeriodMs long

Period to run the search in milliseconds. Set to a negative value for continuous search

Stop()

Stops a Bluetooth search if one is currently running.

public void Stop()

Events

ScanResult

Event that is invoked when the IDeviceScanner has found a Nix device. This is invoked each time that a device advertisement has been received, or signal strength Rssi has updated, so multiple events may be received for a given Nix device. The Id can be used to uniquely identify each separate device.

public event EventHandler<ScanResultEventArgs> ScanResult

Event Type

EventHandler<ScanResultEventArgs>

ScannerCreated

Event that is invoked when the IDeviceScanner has been created

public event EventHandler<ScannerCreatedEventArgs> ScannerCreated

Event Type

EventHandler<ScannerCreatedEventArgs>

ScannerStarted

Event that is invoked when the IDeviceScanner starts searching for devices

public event EventHandler ScannerStarted

Event Type

EventHandler

ScannerStopped

Event that is invoked when the IDeviceScanner stops searching for devices

public event EventHandler ScannerStopped

Event Type

EventHandler