Neonode zForce(TM) SDK

- Main Page
- Modules
- Classes
- Files

- File List
- File Members

Classes | Typedefs | Functions
Protocol.h File Reference

This module implements the Protocol base class. More...

Go to the source code of this file.

## Classes
struct | Protocol
| This structure represents the base class of all protocol definitions. More...

## Typedefs
typedef struct Protocol | Protocol

## Functions
DLLEXTERNAL Protocol * | Protocol_GetInstance (Connection *connection, char *protocolString, char *dataFrameType)
| This is the Protocol factory function. More...
DLLEXTERNAL bool | Protocol_AddProtocol (ProtocolEntry *protocolEntry)
| Add a new protocol to the list of those available. More...
DLLINTERNAL bool | Protocol_Initialize (void)
| Initialize the Protocol module. More...
DLLINTERNAL void | Protocol_Uninitialize (void)
| Unitialize the Protocol module. More...

## Detailed Description

This module implements the Protocol base class.

This module implements the Protocol base class. Here we find all that is essential for a Protocol.

Copyright
  COPYRIGHT NOTICE: (c) 2017 Neonode Technologies AB. All rights reserved.

## Typedef Documentation

typedef struct Protocol Protocol

See also
  struct Protocol

## Function Documentation

DLLEXTERNAL bool Protocol_AddProtocol | ( | ProtocolEntry * | protocolEntry | ) |

Add a new protocol to the list of those available.

This is the method used to find inform the zForce SDK of protocols which can be used for communication.
Upon error the errno variable is set as follows:

- EALREADYADDED - A protocol matching the name and data frame type has already been added.
- EOUTOFMEMORY - The memory used to store protocol details has been exhausted.
- 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.
  Parameters

    protocolEntry | The description of the protocol to add.

  Returns
    true if the protocol has been added. Otherwise false which indicates failure and the errno variable should be inspected for the reason why.

DLLEXTERNAL Protocol* Protocol_GetInstance | ( | Connection * | connection,
|  | char * | protocolString,
|  | char * | dataFrameType
| ) |  |

This is the Protocol factory function.

This is the Protocol class factory function. A new Protocol structure is allocated and if this succeeds the fields of the structure are populated using the arguments passed to the constructor.
Should allocation fail, NULL will be returned and errno is set as follows:

- EOUTOFMEMORY - Memory allocation failed.
- 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.
- EBADCONNECTION - The connection pointer is not valid.
- 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.

Parameters

  connection | A pointer to the Connection instance that will be used with this protocol.
  protocolString | A pointer to a NUL terminated char string holding a unique human readable identifer. The contents of the string are copied to the Protocol structucture. The length of the string as measured by strlen should be at most MAX_ENTRY_NAME_LENGTH chars.
  dataFrameType | An identifying string that determines the type of data frames this protocol should traffic in.

Returns
  Returns a pointer the allocated Protocol structure upon success, otherwise a NULL pointer is returned and errno is set accordingly.

DLLINTERNAL bool Protocol_Initialize | ( | void |  | ) |

Initialize the Protocol module.

Perform the initialization of the Protocol module.
Upon error the errno variable is set as follows:

- EALREADYINITIALIZED - A previous initialization is still in effect.

Returns
  true upon success, false otherwise.

DLLINTERNAL void Protocol_Uninitialize | ( | void |  | ) |

Unitialize the Protocol module.

Perform the uninitialization of the Protocol module. Any allocated resources are deallocated.

Returns
  No return value.