Neonode zForce(TM) SDK
Public Attributes | List of all members
Connection Struct Reference

The main Connection struct. More...

#include <Connection.h>

Collaboration diagram for Connection:
Collaboration graph
[legend]

Public Attributes

zForcezForce
 Pointer to zForce instance.
 
TransportTransport
 Transport this Connection uses.
 
ProtocolProtocol
 Protocol this Connection uses.
 
QueueConnectionQueue
 Queue to report Connection events.
 
QueueDeviceQueue
 Queue to report Device events.
 
Device ** Devices
 List of Devices.
 
uint32_t NumberOfDevices
 Number of Devices detected.
 
bool IsConnected
 Connected to unit.
 
zForceMutexMessageFilterMutex
 Message Filter Mutex.
 
DeviceFilterDevice
 Which Device the filter is set to.
 
MessageType FilterMessageType
 Which Message the filter is set to.
 
uint64_t LastResponseSerialNumber
 Serial number of last processed response message.
 
void(* Destructor )(Connection *self)
 Destructor. More...
 
bool(* AddDevice )(Connection *self, Device *device)
 Internal call to add a Device to the Device list. More...
 
Device *(* FindDevice )(Connection *self, DeviceType deviceType, uint32_t deviceIndex)
 Find a Device with a specified Type/Index combination. More...
 
bool(* ReceiveDataFrame )(Connection *self, DataFrame *dateFrame)
 Internal call to receive a DataFrame from the Transport layer. More...
 
bool(* SendDataFrame )(Connection *self, DataFrame *dataFrame)
 Internal call to send a DataFrame using the Transport layer. More...
 
bool(* SetMessageFilter )(Connection *self, Device *device, MessageType messageType)
 Internal call to set the Message Filter. More...
 
void(* ClearMessageFilter )(Connection *self)
 Internal call to clear the Message Filter. More...
 
bool(* EnqueueMessage )(Connection *self, Device *device, Message *message)
 Internal call to Enqueue a Message on the Device Queue. More...
 
bool(* Connect )(Connection *self)
 Connect to the unit. More...
 
bool(* Disconnect )(Connection *self)
 Disconnect from the unit. More...
 
void(* UnknownCommand )(Connection *self)
 Internal call to signal a Timeout. More...
 
void(* Timeout )(Connection *self)
 Internal call to signal an Unknown Command. More...
 
void(* SetTimeout )(Connection *self, uint64_t relativeTimeoutMilliSeconds)
 Internal call to set the Timeout. More...
 
void(* SignalConnectionEstablished )(Connection *self)
 Internal call to signal that the connection is established. More...
 
void(* SignalConnectionFault )(Connection *self)
 Internal call to signal that the connection is now faulty. More...
 
ConnectionStatus Status
 The status of the connection.
 

Detailed Description

The main Connection struct.

Member Data Documentation

bool( * Connection::AddDevice) (Connection *self, Device *device)

Internal call to add a Device to the Device list.

On error, errno is set.

Parameters
selfPointer to the struct itself.
deviceThe Device to add.
Returns
True if successful, false if not. See errno.
void( * Connection::ClearMessageFilter) (Connection *self)

Internal call to clear the Message Filter.

This function will always clear the filter, even if it was not set to begin with so this function cannot fail.

On failure, errno is set.

Parameters
selfPointer to the struct itself.
Returns
No return value.
bool( * Connection::Connect) (Connection *self)

Connect to the unit.

Connect to the unit using the previously specified Protocol and Transport. This call asynchronously starts the connection process. The call exits immediately and if there is a direct connection problem, for example that the connection is already established, then the call exits with false and errno is set. If there is no immediate error, the call returns true but the connection cannot be considered established until the ConnectionQueue has returned with a message saying status Connected.

Errno list:

void( * Connection::Destructor) (Connection *self)

Destructor.

On error, errno is set.

Parameters
selfPointer to the struct itself.
Returns
No return value.
bool( * Connection::Disconnect) (Connection *self)

Disconnect from the unit.

Disconnect the connection. This call is asynchronous and cannot be considered complete until the ConnectionQueue has reported status Disconnected.

On failure, errno is set.

bool( * Connection::EnqueueMessage) (Connection *self, Device *device, Message *message)

Internal call to Enqueue a Message on the Device Queue.

On failure, errno is set.

Parameters
selfPointer to the struct itself.
deviceThe Device the message corresponds to.
messageThe Message to enqueue.
Returns
True if successful, false if failed. See errno.
Device*( * Connection::FindDevice) (Connection *self, DeviceType deviceType, uint32_t deviceIndex)

Find a Device with a specified Type/Index combination.

Find a Device with a specificed Type/Index combination.
For Platform and Lighting devices, the Type/Index are searched for directly.
For Core, Air and Plus devices, the Type/Index are also searched for directly, but they can also be found using a meta Sensor device type. Sensor is not a real device type, and contains all functionality that is shared between all Sensor types (Core, Air and Plus).
Type = Sensor, Index = 0 is the first Sensor in the list,
Type = Sensor, Index = 1 is the second Sensor. The "real" Device Index is not used for this search when searching for a Sensor.

Examples: A unit that contains 1 Platform Device, 2 Core Devices, 1 Air Device and 1 Lighting Device:
To find the Platform Device, look for Type = Platform, Index = 0.
To find the Lighting Device, look for Type = Lighting, Index = 0.
To find the first Core Device, look for Type = Core, Index = 0.
To find the second Core Device, look for Type = Core, Index = 1.
To find the Air Device, look for Type = Air, Index = 0.
An alternative is to look for Sensor Devices 0, 1 and 2, and then looking at the type of the returned Device.
There is no guarantee that the Sensor Devices are returned in the same order every time.

On error, errno is set.

Parameters
selfPointer to the struct itself.
deviceTypeThe Device Type to find.
deviceIndexThe Device Index to find.
Returns
The Device or NULL if error. See errno.
bool( * Connection::ReceiveDataFrame) (Connection *self, DataFrame *dateFrame)

Internal call to receive a DataFrame from the Transport layer.

Internal call to receive a DataFrame from the Transport layer.

On failure, errno is set.

Parameters
selfPointer to the struct itself.
dataFrameThe received DataFrame.
Returns
True if successful, false if failed. See errno.
bool( * Connection::SendDataFrame) (Connection *self, DataFrame *dataFrame)

Internal call to send a DataFrame using the Transport layer.

On failure, errno is set.

Parameters
selfPointer to the struct itself.
dataFrameThe DataFrame to send.
Returns
True if successful, false if failed. See errno.
bool( * Connection::SetMessageFilter) (Connection *self, Device *device, MessageType messageType)

Internal call to set the Message Filter.

On failure, errno is set.

Parameters
selfPointer to the struct itself.
deviceThe Device to set the filter to.
messageTypeThe MessageType to set the filter to.
Returns
True if successful, false if failed. See errno.
void( * Connection::SetTimeout) (Connection *self, uint64_t relativeTimeoutMilliSeconds)

Internal call to set the Timeout.

Sets the timeout.

On failure, errno is set.

Parameters
selfPointer to the struct itself.
relativeTimeoutMilliSecondsNumber of MilliSeconds to set it to.
Returns
No return value.
void( * Connection::SignalConnectionEstablished) (Connection *self)

Internal call to signal that the connection is established.

On failure, errno is set.

Parameters
selfPointer to the struct itself.
Returns
No return value.
void( * Connection::SignalConnectionFault) (Connection *self)

Internal call to signal that the connection is now faulty.

On failure, errno is set.

Parameters
selfPointer to the struct itself.
Returns
No return value.
void( * Connection::Timeout) (Connection *self)

Internal call to signal an Unknown Command.

Internal call to signal reception of Unknown Command on this Connection.

On failure, errno is set.

Parameters
selfPointer to the struct itself.
Returns
No return value.
void( * Connection::UnknownCommand) (Connection *self)

Internal call to signal a Timeout.

Internal call to signal a Timeout has occured on this Connection.

On failure, errno is set.

Parameters
selfPointer to the struct itself.
Returns
No return value.

The documentation for this struct was generated from the following file: