Connecting to the Cortex API
Create a WebSocket client and connect to localhost on the port 6868, using the wss protocol.
Please note that Cortex only supports the WebSocket Secure (wss) protocol. It doesn't support the plain WebSocket (ws) protocol without encryption.
The Cortex web socket server uses a self-signed certificate. When you install Emotiv softwares, the installer has already installed the Emotiv Root CA file and ask the system to trust it, so most of the time, your application don't need to configure anything else. However, for some programming languagues or for remote connections to Pi, you must configure a custom Certificate Authorities (CA) to trust Cortex websocket connection.
Since 2.7.1 release, we support remote connections to Cortex running on Raspberry Pi device. It requires some steps:
- Connect using the IP address:
- Only applied if the IP address of your Raspberry Pi device is in the below range:
- Create a WebSocket client and connect to
<IP address of Raspberry Pi device>on the port 6868, using the wss protocol.
- Connect using the DNS name:
- Can be applied for any value of IP address of your Raspberry Pi device.
- Add this line into the host file of the desktop machine:
<IP address of Raspberry Pi device> emotiv-cortex.remote
- Create a WebSocket client and connect to emotiv-cortex.remote on the port 6868, using the wss protocol.
Call methods, with or without parameters, and Cortex sends back a result or an error.
Call an API method by sending a JSON object with these fields:
The response from Cortex is a JSON object with these fields:
Here is a simple fictional example:
The rest of this documentation will show you what methods are available, what parameters they take, and how to use these methods.