1 | /**
|
---|
2 | * \section LICENSE
|
---|
3 | * Copyright 2011 by KVASER AB, SWEDEN
|
---|
4 | *
|
---|
5 | * WWW: http://www.kvaser.com
|
---|
6 | *
|
---|
7 | * This software is furnished under a license and may be used and copied
|
---|
8 | * only in accordance with the terms of such license.
|
---|
9 | *
|
---|
10 | * \section DESCRIPTION
|
---|
11 | *
|
---|
12 | * THIS IS A PRELIMINARY VERSION AND SUBJECT TO CHANGE.
|
---|
13 | *
|
---|
14 | * Proposed new remote device API.
|
---|
15 | *
|
---|
16 | * \file kvrlib.h
|
---|
17 | * \version PRELIMINARY
|
---|
18 | * \author Kvaser AB
|
---|
19 | */
|
---|
20 |
|
---|
21 | #ifndef KVRLIB_H_
|
---|
22 | #define KVRLIB_H_
|
---|
23 |
|
---|
24 | #include <windows.h>
|
---|
25 | #include <kvaser_stdint.h>
|
---|
26 |
|
---|
27 | #ifdef __cplusplus
|
---|
28 | extern "C" {
|
---|
29 | #endif
|
---|
30 |
|
---|
31 | /**
|
---|
32 | * Return type of kvrlib functions.
|
---|
33 | */
|
---|
34 | typedef enum {
|
---|
35 | kvrOK = 0, /**< OK! */
|
---|
36 | kvrERR_NOT_INITIALIZED = -1, /**< kvrlib has not been initialized. */
|
---|
37 | kvrERR_GENERIC = -2, /**< Generic error. */
|
---|
38 | kvrERR_CHECKSUM = -3, /**< Checksum problem. */
|
---|
39 | kvrERR_PARAMETER = -4, /**< Error in supplied in parameters. */
|
---|
40 | kvrERR_PASSWORD = -5, /**< Supplied password was wrong. */
|
---|
41 | kvrERR_BLANK = -6, /**< List was not set or no more results. */
|
---|
42 | kvrERR_NO_DEVICE = -7, /**< Remote device is unreachable. */
|
---|
43 | kvrERR_NO_ANSWER = -8, /**< No answer arrived within given timeout. */
|
---|
44 | kvrERR_NOT_IMPLEMENTED = -9, /**< Function is not yet implemented. */
|
---|
45 | kvrERR_PERMISSION_DENIED = -10, /**< Permission denied. */
|
---|
46 | kvrERR_OUT_OF_SPACE = -11, /**< Out of space, eg. to many open handles, to small buffer. */
|
---|
47 | kvrERR_NO_SERVICE = -12, /**< The helper service is not running. */
|
---|
48 | kvrERR_DUPLICATED_DEVICE = -13, /**< There are duplicates in the device list. */
|
---|
49 | /* Remember to update the list of errorstrings (error_text_array) in the library as well. */
|
---|
50 | } kvrStatus;
|
---|
51 |
|
---|
52 | /**
|
---|
53 | * \defgroup Configuration Local configuration
|
---|
54 | */
|
---|
55 | /**@{*/
|
---|
56 |
|
---|
57 | /**
|
---|
58 | * A configuration handle. Created by calling \ref kvrConfigOpen() or \ref kvrConfigOpenEx().
|
---|
59 | */
|
---|
60 | typedef int32_t kvrConfigHandle;
|
---|
61 |
|
---|
62 | /**
|
---|
63 | * \name kvrConfigMode_xxx
|
---|
64 | * Configuration mode.
|
---|
65 | * \anchor kvrConfigMode_xxx
|
---|
66 | * @{
|
---|
67 | */
|
---|
68 | #define kvrConfigMode_R 0 /**< Read only. */
|
---|
69 | #define kvrConfigMode_RW 1 /**< Read/write. */
|
---|
70 | #define kvrConfigMode_ERASE 2 /**< Erase and write. */
|
---|
71 | /** @} */
|
---|
72 |
|
---|
73 | /**
|
---|
74 | * Open a configuration handle to the device.
|
---|
75 | * It should later be closed with \ref kvrConfigClose().
|
---|
76 | *
|
---|
77 | * This configuration handle is used both for changing the device configuration,
|
---|
78 | * reading status information, e.g. \ref kvrNetworkGetConnectionStatus(), and
|
---|
79 | * issuing some other commands such as e.g. \ref kvrNetworkConnectionTest() and
|
---|
80 | * \ref kvrWlanStartScan().
|
---|
81 | *
|
---|
82 | * To change the configuration, you need to open the configuration with
|
---|
83 | * \ref kvrConfigMode_RW before calling \ref kvrConfigSet().
|
---|
84 | *
|
---|
85 | * To read the configuration, you can open the configuration with either
|
---|
86 | * \ref kvrConfigMode_RW or \ref kvrConfigMode_R before calling \ref kvrConfigGet().
|
---|
87 | *
|
---|
88 | * Setting a password is done through the configuration (with \ref kvrConfigSet()).
|
---|
89 | * Resetting a password can be done by erasing the whole configuration with
|
---|
90 | * \ref kvrConfigClear(), while first opening the configuration with
|
---|
91 | * \ref kvrConfigMode_ERASE and supplying an empty password.
|
---|
92 | *
|
---|
93 | * Before calling any other function, you must open the configuration with
|
---|
94 | * \ref kvrConfigMode_R.
|
---|
95 | *
|
---|
96 | * \param[in] can_channel_no CAN channel number.
|
---|
97 | * \param[in] mode Can be set to one of \ref kvrConfigMode_xxx
|
---|
98 | * \param[in] password The password as a C string.
|
---|
99 | * Use an empty string, i.e. "", if no password
|
---|
100 | * is required.
|
---|
101 | * \param[out] handle A configuration handle
|
---|
102 | *
|
---|
103 | * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
|
---|
104 | *
|
---|
105 | * \note \ref kvrConfigOpen() will operate on the active profile.
|
---|
106 | * See \ref page_configuration.
|
---|
107 | * \note When using \ref kvrConfigMode_RW or \ref kvrConfigMode_ERASE, a pause of
|
---|
108 | * ~2 seconds is needed after \ref kvrConfigClose(), to allow CANlib time to
|
---|
109 | * discard the device.
|
---|
110 | * \sa \ref kvrConfigOpenEx()
|
---|
111 | */
|
---|
112 | kvrStatus WINAPI kvrConfigOpen(int32_t can_channel_no,
|
---|
113 | int32_t mode,
|
---|
114 | const char *password,
|
---|
115 | kvrConfigHandle *handle);
|
---|
116 |
|
---|
117 |
|
---|
118 | /**
|
---|
119 | * Set active profile. See \ref page_configuration.
|
---|
120 | *
|
---|
121 | *
|
---|
122 | * \param[in] can_channel_no CAN channel number
|
---|
123 | * \param[in] profile_number
|
---|
124 | * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
|
---|
125 | *
|
---|
126 | * \note A pause of ~2 seconds is needed after \ref kvrConfigActiveProfileSet(),
|
---|
127 | * to allow CANlib time to discard the device.
|
---|
128 | */
|
---|
129 | kvrStatus WINAPI kvrConfigActiveProfileSet (int32_t can_channel_no, int32_t profile_number);
|
---|
130 |
|
---|
131 | /**
|
---|
132 | * Get active profile. See \ref page_configuration.
|
---|
133 | *
|
---|
134 | *
|
---|
135 | * \param[in] can_channel_no CAN channel number
|
---|
136 | * \param[out] profile_number
|
---|
137 | * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
|
---|
138 | */
|
---|
139 | kvrStatus WINAPI kvrConfigActiveProfileGet (int32_t can_channel_no, int32_t *profile_number);
|
---|
140 |
|
---|
141 | /**
|
---|
142 | * Get the maximum number of profile(s) the device can store.
|
---|
143 | * See \ref page_configuration.
|
---|
144 | *
|
---|
145 | *
|
---|
146 | * \param[in] can_channel_no CAN channel number
|
---|
147 | * \param[out] no_profiles
|
---|
148 | * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
|
---|
149 | */
|
---|
150 | kvrStatus WINAPI kvrConfigNoProfilesGet(int32_t can_channel_no, int32_t *no_profiles);
|
---|
151 |
|
---|
152 |
|
---|
153 | /**
|
---|
154 | * Open a configuration handle to the device.
|
---|
155 | * It should later be closed with \ref kvrConfigClose().
|
---|
156 | *
|
---|
157 | * This configuration handle is used both for changing the device configuration,
|
---|
158 | * reading status information, e.g. \ref kvrNetworkGetConnectionStatus(), and
|
---|
159 | * issuing some other commands such as e.g. \ref kvrNetworkConnectionTest() and
|
---|
160 | * \ref kvrWlanStartScan().
|
---|
161 | *
|
---|
162 | * To change the configuration, you need to open the configuration with
|
---|
163 | * \ref kvrConfigMode_RW before calling \ref kvrConfigSet().
|
---|
164 | *
|
---|
165 | * To read the configuration, you can open the configuration with either
|
---|
166 | * \ref kvrConfigMode_RW or \ref kvrConfigMode_R before calling \ref kvrConfigGet().
|
---|
167 | *
|
---|
168 | * Setting a password is done through the configuration (with \ref kvrConfigSet()).
|
---|
169 | * Resetting a password can be done by erasing the whole configuration with
|
---|
170 | * \ref kvrConfigClear(), while first opening the configuration with
|
---|
171 | * \ref kvrConfigMode_ERASE and supplying an empty password.
|
---|
172 | *
|
---|
173 | * Before calling any other function, you must open the configuration with
|
---|
174 | * \ref kvrConfigMode_R.
|
---|
175 | *
|
---|
176 | * The profile number is used to open a specific profile.
|
---|
177 | * See \ref page_configuration.
|
---|
178 | *
|
---|
179 | * \param[in] can_channel_no CAN channel number
|
---|
180 | * \param[in] mode Can be set to one of \ref kvrConfigMode_xxx
|
---|
181 | * \param[in] password The password as a C string.
|
---|
182 | * Use an empty string, i.e. "", if no password
|
---|
183 | * is required.
|
---|
184 | * \param[out] handle A configuration handle
|
---|
185 | * \param[in] profile_no Profile number
|
---|
186 | *
|
---|
187 | * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
|
---|
188 | *
|
---|
189 | * \note When using \ref kvrConfigMode_RW or \ref kvrConfigMode_ERASE, a pause of
|
---|
190 | * ~2 seconds is needed after \ref kvrConfigClose(), to allow CANlib time to
|
---|
191 | * discard the device.
|
---|
192 | * \sa \ref kvrConfigOpen()
|
---|
193 | */
|
---|
194 | kvrStatus WINAPI kvrConfigOpenEx(int32_t can_channel_no,
|
---|
195 | int32_t mode,
|
---|
196 | const char *password,
|
---|
197 | kvrConfigHandle *handle,
|
---|
198 | uint32_t profile_no);
|
---|
199 |
|
---|
200 | /**
|
---|
201 | * Closes the device's configuration area without programming it.
|
---|
202 | * Programming is done with \ref kvrConfigSet().
|
---|
203 | *
|
---|
204 | * \param[in] handle A configuration handle
|
---|
205 | *
|
---|
206 | * \note When using \ref kvrConfigMode_RW or \ref kvrConfigMode_ERASE, a pause of
|
---|
207 | * ~2 seconds is needed after \ref kvrConfigClose(), to allow CANlib time to
|
---|
208 | * discard the device.
|
---|
209 | */
|
---|
210 | void WINAPI kvrConfigClose(kvrConfigHandle handle);
|
---|
211 |
|
---|
212 | /**
|
---|
213 | * Verify that the xml buffer complies with both the DTD and internal restrictions. If
|
---|
214 | * the XML input creates any errors and err_buffer is to small to hold the resulting
|
---|
215 | * error message, \ref kvrERR_PARAMETER will be returned.
|
---|
216 | *
|
---|
217 | * \param[in] xml_buffer A pointer to a C string containing an XML configuration.
|
---|
218 | * \param[out] err_buffer A pointer to a buffer that will hold any error messages.
|
---|
219 | * \param[in] err_buffer_size The buffer size. Maximum size needed is 2048 bytes.
|
---|
220 | *
|
---|
221 | * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
|
---|
222 | *
|
---|
223 | */
|
---|
224 | kvrStatus WINAPI kvrConfigVerifyXml(const char *xml_buffer,
|
---|
225 | char *err_buffer,
|
---|
226 | uint32_t err_buffer_size);
|
---|
227 |
|
---|
228 | /**
|
---|
229 | * Set the device configuration. The area is erased before it is
|
---|
230 | * programmed. The handle must be opened \ref kvrConfigMode_RW and closed with
|
---|
231 | * \ref kvrConfigClose() afterward. If the XML input creates any errors,
|
---|
232 | * \ref kvrERR_PARAMETER will be returned.
|
---|
233 | *
|
---|
234 | * \param[in] handle A configuration handle.
|
---|
235 | * \param[in] xml_buffer A pointer to a C string containing a valid XML config.
|
---|
236 | *
|
---|
237 | * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
|
---|
238 | *
|
---|
239 | */
|
---|
240 | kvrStatus WINAPI kvrConfigSet(kvrConfigHandle handle, const char *xml_buffer);
|
---|
241 |
|
---|
242 | /**
|
---|
243 | * Reads the device configuration. On successful return, the buffer
|
---|
244 | * will contain a valid C string with the configuration in XML format.
|
---|
245 | * The handle must be opened \ref kvrConfigMode_R or \ref kvrConfigMode_RW and closed
|
---|
246 | * with \ref kvrConfigClose().
|
---|
247 | *
|
---|
248 | * \param[in] handle A configuration handle.
|
---|
249 | * \param[out] xml_buffer A pointer to the data buffer.
|
---|
250 | * \param[in] xml_buffer_size The buffer size.
|
---|
251 | *
|
---|
252 | * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
|
---|
253 | *
|
---|
254 | */
|
---|
255 | kvrStatus WINAPI kvrConfigGet(kvrConfigHandle handle,
|
---|
256 | char *xml_buffer,
|
---|
257 | uint32_t xml_buffer_size);
|
---|
258 |
|
---|
259 | /**
|
---|
260 | * Reads a simplified version of A device configuration PROFILE.
|
---|
261 | * On successful return, the buffer will contain a valid C string of this
|
---|
262 | * in XML format.
|
---|
263 | * Since the function takes a CAN channel rather than a \ref kvrConfigHandle, it is
|
---|
264 | * not necessary to know the configuration password.
|
---|
265 | * Note that the partial XML data returned is not enough to reconfigure a device.
|
---|
266 | *
|
---|
267 | * \param[in] can_channel_no CAN channel number.
|
---|
268 | * \param[in] profile_no Profile number
|
---|
269 | * \param[out] xml_buffer A pointer to the data buffer.
|
---|
270 | * \param[in] xml_buffer_size The buffer size.
|
---|
271 | *
|
---|
272 | * \return \ref kvrOK on success,
|
---|
273 | * \ref kvrERR_BLANK when the profile is empty,
|
---|
274 | * or any other \ref kvrStatus on failure.
|
---|
275 | *
|
---|
276 | */
|
---|
277 | kvrStatus WINAPI kvrConfigInfoGet(int32_t can_channel_no,
|
---|
278 | int32_t profile_no,
|
---|
279 | char *xml_buffer,
|
---|
280 | uint32_t xml_buffer_size);
|
---|
281 |
|
---|
282 | /**
|
---|
283 | * Clear the device configuration area. This will also clear any
|
---|
284 | * previously set device password. The handle must be opened \ref kvrConfigMode_ERASE
|
---|
285 | * and closed with \ref kvrConfigClose().
|
---|
286 | *
|
---|
287 | * \param[in] handle A configuration handle.
|
---|
288 | *
|
---|
289 | * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
|
---|
290 | */
|
---|
291 | kvrStatus WINAPI kvrConfigClear(kvrConfigHandle handle);
|
---|
292 |
|
---|
293 | /**@}*/
|
---|
294 |
|
---|
295 | /**
|
---|
296 | * \defgroup Network Network information
|
---|
297 | */
|
---|
298 | /**@{*/
|
---|
299 |
|
---|
300 | /**
|
---|
301 | * Device address.
|
---|
302 | */
|
---|
303 | typedef struct {
|
---|
304 | uint32_t type; /**< \ref kvrAddressType_xxx. */
|
---|
305 | uint8_t address[20]; /**< IP or MAC address. */
|
---|
306 | } kvrAddress;
|
---|
307 |
|
---|
308 |
|
---|
309 | /**
|
---|
310 | * Capability of a WLAN AP. These are values from the standard 802.11 beacon.
|
---|
311 | *
|
---|
312 | * To convert the security information into a more human readable form,
|
---|
313 | * use \ref kvrWlanGetSecurityText().
|
---|
314 | */
|
---|
315 | typedef struct {
|
---|
316 | uint32_t version;
|
---|
317 | uint32_t capability; /**< Advertised capabilities.
|
---|
318 | capability[5] Privacy flag 1: WEP
|
---|
319 | 0: Open */
|
---|
320 | uint32_t group_cipher; /**< 0xff: No WPA/RSN.
|
---|
321 | 0x02: TKIP
|
---|
322 | 0x04: CCMP */
|
---|
323 | uint32_t list_cipher_auth; /**< 8 nybbles (In each nybble:
|
---|
324 | pos 0: cipher where;
|
---|
325 | 0x2: TKIP
|
---|
326 | 0x4: CCMP
|
---|
327 | pos 1: authentication where;
|
---|
328 | 0xa: PSK
|
---|
329 | 0x9: RADIUS
|
---|
330 | Unused nybbles are set to 0xf. */
|
---|
331 | } kvrCipherInfoElement;
|
---|
332 |
|
---|
333 | /**
|
---|
334 | * Type of device address.
|
---|
335 | * \note Ports are currently not used.
|
---|
336 | * \anchor kvrAddressType_xxx
|
---|
337 | * \name kvrAddressType_xxx
|
---|
338 | * @{
|
---|
339 | */
|
---|
340 | #define kvrAddressType_UNKNOWN 0 /**< Unknown (e.g., no reply from device). */
|
---|
341 | #define kvrAddressType_IPV4 1 /**< IP v.4 address. */
|
---|
342 | #define kvrAddressType_IPV6 2 /**< IP v.6 address. */
|
---|
343 | #define kvrAddressType_IPV4_PORT 3 /**< IP v.4 address with tcp-port. */
|
---|
344 | #define kvrAddressType_MAC 4 /**< Ethernet MAC address. */
|
---|
345 | /** @} */
|
---|
346 |
|
---|
347 | /**
|
---|
348 | * Receive Signal Strength Indicator (RSSI).
|
---|
349 | */
|
---|
350 | typedef int32_t kvrRssiHistory;
|
---|
351 |
|
---|
352 | /**
|
---|
353 | * Round-trip delay time (RTT).
|
---|
354 | */
|
---|
355 | typedef uint32_t kvrRttHistory;
|
---|
356 |
|
---|
357 | /**
|
---|
358 | * States for network connection.
|
---|
359 | * \anchor kvrNetworkState_xxx
|
---|
360 | * \name kvrNetworkState_xxx
|
---|
361 | * @{
|
---|
362 | */
|
---|
363 | #define kvrNetworkState_UNKNOWN 0 /**< Bad state, should never be reported. */
|
---|
364 | #define kvrNetworkState_INVALID 1 /**< Network hardware has been disabled. */
|
---|
365 | #define kvrNetworkState_STARTUP 2 /**< Configuring network hardware. */
|
---|
366 | #define kvrNetworkState_INITIALIZING 3 /**< Started, waiting for initialization. */
|
---|
367 | #define kvrNetworkState_NOT_CONNECTED 4 /**< No connection (may auto-connect). */
|
---|
368 | #define kvrNetworkState_CONNECTION_DELAY 5 /**< Delay during connection (ad-hoc). */
|
---|
369 | #define kvrNetworkState_CONNECTING 6 /**< Waiting for connections (ad-hoc). */
|
---|
370 | #define kvrNetworkState_CONNECTED 7 /**< Network is reached. */
|
---|
371 | #define kvrNetworkState_AUTHENTICATING 8 /**< EAPOL handshake ongoing. */
|
---|
372 | #define kvrNetworkState_AUTHENTICATION_FAILED 9 /**< Authentication have failed. */
|
---|
373 | #define kvrNetworkState_ONLINE 10 /**< Authentication completed. */
|
---|
374 | #define kvrNetworkState_FAILED_MIC 11 /**< MIC verification (EAPOL-key) failed. */
|
---|
375 | /** @} */
|
---|
376 |
|
---|
377 | /**
|
---|
378 | * Basic Service Set.
|
---|
379 | * \anchor kvrBss_xxx
|
---|
380 | * \name kvrBss_xxx
|
---|
381 | * @{
|
---|
382 | */
|
---|
383 | #define kvrBss_INFRASTRUCTURE 0 /**< Network with AP. */
|
---|
384 | #define kvrBss_INDEPENDENT 1 /**< Ad-hoc network. */
|
---|
385 | #define kvrBss_ANY 2 /**< Any. */
|
---|
386 | /** @} */
|
---|
387 |
|
---|
388 | /**
|
---|
389 | * Regulatory domain.
|
---|
390 | * \anchor kvrRegulatoryDomain_xxx
|
---|
391 | * \name kvrRegulatoryDomain_xxx
|
---|
392 | * @{
|
---|
393 | */
|
---|
394 |
|
---|
395 | #define kvrRegulatoryDomain_JAPAN_TELEC 0 /**< TELEC */
|
---|
396 | #define kvrRegulatoryDomain_EUROPE_ETSI 1 /**< ETSI */
|
---|
397 | #define kvrRegulatoryDomain_NORTH_AMERICA_FCC 2 /**< FCC */
|
---|
398 | #define kvrRegulatoryDomain_WORLD 3 /**< WORLD */
|
---|
399 | #define kvrRegulatoryDomain_CHINA_MII 4 /**< MII */
|
---|
400 | /** @} */
|
---|
401 |
|
---|
402 | /**
|
---|
403 | * Activate or deactivate connection test. When actived, the device will
|
---|
404 | * connect and start pinging itself to measure RTT. Use \ref kvrNetworkGetRssiRtt()
|
---|
405 | * (after a while) to get the latest values.
|
---|
406 | *
|
---|
407 | * \param[in] handle A configuration handle.
|
---|
408 | * \param[in] active Activate or deactivate connection test.
|
---|
409 | *
|
---|
410 | * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
|
---|
411 | * \sa \ref kvrNetworkGetRssiRtt()
|
---|
412 | */
|
---|
413 | kvrStatus WINAPI kvrNetworkConnectionTest(kvrConfigHandle handle,
|
---|
414 | int32_t active);
|
---|
415 |
|
---|
416 | /**
|
---|
417 | * Get a history of Receive Signal Strength Indicator (RSSI) and
|
---|
418 | * round-trip delay time (RTT) from the connection test.
|
---|
419 | *
|
---|
420 | * \param[in] handle A configuration handle.
|
---|
421 | * \param[out] rssi Receive Signal Strength Indicator.
|
---|
422 | * \param[in] rssi_size Number of entries in \a rssi.
|
---|
423 | * \param[out] rssi_count Number of RSSI elements returned.
|
---|
424 | * \param[out] rtt Round-trip delay time.
|
---|
425 | * \param[in] rtt_size Number of entries in \a rtt.
|
---|
426 | * \param[out] rtt_count Number of RTT elements returned.
|
---|
427 | *
|
---|
428 | * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
|
---|
429 | * \sa \ref kvrNetworkConnectionTest()
|
---|
430 | */
|
---|
431 | kvrStatus WINAPI kvrNetworkGetRssiRtt(kvrConfigHandle handle,
|
---|
432 | kvrRssiHistory *rssi,
|
---|
433 | uint32_t rssi_size,
|
---|
434 | uint32_t *rssi_count,
|
---|
435 | kvrRttHistory *rtt,
|
---|
436 | uint32_t rtt_size,
|
---|
437 | uint32_t *rtt_count);
|
---|
438 |
|
---|
439 | /**
|
---|
440 | * Initiate a scan for existing WLAN networks. The result is acquired
|
---|
441 | * with consecutive calls to \ref kvrWlanGetScanResults(). A new scan can not
|
---|
442 | * be initiated until all data has been retrieved from the previous one.
|
---|
443 | *
|
---|
444 | * \note The device should not be connected to a network when scanning. This
|
---|
445 | * includes the implicit connection done by \ref kvrNetworkConnectionTest().
|
---|
446 | *
|
---|
447 | * \param[in] handle A configuration handle.
|
---|
448 | * \param[in] active If set, performs an active scan.
|
---|
449 | * \param[in] bss_type Basic service set (BSS) selection. \ref kvrBss_xxx.
|
---|
450 | * \param[in] domain Regulatory domain. See \ref kvrRegulatoryDomain_xxx.
|
---|
451 | *
|
---|
452 | * \return \ref kvrOK on success,
|
---|
453 | * \ref kvrERR_NO_ANSWER when previous scan is ongoing
|
---|
454 | * or any other \ref kvrStatus on failure.
|
---|
455 | */
|
---|
456 |
|
---|
457 | kvrStatus WINAPI kvrWlanStartScan(kvrConfigHandle handle,
|
---|
458 | int32_t active,
|
---|
459 | int32_t bss_type,
|
---|
460 | int32_t domain);
|
---|
461 |
|
---|
462 |
|
---|
463 | /**
|
---|
464 | * Get results from WLAN scan. Call \ref kvrWlanGetScanResults() until it returns
|
---|
465 | * \ref kvrERR_BLANK to mark that no more information is available from this scan.
|
---|
466 | *
|
---|
467 | * To convert the security information into a more human readable form,
|
---|
468 | * use \ref kvrWlanGetSecurityText().
|
---|
469 | *
|
---|
470 | * \param[in] handle A configuration handle.
|
---|
471 | * \param[out] rssi Receive Signal Strength Indicator (RSSI).
|
---|
472 | * \param[out] channel WLAN Channel.
|
---|
473 | * \param[out] mac Media Access Control address.
|
---|
474 | * \param[out] bss_type Basic Service Set (BSS) (see \ref kvrBss_xxx).
|
---|
475 | * \param[out] ssid Service Set Identifier(SSID) as a C string.
|
---|
476 | * Maximum length is 32 bytes.
|
---|
477 | * \param[out] capability The advertised capabilities of the BSS.
|
---|
478 | * \param[out] type_wpa Only type 1 (802.1X) is supported for connection.
|
---|
479 | * \param[out] wpa_info Advertised information for WPA
|
---|
480 | * (see \ref kvrCipherInfoElement).
|
---|
481 | * \param[out] rsn_info Advertised information for RSN
|
---|
482 | * (see \ref kvrCipherInfoElement).
|
---|
483 | *
|
---|
484 | * \return \ref kvrOK on success,
|
---|
485 | * \ref kvrERR_NO_ANSWER when waiting for further scan results
|
---|
486 | * \ref kvrERR_BLANK when no further scan results are available
|
---|
487 | * or any other \ref kvrStatus on failure.
|
---|
488 | *
|
---|
489 | */
|
---|
490 | kvrStatus WINAPI kvrWlanGetScanResults(kvrConfigHandle handle,
|
---|
491 | int32_t *rssi,
|
---|
492 | int32_t *channel,
|
---|
493 | kvrAddress *mac,
|
---|
494 | int32_t *bss_type,
|
---|
495 | char *ssid,
|
---|
496 | uint32_t *capability,
|
---|
497 | uint32_t *type_wpa,
|
---|
498 | kvrCipherInfoElement *wpa_info,
|
---|
499 | kvrCipherInfoElement *rsn_info);
|
---|
500 |
|
---|
501 | /**
|
---|
502 | * Read the device Hostname.
|
---|
503 | *
|
---|
504 | * \param[in] handle A configuration handle
|
---|
505 | * \param[out] buffer The device Hostname as a C string.
|
---|
506 | * \param[in] buffer_size The device Hostname buffer size.
|
---|
507 | *
|
---|
508 | * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
|
---|
509 | */
|
---|
510 | kvrStatus WINAPI kvrNetworkGetHostName(kvrConfigHandle handle,
|
---|
511 | char* buffer, uint32_t buffer_size);
|
---|
512 |
|
---|
513 | /**
|
---|
514 | * Read the generated Hostname.
|
---|
515 | *
|
---|
516 | * \param[in] ean_hi The device EAN_high number.
|
---|
517 | * \param[in] ean_lo The device EAN_low number.
|
---|
518 | * \param[in] ser_no The device serial number.
|
---|
519 | * \param[out] buffer The device Hostname as a C string.
|
---|
520 | * \param[in] buffer_size The device Hostname buffer size.
|
---|
521 | *
|
---|
522 | * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
|
---|
523 | */
|
---|
524 | kvrStatus WINAPI kvrHostName(uint32_t ean_hi, uint32_t ean_lo, uint32_t ser_no,
|
---|
525 | char* buffer, uint32_t buffer_size);
|
---|
526 |
|
---|
527 |
|
---|
528 | /**
|
---|
529 | * Get connection status information.
|
---|
530 | *
|
---|
531 | * \param[in] handle A configuration handle.
|
---|
532 | * \param[out] state Network connection state, see \ref kvrNetworkState_xxx.
|
---|
533 | * \param[out] tx_rate Transmit rate in kbit/s.
|
---|
534 | * \param[out] rx_rate Receive rate in kbit/s.
|
---|
535 | * \param[out] channel Channel.
|
---|
536 | * \param[out] rssi Receive Signal Strength Indicator (RSSI).
|
---|
537 | * \param[out] tx_power Transmit power level in dB.
|
---|
538 | *
|
---|
539 | * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
|
---|
540 | */
|
---|
541 | kvrStatus WINAPI kvrNetworkGetConnectionStatus(kvrConfigHandle handle,
|
---|
542 | int32_t *state,
|
---|
543 | int32_t *tx_rate,
|
---|
544 | int32_t *rx_rate,
|
---|
545 | int32_t *channel,
|
---|
546 | int32_t *rssi,
|
---|
547 | int32_t *tx_power);
|
---|
548 |
|
---|
549 | /**
|
---|
550 | * Get information about the network address settings.
|
---|
551 | * For a WLAN connected device, address1, netmask and gateway are IP addresses
|
---|
552 | * and address2 is the MAC address.
|
---|
553 | *
|
---|
554 | * \param[in] handle A configuration handle.
|
---|
555 | * \param[out] address1 The first address associated with the device.
|
---|
556 | * \param[out] address2 The second address associated with the device.
|
---|
557 | * \param[out] netmask The netmask for the device.
|
---|
558 | * \param[out] gateway The gateway for the device.
|
---|
559 | * \param[out] dhcp The device ueses Dynamic Host Configuration
|
---|
560 | * Protocol (DHCP).
|
---|
561 | *
|
---|
562 | * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
|
---|
563 | */
|
---|
564 | kvrStatus WINAPI kvrNetworkGetAddressInfo(kvrConfigHandle handle,
|
---|
565 | kvrAddress *address1,
|
---|
566 | kvrAddress *address2,
|
---|
567 | kvrAddress *netmask,
|
---|
568 | kvrAddress *gateway,
|
---|
569 | int32_t *dhcp);
|
---|
570 |
|
---|
571 | /**@}*/
|
---|
572 |
|
---|
573 | /**
|
---|
574 | * \defgroup Discovery Device discovery
|
---|
575 | */
|
---|
576 | /**@{*/
|
---|
577 |
|
---|
578 | /**
|
---|
579 | * Remote device usage status.
|
---|
580 | * \anchor kvrDeviceUsage_xxx
|
---|
581 | * \name kvrDeviceUsage_xxx
|
---|
582 | * @{
|
---|
583 | */
|
---|
584 |
|
---|
585 | #define kvrDeviceUsage_UNKNOWN 0 /**< Unknown (e.g., no reply from device). */
|
---|
586 | #define kvrDeviceUsage_FREE 1 /**< Not in use. */
|
---|
587 | #define kvrDeviceUsage_REMOTE 2 /**< Connected to a PC (as a remote device). */
|
---|
588 | #define kvrDeviceUsage_USB 3 /**< Connected via USB cable. */
|
---|
589 | #define kvrDeviceUsage_CONFIG 4 /**< Device is being configured via USB. */
|
---|
590 | /** @} */
|
---|
591 |
|
---|
592 |
|
---|
593 | /**
|
---|
594 | * Remote device accessability status.
|
---|
595 | * \anchor kvrAccessibility_xxx
|
---|
596 | * \name kvrAccessibility_xxx
|
---|
597 | */
|
---|
598 | #define kvrAccessibility_UNKNOWN 0 /**< Unknown (e.g., no reply from device). */
|
---|
599 | #define kvrAccessibility_PUBLIC 1 /**< Public (visible for all, no password required to connect). */
|
---|
600 | #define kvrAccessibility_PROTECTED 2 /**< Protected (visible for all, password needed to connect). */
|
---|
601 | #define kvrAccessibility_PRIVATE 3 /**< Private (invisible, password needed to connect). */
|
---|
602 | /** @} */
|
---|
603 |
|
---|
604 | /**
|
---|
605 | * State of connection to device.
|
---|
606 | * \anchor kvrRemoteState_xxx
|
---|
607 | * \name kvrRemoteState_xxx
|
---|
608 | * @{
|
---|
609 | */
|
---|
610 |
|
---|
611 | #define kvrRemoteState_VOID 0 /**< Marked as not in list. */
|
---|
612 | #define kvrRemoteState_AVAILABLE 1 /**< Tries to ping known device. */
|
---|
613 | #define kvrRemoteState_DISCOVERED 2 /**< Currently not used. */
|
---|
614 | #define kvrRemoteState_STARTING 3 /**< Initializes for new device. */
|
---|
615 | #define kvrRemoteState_STARTED 4 /**< Currently not used. */
|
---|
616 | #define kvrRemoteState_CONNECTION_DOWN 5 /**< Will try and restore connection. */
|
---|
617 | #define kvrRemoteState_CONNECTION_UP 6 /**< Device connected, heartbeat up. */
|
---|
618 | #define kvrRemoteState_REDISCOVER 7 /**< Trying to talk to device. */
|
---|
619 | #define kvrRemoteState_UNWILLING 8 /**< Device turned down connection req. */
|
---|
620 | #define kvrRemoteState_REDISCOVER_PENDING 9 /**< Will do rediscover in a moment. */
|
---|
621 | #define kvrRemoteState_CLOSING 10 /**< Will stop communication. */
|
---|
622 | #define kvrRemoteState_REMOVE_ME 11 /**< Device removed, it will be stopped. */
|
---|
623 | #define kvrRemoteState_STANDBY 12 /**< Known device, but unused. */
|
---|
624 | #define kvrRemoteState_CONFIG_CHANGED 13 /**< Same as UNWILLING. */
|
---|
625 | #define kvrRemoteState_STOPPING 14 /**< Tries to stop device. */
|
---|
626 | #define kvrRemoteState_INSTALLING 15 /**< Driver installation is in progress. */
|
---|
627 | /** @} */
|
---|
628 |
|
---|
629 | /**
|
---|
630 | * Device avalability flags.
|
---|
631 | * \anchor kvrAvailability_xxx
|
---|
632 | * \name kvrAvailability_xxx
|
---|
633 | * @{
|
---|
634 | */
|
---|
635 | #define kvrAvailability_NONE 0 /**< Manually added. */
|
---|
636 | #define kvrAvailability_FOUND_BY_SCAN 1 /**< Device was found by scan. */
|
---|
637 | #define kvrAvailability_STORED 2 /**< Device was stored. */
|
---|
638 | /** @} */
|
---|
639 |
|
---|
640 |
|
---|
641 | /**
|
---|
642 | * \brief Holds information about a discovered device.
|
---|
643 | *
|
---|
644 | * The information in here is returned when a device is discovered.
|
---|
645 | * For a WLAN connected device, device_address and client_address are IP
|
---|
646 | * addresses, and base_station_id is the ethernet MAC address of the AP.
|
---|
647 | *
|
---|
648 | * Depending on the "availability" flag, not all fields may be used. If
|
---|
649 | * "availability" includes the flag \ref kvrAvailability_STORED the following
|
---|
650 | * fields are set: ean_hi, ean_lo, ser_no, device_address, request_connection,
|
---|
651 | * name and accessibility_pwd.
|
---|
652 | *
|
---|
653 | * If the field "availability" includes the flag
|
---|
654 | * \ref kvrAvailability_FOUND_BY_SCAN, the following fields are set: fw_major_ver,
|
---|
655 | * fw_minor_ver, fw_build_ver, usage, accessibility, host_name and
|
---|
656 | * client_address.
|
---|
657 | */
|
---|
658 | typedef struct {
|
---|
659 | uint32_t struct_size; /**< Size of struct, used for compatibility. */
|
---|
660 | uint32_t ean_hi; /**< High part of EAN. */
|
---|
661 | uint32_t ean_lo; /**< Low part of EAN. */
|
---|
662 | uint32_t ser_no; /**< Serial number. */
|
---|
663 | int32_t fw_major_ver; /**< Major firmware version. */
|
---|
664 | int32_t fw_minor_ver; /**< Minor firmware version. */
|
---|
665 | int32_t fw_build_ver; /**< Firmware build version. */
|
---|
666 | char name[256]; /**< User-defined name. */
|
---|
667 | char host_name[256]; /**< DNS hostname or empty. */
|
---|
668 | int32_t usage; /**< \ref kvrDeviceUsage_xxx. */
|
---|
669 | int32_t accessibility; /**< \ref kvrAccessibility_xxx. */
|
---|
670 | char accessibility_pwd[256]; /**< Accessibility password or empty. */
|
---|
671 | kvrAddress device_address; /**< Address of remote device. */
|
---|
672 | kvrAddress client_address; /**< Address of connected client, if any. */
|
---|
673 | kvrAddress base_station_id; /**< Unique ID of base station, if any. */
|
---|
674 | int32_t request_connection; /**< Activate or deactivate a request for connection to a specified device.
|
---|
675 | * Activation means that the device will be connected to when it appears in the
|
---|
676 | * future. */
|
---|
677 | int32_t availability; /**< The device availability. One or more \ref kvrAvailability_xxx flags.*/
|
---|
678 | char encryption_key[32]; /**< Encryption key. */
|
---|
679 | char reserved1[256];
|
---|
680 | char reserved2[256];
|
---|
681 | } kvrDeviceInfo;
|
---|
682 |
|
---|
683 | /**
|
---|
684 | * Handle used for discovery.
|
---|
685 | */
|
---|
686 | typedef int32_t kvrDiscoveryHandle;
|
---|
687 |
|
---|
688 |
|
---|
689 | /**
|
---|
690 | * Flags for setting what addresses that should be returned by
|
---|
691 | * \ref kvrDiscoveryGetDefaultAddresses().
|
---|
692 | * \anchor kvrAddressTypeFlag_xxx
|
---|
693 | * \name kvrAddressTypeFlag_xxx
|
---|
694 | * @{
|
---|
695 | */
|
---|
696 | #define kvrAddressTypeFlag_ALL 0xff /**< All defined below */
|
---|
697 | #define kvrAddressTypeFlag_BROADCAST 0x01 /**< Broadcast addresses */
|
---|
698 | #define kvrAddressTypeFlag_STORED 0x02 /**< Previously stored addresses */
|
---|
699 | /** @} */
|
---|
700 |
|
---|
701 | /**
|
---|
702 | * Read out the list of default broadcast addresses. If \a address_type_flags
|
---|
703 | * is set to \ref kvrAddressTypeFlag_ALL the returned list will contain all found
|
---|
704 | * addresses (both broadcast addresses and earlier stored addresses).
|
---|
705 | *
|
---|
706 | * \param[out] address_list An array of addresses.
|
---|
707 | * \param[in] address_list_size Number of entries in \a address_list.
|
---|
708 | * \param[out] address_list_count Number of addresses returned.
|
---|
709 | * \param[in] address_type_flags Which \ref kvrAddressTypeFlag_xxx types of addresses to return
|
---|
710 | *
|
---|
711 | * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
|
---|
712 | */
|
---|
713 | kvrStatus WINAPI kvrDiscoveryGetDefaultAddresses(kvrAddress address_list[],
|
---|
714 | uint32_t address_list_size,
|
---|
715 | uint32_t *address_list_count,
|
---|
716 | uint32_t address_type_flags);
|
---|
717 |
|
---|
718 | /**
|
---|
719 | * Create a handle for device discovery. Used by for instance \ref kvrDiscoveryStart().
|
---|
720 | * Close with \ref kvrDiscoveryClose().
|
---|
721 | *
|
---|
722 | * \param[out] handle Discovery handle.
|
---|
723 | *
|
---|
724 | * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
|
---|
725 | */
|
---|
726 | kvrStatus WINAPI kvrDiscoveryOpen(kvrDiscoveryHandle *handle);
|
---|
727 |
|
---|
728 | /**
|
---|
729 | * Closes the discovery handle opened with \ref kvrDiscoveryOpen().
|
---|
730 | *
|
---|
731 | * \param[in] handle Discovery handle.
|
---|
732 | *
|
---|
733 | * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
|
---|
734 | */
|
---|
735 | kvrStatus WINAPI kvrDiscoveryClose(kvrDiscoveryHandle handle);
|
---|
736 |
|
---|
737 | /**
|
---|
738 | * Set a list of addresses to use for discovery (overwrites any
|
---|
739 | * existing addresses).
|
---|
740 | * Setting \a address_list_size with size = 0 will cause \ref kvrDiscoveryStart()
|
---|
741 | * to only return stored devices (no network traffic).
|
---|
742 | *
|
---|
743 | * \param[in] handle Discovery handle.
|
---|
744 | * \param[in] address_list An array of addresses.
|
---|
745 | * \param[in] address_list_size Number of entries in \a address_list.
|
---|
746 | * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
|
---|
747 | */
|
---|
748 | kvrStatus WINAPI kvrDiscoverySetAddresses(kvrDiscoveryHandle handle,
|
---|
749 | const kvrAddress address_list[],
|
---|
750 | uint32_t address_list_size);
|
---|
751 |
|
---|
752 |
|
---|
753 | /**
|
---|
754 | * Start discovering devices on the addresses previously specified with
|
---|
755 | * \ref kvrDiscoverySetAddresses(). A delay of \a delay_ms ms is inferred between
|
---|
756 | * each device address request. After the last device address is probed, one
|
---|
757 | * more delay of \a timeout_ms is added before returning.
|
---|
758 | *
|
---|
759 | * This means that the function will return in (about)
|
---|
760 | * <address_list_size> * \a delay_ms + \a timeout_ms ms
|
---|
761 | *
|
---|
762 | * The results can be retrieved using \ref kvrDiscoveryGetResults(). A new call to
|
---|
763 | * \ref kvrDiscoveryStart() will discard any results not yet retrieved by
|
---|
764 | * \ref kvrDiscoveryGetResults().
|
---|
765 | *
|
---|
766 | * To decide if an address is a broadcast address, the ip address and subnet
|
---|
767 | * mask for all availible network cards are considered.
|
---|
768 | *
|
---|
769 | * Beside returning the devices discovered by scan, it will also return any
|
---|
770 | * devices previously stored with \ref kvrDiscoveryStoreDevices().
|
---|
771 | *
|
---|
772 | * \note A remote device with accessibility set to "private" will not reply to
|
---|
773 | * a broadcast scan.
|
---|
774 | *
|
---|
775 | * \param[in] handle Discovery handle.
|
---|
776 | * \param[in] delay_ms Delay (in ms) in between sending discovery
|
---|
777 | * messages to addresses in the address list.
|
---|
778 | * \param[in] timeout_ms Stop waiting for device discovery after timeout_ms milliseconds.
|
---|
779 | *
|
---|
780 | * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
|
---|
781 | */
|
---|
782 | kvrStatus WINAPI kvrDiscoveryStart(kvrDiscoveryHandle handle, uint32_t delay_ms,
|
---|
783 | uint32_t timeout_ms);
|
---|
784 |
|
---|
785 | /**
|
---|
786 | * Call this after calling \ref kvrDiscoveryStart(). The first call will return the first result,
|
---|
787 | * second call will return the second etc.
|
---|
788 | * Will return found devices until \ref kvrERR_BLANK is returned.
|
---|
789 | *
|
---|
790 | * \param[in] handle Discovery handle.
|
---|
791 | * \param[out] device_info Device info.
|
---|
792 | *
|
---|
793 | * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
|
---|
794 | */
|
---|
795 | kvrStatus WINAPI kvrDiscoveryGetResults(kvrDiscoveryHandle handle,
|
---|
796 | kvrDeviceInfo *device_info);
|
---|
797 |
|
---|
798 | /**
|
---|
799 | * Store a list of devices that can be discovered later.
|
---|
800 | *
|
---|
801 | * \param[in] device_info_list A list of devices to remember.
|
---|
802 | * \param[in] device_info_list_size The number of elements in \a device_info_list.
|
---|
803 | *
|
---|
804 | * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
|
---|
805 | */
|
---|
806 | kvrStatus WINAPI kvrDiscoveryStoreDevices(const kvrDeviceInfo device_info_list[],
|
---|
807 | uint32_t device_info_list_size);
|
---|
808 |
|
---|
809 |
|
---|
810 | /**
|
---|
811 | * Turn automatic clearing of the stored devices on/off.
|
---|
812 | *
|
---|
813 | * \param[in] onoff Turn auto-clear on/off. TRUE: Stored devices will
|
---|
814 | * be cleared automatically when the application exits, even if the application
|
---|
815 | * terminates abnormally. FALSE: Stored devices will be stored until removed.
|
---|
816 | *
|
---|
817 | * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
|
---|
818 | */
|
---|
819 | kvrStatus WINAPI kvrDiscoveryClearDevicesAtExit(BOOL onoff);
|
---|
820 |
|
---|
821 | /**
|
---|
822 | * Sets the accessibility password to use when connecting to a device.
|
---|
823 | *
|
---|
824 | * \param[in] device_info The device to set the password for.
|
---|
825 | * \param[in] password The password as a C string.
|
---|
826 | *
|
---|
827 | * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
|
---|
828 | */
|
---|
829 | kvrStatus WINAPI kvrDiscoverySetPassword(kvrDeviceInfo *device_info,
|
---|
830 | const char *password);
|
---|
831 |
|
---|
832 | /**
|
---|
833 | * Sets the encryption key to use when encrypting communication.
|
---|
834 | *
|
---|
835 | * \param[in] device_info The device to set the password for.
|
---|
836 | * \param[in] key The key as a C string.
|
---|
837 | *
|
---|
838 | * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
|
---|
839 | */
|
---|
840 | kvrStatus WINAPI kvrDiscoverySetEncryptionKey(kvrDeviceInfo *device_info,
|
---|
841 | const char *key);
|
---|
842 |
|
---|
843 |
|
---|
844 | /**
|
---|
845 | * Returns local connection status of the selected device as ASCII text.
|
---|
846 | *
|
---|
847 | * \param[in] device_info The device to request the status information from.
|
---|
848 | * \param[out] buffer The service status as a C string.
|
---|
849 | * \param[in] buffer_size The service status buffer size.
|
---|
850 | *
|
---|
851 | * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
|
---|
852 | */
|
---|
853 | kvrStatus WINAPI kvrDeviceGetServiceStatusText(const kvrDeviceInfo *device_info,
|
---|
854 | char *buffer,
|
---|
855 | uint32_t buffer_size);
|
---|
856 |
|
---|
857 |
|
---|
858 | /**
|
---|
859 | * Current service state
|
---|
860 | * \anchor kvrServiceState_xxx
|
---|
861 | * \name kvrServiceState_xxx
|
---|
862 | * @{
|
---|
863 | */
|
---|
864 | #define kvrServiceState_VOID 0 /**< Void */
|
---|
865 | #define kvrServiceState_AVAILABLE 1 /**< Device available */
|
---|
866 | #define kvrServiceState_DISCOVERED 2 /**< Device discovered */
|
---|
867 | /**
|
---|
868 | * Device is starting, other devices may inhibit this device from being started
|
---|
869 | * at the moment (e.g. by installing).
|
---|
870 | */
|
---|
871 | #define kvrServiceState_STARTING 3
|
---|
872 | #define kvrServiceState_STARTED 4 /**< Device is started */
|
---|
873 | #define kvrServiceState_CONNECTION_DOWN 5 /**< Connection is currently down */
|
---|
874 | #define kvrServiceState_CONNECTION_UP 6 /**< Connection is corrently up */
|
---|
875 | #define kvrServiceState_REDISCOVER 7 /**< We've lost the device - rediscover it */
|
---|
876 | #define kvrServiceState_UNWILLING 8 /**< Unwilling, see sub state for reason */
|
---|
877 | #define kvrServiceState_REDISCOVER_PENDING 9 /**< Rediscover is pending */
|
---|
878 | #define kvrServiceState_CLOSING 10 /**< Closing */
|
---|
879 | #define kvrServiceState_REMOVE_ME 11 /**< Remove me */
|
---|
880 | #define kvrServiceState_STANDBY 12 /**< Standbe */
|
---|
881 | #define kvrServiceState_CONFIG_CHANGED 13 /**< Configuration has changed */
|
---|
882 | #define kvrServiceState_STOPPING 14 /**< Stopping */
|
---|
883 | #define kvrServiceState_INSTALLING 15 /**< Device is currently being installed */
|
---|
884 | /** @} */
|
---|
885 |
|
---|
886 | /**
|
---|
887 | * Current start information
|
---|
888 | * \anchor kvrStartInfo_xxx
|
---|
889 | * \name kvrStartInfo_xxx
|
---|
890 | * @{
|
---|
891 | */
|
---|
892 | #define kvrStartInfo_NONE 0 /**< No information available */
|
---|
893 | #define kvrStartInfo_START_OK 1 /**< Started OK */
|
---|
894 | #define kvrStartInfo_ERR_IN_USE 2 /**< Already connected to someone else */
|
---|
895 | #define kvrStartInfo_ERR_PWD 3 /**< Wrong connection pwd */
|
---|
896 | #define kvrStartInfo_ERR_NOTME 4 /**< This start is not for me */
|
---|
897 | #define kvrStartInfo_ERR_CONFIGURING 5 /**< I'm being configured so won't start */
|
---|
898 | #define kvrStartInfo_ERR_PARAM 6 /**< Invalid parameters in QRV (non matching versions) */
|
---|
899 | #define kvrStartInfo_ERR_ENCRYPTION_PWD 7 /**< Wrong encryption password. */
|
---|
900 | /** @} */
|
---|
901 |
|
---|
902 |
|
---|
903 | /**
|
---|
904 | * Returns local connection status of the selected device.
|
---|
905 | *
|
---|
906 | * \param[in] device_info The device to request the status information from.
|
---|
907 | * \param[out] state The service state as a \ref kvrServiceState_xxx
|
---|
908 | * \param[out] start_info The start information as a \ref kvrStartInfo_xxx
|
---|
909 | *
|
---|
910 | * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
|
---|
911 | */
|
---|
912 | kvrStatus WINAPI kvrDeviceGetServiceStatus(const kvrDeviceInfo *device_info,
|
---|
913 | int32_t *state, int32_t *start_info);
|
---|
914 |
|
---|
915 | /**@}*/
|
---|
916 |
|
---|
917 |
|
---|
918 |
|
---|
919 |
|
---|
920 | /**
|
---|
921 | * \defgroup Helper Helper functions
|
---|
922 | */
|
---|
923 | /**@{*/
|
---|
924 |
|
---|
925 | /**
|
---|
926 | * Convert a \ref kvrStatus errorcode to a text.
|
---|
927 | *
|
---|
928 | * \param[in] error The error code to convert.
|
---|
929 | * \param[out] buffer Buffer to receive error text.
|
---|
930 | * \param[in] buffer_size Buffer size in bytes.
|
---|
931 | */
|
---|
932 | kvrStatus WINAPI kvrGetErrorText(kvrStatus error, char *buffer,
|
---|
933 | uint32_t buffer_size);
|
---|
934 |
|
---|
935 | /**
|
---|
936 | * Return the version of the kvrlib DLL. The most significant byte is
|
---|
937 | * the major version number and the least significant byte is the
|
---|
938 | * minor version number.
|
---|
939 | *
|
---|
940 | * \source_cs <b>static short kvrGetVersion();</b>
|
---|
941 | *
|
---|
942 | * \source_delphi <b>function kvrGetVersion: Word;</b>
|
---|
943 | * \source_end
|
---|
944 | *
|
---|
945 | * \return version number of kvrlib32.dll
|
---|
946 | */
|
---|
947 | uint16_t WINAPI kvrGetVersion(void);
|
---|
948 |
|
---|
949 | /**
|
---|
950 | * Convert a \ref kvrAddress to a text string.
|
---|
951 | * The output format depends on the \ref kvrAddressType_xxx.
|
---|
952 | * \a buffer_size must be the maximum lenth for each type.
|
---|
953 | * i.e. \ref kvrAddressType_IPV4 must have lenght at least 16.
|
---|
954 | *
|
---|
955 | * \param[out] buffer The converted string as a C string.
|
---|
956 | * \param[in] buffer_size Size of buffer.
|
---|
957 | * \param[in] address The address to convert.
|
---|
958 | */
|
---|
959 | kvrStatus WINAPI kvrStringFromAddress(char *buffer, uint32_t buffer_size,
|
---|
960 | const kvrAddress *address);
|
---|
961 |
|
---|
962 | /**
|
---|
963 | * Convert a C string into a \ref kvrAddress.
|
---|
964 | *
|
---|
965 | * Examples:
|
---|
966 | * - <b>MAC address</b><br>
|
---|
967 | * address_string: "90:E6:BA:3C:32:12"<br>
|
---|
968 | * type: \ref kvrAddressType_MAC
|
---|
969 | *
|
---|
970 | * - <b>IP v.4</b><br>
|
---|
971 | * address_string: "192.168.1.142"<br>
|
---|
972 | * type: \ref kvrAddressType_IPV4
|
---|
973 | *
|
---|
974 | * - <b>IP v.4 with port</b><br>
|
---|
975 | * address_string: "192.168.1.142:8080"<br>
|
---|
976 | * type: \ref kvrAddressType_IPV4_PORT
|
---|
977 | *
|
---|
978 | *
|
---|
979 | * \param[in] address_type \ref kvrAddressType_xxx to convert into.
|
---|
980 | * \param[out] address Returned address.
|
---|
981 | * \param[in] address_string C string to convert into a kvrAddress.
|
---|
982 | */
|
---|
983 | kvrStatus WINAPI kvrAddressFromString(int32_t address_type, kvrAddress *address,
|
---|
984 | const char *address_string);
|
---|
985 |
|
---|
986 | /**
|
---|
987 | * Returns a C string in human readable format from the security
|
---|
988 | * information gathered with \ref kvrWlanGetScanResults()
|
---|
989 | *
|
---|
990 | * Example output:
|
---|
991 | * "WPA2: G-TKIP (PSK) P1-AES P2-TKIP WPA: G-TKIP (PSK) P1-AES P2-TKIP"
|
---|
992 | *
|
---|
993 | * The above example shows a network using Pre-Shared Key with both
|
---|
994 | * WPA2 and WPA enabled, for both modes, a group key using TKIP is
|
---|
995 | * needed, and in both modes you can choose between AES (CCMP) and
|
---|
996 | * TKIP as the cipher for the pairwise key.
|
---|
997 | *
|
---|
998 | * The length of the generated string could theoretically be up to
|
---|
999 | * about 180 characters. If the length of the supplied security_string
|
---|
1000 | * is too short, the result will be truncated and the function will
|
---|
1001 | * return \ref kvrERR_PARAMETER.
|
---|
1002 | *
|
---|
1003 | * \param[out] security_string A C string.
|
---|
1004 | * \param[in] security_string_size Max size of security_string.
|
---|
1005 | * \param[in] capability The advertised capabilities of the BSS.
|
---|
1006 | * \param[in] type_wpa Authentication suite type.
|
---|
1007 | * \param[in] wpa_info Advertised information for WPA.
|
---|
1008 | * \param[in] rsn_info Advertised information for RSN.
|
---|
1009 | *
|
---|
1010 | * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
|
---|
1011 | */
|
---|
1012 | kvrStatus WINAPI kvrWlanGetSecurityText(char *security_string,
|
---|
1013 | uint32_t security_string_size,
|
---|
1014 | uint32_t capability,
|
---|
1015 | uint32_t type_wpa,
|
---|
1016 | const kvrCipherInfoElement *wpa_info,
|
---|
1017 | const kvrCipherInfoElement *rsn_info);
|
---|
1018 |
|
---|
1019 | /**
|
---|
1020 | * Generates four 64-bit and one 128-bit WEP keys.
|
---|
1021 | *
|
---|
1022 | * All generated keys are returned as ASCII hexadecimal C strings.
|
---|
1023 | *
|
---|
1024 | * \param[in] pass_phrase The pass phrase as a C string.
|
---|
1025 | * \param[out] key64_1 Generated 64-bit WEP key 1 (10 + 1 bytes).
|
---|
1026 | * \param[out] key64_2 Generated 64-bit WEP key 2 (10 + 1 bytes).
|
---|
1027 | * \param[out] key64_3 Generated 64-bit WEP key 3 (10 + 1 bytes).
|
---|
1028 | * \param[out] key64_4 Generated 64-bit WEP key 4 (10 + 1 bytes).
|
---|
1029 | * \param[out] key128 Generated 128-bit WEP key (26 + 1 bytes).
|
---|
1030 | *
|
---|
1031 | * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
|
---|
1032 | */
|
---|
1033 | kvrStatus WINAPI kvrNetworkGenerateWepKeys(const char *pass_phrase,
|
---|
1034 | char *key64_1,
|
---|
1035 | char *key64_2,
|
---|
1036 | char *key64_3,
|
---|
1037 | char *key64_4,
|
---|
1038 | char *key128);
|
---|
1039 |
|
---|
1040 | /**
|
---|
1041 | * Generates a WPA key.
|
---|
1042 | *
|
---|
1043 | * \param[in] pass_phrase The pass phrase as a C string.
|
---|
1044 | * \param[in] ssid SSID as a C string. Maximum length is 32 bytes.
|
---|
1045 | * \param[out] key The WPA key, 256 bits as a an ASCII hexadecimal
|
---|
1046 | * C string (64 + 1 bytes).
|
---|
1047 | *
|
---|
1048 | * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
|
---|
1049 | */
|
---|
1050 | kvrStatus WINAPI kvrNetworkGenerateWpaKeys(const char *pass_phrase,
|
---|
1051 | const char *ssid,
|
---|
1052 | char *key);
|
---|
1053 |
|
---|
1054 | /**@}*/
|
---|
1055 |
|
---|
1056 | /**
|
---|
1057 | * Initializes library stuff.
|
---|
1058 | * Call this function before calling any other kvr function.
|
---|
1059 | */
|
---|
1060 | void WINAPI kvrInitializeLibrary(void);
|
---|
1061 |
|
---|
1062 |
|
---|
1063 | /**
|
---|
1064 | * Unloads library stuff.
|
---|
1065 | * Call this function after calling all other kvr functions.
|
---|
1066 | */
|
---|
1067 | void WINAPI kvrUnloadLibrary(void);
|
---|
1068 |
|
---|
1069 |
|
---|
1070 | /**
|
---|
1071 | * Queries the status of the helper service. The helper service is installed as a part
|
---|
1072 | * of the driver package and is normally set to automatic start.
|
---|
1073 | *
|
---|
1074 | * \note This API call requires read access to the service.
|
---|
1075 | *
|
---|
1076 | * \param[out] status Win32 status code on failure.
|
---|
1077 | *
|
---|
1078 | * \return \ref kvrOK on success (meaning that the service is running) or any other \ref kvrStatus on failure.
|
---|
1079 | */
|
---|
1080 | kvrStatus WINAPI kvrServiceQuery(int *status);
|
---|
1081 |
|
---|
1082 | /**
|
---|
1083 | * Starts the helper service. The helper service is installed as a part
|
---|
1084 | * of the driver package and is normally set to automatic start.
|
---|
1085 | *
|
---|
1086 | * \note This API call requires control access to the service.
|
---|
1087 | *
|
---|
1088 | * \param[out] status Win32 status code on failure.
|
---|
1089 | *
|
---|
1090 | * \return \ref kvrOK on success (meaning that the service is started or
|
---|
1091 | * already is running) or any other \ref kvrStatus on failure.
|
---|
1092 | */
|
---|
1093 | kvrStatus WINAPI kvrServiceStart(int *status);
|
---|
1094 |
|
---|
1095 | /**
|
---|
1096 | * Stops the helper service. The helper service is installed as a part
|
---|
1097 | * of the driver package and is normally set to automatic start.
|
---|
1098 | *
|
---|
1099 | * \note This API call requires control access to the service.
|
---|
1100 | *
|
---|
1101 | * \param[out] status Win32 status code on failure.
|
---|
1102 | *
|
---|
1103 | * \return \ref kvrOK on success (meaning that the service is stopped or
|
---|
1104 | * already is stopped) or any other \ref kvrStatus on failure.
|
---|
1105 | */
|
---|
1106 | kvrStatus WINAPI kvrServiceStop(int *status);
|
---|
1107 |
|
---|
1108 |
|
---|
1109 | /**
|
---|
1110 | * \mainpage Remote Device API
|
---|
1111 | *
|
---|
1112 | * <h1>THIS IS A PRELIMINARY VERSION AND SUBJECT TO CHANGE</h1>
|
---|
1113 | *
|
---|
1114 | * This is an API for remote devices.
|
---|
1115 | *
|
---|
1116 | * - \subpage page_configuration
|
---|
1117 | * - \subpage page_discovery
|
---|
1118 | * - \subpage page_network
|
---|
1119 | * - \subpage page_support
|
---|
1120 | *
|
---|
1121 | * \page page_support Support
|
---|
1122 | * For support, contact support@kvaser.com
|
---|
1123 | *
|
---|
1124 | * \page page_discovery Device discovery
|
---|
1125 | * The following is an example of calls that can be used for device discovery.
|
---|
1126 | *
|
---|
1127 | * Initialize/Unload library
|
---|
1128 | * - \ref kvrInitializeLibrary()
|
---|
1129 | * - \ref kvrUnloadLibrary()
|
---|
1130 | *
|
---|
1131 | * Get the default addresses used for discovering devices
|
---|
1132 | * - \ref kvrDiscoveryGetDefaultAddresses()
|
---|
1133 | *
|
---|
1134 | * Discover all devices
|
---|
1135 | * to the device list
|
---|
1136 | * - \ref kvrDiscoveryStart()
|
---|
1137 | * - \ref kvrDiscoveryGetResults()
|
---|
1138 | *
|
---|
1139 | * Save devices you want to remember or use.
|
---|
1140 | * - \ref kvrDiscoveryStoreDevices()
|
---|
1141 | *
|
---|
1142 | * Get device status
|
---|
1143 | * - \ref kvrDeviceGetServiceStatusText()
|
---|
1144 | *
|
---|
1145 | * \page page_configuration Local Configuration
|
---|
1146 | * When the remote device is connected to the host it can be configured.
|
---|
1147 | * A device can hold a number of different profiles. The number of profiles
|
---|
1148 | * that the device supports can be found by using \ref kvrConfigNoProfilesGet().
|
---|
1149 | * Each profile contains a complete configuration. To configure a specific
|
---|
1150 | * profile open it with \ref kvrConfigOpenEx(). To activate a specific profile
|
---|
1151 | * use \ref kvrConfigActiveProfileSet(). The active profile is the one the
|
---|
1152 | * device will use.
|
---|
1153 | *
|
---|
1154 | *
|
---|
1155 | * The following is an example of calls that are used to configure a device.
|
---|
1156 | *
|
---|
1157 | * Initialize/Unload library
|
---|
1158 | * - \ref kvrInitializeLibrary()
|
---|
1159 | * - \ref kvrUnloadLibrary()
|
---|
1160 | *
|
---|
1161 | * Get the number of supported profiles.
|
---|
1162 | * - \ref kvrConfigNoProfilesGet()
|
---|
1163 | *
|
---|
1164 | * Get and set the active profile.
|
---|
1165 | * - \ref kvrConfigActiveProfileGet()
|
---|
1166 | * - \ref kvrConfigActiveProfileSet()
|
---|
1167 | *
|
---|
1168 | * Open the device's configuration area. If protected, you need to enter a
|
---|
1169 | * password as well.
|
---|
1170 | * - \ref kvrConfigOpen()
|
---|
1171 | * - \ref kvrConfigOpenEx()
|
---|
1172 | *
|
---|
1173 | * If password is unknown, it is possible to first clear entire area including
|
---|
1174 | * password
|
---|
1175 | * - \ref kvrConfigClear()
|
---|
1176 | *
|
---|
1177 | * Write new configuration and read the configuration from the device
|
---|
1178 | * - \ref kvrConfigSet()
|
---|
1179 | * - \ref kvrConfigGet()
|
---|
1180 | *
|
---|
1181 | * Close the device's configuration area for writing
|
---|
1182 | * - \ref kvrConfigClose()
|
---|
1183 | *
|
---|
1184 | * \page page_network Network information
|
---|
1185 | * The following is an example of calls that are used for network maintenance.
|
---|
1186 | *
|
---|
1187 | * Initialize library
|
---|
1188 | * - \ref kvrInitializeLibrary()
|
---|
1189 | *
|
---|
1190 | * Start scan for existing WLAN networks and get the result
|
---|
1191 | * - \ref kvrWlanStartScan()
|
---|
1192 | * - \ref kvrWlanGetScanResults()
|
---|
1193 | *
|
---|
1194 | * Get device's IP settings
|
---|
1195 | * - \ref kvrNetworkGetAddressInfo()
|
---|
1196 | *
|
---|
1197 | * Get status information; WLAN connection state, RSSI, RTT, TX power etc.
|
---|
1198 | * - \ref kvrNetworkGetConnectionStatus()
|
---|
1199 | *
|
---|
1200 | * Start sending 'ping' and get latest RTT (and RSSI) values.
|
---|
1201 | * - \ref kvrNetworkConnectionTest()
|
---|
1202 | * - \ref kvrNetworkGetRssiRtt()
|
---|
1203 | */
|
---|
1204 |
|
---|
1205 |
|
---|
1206 | /**
|
---|
1207 | * \example kvrConnect.c
|
---|
1208 | * \example kvrConfig.c
|
---|
1209 | * \example kvrNetworkConnectionTest.c
|
---|
1210 | */
|
---|
1211 |
|
---|
1212 | #ifdef __cplusplus
|
---|
1213 | }
|
---|
1214 | #endif
|
---|
1215 |
|
---|
1216 | #endif
|
---|