Digi IoT Library for .NET MAUI API reference

Show / Hide Table of Contents

Class DigiBLEDevice

This class represents a generic Digi device with Bluetooth Low Energy (BLE) connectivity.

Inheritance
object
DigiBLEDevice
ConnectCoreBLEDevice
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
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 null).

Remarks

The Bluetooth password must be provided before calling the Connect() method, either through this constructor or the SetBluetoothPassword(string) method.

See Also
IDevice

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 null).

Remarks

The Bluetooth password must be provided before calling the Connect() method, either through this constructor or the SetBluetoothPassword(string) method.

See Also
Guid

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 00112233AABB or 00:11:22:33:AA:BB for the address or 01234567-0123-0123-0123-0123456789AB for the GUID.

string password

Bluetooth password (can be null).

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 deviceAddress does not follow the format 00112233AABB or 00:11:22:33:AA:BB or 01234567-0123-0123-0123-0123456789AB.

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
object.ToString()

Events

DataReceived

Represents the method that will handle the Bluetooth data received event.

Declaration
public event EventHandler<DataReceivedEventArgs> DataReceived
Event Type
Type Description
EventHandlerDataReceivedEventArgs
Product page More documentation Official site About Digi Contact us Support
©2023, Digi International Inc. All rights reserved.
Digi International Inc.