]> begriffs open source - cmsis/blob - CMSIS/DoxyGen/Driver/src/Driver_WiFi.c
CMSIS Driver: removed volatile from status related typedefs APIs
[cmsis] / CMSIS / DoxyGen / Driver / src / Driver_WiFi.c
1 /**
2 \defgroup wifi_interface_gr WiFi Interface
3 \brief Driver API for WiFi (%Driver_WiFi.h)
4 \details 
5
6 Wi-Fi is technology for radio wireless local area networking of devices. Wi-Fi compatible devices typically
7 connect to the Internet via a WLAN and a wireless access point (AP) also called hotspot.
8
9 Wikipedia offers more information about 
10 the <a href="http://en.wikipedia.org/wiki/Ethernet" target="_blank"><b>WiFi</b></a>.
11
12 <b>Driver Block Diagram</b>
13
14 \image html WiFi.png  "Block Diagram of the WiFi interface"
15
16 <b>WiFi API</b>
17
18 The following header files define the Application Programming Interface (API) for the WiFi interface:
19   - \b %Driver_WiFi.h : Driver API for WiFi
20
21 The CMSIS-Driver WiFi provides access to the following interfaces:
22
23  - \ref wifi_control_gr "Control interface": setup and control the WiFi module.
24  - \ref wifi_management_gr "Management interface": allows you to configure and manage the connection
25    to the WiFi access point (AP) or configure and manage the access point (AP).
26  - \ref wifi_socket_gr "Socket interface": provides the interface to an IP stack that is running
27    on the WiFi module. This IP stack handles data communication.
28  - \ref wifi_bypass_gr "Bypass interface": is an optional interface and enables the transmission of
29    Ethernet frames with the WiFi module. Using this interface requires the IP stack running on the microcontroller.
30
31 The WiFi interface usually requires CMSIS-RTOS features (i.e. mutex) and is often implemented
32 with a peripheral device that is connected to the system using the SPI or UART interface. However,
33 there are also some microcontroller devices with WiFi interface on the chip.
34
35 The implementation of the WiFi CMSIS-Driver is therefore generally provided as a separate software pack.
36 It is often implemented as wrapper to the SDK (Software Development Kit) of the WiFi chipset.
37
38
39 <b>Driver Functions</b>
40
41 The driver functions are published in the access struct as explained in \ref DriverFunctions
42   - \ref ARM_DRIVER_WIFI : access struct for WiFi driver functions
43
44
45 <b>Example Code</b>
46
47 @{
48 */
49
50 /**
51 \struct  ARM_DRIVER_WIFI
52 \details 
53 The functions of the WiFi driver are accessed by function pointers exposed by this structure.
54 Refer to \ref DriverFunctions for overview information.
55
56 Each instance of a WiFi interface provides such an access structure. 
57 The instance is identified by a postfix number in the symbol name of the access structure, for example:
58  - \b Driver_WiFi0 is the name of the access struct of the first instance (no. \token{0}).
59  - \b Driver_WiFi1 is the name of the access struct of the second instance (no. \token{1}).
60
61 A middleware configuration setting allows connecting the middleware to a specific driver instance \b %Driver_WiFi<i>n</i>.
62 The default is \token{0}, which connects a middleware to the first instance of a driver.
63 *******************************************************************************************************************/
64
65
66 /**
67 \defgroup wifi_control_gr WiFi Control
68 \ingroup wifi_interface_gr
69 \brief Control functions for the WiFi module
70 \details  
71 The \ref wifi_control_gr functions setup and control the WiFi module.
72 @{
73 */
74
75 /** 
76 \struct  ARM_WIFI_CAPABILITIES
77 \details
78 A WiFi driver can be implemented with different capabilities.
79 The data fields of this structure encode the capabilities implemented by this driver.
80
81 <b>Returned by:</b>
82   - \ref ARM_WIFI_GetCapabilities
83 *******************************************************************************************************************/
84
85 /**
86 \typedef ARM_WIFI_SignalEvent_t
87 \details
88 Provides the typedef for the callback function \ref ARM_WIFI_SignalEvent.
89
90 <b>Parameter for:</b>
91   - \ref ARM_WIFI_Initialize
92 *******************************************************************************************************************/
93
94 /**
95 \defgroup wifi_event WiFi Events
96 \ingroup wifi_control_gr
97 \brief The WiFi driver generates call back events that are notified via the function \ref ARM_WIFI_SignalEvent.
98 \details The following call back notification events are generated:
99 @{
100 \def ARM_WIFI_EVENT_AP_CONNECT
101 \def ARM_WIFI_EVENT_AP_DISCONNECT
102 \def ARM_WIFI_EVENT_ETH_RX_FRAME
103 @}
104 */
105
106 ARM_DRIVER_VERSION ARM_WIFI_GetVersion (void) {
107   return { 0, 0 };
108 }
109 /**
110 \fn ARM_DRIVER_VERSION ARM_WIFI_GetVersion (void)
111 \details
112 The function \b ARM_WIFI_GetVersion returns version information of the driver implementation in \ref ARM_DRIVER_VERSION.
113
114 API version is the version of the CMSIS-Driver specification used to implement this driver.
115 Driver version is source code version of the actual driver implementation.
116
117 \b Example:
118 \code
119 extern ARM_DRIVER_WIFI Driver_WiFi0;
120 static ARM_DRIVER_WIFI *wifi;
121  
122 void get_wifi_version (void)  {
123   ARM_DRIVER_VERSION version;
124  
125   wifi= &Driver_WiFi0;  
126   version = wifi->GetVersion ();
127   if (version.api < 0x100U) {        // requires at minimum API version 1.0 or higher
128     // error handling
129     return;
130   }
131 }
132 \endcode
133 */
134
135 ARM_WIFI_CAPABILITIES ARM_WIFI_GetCapabilities (void) {
136   return { 0 };
137 }
138 /**
139 \fn ARM_WIFI_CAPABILITIES ARM_WIFI_GetCapabilities (void)
140 \details
141 The function \b ARM_WIFI_GetCapabilities retrieves information about capabilities in this driver implementation.
142 The data fields of the struct \ref ARM_WIFI_CAPABILITIES encode various capabilities, for example
143 if a WiFi module supports the Access Point mode or the bypass mode, or is capable to signal events using
144 the \ref ARM_WIFI_SignalEvent callback function.
145
146 \b Example:
147 \code
148 extern ARM_DRIVER_WIFI Driver_WiFi0;
149 static ARM_DRIVER_WIFI *wifi;
150   
151 void get_wifi_capabilities (void)  {
152   ARM_WIFI_CAPABILITIES capabilities;
153  
154   wifi = &Driver_WiFi0;  
155   capabilities = wifi->GetCapabilities ();
156   // interrogate capabilities
157    :
158 }
159 \endcode
160 */
161
162 int32_t ARM_WIFI_Initialize (ARM_WIFI_SignalEvent_t cb_event) {
163   return ARM_DRIVER_OK;
164 }
165 /**
166 \fn int32_t ARM_WIFI_Initialize (ARM_WIFI_SignalEvent_t cb_event)
167 \details
168 The function \b ARM_WIFI_Initialize initializes the WiFi module.
169
170 It is called when the middleware component starts operation.
171
172 The \ref ARM_WIFI_Initialize function performs the following operations:
173   - Initializes the resources and peripherals required for the WiFi module.
174   - Registers the \ref ARM_WIFI_SignalEvent callback function.
175
176 The parameter \em cb_event is a pointer to the \ref ARM_WIFI_SignalEvent callback function;
177 use a \token{NULL} pointer when no callback signals are required.
178
179 \b Example:
180 \code
181 extern ARM_DRIVER_WIFI Driver_WiFi0;
182 static ARM_DRIVER_WIFI *wifi;
183 static ARM_ETH_MAC_ADDR own_mac_address;
184  
185 void initialize_wifi (void) {
186   wifi = &Driver_WiFi0;
187  
188   // Initialize and Power-on WiFi Module
189   wifi->Initialize (NULL);
190   wifi->PowerControl (ARM_POWER_FULL);
191  
192   // Populate own_mac_address with the address to use
193   wifi->SetOption(ARM_WIFI_MAC, &own_mac_address, 6U);
194 }
195 \endcode
196 */
197
198 int32_t ARM_WIFI_Uninitialize (void) {
199   return ARM_DRIVER_OK;
200 }
201 /**
202 \fn int32_t ARM_WIFI_Uninitialize (void)
203 \details
204 The function \b ARM_WIFI_Uninitialize de-initializes the resources of the WiFi module.
205
206 It is called when the middleware component stops operation and releases the software resources 
207 used by the module.
208
209 \b Example:
210 \code
211 extern ARM_DRIVER_WIFI Driver_WiFi0;
212 static ARM_DRIVER_WIFI *wifi;
213  
214 void uninitialize_wifi (void) {
215   wifi = &Driver_WiFi0;
216  
217   // Power off and De-initialize WiFi Module
218   wifi->PowerControl (ARM_POWER_OFF);
219   wifi->Uninitialize ();
220 }
221 \endcode
222 */
223
224 int32_t ARM_WIFI_PowerControl (ARM_POWER_STATE state) {
225   return ARM_DRIVER_OK;
226 }
227 /**
228 \fn int32_t ARM_WIFI_PowerControl (ARM_POWER_STATE state)
229 \details
230 The function \b ARM_WIFI_PowerControl allows you to configure the power modes of the WiFi module.
231
232 The parameter \em state specifies the \ref ARM_POWER_STATE.
233
234 Low-power mode depends on additional options set by \ref ARM_WIFI_SetOption :
235  - Deep-sleep mode is entered when \ref ARM_WIFI_LP_TIMER option is set to a value different than 0
236  - Sleep mode is entered otherwise
237
238 \b Deep-sleep mode (only for station):
239 Module turns off the radio and also internal CPU thus reducing power consumption to minimum,
240 only the timer is running that wakes-up the module after specified time.
241 When timer expires the module reconnects to the access point.
242
243 This mode is used when power consumption is a priority (battery powered devices) and when WiFi
244 is used in short intervals that do not occur very often
245 (example: sending a temperature from a sensor to a cloud every 10 seconds).
246
247 \b Sleep mode (only for station):
248 Module reduces power consumption by going into sleep and waking up periodically to listen for beacons.
249
250 Delivery Traffic Indication Message (DTIM) interval can be configured with option \ref ARM_WIFI_DTIM
251 (station and access point) and beacon interval with option \ref ARM_WIFI_BEACON (only for access point).
252
253 Default module intervals are used when those options are not explicitly set.
254
255 If power \em state specifies an unsupported mode, the function returns \ref ARM_DRIVER_ERROR_UNSUPPORTED as
256 status information and the previous power state of the peripheral is unchanged. Multiple calls with the same
257 \em state generate no error.
258
259 \b Example:
260  - see \ref ARM_WIFI_Initialize
261  - see \ref ARM_WIFI_Uninitialize
262 */
263
264 int32_t ARM_WIFI_GetModuleInfo (char *module_info, uint32_t max_len) {
265   return ARM_DRIVER_OK;
266 }
267 /**
268 \fn int32_t ARM_WIFI_GetModuleInfo (char *module_info, uint32_t max_len)
269 \details
270 The function \b ARM_WIFI_GetModuleInfo retrieves string containing information about the WiFi module.
271
272 The information might include module name, firmware version, ...
273
274 \note Module must be initialized and powered before module information can be retrieved.
275
276 \b Example:
277 \code
278 extern ARM_DRIVER_WIFI Driver_WiFi0;
279 static ARM_DRIVER_WIFI *wifi;
280  
281 void initialize_wifi (void) {
282   char info[32];
283  
284   wifi = &Driver_WiFi0;
285  
286   // Initialize and Power-on WiFi Module
287   wifi->Initialize (NULL);
288   wifi->PowerControl (ARM_POWER_FULL);
289  
290   // Retrieve module information
291   wifi->GetModuleInfo(&info, sizeof(info));
292 }
293 \endcode
294 */
295
296 void ARM_WIFI_SignalEvent (uint32_t event, void *arg) {
297 }
298 /**
299 \fn void ARM_WIFI_SignalEvent (uint32_t event, void *arg)
300 \details
301 The function \b ARM_WIFI_SignalEvent is a callback function registered by the function \ref ARM_WIFI_Initialize.
302 It is called by the WiFi driver to notify the application about WiFi Events occurred during operation.
303
304 The parameter \em event indicates the event that occurred during driver operation.
305
306 The parameter \em arg provides additional information about the event.
307
308 The following events can be generated:
309
310 Parameter \em event                  | Description
311 :------------------------------------|:------------------------------------------
312 \ref ARM_WIFI_EVENT_AP_CONNECT       | Occurs in access point mode when a station has connected to the access point.
313 \ref ARM_WIFI_EVENT_AP_DISCONNECT    | Occurs in access point mode when a station has disconnected from the access point.
314 \ref ARM_WIFI_EVENT_ETH_RX_FRAME     | Occurs in \ref wifi_bypass_gr when an ethernet frame is received.
315 */
316
317 /**
318 @}
319 */
320 // end group wifi_control_gr
321
322
323 /**
324 \defgroup wifi_management_gr WiFi Management
325 \ingroup wifi_interface_gr
326 \brief Configure and manage the connection to a WiFi access point (AP) or configure and manage the access point (AP).
327 \details The \ref wifi_management_gr functions are used to configure and manage the connection to a WiFi access point (AP)
328 also called hotspot when in station mode. They are also used to configure and manage the access point (AP) itself
329 when in access point mode.
330 @{
331 */
332
333 /**
334 \defgroup WiFi_option WiFi Option Codes
335 \ingroup wifi_management_gr
336 \brief  WiFi Option Codes for \ref ARM_WIFI_SetOption or \ref ARM_WIFI_GetOption function.
337 \details 
338 Many parameters of the WiFi module are configured using the \ref ARM_WIFI_SetOption or \ref ARM_WIFI_GetOption function.
339 @{
340 \def ARM_WIFI_BSSID
341 \details Specifies the BSSID of the access point to connect or the access point itself.
342 \sa WiFi_option
343 \def ARM_WIFI_TX_POWER
344 \details Specifies the transmit power in dBm.
345 \sa WiFi_option
346 \def ARM_WIFI_LP_TIMER
347 \details Specifies the low-power deep-sleep time in seconds for station (disabled when 0 - default).
348 \sa WiFi_option
349 \def ARM_WIFI_DTIM
350 \details Specifies the DTIM interval in number of beacons.
351 \sa WiFi_option
352 \def ARM_WIFI_BEACON
353 \details Specifies the beacon interval in milliseconds for access point.
354 \sa WiFi_option
355 \def ARM_WIFI_MAC
356 \details Specifies the MAC address.
357 \sa WiFi_option
358 \def ARM_WIFI_IP
359 \details Specifies the IP address.
360 \sa WiFi_option
361 \def ARM_WIFI_IP_SUBNET_MASK
362 \details Specifies the subnet mask.
363 \sa WiFi_option
364 \def ARM_WIFI_IP_GATEWAY
365 \details Specifies the gateway IP address.
366 \sa WiFi_option
367 \def ARM_WIFI_IP_DNS1
368 \details Specifies the IP address of the primary DNS server.
369 \sa WiFi_option
370 \def ARM_WIFI_IP_DNS2
371 \details Specifies the IP address of the secondary DNS server.
372 \sa WiFi_option
373 \def ARM_WIFI_IP_DHCP
374 \details Enables or disables the DHCP client for station or DHCP server for access point.
375 \sa WiFi_option
376 \def ARM_WIFI_IP_DHCP_POOL_BEGIN
377 \details Specifies the start IP address for DHCP server (access point).
378 \sa WiFi_option
379 \def ARM_WIFI_IP_DHCP_POOL_END
380 \details Specifies the end IP address for DHCP server (access point).
381 \sa WiFi_option
382 \def ARM_WIFI_IP_DHCP_LEASE_TIME
383 \details Specifies the lease time for DHCP server (access point).
384 \sa WiFi_option
385 \def ARM_WIFI_IP6_GLOBAL
386 \details Specifies the global IPv6 address.
387 \sa WiFi_option
388 \def ARM_WIFI_IP6_LINK_LOCAL
389 \details Specifies the link-local IPv6 address.
390 \sa WiFi_option
391 \def ARM_WIFI_IP6_SUBNET_PREFIX_LEN
392 \details Specifies the address prefix length.
393 \sa WiFi_option
394 \def ARM_WIFI_IP6_GATEWAY
395 \details Specifies the gateway IPv6 address.
396 \sa WiFi_option
397 \def ARM_WIFI_IP6_DNS1
398 \details Specifies the IPv6 address of the primary DNS server.
399 \sa WiFi_option
400 \def ARM_WIFI_IP6_DNS2
401 \details Specifies the IPv6 address of the secondary DNS server.
402 \sa WiFi_option
403 \def ARM_WIFI_IP6_DHCP_MODE
404 \details Specifies the operation mode of the DHCPv6 client.
405 \sa WiFi_option
406 @}
407 */
408
409 /**
410 \defgroup wifi_sec_type WiFi Security Type
411 \ingroup wifi_management_gr
412 \brief Specifies WiFi security type for \ref ARM_WIFI_Activate.
413 \details
414 The WiFi security type defines the standard used to protect the wireless network from unauthorized access.
415 @{
416 \def ARM_WIFI_SECURITY_OPEN
417 \details This is an open system which provides \b no security.
418 \sa wifi_sec_type
419 \def ARM_WIFI_SECURITY_WEP
420 \details This security standard provides \b weak level of security.
421 \sa wifi_sec_type
422 \def ARM_WIFI_SECURITY_WPA
423 \details This security standard provides \b medium level of security.
424 \sa wifi_sec_type
425 \def ARM_WIFI_SECURITY_WPA2
426 \details This security standard provides \b strong level of security.
427 \sa wifi_sec_type
428 \def ARM_WIFI_SECURITY_UNKNOWN
429 \details Unknown security standard (reported by \ref ARM_WIFI_Scan).
430 \sa wifi_sec_type
431 @}
432 */
433
434 /**
435 \defgroup wifi_wps_method WiFi Protected Setup (WPS) Method
436 \ingroup wifi_management_gr
437 \brief Specifies WiFi WPS method for \ref ARM_WIFI_Activate.
438 \details
439 The WiFi WPS method defines which WPS method is used.
440 @{
441 \def ARM_WIFI_WPS_METHOD_NONE
442 \details WPS not used.
443 \sa wifi_wps_method
444 \def ARM_WIFI_WPS_METHOD_PBC
445 \details WPS with Push Button Configuration.
446 \sa wifi_wps_method
447 \def ARM_WIFI_WPS_METHOD_PIN
448 \details WPS with PIN.
449 \sa wifi_wps_method
450 @}
451 */
452
453 /**
454 \defgroup wifi_dhcp_v6_mode WiFi DHCPv6 Mode
455 \ingroup wifi_management_gr
456 \brief Specifies IPv6 Dynamic Host Configuration Protocol (DHCP) Mode.
457 \details
458 The WiFi DHCPv6 mode defines the DHCP mode in IPv6.
459 @{
460 \def ARM_WIFI_IP6_DHCP_OFF
461 \details
462 In the static host configuration mode, the IPv6 address, the default gateway address,
463 and the addresses of DNS servers are statically configured from the preset values.
464 \sa wifi_dhcp_v6_mode
465 \def ARM_WIFI_IP6_DHCP_STATELESS
466 \details
467 In the stateless DHCP configuration mode, the client obtains only extended information
468 from a DHCPv6 server, such as DNS server addresses. Stateless auto-configuration of
469 IPv6 allows the client device to self configure it's IPv6 addresses and routing based
470 on the router advertisements.
471 \sa wifi_dhcp_v6_mode
472 \def ARM_WIFI_IP6_DHCP_STATEFULL
473 \details
474 In the stateful DHCP configuration mode, the client connects to a DHCPv6 server for
475 a leased IPv6 address and DNS server addresses.
476 \sa wifi_dhcp_v6_mode
477 @}
478 */
479
480 /**
481 \struct  ARM_WIFI_CONFIG_t
482 \details
483 Provides information needed to connect to the WiFi network for station or how to configure the access point (AP).
484
485 <b>Used in:</b>
486   - \ref ARM_WIFI_Activate
487 *******************************************************************************************************************/
488
489 /**
490 \struct  ARM_WIFI_SCAN_INFO_t
491 \details
492 Provides information about the wireless networks that were detected when searching for available WiFi networks. The structure
493 contains the information needed to connect to the WiFi network. Of course, the access password is not included and must
494 be provided separately.
495
496 <b>Used in:</b>
497   - \ref ARM_WIFI_Scan
498 *******************************************************************************************************************/
499
500 /**
501 \struct  ARM_WIFI_NET_INFO_t
502 \details
503 Provides information about the network that the station is connected to.
504
505 <b>Used in:</b>
506   - \ref ARM_WIFI_GetNetInfo
507 *******************************************************************************************************************/
508
509 int32_t ARM_WIFI_SetOption (uint32_t interface, uint32_t option, const void *data, uint32_t len) {
510   return ARM_DRIVER_OK;
511 }
512 /**
513 \fn int32_t ARM_WIFI_SetOption (uint32_t interface, uint32_t option, const void *data, uint32_t len)
514 \details
515 The function \b ARM_WIFI_SetOption sets the value of the specified option of the WiFi module.
516
517 The argument \em interface specifies the interface (0 = Station, 1 = Access Point).
518
519 The argument \em option specifies the option that is to be set (see below).
520
521 The argument \em data points to a buffer containing the value of the option to be set
522 and must be aligned to the data type of the corresponding option.
523
524 The argument \em len specifies the length of the buffer \em data and must be equal (or higher)
525 to the length of the corresponding option.
526  
527 Option                                 | Description                            | Data          | Type/Length
528 :--------------------------------------|:---------------------------------------|:--------------|:-----------
529 \ref ARM_WIFI_BSSID                    | BSSID of AP to connect or AP           | bssid         | uint8_t[6]
530 \ref ARM_WIFI_TX_POWER                 | Transmit power                         | power[dbm]    | uint32_t
531 \ref ARM_WIFI_LP_TIMER                 | Low-power deep-sleep time              | time[seconds] | uint32_t
532 \ref ARM_WIFI_DTIM                     | DTIM interval                          | dtim[beacons] | uint32_t
533 \ref ARM_WIFI_BEACON                   | Beacon interval                        | interval[ms]  | uint32_t
534 \ref ARM_WIFI_MAC                      | MAC address                            | mac           | uint8_t[6]
535 \ref ARM_WIFI_IP                       | IPv4 address                           | ip            | uint8_t[4]
536 \ref ARM_WIFI_IP_SUBNET_MASK           | IPv4 subnet mask                       | mask          | uint8_t[4]
537 \ref ARM_WIFI_IP_GATEWAY               | IPv4 gateway address                   | ip            | uint8_t[4]
538 \ref ARM_WIFI_IP_DNS1                  | IPv4 primary DNS server address        | ip            | uint8_t[4]
539 \ref ARM_WIFI_IP_DNS2                  | IPv4 secondary DNS server address      | ip            | uint8_t[4]
540 \ref ARM_WIFI_IP_DHCP                  | IPv4 DHCP client/server enable/disable | dhcp (0, 1)   | uint32_t
541 \ref ARM_WIFI_IP_DHCP_POOL_BEGIN       | IPv4 DHCP server begin address         | ip            | uint8_t[4]
542 \ref ARM_WIFI_IP_DHCP_POOL_END         | IPv4 DHCP server end address           | ip            | uint8_t[4]
543 \ref ARM_WIFI_IP_DHCP_LEASE_TIME       | IPv4 DHCP server lease time            | time[seconds] | uint32_t
544 \ref ARM_WIFI_IP6_GLOBAL               | IPv6 global address                    | ip6           | uint8_t[16]
545 \ref ARM_WIFI_IP6_LINK_LOCAL           | IPv6 link-local address                | ip6           | uint8_t[16]
546 \ref ARM_WIFI_IP6_SUBNET_PREFIX_LEN    | IPv6 subnet prefix length              | len (1..127)  | uint32_t
547 \ref ARM_WIFI_IP6_GATEWAY              | IPv6 gateway address                   | ip6           | uint8_t[16]
548 \ref ARM_WIFI_IP6_DNS1                 | IPv6 primary DNS server address        | ip6           | uint8_t[16]
549 \ref ARM_WIFI_IP6_DNS2                 | IPv6 secondary DNS server address      | ip6           | uint8_t[16]
550 \ref ARM_WIFI_IP6_DHCP_MODE            | IPv6 DHCP client mode                  | mode          | uint32_t
551
552 \b Example:
553 \code
554 uint8_t ip[4];
555  
556 ip[0] = 192U;
557 ip[1] = 168U;
558 ip[2] = 0U;
559 ip[3] = 1U;
560  
561 // Set IP static address of the Station
562 wifi->SetOption (0U, ARM_WIFI_IP, &ip, sizeof(ip));
563 \endcode
564 */
565
566 int32_t ARM_WIFI_GetOption (uint32_t interface, uint32_t option, void *data, uint32_t *len) {
567   return ARM_DRIVER_OK;
568 }
569 /**
570 \fn int32_t ARM_WIFI_GetOption (uint32_t interface, uint32_t option, void *data, uint32_t *len)
571 \details
572 The function \b ARM_WIFI_GetOption retrieves the current value of the specified option of
573 the WiFi module.
574
575 The argument \em interface specifies the interface (0 = Station, 1 = Access Point).
576
577 The argument \em option specifies the option that is to be retrieved (see \ref ARM_WIFI_SetOption).
578
579 The argument \em data points to a buffer that will be used to store the value of 
580 the \em option and must be aligned to the data type of the corresponding option.
581
582 The argument \em len is a pointer to the length of the buffer at input and returns the length
583 of the option information on the output.
584
585 \b Example:
586 \code
587 uint8_t ip[4];          // IP address
588 uint8_t mask[4];        // Subnet mask
589 uint8_t gateway[4];     // Gateway address
590  
591 // Get IP address, Subnet mask and Gateway address of the Station
592 wifi->GetOption (0U, ARM_WIFI_IP, &ip, sizeof(ip));
593 wifi->GetOption (0U, ARM_WIFI_IP_SUBNET_MASK, &mask, sizeof(mask));
594 wifi->GetOption (0U, ARM_WIFI_IP_GATEWAY, &gateway, sizeof(gateway));
595 \endcode
596 */
597
598 int32_t ARM_WIFI_Scan (ARM_WIFI_SCAN_INFO_t scan_info[], uint32_t max_num) {
599   return ARM_DRIVER_OK;
600 }
601 /**
602 \fn int32_t ARM_WIFI_Scan (ARM_WIFI_SCAN_INFO_t scan_info[], uint32_t max_num)
603 \details
604 The function \b ARM_WIFI_Scan searches for available WiFi networks. Using this function,
605 you can determine which wireless networks are available for the connection. If the network is
606 secured, you must also know the password to connect.
607  
608 The argument \em scan_info is a pointer to an array of network information structures, where 
609 the available network information will be returned.
610
611 The argument \em max_num specifies maximum number of network information structures,
612 that can be stored to the \em scan_info.
613
614 \b Example:
615 \code
616 ARM_WIFI_SCAN_INFO_t scan_info[8];
617  
618 num = wifi->Scan (scan_info, 8U);
619  
620 // Print SSIDs of available WiFi networks
621 for (i = 0; i < num; i++) {
622   printf ("%d. ssid=%s\n", i, scan_info[i].ssid);
623 }
624 \endcode
625 */
626
627 int32_t ARM_WIFI_Activate (uint32_t interface, ARM_WIFI_CONFIG_t *config) {
628   return ARM_DRIVER_OK;
629 }
630 /**
631 \fn int32_t ARM_WIFI_Activate (uint32_t interface, ARM_WIFI_CONFIG_t *config)
632 \details
633 The function \b ARM_WIFI_Activate activates the specified interface.
634
635 The argument \em interface specifies the interface (0 = Station, 1 = Access Point).
636
637 When station interface is specified, the WiFi module connects to a wireless network.
638
639 The wireless network trying to connect to must be available,
640 otherwise the operation will fail after a timeout.
641
642 Available wireless networks can be scanned by using the function \ref ARM_WIFI_Scan.
643
644 When access point interface is specified, the WiFi module creates a wireless network
645 by activating the access point.
646
647 The argument \em config is a pointer to the configuration \ref ARM_WIFI_CONFIG_t
648 which provides information needed to connect to a WiFi network for station interface
649 or information used to configure the access point (AP) for access point interface.
650
651 \em ssid specifies the name of the network to connect to or the network to create.
652
653 \em pass specifies the password for accessing the wireless network.
654
655 \em security specifies the security type which will be used for the connection.
656
657 \em ch specifies the WiFi channel which will be used for the connection.
658 Valid channels for 2.4 GHz frequency are from \token{1} to \token{13}. If the value for \em ch = \token{0},
659 the system automatically selects the channel.
660 For station interface the channel of the AP being connected to is used.
661 For access point interface the module automatically selects the best channel for the WiFi connection.
662
663 \note
664 Optionally BSSID parameter can be also set using \ref ARM_WIFI_SetOption.
665 It allows connection to specific BSSID when connecting to an access point or specifies
666 the BSSID of the access point.
667
668 \em wps_method specifies if WiFi Protected Setup (WPS) is used and which method.
669
670 \em wps_pin specifies the PIN used with WPS (\ref ARM_WIFI_WPS_METHOD_PIN).
671
672 With the \b push-button method, you typically press the button, either real or virtual,
673 both at the access point and the station. No credentials are needed.
674
675 With \b PIN method, you must provide the PIN code that you read from the label or screen
676 on the wireless device.
677
678 WPS configuration for station is used when station connects to an access point.
679 It enables to connect without specifying SSID, Password, Security Type or WiFi Channel.
680 The actual network information can be retrieved once connected with \ref ARM_WIFI_GetNetInfo.
681
682 WPS configuration for access point is used when access point is activated.
683 Subsequent activate calls re-trigger the WPS procedure.
684
685 \note
686 WPS is typically activated by pressing the WPS button at the access point.
687 During the discovery mode (usually 2 minutes or less) any wireless device may connect
688 to the access point (PIN needs to match when PIN method is selected).
689
690 \b Example:
691 \code
692 ARM_WIFI_CONFIG_t wifi_config;
693  
694 wifi_config.ssid = "GuestAccess";
695 wifi_config.pass = "guest";
696 wifi_config.security = ARM_WIFI_SECURITY_WPA2;
697 wifi_config.ch = 0U;
698 wifi_config.wps_method = ARM_WIFI_WPS_METHOD_NONE;
699  
700 // Connect to wireless network
701 status = wifi->Activate (0U, &wifi_config);
702 if (status != ARM_DRIVER_OK) {
703   // error handling
704 }
705 \endcode
706 */
707
708 int32_t ARM_WIFI_Deactivate (uint32_t interface) {
709   return ARM_DRIVER_OK;
710 }
711 /**
712 \fn int32_t ARM_WIFI_Deactivate (uint32_t interface)
713 \details
714 The function \b ARM_WIFI_Deactivate deactivates the specified interface.
715
716 The argument \em interface specifies the interface (0 = Station, 1 = Access Point).
717
718 When station interface is specified, the WiFi module disconnects from the wireless network.
719
720 When access point interface is specified, the WiFi module deactivates the access point.
721
722 \b Example:
723  - see \ref ARM_WIFI_GetNetInfo
724 */
725
726 uint32_t ARM_WIFI_IsConnected (void) {
727   return 0;
728 }
729 /**
730 \fn uint32_t ARM_WIFI_IsConnected (void)
731 \details
732 The function \b ARM_WIFI_IsConnected checks if the station is connected to a wireless network
733 and returns the connection status.
734
735 The function returns a \token{non-zero} value, if the station is connected. If the station
736 is not connected, the function returns \token{0}.
737
738 \b Example:
739  - see \ref ARM_WIFI_GetNetInfo
740 */
741
742 int32_t ARM_WIFI_GetNetInfo (ARM_WIFI_NET_INFO_t *net_info) {
743   return ARM_DRIVER_OK;
744 }
745 /**
746 \fn int32_t ARM_WIFI_GetNetInfo (ARM_WIFI_NET_INFO_t *net_info)
747 \details
748 The function \b ARM_WIFI_GetNetInfo retrieves wireless network information of a connected station.
749
750 It can be used to retrieve network connection information for subsequent connections
751 after initially connecting using WPS.
752
753 \b Example:
754 \code
755 ARM_WIFI_CONFIG_t wifi_config;
756 ARM_WIFI_NET_INFO_t net_info;
757  
758 memset(&wifi_config, 0, sizeof(wifi_config));
759  
760 wifi_config.wps_method = ARM_WIFI_WPS_METHOD_PBC;
761  
762 // Connect to wireless network (WPS)
763 status = wifi->Activate (0U, &wifi_config);
764 if (status != ARM_DRIVER_OK) {
765   // error handling
766 }
767  
768 // Retrieve network information
769 if (wifi->IsConnected ()) {
770   status = wifi->GetNetInfo (&net_info);
771   if (status != ARM_DRIVER_OK) {
772     // error handling
773   }
774   printf("SSID=%s, Password=%s",net_info.ssid, net_info.pass);
775 }
776  
777 // Disconnect from wireless network
778 wifi->Deactivate (0U);
779 \endcode
780 */
781
782 /**
783 @}
784 */
785 // end group wifi_management_gr
786
787
788 /**
789 \defgroup wifi_bypass_gr WiFi Bypass Mode
790 \ingroup wifi_interface_gr
791 \brief Transfer Ethernet frames by WiFi module.
792 \details The \ref wifi_bypass_gr functions are an optional interface and enable the transmission of
793 Ethernet frames with WiFi modules. The use of this interface requires that the IP stack is running
794 on the microcontroller. The internal IP stack of the WiFi module is therefore not used, and this
795 usually means that the \ref wifi_socket_gr functions can not be used.
796 @{
797 */
798
799 int32_t ARM_WIFI_BypassControl (uint32_t interface, uint32_t mode) {
800   return ARM_DRIVER_OK;
801 }
802 /**
803 \fn int32_t ARM_WIFI_BypassControl (uint32_t interface, uint32_t mode)
804 \details
805 The function \b ARM_WIFI_BypassControl enables or disables the WiFi bypass mode.
806
807 The WiFi Bypass mode can only be enabled, if there is a bypass mode supported in the WiFi driver.
808 You can check this by checking the driver's capabilities.
809
810 \note
811 Bypass mode is enabled by default if the module does not support the Socket interface.
812
813 The argument \em mode specifies the desired state of the WiFi Bypass mode, which is
814 enabled or disabled.
815  
816 \b Example:
817 \code
818 extern ARM_DRIVER_WIFI Driver_WiFi0;
819 static ARM_DRIVER_WIFI *wifi;
820 static ARM_ETH_MAC_ADDR own_mac_address;
821  
822 static void wifi_notify (uint32_t event, ,void *arg) {
823   switch (event)  {
824      :
825   }  
826 }
827  
828 void initialize_wifi_bypass (void) {
829   ARM_WIFI_CAPABILITIES capabilities;
830  
831   wifi = &Driver_WiFi0;
832   capabilities = wifi->GetCapabilities ();
833   if (capabilities.bypass_mode == 0) {
834     // error handling 
835   } 
836  
837   // Initialize and Power-on WiFi Interface
838   wifi->Initialize ((capabilities.eth_rx_frame_event) ? wifi_notify : NULL);
839   wifi->PowerControl (ARM_POWER_FULL);
840  
841   // populate own_mac_address with the address to use for station
842   wifi->SetOption(0U, ARM_WIFI_MAC, &own_mac_address, 6U);
843  
844   wifi->BypassControl (0U, 1U); // Enable bypass mode for station
845 }
846 \endcode
847 */
848
849 int32_t ARM_WIFI_EthSendFrame (uint32_t interface, const uint8_t *frame, uint32_t len) {
850   return ARM_DRIVER_OK;
851 }
852 /**
853 \fn int32_t ARM_WIFI_EthSendFrame (uint32_t interface, const uint8_t *frame, uint32_t len)
854 \details
855 The function \b ARM_WIFI_EthSendFrame writes an <b>Ethernet frame</b> to the WiFi transmit buffer.
856
857 The WiFi bypass mode must be enabled by using the function \ref ARM_WIFI_BypassControl
858 before a call to this function.
859
860 The frame data addressed by \em frame starts with MAC destination and ends with the last
861 Payload data byte. The frame data is copied into the transmit buffer of the WiFi interface.
862
863 The maximum value for \em len is implied by the size restrictions of the Ethernet frame
864 but is not verified. Using an invalid value for \em len may generate unpredicted results.
865
866 \b Example:
867 \code
868 status = wifi->EthSendFrame (0U, &frame_data[0], frame_length);
869 if (status != ARM_DRIVER_OK)  {
870   // error handling
871 }
872 \endcode
873 */
874
875 int32_t ARM_WIFI_EthReadFrame (uint32_t interface, uint8_t *frame, uint32_t len) {
876   return ARM_DRIVER_OK;
877 }
878 /**
879 \fn int32_t ARM_WIFI_EthReadFrame (uint32_t interface, uint8_t *frame, uint32_t len)
880 \details
881 The function \b ARM_WIFI_EthReadFrame reads an <b>Ethernet frame</b> from the WiFi interface
882 in the bypass mode.
883
884 The \em len of the Ethernet frame can be checked using the function \ref ARM_WIFI_EthGetRxFrameSize.
885
886 The frame data addressed by \em frame starts with MAC destination and ends with the last
887 Payload data byte. The frame data is read from the receive buffer of the WiFi interface and
888 the number of bytes written into the memory addressed by \em frame is returned.
889 A negative return value indicates an error whereby the status code is defined with 
890 driver common return codes.
891
892 The function \ref ARM_WIFI_EthReadFrame may be called with \em buf = \token{NULL} and \em len = \token{0}
893 to discard or release a frame. This is useful when an incorrect frame has been received or
894 no memory is available to hold the Ethernet frame.
895  
896 \b Example:
897 \code
898 size = wifi->EthGetRxFrameSize ();
899 if ((size < 14) || (size > 1514)) {    // frame excludes CRC
900   wifi->EthReadFrame (NULL, 0);        // Frame error, release it
901 }
902 len = wifi->ReadFrame (0U, &frame_data[0], size);
903 if (len < 0)  {
904   // error handling
905 }
906 \endcode
907 */
908
909 uint32_t ARM_WIFI_EthGetRxFrameSize (uint32_t interface) {
910   return 0;
911 }
912 /**
913 \fn uint32_t ARM_WIFI_EthGetRxFrameSize (uint32_t interface)
914 \details
915 The function \b ARM_WIFI_EthGetRxFrameSize returns the size of a received <b>Ethernet frame</b>
916 in the bypass mode. This function can be called before \ref ARM_WIFI_EthReadFrame and retrieves 
917 the value \em len.
918
919 The frame size includes MAC destination and ends with the last Payload data byte.
920 Value \token{0} indicates that no Ethernet frame is available in the receive buffer.
921 Values smaller than minimum size of Ethernet frame or larger than maximum size of Ethernet frame
922 indicate an invalid frame which needs to be discarded by calling \ref ARM_WIFI_EthReadFrame.
923  
924 \b Example:
925  - see \ref ARM_WIFI_EthReadFrame
926 */
927 /**
928 @}
929 */
930 // end group wifi_bypass_gr
931
932
933 /**
934 \defgroup wifi_socket_gr WiFi Socket
935 \ingroup wifi_interface_gr
936 \brief Socket interface to IP stack running on WiFi module
937 \details The \ref wifi_socket_gr functions provide the interface to an IP stack that is running
938 on the WiFi module. This IP stack handles data communication with the network and provides the user
939 with a communication endpoint called sockets.
940 @{
941 */
942
943 /**
944 \defgroup wifi_addr_family WiFi Socket Address Family definitions
945 \ingroup wifi_socket_gr
946 \brief WiFi Socket Address Family definitions.
947 \details The WiFi Socket Address Family specifies the addressing scheme that an instance of the WiFi socket can use.
948 @{
949 \def ARM_SOCKET_AF_INET
950 \details Internet Address Family version 4.
951 \def ARM_SOCKET_AF_INET6
952 \details Internet Address Family version 6.
953 @}
954 */
955
956 /**
957 \defgroup wifi_socket_type WiFi Socket Type definitions
958 \ingroup wifi_socket_gr
959 \brief WiFi Socket Type definitions.
960 \details The WiFi Socket Type specifies the type of the WiFi socket.
961 @{
962 \def ARM_SOCKET_SOCK_STREAM
963 \details Stream Socket is connection-oriented, sequenced and reliable, implemented on top of the TCP protocol.
964 \def ARM_SOCKET_SOCK_DGRAM
965 \details Datagram Socket is connectionless, unreliable, using the UDP protocol.
966 @}
967 */
968
969 /**
970 \defgroup wifi_protocol WiFi Socket Protocol definitions
971 \ingroup WiFi_socket_gr
972 \brief WiFi Socket Protocol definitions.
973 \details The WiFi Socket Protocol specifies the Internet Protocol Type that the socket is using.
974 @{
975 \def ARM_SOCKET_IPPROTO_TCP
976 \details Transmission Control Protocol.
977 \def ARM_SOCKET_IPPROTO_UDP
978 \details User Datagram Protocol.
979 @}
980 */
981
982 /**
983 \defgroup wifi_soc_opt WiFi Socket Option definitions
984 \ingroup WiFi_socket_gr
985 \brief WiFi Socket Option definitions.
986 \details The WiFi Socket Option specifies the socket option for which the value is to be set or obtained.
987 @{
988 \def ARM_SOCKET_IO_FIONBIO
989 \details Enables or disables the non-blocking mode for the WiFi socket.
990 \sa wifi_soc_opt
991 \def ARM_SOCKET_SO_RCVTIMEO
992 \details Specifies the time limit for receiving in blocking mode. The time limit is in milliseconds.
993 \sa wifi_soc_opt
994 \def ARM_SOCKET_SO_SNDTIMEO
995 \details Specifies the time limit for sending in blocking mode. The time limit is in milliseconds.
996 \sa wifi_soc_opt
997 \def ARM_SOCKET_SO_KEEPALIVE
998 \details Enables or disables the keep-alive mode for the stream socket.
999 \sa wifi_soc_opt
1000 \def ARM_SOCKET_SO_TYPE
1001 \details Obtains the type of the Wifi socket.
1002 \sa wifi_soc_opt
1003 @}
1004 */
1005
1006 /**
1007 \defgroup wifi_soc_func WiFi Socket Function return codes
1008 \ingroup WiFi_socket_gr
1009 \brief WiFi Socket Function return codes.
1010 \details This section lists all the return errors the WiFi socket functions will return.
1011 The error codes are negative. This makes it easy to check an error when the return
1012 code is less than \token{0}.
1013 @{
1014 \def ARM_SOCKET_ERROR
1015 \sa wifi_soc_func
1016 \def ARM_SOCKET_ESOCK
1017 \sa wifi_soc_func
1018 \def ARM_SOCKET_EINVAL
1019 \sa wifi_soc_func
1020 \def ARM_SOCKET_ENOTSUP
1021 \sa wifi_soc_func
1022 \def ARM_SOCKET_ENOMEM
1023 \sa wifi_soc_func
1024 \def ARM_SOCKET_EAGAIN
1025 \sa wifi_soc_func
1026 \def ARM_SOCKET_EINPROGRESS
1027 \sa wifi_soc_func
1028 \def ARM_SOCKET_ETIMEDOUT
1029 \sa wifi_soc_func
1030 \def ARM_SOCKET_EISCONN
1031 \sa wifi_soc_func
1032 \def ARM_SOCKET_ENOTCONN
1033 \sa wifi_soc_func
1034 \def ARM_SOCKET_ECONNREFUSED
1035 \sa wifi_soc_func
1036 \def ARM_SOCKET_ECONNRESET
1037 \sa wifi_soc_func
1038 \def ARM_SOCKET_ECONNABORTED
1039 \sa wifi_soc_func
1040 \def ARM_SOCKET_EALREADY
1041 \sa wifi_soc_func
1042 \def ARM_SOCKET_EADDRINUSE
1043 \sa wifi_soc_func
1044 \def ARM_SOCKET_EHOSTNOTFOUND
1045 \sa wifi_soc_func
1046 @}
1047 */
1048
1049 int32_t ARM_WIFI_SocketCreate (int32_t af, int32_t type, int32_t protocol) {
1050   return 0;
1051 }
1052 /**
1053 \fn int32_t ARM_WIFI_SocketCreate (int32_t af, int32_t type, int32_t protocol)
1054 \details
1055 The function \b ARM_WIFI_SocketCreate creates a communication endpoint called a socket.
1056
1057 The argument \em af specifies the address family. The following values are supported:
1058 Family                       | Description
1059 :----------------------------|:-------------------------------------------------
1060 \ref ARM_SOCKET_AF_INET      | Address Family Internet
1061 \ref ARM_SOCKET_AF_INET6     | Address Family Internet version 6
1062
1063 The argument \em type specifies the communication semantics. The following are the currently supported types:
1064 Type                         | Description
1065 :----------------------------|:-------------------------------------------------
1066 \ref ARM_SOCKET_SOCK_STREAM  | Provides a reliable connection based data stream that is full-duplex
1067 \ref ARM_SOCKET_SOCK_DGRAM   | Provides connectionless communication that is unreliable
1068
1069 The argument \em protocol specifies the protocol that must be used with the socket type:
1070 Protocol                     | Description
1071 :----------------------------|:-------------------------------------------------
1072 \ref ARM_SOCKET_IPPROTO_TCP  | Must be used with ARM_SOCKET_SOCK_STREAM socket type
1073 \ref ARM_SOCKET_IPPROTO_UDP  | Must be used with ARM_SOCKET_SOCK_DGRAM socket type
1074  
1075 \b Example:
1076  - see \ref ARM_WIFI_SocketListen, \ref ARM_WIFI_SocketConnect
1077 */
1078
1079 int32_t ARM_WIFI_SocketBind (int32_t socket, const uint8_t *ip, uint32_t ip_len, uint16_t port) {
1080   return 0;
1081 }
1082 /**
1083 \fn int32_t ARM_WIFI_SocketBind (int32_t socket, const uint8_t *ip, uint32_t ip_len, uint16_t port)
1084 \details
1085 The function \b ARM_WIFI_SocketBind assigns a name to an unnamed socket. The name represents the local address
1086 and port of the communication endpoint.
1087
1088 The argument \em socket specifies a socket identification number returned from a previous call
1089 to \ref ARM_WIFI_SocketCreate.
1090
1091 The argument \em ip is a pointer to the buffer containing the IP address octets of the local IP address.
1092
1093 The argument \em ip_len specifies the length of the local IP address. The length is \token{4} bytes
1094 for the IPv4 address and \token{16} bytes for the IPv6 address.
1095
1096 The argument \em port specifies the local port. If the argument \em port is \token{0}, the function returns error,
1097 because this port is reserved.
1098  
1099 \b Example:
1100  - see \ref ARM_WIFI_SocketListen
1101 */
1102
1103 int32_t ARM_WIFI_SocketListen (int32_t socket, int32_t backlog) {
1104   return 0;
1105 }
1106 /**
1107 \fn int32_t ARM_WIFI_SocketListen (int32_t socket, int32_t backlog)
1108 \details
1109 The function \b ARM_WIFI_SocketListen sets the specified socket to listening mode, that is to the
1110 server mode of operation. Before calling the \b ARM_WIFI_SocketListen function, the \ref ARM_WIFI_SocketBind
1111 function must be called.
1112
1113 The argument \em socket specifies a socket identification number returned from a previous call
1114 to \ref ARM_WIFI_SocketCreate.
1115
1116 The argument \em backlog specifies a maximum number of connection requests that can be queued.
1117  
1118 \b Example:
1119 \code
1120 extern ARM_DRIVER_WIFI Driver_WiFi0;
1121 static ARM_DRIVER_WIFI *wifi;
1122  
1123 void Echo_Server_Thread (void *arg) {
1124   uint8_t ip[4] = { 0U, 0U, 0U, 0U };
1125   int32_t sock, sd, res;
1126   char dbuf[120];
1127  
1128   while (1) {
1129     wifi = &Driver_WiFi0;
1130     sock = wifi->SocketCreate (ARM_SOCKET_AF_INET, ARM_SOCKET_SOCK_STREAM, ARM_SOCKET_IPPROTO_TCP);
1131  
1132     wifi->SocketBind (sock, (uint8_t *)ip, sizeof(ip), 7U);
1133     wifi->SocketListen (sock, 1);
1134     sd = wifi->SocketAccept (sock, NULL, NULL, NULL);
1135     wifi->SocketClose (sock);
1136     sock = sd;
1137  
1138     while (1) {
1139       res = wifi->SocketRecv (sock, dbuf, sizeof(dbuf));
1140       if (res < 0) {
1141         break;                                      // Error occurred
1142       }
1143       if (res > 0) {
1144         wifi->SocketSend (sock, dbuf, res);         // Echo the data
1145       }    
1146     }
1147     wifi->SocketClose (sock);
1148   }
1149 }
1150 \endcode
1151 */
1152
1153 int32_t ARM_WIFI_SocketAccept (int32_t socket, uint8_t *ip, uint32_t *ip_len, uint16_t *port) {
1154   return 0;
1155 }
1156 /**
1157 \fn int32_t ARM_WIFI_SocketAccept (int32_t socket, uint8_t *ip, uint32_t *ip_len, uint16_t *port)
1158 \details
1159 The function \b ARM_WIFI_SocketAccept accepts a connection request queued for a listening socket.
1160 If a connection request is pending, \b ARM_WIFI_SocketAccept removes the request from the queue,
1161 and creates a new socket for the connection. The original listening socket remains open and continues
1162 to queue new connection requests. The \em socket must be a socket of type \b ARM_SOCKET_SOCK_STREAM.
1163
1164 In blocking mode, which is enabled by default, this function waits for a connection request. In
1165 non blocking mode, you must call the \b ARM_WIFI_SocketAccept function again if the error code
1166 \c ARM_SOCKET_EAGAIN is returned.
1167
1168 The argument \em socket specifies a socket identification number returned from a previous call
1169 to \ref ARM_WIFI_SocketCreate.
1170
1171 The argument \em ip is a pointer to the buffer that will receive the IP address of the connection node.
1172 If the \em ip is \token{NULL}, the IP address is not returned.
1173
1174 The argument \em ip_len is a pointer to the IP address length. It should initially contain the amount of
1175 space pointed to by \em ip. On return it contains the actual length of the address returned in bytes.
1176
1177 The argument \em port is a pointer to the buffer, that will receive the port number of the connection node.
1178 If the \em port is \token{NULL}, the port number is not returned.
1179
1180 \b Example:
1181  - see \ref ARM_WIFI_SocketListen
1182 */
1183
1184 int32_t ARM_WIFI_SocketConnect (int32_t socket, const uint8_t *ip, uint32_t ip_len, uint16_t port) {
1185   return 0;
1186 }
1187 /**
1188 \fn int32_t ARM_WIFI_SocketConnect (int32_t socket, const uint8_t *ip, uint32_t ip_len, uint16_t port)
1189 \details
1190 The function \b ARM_WIFI_SocketConnect assigns the address of the peer communication endpoint. The function
1191 behaves differently according to the type of socket:
1192
1193 - \b ARM_SOCKET_SOCK_STREAM: A connection is established between the endpoints.
1194
1195   In blocking mode, which is enabled by default, this function waits for a connection to be established.
1196
1197   In non blocking mode, the function returns the error code \c ARM_SOCKET_EINPROGRESS and the connection
1198   is established asynchronously. Subsequent calls to \b ARM_WIFI_SocketConnect for the same socket,
1199   before the connection is established, return the error code \c ARM_SOCKET_EALREADY.  When the connection
1200   is established, the call to \b ARM_WIFI_SocketConnect returns the error code \c ARM_SOCKET_EISCONN. 
1201
1202 - \b ARM_SOCKET_SOCK_DGRAM: An address filter is established between the endpoints.
1203
1204   The address filter is changed with another \b ARM_WIFI_SocketConnect function call. If the socket
1205   is not yet bound, the system implicitly binds to a random dynamic port.
1206
1207 The argument \em socket specifies a socket identification number returned from a previous call
1208 to \ref ARM_WIFI_SocketCreate.
1209
1210 The argument \em ip is a pointer to the buffer containing the IP address octets of the endpoint node.
1211
1212 The argument \em ip_len specifies the length of the IP address. The length is \token{4} bytes
1213 for the IPv4 address and \token{16} bytes for the IPv6 address.
1214
1215 The argument \em port specifies the port of the endpoint node. If the argument \em port is \token{0}, 
1216 the function returns error, because this port is reserved.
1217
1218 \b Example:
1219 \code
1220 extern ARM_DRIVER_WIFI Driver_WiFi0;
1221 static ARM_DRIVER_WIFI *wifi;
1222  
1223 static const char message[] = { "The quick brown fox jumps over the lazy dog." };
1224   
1225 void Echo_Client_Thread (void *arg) {
1226   uint8_t ip[4] = { 192U, 168U, 0U, 100U };
1227   int32_t sock, res;
1228   char dbuf[120];
1229  
1230   while (1) {
1231     wifi = &Driver_WiFi0;
1232     sock = wifi->SocketCreate (ARM_SOCKET_AF_INET, ARM_SOCKET_SOCK_STREAM, ARM_SOCKET_IPPROTO_TCP);
1233  
1234     res = wifi->SocketConnect (sock, (uint8_t *)ip, sizeof(ip), 7U);
1235     if (res == 0) {
1236       wifi->SocketSend (sock, message, sizeof(message));
1237       res = wifi->SocketRecv (sock, dbuf, sizeof(dbuf));
1238       if (res < 0) {
1239         break;               // Error occured
1240       }
1241       if (res > 0) {
1242         if (memcmp (dbuf, message, res) != 0) {
1243           // error handling, message is not the same as sent
1244         }
1245       }    
1246     }
1247     wifi->SocketClose (sock);
1248     osDelay (1000U);
1249   }
1250 }
1251 \endcode
1252 */
1253
1254 int32_t ARM_WIFI_SocketRecv (int32_t socket, void *buf, uint32_t len) {
1255   return 1;
1256 }
1257 /**
1258 \fn int32_t ARM_WIFI_SocketRecv (int32_t socket, void *buf, uint32_t len)
1259 \details
1260 The function \b ARM_WIFI_SocketRecv receives incoming data that has been queued for the socket.
1261 You can use this function with both, the stream and the datagram socket. It reads as much
1262 information as currently available up to the size of the buffer specified.
1263
1264 In blocking mode, which is enabled by default, this function waits for received data. In non
1265 blocking mode, you must call the \b ARM_WIFI_SocketRecv function again if the error code 
1266 \c ARM_SOCKET_EAGAIN is returned.
1267
1268 The argument \em socket specifies a socket identification number returned from a previous call
1269 to \ref ARM_WIFI_SocketCreate.
1270
1271 The argument \em buf is a pointer to the application data buffer for storing the data to.
1272 If the available data is too large to fit in the supplied application buffer \em buf, excess bytes
1273 are discarded in case of a datagram sockets. For stream sockets, the data is buffered internally
1274 so the application can retrieve all data by multiple calls of \b ARM_WIFI_SocketRecv function.
1275
1276 The argument \em len specifies the size of the application data buffer.
1277
1278 \b Example:
1279  - see \ref ARM_WIFI_SocketListen
1280 */
1281
1282 int32_t ARM_WIFI_SocketRecvFrom (int32_t socket, void *buf, uint32_t len, uint8_t *ip, uint32_t *ip_len, uint16_t *port) {
1283   return 1;
1284 }
1285 /**
1286 \fn int32_t ARM_WIFI_SocketRecvFrom (int32_t socket, void *buf, uint32_t len, uint8_t *ip, uint32_t *ip_len, uint16_t *port)
1287 \details
1288 The function \b ARM_WIFI_SocketRecvFrom is used to receive data that has been queued for a socket.
1289 It is normally used to receive messages on datagram sockets, but can also be used to receive a reliable,
1290 ordered stream of data on a connected stream sockets. It reads as much information as currently available
1291 up to the size of the buffer specified.
1292
1293 In blocking mode, which is enabled by default, this function waits for received data. In non
1294 blocking mode, you must call the \b ARM_WIFI_SocketRecv function again if the error code 
1295 \c ARM_SOCKET_EAGAIN is returned.
1296
1297 The argument \em socket specifies a socket identification number returned from a previous call
1298 to \ref ARM_WIFI_SocketCreate.
1299
1300 The argument \em buf is a pointer to the application data buffer for storing the data to.
1301 If the available data is too large to fit in the supplied application buffer \em buf, excess bytes
1302 are discarded in case of a datagram sockets. For stream sockets, the data is buffered internally
1303 so the application can retrieve all data by multiple calls of \b ARM_WIFI_SocketRecv function.
1304
1305 The argument \em len specifies the size of the application data buffer.
1306
1307 The argument \em ip is a pointer to the buffer that will receive the IP address of the sender.
1308 If the \em ip is \token{NULL}, the IP address is not returned.
1309
1310 The argument \em ip_len is a pointer to the IP address length. It should initially contain the amount of
1311 space pointed to by \em ip. On return it contains the actual length of the address returned in bytes.
1312
1313 The argument \em port is a pointer to the buffer, that will receive the port number of the sender.
1314 If the \em port is \token{NULL}, the port number is not returned.
1315  
1316 \b Example:
1317 \code
1318 extern ARM_DRIVER_WIFI Driver_WiFi0;
1319 static ARM_DRIVER_WIFI *wifi;
1320  
1321 void Echo_Server_Thread (void *arg) {
1322   uint8_t ip[4];
1323   uint16_t port;
1324   int32_t sock, res;
1325   uint32_t ip_len;
1326   char dbuf[120];
1327  
1328   while (1) {
1329     wifi = &Driver_WiFi0;
1330     sock = wifi->SocketCreate (ARM_SOCKET_AF_INET, ARM_SOCKET_SOCK_DGRAM, ARM_SOCKET_IPPROTO_UDP);
1331  
1332     ip[0] = 0U;                 // Unspecified address
1333     ip[1] = 0U;
1334     ip[2] = 0U;
1335     ip[3] = 0U;
1336     port  = 7U;                 // Standard port for Echo service
1337  
1338     wifi->SocketBind (sock, (uint8_t *)ip, sizeof(ip), port);
1339  
1340     while (1) {
1341       ip_len = sizeof(ip);
1342       res = wifi->SocketRecvFrom (sock, dbuf, sizeof(dbuf), (uint8_t *)ip, &ip_len, &port);
1343       if (res < 0) {
1344         break;                  // Error occurred
1345       }
1346       if (res > 0) {            // Echo the data
1347         wifi->SocketSendTo (sock, dbuf, res, (uint8_t *)ip, ip_len, port);
1348       }    
1349     }
1350     wifi->SocketClose (sock);
1351   }
1352 }
1353 \endcode
1354 */
1355
1356 int32_t ARM_WIFI_SocketSend (int32_t socket, const void *buf, uint32_t len) {
1357   return 1;
1358 }
1359 /**
1360 \fn int32_t ARM_WIFI_SocketSend (int32_t socket, const void *buf, uint32_t len)
1361 \details
1362 The function \b ARM_WIFI_SocketSend is used to send data on an already connected socket. This function is
1363 normally used to send a reliable, ordered stream of data bytes on a stream sockets. It can also be used
1364 to send messages on datagram sockets.
1365
1366 The argument \em socket specifies a socket identification number returned from a previous call
1367 to \ref ARM_WIFI_SocketCreate.
1368
1369 The argument \a buf is a pointer to the application data buffer containing data to transmit. The buffer
1370 data length is not limited in size. If the data length is too large for one packet, the \b ARM_WIFI_SocketSend function
1371 will fragment the data and send it in several successive data packets:
1372 - In blocking mode, which is enabled by default, this function returns after the data has been successfully queued for transmission.
1373 - In non blocking mode, the function returns immediately without blocking the system.
1374
1375 The argument \a len specifies the length of data in bytes.
1376
1377 Return value, when positive, represents the number of bytes sent, which can be less than \a len.
1378  
1379 \b Example:
1380  - see \ref ARM_WIFI_SocketListen
1381 */
1382
1383 int32_t ARM_WIFI_SocketSendTo (int32_t socket, const void *buf, uint32_t len, const uint8_t *ip, uint32_t ip_len, uint16_t port) {
1384   return 1;
1385 }
1386 /**
1387 \fn int32_t ARM_WIFI_SocketSendTo (int32_t socket, const void *buf, uint32_t len, const uint8_t *ip, uint32_t ip_len, uint16_t port)
1388 \details
1389 The function \b ARM_WIFI_SocketSendTo is used to send data. It is normally used to send messages
1390 on a datagram sockets, but can also be used to send data on a connected stream sockets.
1391
1392 If the datagram socket is not yet bound, the system implicitly binds to a random dynamic port.
1393
1394 The argument \em socket specifies a socket identification number returned from a previous call
1395 to \ref ARM_WIFI_SocketCreate.
1396
1397 The argument \a buf is a pointer to the application data buffer containing data to transmit. The buffer
1398 data length is not limited in size. If the data length is too large for one packet, the \b ARM_WIFI_SocketSend function
1399 will fragment the data and send it in several successive data packets:
1400 - In blocking mode, which is enabled by default, this function returns after the data has been successfully queued for transmission.
1401 - In non blocking mode, the function returns immediately without blocking the system.
1402
1403 The argument \a len specifies the length of data in bytes.
1404
1405 The argument \em ip is a pointer to the buffer containing the IP address octets of the endpoint node.
1406
1407 The argument \em ip_len specifies the length of the IP address. The length is \token{4} bytes
1408 for the IPv4 address and \token{16} bytes for the IPv6 address.
1409
1410 The argument \em port specifies the port of the endpoint node. If the argument \em port is \token{0}, 
1411 the function returns error, because this port is reserved.
1412
1413 For the stream sockets, arguments \em ip, \em ip_len and \em port are ignored.
1414
1415 Return value, when positive, represents the number of bytes sent, which can be less than \a len.
1416
1417 \b Example:
1418  - see \ref ARM_WIFI_SocketRecvFrom
1419 */
1420
1421 int32_t ARM_WIFI_SocketGetSockName (int32_t socket, uint8_t *ip, uint32_t *ip_len, uint16_t *port) {
1422   return 0;
1423 }
1424 /**
1425 \fn int32_t ARM_WIFI_SocketGetSockName (int32_t socket, uint8_t *ip, uint32_t *ip_len, uint16_t *port)
1426 \details
1427 The function \b ARM_WIFI_SocketGetSockName retrieves the local IP address and port for a socket.
1428
1429 The argument \em socket specifies a socket identification number returned from a previous call
1430 to \ref ARM_WIFI_SocketCreate.
1431
1432 The argument \em ip is a pointer to the buffer that will receive the local IP address.
1433 If the \em ip is \token{NULL}, the local IP address is not returned.
1434
1435 The argument \em ip_len is a pointer to the IP address length. It should initially contain the amount of
1436 space pointed to by \em ip. On return it contains the actual length of the address returned in bytes.
1437
1438 The argument \em port is a pointer to the buffer, that will receive the local port number.
1439 If the \em port is \token{NULL}, the local port number is not returned.
1440
1441 \b Example:
1442 \code
1443 static uint8_t  local_ip[4];    // Socket address and port
1444 static uint16_t local_port;
1445  
1446 static void get_socket_local_info (void) {
1447   uint32_t ip_len;
1448  
1449   ip_len = sizeof(local_ip);
1450   wifi->SocketGetSockName (sock, (uint8_t *)local_ip, &ip_len, &local_port);
1451 }
1452 \endcode
1453 */
1454
1455 int32_t ARM_WIFI_SocketGetPeerName (int32_t socket, uint8_t *ip, uint32_t *ip_len, uint16_t *port) {
1456   return 0;
1457 }
1458 /**
1459 \fn int32_t ARM_WIFI_SocketGetPeerName (int32_t socket, uint8_t *ip, uint32_t *ip_len, uint16_t *port)
1460 \details
1461 The function \b ARM_WIFI_SocketGetPeerName retrieves the IP address and port of the peer to which
1462 a socket is connected.
1463
1464 The argument \em socket specifies a socket identification number returned from a previous call
1465 to \ref ARM_WIFI_SocketCreate.
1466
1467 The argument \em ip is a pointer to the buffer that will receive the IP address of the peer.
1468 If the \em ip is \token{NULL}, the IP address is not returned.
1469
1470 The argument \em ip_len is a pointer to the IP address length. It should initially contain the amount of
1471 space pointed to by \em ip. On return it contains the actual length of the address returned in bytes.
1472
1473 The argument \em port is a pointer to the buffer, that will receive the port number of the peer.
1474 If the \em port is \token{NULL}, the port number is not returned.
1475
1476 \b Example:
1477 \code
1478 static uint8_t  peer_ip[4];    // Socket address and port
1479 static uint16_t peer_port;
1480  
1481 static void get_socket_peer_info (void) {
1482   uint32_t ip_len;
1483  
1484   ip_len = sizeof(peer_ip);
1485   wifi->SocketGetPeerName (sock, (uint8_t *)peer_ip, &ip_len, &peer_port);
1486 }
1487 \endcode
1488 */
1489
1490 int32_t ARM_WIFI_SocketGetOpt (int32_t socket, int32_t opt_id, void *opt_val, uint32_t *opt_len) {
1491   return 0;
1492 }
1493 /**
1494 \fn int32_t ARM_WIFI_SocketGetOpt (int32_t socket, int32_t opt_id, void *opt_val, uint32_t *opt_len)
1495 \details
1496 The function \b ARM_WIFI_SocketGetOpt retrieves options for a socket.
1497
1498 The argument \em socket specifies a socket identification number returned from a previous call
1499 to \ref ARM_WIFI_SocketCreate.
1500
1501 The argument \em opt_id is the socket option for which the value is to be retrieved. The following
1502 socket options are supported:
1503 Option                       | Description
1504 :----------------------------|:-------------------------------------------------
1505 \ref ARM_SOCKET_SO_RCVTIMEO  | Timeout for receiving in blocking mode
1506 \ref ARM_SOCKET_SO_SNDTIMEO  | Timeout for sending in blocking mode
1507 \ref ARM_SOCKET_SO_KEEPALIVE | Keep-alive mode for the stream socket
1508 \ref ARM_SOCKET_SO_TYPE      | Type of the socket (stream or datagram)
1509
1510 The argument \em opt_val points to the buffer that will receive the value of the \em opt_id.
1511
1512 The argument \em opt_len contains the length of the buffer at the input and returns the length
1513 of the option information on the output.
1514
1515 \b Example:
1516 \code
1517 uint32_t type;
1518  
1519 wifi->SocketGetOpt (sock, ARM_SOCKET_SO_TYPE, &type, sizeof(type));
1520 if (type == ARM_SOCKET_SOCK_STREAM) {
1521   // Stream socket
1522 }
1523 if (type == ARM_SOCKET_SOCK_DGRAM) {
1524   // Datagram socket
1525 }
1526 \endcode
1527 */
1528
1529 int32_t ARM_WIFI_SocketSetOpt (int32_t socket, int32_t opt_id, const void *opt_val, uint32_t opt_len) {
1530   return 0;
1531 }
1532 /**
1533 \fn int32_t ARM_WIFI_SocketSetOpt (int32_t socket, int32_t opt_id, const void *opt_val, uint32_t opt_len)
1534 \details
1535 The function \b ARM_WIFI_SocketSetOpt sets options for a socket.
1536
1537 The argument \em socket specifies a socket identification number returned from a previous call
1538 to \ref ARM_WIFI_SocketCreate.
1539
1540 The argument \em opt_id is the socket option for which the value is to be set. The following
1541 socket options are supported:
1542 Option                       | Description
1543 :----------------------------|:-------------------------------------------------
1544 \ref ARM_SOCKET_IO_FIONBIO   | Non-blocking mode for the socket
1545 \ref ARM_SOCKET_SO_RCVTIMEO  | Timeout for receiving in blocking mode
1546 \ref ARM_SOCKET_SO_SNDTIMEO  | Timeout for sending in blocking mode
1547 \ref ARM_SOCKET_SO_KEEPALIVE | Keep-alive mode for the stream socket
1548
1549 The argument \em opt_val points to the buffer containing the value of the \em opt_id.
1550
1551 The argument \em opt_len tells the exact length of the option.
1552  
1553 \b Example:
1554 \code
1555 uint32_t nonblocking = 0U;    // Blocking mode
1556 uint32_t timeout = 10000U;    // Timeout 10 seconds
1557  
1558 wifi->SocketSetOpt (sock, ARM_SOCKET_IO_FIONBIO, &nonblocking, sizeof(nonblocking));
1559 wifi->SocketSetOpt (sock, ARM_SOCKET_SO_RCVTIMEO, &timeout, sizeof(timeout)); 
1560 wifi->SocketSetOpt (sock, ARM_SOCKET_SO_SNDTIMEO, &timeout, sizeof(timeout));
1561 \endcode
1562 */
1563
1564 int32_t ARM_WIFI_SocketClose (int32_t socket) {
1565   return 0;
1566 }
1567 /**
1568 \fn int32_t ARM_WIFI_SocketClose (int32_t socket)
1569 \details
1570 The function \b ARM_WIFI_SocketClose closes an existing socket and releases the socket descriptor.
1571 Further references to \em socket fail with \c ARM_SOCKET_EINVAL error code.
1572
1573 The argument \em socket specifies a socket identification number returned from a previous call
1574 to \ref ARM_WIFI_SocketCreate.
1575
1576 In blocking mode, which is enabled by default, this function will wait until a socket is closed.
1577 In non blocking mode, you must call the \b ARM_WIFI_SocketClose function again if the error code
1578 \c ARM_SOCKET_EAGAIN is returned.
1579
1580 \b Example:
1581  - see \ref ARM_WIFI_SocketListen
1582 */
1583
1584 int32_t ARM_WIFI_SocketGetHostByName (const char *name, int32_t af, uint8_t *ip, uint32_t *ip_len) {
1585   return 0;
1586 }
1587 /**
1588 \fn int32_t ARM_WIFI_SocketGetHostByName (const char *name, int32_t af, uint8_t *ip, uint32_t *ip_len)
1589 \details
1590 The function \b ARM_WIFI_SocketGetHostByName retrieves host information corresponding to
1591 a host name from a host database. It does this by sending DNS requests to the DNS server.
1592 The IP address of the DNS server is specified in the network interface configuration or can be
1593 obtained from the DHCP server for the local area network.
1594
1595 The argument \a name is a pointer to the \token{null}-terminated name of the host to resolve.
1596
1597 The argument \em af specifies the address family, that is, which type of IP address you want
1598 to resolve. The following values are supported:
1599 Family                       | Description
1600 :----------------------------|:-------------------------------------------------
1601 \ref ARM_SOCKET_AF_INET      | Resolve the IPv4 address
1602 \ref ARM_SOCKET_AF_INET6     | Resolve the IPv6 address
1603
1604 The argument \em ip is a pointer to the buffer that will receive the resolved IP address of the host.
1605 If the argument \em ip is \token{NULL}, the function returns error.
1606
1607 The argument \em ip_len is a pointer to the IP address length. It should initially contain the amount of
1608 space pointed to by \em ip. On return it contains the actual length of the address returned in bytes.
1609
1610 \b Example:
1611 \code
1612 extern ARM_DRIVER_WIFI Driver_WiFi0;
1613 static ARM_DRIVER_WIFI *wifi;
1614  
1615 void ping_arm_com (void) {
1616   uint8_t ip[4];
1617   uint32_t ip_len;
1618   int32_t res;
1619  
1620   wifi = &Driver_WiFi0;
1621   ip_len = sizeof(ip);
1622   res = wifi->SocketGetHostByName ("www.arm.com", ARM_SOCKET_AF_INET, (uint8_t *)ip, &ip_len);
1623   if (res == ARM_DRIVER_OK) {
1624     res = wifi->Ping ((uint8_t *)ip, sizeof(ip));
1625     if (res == ARM_DRIVER_OK) {
1626       // "www.arm.com" responded to ping  
1627     }
1628   }
1629   else {
1630     // "www.arm.com" not resolved
1631   }
1632 }
1633 \endcode
1634 */
1635
1636 int32_t ARM_WIFI_Ping (const uint8_t *ip, uint32_t ip_len) {
1637   return ARM_DRIVER_OK;
1638 }
1639 /**
1640 \fn int32_t ARM_WIFI_Ping (const uint8_t *ip, uint32_t ip_len)
1641 \details
1642 The function \b ARM_WIFI_Ping checks if the remote host is reachable. It does this by sending 
1643 an echo request and waiting for an echo response. The function then returns the result
1644 of the operation. Check the \ref ARM_WIFI_CAPABILITIES of the driver, if this function
1645 is supported in the driver implementation.
1646
1647 The argument \em ip is a pointer to the buffer containing the IP address octets of the host to ping.
1648
1649 The argument \em ip_len specifies the length of the IP address. The length is \token{4} bytes
1650 for the IPv4 address and \token{16} bytes for the IPv6 address.
1651  
1652 \note
1653 The host availability check fails, if the remote host does not respond to echo requests,
1654 or intermediate routers do not forward the echo requests or echo responses.
1655
1656 \b Example:
1657 \code
1658 extern ARM_DRIVER_WIFI Driver_WiFi0;
1659 static ARM_DRIVER_WIFI *wifi;
1660  
1661 void ping_host (void) {
1662   uint8_t ip[4] = { 192U, 168U, 0U, 100U };
1663   int32_t res;
1664  
1665   wifi = &Driver_WiFi0;
1666   res = wifi->Ping ((uint8_t *)ip, sizeof(ip));
1667   if (res == ARM_DRIVER_OK) {
1668     // Host responded
1669   }
1670 }
1671 \endcode
1672 */
1673 /**
1674 @}
1675 */
1676 // end group wifi_socket_gr
1677
1678
1679 /**
1680 @}
1681 */
1682 // End WiFi Interface