Connecting to Omnicept

On this page:


Using the GliaBehaviour

The easiest way to get HP Omnicept running and connected is using the GliaBehaviour script that comes with the Unity SDK. This script will use the configured credentials and will automatically connect to the Omnicept runtime. Also, it exposes events and functions so you can consume the Omnicept headset sensor data.

Adding GliaBehaivour

Simply add the script to any GameObject on your scene and you will see on the editor all the unity Events that you can use.

Handling Connection Events

When using GliaBehaivour you can receive the following events that will report :

  • ConnectEvent: Connected successfully to Omnicept Runtime

  • DisconnectEvent: Disconnected from Omnicept Runtime

  • ConnectionFailureEvent: Failed to connect to the Omnicept Runtime


Handling the connection yourself


First, let's create a task and create glia client and then a glia cache value:

SessionLicense sessionLicense = new SessionLicense("ClientID", "AccessKey", LicensingModel.Rev_Share, Application.isEditor);

m_isConnected = false;
Debug.Log("Connecting to service");
m_connectTask = Task.Run( () =>
        m_gliaClient = new Glia("UnityClient", sessionLicense);
        m_gliaValCache = new GliaValueCache(m_gliaClient.Connection);
        Debug.Log("Connected To Omnicept Runtime");

Now we want to wait for the task or poll the task status to see if it has been completed successfully. If the task fails you can query the exception to get the error that has caused the connection failure.

Getting data

Once connected you can Retrieve messages from the connection as follows:

ITransportMessage RetrieveMessage()
    ITransportMessage msg = null;
    if (m_gliaValCache != null)
            msg = m_gliaValCache.GetNext();
        catch (HP.Omnicept.Errors.TransportError e)
            enabled = false;
            if (eventHasTarget(OnDisconnect))
    return msg;

Now that we have the message as an ITransportMessage we can check the message type and build the concrete message type as follows:

switch (msg.Header.MessageType)
    case MessageTypes.ABI_MESSAGE_HEART_RATE:
        if (OnHeartRate != null)
            var heartRate = m_gliaClient.Connection.Build(msg);

With this, we have our data ready to be used. If you want to find more details on a custom implementation of the connection replicating the GliaBehaivour is a good way to get started.


Subscription List

By default, GliaBehaivour subscribes to all available message types. A user application may also choose to subscribe to only specific message types. A SubscriptionList class is provided for custom message type subscriptions after the client program has been successfully connected to the Glia runtime. 

A SubscriptionList object contains a List of Subscription objects which specify the subscription information for each message type individually.  A complete Subscription entity contains the following information:

  • Message Type: A mandatory field to specify the target message type of the subscription.
  • Version: An optional field to specify the target version of the message of the subscription. If the Version field is empty, only the latest available version will be automatically assigned by Omnicept runtime.
  • Sensor Info: An optional field to specify the target sensor that generates the message of the message type. If Sensor Info filed is empty, ANY sensor generating the message of the message type will be delivered.
  • Sender: An optional field to specify the target sender that sends the message of the message type. If the Sender field is empty, ANY sensor device generating the message of the message type will be delivered. 


Upon receiving the subscription request from the client, Omnicept runtime will process and reply with a SubscriptionResultList message to either accept or reject the subscription of each message type individually. Subscriptions to individual messages may be accepted or rejected due to such factors as the availability of the version of the message type or the licensing privilege of the client, as communicated via the ‘Result Error’ field. Developers should set up the GliaBehaviour script message events to handle the returned SubscriptionResultList message.




DataVault is designed so you can share back data with HP for us to keep improving our inference engines. By default, no data is shared with HP and no data is stored. With DataVault we will enable the calls for the developers to manually start/stop data collection.

DataVault calls are exposed on the SDK but will not work unless this has been enabled on your console profile by the HP team. We will roll out this feature and give more information once this is exposed to a broad audience.