public override void OnReceive(Context context, Intent intent) { switch (intent.Action) { case BluetoothAdapter.ActionDiscoveryStarted: System.Diagnostics.Debug.WriteLine("DiscoveryStarted"); break; case BluetoothAdapter.ActionDiscoveryFinished: System.Diagnostics.Debug.WriteLine("DiscoveryFinished"); DiscoveryComplete?.Invoke(this, EventArgs.Empty); break; case BluetoothDevice.ActionFound: var device = (BluetoothDevice)intent.GetParcelableExtra(BluetoothDevice.ExtraDevice); if (device.Type != BluetoothDeviceType.Le) { System.Diagnostics.Debug.WriteLine($"Found {device.Name} {device.Address} {device.BondState}"); DeviceFound?.Invoke(this, device); } break; case BluetoothDevice.ActionNameChanged: var device2 = (BluetoothDevice)intent.GetParcelableExtra(BluetoothDevice.ExtraDevice); System.Diagnostics.Debug.WriteLine($"Name Changed {device2.Name} {device2.Address}"); break; case BluetoothDevice.ActionAclConnected: break; case BluetoothDevice.ActionAclDisconnected: break; } }
/// <summary> /// Called when the discovery process is complete /// </summary> /// <param name="sender">Device watcher which did the discovery process</param> /// <param name="e">not used, always null</param> private void DeviceWatcher_EnumerationCompleted(DeviceWatcher sender, object e) { // Update discovery status _discovery_status = BleDiscoveryStatus.BDS_COMPLETE; _device_watcher.Stop(); // Notify end of discovery DiscoveryComplete?.Invoke(this, BleDiscoveryStatus.BDS_COMPLETE); }
/// <summary> /// Called when the discovery process has been stopped /// </summary> /// <param name="sender">Device watcher which did the discovery process</param> /// <param name="e">not used, always null</param> private void DeviceWatcher_Stopped(DeviceWatcher sender, object e) { // Check if the discovery process is not already complete if (_discovery_status != BleDiscoveryStatus.BDS_COMPLETE) { // Update discovery status _discovery_status = BleDiscoveryStatus.BDS_CANCELED; // Notify end of discovery DiscoveryComplete?.Invoke(this, BleDiscoveryStatus.BDS_CANCELED); } }
public bool OnMessageWithTypes(IMessageSinkMessage message, HashSet <string> messageTypes) { switch (message) { case IDiscoveryCompleteMessage _: DiscoveryComplete.Set(); break; case ITestCaseDiscoveryMessage testCaseDiscoveryMessage: TestCases.Add(testCaseDiscoveryMessage.TestCase); break; } return(true); }
public void OnDiscoveryComplete(DiscoveryCompleteEventArgs e) => DiscoveryComplete?.Invoke(this, e);