Bluetooth Manager For Windows 10 UWP App

Sometimes, we need to transfer data from one device to another device in a short range,and  for that we need to use the Bluetooth protocol.

Bluetooth

To manage Bluetooth is easy. An external library is available to manage Bluetooth in Universal Windows 10 applications. This library hides all the device discovery and connection stuff behind a well behaved interface. It makes it really easy to bind to events that you can use to drive your user interface.

You can find the library on Nuget with the name BluetoothManager.

Let’s see the steps.

Create new Windows 10 UWP app and install the BluetoothManager like the following screen.

install

Now create instance from BluetoothManager to bind the events like the following code.

  1. BluetoothManager manager = new BluetoothManager();  
  2. manager.StatusChangedNotification += new BluetoothManager.StatusChangedDelegate(statusChanged);  
  3. manager.DiagnosticsChangedNotification += new BluetoothManager.DiagnosticsMessageDelegate(messageReceived);  
  4. manager.Initialise("DeviceName");  
Initialize your device name directly.
  1. private void messageReceived(string message)  
  2. {  
  3.   
  4. }  
We can get the status of device changes.
  1. private void statusChanged(BluetoothManager.ManagerStatus status)  
  2. {  
  3. }  
To send string,
  1. manager.SendStringAsync("Test String");  
Now run the app and check the device Bluetooth changes. My concern is this Bluetooth manager is mainly used to connect with Bluetooth printers.

Up Next
    Ebook Download
    View all
    Learn
    View all