Skip to content

Instantly share code, notes, and snippets.

@hasan-hasanov
Created April 24, 2021 22:36
Show Gist options
  • Select an option

  • Save hasan-hasanov/1cccd2aeb4f6588681520889dcdb84aa to your computer and use it in GitHub Desktop.

Select an option

Save hasan-hasanov/1cccd2aeb4f6588681520889dcdb84aa to your computer and use it in GitHub Desktop.
Bluetooth Low Energy Example
class Program
{
static async Task Main(string[] args)
{
var watcher = new BluetoothLEAdvertisementWatcher();
watcher = new BluetoothLEAdvertisementWatcher()
{
ScanningMode = BluetoothLEScanningMode.Passive
};
watcher.Received += Watcher_Received;
watcher.Start();
await Task.Delay(Timeout.Infinite);
}
private static async void Watcher_Received(
BluetoothLEAdvertisementWatcher sender,
BluetoothLEAdvertisementReceivedEventArgs args)
{
var device = await BluetoothLEDevice.FromBluetoothAddressAsync(args.BluetoothAddress);
if (device != null)
{
Console.WriteLine(device.BluetoothAddress);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment