Class BluetoothInterface
Class that handles the connection with the XBee module through Bluetooth Low Energy.
Inheritance
Implements
Inherited Members
Namespace: XBeeLibrary.Xamarin.Connection.Bluetooth
Assembly: XBeeLibrary.Xamarin.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 |
|---|---|---|
| Plugin.BLE.Abstractions.Contracts.IDevice | device | Bluetooth device. |
See Also
BluetoothInterface(String)
Class constructor. Instantiates a new BluetoothInterface object with the given Bluetooth device GUID.
Declaration
public BluetoothInterface(string deviceAddress)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | deviceAddress | The address of the Bluetooth device. It must follow the
format |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | If |
Properties
IsOpen
Returns whether the connection interface is open or not.
Declaration
public bool IsOpen { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
See Also
Stream
Returns the bluetooth connection interface stream to read and write data.
Declaration
public DataStream Stream { get; }
Property Value
| Type | Description |
|---|---|
| DataStream |
See Also
Methods
Close()
Closes the connection interface associated with this bluetooth device.
Declaration
public void Close()
Exceptions
| Type | Condition |
|---|---|
| XBeeException | If there is any XBee error. |
See Also
GetConnectionType()
Returns the connection type of this bluetooth XBee interface.
Declaration
public ConnectionType GetConnectionType()
Returns
| Type | Description |
|---|---|
| ConnectionType | The connection type of this bluetooth XBee interface. |
See Also
Open()
Opens the connection interface associated with this Bluetooth device.
Declaration
public void Open()
Exceptions
| Type | Condition |
|---|---|
| System.Exception | If there is any problem opening the connection with this bluetooth device. |
| XBeeException | If there is any XBee error. |
See Also
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 |
|---|---|---|
| System.Byte[] | data | The byte array to store the read data. |
Returns
| Type | Description |
|---|---|
| System.Int32 | The number of bytes read. |
See Also
ReadData(Byte[], Int32, Int32)
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 |
|---|---|---|
| System.Byte[] | data | The byte array to store the read data. |
| System.Int32 | offset | The start offset in data array at which the data is written. |
| System.Int32 | length | Maximum number of bytes to read. |
Returns
| Type | Description |
|---|---|
| System.Int32 | The number of bytes read. |
See Also
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 |
|---|---|---|
| System.Byte[] | key | Session key. |
| System.Byte[] | txNonce | TX nonce used as prefix of the counter block. |
| System.Byte[] | rxNonce | RX nonce used as prefix of the counter block. |
WriteData(Byte[])
Writes the given data in the bluetooth connection interface.
Declaration
public void WriteData(byte[] data)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | data | The data to be written in the connection interface. |
See Also
WriteData(Byte[], Int32, Int32)
Writes the given data in the bluetooth connection interface.
Declaration
public void WriteData(byte[] data, int offset, int length)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | data | The data to be written in the connection interface. |
| System.Int32 | offset | The start offset in the data to write. |
| System.Int32 | length | The number of bytes to write. |
Exceptions
| Type | Condition |
|---|---|
| XBeeException | If there is any XBee error. |