Neonode zForce(TM) SDK
Transport.h
Go to the documentation of this file.
1 
12 #ifndef TRANSPORT_TRANSPORT_H
13 #define TRANSPORT_TRANSPORT_H
14 
15 #ifndef ZFORCECOMMON_H
16  #error Please include "zForceCommon.h" before this file.
17 #endif // ZFORCECOMMON_H
18 
23 {
28 };
29 
30 /*
31  * Forward declaration required in order to break the cycle where
32  * Transport needs TransportEntry, and
33  * TransportEntry needs Transport.
34  */
35 typedef struct TransportEntry TransportEntry;
36 
40 typedef struct Transport Transport;
46 struct Transport
47 {
67  char ConnectionString
68  [TRANSPORTPROTOCOL_MaxOptionParameterLength + 1];
73  bool Terminate;
81  bool IsOpen;
82  bool Opening;
87 
108  bool ( * Open)(Transport * self);
121  bool ( * Close)(Transport * self);
136  DataFrame * ( * Read)(Transport * self);
150  bool ( * Write)(Transport * self, DataFrame * payload);
158  uint64_t ( * GetTimeOutValue)(Transport * self);
173  bool ( * EnqueueDataFrame)(Transport * self, DataFrame * dataFrame);
174 
179  void ( * Destructor )(Transport * self);
180 };
181 
182 // Exported Functions (prefixed with module name and underscore)
183 
216 DLLEXTERNAL Transport * Transport_GetInstance (Connection * connection,
217  char * connectionString,
218  char * dataFrameType);
219 
244 DLLEXTERNAL bool Transport_AddTransport(TransportEntry * transportEntry);
245 
266 DLLINTERNAL bool Transport_Initialize (void);
267 
281 DLLINTERNAL void Transport_Uninitialize (void);
282 
283 #ifdef USE_SERIALTRANSPORT
284  DLLINTERNAL bool SerialTransport_AddSerialTransportEntry (void);
285 #endif //USE_SERIALTRANSPORT
286 
287 #ifdef USE_HIDPIPETRANSPORT
288  DLLINTERNAL bool HidPipeTransport_AddHidPipeTransportEntry (void);
289 #endif //USE_HIDPIPETRANSPORT
290 
291 #endif // TRANSPORT_TRANSPORT_H
292 
DLLINTERNAL void Transport_Uninitialize(void)
Uninitialize the Transport module.
bool(* Write)(Transport *self, DataFrame *payload)
Function pointer to Transport's Write.
Definition: Transport.h:150
The main Connection struct.
Definition: Connection.h:43
bool(* Open)(Transport *self)
Open the generic Transport.
Definition: Transport.h:108
volatile ReadWriteThreadStatus ReadThreadStatus
Thread is active.
Definition: Transport.h:86
Transport struct. This structure represents the base class of all Transport definitions.
Definition: Transport.h:46
bool Terminate
A flag indicating if the Transport Read and Write threads should terminate (true) or not (false)...
Definition: Transport.h:73
zForce * zForce
A pointer to the global zForce instance.
Definition: Transport.h:60
bool IsOpen
A flag indicating if the Transport is open (true) or not (false).
Definition: Transport.h:81
Thread is Initializing.
Definition: Transport.h:25
void(* Destructor)(Transport *self)
Destructor frees all the resources that have been allocated.
Definition: Transport.h:179
volatile ReadWriteThreadStatus WriteThreadStatus
Thread is active.
Definition: Transport.h:85
DLLEXTERNAL bool Transport_AddTransport(TransportEntry *transportEntry)
Add a new Transport to the list of those available.
Thread is Terminating.
Definition: Transport.h:27
Thread is not running.
Definition: Transport.h:24
Transport * Base
Base pointer to the immediate base Transport class. The inheritance is nested so for example WinSerTr...
Definition: Transport.h:54
The Queue struct.
Definition: Queue.h:26
bool Opening
Transport is in Opening phase.
Definition: Transport.h:82
Struct containing the DataFrame information.
Definition: DataFrame.h:27
uint64_t(* GetTimeOutValue)(Transport *self)
Function pointer to Transport's GetTimeOutValue.
Definition: Transport.h:158
void zForceThread
Typecast to underlying (system) type.
Definition: OsAbstractionLayer.h:21
DLLINTERNAL bool Transport_Initialize(void)
Initialize the Transport module.
Main struct.
Definition: zForce.h:29
DLLEXTERNAL Transport * Transport_GetInstance(Connection *connection, char *connectionString, char *dataFrameType)
This is the Transport factory function.
zForceThread * WriteThread
Write Thread pointer.
Definition: Transport.h:83
char ConnectionString[TRANSPORTPROTOCOL_MaxOptionParameterLength+1]
Connection string. This string contain the type of transport and the option parameters on the followi...
Definition: Transport.h:68
Queue * WriteQueue
A pointer to the Write queue used by EnqueueDataFrame.
Definition: Transport.h:77
bool(* Close)(Transport *self)
Close the generic Transport.
Definition: Transport.h:121
Connection * Connection
Each Transport is linked to one Connection.
Definition: Transport.h:58
Thread is Running.
Definition: Transport.h:26
ReadWriteThreadStatus
Enum describing the current status of a Read or Write thread.
Definition: Transport.h:22
zForceThread * ReadThread
Read Thread pointer.
Definition: Transport.h:84
bool(* EnqueueDataFrame)(Transport *self, DataFrame *dataFrame)
Enqueue given dataframe.
Definition: Transport.h:173