public void GetAvailableDevices(SerialSearchStarted started, SerialSearchFound found, SerialSearchFinished finished) { started(); foreach (string portName in SerialPort.GetPortNames()) { found(portName); } finished(); }
public void SearchAvailableDevices(SerialSearchStarted started, SerialSearchFound found, SerialSearchFinished finished) { // Search for bluetooth devices _bluetoothBroadcastRecevicer = new BluetoothBroadcastReceiver(started, found, finished); IntentFilter deviceFoundFilter = new IntentFilter(BluetoothDevice.ActionFound); Context.RegisterReceiver(_bluetoothBroadcastRecevicer, deviceFoundFilter); IntentFilter discoveryFinishedFilter = new IntentFilter(Android.Bluetooth.BluetoothAdapter.ActionDiscoveryFinished); Context.RegisterReceiver(_bluetoothBroadcastRecevicer, discoveryFinishedFilter); IntentFilter discoveryStartedFilter = new IntentFilter(Android.Bluetooth.BluetoothAdapter.ActionDiscoveryStarted); Context.RegisterReceiver(_bluetoothBroadcastRecevicer, discoveryStartedFilter); _bluetoothAdapter.StartDiscovery(); }
public BluetoothBroadcastReceiver(SerialSearchStarted started, SerialSearchFound found, SerialSearchFinished finished) { _startedDelegate = started; _foundDelegate = found; _finishedDelegate = finished; }