Neonode zForce(TM) SDK
Connection.h
Go to the documentation of this file.
1 
11 #ifndef CONNECTION_CONNECTION_H
12 #define CONNECTION_CONNECTION_H 1
13 
14 #ifndef ZFORCECOMMON_H
15  #error Please include "zForceCommon.h" before this file.
16 #endif // ZFORCECOMMON_H
17 
20 {
24 };
27 
32 {
34  uint32_t ErrorCode;
35  void ( * Destructor)(ConnectionMessage * self);
36 };
37 
38 #ifdef __cplusplus
39 extern "C"
40 {
41 #endif // __cplusplus
42 
56 DLLINTERNAL ConnectionMessage * ConnectionMessage_New (ConnectionStatus connectionStatus, uint32_t errorCode);
57 
58 #ifdef __cplusplus
59 }
60 #endif // __cplusplus
61 
63 typedef struct Connection Connection;
65 struct Connection
66 {
73  uint32_t NumberOfDevices;
74  bool IsConnected;
79 
99  void ( * Destructor)(Connection * self);
113  bool ( * AddDevice)(Connection * self, Device * device);
147  Device * ( * FindDevice)(Connection * self, DeviceType deviceType, uint32_t deviceIndex);
159  bool ( * ReceiveDataFrame)(Connection * self, DataFrame * dateFrame);
176  bool ( * SendDataFrame)(Connection * self, DataFrame * dataFrame);
195  bool ( * SetMessageFilter)(Connection * self, Device * device, MessageType messageType);
214  void ( * ClearMessageFilter)(Connection * self);
235  bool ( * EnqueueMessage)(Connection * self, Device * device, Message * message);
264  bool ( * Connect)(Connection * self);
288  bool ( * Disconnect)(Connection * self);
309  void ( * UnknownCommand)(Connection * self);
330  void ( * Timeout)(Connection * self);
349  void ( * SetTimeout)(Connection * self, uint64_t relativeTimeoutMilliSeconds);
384 
387 };
388 
389 #ifdef __cplusplus
390 extern "C"
391 {
392 #endif // __cplusplus
393 
438 DLLEXTERNAL Connection * Connection_New (char * connectionString, char * protocolString, char * dataFrameType);
439 
440 #ifdef __cplusplus
441 }
442 #endif // __cplusplus
443 
444 #endif // CONNECTION_CONNECTION_H
DLLINTERNAL ConnectionMessage * ConnectionMessage_New(ConnectionStatus connectionStatus, uint32_t errorCode)
Internal call used to create a new ConnectionMessage.
ConnectionStatus
Connection events.
Definition: Connection.h:20
@ Disconnected
Status changed to Disconnected.
Definition: Connection.h:22
@ Connected
Status changed to Connected.
Definition: Connection.h:21
@ ConnectionFault
Connection Fault. Only set internally.
Definition: Connection.h:23
DLLEXTERNAL Connection * Connection_New(char *connectionString, char *protocolString, char *dataFrameType)
Create a new Connection.
void zForceMutex
Typecast to underlying (system) type.
Definition: OsAbstractionLayer.h:18
Connection messages struct.
Definition: Connection.h:32
void(* Destructor)(ConnectionMessage *self)
Destructor.
Definition: Connection.h:35
ConnectionStatus ConnectionStatus
New status of Connection.
Definition: Connection.h:33
uint32_t ErrorCode
Error code if connection error.
Definition: Connection.h:34
The main Connection struct.
Definition: Connection.h:66
void(* SignalConnectionEstablished)(Connection *self)
Internal call to signal that the connection is established.
Definition: Connection.h:366
bool(* Disconnect)(Connection *self)
Disconnect from the unit.
Definition: Connection.h:288
Queue * DeviceQueue
Queue to report Device events.
Definition: Connection.h:71
void(* UnknownCommand)(Connection *self)
Internal call to signal a Timeout.
Definition: Connection.h:309
Protocol * Protocol
Protocol this Connection uses.
Definition: Connection.h:69
bool(* ReceiveDataFrame)(Connection *self, DataFrame *dateFrame)
Internal call to receive a DataFrame from the Transport layer.
Definition: Connection.h:159
bool(* Connect)(Connection *self)
Connect to the unit.
Definition: Connection.h:264
bool IsConnected
Connected to unit.
Definition: Connection.h:74
Device ** Devices
List of Devices.
Definition: Connection.h:72
void(* ClearMessageFilter)(Connection *self)
Internal call to clear the Message Filter.
Definition: Connection.h:214
void(* Destructor)(Connection *self)
Destructor.
Definition: Connection.h:99
MessageType FilterMessageType
Which Message the filter is set to.
Definition: Connection.h:77
zForceMutex * MessageFilterMutex
Message Filter Mutex.
Definition: Connection.h:75
Queue * ConnectionQueue
Queue to report Connection events.
Definition: Connection.h:70
Device * FilterDevice
Which Device the filter is set to.
Definition: Connection.h:76
uint64_t LastResponseSerialNumber
Serial number of last processed response message.
Definition: Connection.h:78
ConnectionStatus Status
The status of the connection.
Definition: Connection.h:386
Transport * Transport
Transport this Connection uses.
Definition: Connection.h:68
bool(* EnqueueMessage)(Connection *self, Device *device, Message *message)
Internal call to Enqueue a Message on the Device Queue.
Definition: Connection.h:235
bool(* SendDataFrame)(Connection *self, DataFrame *dataFrame)
Internal call to send a DataFrame using the Transport layer.
Definition: Connection.h:176
uint32_t NumberOfDevices
Number of Devices detected.
Definition: Connection.h:73
void(* SetTimeout)(Connection *self, uint64_t relativeTimeoutMilliSeconds)
Internal call to set the Timeout.
Definition: Connection.h:349
void(* Timeout)(Connection *self)
Internal call to signal an Unknown Command.
Definition: Connection.h:330
bool(* SetMessageFilter)(Connection *self, Device *device, MessageType messageType)
Internal call to set the Message Filter.
Definition: Connection.h:195
bool(* AddDevice)(Connection *self, Device *device)
Internal call to add a Device to the Device list.
Definition: Connection.h:113
void(* SignalConnectionFault)(Connection *self)
Internal call to signal that the connection is now faulty.
Definition: Connection.h:383
zForce * zForce
Pointer to zForce instance.
Definition: Connection.h:67
Struct containing the DataFrame information.
Definition: DataFrame.h:25
Device base class.
Definition: Device.h:26
The main Message struct.
Definition: Message.h:21
This structure represents the base class of all protocol definitions.
Definition: Protocol.h:28
The Queue struct.
Definition: Queue.h:25
Transport struct. This structure represents the base class of all Transport definitions.
Definition: Transport.h:43
Main struct.
Definition: zForce.h:29
MessageType
Enum describing the different message types that exists.
Definition: zForceTypes.h:104
DeviceType
Enum describing the different device types that exists.
Definition: zForceTypes.h:90