2 * Copyright (c) 2019 Arm Limited. All rights reserved.
4 * SPDX-License-Identifier: Apache-2.0
6 * Licensed under the Apache License, Version 2.0 (the License); you may
7 * not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
14 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * $Date: 13. March 2019
19 * $Revision: V1.0 (beta)
21 * Project: WiFi (Wireless Fidelity Interface) Driver definitions
26 * Initial beta version
29 #ifndef DRIVER_WIFI_H_
30 #define DRIVER_WIFI_H_
37 #include "Driver_Common.h"
39 #define ARM_WIFI_API_VERSION ARM_DRIVER_VERSION_MAJOR_MINOR(1,0) /* API version */
41 #define _ARM_Driver_WiFi_(n) Driver_WiFi##n
42 #define ARM_Driver_WiFi_(n) _ARM_Driver_WiFi_(n)
45 /****** WiFi SetOption/GetOption Function Option Codes *****/
46 #define ARM_WIFI_BSSID 1U ///< Station/AP Set/Get BSSID of AP to connect or of AP; data = &bssid, len = 6, uint8_t[6]
47 #define ARM_WIFI_TX_POWER 2U ///< Station/AP Set/Get transmit power; data = &power, len = 4, uint32_t: 0 .. 20 [dBm]
48 #define ARM_WIFI_LP_TIMER 3U ///< Station Set/Get low-power deep-sleep time; data = &time, len = 4, uint32_t [seconds]: 0 = disable (default)
49 #define ARM_WIFI_DTIM 4U ///< Station/AP Set/Get DTIM interval; data = &dtim, len = 4, uint32_t [beacons]
50 #define ARM_WIFI_BEACON 5U ///< AP Set/Get beacon interval; data = &interval, len = 4, uint32_t [ms]
51 #define ARM_WIFI_MAC 6U ///< Station/AP Set/Get MAC; data = &mac, len = 6, uint8_t[6]
52 #define ARM_WIFI_IP 7U ///< Station/AP Set/Get IPv4 static/assigned address; data = &ip, len = 4, uint8_t[4]
53 #define ARM_WIFI_IP_SUBNET_MASK 8U ///< Station/AP Set/Get IPv4 subnet mask; data = &mask, len = 4, uint8_t[4]
54 #define ARM_WIFI_IP_GATEWAY 9U ///< Station/AP Set/Get IPv4 gateway address; data = &ip, len = 4, uint8_t[4]
55 #define ARM_WIFI_IP_DNS1 10U ///< Station/AP Set/Get IPv4 primary DNS address; data = &ip, len = 4, uint8_t[4]
56 #define ARM_WIFI_IP_DNS2 11U ///< Station/AP Set/Get IPv4 secondary DNS address; data = &ip, len = 4, uint8_t[4]
57 #define ARM_WIFI_IP_DHCP 12U ///< Station/AP Set/Get IPv4 DHCP client/server enable/disable; data = &dhcp, len = 4, uint32_t: 0 = disable, non-zero = enable (default)
58 #define ARM_WIFI_IP_DHCP_POOL_BEGIN 13U ///< AP Set/Get IPv4 DHCP pool begin address; data = &ip, len = 4, uint8_t[4]
59 #define ARM_WIFI_IP_DHCP_POOL_END 14U ///< AP Set/Get IPv4 DHCP pool end address; data = &ip, len = 4, uint8_t[4]
60 #define ARM_WIFI_IP_DHCP_LEASE_TIME 15U ///< AP Set/Get IPv4 DHCP lease time; data = &time, len = 4, uint32_t [seconds]
61 #define ARM_WIFI_IP6_GLOBAL 16U ///< Station/AP Set/Get IPv6 global address; data = &ip6, len = 16, uint8_t[16]
62 #define ARM_WIFI_IP6_LINK_LOCAL 17U ///< Station/AP Set/Get IPv6 link local address; data = &ip6, len = 16, uint8_t[16]
63 #define ARM_WIFI_IP6_SUBNET_PREFIX_LEN 18U ///< Station/AP Set/Get IPv6 subnet prefix length; data = &len, len = 4, uint32_t: 1 .. 127
64 #define ARM_WIFI_IP6_GATEWAY 19U ///< Station/AP Set/Get IPv6 gateway address; data = &ip6, len = 16, uint8_t[16]
65 #define ARM_WIFI_IP6_DNS1 20U ///< Station/AP Set/Get IPv6 primary DNS address; data = &ip6, len = 16, uint8_t[16]
66 #define ARM_WIFI_IP6_DNS2 21U ///< Station/AP Set/Get IPv6 secondary DNS address; data = &ip6, len = 16, uint8_t[16]
67 #define ARM_WIFI_IP6_DHCP_MODE 22U ///< Station/AP Set/Get IPv6 DHCPv6 client mode; data = &mode, len = 4, uint32_t: ARM_WIFI_IP6_DHCP_xxx (default Off)
69 /****** WiFi Operating Mode *****/
70 #define ARM_WIFI_MODE_NONE 0U ///< Inactive (default)
71 #define ARM_WIFI_MODE_STATION 1U ///< Station
72 #define ARM_WIFI_MODE_AP 2U ///< Access Point
73 #define ARM_WIFI_MODE_STATION_AP 3U ///< Station and Access Point
74 #define ARM_WIFI_MODE_AD_HOC 4U ///< Ad-hoc
76 /****** WiFi Security Type *****/
77 #define ARM_WIFI_SECURITY_OPEN 0U ///< Open
78 #define ARM_WIFI_SECURITY_WEP 1U ///< Wired Equivalent Privacy (WEP) with Pre-Sheared Key (PSK)
79 #define ARM_WIFI_SECURITY_WPA 2U ///< WiFi Protected Access (WPA) with PSK
80 #define ARM_WIFI_SECURITY_WPA2 3U ///< WiFi Protected Access II (WPA2) with PSK
81 #define ARM_WIFI_SECURITY_UNKNOWN 255U ///< Unknown
83 /****** WiFi Protected Setup (WPS) Method *****/
84 #define ARM_WIFI_WPS_METHOD_NONE 0U ///< Not used
85 #define ARM_WIFI_WPS_METHOD_PBC 1U ///< Push Button Configuration
86 #define ARM_WIFI_WPS_METHOD_PIN 2U ///< PIN
88 /****** WiFi IPv6 Dynamic Host Configuration Protocol (DHCP) Mode *****/
89 #define ARM_WIFI_IP6_DHCP_OFF 0U ///< Static Host Configuration (default)
90 #define ARM_WIFI_IP6_DHCP_STATELESS 1U ///< Dynamic Host Configuration stateless DHCPv6
91 #define ARM_WIFI_IP6_DHCP_STATEFULL 2U ///< Dynamic Host Configuration statefull DHCPv6
93 /****** WiFi Event *****/
94 #define ARM_WIFI_EVENT_AP_CONNECT (1UL << 0) ///< Access Point: Station has connected; arg = &mac, mac (uint8_t[6])
95 #define ARM_WIFI_EVENT_AP_DISCONNECT (1UL << 1) ///< Access Point: Station has disconnected; arg = &mac, mac (uint8_t[6])
96 #define ARM_WIFI_EVENT_ETH_RX_FRAME (1UL << 4) ///< Ethernet Frame Received (in bypass mode only); arg = interface (0 = Station, 1 = Access Point)
100 \brief WiFi Configuration
103 char ssid[32+1]; ///< Service Set Identifier (SSID) null-terminated string
104 char pass[64+1]; ///< Password null-terminated string
105 uint8_t security; ///< Security type (ARM_WIFI_SECURITY_xxx)
106 uint8_t ch; ///< WiFi Channel (0 = auto, otherwise = exact channel)
107 uint8_t wps_method; ///< WiFi Protected Setup (WPS) method (ARM_WIFI_WPS_METHOD_xxx)
108 char wps_pin[8+1]; ///< WiFi Protected Setup (WPS) PIN null-terminated string
112 \brief WiFi Scan Information
115 char ssid[32+1]; ///< Service Set Identifier (SSID) null-terminated string
116 uint8_t bssid[6]; ///< Basic Service Set Identifier (BSSID)
117 uint8_t security; ///< Security type (ARM_WIFI_SECURITY_xxx)
118 uint8_t ch; ///< WiFi Channel
119 uint8_t rssi; ///< Received Signal Strength Indicator
120 } ARM_WIFI_SCAN_INFO_t;
123 \brief WiFi Network Information
126 char ssid[32+1]; ///< Service Set Identifier (SSID) null-terminated string
127 char pass[64+1]; ///< Password null-terminated string
128 uint8_t security; ///< Security type (ARM_WIFI_SECURITY_xxx)
129 uint8_t ch; ///< WiFi Channel
130 uint8_t rssi; ///< Received Signal Strength Indicator
131 } ARM_WIFI_NET_INFO_t;
133 /****** Socket Address Family definitions *****/
134 #define ARM_SOCKET_AF_INET 1 ///< IPv4
135 #define ARM_SOCKET_AF_INET6 2 ///< IPv6
137 /****** Socket Type definitions *****/
138 #define ARM_SOCKET_SOCK_STREAM 1 ///< Stream socket
139 #define ARM_SOCKET_SOCK_DGRAM 2 ///< Datagram socket
141 /****** Socket Protocol definitions *****/
142 #define ARM_SOCKET_IPPROTO_TCP 1 ///< TCP
143 #define ARM_SOCKET_IPPROTO_UDP 2 ///< UDP
145 /****** Socket Option definitions *****/
146 #define ARM_SOCKET_IO_FIONBIO 1 ///< Non-blocking I/O (Set only, default = 0); opt_val = &nbio, opt_len = sizeof(nbio), nbio (integer): 0=blocking, non-blocking otherwise
147 #define ARM_SOCKET_SO_RCVTIMEO 2 ///< Receive timeout in ms (default = 0); opt_val = &timeout, opt_len = sizeof(timeout)
148 #define ARM_SOCKET_SO_SNDTIMEO 3 ///< Send timeout in ms (default = 0); opt_val = &timeout, opt_len = sizeof(timeout)
149 #define ARM_SOCKET_SO_KEEPALIVE 4 ///< Keep-alive messages (default = 0); opt_val = &keepalive, opt_len = sizeof(keepalive), keepalive (integer): 0=disabled, enabled otherwise
150 #define ARM_SOCKET_SO_TYPE 5 ///< Socket Type (Get only); opt_val = &socket_type, opt_len = sizeof(socket_type), socket_type (integer): ARM_SOCKET_SOCK_xxx
152 /****** Socket Function return codes *****/
153 #define ARM_SOCKET_ERROR (-1) ///< Unspecified error
154 #define ARM_SOCKET_ESOCK (-2) ///< Invalid socket
155 #define ARM_SOCKET_EINVAL (-3) ///< Invalid argument
156 #define ARM_SOCKET_ENOTSUP (-4) ///< Operation not supported
157 #define ARM_SOCKET_ENOMEM (-5) ///< Not enough memory
158 #define ARM_SOCKET_EAGAIN (-6) ///< Operation would block or timed out
159 #define ARM_SOCKET_EINPROGRESS (-7) ///< Operation in progress
160 #define ARM_SOCKET_ETIMEDOUT (-8) ///< Operation timed out
161 #define ARM_SOCKET_EISCONN (-9) ///< Socket is connected
162 #define ARM_SOCKET_ENOTCONN (-10) ///< Socket is not connected
163 #define ARM_SOCKET_ECONNREFUSED (-11) ///< Connection rejected by the peer
164 #define ARM_SOCKET_ECONNRESET (-12) ///< Connection reset by the peer
165 #define ARM_SOCKET_ECONNABORTED (-13) ///< Connection aborted locally
166 #define ARM_SOCKET_EALREADY (-14) ///< Connection already in progress
167 #define ARM_SOCKET_EADDRINUSE (-15) ///< Address in use
168 #define ARM_SOCKET_EHOSTNOTFOUND (-16) ///< Host not found
171 // Function documentation
173 \fn ARM_DRIVER_VERSION ARM_WIFI_GetVersion (void)
174 \brief Get driver version.
175 \return \ref ARM_DRIVER_VERSION
178 \fn ARM_WIFI_CAPABILITIES ARM_WIFI_GetCapabilities (void)
179 \brief Get driver capabilities.
180 \return \ref ARM_WIFI_CAPABILITIES
183 \fn int32_t ARM_WIFI_Initialize (ARM_WIFI_SignalEvent_t cb_event)
184 \brief Initialize WiFi Module.
185 \param[in] cb_event Pointer to \ref ARM_WIFI_SignalEvent_t
186 \return execution status
187 - \ref ARM_DRIVER_OK : Operation successful
188 - \ref ARM_DRIVER_ERROR : Operation failed
191 \fn int32_t ARM_WIFI_Uninitialize (void)
192 \brief De-initialize WiFi Module.
193 \return execution status
194 - \ref ARM_DRIVER_OK : Operation successful
195 - \ref ARM_DRIVER_ERROR : Operation failed
198 \fn int32_t ARM_WIFI_PowerControl (ARM_POWER_STATE state)
199 \brief Control WiFi Module Power.
200 \param[in] state Power state
201 - \ref ARM_POWER_OFF : Power off: no operation possible
202 - \ref ARM_POWER_LOW : Low-power mode: sleep or deep-sleep depending on \ref ARM_WIFI_LP_TIMER option set
203 - \ref ARM_POWER_FULL : Power on: full operation at maximum performance
204 \return execution status
205 - \ref ARM_DRIVER_OK : Operation successful
206 - \ref ARM_DRIVER_ERROR : Operation failed
207 - \ref ARM_DRIVER_ERROR_UNSUPPORTED : Operation not supported
208 - \ref ARM_DRIVER_ERROR_PARAMETER : Parameter error (invalid state)
211 \fn int32_t ARM_WIFI_GetModuleInfo (char *module_info, uint32_t max_len)
212 \brief Get Module information.
213 \param[out] module_info Pointer to character buffer were info string will be returned
214 \param[in] max_len Maximum length of string to return (including null terminator)
215 \return execution status
216 - \ref ARM_DRIVER_OK : Operation successful
217 - \ref ARM_DRIVER_ERROR : Operation failed
218 - \ref ARM_DRIVER_ERROR_UNSUPPORTED : Operation not supported
219 - \ref ARM_DRIVER_ERROR_PARAMETER : Parameter error (NULL module_info pointer or max_len equals to 0)
222 \fn int32_t ARM_WIFI_SetOption (uint32_t interface, uint32_t option, const void *data, uint32_t len)
223 \brief Set WiFi Module Options.
224 \param[in] interface Interface (0 = Station, 1 = Access Point)
225 \param[in] option Option to set
226 \param[in] data Pointer to data relevant to selected option
227 \param[in] len Length of data (in bytes)
228 \return execution status
229 - \ref ARM_DRIVER_OK : Operation successful
230 - \ref ARM_DRIVER_ERROR : Operation failed
231 - \ref ARM_DRIVER_ERROR_UNSUPPORTED : Operation not supported
232 - \ref ARM_DRIVER_ERROR_PARAMETER : Parameter error (invalid interface, NULL data pointer or len less than option specifies)
235 \fn int32_t ARM_WIFI_GetOption (uint32_t interface, uint32_t option, void *data, uint32_t *len)
236 \brief Get WiFi Module Options.
237 \param[in] interface Interface (0 = Station, 1 = Access Point)
238 \param[in] option Option to get
239 \param[out] data Pointer to memory where data for selected option will be returned
240 \param[in,out] len Pointer to length of data (input/output)
241 - input: maximum length of data that can be returned (in bytes)
242 - output: length of returned data (in bytes)
243 \return execution status
244 - \ref ARM_DRIVER_OK : Operation successful
245 - \ref ARM_DRIVER_ERROR : Operation failed
246 - \ref ARM_DRIVER_ERROR_UNSUPPORTED : Operation not supported
247 - \ref ARM_DRIVER_ERROR_PARAMETER : Parameter error (invalid interface, NULL data or len pointer, or *len less than option specifies)
250 \fn int32_t ARM_WIFI_Scan (ARM_WIFI_SCAN_INFO_t scan_info[], uint32_t max_num)
251 \brief Scan for available networks in range.
252 \param[out] scan_info Pointer to array of ARM_WIFI_SCAN_INFO_t structures where available Scan Information will be returned
253 \param[in] max_num Maximum number of Network Information structures to return
254 \return number of ARM_WIFI_SCAN_INFO_t structures returned or error code
255 - value >= 0 : Number of ARM_WIFI_SCAN_INFO_t structures returned
256 - \ref ARM_DRIVER_ERROR : Operation failed
257 - \ref ARM_DRIVER_ERROR_PARAMETER : Parameter error (NULL scan_info pointer or max_num equal to 0)
260 \fn int32_t ARM_WIFI_Configure (uint32_t interface, ARM_WIFI_CONFIG_t *config)
261 \brief Configure Network Parameters.
262 \param[in] interface Interface (0 = Station, 1 = Access Point)
263 \param[in] config Pointer to ARM_WIFI_CONFIG_t structure where Configuration parameters are located
264 \return execution status
265 - \ref ARM_DRIVER_OK : Operation successful
266 - \ref ARM_DRIVER_ERROR : Operation failed
267 - \ref ARM_DRIVER_ERROR_UNSUPPORTED : Operation not supported (security type, WPS or channel autodetect not supported)
268 - \ref ARM_DRIVER_ERROR_PARAMETER : Parameter error (invalid interface, security type or NULL config pointer)
271 \fn int32_t ARM_WIFI_Activate (uint32_t mode)
272 \brief Activate selected mode of operation.
273 \param[in] mode Mode of operation
274 - \ref ARM_WIFI_MODE_STATION : Station only
275 - \ref ARM_WIFI_MODE_AP : Access Point only
276 - \ref ARM_WIFI_MODE_STATION_AP : Station and Access Point
277 - \ref ARM_WIFI_MODE_AD_HOC : Ad-hoc
278 \return execution status
279 - \ref ARM_DRIVER_OK : Operation successful
280 - \ref ARM_DRIVER_ERROR : Operation failed
281 - \ref ARM_DRIVER_ERROR_TIMEOUT : Timeout occurred
282 - \ref ARM_DRIVER_ERROR_UNSUPPORTED : Operation not supported
283 - \ref ARM_DRIVER_ERROR_PARAMETER : Parameter error (invalid mode)
286 \fn int32_t ARM_WIFI_Deactivate (void)
287 \brief Deactivate current mode of operation.
288 \return execution status
289 - \ref ARM_DRIVER_OK : Operation successful
290 - \ref ARM_DRIVER_ERROR : Operation failed
293 \fn uint32_t ARM_WIFI_IsConnected (void)
294 \brief Get station connection status.
295 \return station connection status
296 - value != 0: Station connected
297 - value = 0: Station not connected
300 \fn int32_t ARM_WIFI_GetNetInfo (ARM_WIFI_NET_INFO_t *net_info)
301 \brief Get station Network Information.
302 \param[out] net_info Pointer to ARM_WIFI_NET_INFO_t structure where station Network Information will be returned
303 \return execution status
304 - \ref ARM_DRIVER_OK : Operation successful
305 - \ref ARM_DRIVER_ERROR : Operation failed (station not connected)
306 - \ref ARM_DRIVER_ERROR_UNSUPPORTED : Operation not supported
307 - \ref ARM_DRIVER_ERROR_PARAMETER : Parameter error (invalid interface or NULL net_info pointer)
310 \fn int32_t ARM_WIFI_BypassControl (uint32_t interface, uint32_t mode)
311 \brief Enable or disable bypass (pass-through) mode. Transmit and receive Ethernet frames (IP layer bypassed and WiFi/Ethernet translation).
312 \param[in] interface Interface (0 = Station, 1 = Access Point)
314 - value = 1: all packets bypass internal IP stack
315 - value = 0: all packets processed by internal IP stack
316 \return execution status
317 - \ref ARM_DRIVER_OK : Operation successful
318 - \ref ARM_DRIVER_ERROR : Operation failed
319 - \ref ARM_DRIVER_ERROR_UNSUPPORTED : Operation not supported
320 - \ref ARM_DRIVER_ERROR_PARAMETER : Parameter error (invalid interface or mode)
323 \fn int32_t ARM_WIFI_EthSendFrame (uint32_t interface, const uint8_t *frame, uint32_t len)
324 \brief Send Ethernet frame (in bypass mode only).
325 \param[in] interface Interface (0 = Station, 1 = Access Point)
326 \param[in] frame Pointer to frame buffer with data to send
327 \param[in] len Frame buffer length in bytes
328 \return execution status
329 - \ref ARM_DRIVER_OK : Operation successful
330 - \ref ARM_DRIVER_ERROR : Operation failed
331 - \ref ARM_DRIVER_ERROR_BUSY : Driver is busy
332 - \ref ARM_DRIVER_ERROR_UNSUPPORTED : Operation not supported
333 - \ref ARM_DRIVER_ERROR_PARAMETER : Parameter error (invalid interface or NULL frame pointer)
336 \fn int32_t ARM_WIFI_EthReadFrame (uint32_t interface, uint8_t *frame, uint32_t len)
337 \brief Read data of received Ethernet frame (in bypass mode only).
338 \param[in] interface Interface (0 = Station, 1 = Access Point)
339 \param[in] frame Pointer to frame buffer for data to read into
340 \param[in] len Frame buffer length in bytes
341 \return number of data bytes read or error code
342 - value >= 0 : Number of data bytes read
343 - \ref ARM_DRIVER_ERROR : Operation failed
344 - \ref ARM_DRIVER_ERROR_UNSUPPORTED : Operation not supported
345 - \ref ARM_DRIVER_ERROR_PARAMETER : Parameter error (invalid interface or NULL frame pointer)
348 \fn uint32_t ARM_WIFI_EthGetRxFrameSize (uint32_t interface)
349 \brief Get size of received Ethernet frame (in bypass mode only).
350 \param[in] interface Interface (0 = Station, 1 = Access Point)
351 \return number of bytes in received frame
354 \fn int32_t ARM_WIFI_SocketCreate (int32_t af, int32_t type, int32_t protocol)
355 \brief Create a communication socket.
356 \param[in] af Address family
357 \param[in] type Socket type
358 \param[in] protocol Socket protocol
359 \return status information
360 - Socket identification number (>=0)
361 - \ref ARM_SOCKET_EINVAL : Invalid argument
362 - \ref ARM_SOCKET_ENOTSUP : Operation not supported
363 - \ref ARM_SOCKET_ENOMEM : Not enough memory
364 - \ref ARM_SOCKET_ERROR : Unspecified error
367 \fn int32_t ARM_WIFI_SocketBind (int32_t socket, const uint8_t *ip, uint32_t ip_len, uint16_t port)
368 \brief Assign a local address to a socket.
369 \param[in] socket Socket identification number
370 \param[in] ip Pointer to local IP address
371 \param[in] ip_len Length of 'ip' address in bytes
372 \param[in] port Local port number
373 \return status information
374 - 0 : Operation successful
375 - \ref ARM_SOCKET_ESOCK : Invalid socket
376 - \ref ARM_SOCKET_EINVAL : Invalid argument (address or socket already bound)
377 - \ref ARM_SOCKET_EADDRINUSE : Address already in use
378 - \ref ARM_SOCKET_ERROR : Unspecified error
381 \fn int32_t ARM_WIFI_SocketListen (int32_t socket, int32_t backlog)
382 \brief Listen for socket connections.
383 \param[in] socket Socket identification number
384 \param[in] backlog Number of connection requests that can be queued
385 \return status information
386 - 0 : Operation successful
387 - \ref ARM_SOCKET_ESOCK : Invalid socket
388 - \ref ARM_SOCKET_EINVAL : Invalid argument (socket not bound)
389 - \ref ARM_SOCKET_ENOTSUP : Operation not supported
390 - \ref ARM_SOCKET_EISCONN : Socket is already connected
391 - \ref ARM_SOCKET_ERROR : Unspecified error
394 \fn int32_t ARM_WIFI_SocketAccept (int32_t socket, uint8_t *ip, uint32_t *ip_len, uint16_t *port)
395 \brief Accept a new connection on a socket.
396 \param[in] socket Socket identification number
397 \param[out] ip Pointer to buffer where address of connecting socket shall be returned (NULL for none)
398 \param[in,out] ip_len Pointer to length of 'ip' (or NULL if 'ip' is NULL)
399 - length of supplied 'ip' on input
400 - length of stored 'ip' on output
401 \param[out] port Pointer to buffer where port of connecting socket shall be returned (NULL for none)
402 \return status information
403 - socket identification number of accepted socket (>=0)
404 - \ref ARM_SOCKET_ESOCK : Invalid socket
405 - \ref ARM_SOCKET_EINVAL : Invalid argument (socket not in listen mode)
406 - \ref ARM_SOCKET_ENOTSUP : Operation not supported (socket type does not support accepting connections)
407 - \ref ARM_SOCKET_ECONNRESET : Connection reset by the peer
408 - \ref ARM_SOCKET_ECONNABORTED : Connection aborted locally
409 - \ref ARM_SOCKET_EAGAIN : Operation would block or timed out (may be called again)
410 - \ref ARM_SOCKET_ERROR : Unspecified error
413 \fn int32_t ARM_WIFI_SocketConnect (int32_t socket, const uint8_t *ip, uint32_t ip_len, uint16_t port)
414 \brief Connect a socket to a remote host.
415 \param[in] socket Socket identification number
416 \param[in] ip Pointer to remote IP address
417 \param[in] ip_len Length of 'ip' address in bytes
418 \param[in] port Remote port number
419 \return status information
420 - 0 : Operation successful
421 - \ref ARM_SOCKET_ESOCK : Invalid socket
422 - \ref ARM_SOCKET_EINVAL : Invalid argument
423 - \ref ARM_SOCKET_EALREADY : Connection already in progress
424 - \ref ARM_SOCKET_EINPROGRESS : Operation in progress
425 - \ref ARM_SOCKET_EISCONN : Socket is connected
426 - \ref ARM_SOCKET_ECONNREFUSED : Connection rejected by the peer
427 - \ref ARM_SOCKET_ECONNABORTED : Connection aborted locally
428 - \ref ARM_SOCKET_EADDRINUSE : Address already in use
429 - \ref ARM_SOCKET_ETIMEDOUT : Operation timed out
430 - \ref ARM_SOCKET_ERROR : Unspecified error
433 \fn int32_t ARM_WIFI_SocketRecv (int32_t socket, void *buf, uint32_t len)
434 \brief Receive data on a connected socket.
435 \param[in] socket Socket identification number
436 \param[out] buf Pointer to buffer where data should be stored
437 \param[in] len Length of buffer (in bytes)
438 \return status information
439 - number of bytes received (>0)
440 - \ref ARM_SOCKET_ESOCK : Invalid socket
441 - \ref ARM_SOCKET_EINVAL : Invalid argument (pointer to buffer or length)
442 - \ref ARM_SOCKET_ENOTCONN : Socket is not connected
443 - \ref ARM_SOCKET_ECONNRESET : Connection reset by the peer
444 - \ref ARM_SOCKET_ECONNABORTED : Connection aborted locally
445 - \ref ARM_SOCKET_EAGAIN : Operation would block or timed out (may be called again)
446 - \ref ARM_SOCKET_ERROR : Unspecified error
449 \fn int32_t ARM_WIFI_SocketRecvFrom (int32_t socket, void *buf, uint32_t len, uint8_t *ip, uint32_t *ip_len, uint16_t *port)
450 \brief Receive data on a socket.
451 \param[in] socket Socket identification number
452 \param[out] buf Pointer to buffer where data should be stored
453 \param[in] len Length of buffer (in bytes)
454 \param[out] ip Pointer to buffer where remote source address shall be returned (NULL for none)
455 \param[in,out] ip_len Pointer to length of 'ip' (or NULL if 'ip' is NULL)
456 - length of supplied 'ip' on input
457 - length of stored 'ip' on output
458 \param[out] port Pointer to buffer where remote source port shall be returned (NULL for none)
459 \return status information
460 - number of bytes received (>0)
461 - \ref ARM_SOCKET_ESOCK : Invalid socket
462 - \ref ARM_SOCKET_EINVAL : Invalid argument (pointer to buffer or length)
463 - \ref ARM_SOCKET_ENOTCONN : Socket is not connected
464 - \ref ARM_SOCKET_ECONNRESET : Connection reset by the peer
465 - \ref ARM_SOCKET_ECONNABORTED : Connection aborted locally
466 - \ref ARM_SOCKET_EAGAIN : Operation would block or timed out (may be called again)
467 - \ref ARM_SOCKET_ERROR : Unspecified error
470 \fn int32_t ARM_WIFI_SocketSend (int32_t socket, const void *buf, uint32_t len)
471 \brief Send data on a connected socket.
472 \param[in] socket Socket identification number
473 \param[in] buf Pointer to buffer containing data to send
474 \param[in] len Length of data (in bytes)
475 \return status information
476 - number of bytes sent (>0)
477 - \ref ARM_SOCKET_ESOCK : Invalid socket
478 - \ref ARM_SOCKET_EINVAL : Invalid argument (pointer to buffer or length)
479 - \ref ARM_SOCKET_ENOTCONN : Socket is not connected
480 - \ref ARM_SOCKET_ECONNRESET : Connection reset by the peer
481 - \ref ARM_SOCKET_ECONNABORTED : Connection aborted locally
482 - \ref ARM_SOCKET_EAGAIN : Operation would block or timed out (may be called again)
483 - \ref ARM_SOCKET_ERROR : Unspecified error
486 \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)
487 \brief Send data on a socket.
488 \param[in] socket Socket identification number
489 \param[in] buf Pointer to buffer containing data to send
490 \param[in] len Length of data (in bytes)
491 \param[in] ip Pointer to remote destination IP address
492 \param[in] ip_len Length of 'ip' address in bytes
493 \param[in] port Remote destination port number
494 \return status information
495 - number of bytes sent (>0)
496 - \ref ARM_SOCKET_ESOCK : Invalid socket
497 - \ref ARM_SOCKET_EINVAL : Invalid argument (pointer to buffer or length)
498 - \ref ARM_SOCKET_ENOTCONN : Socket is not connected
499 - \ref ARM_SOCKET_ECONNRESET : Connection reset by the peer
500 - \ref ARM_SOCKET_ECONNABORTED : Connection aborted locally
501 - \ref ARM_SOCKET_EAGAIN : Operation would block or timed out (may be called again)
502 - \ref ARM_SOCKET_ERROR : Unspecified error
505 \fn int32_t ARM_WIFI_SocketGetSockName (int32_t socket, uint8_t *ip, uint32_t *ip_len, uint16_t *port)
506 \brief Retrieve local IP address and port of a socket.
507 \param[in] socket Socket identification number
508 \param[out] ip Pointer to buffer where local address shall be returned (NULL for none)
509 \param[in,out] ip_len Pointer to length of 'ip' (or NULL if 'ip' is NULL)
510 - length of supplied 'ip' on input
511 - length of stored 'ip' on output
512 \param[out] port Pointer to buffer where local port shall be returned (NULL for none)
513 \return status information
514 - 0 : Operation successful
515 - \ref ARM_SOCKET_ESOCK : Invalid socket
516 - \ref ARM_SOCKET_EINVAL : Invalid argument (pointer to buffer or length)
517 - \ref ARM_SOCKET_ERROR : Unspecified error
520 \fn int32_t ARM_WIFI_SocketGetPeerName (int32_t socket, uint8_t *ip, uint32_t *ip_len, uint16_t *port)
521 \brief Retrieve remote IP address and port of a socket
522 \param[in] socket Socket identification number
523 \param[out] ip Pointer to buffer where remote address shall be returned (NULL for none)
524 \param[in,out] ip_len Pointer to length of 'ip' (or NULL if 'ip' is NULL)
525 - length of supplied 'ip' on input
526 - length of stored 'ip' on output
527 \param[out] port Pointer to buffer where remote port shall be returned (NULL for none)
528 \return status information
529 - 0 : Operation successful
530 - \ref ARM_SOCKET_ESOCK : Invalid socket
531 - \ref ARM_SOCKET_EINVAL : Invalid argument (pointer to buffer or length)
532 - \ref ARM_SOCKET_ENOTCONN : Socket is not connected
533 - \ref ARM_SOCKET_ERROR : Unspecified error
536 \fn int32_t ARM_WIFI_SocketGetOpt (int32_t socket, int32_t opt_id, void *opt_val, uint32_t *opt_len)
537 \brief Get socket option.
538 \param[in] socket Socket identification number
539 \param[in] opt_id Option identifier
540 \param[out] opt_val Pointer to the buffer that will receive the option value
541 \param[in,out] opt_len Pointer to length of the option value
542 - length of buffer on input
543 - length of data on output
544 \return status information
545 - 0 : Operation successful
546 - \ref ARM_SOCKET_ESOCK : Invalid socket
547 - \ref ARM_SOCKET_EINVAL : Invalid argument
548 - \ref ARM_SOCKET_ENOTSUP : Operation not supported
549 - \ref ARM_SOCKET_ERROR : Unspecified error
552 \fn int32_t ARM_WIFI_SocketSetOpt (int32_t socket, int32_t opt_id, const void *opt_val, uint32_t opt_len)
553 \brief Set socket option.
554 \param[in] socket Socket identification number
555 \param[in] opt_id Option identifier
556 \param[in] opt_val Pointer to the option value
557 \param[in] opt_len Length of the option value in bytes
558 \return status information
559 - 0 : Operation successful
560 - \ref ARM_SOCKET_ESOCK : Invalid socket
561 - \ref ARM_SOCKET_EINVAL : Invalid argument
562 - \ref ARM_SOCKET_ENOTSUP : Operation not supported
563 - \ref ARM_SOCKET_ERROR : Unspecified error
566 \fn int32_t ARM_WIFI_SocketClose (int32_t socket)
567 \brief Close and release a socket.
568 \param[in] socket Socket identification number
569 \return status information
570 - 0 : Operation successful
571 - \ref ARM_SOCKET_ESOCK : Invalid socket
572 - \ref ARM_SOCKET_EAGAIN : Operation would block (may be called again)
573 - \ref ARM_SOCKET_ERROR : Unspecified error
576 \fn int32_t ARM_WIFI_SocketGetHostByName (const char *name, int32_t af, uint8_t *ip, uint32_t *ip_len)
577 \brief Retrieve host IP address from host name.
578 \param[in] name Host name
579 \param[in] af Address family
580 \param[out] ip Pointer to buffer where resolved IP address shall be returned
581 \param[in,out] ip_len Pointer to length of 'ip'
582 - length of supplied 'ip' on input
583 - length of stored 'ip' on output
584 \return status information
585 - 0 : Operation successful
586 - \ref ARM_SOCKET_EINVAL : Invalid argument
587 - \ref ARM_SOCKET_ENOTSUP : Operation not supported
588 - \ref ARM_SOCKET_ETIMEDOUT : Operation timed out
589 - \ref ARM_SOCKET_EHOSTNOTFOUND : Host not found
590 - \ref ARM_SOCKET_ERROR : Unspecified error
593 \fn int32_t ARM_WIFI_Ping (const uint8_t *ip, uint32_t ip_len)
594 \brief Probe remote host with Ping command.
595 \param[in] ip Pointer to remote host IP address
596 \param[in] ip_len Length of 'ip' address in bytes
597 \return execution status
598 - \ref ARM_DRIVER_OK : Operation successful
599 - \ref ARM_DRIVER_ERROR : Operation failed
600 - \ref ARM_DRIVER_ERROR_TIMEOUT : Timeout occurred
601 - \ref ARM_DRIVER_ERROR_UNSUPPORTED : Operation not supported
602 - \ref ARM_DRIVER_ERROR_PARAMETER : Parameter error (NULL ip pointer or ip_len different than 4 or 16)
605 \fn void ARM_WIFI_SignalEvent (uint32_t event, void *arg)
606 \brief Signal WiFi Events.
607 \param[in] event \ref wifi_event notification mask
608 \param[in] arg Pointer to argument of signaled event
612 typedef void (*ARM_WIFI_SignalEvent_t) (uint32_t event, void *arg); ///< Pointer to \ref ARM_WIFI_SignalEvent : Signal WiFi Event.
616 \brief WiFi Driver Capabilities.
619 uint32_t mode_station : 1; ///< Mode: Station
620 uint32_t mode_ap : 1; ///< Mode: Access Point
621 uint32_t mode_station_ap : 1; ///< Mode: Station and Access Point
622 uint32_t mode_ad_hoc : 1; ///< Mode: Ad-hoc
623 uint32_t wps_station : 1; ///< WiFi Protected Setup (WPS) for Station
624 uint32_t wps_ap : 1; ///< WiFi Protected Setup (WPS) for Access Point
625 uint32_t event_ap_connect : 1; ///< Access Point: event generated on Station connect
626 uint32_t event_ap_disconnect : 1; ///< Access Point: event generated on Station disconnect
627 uint32_t bypass_mode : 1; ///< Bypass or pass-through mode (Ethernet interface)
628 uint32_t event_eth_rx_frame : 1; ///< Event generated on Ethernet frame reception in bypass mode
629 uint32_t ip : 1; ///< IP (UDP/TCP) (Socket interface)
630 uint32_t ip6 : 1; ///< IPv6 (Socket interface)
631 uint32_t ping : 1; ///< Ping (ICMP)
632 uint32_t reserved : 19; ///< Reserved (must be zero)
633 } ARM_WIFI_CAPABILITIES;
636 \brief Access structure of the WiFi Driver.
639 ARM_DRIVER_VERSION (*GetVersion) (void);
640 ARM_WIFI_CAPABILITIES (*GetCapabilities) (void);
641 int32_t (*Initialize) (ARM_WIFI_SignalEvent_t cb_event);
642 int32_t (*Uninitialize) (void);
643 int32_t (*PowerControl) (ARM_POWER_STATE state);
644 int32_t (*GetModuleInfo) (char *module_info, uint32_t max_len);
645 int32_t (*SetOption) (uint32_t interface, uint32_t option, const void *data, uint32_t len);
646 int32_t (*GetOption) (uint32_t interface, uint32_t option, void *data, uint32_t *len);
647 int32_t (*Scan) (ARM_WIFI_SCAN_INFO_t scan_info[], uint32_t max_num);
648 int32_t (*Configure) (uint32_t interface, ARM_WIFI_CONFIG_t *config);
649 int32_t (*Activate) (uint32_t mode);
650 int32_t (*Deactivate) (void);
651 uint32_t (*IsConnected) (void);
652 int32_t (*GetNetInfo) (ARM_WIFI_NET_INFO_t *net_info);
653 int32_t (*BypassControl) (uint32_t interface, uint32_t mode);
654 int32_t (*EthSendFrame) (uint32_t interface, const uint8_t *frame, uint32_t len);
655 int32_t (*EthReadFrame) (uint32_t interface, uint8_t *frame, uint32_t len);
656 uint32_t (*EthGetRxFrameSize) (uint32_t interface);
657 int32_t (*SocketCreate) (int32_t af, int32_t type, int32_t protocol);
658 int32_t (*SocketBind) (int32_t socket, const uint8_t *ip, uint32_t ip_len, uint16_t port);
659 int32_t (*SocketListen) (int32_t socket, int32_t backlog);
660 int32_t (*SocketAccept) (int32_t socket, uint8_t *ip, uint32_t *ip_len, uint16_t *port);
661 int32_t (*SocketConnect) (int32_t socket, const uint8_t *ip, uint32_t ip_len, uint16_t port);
662 int32_t (*SocketRecv) (int32_t socket, void *buf, uint32_t len);
663 int32_t (*SocketRecvFrom) (int32_t socket, void *buf, uint32_t len, uint8_t *ip, uint32_t *ip_len, uint16_t *port);
664 int32_t (*SocketSend) (int32_t socket, const void *buf, uint32_t len);
665 int32_t (*SocketSendTo) (int32_t socket, const void *buf, uint32_t len, const uint8_t *ip, uint32_t ip_len, uint16_t port);
666 int32_t (*SocketGetSockName) (int32_t socket, uint8_t *ip, uint32_t *ip_len, uint16_t *port);
667 int32_t (*SocketGetPeerName) (int32_t socket, uint8_t *ip, uint32_t *ip_len, uint16_t *port);
668 int32_t (*SocketGetOpt) (int32_t socket, int32_t opt_id, void *opt_val, uint32_t *opt_len);
669 int32_t (*SocketSetOpt) (int32_t socket, int32_t opt_id, const void *opt_val, uint32_t opt_len);
670 int32_t (*SocketClose) (int32_t socket);
671 int32_t (*SocketGetHostByName) (const char *name, int32_t af, uint8_t *ip, uint32_t *ip_len);
672 int32_t (*Ping) (const uint8_t *ip, uint32_t ip_len);
673 } const ARM_DRIVER_WIFI;
679 #endif /* DRIVER_WIFI_H_ */