Neonode zForce(TM) SDK
Classes | Macros | Typedefs | Enumerations | Functions
Connection.h File Reference

Handles connections. More...

Go to the source code of this file.


struct  ConnectionMessage
 Connection messages struct. More...
struct  Connection
 The main Connection struct. More...


typedef enum ConnectionStatus ConnectionStatus
typedef struct ConnectionMessage ConnectionMessage
typedef struct Connection Connection


enum  ConnectionStatus { Connected, Disconnected, ConnectionFault }
 Connection events. More...


DLLINTERNAL ConnectionMessageConnectionMessage_New (ConnectionStatus connectionStatus, uint32_t errorCode)
 Internal call used to create a new ConnectionMessage. More...
DLLEXTERNAL ConnectionConnection_New (char *connectionString, char *protocolString, char *dataFrameType)
 Create a new Connection. More...

Detailed Description

Handles connections.

Handles connections, acts as the glue between devices, protocols and transports. Also handles queues to notify software about incoming messages.

Typedef Documentation

typedef struct Connection Connection
See also
struct Connection
See also
struct ConnectionMessage
See also
enum ConnectionStatus

Enumeration Type Documentation

Connection events.


Status changed to Connected.


Status changed to Disconnected.


Connection Fault. Only set internally.

Function Documentation

DLLEXTERNAL Connection* Connection_New ( char *  connectionString,
char *  protocolString,
char *  dataFrameType 

Create a new Connection.

This call does not actually connect, it just creates the binding between the Protocol and Transport.

On failure, errno is set.

  • EUNKNOWNTRANSPORT - Unknown transport.
  • EOUTOFMEMORY - Out of memory.
  • EBADNAME - The protocolString does not have a protocol name of the correct format.
  • EUNKNOWNPROTOCOL - There is no defined protocol with a name which matches the name in protocolString.
  • EMUTEXLOCKFAILED - We couldn't lock a mutex we need for an internal critical section. This should not happen.
  • EBADMUTEX - We tried to use a mutex internally but it wasn't a valid mutex. This should not happen.

Each Transport and Protocol has its own options.

Example to connect to a sensor over Hid using Asn1 as protocol.

HidPipeTransport (hidpipe) has the following options:

  • vid - Vendor ID. Current neonode sensors have VID 0x1536.
  • pid - Product ID. Current neonode sensors have PID 0x0101.
  • index - If the computer has multiple connected Neonode sensors, the first one has index 0, the second has index 1, etc. Note: The order is decided by the Operating System.

Asn1Protocol (asn1) currently has no options.

StreamingDataFrame (Streaming) is the DataFrame type used by both HidPipeTransport and Asn1Protocol.

MyConnection = Connection_New (

connectionStringA Transport specific connection string.
protocolStringA Protocol specific prototocol string.
dataFrameTypeWhich Data Frame Type the Transport and Protocol uses.
Connection pointer or NULL if failed. See errno.
DLLINTERNAL ConnectionMessage* ConnectionMessage_New ( ConnectionStatus  connectionStatus,
uint32_t  errorCode 

Internal call used to create a new ConnectionMessage.

On failure, errno is set.

connectionStatusConnectionStatus of message.
errorCodeErrorCode of message.
A pointer to the new ConnectionMessage.