60
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
#ifndef __TCFCPPAPI_H__
|
|
18 |
#define __TCFCPPAPI_H__
|
|
19 |
|
|
20 |
#include "TCErrorConstants.h"
|
|
21 |
|
|
22 |
#ifdef __cplusplus
|
|
23 |
extern "C" {
|
|
24 |
#endif
|
|
25 |
|
|
26 |
#ifdef TCFCLIENT_EXPORTS
|
|
27 |
#define TCF_EXP __declspec(dllexport)
|
|
28 |
#else
|
|
29 |
#define TCF_EXP __declspec(dllimport)
|
|
30 |
#endif
|
|
31 |
|
|
32 |
#define TCF_CALL
|
|
33 |
|
|
34 |
// TCP/IP
|
|
35 |
#define MAX_IPADDRESS_SIZE (20)
|
|
36 |
#define MAX_PORT_SIZE (6)
|
|
37 |
typedef struct tagTCFCppTcpConnectData
|
|
38 |
{
|
|
39 |
char ipAddress[MAX_IPADDRESS_SIZE]; // e.g., "127.0.0.1"
|
|
40 |
char ipPort[MAX_PORT_SIZE]; // e.g., "7654"
|
|
41 |
} *pTCFCppTcpConnectData, TCFCppTcpConnectData;
|
|
42 |
|
|
43 |
// Virtual Serial (BT and USB over Serial port)
|
|
44 |
#define MAX_COMPORT_SIZE (20)
|
|
45 |
typedef struct tagTCFCppVirtualSerialConnectData
|
|
46 |
{
|
|
47 |
char comPort[MAX_COMPORT_SIZE]; // only COM port required: e.g. COM0
|
|
48 |
} *pTCFCppVirtualSerialConnectData, TCFCppVirtualSerialConnectData;
|
|
49 |
|
|
50 |
// Real Serial
|
|
51 |
enum eTCFCppFlowControl
|
|
52 |
{
|
|
53 |
eTCFCppFlowControlNone,
|
|
54 |
eTCFCppFlowControlHW,
|
|
55 |
eTCFCppFlowControlSW,
|
|
56 |
};
|
|
57 |
enum eTCFCppStopBits
|
|
58 |
{
|
|
59 |
eTCFCppStopBits1,
|
|
60 |
eTCFCppStopBits15,
|
|
61 |
eTCFCppStopBits2,
|
|
62 |
};
|
|
63 |
enum eTCFCppParity
|
|
64 |
{
|
|
65 |
eTCFCppParityNone,
|
|
66 |
eTCFCppParityOdd,
|
|
67 |
eTCFCppParityEven,
|
|
68 |
};
|
|
69 |
|
|
70 |
typedef struct tagTCFCppRealSerialConnectData
|
|
71 |
{
|
|
72 |
eTCFCppFlowControl flowControl;
|
|
73 |
eTCFCppStopBits stopBits;
|
|
74 |
eTCFCppParity parity;
|
|
75 |
DWORD baudRate;
|
|
76 |
DWORD dataBits;
|
|
77 |
char comPort[MAX_COMPORT_SIZE];
|
|
78 |
} *pTCFCppRealSerialConnectData, TCFCppRealSerialConnectData;
|
|
79 |
|
|
80 |
// Real USB
|
|
81 |
#define MAX_USBDEVICE_SIZE (100)
|
|
82 |
typedef struct tagTCFCppUSBConnectData
|
|
83 |
{
|
|
84 |
char device[MAX_USBDEVICE_SIZE];
|
|
85 |
} *pTCFCppUSBConnectData, TCFCppUSBConnectData;
|
|
86 |
|
|
87 |
#define MAX_DECODE_FORMAT (16)
|
|
88 |
#define MAX_CONNECTION_TYPE (16)
|
|
89 |
typedef struct tagTCFCppConnectData
|
|
90 |
{
|
|
91 |
long retryInterval; // retry interval in seconds when port access is lost
|
|
92 |
long retryTimeout; // retry timeout in seconds when port access is lost
|
|
93 |
long traceBoxChannel; // Tracebox parameter
|
|
94 |
char decodeFormat[MAX_DECODE_FORMAT]; // protocol decode format on incoming messages
|
|
95 |
char connectType[MAX_CONNECTION_TYPE]; // connection type
|
|
96 |
TCFCppTcpConnectData tcpSettings; // TCP/IP
|
|
97 |
TCFCppVirtualSerialConnectData virtualSerialSettings; // Virtual serial
|
|
98 |
TCFCppRealSerialConnectData realSerialSettings; // Real Serial
|
|
99 |
TCFCppUSBConnectData usbSettings; // Real USB
|
|
100 |
} *pTCFCppConnectData, TCFCppConnectData;
|
|
101 |
|
|
102 |
// Various options for this client
|
|
103 |
// Incoming message handling
|
|
104 |
enum eTCFCppUnWrapFormat
|
|
105 |
{
|
|
106 |
eTCFCppNone, // return whole message (including protocol)
|
|
107 |
eTCFCppDeleteHeader, // return only message data (excluding headers)
|
|
108 |
};
|
|
109 |
// Outgoing message encoding options for this client
|
|
110 |
enum eTCFCppEncodeFormat
|
|
111 |
{
|
|
112 |
eTCFCppEncodeNone, // leave message as-is
|
|
113 |
eTCFCppEncode, // encode message using decode format
|
|
114 |
};
|
|
115 |
// input stream overflow
|
|
116 |
enum eTCPCppStreamOverflowOption
|
|
117 |
{
|
|
118 |
eTCPCppStreamOverflowOff, // no overflow to file
|
|
119 |
eTCPCppStreamOverflowOn, // overflow to file
|
|
120 |
};
|
|
121 |
#define MAX_INPUTSTREAMPATH (2048L)
|
|
122 |
|
|
123 |
typedef struct tagTCFCppMessageOptions
|
|
124 |
{
|
|
125 |
long inputStreamSize; // input stream size
|
|
126 |
// eTCPCppStreamOverflowOption streamOverflowOption; // stream overflow option
|
|
127 |
// char overflowFile[MAX_INPUTSTREAMPATH]; // overflow file to use
|
|
128 |
eTCFCppUnWrapFormat unWrapFormat; // message unwrapping option
|
|
129 |
long ostVersion; // OST version to use for decoding messages
|
|
130 |
} *pTCFCppMessageOptions, TCFCppMessageOptions;
|
|
131 |
|
|
132 |
#define MAX_VERSION_STRING (80)
|
|
133 |
#define MAX_MESSAGEIDS (256)
|
|
134 |
typedef struct tagTCFCppMessageIds
|
|
135 |
{
|
|
136 |
long numberIds;
|
|
137 |
BYTE messageIds[MAX_MESSAGEIDS];
|
|
138 |
} *pTCFCppMessageIds, TCFCppMessageIds;
|
|
139 |
|
|
140 |
#define MAX_SENDMESSAGE (64*1024L+12)
|
|
141 |
typedef struct tagTCFCppMessage
|
|
142 |
{
|
|
143 |
eTCFCppEncodeFormat encodeFormat; // encode or do not encode protocol using current protocol
|
|
144 |
long ostVersion; // OST version to use when above and encodeFormat = "ost"
|
|
145 |
BOOL useMyId; // format for protocol
|
|
146 |
BYTE myId; // my message ID to use (if useMyId=true)
|
|
147 |
} *pTCFCppMessage, TCFCppMessage;
|
|
148 |
|
|
149 |
// APIs
|
|
150 |
|
|
151 |
TCF_EXP long TCF_CALL TCFConnect(pTCFCppConnectData inConnection, pTCFCppMessageOptions inMessageOptions, pTCFCppMessageIds inMessageIds, long* outClientId);
|
|
152 |
TCF_EXP long TCF_CALL TCFDisconnect(long inClientId);
|
|
153 |
TCF_EXP long TCF_CALL TCFGetVersions(long inClientId, long& outNumberVersions, char** outVersions);
|
|
154 |
TCF_EXP long TCF_CALL TCFGetConnections(long& outNumberConnections, pTCFCppConnectData* outConnections);
|
|
155 |
TCF_EXP long TCF_CALL TCFSendMessage(long inClientId, pTCFCppMessage inMessage, long length, BYTE* data);
|
|
156 |
TCF_EXP long TCF_CALL TCFStart(long inClientId);
|
|
157 |
TCF_EXP long TCF_CALL TCFStop(long inClientId);
|
|
158 |
TCF_EXP long TCF_CALL TCFSetMessageIds(long inClientId, pTCFCppMessageIds inMessageIds);
|
|
159 |
TCF_EXP long TCF_CALL TCFPollInputStream(long inClientId, long& outLength);
|
|
160 |
TCF_EXP long TCF_CALL TCFReadInputStream(long inClientId, pTCFCppMessage outMessage, long& inLength, BYTE* outData);
|
|
161 |
TCF_EXP BOOL TCF_CALL TCFPollError(long inClientId, int* outErrorCode, BOOL* outHasOSErrorCode, long* outOSErrorCode);
|
|
162 |
|
|
163 |
|
|
164 |
typedef long (*TCFCONNECT)(pTCFCppConnectData inConnection, pTCFCppMessageOptions inMessageOptions, pTCFCppMessageIds inMessageIds, long* outClientId);
|
|
165 |
#define TCFCONNECT_FNNAME "TCFConnect"
|
|
166 |
|
|
167 |
typedef long (*TCFDISCONNECT)(long inClientId);
|
|
168 |
#define TCFDISCONNECT_FNNAME "TCFDisconnect"
|
|
169 |
|
|
170 |
typedef long (*TCFGETVERIONS)(long inClientId, long& outNumberVersions, char** outVersions);
|
|
171 |
#define TCFGETVERIONS_FNNAME "TCFGetVersions"
|
|
172 |
|
|
173 |
typedef long (*TCFGETCONNECTIONS)(long& outNumberConnections, pTCFCppConnectData* outConnections);
|
|
174 |
#define TCFGETCONNECTIONS_FNNAME "TCFGetConnections"
|
|
175 |
|
|
176 |
typedef long (*TCFSENDMESSAGE)(long inClientId, pTCFCppMessage inMessage, long length, BYTE* data);
|
|
177 |
#define TCFSENDMESSAGE_FNNAME "TCFSendMessage"
|
|
178 |
|
|
179 |
typedef long (*TCFSTART)(long inClientId);
|
|
180 |
#define TCFSTART_FNNAME "TCFStart"
|
|
181 |
|
|
182 |
typedef long (*TCFSTOP)(long inClientId);
|
|
183 |
#define TCFSTOP_FNNAME "TCFStop"
|
|
184 |
|
|
185 |
typedef long (*TCFSETMESSAGEIDS)(long inClientId, pTCFCppMessageIds inMessageIds);
|
|
186 |
#define TCFSETMESSAGEIDS_FNNAME "TCFSetMessageIds"
|
|
187 |
|
|
188 |
typedef long (*TCFPOLLINPUTSTREAM)(long inClientId, long& outLength);
|
|
189 |
#define TCFPOLLINPUTSTREAM_FNNAME "TCFPollInputStream"
|
|
190 |
|
|
191 |
typedef long (*TCFREADINPUTSTREAM)(long inClientId, pTCFCppMessage outMessage, long& inLength, BYTE* outData);
|
|
192 |
#define TCFREADINPUTSTREAM_FNNAME "TCFReadInputStream"
|
|
193 |
|
|
194 |
typedef long (*TCFPOLLERROR)(long inClientId, int* outErrorCode, BOOL* outHasOSErrorCode, long* outOSErrorCode);
|
|
195 |
#define TCFPOLLERROR_FNNAME "TCFPollError"
|
|
196 |
|
|
197 |
#ifdef __cplusplus
|
|
198 |
}
|
|
199 |
#endif
|
|
200 |
|
|
201 |
|
|
202 |
#endif // __TCFCPPAPI_H__
|