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
19 enum ConnectionStatus
20 {
21 Connected,
22 Disconnected,
23 ConnectionFault
24 };
26 typedef enum ConnectionStatus ConnectionStatus;
27
29 typedef struct ConnectionMessage ConnectionMessage;
31 struct ConnectionMessage
32 {
33 ConnectionStatus ConnectionStatus;
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 {
67 zForce * zForce;
68 Transport * Transport;
69 Protocol * Protocol;
70 Queue * ConnectionQueue;
71 Queue * DeviceQueue;
72 Device ** Devices;
73 uint32_t NumberOfDevices;
74 bool IsConnected;
75 zForceMutex * MessageFilterMutex;
76 Device * FilterDevice;
77 MessageType FilterMessageType;
78 uint64_t LastResponseSerialNumber;
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);
366 void ( * SignalConnectionEstablished)(Connection * self);
383 void ( * SignalConnectionFault)(Connection * self);
384
386 ConnectionStatus Status;
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
ConnectionMessage_New
DLLINTERNAL ConnectionMessage * ConnectionMessage_New(ConnectionStatus connectionStatus, uint32_t errorCode)
Internal call used to create a new ConnectionMessage.
ConnectionStatus
ConnectionStatus
Connection events.
Definition: Connection.h:20
Disconnected
@ Disconnected
Status changed to Disconnected.
Definition: Connection.h:22
Connected
@ Connected
Status changed to Connected.
Definition: Connection.h:21
ConnectionFault
@ ConnectionFault
Connection Fault. Only set internally.
Definition: Connection.h:23
Connection_New
DLLEXTERNAL Connection * Connection_New(char *connectionString, char *protocolString, char *dataFrameType)
Create a new Connection.
zForceMutex
void zForceMutex
Typecast to underlying (system) type.
Definition: OsAbstractionLayer.h:18
ConnectionMessage
Connection messages struct.
Definition: Connection.h:32
ConnectionMessage::Destructor
void(* Destructor)(ConnectionMessage *self)
Destructor.
Definition: Connection.h:35
ConnectionMessage::ConnectionStatus
ConnectionStatus ConnectionStatus
New status of Connection.
Definition: Connection.h:33
ConnectionMessage::ErrorCode
uint32_t ErrorCode
Error code if connection error.
Definition: Connection.h:34
Connection
The main Connection struct.
Definition: Connection.h:66
Connection::SignalConnectionEstablished
void(* SignalConnectionEstablished)(Connection *self)
Internal call to signal that the connection is established.
Definition: Connection.h:366
Connection::Disconnect
bool(* Disconnect)(Connection *self)
Disconnect from the unit.
Definition: Connection.h:288
Connection::DeviceQueue
Queue * DeviceQueue
Queue to report Device events.
Definition: Connection.h:71
Connection::UnknownCommand
void(* UnknownCommand)(Connection *self)
Internal call to signal a Timeout.
Definition: Connection.h:309
Connection::Protocol
Protocol * Protocol
Protocol this Connection uses.
Definition: Connection.h:69
Connection::ReceiveDataFrame
bool(* ReceiveDataFrame)(Connection *self, DataFrame *dateFrame)
Internal call to receive a DataFrame from the Transport layer.
Definition: Connection.h:159
Connection::Connect
bool(* Connect)(Connection *self)
Connect to the unit.
Definition: Connection.h:264
Connection::IsConnected
bool IsConnected
Connected to unit.
Definition: Connection.h:74
Connection::Devices
Device ** Devices
List of Devices.
Definition: Connection.h:72
Connection::ClearMessageFilter
void(* ClearMessageFilter)(Connection *self)
Internal call to clear the Message Filter.
Definition: Connection.h:214
Connection::Destructor
void(* Destructor)(Connection *self)
Destructor.
Definition: Connection.h:99
Connection::FilterMessageType
MessageType FilterMessageType
Which Message the filter is set to.
Definition: Connection.h:77
Connection::MessageFilterMutex
zForceMutex * MessageFilterMutex
Message Filter Mutex.
Definition: Connection.h:75
Connection::ConnectionQueue
Queue * ConnectionQueue
Queue to report Connection events.
Definition: Connection.h:70
Connection::FilterDevice
Device * FilterDevice
Which Device the filter is set to.
Definition: Connection.h:76
Connection::LastResponseSerialNumber
uint64_t LastResponseSerialNumber
Serial number of last processed response message.
Definition: Connection.h:78
Connection::Status
ConnectionStatus Status
The status of the connection.
Definition: Connection.h:386
Connection::Transport
Transport * Transport
Transport this Connection uses.
Definition: Connection.h:68
Connection::EnqueueMessage
bool(* EnqueueMessage)(Connection *self, Device *device, Message *message)
Internal call to Enqueue a Message on the Device Queue.
Definition: Connection.h:235
Connection::SendDataFrame
bool(* SendDataFrame)(Connection *self, DataFrame *dataFrame)
Internal call to send a DataFrame using the Transport layer.
Definition: Connection.h:176
Connection::NumberOfDevices
uint32_t NumberOfDevices
Number of Devices detected.
Definition: Connection.h:73
Connection::SetTimeout
void(* SetTimeout)(Connection *self, uint64_t relativeTimeoutMilliSeconds)
Internal call to set the Timeout.
Definition: Connection.h:349
Connection::Timeout
void(* Timeout)(Connection *self)
Internal call to signal an Unknown Command.
Definition: Connection.h:330
Connection::SetMessageFilter
bool(* SetMessageFilter)(Connection *self, Device *device, MessageType messageType)
Internal call to set the Message Filter.
Definition: Connection.h:195
Connection::AddDevice
bool(* AddDevice)(Connection *self, Device *device)
Internal call to add a Device to the Device list.
Definition: Connection.h:113
Connection::SignalConnectionFault
void(* SignalConnectionFault)(Connection *self)
Internal call to signal that the connection is now faulty.
Definition: Connection.h:383
Connection::zForce
zForce * zForce
Pointer to zForce instance.
Definition: Connection.h:67
DataFrame
Struct containing the DataFrame information.
Definition: DataFrame.h:25
Device
Device base class.
Definition: Device.h:26
Message
The main Message struct.
Definition: Message.h:21
Protocol
This structure represents the base class of all protocol definitions.
Definition: Protocol.h:28
Queue
The Queue struct.
Definition: Queue.h:25
Transport
Transport struct. This structure represents the base class of all Transport definitions.
Definition: Transport.h:43
zForce
Main struct.
Definition: zForce.h:29
MessageType
MessageType
Enum describing the different message types that exists.
Definition: zForceTypes.h:104
DeviceType
DeviceType
Enum describing the different device types that exists.
Definition: zForceTypes.h:90