user11415509
user11415509

Reputation:

How to monitor bluetooth device connectivity status in xamarin Forms?

Can someone guide me on how to monitor the connection status of Bluetooth device? When the device is disconnected I need the notification. Please guide. Does Bluetooth LE plugin work for the normal Bluetooth?

Upvotes: 2

Views: 1852

Answers (2)

Jessie Zhang -MSFT
Jessie Zhang -MSFT

Reputation: 13803

Yes, Shiny is one of the more commonly used plugin, which is a Xamarin Framework for Backgrounding & Device Hardware Services.

First you should read the README.md file of this plugin. They provides two interfaces, IBluetoothLE is helping you to access the Bluetooth status and related things and the IAdapter is for handling the device and communicate with it.

The following information should be helpful for you to understand the plugin.

[IBluetoothLE].StateChanged => To know the Bluetooth status, like its off/on
[IAdapter].DeviceDiscovered => This will trigger when any device is discovered
[IAdapter].ConnectToDeviceAsync => For connecting with a device
[IAdapter].GetServicesAsync => To read the Bluetooth device service (The service is 
providing the characteristic to read and write the query between connected device)
[service].GetCharacteristicsAsync => To get the characteristics from the selected 
service
[characteristic].ReadAsync => Read the data from the device
[characteristic].WriteAsync => Write the data to the device
[characteristic].ValueUpdated => This will trigger when the data through from the 
device
[characteristic].StartUpdatesAsync => Start to get the notifying the value updates

And there are samples about almost every single function point within Shiny. https://github.com/shinyorg/shinysamples

For more details, you can check: https://shinydocs.azurewebsites.net/docs/ble/

Upvotes: 1

Roubachof
Roubachof

Reputation: 3401

You can use Shiny. You will be able to get the connected devices and get status changes:

https://shinydocs.azurewebsites.net/docs/ble/central/centralmanager

Upvotes: 0

Related Questions