Class DigiBLEDevice
This class represents a generic Digi device with Bluetooth Low Energy (BLE) connectivity.
Inherited Members
Namespace: DigiIoTDigiIoT.MauiDevices
Assembly: DigiIoT.Maui.dll
Syntax
public class DigiBLEDevice
Constructors
DigiBLEDevice(IDevice, string)
Class constructor. Instantiates a new DigiBLEDevice object with the given parameters.
Declaration
public DigiBLEDevice(IDevice device, string password)
Parameters
| Type | Name | Description |
|---|---|---|
| IDevice | device | Bluetooth device to connect to. |
| string | password | Bluetooth password (can be |
Remarks
The Bluetooth password must be provided before calling the Connect() method, either through this constructor or the SetBluetoothPassword(string) method.
See Also
DigiBLEDevice(Guid, string)
Class constructor. Instantiates a new DigiBLEDevice object with the given parameters.
Declaration
public DigiBLEDevice(Guid deviceGuid, string password)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | deviceGuid | The Bluetooth device GUID. |
| string | password | Bluetooth password (can be |
Remarks
The Bluetooth password must be provided before calling the Connect() method, either through this constructor or the SetBluetoothPassword(string) method.
See Also
DigiBLEDevice(string, string)
Class constructor. Instantiates a new DigiBLEDevice object with the given parameters.
Declaration
public DigiBLEDevice(string deviceAddress, string password)
Parameters
| Type | Name | Description |
|---|---|---|
| string | deviceAddress | The address or GUID of the Bluetooth device. It must follow the
format |
| string | password | Bluetooth password (can be |
Remarks
The Bluetooth password must be provided before calling the Connect() method, either through this constructor or the SetBluetoothPassword(string) method.
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | If |
Properties
IsConnected
The status of the Bluetooth connection. It indicates if the device is connected or not.
Declaration
public bool IsConnected { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Methods
Connect()
Opens the Bluetooth connection with the device.
Declaration
public void Connect()
Disconnect()
Closes the Bluetooth connection with the device.
Declaration
public void Disconnect()
ReadData()
Reads a Bluetooth data packet received by the device during the configured receive timeout.
Declaration
public byte[] ReadData()
Returns
| Type | Description |
|---|---|
| byte |
ReadData(int)
Reads a Bluetooth data packet received by the device during the provided timeout.
Declaration
public byte[] ReadData(int timeout)
Parameters
| Type | Name | Description |
|---|---|---|
| int | timeout |
Returns
| Type | Description |
|---|---|
| byte |
SendData(byte[])
Sends the given data to the device.
Declaration
public void SendData(byte[] data)
Parameters
| Type | Name | Description |
|---|---|---|
| byte | data |
SetBluetoothPassword(string)
Sets the Bluetooth password of the Digi device in order to connect to it.
Declaration
public void SetBluetoothPassword(string password)
Parameters
| Type | Name | Description |
|---|---|---|
| string | password |
ToString()
Returns the string representation of this device.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | The string representation of this device. |
Overrides
Events
DataReceived
Represents the method that will handle the Bluetooth data received event.
Declaration
public event EventHandler<DataReceivedEventArgs> DataReceived
Event Type
| Type | Description |
|---|---|
| EventHandlerDataReceivedEventArgs |