wifi test
Dependencies: X_NUCLEO_IKS01A2 mbed-http
easy-connect/wizfi310-driver/WizFi310Interface.h@0:24d3eb812fd4, 2018-09-05 (annotated)
- Committer:
- JMF
- Date:
- Wed Sep 05 14:28:24 2018 +0000
- Revision:
- 0:24d3eb812fd4
Initial commit
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| JMF | 0:24d3eb812fd4 | 1 | /* WizFi310 implementation of NetworkInterfaceAPI |
| JMF | 0:24d3eb812fd4 | 2 | * Copyright (c) 2015 ARM Limited |
| JMF | 0:24d3eb812fd4 | 3 | * |
| JMF | 0:24d3eb812fd4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| JMF | 0:24d3eb812fd4 | 5 | * you may not use this file except in compliance with the License. |
| JMF | 0:24d3eb812fd4 | 6 | * You may obtain a copy of the License at |
| JMF | 0:24d3eb812fd4 | 7 | * |
| JMF | 0:24d3eb812fd4 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| JMF | 0:24d3eb812fd4 | 9 | * |
| JMF | 0:24d3eb812fd4 | 10 | * Unless required by applicable law or agreed to in writing, software |
| JMF | 0:24d3eb812fd4 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| JMF | 0:24d3eb812fd4 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| JMF | 0:24d3eb812fd4 | 13 | * See the License for the specific language governing permissions and |
| JMF | 0:24d3eb812fd4 | 14 | * limitations under the License. |
| JMF | 0:24d3eb812fd4 | 15 | */ |
| JMF | 0:24d3eb812fd4 | 16 | |
| JMF | 0:24d3eb812fd4 | 17 | /** |
| JMF | 0:24d3eb812fd4 | 18 | ****************************************************************************** |
| JMF | 0:24d3eb812fd4 | 19 | * @file WizFi310Interface.h |
| JMF | 0:24d3eb812fd4 | 20 | * @author Gateway Team |
| JMF | 0:24d3eb812fd4 | 21 | * @brief Header file of the NetworkStack for the WizFi310 WiFi Device |
| JMF | 0:24d3eb812fd4 | 22 | ****************************************************************************** |
| JMF | 0:24d3eb812fd4 | 23 | * @attention |
| JMF | 0:24d3eb812fd4 | 24 | * |
| JMF | 0:24d3eb812fd4 | 25 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS |
| JMF | 0:24d3eb812fd4 | 26 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE |
| JMF | 0:24d3eb812fd4 | 27 | * TIME. AS A RESULT, WIZnet SHALL NOT BE HELD LIABLE FOR ANY |
| JMF | 0:24d3eb812fd4 | 28 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING |
| JMF | 0:24d3eb812fd4 | 29 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE |
| JMF | 0:24d3eb812fd4 | 30 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. |
| JMF | 0:24d3eb812fd4 | 31 | * |
| JMF | 0:24d3eb812fd4 | 32 | * <h2><center>© COPYRIGHT 2017 WIZnet Co.,Ltd.</center></h2> |
| JMF | 0:24d3eb812fd4 | 33 | ****************************************************************************** |
| JMF | 0:24d3eb812fd4 | 34 | */ |
| JMF | 0:24d3eb812fd4 | 35 | |
| JMF | 0:24d3eb812fd4 | 36 | #ifndef WIZFI310_INTERFACE_H |
| JMF | 0:24d3eb812fd4 | 37 | #define WIZFI310_INTERFACE_H |
| JMF | 0:24d3eb812fd4 | 38 | |
| JMF | 0:24d3eb812fd4 | 39 | #include "NetworkStack.h" |
| JMF | 0:24d3eb812fd4 | 40 | #include "WiFiInterface.h" |
| JMF | 0:24d3eb812fd4 | 41 | #include "WizFi310.h" |
| JMF | 0:24d3eb812fd4 | 42 | |
| JMF | 0:24d3eb812fd4 | 43 | #define WIZFI310_SOCKET_COUNT 8 |
| JMF | 0:24d3eb812fd4 | 44 | |
| JMF | 0:24d3eb812fd4 | 45 | /** WizFi310Interface class |
| JMF | 0:24d3eb812fd4 | 46 | * Implementation of the NetworkStack for the WizFi310 |
| JMF | 0:24d3eb812fd4 | 47 | */ |
| JMF | 0:24d3eb812fd4 | 48 | class WizFi310Interface : public NetworkStack, public WiFiInterface |
| JMF | 0:24d3eb812fd4 | 49 | { |
| JMF | 0:24d3eb812fd4 | 50 | public: |
| JMF | 0:24d3eb812fd4 | 51 | /* WizFi310Interface constructor |
| JMF | 0:24d3eb812fd4 | 52 | */ |
| JMF | 0:24d3eb812fd4 | 53 | |
| JMF | 0:24d3eb812fd4 | 54 | WizFi310Interface(PinName tx = MBED_CONF_WIZFI310_TX, |
| JMF | 0:24d3eb812fd4 | 55 | PinName rx = MBED_CONF_WIZFI310_RX, |
| JMF | 0:24d3eb812fd4 | 56 | bool debug = MBED_CONF_WIZFI310_DEBUG); |
| JMF | 0:24d3eb812fd4 | 57 | |
| JMF | 0:24d3eb812fd4 | 58 | /** Start the interface |
| JMF | 0:24d3eb812fd4 | 59 | * |
| JMF | 0:24d3eb812fd4 | 60 | * Attempts to connect to a WiFi network. Requires ssid and passphrase to be set. |
| JMF | 0:24d3eb812fd4 | 61 | * If passphrase is invalid, NSAPI_ERROR_AUTH_ERROR is returned. |
| JMF | 0:24d3eb812fd4 | 62 | * |
| JMF | 0:24d3eb812fd4 | 63 | * @return 0 on success, negative error code on failure |
| JMF | 0:24d3eb812fd4 | 64 | */ |
| JMF | 0:24d3eb812fd4 | 65 | virtual int connect(); |
| JMF | 0:24d3eb812fd4 | 66 | |
| JMF | 0:24d3eb812fd4 | 67 | /** Start the interface |
| JMF | 0:24d3eb812fd4 | 68 | * |
| JMF | 0:24d3eb812fd4 | 69 | * Attempts to connect to a WiFi network. |
| JMF | 0:24d3eb812fd4 | 70 | * |
| JMF | 0:24d3eb812fd4 | 71 | * @param ssid Name of the network to connect to |
| JMF | 0:24d3eb812fd4 | 72 | * @param pass Security passphrase to connect to the network |
| JMF | 0:24d3eb812fd4 | 73 | * @param security Type of encryption for connection (Default: NSAPI_SECURITY_NONE) |
| JMF | 0:24d3eb812fd4 | 74 | * @param channel This parameter is not supported, setting it to anything else than 0 will result in NSAPI_ERROR_UNSUPPORTED |
| JMF | 0:24d3eb812fd4 | 75 | * @return 0 on success, or error code on failure |
| JMF | 0:24d3eb812fd4 | 76 | */ |
| JMF | 0:24d3eb812fd4 | 77 | virtual int connect(const char *ssid, const char *pass, nsapi_security_t security = NSAPI_SECURITY_NONE, |
| JMF | 0:24d3eb812fd4 | 78 | uint8_t channel = 0); |
| JMF | 0:24d3eb812fd4 | 79 | |
| JMF | 0:24d3eb812fd4 | 80 | /** Set the WiFi network credentials |
| JMF | 0:24d3eb812fd4 | 81 | * |
| JMF | 0:24d3eb812fd4 | 82 | * @param ssid Name of the network to connect to |
| JMF | 0:24d3eb812fd4 | 83 | * @param pass Security passphrase to connect to the network |
| JMF | 0:24d3eb812fd4 | 84 | * @param security Type of encryption for connection |
| JMF | 0:24d3eb812fd4 | 85 | * (defaults to NSAPI_SECURITY_NONE) |
| JMF | 0:24d3eb812fd4 | 86 | * @return 0 on success, or error code on failure |
| JMF | 0:24d3eb812fd4 | 87 | */ |
| JMF | 0:24d3eb812fd4 | 88 | virtual int set_credentials(const char *ssid, const char *pass, nsapi_security_t security = NSAPI_SECURITY_NONE); |
| JMF | 0:24d3eb812fd4 | 89 | |
| JMF | 0:24d3eb812fd4 | 90 | /** Set the WiFi network channel - NOT SUPPORTED |
| JMF | 0:24d3eb812fd4 | 91 | * |
| JMF | 0:24d3eb812fd4 | 92 | * This function is not supported and will return NSAPI_ERROR_UNSUPPORTED |
| JMF | 0:24d3eb812fd4 | 93 | * |
| JMF | 0:24d3eb812fd4 | 94 | * @param channel Channel on which the connection is to be made, or 0 for any (Default: 0) |
| JMF | 0:24d3eb812fd4 | 95 | * @return Not supported, returns NSAPI_ERROR_UNSUPPORTED |
| JMF | 0:24d3eb812fd4 | 96 | */ |
| JMF | 0:24d3eb812fd4 | 97 | virtual int set_channel(uint8_t channel); |
| JMF | 0:24d3eb812fd4 | 98 | |
| JMF | 0:24d3eb812fd4 | 99 | /** Stop the interface |
| JMF | 0:24d3eb812fd4 | 100 | * @return 0 on success, negative on failure |
| JMF | 0:24d3eb812fd4 | 101 | */ |
| JMF | 0:24d3eb812fd4 | 102 | virtual int disconnect(); |
| JMF | 0:24d3eb812fd4 | 103 | |
| JMF | 0:24d3eb812fd4 | 104 | /** Get the internally stored IP address |
| JMF | 0:24d3eb812fd4 | 105 | * @return IP address of the interface or null if not yet connected |
| JMF | 0:24d3eb812fd4 | 106 | */ |
| JMF | 0:24d3eb812fd4 | 107 | virtual const char *get_ip_address(); |
| JMF | 0:24d3eb812fd4 | 108 | |
| JMF | 0:24d3eb812fd4 | 109 | /** Get the internally stored MAC address |
| JMF | 0:24d3eb812fd4 | 110 | * @return MAC address of the interface |
| JMF | 0:24d3eb812fd4 | 111 | */ |
| JMF | 0:24d3eb812fd4 | 112 | virtual const char *get_mac_address(); |
| JMF | 0:24d3eb812fd4 | 113 | |
| JMF | 0:24d3eb812fd4 | 114 | /** Get the local gateway |
| JMF | 0:24d3eb812fd4 | 115 | * |
| JMF | 0:24d3eb812fd4 | 116 | * @return Null-terminated representation of the local gateway |
| JMF | 0:24d3eb812fd4 | 117 | * or null if no network mask has been recieved |
| JMF | 0:24d3eb812fd4 | 118 | */ |
| JMF | 0:24d3eb812fd4 | 119 | virtual const char *get_gateway(); |
| JMF | 0:24d3eb812fd4 | 120 | |
| JMF | 0:24d3eb812fd4 | 121 | /** Get the local network mask |
| JMF | 0:24d3eb812fd4 | 122 | * |
| JMF | 0:24d3eb812fd4 | 123 | * @return Null-terminated representation of the local network mask |
| JMF | 0:24d3eb812fd4 | 124 | * or null if no network mask has been recieved |
| JMF | 0:24d3eb812fd4 | 125 | */ |
| JMF | 0:24d3eb812fd4 | 126 | virtual const char *get_netmask(); |
| JMF | 0:24d3eb812fd4 | 127 | |
| JMF | 0:24d3eb812fd4 | 128 | /** Gets the current radio signal strength for active connection |
| JMF | 0:24d3eb812fd4 | 129 | * |
| JMF | 0:24d3eb812fd4 | 130 | * @return Connection strength in dBm (negative value) |
| JMF | 0:24d3eb812fd4 | 131 | */ |
| JMF | 0:24d3eb812fd4 | 132 | virtual int8_t get_rssi(); |
| JMF | 0:24d3eb812fd4 | 133 | |
| JMF | 0:24d3eb812fd4 | 134 | /** Scan for available networks |
| JMF | 0:24d3eb812fd4 | 135 | * |
| JMF | 0:24d3eb812fd4 | 136 | * This function will block. |
| JMF | 0:24d3eb812fd4 | 137 | * |
| JMF | 0:24d3eb812fd4 | 138 | * @param ap Pointer to allocated array to store discovered AP |
| JMF | 0:24d3eb812fd4 | 139 | * @param count Size of allocated @a res array, or 0 to only count available AP |
| JMF | 0:24d3eb812fd4 | 140 | * @return Number of entries in @a, or if @a count was 0 number of available networks, negative on error |
| JMF | 0:24d3eb812fd4 | 141 | * see @a nsapi_error |
| JMF | 0:24d3eb812fd4 | 142 | */ |
| JMF | 0:24d3eb812fd4 | 143 | virtual int scan(WiFiAccessPoint *res, unsigned count); |
| JMF | 0:24d3eb812fd4 | 144 | |
| JMF | 0:24d3eb812fd4 | 145 | /** Translates a hostname to an IP address with specific version |
| JMF | 0:24d3eb812fd4 | 146 | * |
| JMF | 0:24d3eb812fd4 | 147 | * The hostname may be either a domain name or an IP address. If the |
| JMF | 0:24d3eb812fd4 | 148 | * hostname is an IP address, no network transactions will be performed. |
| JMF | 0:24d3eb812fd4 | 149 | * |
| JMF | 0:24d3eb812fd4 | 150 | * If no stack-specific DNS resolution is provided, the hostname |
| JMF | 0:24d3eb812fd4 | 151 | * will be resolve using a UDP socket on the stack. |
| JMF | 0:24d3eb812fd4 | 152 | * |
| JMF | 0:24d3eb812fd4 | 153 | * @param address Destination for the host SocketAddress |
| JMF | 0:24d3eb812fd4 | 154 | * @param host Hostname to resolve |
| JMF | 0:24d3eb812fd4 | 155 | * @param version IP version of address to resolve, NSAPI_UNSPEC indicates |
| JMF | 0:24d3eb812fd4 | 156 | * version is chosen by the stack (defaults to NSAPI_UNSPEC) |
| JMF | 0:24d3eb812fd4 | 157 | * @return 0 on success, negative error code on failure |
| JMF | 0:24d3eb812fd4 | 158 | */ |
| JMF | 0:24d3eb812fd4 | 159 | //using NetworkInterface::gethostbyname; |
| JMF | 0:24d3eb812fd4 | 160 | virtual nsapi_error_t gethostbyname(const char *host, |
| JMF | 0:24d3eb812fd4 | 161 | SocketAddress *address, nsapi_version_t version = NSAPI_UNSPEC); |
| JMF | 0:24d3eb812fd4 | 162 | |
| JMF | 0:24d3eb812fd4 | 163 | /** Add a domain name server to list of servers to query |
| JMF | 0:24d3eb812fd4 | 164 | * |
| JMF | 0:24d3eb812fd4 | 165 | * @param addr Destination for the host address |
| JMF | 0:24d3eb812fd4 | 166 | * @return 0 on success, negative error code on failure |
| JMF | 0:24d3eb812fd4 | 167 | */ |
| JMF | 0:24d3eb812fd4 | 168 | using NetworkInterface::add_dns_server; |
| JMF | 0:24d3eb812fd4 | 169 | |
| JMF | 0:24d3eb812fd4 | 170 | protected: |
| JMF | 0:24d3eb812fd4 | 171 | /** Open a socket |
| JMF | 0:24d3eb812fd4 | 172 | * @param handle Handle in which to store new socket |
| JMF | 0:24d3eb812fd4 | 173 | * @param proto Type of socket to open, NSAPI_TCP or NSAPI_UDP |
| JMF | 0:24d3eb812fd4 | 174 | * @return 0 on success, negative on failure |
| JMF | 0:24d3eb812fd4 | 175 | */ |
| JMF | 0:24d3eb812fd4 | 176 | virtual int socket_open(void **handle, nsapi_protocol_t proto); |
| JMF | 0:24d3eb812fd4 | 177 | |
| JMF | 0:24d3eb812fd4 | 178 | /** Close the socket |
| JMF | 0:24d3eb812fd4 | 179 | * @param handle Socket handle |
| JMF | 0:24d3eb812fd4 | 180 | * @return 0 on success, negative on failure |
| JMF | 0:24d3eb812fd4 | 181 | * @note On failure, any memory associated with the socket must still |
| JMF | 0:24d3eb812fd4 | 182 | * be cleaned up |
| JMF | 0:24d3eb812fd4 | 183 | */ |
| JMF | 0:24d3eb812fd4 | 184 | virtual int socket_close(void *handle); |
| JMF | 0:24d3eb812fd4 | 185 | |
| JMF | 0:24d3eb812fd4 | 186 | /** Bind a server socket to a specific port |
| JMF | 0:24d3eb812fd4 | 187 | * @param handle Socket handle |
| JMF | 0:24d3eb812fd4 | 188 | * @param address Local address to listen for incoming connections on |
| JMF | 0:24d3eb812fd4 | 189 | * @return 0 on success, negative on failure. |
| JMF | 0:24d3eb812fd4 | 190 | */ |
| JMF | 0:24d3eb812fd4 | 191 | virtual int socket_bind(void *handle, const SocketAddress &address); |
| JMF | 0:24d3eb812fd4 | 192 | |
| JMF | 0:24d3eb812fd4 | 193 | /** Start listening for incoming connections |
| JMF | 0:24d3eb812fd4 | 194 | * @param handle Socket handle |
| JMF | 0:24d3eb812fd4 | 195 | * @param backlog Number of pending connections that can be queued up at any |
| JMF | 0:24d3eb812fd4 | 196 | * one time [Default: 1] |
| JMF | 0:24d3eb812fd4 | 197 | * @return 0 on success, negative on failure |
| JMF | 0:24d3eb812fd4 | 198 | */ |
| JMF | 0:24d3eb812fd4 | 199 | virtual int socket_listen(void *handle, int backlog); |
| JMF | 0:24d3eb812fd4 | 200 | |
| JMF | 0:24d3eb812fd4 | 201 | /** Connects this TCP socket to the server |
| JMF | 0:24d3eb812fd4 | 202 | * @param handle Socket handle |
| JMF | 0:24d3eb812fd4 | 203 | * @param address SocketAddress to connect to |
| JMF | 0:24d3eb812fd4 | 204 | * @return 0 on success, negative on failure |
| JMF | 0:24d3eb812fd4 | 205 | */ |
| JMF | 0:24d3eb812fd4 | 206 | virtual int socket_connect(void *handle, const SocketAddress &address); |
| JMF | 0:24d3eb812fd4 | 207 | |
| JMF | 0:24d3eb812fd4 | 208 | /** Accept a new connection. |
| JMF | 0:24d3eb812fd4 | 209 | * @param handle Handle in which to store new socket |
| JMF | 0:24d3eb812fd4 | 210 | * @param server Socket handle to server to accept from |
| JMF | 0:24d3eb812fd4 | 211 | * @return 0 on success, negative on failure |
| JMF | 0:24d3eb812fd4 | 212 | * @note This call is not-blocking, if this call would block, must |
| JMF | 0:24d3eb812fd4 | 213 | * immediately return NSAPI_ERROR_WOULD_WAIT |
| JMF | 0:24d3eb812fd4 | 214 | */ |
| JMF | 0:24d3eb812fd4 | 215 | virtual int socket_accept(void *handle, void **socket, SocketAddress *address); |
| JMF | 0:24d3eb812fd4 | 216 | |
| JMF | 0:24d3eb812fd4 | 217 | /** Send data to the remote host |
| JMF | 0:24d3eb812fd4 | 218 | * @param handle Socket handle |
| JMF | 0:24d3eb812fd4 | 219 | * @param data The buffer to send to the host |
| JMF | 0:24d3eb812fd4 | 220 | * @param size The length of the buffer to send |
| JMF | 0:24d3eb812fd4 | 221 | * @return Number of written bytes on success, negative on failure |
| JMF | 0:24d3eb812fd4 | 222 | * @note This call is not-blocking, if this call would block, must |
| JMF | 0:24d3eb812fd4 | 223 | * immediately return NSAPI_ERROR_WOULD_WAIT |
| JMF | 0:24d3eb812fd4 | 224 | */ |
| JMF | 0:24d3eb812fd4 | 225 | virtual int socket_send(void *handle, const void *data, unsigned size); |
| JMF | 0:24d3eb812fd4 | 226 | |
| JMF | 0:24d3eb812fd4 | 227 | /** Receive data from the remote host |
| JMF | 0:24d3eb812fd4 | 228 | * @param handle Socket handle |
| JMF | 0:24d3eb812fd4 | 229 | * @param data The buffer in which to store the data received from the host |
| JMF | 0:24d3eb812fd4 | 230 | * @param size The maximum length of the buffer |
| JMF | 0:24d3eb812fd4 | 231 | * @return Number of received bytes on success, negative on failure |
| JMF | 0:24d3eb812fd4 | 232 | * @note This call is not-blocking, if this call would block, must |
| JMF | 0:24d3eb812fd4 | 233 | * immediately return NSAPI_ERROR_WOULD_WAIT |
| JMF | 0:24d3eb812fd4 | 234 | */ |
| JMF | 0:24d3eb812fd4 | 235 | virtual int socket_recv(void *handle, void *data, unsigned size); |
| JMF | 0:24d3eb812fd4 | 236 | |
| JMF | 0:24d3eb812fd4 | 237 | /** Send a packet to a remote endpoint |
| JMF | 0:24d3eb812fd4 | 238 | * @param handle Socket handle |
| JMF | 0:24d3eb812fd4 | 239 | * @param address The remote SocketAddress |
| JMF | 0:24d3eb812fd4 | 240 | * @param data The packet to be sent |
| JMF | 0:24d3eb812fd4 | 241 | * @param size The length of the packet to be sent |
| JMF | 0:24d3eb812fd4 | 242 | * @return The number of written bytes on success, negative on failure |
| JMF | 0:24d3eb812fd4 | 243 | * @note This call is not-blocking, if this call would block, must |
| JMF | 0:24d3eb812fd4 | 244 | * immediately return NSAPI_ERROR_WOULD_WAIT |
| JMF | 0:24d3eb812fd4 | 245 | */ |
| JMF | 0:24d3eb812fd4 | 246 | virtual int socket_sendto(void *handle, const SocketAddress &address, const void *data, unsigned size); |
| JMF | 0:24d3eb812fd4 | 247 | |
| JMF | 0:24d3eb812fd4 | 248 | /** Receive a packet from a remote endpoint |
| JMF | 0:24d3eb812fd4 | 249 | * @param handle Socket handle |
| JMF | 0:24d3eb812fd4 | 250 | * @param address Destination for the remote SocketAddress or null |
| JMF | 0:24d3eb812fd4 | 251 | * @param buffer The buffer for storing the incoming packet data |
| JMF | 0:24d3eb812fd4 | 252 | * If a packet is too long to fit in the supplied buffer, |
| JMF | 0:24d3eb812fd4 | 253 | * excess bytes are discarded |
| JMF | 0:24d3eb812fd4 | 254 | * @param size The length of the buffer |
| JMF | 0:24d3eb812fd4 | 255 | * @return The number of received bytes on success, negative on failure |
| JMF | 0:24d3eb812fd4 | 256 | * @note This call is not-blocking, if this call would block, must |
| JMF | 0:24d3eb812fd4 | 257 | * immediately return NSAPI_ERROR_WOULD_WAIT |
| JMF | 0:24d3eb812fd4 | 258 | */ |
| JMF | 0:24d3eb812fd4 | 259 | virtual int socket_recvfrom(void *handle, SocketAddress *address, void *buffer, unsigned size); |
| JMF | 0:24d3eb812fd4 | 260 | |
| JMF | 0:24d3eb812fd4 | 261 | /** Register a callback on state change of the socket |
| JMF | 0:24d3eb812fd4 | 262 | * @param handle Socket handle |
| JMF | 0:24d3eb812fd4 | 263 | * @param callback Function to call on state change |
| JMF | 0:24d3eb812fd4 | 264 | * @param data Argument to pass to callback |
| JMF | 0:24d3eb812fd4 | 265 | * @note Callback may be called in an interrupt context. |
| JMF | 0:24d3eb812fd4 | 266 | */ |
| JMF | 0:24d3eb812fd4 | 267 | virtual void socket_attach(void *handle, void (*callback)(void *), void *data); |
| JMF | 0:24d3eb812fd4 | 268 | |
| JMF | 0:24d3eb812fd4 | 269 | /** Provide access to the NetworkStack object |
| JMF | 0:24d3eb812fd4 | 270 | * |
| JMF | 0:24d3eb812fd4 | 271 | * @return The underlying NetworkStack object |
| JMF | 0:24d3eb812fd4 | 272 | */ |
| JMF | 0:24d3eb812fd4 | 273 | virtual NetworkStack *get_stack() |
| JMF | 0:24d3eb812fd4 | 274 | { |
| JMF | 0:24d3eb812fd4 | 275 | return this; |
| JMF | 0:24d3eb812fd4 | 276 | } |
| JMF | 0:24d3eb812fd4 | 277 | |
| JMF | 0:24d3eb812fd4 | 278 | private: |
| JMF | 0:24d3eb812fd4 | 279 | WizFi310 _wizfi310; |
| JMF | 0:24d3eb812fd4 | 280 | bool _ids[WIZFI310_SOCKET_COUNT]; |
| JMF | 0:24d3eb812fd4 | 281 | |
| JMF | 0:24d3eb812fd4 | 282 | char ap_ssid[33]; /* 32 is what 802.11 defines as longest possible name; +1 for the \0 */ |
| JMF | 0:24d3eb812fd4 | 283 | nsapi_security_t ap_sec; |
| JMF | 0:24d3eb812fd4 | 284 | uint8_t ap_ch; |
| JMF | 0:24d3eb812fd4 | 285 | char ap_pass[64]; /* The longest allowed passphrase */ |
| JMF | 0:24d3eb812fd4 | 286 | |
| JMF | 0:24d3eb812fd4 | 287 | void event(); |
| JMF | 0:24d3eb812fd4 | 288 | |
| JMF | 0:24d3eb812fd4 | 289 | struct { |
| JMF | 0:24d3eb812fd4 | 290 | void (*callback)(void *); |
| JMF | 0:24d3eb812fd4 | 291 | void *data; |
| JMF | 0:24d3eb812fd4 | 292 | } _cbs[WIZFI310_SOCKET_COUNT]; |
| JMF | 0:24d3eb812fd4 | 293 | }; |
| JMF | 0:24d3eb812fd4 | 294 | |
| JMF | 0:24d3eb812fd4 | 295 | #endif |
| JMF | 0:24d3eb812fd4 | 296 |