Digi IoT Library for .NET MAUI API reference

Show / Hide Table of Contents

Class BluetoothInterface

Class that handles the connection with a Digi device through Bluetooth Low Energy.

Inheritance
object
BluetoothInterface
Implements
XBeeLibrary.Core.Connection.IConnectionInterface
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
Namespace: DigiIoTDigiIoT.MauiDigiIoT.Maui.ConnectionBluetooth
Assembly: DigiIoT.Maui.dll
Syntax
public class BluetoothInterface : IConnectionInterface

Constructors

BluetoothInterface(IDevice)

Class constructor. Instantiates a new BluetoothInterface object with the given device.

Declaration
public BluetoothInterface(IDevice device)
Parameters
Type Name Description
IDevice device

Bluetooth device.

See Also
IDevice

BluetoothInterface(Guid)

Class constructor. Instantiates a new BluetoothInterface object with the given Bluetooth device GUID.

Declaration
public BluetoothInterface(Guid deviceGuid)
Parameters
Type Name Description
Guid deviceGuid

The Bluetooth device GUID.

See Also
Guid

BluetoothInterface(string)

Class constructor. Instantiates a new BluetoothInterface object with the given Bluetooth device GUID.

Declaration
public BluetoothInterface(string deviceAddress)
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.

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

IsOpen

Returns whether the connection interface is open or not.

Declaration
public bool IsOpen { get; }
Property Value
Type Description
bool
See Also
Close()
Open()

Stream

Returns the bluetooth connection interface stream to read and write data.

Declaration
public DataStream Stream { get; }
Property Value
Type Description
XBeeLibrary.Core.Connection.DataStream
See Also
XBeeLibrary.Core.Connection.DataStream

Methods

Close()

Closes the connection interface associated with this bluetooth device.

Declaration
public void Close()
Exceptions
Type Condition
DigiIoTException

If there is any error closing the connection.

See Also
IsOpen
Open()

GetConnectionType()

Returns the connection type of this bluetooth interface.

Declaration
public ConnectionType GetConnectionType()
Returns
Type Description
XBeeLibrary.Core.Connection.ConnectionType

The connection type of this bluetooth interface.

See Also
XBeeLibrary.Core.Connection.ConnectionType

Open()

Opens the connection interface associated with this Bluetooth device.

Declaration
public void Open()
Exceptions
Type Condition
DigiIoTException

If there is any problem opening the connection with this bluetooth device.

See Also
IsOpen
Close()

ReadData(byte[])

Reads data from the bluetooth connection interface and stores it in the provided byte array returning the number of read bytes.

Declaration
public int ReadData(byte[] data)
Parameters
Type Name Description
byte data

The byte array to store the read data.

Returns
Type Description
int

The number of bytes read.

See Also
ReadData(byte[], int, int)

ReadData(byte[], int, int)

Reads the given number of bytes at the given offset from the bluetooth connection interface and stores it in the provided byte array returning the number of read bytes.

Declaration
public int ReadData(byte[] data, int offset, int length)
Parameters
Type Name Description
byte data

The byte array to store the read data.

int offset

The start offset in data array at which the data is written.

int length

Maximum number of bytes to read.

Returns
Type Description
int

The number of bytes read.

See Also
ReadData(byte[])

SetEncryptionKeys(byte[], byte[], byte[])

Sets the encryption keys and starts to encrypt the communication with the module.

Declaration
public void SetEncryptionKeys(byte[] key, byte[] txNonce, byte[] rxNonce)
Parameters
Type Name Description
byte key

Session key.

byte txNonce

TX nonce used as prefix of the counter block.

byte rxNonce

RX nonce used as prefix of the counter block.

ToString()

Returns the string representation of the Bluetooth interface.

Declaration
public override string ToString()
Returns
Type Description
string

The string representation of the Bluetooth interface.

Overrides
object.ToString()

WriteData(byte[])

Writes the given data in the bluetooth connection interface.

Declaration
public void WriteData(byte[] data)
Parameters
Type Name Description
byte data

The data to be written in the connection interface.

Exceptions
Type Condition
DigiIoTException

If there is any error writing data.

See Also
WriteData(byte[], int, int)

WriteData(byte[], int, int)

Writes the given data in the bluetooth connection interface.

Declaration
public void WriteData(byte[] data, int offset, int length)
Parameters
Type Name Description
byte data

The data to be written in the connection interface.

int offset

The start offset in the data to write.

int length

The number of bytes to write.

Exceptions
Type Condition
DigiIoTException

If there is any error writing data.

See Also
WriteData(byte[])

Implements

XBeeLibrary.Core.Connection.IConnectionInterface

See Also

XBeeLibrary.Core.Connection.IConnectionInterface
Product page More documentation Official site About Digi Contact us Support
©2023, Digi International Inc. All rights reserved.
Digi International Inc.