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
DefaultSingleDevicePeriodMs
Scan period in milliseconds (10000) used when no time period is provided to SearchForIdAsync(string, long)
public const long DefaultSingleDevicePeriodMs = 10000
Field Value
Properties
State
Current state of the IDeviceScanner
public DeviceScannerState State { get; }
Property Value
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
stringNix device ID used to filter search results
scanPeriodMs
longPeriod 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
longPeriod 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
ScannerCreated
Event that is invoked when the IDeviceScanner has been created
public event EventHandler<ScannerCreatedEventArgs> ScannerCreated
Event Type
ScannerStarted
Event that is invoked when the IDeviceScanner starts searching for devices
public event EventHandler ScannerStarted
Event Type
ScannerStopped
Event that is invoked when the IDeviceScanner stops searching for devices
public event EventHandler ScannerStopped