Ejemplo n.º 1
0
        /// <inheritdoc/>
        public async Task <int> ScanAsync(string adapterName = null, int scanDurationSeconds = DefaultScanDurationSeconds)
        {
            var adapter = await _bluetoothService.GetAdapterAsync(adapterName);

            if (adapter == null)
            {
                throw new AdapterNotFoundException($"Adapter '{adapterName}' was not found");
            }

            await adapter.StartDiscoveryAsync();

            await Task.Delay(TimeSpan.FromSeconds(scanDurationSeconds));

            await adapter.StopDiscoveryAsync();

            _deviceList = await adapter.GetDevicesAsync();

            return(_deviceList.Count);
        }