protected async Task TeardownBluetooth()
        {
            if (_axLEManager != null)
            {
                await _axLEManager.StopScan();

                _axLEManager = null;
            }

            if (_bluetoothManager != null)
            {
                _bluetoothManager.Dispose();
                _bluetoothManager = null;
            }
        }
Esempio n. 2
0
        async Task Run()
        {
            this.started = DateTime.Now;

            if (imageTest)
            {
                Bitmap bitmap = GetBitmap();
                GetBitmapData(bitmap);
                Console.WriteLine("DEBUG: Stopped after image test - press ENTER to exit...");
                Console.In.Read();
                return;
            }

            _bluetoothManager = new BluetoothManager();
            _axLEManager      = new AxLEManager(_bluetoothManager)
            {
                RssiFilter = 0 // 40 Scan only nearby AxLEs
            };
            _axLEManager.DeviceFound += AxLEManager_DeviceFound;

            // Start the scanner
            try
            {
                await _axLEManager.StartScan();
            }
            catch (Exception e)
            {
                Console.WriteLine("ERROR: Problem starting scanner: " + e.Message);
                return;
            }

            try
            {
                while (!await MainTasks())
                {
                }
            }
            finally
            {
                await _axLEManager.StopScan();
            }
        }