Neonode zForce(TM) SDK

- Main Page
- Modules
- Classes
- Files

- Class List
- Class Index
- Class Members

Public Attributes | List of all members
Connection Struct Reference

The main Connection struct. More...

`#include <Connection.h>`

Collaboration diagram for Connection:
[legend]

## Public Attributes
zForce * | zForce
| Pointer to zForce instance.
Transport * | Transport
| Transport this Connection uses.
Protocol * | Protocol
| Protocol this Connection uses.
Queue * | ConnectionQueue
| Queue to report Connection events.
Queue * | DeviceQueue
| Queue to report Device events.
Device ** | Devices
| List of Devices.
uint32_t | NumberOfDevices
| Number of Devices detected.
bool | IsConnected
| Connected to unit.
zForceMutex * | MessageFilterMutex
| Message Filter Mutex.
Device * | FilterDevice
| 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.

- EOUTOFMEMORY - Memory exhaustion.

Parameters

  self | Pointer to the struct itself.
  device | The 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.

- EMUTEXNOTINITIALIZED - Mutex not initialized.
- EMUTEXLOCKFAILED - Mutex Lock failed.
- EMUTEXUNLOCKFAILED - Mutex Unlock failed.
- EBADMUTEX - Bad Mutex pointer.

Parameters

  self | Pointer 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:

- EALREADYCONNECTED - The Connection is already established.
- EALREADYOPEN - Transport already open.
- ETHREADCREATEFAILED - Thread Creation Failed.
- EOUTOFMEMORY - Out of memory.
- EBADTHREAD - Bad Thread pointer.
- ENOTSUPPORTED - Operation not supported.
- EMUTEXNOTINITIALIZED - Mutex not initialized.
- EMUTEXLOCKFAILED - Mutex Lock failed.
- EMUTEXUNLOCKFAILED - Mutex Unlock failed.
- EZFORCENOTINITIALIZED - zForce not Initialized.
  See also
    ConnectionStatus
  Parameters

    self | Pointer to the struct itself.

  Returns
    True if successful, false if failed. See errno.

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

Destructor.

On error, errno is set.

- ENOTCONNECTED - The connection is not connected.
- EMUTEXDESTROYFAILED - OsAbstractionLayer Mutex Destroy failed.
- EBADMUTEX - OsAbstractionLayer Bad Mutex pointer.
- EBADQUEUE - Bad Queue pointer.
- EMUTEXNOTINITIALIZED - Queue Mutex not initialized.
- EMUTEXLOCKFAILED - Queue Mutex Lock failed.
- ESEMAPHORENOTINITIALIZED - Queue Semaphore not initialized.
- ESEMAPHOREDESTROYFAILED - Queue Destroy Semaphore failed.

Parameters

  self | Pointer 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.

- ENOTCONNECTED - The Connection not connected.
- ENOTOPENED - Transport is not open.
- ECLOSEFAILED - Closing file descriptor failed.
- EBADTHREAD - Bad thread pointer, problem with exiting thread.
- EENQUEUEFAILED - Generic enqueue error.
- EOUTOFMEMORY - Memory allocation failed.
- EBADQUEUE - Bad Queue Pointer.
- EBADSEMAPHORE - Bad Semaphore pointer.
- EBADMUTEX - Bad Mutex pointer.
  See also
    ConnectionStatus
  Parameters

    self | Pointer to the struct itself.

  Returns
    True if successful, false if failed. See errno.

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

Internal call to Enqueue a Message on the Device Queue.

On failure, errno is set.

- EENQUEUEFAILED - Generic enqueue error.
- EOUTOFMEMORY - Memory allocation failed.
- EBADQUEUE - Bad Queue pointer.
- EMUTEXNOTINITIALIZED - Mutex not initialized.
- EMUTEXLOCKFAILED - Mutex Lock failed.
- EBADMUTEX - Bad Mutex pointer.
- EMUTEXUNLOCKFAILED - Mutex Unlock failed.

Parameters

  self | Pointer to the struct itself.
  device | The Device the message corresponds to.
  message | The 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.

- EDEVICENOTFOUND - Device with specified Type/Index not found.
- EUNKNOWNDEVICETYPE - Unknown Device Type.

Parameters

  self | Pointer to the struct itself.
  deviceType | The Device Type to find.
  deviceIndex | The 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

  self | Pointer to the struct itself.
  dataFrame | The 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.

- EENQUEUEFAILED - Generic enqueue error.
- EOUTOFMEMORY - Memory allocation failed.
- EBADQUEUE - Bad Queue pointer.
- ENOTCONNECTED - Not connected.

Parameters

  self | Pointer to the struct itself.
  dataFrame | The 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.

- EMESSAGEFILTERALREADYSET - Message filter set previously.
- EMUTEXNOTINITIALIZED - Mutex not initialized.
- EMUTEXLOCKFAILED - Mutex Lock failed.
- EMUTEXUNLOCKFAILED - Mutex Unlock failed.
- EBADMUTEX - Bad Mutex pointer.

Parameters

  self | Pointer to the struct itself.
  device | The Device to set the filter to.
  messageType | The 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.

- EOUTOFMEMORY - Memory allocation failed.
- EENQUEUEFAILED - Generic enqueue error.
- EOUTOFMEMORY - Memory allocation failed.
- EBADQUEUE - Bad Queue Pointer.
- EBADSEMAPHORE - Bad Semaphore pointer.
- EBADMUTEX - Bad Mutex pointer.

Parameters

  self | Pointer to the struct itself.
  relativeTimeoutMilliSeconds | Number 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.

- EENQUEUEFAILED - Generic enqueue error.
- EOUTOFMEMORY - Memory allocation failed.
- EBADQUEUE - Bad Queue Pointer.
- EBADSEMAPHORE - Bad Semaphore pointer.
- EBADMUTEX - Bad Mutex pointer.

Parameters

  self | Pointer 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.

- EENQUEUEFAILED - Generic enqueue error.
- EOUTOFMEMORY - Memory allocation failed.
- EBADQUEUE - Bad Queue Pointer.
- EBADSEMAPHORE - Bad Semaphore pointer.
- EBADMUTEX - Bad Mutex pointer.

Parameters

  self | Pointer 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.

- ERECEIVETIMEOUT - Timeout received.
- EENQUEUEFAILED - Generic enqueue error.
- EOUTOFMEMORY - Memory allocation failed.
- EBADQUEUE - Bad Queue Pointer.
- EBADSEMAPHORE - Bad Semaphore pointer.
- EBADMUTEX - Bad Mutex pointer.
- EMUTEXNOTINITIALIZED - Mutex not initialized.
- EMUTEXLOCKFAILED - Mutex Lock failed.
- EMUTEXUNLOCKFAILED - Mutex Unlock failed.

Parameters

  self | Pointer 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.

- ERECEIVETIMEOUT - Timeout received.
- EENQUEUEFAILED - Generic enqueue error.
- EOUTOFMEMORY - Memory allocation failed.
- EBADQUEUE - Bad Queue Pointer.
- EBADSEMAPHORE - Bad Semaphore pointer.
- EBADMUTEX - Bad Mutex pointer.
- EMUTEXNOTINITIALIZED - Mutex not initialized.
- EMUTEXLOCKFAILED - Mutex Lock failed.
- EMUTEXUNLOCKFAILED - Mutex Unlock failed.

Parameters

  self | Pointer to the struct itself.

Returns
  No return value.

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

- Connection.h