Class DigiBLEManager
Class used to manage Bluetooth events and permissions.
Inherited Members
Namespace: DigiIoTDigiIoT.MauiModels
Assembly: DigiIoT.Maui.dll
Syntax
public class DigiBLEManager
Constructors
DigiBLEManager()
Class constructior. Instantiates a new BluetoothManager object.
Declaration
public DigiBLEManager()
Properties
IsScanning
Indicates whether Bluetooth is scanning or not.
Declaration
public bool IsScanning { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Methods
GetBluetoothState()
Returns the current Bluetooth state.
Declaration
public static Task<BluetoothState> GetBluetoothState()
Returns
| Type | Description |
|---|---|
| TaskBluetoothState | The Bluetooth state |
IsBluetoothEnabled()
Returns whether the Bluetooth adapter is enabled or not.
Declaration
public static Task<bool> IsBluetoothEnabled()
Returns
| Type | Description |
|---|---|
| Taskbool |
|
IsGPSEnabled()
Returns whether the GPS is enabled or not.
Declaration
public static bool IsGPSEnabled()
Returns
| Type | Description |
|---|---|
| bool |
|
RequestBluetoothPermission()
Requests Bluetooth permisions.
Declaration
public static Task<bool> RequestBluetoothPermission()
Returns
| Type | Description |
|---|---|
| Taskbool |
|
RequestLocationPermission()
Requests location permisions.
Declaration
public static Task<bool> RequestLocationPermission()
Returns
| Type | Description |
|---|---|
| Taskbool |
|
StartScanning()
Starts the scan process to look for BLE devices.
Declaration
public void StartScanning()
StopScanning()
Stops the BLE scanning process.
Declaration
public void StopScanning()
ValidateBluetoothStatus()
Validates that Bluetooth is operative in the device. This means that necessary interfaces and permissions are enabled and granted. The method requests for permissions to the user if necessary.
Declaration
public static void ValidateBluetoothStatus()
Exceptions
| Type | Condition |
|---|---|
| DigiIoTException | If any required interface is not enabled or necessary permission was not granted. |
Events
BluetoothStateChanged
Event called when the Bluetooth interface state changed.
Declaration
public event DigiBLEManager.BluetoothStateChangedHandler BluetoothStateChanged
Event Type
| Type | Description |
|---|---|
| DigiBLEManagerBluetoothStateChangedHandler |
ConnectionLost
Event called when the Bluetooth connection was lost.
Declaration
public event DigiBLEManager.ConnectionLostHandler ConnectionLost
Event Type
| Type | Description |
|---|---|
| DigiBLEManagerConnectionLostHandler |
DeviceAdvertised
Event called when a Bluetooth device has been advertised.
Declaration
public event DigiBLEManager.DeviceAdvertisedHandler DeviceAdvertised
Event Type
| Type | Description |
|---|---|
| DigiBLEManagerDeviceAdvertisedHandler |
ScanStarted
Event called when the Bluetooth scan process has started.
Declaration
public event DigiBLEManager.ScanStartedHandler ScanStarted
Event Type
| Type | Description |
|---|---|
| DigiBLEManagerScanStartedHandler |
ScanStopped
Event called when the Bluetooth scan process has stopped.
Declaration
public event DigiBLEManager.ScanStoppedHandler ScanStopped
Event Type
| Type | Description |
|---|---|
| DigiBLEManagerScanStoppedHandler |