Methods

List of methods available in the base Cortex class

Start

Initialize connection to the Emotiv launcher, enabling use of the API. It is best to delay other functionality until the connection has been authorized, or until the connection state has been updated to authorized.

void Start(string clientId, string clientSecret, string appURL = "wss://localhost:6868", string emotivAppsPath = "C:\\Program Files\\EmotivApps", bool logs = false, bool streamPrint = false, string license = "");
Parameter
Description

clientId

client id of your cortex application

clientSecret

client secret of your cortex application

appURL

url through which to connect to the emotiv launcher

emotivAppsPath

filepath where the emotiv launcher is installed, used to check if the launcher is installed

logs

print logs to the debug console

streamPrint

print all incoming stream data to the debug console

license

cortex api license, required for EEG access, which the plugin does not currently support

Example:

using UnityEngine;
using CortexPlugin;

public class ConnectToCortex : MonoBehaviour
{
    [Header("credentials")]
    public string clientId;
    public string clientSecret;

    [Header("settings")]
    public bool printLogs;
    public bool printDataStreams;

    void Awake()
    {
        Cortex.Start(clientId, clientSecret, logs: printLogs, streamPrint: printDataStreams);
    }

    private void OnApplicationQuit()
    {
        Cortex.Stop();
    }
}

Query Headsets

Queries a list of available headsets, triggering Headset Query Result.

-> Headset Query Result

void QueryHeadsets();

Start Session

Opens a session and starts data streams with the headset, provided it has been connected. If successful, will trigger Data Stream Started.

->-> Data Stream Started

void StartSession(string headsetId);

Example:

public void PairWithHeadset(Headset target)
{
    if(target.status == "connected")
    {
        Cortex.StartSession(target.headsetId);
    }
}

Connect Device

Pairs a device with the Emotiv launcher, needed to start a session. Devices may already be connected, which will result in an error event.

-> Device Connected

void ConnectDevice(string headsetId);

Example:

string pairingHeadset;

public void PairWithHeadset(Headset target)
{
    if(target.status == "connected")
    {
        Cortex.StartSession(target.headsetId);
    }
    else
    {
        pairingHeadset = target.headsetId;
        Cortex.ConnectDevice(target.headsetId);
        Cortex.HeadsetConnected += PairWithNewlyConnectedHeadset;
    }
}

void PairWithNewlyConnectedHeadset(HeadsetConnectEventArgs args)
{
    if (args.HeadsetId != pairingHeadset)
        return;

    Cortex.StartSession(args.HeadsetId);
    pairingHeadset = "";
    Cortex.HeadsetConnected -= PairWithNewlyConnectedHeadset;
}

End Session

Ends a headset session.

-> Data Stream Ended

void EndSession(string sessionId);

End Session By Headset

End a headset session with a headset id rather than a session id.

-> Data Stream Ended

void EndSessionByHeadset(string headsetId);

Get Session By Headset

Gets the session id associated with the given headset if it exists.

string GetSessionByHeadset(string headsetId);

End Most Recent Session

Ends the session that was started most recently, regardless of activity.

-> Data Stream Ended

void EndMostRecentSession();

Stop

Closes the Cortex connection.

void Stop();

Last updated