Unity SDK  v1.2.0
Loading...
Searching...
No Matches
WeArt.Bluetooth.BluetoothManager Class Reference

BluetoothManager — is a main class for BLE interactions. More...

Classes

class  DeviceStatusInfo
 

Public Member Functions

delegate void dDeviceStatus< DeviceStatusInfo > (DeviceStatusInfo deviceStatusInfo)
 Event when Device status is changing.
 
 BluetoothManager (Action< BleDevice > deviceConnectionHandler, Action< BleDevice > deviceReadyHandler, Action< BleDevice > deviceDisconnectionHandler, Action< int, string > errorReceivedHandler)
 Constructor of the class, calls the request of required permissions from device and init the core variable for further work.
 
string GetPluginVersion ()
 Gets the current version of BLE Android plugin.
 
void StartScanning (Action< BleDevice > deviceFoundHandler, Action< BleDevice > deviceRemovedHandler)
 Starts the scan for bluetooth devices.
 
void StopScanning ()
 Stops the scan for bluetooth devices.
 
List< BleDeviceGetAvailableBleDevices ()
 Gets the list with currently available devices.
 
void ConnectToDevice (string deviceMacAddress, Action< BleDevice, sbyte[]> dataReceiveHandler)
 Connects to device using its MAC address and callback to handle data from device.
 
void ConnectToDevice (BleDevice device, Action< BleDevice, sbyte[]> dataReceiveHandler)
 Connects to device using its MAC address and callback to handle data from device.
 
void DisconnectDevice (string deviceMacAddress)
 Disconnects device by its MAC address.
 
void DisconnectDevice (BleDevice device)
 Disconnects device.
 
void SendData (string deviceMacAddress, byte[] sendingData)
 Sends data to connected device by its MAC Address.
 
void SendData (BleDevice device, byte[] sendingData)
 Sends data to connected device.
 
bool ContainsConnectedDevice (BleDevice device)
 Checks if such BleDevice is connected to this BluetoothManager.
 
bool ContainsConnectedDevice (string deviceMacAddress)
 Checks if such MAC Address is connected to this BluetoothManager.
 
string GetConnectedDeviceName (string deviceMacAddress)
 Returns connected device name by its MAC Address or empty string if it is not connected.
 
string GetDeviceNameFromScanner (string deviceMacAddress)
 Returns name by its MAC Address or empty string if it is not scanned by BLE plugin.
 
BleDevice GetDeviceFromScannedDevices (string deviceMacAddress)
 Gets device from ScannedDeviceList by its MAC Address. If this device is absent in the list — creates and returns the new one.
 
DeviceStatus GetDeviceStatus (string deviceMacAddress)
 Returns known DeviceStatus by its MAC Address.
 
DeviceStatus GetDeviceStatus (BleDevice bleDevice)
 Returns known BLE Device Status.
 
bool CheckDeviceConnectionInPlugin (BleDevice bleDevice)
 Checks if the device is connected with plugin. Useful to handle the delayed OnDisconnected events.
 
string ExtractMacAddressFromMessage (string input)
 Extracts the MAC Addresses from provided string and returns the first match or returns null if there is no MAC Address.
 

Properties

bool IsScanning [get]
 
List< BleDeviceListOfScannedDevices = new List<BleDevice>() [get]
 List of devices that were scanned by BluetoothManager within current Application session.
 
List< BleDeviceConnectedDevices = new List<BleDevice>() [get]
 List of connected BleDevices.
 

Events

dDeviceStatus< DeviceStatusInfoDeviceStatusInfoReady
 

Detailed Description

BluetoothManager — is a main class for BLE interactions.

Constructor & Destructor Documentation

◆ BluetoothManager()

WeArt.Bluetooth.BluetoothManager.BluetoothManager ( Action< BleDevice deviceConnectionHandler,
Action< BleDevice deviceReadyHandler,
Action< BleDevice deviceDisconnectionHandler,
Action< int, string >  errorReceivedHandler 
)
inline

Constructor of the class, calls the request of required permissions from device and init the core variable for further work.

Parameters
deviceConnectionHandlerMethod to call when connection to device is finished.
deviceReadyHandlerMethod to call when device is ready for transhipment.
deviceDisconnectionHandlerMethod to call when the disconnection from devices is finished(optional).

///

Parameters
errorReceivedHandlerMethod to call when error is occurred.

Member Function Documentation

◆ CheckDeviceConnectionInPlugin()

bool WeArt.Bluetooth.BluetoothManager.CheckDeviceConnectionInPlugin ( BleDevice  bleDevice)
inline

Checks if the device is connected with plugin. Useful to handle the delayed OnDisconnected events.

Parameters
bleDevice
Returns

◆ ConnectToDevice() [1/2]

void WeArt.Bluetooth.BluetoothManager.ConnectToDevice ( BleDevice  device,
Action< BleDevice, sbyte[]>  dataReceiveHandler 
)
inline

Connects to device using its MAC address and callback to handle data from device.

Parameters
deviceBle device to connect.
dataReceiveHandlerMethod to call when data received from device.

◆ ConnectToDevice() [2/2]

void WeArt.Bluetooth.BluetoothManager.ConnectToDevice ( string  deviceMacAddress,
Action< BleDevice, sbyte[]>  dataReceiveHandler 
)
inline

Connects to device using its MAC address and callback to handle data from device.

Parameters
deviceMacAddressMAC Address of device.
dataReceiveHandlerMethod to call when data received from device.

◆ ContainsConnectedDevice() [1/2]

bool WeArt.Bluetooth.BluetoothManager.ContainsConnectedDevice ( BleDevice  device)
inline

Checks if such BleDevice is connected to this BluetoothManager.

Parameters
deviceBLE Device to be checked
Returns
"True" if connected and "False" otherwise.

◆ ContainsConnectedDevice() [2/2]

bool WeArt.Bluetooth.BluetoothManager.ContainsConnectedDevice ( string  deviceMacAddress)
inline

Checks if such MAC Address is connected to this BluetoothManager.

Parameters
deviceMacAddressMAC Address to be checked.
Returns
"True" if connected and "False" otherwise.

◆ dDeviceStatus< DeviceStatusInfo >()

delegate void WeArt.Bluetooth.BluetoothManager.dDeviceStatus< DeviceStatusInfo > ( DeviceStatusInfo  deviceStatusInfo)

Event when Device status is changing.

◆ DisconnectDevice() [1/2]

void WeArt.Bluetooth.BluetoothManager.DisconnectDevice ( BleDevice  device)
inline

Disconnects device.

Parameters
deviceBLE device to disconnect.

◆ DisconnectDevice() [2/2]

void WeArt.Bluetooth.BluetoothManager.DisconnectDevice ( string  deviceMacAddress)
inline

Disconnects device by its MAC address.

Parameters
deviceMacAddressMAC address of device to disconnect.

◆ ExtractMacAddressFromMessage()

string WeArt.Bluetooth.BluetoothManager.ExtractMacAddressFromMessage ( string  input)
inline

Extracts the MAC Addresses from provided string and returns the first match or returns null if there is no MAC Address.

Parameters
input
Returns

◆ GetAvailableBleDevices()

List< BleDevice > WeArt.Bluetooth.BluetoothManager.GetAvailableBleDevices ( )
inline

Gets the list with currently available devices.

Returns
List with scanned BleDevices. Devices without name are ignored.

◆ GetConnectedDeviceName()

string WeArt.Bluetooth.BluetoothManager.GetConnectedDeviceName ( string  deviceMacAddress)
inline

Returns connected device name by its MAC Address or empty string if it is not connected.

Parameters
deviceMacAddress
Returns

◆ GetDeviceFromScannedDevices()

BleDevice WeArt.Bluetooth.BluetoothManager.GetDeviceFromScannedDevices ( string  deviceMacAddress)
inline

Gets device from ScannedDeviceList by its MAC Address. If this device is absent in the list — creates and returns the new one.

Parameters
deviceMacAddress
Returns

◆ GetDeviceNameFromScanner()

string WeArt.Bluetooth.BluetoothManager.GetDeviceNameFromScanner ( string  deviceMacAddress)
inline

Returns name by its MAC Address or empty string if it is not scanned by BLE plugin.

Parameters
deviceMacAddress
Returns

◆ GetDeviceStatus() [1/2]

DeviceStatus WeArt.Bluetooth.BluetoothManager.GetDeviceStatus ( BleDevice  bleDevice)
inline

Returns known BLE Device Status.

Parameters
bleDevice
Returns

◆ GetDeviceStatus() [2/2]

DeviceStatus WeArt.Bluetooth.BluetoothManager.GetDeviceStatus ( string  deviceMacAddress)
inline

Returns known DeviceStatus by its MAC Address.

Parameters
deviceMacAddress
Returns

◆ GetPluginVersion()

string WeArt.Bluetooth.BluetoothManager.GetPluginVersion ( )
inline

Gets the current version of BLE Android plugin.

Returns

◆ SendData() [1/2]

void WeArt.Bluetooth.BluetoothManager.SendData ( BleDevice  device,
byte[]  sendingData 
)
inline

Sends data to connected device.

Parameters
deviceConnected device.
sendingDataData to be sent to device.

◆ SendData() [2/2]

void WeArt.Bluetooth.BluetoothManager.SendData ( string  deviceMacAddress,
byte[]  sendingData 
)
inline

Sends data to connected device by its MAC Address.

Parameters
deviceMacAddressMAC address of the connected device.
sendingDataData to be sent to device.

◆ StartScanning()

void WeArt.Bluetooth.BluetoothManager.StartScanning ( Action< BleDevice deviceFoundHandler,
Action< BleDevice deviceRemovedHandler 
)
inline

Starts the scan for bluetooth devices.

Parameters
deviceFoundHandlerMethod to call when new device is found.

///

Parameters
deviceRemovedHandlerMethod to call when discovered device stops being available for connection.

◆ StopScanning()

void WeArt.Bluetooth.BluetoothManager.StopScanning ( )
inline

Stops the scan for bluetooth devices.

Property Documentation

◆ ConnectedDevices

List<BleDevice> WeArt.Bluetooth.BluetoothManager.ConnectedDevices = new List<BleDevice>()
get

List of connected BleDevices.

◆ IsScanning

bool WeArt.Bluetooth.BluetoothManager.IsScanning
get

◆ ListOfScannedDevices

List<BleDevice> WeArt.Bluetooth.BluetoothManager.ListOfScannedDevices = new List<BleDevice>()
get

List of devices that were scanned by BluetoothManager within current Application session.

Event Documentation

◆ DeviceStatusInfoReady

dDeviceStatus<DeviceStatusInfo> WeArt.Bluetooth.BluetoothManager.DeviceStatusInfoReady

The documentation for this class was generated from the following file: