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="https://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 \note Often, WiFi chips and modules have their own networking stack incorporated. This means that payload data is sent via
31 a serial interface (SPI or USART) to the WiFi chip/module and the Ethernet frames are assembled inside. If you intend to use
32 a separate TCP/IP stack on the microcontroller, make sure that the WiFi driver has a \ref wifi_bypass_gr.
33 This allows to send the Ethernet frames assembled by the TCP/IP component transparently through the WiFi chip/module.
34
35 The WiFi interface usually requires CMSIS-RTOS features (i.e. mutex) and is often implemented
36 with a peripheral device that is connected to the system using the SPI or UART interface. However,
37 there are also some microcontroller devices with WiFi interface on the chip.
38
39 The implementation of the WiFi CMSIS-Driver is therefore generally provided as a separate software pack.
40 It is often implemented as wrapper to the SDK (Software Development Kit) of the WiFi chipset.
41
42 <b>Driver Functions</b>
43
44 The driver functions are published in the access struct as explained in \ref DriverFunctions
45 - \ref ARM_DRIVER_WIFI : access struct for WiFi driver functions
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
ARM_WIFI_GetVersion(void)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
ARM_WIFI_GetCapabilities(void)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
ARM_WIFI_Initialize(ARM_WIFI_SignalEvent_t cb_event)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
ARM_WIFI_Uninitialize(void)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
ARM_WIFI_PowerControl(ARM_POWER_STATE state)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
ARM_WIFI_GetModuleInfo(char * module_info,uint32_t max_len)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
ARM_WIFI_SignalEvent(uint32_t event,void * arg)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
ARM_WIFI_SetOption(uint32_t interface,uint32_t option,const void * data,uint32_t len)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
ARM_WIFI_GetOption(uint32_t interface,uint32_t option,void * data,uint32_t * len)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
ARM_WIFI_Scan(ARM_WIFI_SCAN_INFO_t scan_info[],uint32_t max_num)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
ARM_WIFI_Activate(uint32_t interface,const ARM_WIFI_CONFIG_t * config)627 int32_t ARM_WIFI_Activate (uint32_t interface, const ARM_WIFI_CONFIG_t *config) {
628 return ARM_DRIVER_OK;
629 }
630 /**
631 \fn int32_t ARM_WIFI_Activate (uint32_t interface, const 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
ARM_WIFI_Deactivate(uint32_t interface)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
ARM_WIFI_IsConnected(void)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
ARM_WIFI_GetNetInfo(ARM_WIFI_NET_INFO_t * net_info)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 TCP/IP stack is running
794 on the microcontroller (usually a third-party or open-source networking component). The internal TCP/IP
795 stack of the WiFi module is therefore not used, and this usually means that the \ref wifi_socket_gr
796 functions can not be used.
797 @{
798 */
799
ARM_WIFI_BypassControl(uint32_t interface,uint32_t mode)800 int32_t ARM_WIFI_BypassControl (uint32_t interface, uint32_t mode) {
801 return ARM_DRIVER_OK;
802 }
803 /**
804 \fn int32_t ARM_WIFI_BypassControl (uint32_t interface, uint32_t mode)
805 \details
806 The function \b ARM_WIFI_BypassControl enables or disables the WiFi bypass mode.
807
808 The WiFi Bypass mode can only be enabled, if there is a bypass mode supported in the WiFi driver.
809 You can check this by checking the driver's capabilities.
810
811 \note
812 Bypass mode is enabled by default if the module does not support the Socket interface.
813
814 The argument \em mode specifies the desired state of the WiFi Bypass mode, which is
815 enabled or disabled.
816
817 \b Example:
818 \code
819 extern ARM_DRIVER_WIFI Driver_WiFi0;
820 static ARM_DRIVER_WIFI *wifi;
821 static ARM_ETH_MAC_ADDR own_mac_address;
822
823 static void wifi_notify (uint32_t event, ,void *arg) {
824 switch (event) {
825 :
826 }
827 }
828
829 void initialize_wifi_bypass (void) {
830 ARM_WIFI_CAPABILITIES capabilities;
831
832 wifi = &Driver_WiFi0;
833 capabilities = wifi->GetCapabilities ();
834 if (capabilities.bypass_mode == 0) {
835 // error handling
836 }
837
838 // Initialize and Power-on WiFi Interface
839 wifi->Initialize ((capabilities.eth_rx_frame_event) ? wifi_notify : NULL);
840 wifi->PowerControl (ARM_POWER_FULL);
841
842 // populate own_mac_address with the address to use for station
843 wifi->SetOption(0U, ARM_WIFI_MAC, &own_mac_address, 6U);
844
845 wifi->BypassControl (0U, 1U); // Enable bypass mode for station
846 }
847 \endcode
848 */
849
ARM_WIFI_EthSendFrame(uint32_t interface,const uint8_t * frame,uint32_t len)850 int32_t ARM_WIFI_EthSendFrame (uint32_t interface, const uint8_t *frame, uint32_t len) {
851 return ARM_DRIVER_OK;
852 }
853 /**
854 \fn int32_t ARM_WIFI_EthSendFrame (uint32_t interface, const uint8_t *frame, uint32_t len)
855 \details
856 The function \b ARM_WIFI_EthSendFrame writes an <b>Ethernet frame</b> to the WiFi transmit buffer.
857
858 The WiFi bypass mode must be enabled by using the function \ref ARM_WIFI_BypassControl
859 before a call to this function.
860
861 The frame data addressed by \em frame starts with MAC destination and ends with the last
862 Payload data byte. The frame data is copied into the transmit buffer of the WiFi interface.
863
864 The maximum value for \em len is implied by the size restrictions of the Ethernet frame
865 but is not verified. Using an invalid value for \em len may generate unpredicted results.
866
867 \b Example:
868 \code
869 status = wifi->EthSendFrame (0U, &frame_data[0], frame_length);
870 if (status != ARM_DRIVER_OK) {
871 // error handling
872 }
873 \endcode
874 */
875
ARM_WIFI_EthReadFrame(uint32_t interface,uint8_t * frame,uint32_t len)876 int32_t ARM_WIFI_EthReadFrame (uint32_t interface, uint8_t *frame, uint32_t len) {
877 return ARM_DRIVER_OK;
878 }
879 /**
880 \fn int32_t ARM_WIFI_EthReadFrame (uint32_t interface, uint8_t *frame, uint32_t len)
881 \details
882 The function \b ARM_WIFI_EthReadFrame reads an <b>Ethernet frame</b> from the WiFi interface
883 in the bypass mode.
884
885 The \em len of the Ethernet frame can be checked using the function \ref ARM_WIFI_EthGetRxFrameSize.
886
887 The frame data addressed by \em frame starts with MAC destination and ends with the last
888 Payload data byte. The frame data is read from the receive buffer of the WiFi interface and
889 the number of bytes written into the memory addressed by \em frame is returned.
890 A negative return value indicates an error whereby the status code is defined with
891 driver common return codes.
892
893 The function \ref ARM_WIFI_EthReadFrame may be called with \em buf = \token{NULL} and \em len = \token{0}
894 to discard or release a frame. This is useful when an incorrect frame has been received or
895 no memory is available to hold the Ethernet frame.
896
897 \b Example:
898 \code
899 size = wifi->EthGetRxFrameSize ();
900 if ((size < 14) || (size > 1514)) { // frame excludes CRC
901 wifi->EthReadFrame (NULL, 0); // Frame error, release it
902 }
903 len = wifi->ReadFrame (0U, &frame_data[0], size);
904 if (len < 0) {
905 // error handling
906 }
907 \endcode
908 */
909
ARM_WIFI_EthGetRxFrameSize(uint32_t interface)910 uint32_t ARM_WIFI_EthGetRxFrameSize (uint32_t interface) {
911 return 0;
912 }
913 /**
914 \fn uint32_t ARM_WIFI_EthGetRxFrameSize (uint32_t interface)
915 \details
916 The function \b ARM_WIFI_EthGetRxFrameSize returns the size of a received <b>Ethernet frame</b>
917 in the bypass mode. This function can be called before \ref ARM_WIFI_EthReadFrame and retrieves
918 the value \em len.
919
920 The frame size includes MAC destination and ends with the last Payload data byte.
921 Value \token{0} indicates that no Ethernet frame is available in the receive buffer.
922 Values smaller than minimum size of Ethernet frame or larger than maximum size of Ethernet frame
923 indicate an invalid frame which needs to be discarded by calling \ref ARM_WIFI_EthReadFrame.
924
925 \b Example:
926 - see \ref ARM_WIFI_EthReadFrame
927 */
928 /**
929 @}
930 */
931 // end group wifi_bypass_gr
932
933
934 /**
935 \defgroup wifi_socket_gr WiFi Socket
936 \ingroup wifi_interface_gr
937 \brief Socket interface to IP stack running on WiFi module
938 \details The \ref wifi_socket_gr functions provide the interface to an IP stack that is running
939 on the WiFi module. This IP stack handles data communication with the network and provides the user
940 with a communication endpoint called sockets.
941 @{
942 */
943
944 /**
945 \defgroup wifi_addr_family WiFi Socket Address Family definitions
946 \ingroup wifi_socket_gr
947 \brief WiFi Socket Address Family definitions.
948 \details The WiFi Socket Address Family specifies the addressing scheme that an instance of the WiFi socket can use.
949 @{
950 \def ARM_SOCKET_AF_INET
951 \details Internet Address Family version 4.
952 \def ARM_SOCKET_AF_INET6
953 \details Internet Address Family version 6.
954 @}
955 */
956
957 /**
958 \defgroup wifi_socket_type WiFi Socket Type definitions
959 \ingroup wifi_socket_gr
960 \brief WiFi Socket Type definitions.
961 \details The WiFi Socket Type specifies the type of the WiFi socket.
962 @{
963 \def ARM_SOCKET_SOCK_STREAM
964 \details Stream Socket is connection-oriented, sequenced and reliable, implemented on top of the TCP protocol.
965 \def ARM_SOCKET_SOCK_DGRAM
966 \details Datagram Socket is connectionless, unreliable, using the UDP protocol.
967 @}
968 */
969
970 /**
971 \defgroup wifi_protocol WiFi Socket Protocol definitions
972 \ingroup WiFi_socket_gr
973 \brief WiFi Socket Protocol definitions.
974 \details The WiFi Socket Protocol specifies the Internet Protocol Type that the socket is using.
975 @{
976 \def ARM_SOCKET_IPPROTO_TCP
977 \details Transmission Control Protocol.
978 \def ARM_SOCKET_IPPROTO_UDP
979 \details User Datagram Protocol.
980 @}
981 */
982
983 /**
984 \defgroup wifi_soc_opt WiFi Socket Option definitions
985 \ingroup WiFi_socket_gr
986 \brief WiFi Socket Option definitions.
987 \details The WiFi Socket Option specifies the socket option for which the value is to be set or obtained.
988 @{
989 \def ARM_SOCKET_IO_FIONBIO
990 \details Enables or disables the non-blocking mode for the WiFi socket.
991 \sa wifi_soc_opt
992 \def ARM_SOCKET_SO_RCVTIMEO
993 \details Specifies the time limit for receiving in blocking mode. The time limit is in milliseconds.
994 \sa wifi_soc_opt
995 \def ARM_SOCKET_SO_SNDTIMEO
996 \details Specifies the time limit for sending in blocking mode. The time limit is in milliseconds.
997 \sa wifi_soc_opt
998 \def ARM_SOCKET_SO_KEEPALIVE
999 \details Enables or disables the keep-alive mode for the stream socket.
1000 \sa wifi_soc_opt
1001 \def ARM_SOCKET_SO_TYPE
1002 \details Obtains the type of the Wifi socket.
1003 \sa wifi_soc_opt
1004 @}
1005 */
1006
1007 /**
1008 \defgroup wifi_soc_func WiFi Socket Function return codes
1009 \ingroup WiFi_socket_gr
1010 \brief WiFi Socket Function return codes.
1011 \details This section lists all the return errors the WiFi socket functions will return.
1012 The error codes are negative. This makes it easy to check an error when the return
1013 code is less than \token{0}.
1014 @{
1015 \def ARM_SOCKET_ERROR
1016 \sa wifi_soc_func
1017 \def ARM_SOCKET_ESOCK
1018 \sa wifi_soc_func
1019 \def ARM_SOCKET_EINVAL
1020 \sa wifi_soc_func
1021 \def ARM_SOCKET_ENOTSUP
1022 \sa wifi_soc_func
1023 \def ARM_SOCKET_ENOMEM
1024 \sa wifi_soc_func
1025 \def ARM_SOCKET_EAGAIN
1026 \sa wifi_soc_func
1027 \def ARM_SOCKET_EINPROGRESS
1028 \sa wifi_soc_func
1029 \def ARM_SOCKET_ETIMEDOUT
1030 \sa wifi_soc_func
1031 \def ARM_SOCKET_EISCONN
1032 \sa wifi_soc_func
1033 \def ARM_SOCKET_ENOTCONN
1034 \sa wifi_soc_func
1035 \def ARM_SOCKET_ECONNREFUSED
1036 \sa wifi_soc_func
1037 \def ARM_SOCKET_ECONNRESET
1038 \sa wifi_soc_func
1039 \def ARM_SOCKET_ECONNABORTED
1040 \sa wifi_soc_func
1041 \def ARM_SOCKET_EALREADY
1042 \sa wifi_soc_func
1043 \def ARM_SOCKET_EADDRINUSE
1044 \sa wifi_soc_func
1045 \def ARM_SOCKET_EHOSTNOTFOUND
1046 \sa wifi_soc_func
1047 @}
1048 */
1049
ARM_WIFI_SocketCreate(int32_t af,int32_t type,int32_t protocol)1050 int32_t ARM_WIFI_SocketCreate (int32_t af, int32_t type, int32_t protocol) {
1051 return 0;
1052 }
1053 /**
1054 \fn int32_t ARM_WIFI_SocketCreate (int32_t af, int32_t type, int32_t protocol)
1055 \details
1056 The function \b ARM_WIFI_SocketCreate creates a communication endpoint called a socket.
1057
1058 The argument \em af specifies the address family. The following values are supported:
1059 Family | Description
1060 :----------------------------|:-------------------------------------------------
1061 \ref ARM_SOCKET_AF_INET | Address Family Internet
1062 \ref ARM_SOCKET_AF_INET6 | Address Family Internet version 6
1063
1064 The argument \em type specifies the communication semantics. The following are the currently supported types:
1065 Type | Description
1066 :----------------------------|:-------------------------------------------------
1067 \ref ARM_SOCKET_SOCK_STREAM | Provides a reliable connection based data stream that is full-duplex
1068 \ref ARM_SOCKET_SOCK_DGRAM | Provides connectionless communication that is unreliable
1069
1070 The argument \em protocol specifies the protocol that must be used with the socket type:
1071 Protocol | Description
1072 :----------------------------|:-------------------------------------------------
1073 \ref ARM_SOCKET_IPPROTO_TCP | Must be used with ARM_SOCKET_SOCK_STREAM socket type
1074 \ref ARM_SOCKET_IPPROTO_UDP | Must be used with ARM_SOCKET_SOCK_DGRAM socket type
1075 \token{0} | The system selects a matching protocol for the socket type
1076
1077 \b Example:
1078 - see \ref ARM_WIFI_SocketListen, \ref ARM_WIFI_SocketConnect
1079 */
1080
ARM_WIFI_SocketBind(int32_t socket,const uint8_t * ip,uint32_t ip_len,uint16_t port)1081 int32_t ARM_WIFI_SocketBind (int32_t socket, const uint8_t *ip, uint32_t ip_len, uint16_t port) {
1082 return 0;
1083 }
1084 /**
1085 \fn int32_t ARM_WIFI_SocketBind (int32_t socket, const uint8_t *ip, uint32_t ip_len, uint16_t port)
1086 \details
1087 The function \b ARM_WIFI_SocketBind assigns a name to an unnamed socket. The name represents the local address
1088 and port of the communication endpoint.
1089
1090 The argument \em socket specifies a socket identification number returned from a previous call
1091 to \ref ARM_WIFI_SocketCreate.
1092
1093 The argument \em ip is a pointer to the buffer containing the IP address octets of the local IP address.
1094
1095 The argument \em ip_len specifies the length of the local IP address. The length is \token{4} bytes
1096 for the IPv4 address and \token{16} bytes for the IPv6 address.
1097
1098 The argument \em port specifies the local port. If the argument \em port is \token{0}, the function returns error,
1099 because this port is reserved.
1100
1101 \b Example:
1102 - see \ref ARM_WIFI_SocketListen
1103 */
1104
ARM_WIFI_SocketListen(int32_t socket,int32_t backlog)1105 int32_t ARM_WIFI_SocketListen (int32_t socket, int32_t backlog) {
1106 return 0;
1107 }
1108 /**
1109 \fn int32_t ARM_WIFI_SocketListen (int32_t socket, int32_t backlog)
1110 \details
1111 The function \b ARM_WIFI_SocketListen sets the specified socket to listening mode, that is to the
1112 server mode of operation. Before calling the \b ARM_WIFI_SocketListen function, the \ref ARM_WIFI_SocketBind
1113 function must be called.
1114
1115 The argument \em socket specifies a socket identification number returned from a previous call
1116 to \ref ARM_WIFI_SocketCreate.
1117
1118 The argument \em backlog specifies a maximum number of connection requests that can be queued.
1119
1120 \b Example:
1121 \code
1122 extern ARM_DRIVER_WIFI Driver_WiFi0;
1123 static ARM_DRIVER_WIFI *wifi;
1124
1125 void Echo_Server_Thread (void *arg) {
1126 uint8_t ip[4] = { 0U, 0U, 0U, 0U };
1127 int32_t sock, sd, res;
1128 char dbuf[120];
1129
1130 while (1) {
1131 wifi = &Driver_WiFi0;
1132 sock = wifi->SocketCreate (ARM_SOCKET_AF_INET, ARM_SOCKET_SOCK_STREAM, ARM_SOCKET_IPPROTO_TCP);
1133
1134 wifi->SocketBind (sock, (uint8_t *)ip, sizeof(ip), 7U);
1135 wifi->SocketListen (sock, 1);
1136 sd = wifi->SocketAccept (sock, NULL, NULL, NULL);
1137 wifi->SocketClose (sock);
1138 sock = sd;
1139
1140 while (1) {
1141 res = wifi->SocketRecv (sock, dbuf, sizeof(dbuf));
1142 if (res < 0) {
1143 break; // Error occurred
1144 }
1145 if (res > 0) {
1146 wifi->SocketSend (sock, dbuf, res); // Echo the data
1147 }
1148 }
1149 wifi->SocketClose (sock);
1150 }
1151 }
1152 \endcode
1153 */
1154
ARM_WIFI_SocketAccept(int32_t socket,uint8_t * ip,uint32_t * ip_len,uint16_t * port)1155 int32_t ARM_WIFI_SocketAccept (int32_t socket, uint8_t *ip, uint32_t *ip_len, uint16_t *port) {
1156 return 0;
1157 }
1158 /**
1159 \fn int32_t ARM_WIFI_SocketAccept (int32_t socket, uint8_t *ip, uint32_t *ip_len, uint16_t *port)
1160 \details
1161 The function \b ARM_WIFI_SocketAccept accepts a connection request queued for a listening socket.
1162 If a connection request is pending, \b ARM_WIFI_SocketAccept removes the request from the queue,
1163 and creates a new socket for the connection. The original listening socket remains open and continues
1164 to queue new connection requests. The \em socket must be a socket of type \b ARM_SOCKET_SOCK_STREAM.
1165
1166 In blocking mode, which is enabled by default, this function waits for a connection request. In
1167 non blocking mode, you must call the \b ARM_WIFI_SocketAccept function again if the error code
1168 \c ARM_SOCKET_EAGAIN is returned.
1169
1170 The argument \em socket specifies a socket identification number returned from a previous call
1171 to \ref ARM_WIFI_SocketCreate.
1172
1173 The argument \em ip is a pointer to the buffer that will receive the IP address of the connection node.
1174 If the \em ip is \token{NULL}, the IP address is not returned.
1175
1176 The argument \em ip_len is a pointer to the IP address length. It should initially contain the amount of
1177 space pointed to by \em ip. On return it contains the actual length of the address returned in bytes.
1178
1179 The argument \em port is a pointer to the buffer, that will receive the port number of the connection node.
1180 If the \em port is \token{NULL}, the port number is not returned.
1181
1182 \b Example:
1183 - see \ref ARM_WIFI_SocketListen
1184 */
1185
ARM_WIFI_SocketConnect(int32_t socket,const uint8_t * ip,uint32_t ip_len,uint16_t port)1186 int32_t ARM_WIFI_SocketConnect (int32_t socket, const uint8_t *ip, uint32_t ip_len, uint16_t port) {
1187 return 0;
1188 }
1189 /**
1190 \fn int32_t ARM_WIFI_SocketConnect (int32_t socket, const uint8_t *ip, uint32_t ip_len, uint16_t port)
1191 \details
1192 The function \b ARM_WIFI_SocketConnect assigns the address of the peer communication endpoint. The function
1193 behaves differently according to the type of socket:
1194
1195 - \b ARM_SOCKET_SOCK_STREAM: A connection is established between the endpoints.
1196
1197 In blocking mode, which is enabled by default, this function waits for a connection to be established.
1198
1199 In non blocking mode, the function returns the error code \c ARM_SOCKET_EINPROGRESS and the connection
1200 is established asynchronously. Subsequent calls to \b ARM_WIFI_SocketConnect for the same socket,
1201 before the connection is established, return the error code \c ARM_SOCKET_EALREADY. When the connection
1202 is established, the call to \b ARM_WIFI_SocketConnect returns the error code \c ARM_SOCKET_EISCONN.
1203
1204 - \b ARM_SOCKET_SOCK_DGRAM: An address filter is established between the endpoints.
1205
1206 The address filter is changed with another \b ARM_WIFI_SocketConnect function call. If the socket
1207 is not yet bound, the system implicitly binds to a random dynamic port.
1208
1209 The argument \em socket specifies a socket identification number returned from a previous call
1210 to \ref ARM_WIFI_SocketCreate.
1211
1212 The argument \em ip is a pointer to the buffer containing the IP address octets of the endpoint node.
1213
1214 The argument \em ip_len specifies the length of the IP address. The length is \token{4} bytes
1215 for the IPv4 address and \token{16} bytes for the IPv6 address.
1216
1217 The argument \em port specifies the port of the endpoint node. If the argument \em port is \token{0},
1218 the function returns error, because this port is reserved.
1219
1220 \b Example:
1221 \code
1222 extern ARM_DRIVER_WIFI Driver_WiFi0;
1223 static ARM_DRIVER_WIFI *wifi;
1224
1225 static const char message[] = { "The quick brown fox jumps over the lazy dog." };
1226
1227 void Echo_Client_Thread (void *arg) {
1228 uint8_t ip[4] = { 192U, 168U, 0U, 100U };
1229 int32_t sock, res;
1230 char dbuf[120];
1231
1232 while (1) {
1233 wifi = &Driver_WiFi0;
1234 sock = wifi->SocketCreate (ARM_SOCKET_AF_INET, ARM_SOCKET_SOCK_STREAM, ARM_SOCKET_IPPROTO_TCP);
1235
1236 res = wifi->SocketConnect (sock, (uint8_t *)ip, sizeof(ip), 7U);
1237 if (res == 0) {
1238 wifi->SocketSend (sock, message, sizeof(message));
1239 res = wifi->SocketRecv (sock, dbuf, sizeof(dbuf));
1240 if (res < 0) {
1241 break; // Error occurred
1242 }
1243 if (res > 0) {
1244 if (memcmp (dbuf, message, res) != 0) {
1245 // error handling, message is not the same as sent
1246 }
1247 }
1248 }
1249 wifi->SocketClose (sock);
1250 osDelay (1000U);
1251 }
1252 }
1253 \endcode
1254 */
1255
ARM_WIFI_SocketRecv(int32_t socket,void * buf,uint32_t len)1256 int32_t ARM_WIFI_SocketRecv (int32_t socket, void *buf, uint32_t len) {
1257 return 1;
1258 }
1259 /**
1260 \fn int32_t ARM_WIFI_SocketRecv (int32_t socket, void *buf, uint32_t len)
1261 \details
1262 The function \b ARM_WIFI_SocketRecv receives incoming data that has been queued for the socket.
1263 You can use this function with both, the stream and the datagram socket. It reads as much
1264 information as currently available up to the size of the buffer specified.
1265
1266 In blocking mode, which is enabled by default, this function waits for received data. In non
1267 blocking mode, you must call the \b ARM_WIFI_SocketRecv function again if the error code
1268 \c ARM_SOCKET_EAGAIN is returned.
1269
1270 The argument \em socket specifies a socket identification number returned from a previous call
1271 to \ref ARM_WIFI_SocketCreate.
1272
1273 The argument \em buf is a pointer to the application data buffer for storing the data to.
1274 If the available data is too large to fit in the supplied application buffer \em buf, excess bytes
1275 are discarded in case of a datagram sockets. For stream sockets, the data is buffered internally
1276 so the application can retrieve all data by multiple calls of \b ARM_WIFI_SocketRecv function.
1277
1278 The argument \em len specifies the size of the application data buffer.
1279
1280 \note
1281 The function can also be used to check if the socket has data available to read by specifying \token{0}
1282 for argument \em len (argument \em buf is ignored).
1283 The function returns \token{0} if data is available or error code otherwise.
1284 In blocking mode, the function waits until data is available, in non blocking mode the function returns instantly.
1285
1286
1287 \b Example:
1288 - see \ref ARM_WIFI_SocketListen
1289 */
1290
ARM_WIFI_SocketRecvFrom(int32_t socket,void * buf,uint32_t len,uint8_t * ip,uint32_t * ip_len,uint16_t * port)1291 int32_t ARM_WIFI_SocketRecvFrom (int32_t socket, void *buf, uint32_t len, uint8_t *ip, uint32_t *ip_len, uint16_t *port) {
1292 return 1;
1293 }
1294 /**
1295 \fn int32_t ARM_WIFI_SocketRecvFrom (int32_t socket, void *buf, uint32_t len, uint8_t *ip, uint32_t *ip_len, uint16_t *port)
1296 \details
1297 The function \b ARM_WIFI_SocketRecvFrom is used to receive data that has been queued for a socket.
1298 It is normally used to receive messages on datagram sockets, but can also be used to receive a reliable,
1299 ordered stream of data on a connected stream sockets. It reads as much information as currently available
1300 up to the size of the buffer specified.
1301
1302 In blocking mode, which is enabled by default, this function waits for received data. In non
1303 blocking mode, you must call the \b ARM_WIFI_SocketRecv function again if the error code
1304 \c ARM_SOCKET_EAGAIN is returned.
1305
1306 The argument \em socket specifies a socket identification number returned from a previous call
1307 to \ref ARM_WIFI_SocketCreate.
1308
1309 The argument \em buf is a pointer to the application data buffer for storing the data to.
1310 If the available data is too large to fit in the supplied application buffer \em buf, excess bytes
1311 are discarded in case of a datagram sockets. For stream sockets, the data is buffered internally
1312 so the application can retrieve all data by multiple calls of \b ARM_WIFI_SocketRecv function.
1313
1314 The argument \em len specifies the size of the application data buffer.
1315
1316 The argument \em ip is a pointer to the buffer that will receive the IP address of the sender.
1317 If the \em ip is \token{NULL}, the IP address is not returned.
1318
1319 The argument \em ip_len is a pointer to the IP address length. It should initially contain the amount of
1320 space pointed to by \em ip. On return it contains the actual length of the address returned in bytes.
1321
1322 The argument \em port is a pointer to the buffer, that will receive the port number of the sender.
1323 If the \em port is \token{NULL}, the port number is not returned.
1324
1325 \note
1326 The function can also be used to check if the socket has data available to read by specifying \token{0}
1327 for argument \em len (arguments \em buf, \em ip, \em ip_len and \em port are ignored).
1328 The function returns \token{0} if data is available or error code otherwise.
1329 In blocking mode, the function waits until data is available, in non blocking mode the function returns instantly.
1330
1331 \b Example:
1332 \code
1333 extern ARM_DRIVER_WIFI Driver_WiFi0;
1334 static ARM_DRIVER_WIFI *wifi;
1335
1336 void Echo_Server_Thread (void *arg) {
1337 uint8_t ip[4];
1338 uint16_t port;
1339 int32_t sock, res;
1340 uint32_t ip_len;
1341 char dbuf[120];
1342
1343 while (1) {
1344 wifi = &Driver_WiFi0;
1345 sock = wifi->SocketCreate (ARM_SOCKET_AF_INET, ARM_SOCKET_SOCK_DGRAM, ARM_SOCKET_IPPROTO_UDP);
1346
1347 ip[0] = 0U; // Unspecified address
1348 ip[1] = 0U;
1349 ip[2] = 0U;
1350 ip[3] = 0U;
1351 port = 7U; // Standard port for Echo service
1352
1353 wifi->SocketBind (sock, (uint8_t *)ip, sizeof(ip), port);
1354
1355 while (1) {
1356 ip_len = sizeof(ip);
1357 res = wifi->SocketRecvFrom (sock, dbuf, sizeof(dbuf), (uint8_t *)ip, &ip_len, &port);
1358 if (res < 0) {
1359 break; // Error occurred
1360 }
1361 if (res > 0) { // Echo the data
1362 wifi->SocketSendTo (sock, dbuf, res, (uint8_t *)ip, ip_len, port);
1363 }
1364 }
1365 wifi->SocketClose (sock);
1366 }
1367 }
1368 \endcode
1369 */
1370
ARM_WIFI_SocketSend(int32_t socket,const void * buf,uint32_t len)1371 int32_t ARM_WIFI_SocketSend (int32_t socket, const void *buf, uint32_t len) {
1372 return 1;
1373 }
1374 /**
1375 \fn int32_t ARM_WIFI_SocketSend (int32_t socket, const void *buf, uint32_t len)
1376 \details
1377 The function \b ARM_WIFI_SocketSend is used to send data on an already connected socket. This function is
1378 normally used to send a reliable, ordered stream of data bytes on a stream sockets. It can also be used
1379 to send messages on datagram sockets.
1380
1381 The argument \em socket specifies a socket identification number returned from a previous call
1382 to \ref ARM_WIFI_SocketCreate.
1383
1384 The argument \a buf is a pointer to the application data buffer containing data to transmit. The buffer
1385 data length is not limited in size. If the data length is too large for one packet, the \b ARM_WIFI_SocketSend function
1386 will fragment the data and send it in several successive data packets:
1387 - In blocking mode, which is enabled by default, this function returns after the data has been successfully queued for transmission.
1388 - In non blocking mode, the function returns immediately without blocking the system.
1389
1390 The argument \a len specifies the length of data in bytes.
1391
1392 Return value, when positive, represents the number of bytes sent, which can be less than \a len.
1393
1394 \note
1395 The function can also be used to check if the socket is ready to send data by specifying \token{0}
1396 for argument \em len (argument \em buf is ignored).
1397 The function returns \token{0} if the socket is writable or error code otherwise.
1398
1399 \b Example:
1400 - see \ref ARM_WIFI_SocketListen
1401 */
1402
ARM_WIFI_SocketSendTo(int32_t socket,const void * buf,uint32_t len,const uint8_t * ip,uint32_t ip_len,uint16_t port)1403 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) {
1404 return 1;
1405 }
1406 /**
1407 \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)
1408 \details
1409 The function \b ARM_WIFI_SocketSendTo is used to send data. It is normally used to send messages
1410 on a datagram sockets, but can also be used to send data on a connected stream sockets.
1411
1412 If the datagram socket is not yet bound, the system implicitly binds to a random dynamic port.
1413
1414 The argument \em socket specifies a socket identification number returned from a previous call
1415 to \ref ARM_WIFI_SocketCreate.
1416
1417 The argument \a buf is a pointer to the application data buffer containing data to transmit. The buffer
1418 data length is not limited in size. If the data length is too large for one packet, the \b ARM_WIFI_SocketSend function
1419 will fragment the data and send it in several successive data packets:
1420 - In blocking mode, which is enabled by default, this function returns after the data has been successfully queued for transmission.
1421 - In non blocking mode, the function returns immediately without blocking the system.
1422
1423 The argument \a len specifies the length of data in bytes.
1424
1425 The argument \em ip is a pointer to the buffer containing the IP address octets of the endpoint node.
1426
1427 The argument \em ip_len specifies the length of the IP address. The length is \token{4} bytes
1428 for the IPv4 address and \token{16} bytes for the IPv6 address.
1429
1430 The argument \em port specifies the port of the endpoint node. If the argument \em port is \token{0},
1431 the function returns error, because this port is reserved.
1432
1433 For the stream sockets, arguments \em ip, \em ip_len and \em port are ignored.
1434
1435 Return value, when positive, represents the number of bytes sent, which can be less than \a len.
1436
1437 \note
1438 The function can also be used to check if the socket is ready to send data by specifying \token{0}
1439 for argument \em len (arguments \em buf, \em ip, \em ip_len and \em port are ignored).
1440 The function returns \token{0} if the socket is writable or error code otherwise.
1441
1442 \b Example:
1443 - see \ref ARM_WIFI_SocketRecvFrom
1444 */
1445
ARM_WIFI_SocketGetSockName(int32_t socket,uint8_t * ip,uint32_t * ip_len,uint16_t * port)1446 int32_t ARM_WIFI_SocketGetSockName (int32_t socket, uint8_t *ip, uint32_t *ip_len, uint16_t *port) {
1447 return 0;
1448 }
1449 /**
1450 \fn int32_t ARM_WIFI_SocketGetSockName (int32_t socket, uint8_t *ip, uint32_t *ip_len, uint16_t *port)
1451 \details
1452 The function \b ARM_WIFI_SocketGetSockName retrieves the local IP address and port for a socket.
1453
1454 The argument \em socket specifies a socket identification number returned from a previous call
1455 to \ref ARM_WIFI_SocketCreate.
1456
1457 The argument \em ip is a pointer to the buffer that will receive the local IP address.
1458 If the \em ip is \token{NULL}, the local IP address is not returned.
1459
1460 The argument \em ip_len is a pointer to the IP address length. It should initially contain the amount of
1461 space pointed to by \em ip. On return it contains the actual length of the address returned in bytes.
1462
1463 The argument \em port is a pointer to the buffer, that will receive the local port number.
1464 If the \em port is \token{NULL}, the local port number is not returned.
1465
1466 \b Example:
1467 \code
1468 static uint8_t local_ip[4]; // Socket address and port
1469 static uint16_t local_port;
1470
1471 static void get_socket_local_info (void) {
1472 uint32_t ip_len;
1473
1474 ip_len = sizeof(local_ip);
1475 wifi->SocketGetSockName (sock, (uint8_t *)local_ip, &ip_len, &local_port);
1476 }
1477 \endcode
1478 */
1479
ARM_WIFI_SocketGetPeerName(int32_t socket,uint8_t * ip,uint32_t * ip_len,uint16_t * port)1480 int32_t ARM_WIFI_SocketGetPeerName (int32_t socket, uint8_t *ip, uint32_t *ip_len, uint16_t *port) {
1481 return 0;
1482 }
1483 /**
1484 \fn int32_t ARM_WIFI_SocketGetPeerName (int32_t socket, uint8_t *ip, uint32_t *ip_len, uint16_t *port)
1485 \details
1486 The function \b ARM_WIFI_SocketGetPeerName retrieves the IP address and port of the peer to which
1487 a socket is connected.
1488
1489 The argument \em socket specifies a socket identification number returned from a previous call
1490 to \ref ARM_WIFI_SocketCreate.
1491
1492 The argument \em ip is a pointer to the buffer that will receive the IP address of the peer.
1493 If the \em ip is \token{NULL}, the IP address is not returned.
1494
1495 The argument \em ip_len is a pointer to the IP address length. It should initially contain the amount of
1496 space pointed to by \em ip. On return it contains the actual length of the address returned in bytes.
1497
1498 The argument \em port is a pointer to the buffer, that will receive the port number of the peer.
1499 If the \em port is \token{NULL}, the port number is not returned.
1500
1501 \b Example:
1502 \code
1503 static uint8_t peer_ip[4]; // Socket address and port
1504 static uint16_t peer_port;
1505
1506 static void get_socket_peer_info (void) {
1507 uint32_t ip_len;
1508
1509 ip_len = sizeof(peer_ip);
1510 wifi->SocketGetPeerName (sock, (uint8_t *)peer_ip, &ip_len, &peer_port);
1511 }
1512 \endcode
1513 */
1514
ARM_WIFI_SocketGetOpt(int32_t socket,int32_t opt_id,void * opt_val,uint32_t * opt_len)1515 int32_t ARM_WIFI_SocketGetOpt (int32_t socket, int32_t opt_id, void *opt_val, uint32_t *opt_len) {
1516 return 0;
1517 }
1518 /**
1519 \fn int32_t ARM_WIFI_SocketGetOpt (int32_t socket, int32_t opt_id, void *opt_val, uint32_t *opt_len)
1520 \details
1521 The function \b ARM_WIFI_SocketGetOpt retrieves options for a socket.
1522
1523 The argument \em socket specifies a socket identification number returned from a previous call
1524 to \ref ARM_WIFI_SocketCreate.
1525
1526 The argument \em opt_id is the socket option for which the value is to be retrieved. The following
1527 socket options are supported:
1528 Option | Description
1529 :----------------------------|:-------------------------------------------------
1530 \ref ARM_SOCKET_SO_RCVTIMEO | Timeout for receiving in blocking mode
1531 \ref ARM_SOCKET_SO_SNDTIMEO | Timeout for sending in blocking mode
1532 \ref ARM_SOCKET_SO_KEEPALIVE | Keep-alive mode for the stream socket
1533 \ref ARM_SOCKET_SO_TYPE | Type of the socket (stream or datagram)
1534
1535 The argument \em opt_val points to the buffer that will receive the value of the \em opt_id.
1536
1537 The argument \em opt_len contains the length of the buffer at the input and returns the length
1538 of the option information on the output.
1539
1540 \b Example:
1541 \code
1542 uint32_t type;
1543
1544 wifi->SocketGetOpt (sock, ARM_SOCKET_SO_TYPE, &type, sizeof(type));
1545 if (type == ARM_SOCKET_SOCK_STREAM) {
1546 // Stream socket
1547 }
1548 if (type == ARM_SOCKET_SOCK_DGRAM) {
1549 // Datagram socket
1550 }
1551 \endcode
1552 */
1553
ARM_WIFI_SocketSetOpt(int32_t socket,int32_t opt_id,const void * opt_val,uint32_t opt_len)1554 int32_t ARM_WIFI_SocketSetOpt (int32_t socket, int32_t opt_id, const void *opt_val, uint32_t opt_len) {
1555 return 0;
1556 }
1557 /**
1558 \fn int32_t ARM_WIFI_SocketSetOpt (int32_t socket, int32_t opt_id, const void *opt_val, uint32_t opt_len)
1559 \details
1560 The function \b ARM_WIFI_SocketSetOpt sets options for a socket.
1561
1562 The argument \em socket specifies a socket identification number returned from a previous call
1563 to \ref ARM_WIFI_SocketCreate.
1564
1565 The argument \em opt_id is the socket option for which the value is to be set. The following
1566 socket options are supported:
1567 Option | Description
1568 :----------------------------|:-------------------------------------------------
1569 \ref ARM_SOCKET_IO_FIONBIO | Non-blocking mode for the socket
1570 \ref ARM_SOCKET_SO_RCVTIMEO | Timeout for receiving in blocking mode
1571 \ref ARM_SOCKET_SO_SNDTIMEO | Timeout for sending in blocking mode
1572 \ref ARM_SOCKET_SO_KEEPALIVE | Keep-alive mode for the stream socket
1573
1574 The argument \em opt_val points to the buffer containing the value of the \em opt_id.
1575
1576 The argument \em opt_len tells the exact length of the option.
1577
1578 \b Example:
1579 \code
1580 uint32_t nonblocking = 0U; // Blocking mode
1581 uint32_t timeout = 10000U; // Timeout 10 seconds
1582
1583 wifi->SocketSetOpt (sock, ARM_SOCKET_IO_FIONBIO, &nonblocking, sizeof(nonblocking));
1584 wifi->SocketSetOpt (sock, ARM_SOCKET_SO_RCVTIMEO, &timeout, sizeof(timeout));
1585 wifi->SocketSetOpt (sock, ARM_SOCKET_SO_SNDTIMEO, &timeout, sizeof(timeout));
1586 \endcode
1587 */
1588
ARM_WIFI_SocketClose(int32_t socket)1589 int32_t ARM_WIFI_SocketClose (int32_t socket) {
1590 return 0;
1591 }
1592 /**
1593 \fn int32_t ARM_WIFI_SocketClose (int32_t socket)
1594 \details
1595 The function \b ARM_WIFI_SocketClose closes an existing socket and releases the socket descriptor.
1596 Further references to \em socket fail with \c ARM_SOCKET_EINVAL error code.
1597
1598 The argument \em socket specifies a socket identification number returned from a previous call
1599 to \ref ARM_WIFI_SocketCreate.
1600
1601 In blocking mode, which is enabled by default, this function will wait until a socket is closed.
1602 In non blocking mode, you must call the \b ARM_WIFI_SocketClose function again if the error code
1603 \c ARM_SOCKET_EAGAIN is returned.
1604
1605 \b Example:
1606 - see \ref ARM_WIFI_SocketListen
1607 */
1608
ARM_WIFI_SocketGetHostByName(const char * name,int32_t af,uint8_t * ip,uint32_t * ip_len)1609 int32_t ARM_WIFI_SocketGetHostByName (const char *name, int32_t af, uint8_t *ip, uint32_t *ip_len) {
1610 return 0;
1611 }
1612 /**
1613 \fn int32_t ARM_WIFI_SocketGetHostByName (const char *name, int32_t af, uint8_t *ip, uint32_t *ip_len)
1614 \details
1615 The function \b ARM_WIFI_SocketGetHostByName retrieves host information corresponding to
1616 a host name from a host database. It does this by sending DNS requests to the DNS server.
1617 The IP address of the DNS server is specified in the network interface configuration or can be
1618 obtained from the DHCP server for the local area network.
1619
1620 The argument \a name is a pointer to the \token{null}-terminated name of the host to resolve.
1621
1622 The argument \em af specifies the address family, that is, which type of IP address you want
1623 to resolve. The following values are supported:
1624 Family | Description
1625 :----------------------------|:-------------------------------------------------
1626 \ref ARM_SOCKET_AF_INET | Resolve the IPv4 address
1627 \ref ARM_SOCKET_AF_INET6 | Resolve the IPv6 address
1628
1629 The argument \em ip is a pointer to the buffer that will receive the resolved IP address of the host.
1630 If the argument \em ip is \token{NULL}, the function returns error.
1631
1632 The argument \em ip_len is a pointer to the IP address length. It should initially contain the amount of
1633 space pointed to by \em ip. On return it contains the actual length of the address returned in bytes.
1634
1635 \b Example:
1636 \code
1637 extern ARM_DRIVER_WIFI Driver_WiFi0;
1638 static ARM_DRIVER_WIFI *wifi;
1639
1640 void ping_arm_com (void) {
1641 uint8_t ip[4];
1642 uint32_t ip_len;
1643 int32_t res;
1644
1645 wifi = &Driver_WiFi0;
1646 ip_len = sizeof(ip);
1647 res = wifi->SocketGetHostByName ("www.arm.com", ARM_SOCKET_AF_INET, (uint8_t *)ip, &ip_len);
1648 if (res == ARM_DRIVER_OK) {
1649 res = wifi->Ping ((uint8_t *)ip, sizeof(ip));
1650 if (res == ARM_DRIVER_OK) {
1651 // "www.arm.com" responded to ping
1652 }
1653 }
1654 else {
1655 // "www.arm.com" not resolved
1656 }
1657 }
1658 \endcode
1659 */
1660
ARM_WIFI_Ping(const uint8_t * ip,uint32_t ip_len)1661 int32_t ARM_WIFI_Ping (const uint8_t *ip, uint32_t ip_len) {
1662 return ARM_DRIVER_OK;
1663 }
1664 /**
1665 \fn int32_t ARM_WIFI_Ping (const uint8_t *ip, uint32_t ip_len)
1666 \details
1667 The function \b ARM_WIFI_Ping checks if the remote host is reachable. It does this by sending
1668 an echo request and waiting for an echo response. The function then returns the result
1669 of the operation. Check the \ref ARM_WIFI_CAPABILITIES of the driver, if this function
1670 is supported in the driver implementation.
1671
1672 The argument \em ip is a pointer to the buffer containing the IP address octets of the host to ping.
1673
1674 The argument \em ip_len specifies the length of the IP address. The length is \token{4} bytes
1675 for the IPv4 address and \token{16} bytes for the IPv6 address.
1676
1677 \note
1678 The host availability check fails, if the remote host does not respond to echo requests,
1679 or intermediate routers do not forward the echo requests or echo responses.
1680
1681 \b Example:
1682 \code
1683 extern ARM_DRIVER_WIFI Driver_WiFi0;
1684 static ARM_DRIVER_WIFI *wifi;
1685
1686 void ping_host (void) {
1687 uint8_t ip[4] = { 192U, 168U, 0U, 100U };
1688 int32_t res;
1689
1690 wifi = &Driver_WiFi0;
1691 res = wifi->Ping ((uint8_t *)ip, sizeof(ip));
1692 if (res == ARM_DRIVER_OK) {
1693 // Host responded
1694 }
1695 }
1696 \endcode
1697 */
1698 /**
1699 @}
1700 */
1701 // end group wifi_socket_gr
1702
1703
1704 /**
1705 @}
1706 */
1707 // End WiFi Interface
1708