Skip to content

DeviceSignature Struct

Lucas LucidVR edited this page Jan 6, 2023 · 4 revisions

Reference: DeviceSignature

The DeviceSignature struct is a data type representing the signature of a paired (but not necessarily yet connected) Bluetooth device.

Here it is:

public struct DeviceSignature
{
    public string name;
    public string mac;
}

The struct has two fields, mac, and name.


string name

A string representing the name of the Bluetooth device.

string mac

A string representing the MAC address of the Bluetooth device.


The easiest way to obtain a valid DeviceSignature is to get a list of them by calling GetPairedDevices on a SingularityManager.

List<DeviceSignature> pairedDevices = mySingularityManager.GetPairedDevices();
DeviceSignature myDevice = pairedDevices[0]; //if you just wanted the first device

//If you are looking for a device with a specific name (in this case exampleDeviceName):
for (int i = 0; i < pairedDevices.Count; i++)
{
    if (pairedDevices[i].name == "exampleDeviceName")
    {
        myDevice = pairedDevices[i];
        break;
    }
}

Example usage:
Let's say you have a DeviceSignature called myDevice that you got from running GetPairedDevices on a singularity manager called mySingularityManager.

Debug.Log(myDevice.name); //Prints the name of your device (e.g. Lucas-ESP32)
Debug.Log(myDevice.mac);  //Prints the mac address of your device
mySingularityManager.ConnectToDevice(myDevice) //Attempts to connect to this device over bluetooth
Clone this wiki locally