Host library for controlling a WiConnect enabled Wi-Fi module.
Dependents: wiconnect-ota_example wiconnect-web_setup_example wiconnect-test-console wiconnect-tcp_server_example ... more
NetworkInterface.h@21:17bb3eddcbae, 2014-08-26 (annotated)
- Committer:
- dan_ackme
- Date:
- Tue Aug 26 16:38:19 2014 -0700
- Revision:
- 21:17bb3eddcbae
- Parent:
- 17:7268f365676b
- Child:
- 26:8067e3d463d3
Add TCP server API
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dan_ackme | 21:17bb3eddcbae | 1 | /** |
dan_ackme | 21:17bb3eddcbae | 2 | * ACKme WiConnect Host Library is licensed under the BSD licence: |
dan_ackme | 21:17bb3eddcbae | 3 | * |
dan_ackme | 21:17bb3eddcbae | 4 | * Copyright (c)2014 ACKme Networks. |
dan_ackme | 21:17bb3eddcbae | 5 | * All rights reserved. |
dan_ackme | 21:17bb3eddcbae | 6 | * |
dan_ackme | 21:17bb3eddcbae | 7 | * Redistribution and use in source and binary forms, with or without modification, |
dan_ackme | 21:17bb3eddcbae | 8 | * are permitted provided that the following conditions are met: |
dan_ackme | 21:17bb3eddcbae | 9 | * |
dan_ackme | 21:17bb3eddcbae | 10 | * 1. Redistributions of source code must retain the above copyright notice, |
dan_ackme | 21:17bb3eddcbae | 11 | * this list of conditions and the following disclaimer. |
dan_ackme | 21:17bb3eddcbae | 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
dan_ackme | 21:17bb3eddcbae | 13 | * this list of conditions and the following disclaimer in the documentation |
dan_ackme | 21:17bb3eddcbae | 14 | * and/or other materials provided with the distribution. |
dan_ackme | 21:17bb3eddcbae | 15 | * 3. The name of the author may not be used to endorse or promote products |
dan_ackme | 21:17bb3eddcbae | 16 | * derived from this software without specific prior written permission. |
dan_ackme | 21:17bb3eddcbae | 17 | * |
dan_ackme | 21:17bb3eddcbae | 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS AND ANY EXPRESS OR IMPLIED |
dan_ackme | 21:17bb3eddcbae | 19 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
dan_ackme | 21:17bb3eddcbae | 20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
dan_ackme | 21:17bb3eddcbae | 21 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
dan_ackme | 21:17bb3eddcbae | 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT |
dan_ackme | 21:17bb3eddcbae | 23 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
dan_ackme | 21:17bb3eddcbae | 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
dan_ackme | 21:17bb3eddcbae | 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
dan_ackme | 21:17bb3eddcbae | 26 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY |
dan_ackme | 21:17bb3eddcbae | 27 | * OF SUCH DAMAGE. |
dan_ackme | 0:ea85c4bb5e1f | 28 | */ |
dan_ackme | 0:ea85c4bb5e1f | 29 | #pragma once |
dan_ackme | 0:ea85c4bb5e1f | 30 | |
dan_ackme | 0:ea85c4bb5e1f | 31 | |
dan_ackme | 0:ea85c4bb5e1f | 32 | #include "WiconnectTypes.h" |
dan_ackme | 0:ea85c4bb5e1f | 33 | #include "types/ScanResultList.h" |
dan_ackme | 0:ea85c4bb5e1f | 34 | |
dan_ackme | 0:ea85c4bb5e1f | 35 | |
dan_ackme | 0:ea85c4bb5e1f | 36 | namespace wiconnect { |
dan_ackme | 0:ea85c4bb5e1f | 37 | |
dan_ackme | 0:ea85c4bb5e1f | 38 | |
dan_ackme | 11:ea484e1b7fc4 | 39 | /** |
dan_ackme | 13:2b51f5267c92 | 40 | * @ingroup api_network_types |
dan_ackme | 11:ea484e1b7fc4 | 41 | * |
dan_ackme | 11:ea484e1b7fc4 | 42 | * @brief The provides an interface for joining and/or creating a network. |
dan_ackme | 11:ea484e1b7fc4 | 43 | * It provides other utilities such as scanning for networks, pinging a network, |
dan_ackme | 11:ea484e1b7fc4 | 44 | * resolving a domain name to IP address. |
dan_ackme | 11:ea484e1b7fc4 | 45 | * |
dan_ackme | 13:2b51f5267c92 | 46 | * @note This class is an interface to the Wiconnect class. It should never be |
dan_ackme | 13:2b51f5267c92 | 47 | * independently instantiated or the parent of another class. |
dan_ackme | 11:ea484e1b7fc4 | 48 | */ |
dan_ackme | 0:ea85c4bb5e1f | 49 | class NetworkInterface |
dan_ackme | 0:ea85c4bb5e1f | 50 | { |
dan_ackme | 0:ea85c4bb5e1f | 51 | public: |
dan_ackme | 11:ea484e1b7fc4 | 52 | /** |
dan_ackme | 11:ea484e1b7fc4 | 53 | * @ingroup api_network_setup |
dan_ackme | 11:ea484e1b7fc4 | 54 | * |
dan_ackme | 11:ea484e1b7fc4 | 55 | * @brief Start the WiConnect WiFi module 'web setup' feature. |
dan_ackme | 13:2b51f5267c92 | 56 | * |
dan_ackme | 13:2b51f5267c92 | 57 | * This command has an optional background processing feature. |
dan_ackme | 13:2b51f5267c92 | 58 | * Background processing is enabled if the completeHandler parameter |
dan_ackme | 13:2b51f5267c92 | 59 | * is specified. If enabled, the library will poll the module every second |
dan_ackme | 13:2b51f5267c92 | 60 | * for the web setup status (essentially it'll call isWebSetupRunning() every |
dan_ackme | 13:2b51f5267c92 | 61 | * second in the background). When the web setup is no longer running the |
dan_ackme | 13:2b51f5267c92 | 62 | * callback will be executed. The background processing is disabled when stopWebSetup() |
dan_ackme | 13:2b51f5267c92 | 63 | * is called. |
dan_ackme | 13:2b51f5267c92 | 64 | * |
dan_ackme | 13:2b51f5267c92 | 65 | * @note only the 'result' parameter of the callback handler is valid. |
dan_ackme | 13:2b51f5267c92 | 66 | * |
dan_ackme | 13:2b51f5267c92 | 67 | * Refer to @ref setting_async_processing for more info. |
dan_ackme | 13:2b51f5267c92 | 68 | * |
dan_ackme | 13:2b51f5267c92 | 69 | * @param[in] ssid Optional, optionally set the SSID of module's softAp |
dan_ackme | 13:2b51f5267c92 | 70 | * @param[in] password Optional, optionally set the WPA2-PSK password for the module'S softap |
dan_ackme | 13:2b51f5267c92 | 71 | * Note: make an OPEN softAp, set this parameter to a null string (i.e. "") |
dan_ackme | 13:2b51f5267c92 | 72 | * @param[in] completeHandler Optional, callback to be executed when module web setup completes. |
dan_ackme | 13:2b51f5267c92 | 73 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 11:ea484e1b7fc4 | 74 | */ |
dan_ackme | 0:ea85c4bb5e1f | 75 | WiconnectResult startWebSetup(const char *ssid = NULL, const char *password = NULL, const Callback &completeHandler = Callback()); |
dan_ackme | 11:ea484e1b7fc4 | 76 | |
dan_ackme | 11:ea484e1b7fc4 | 77 | /** |
dan_ackme | 11:ea484e1b7fc4 | 78 | * @ingroup api_network_setup |
dan_ackme | 11:ea484e1b7fc4 | 79 | * |
dan_ackme | 11:ea484e1b7fc4 | 80 | * @brief Stop the WiConnect WiFi module 'web setup' feature. |
dan_ackme | 13:2b51f5267c92 | 81 | * |
dan_ackme | 13:2b51f5267c92 | 82 | * This method should be called AFTER startWebSetup() to prematurely terminate |
dan_ackme | 13:2b51f5267c92 | 83 | * web setup. Note that this is not needed if web setup completes by itself |
dan_ackme | 13:2b51f5267c92 | 84 | * (i.e. if the user exits web setup from the webpage). |
dan_ackme | 13:2b51f5267c92 | 85 | * |
dan_ackme | 13:2b51f5267c92 | 86 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 11:ea484e1b7fc4 | 87 | */ |
dan_ackme | 0:ea85c4bb5e1f | 88 | WiconnectResult stopWebSetup(); |
dan_ackme | 11:ea484e1b7fc4 | 89 | |
dan_ackme | 11:ea484e1b7fc4 | 90 | /** |
dan_ackme | 11:ea484e1b7fc4 | 91 | * @ingroup api_network_setup |
dan_ackme | 11:ea484e1b7fc4 | 92 | * |
dan_ackme | 11:ea484e1b7fc4 | 93 | * @brief Return status of WiConnect WiFi module 'web setup' feature. |
dan_ackme | 13:2b51f5267c92 | 94 | * |
dan_ackme | 13:2b51f5267c92 | 95 | * This may be called at any time (whether web setpu has been stared or not). |
dan_ackme | 13:2b51f5267c92 | 96 | * |
dan_ackme | 13:2b51f5267c92 | 97 | * @param[out] isRunningPtr Pointer to bool to contain TRUE if web setup is running, FALSE else |
dan_ackme | 13:2b51f5267c92 | 98 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 11:ea484e1b7fc4 | 99 | */ |
dan_ackme | 0:ea85c4bb5e1f | 100 | WiconnectResult isWebSetupRunning(bool *isRunningPtr); |
dan_ackme | 0:ea85c4bb5e1f | 101 | |
dan_ackme | 11:ea484e1b7fc4 | 102 | |
dan_ackme | 11:ea484e1b7fc4 | 103 | // ------------------------------------------------------------------------ |
dan_ackme | 11:ea484e1b7fc4 | 104 | |
dan_ackme | 11:ea484e1b7fc4 | 105 | |
dan_ackme | 11:ea484e1b7fc4 | 106 | /** |
dan_ackme | 11:ea484e1b7fc4 | 107 | * @ingroup api_network_wlan |
dan_ackme | 11:ea484e1b7fc4 | 108 | * |
dan_ackme | 11:ea484e1b7fc4 | 109 | * @brief Join a WiFi network. |
dan_ackme | 13:2b51f5267c92 | 110 | * |
dan_ackme | 13:2b51f5267c92 | 111 | * This command has an optional background processing feature. |
dan_ackme | 13:2b51f5267c92 | 112 | * Background processing is enabled if the completeHandler parameter |
dan_ackme | 13:2b51f5267c92 | 113 | * is specified. If enabled, the library will poll the module every second |
dan_ackme | 13:2b51f5267c92 | 114 | * for the join status (essentially it'll call getNetworkStatus() every |
dan_ackme | 13:2b51f5267c92 | 115 | * second in the background). When the module join sequence complete the callback will be executed. |
dan_ackme | 21:17bb3eddcbae | 116 | * The background processing is disabled when leave() is called. |
dan_ackme | 21:17bb3eddcbae | 117 | * |
dan_ackme | 21:17bb3eddcbae | 118 | * * If completeHandler parameter is NOT specified: |
dan_ackme | 21:17bb3eddcbae | 119 | * This command will BLOCK/return WICONNECT_PROCESSING until the module has |
dan_ackme | 21:17bb3eddcbae | 120 | * either successfully joined the network or failed. |
dan_ackme | 21:17bb3eddcbae | 121 | * * If the completeHandler parameter IS specified: |
dan_ackme | 17:7268f365676b | 122 | * This command will return and use the background processing feature described above. |
dan_ackme | 13:2b51f5267c92 | 123 | * |
dan_ackme | 13:2b51f5267c92 | 124 | * @note only the 'result' parameter of the callback handler is valid. |
dan_ackme | 13:2b51f5267c92 | 125 | * |
dan_ackme | 13:2b51f5267c92 | 126 | * Refer to @ref setting_async_processing for more info. |
dan_ackme | 13:2b51f5267c92 | 127 | * |
dan_ackme | 13:2b51f5267c92 | 128 | * @param[in] ssid Optional, optionally set the SSID of the network to join |
dan_ackme | 13:2b51f5267c92 | 129 | * @param[in] password Optional, optionally set the passkey of the network to join |
dan_ackme | 13:2b51f5267c92 | 130 | * Note: to join an OPEN network, set this parameter to a null string (i.e. "") |
dan_ackme | 13:2b51f5267c92 | 131 | * @param[in] completeHandler Optional, callback to be executed when the join sequence completes. |
dan_ackme | 13:2b51f5267c92 | 132 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 11:ea484e1b7fc4 | 133 | */ |
dan_ackme | 0:ea85c4bb5e1f | 134 | WiconnectResult join(const char* ssid = NULL, const char *password = NULL, const Callback &completeHandler = Callback()); |
dan_ackme | 11:ea484e1b7fc4 | 135 | |
dan_ackme | 11:ea484e1b7fc4 | 136 | /** |
dan_ackme | 11:ea484e1b7fc4 | 137 | * @ingroup api_network_wlan |
dan_ackme | 11:ea484e1b7fc4 | 138 | * |
dan_ackme | 11:ea484e1b7fc4 | 139 | * @brief Leave a WiFi network. |
dan_ackme | 13:2b51f5267c92 | 140 | * |
dan_ackme | 13:2b51f5267c92 | 141 | * This method may be called to either terminate a join sequence or |
dan_ackme | 13:2b51f5267c92 | 142 | * leave a previously connected networked. |
dan_ackme | 13:2b51f5267c92 | 143 | * |
dan_ackme | 13:2b51f5267c92 | 144 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 11:ea484e1b7fc4 | 145 | */ |
dan_ackme | 0:ea85c4bb5e1f | 146 | WiconnectResult leave(); |
dan_ackme | 11:ea484e1b7fc4 | 147 | |
dan_ackme | 11:ea484e1b7fc4 | 148 | /** |
dan_ackme | 11:ea484e1b7fc4 | 149 | * @ingroup api_network_wlan |
dan_ackme | 11:ea484e1b7fc4 | 150 | * |
dan_ackme | 11:ea484e1b7fc4 | 151 | * @brief Get connection status to WiFi network. |
dan_ackme | 13:2b51f5267c92 | 152 | * |
dan_ackme | 13:2b51f5267c92 | 153 | * Refer to @ref NetworkStatus for more info. |
dan_ackme | 13:2b51f5267c92 | 154 | * |
dan_ackme | 13:2b51f5267c92 | 155 | * @param[out] statusPtr Point to a @ref NetworkStatus which will hold current network status of module |
dan_ackme | 13:2b51f5267c92 | 156 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 11:ea484e1b7fc4 | 157 | */ |
dan_ackme | 0:ea85c4bb5e1f | 158 | WiconnectResult getNetworkStatus(NetworkStatus *statusPtr); |
dan_ackme | 0:ea85c4bb5e1f | 159 | |
dan_ackme | 11:ea484e1b7fc4 | 160 | // ------------------------------------------------------------------------ |
dan_ackme | 11:ea484e1b7fc4 | 161 | |
dan_ackme | 11:ea484e1b7fc4 | 162 | |
dan_ackme | 0:ea85c4bb5e1f | 163 | // WiconnectResult startSoftAp(const char* ssid = NULL, const char *password = NULL, const Callback &clientConnectedCallback = Callback()); |
dan_ackme | 0:ea85c4bb5e1f | 164 | // WiconnectResult stopSoftAp(); |
dan_ackme | 0:ea85c4bb5e1f | 165 | // WiconnectResult getSoftApClientList(); |
dan_ackme | 0:ea85c4bb5e1f | 166 | |
dan_ackme | 11:ea484e1b7fc4 | 167 | |
dan_ackme | 11:ea484e1b7fc4 | 168 | // ------------------------------------------------------------------------ |
dan_ackme | 11:ea484e1b7fc4 | 169 | |
dan_ackme | 11:ea484e1b7fc4 | 170 | |
dan_ackme | 11:ea484e1b7fc4 | 171 | /** |
dan_ackme | 11:ea484e1b7fc4 | 172 | * @ingroup api_network_util |
dan_ackme | 11:ea484e1b7fc4 | 173 | * |
dan_ackme | 11:ea484e1b7fc4 | 174 | * @brief Scan for available WiFi networks. |
dan_ackme | 13:2b51f5267c92 | 175 | * |
dan_ackme | 13:2b51f5267c92 | 176 | * The populate the supplied @ref ScanResultList with @ref ScanResult of each found network. |
dan_ackme | 13:2b51f5267c92 | 177 | * |
dan_ackme | 13:2b51f5267c92 | 178 | * Optionally only scan of specific channels by supplying a null terminated list of channels. |
dan_ackme | 13:2b51f5267c92 | 179 | * Example: |
dan_ackme | 13:2b51f5267c92 | 180 | * @code |
dan_ackme | 13:2b51f5267c92 | 181 | * const uint8_t channelsToScan[] = {1, 6, 11, 0}; |
dan_ackme | 13:2b51f5267c92 | 182 | * @endcode |
dan_ackme | 13:2b51f5267c92 | 183 | * |
dan_ackme | 13:2b51f5267c92 | 184 | * @param[out] resultList List to populate with scan results. |
dan_ackme | 13:2b51f5267c92 | 185 | * @param[in] channelList Optional, null terminated list of channels to scan. |
dan_ackme | 13:2b51f5267c92 | 186 | * @param[in] ssid Optional, specific network name to scan for. |
dan_ackme | 13:2b51f5267c92 | 187 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 11:ea484e1b7fc4 | 188 | */ |
dan_ackme | 0:ea85c4bb5e1f | 189 | WiconnectResult scan(ScanResultList &resultList, const uint8_t *channelList = NULL, const char* ssid = NULL); |
dan_ackme | 11:ea484e1b7fc4 | 190 | |
dan_ackme | 11:ea484e1b7fc4 | 191 | /** |
dan_ackme | 11:ea484e1b7fc4 | 192 | * @ingroup api_network_util |
dan_ackme | 11:ea484e1b7fc4 | 193 | * |
dan_ackme | 11:ea484e1b7fc4 | 194 | * @brief Ping a WiFi network. |
dan_ackme | 13:2b51f5267c92 | 195 | * |
dan_ackme | 13:2b51f5267c92 | 196 | * Optionally ping a specific server and return the time in milliseconds it took |
dan_ackme | 13:2b51f5267c92 | 197 | * for the network to response. If no domain is supplied, the module pings to gateway |
dan_ackme | 13:2b51f5267c92 | 198 | * (i.e router it's connected to). |
dan_ackme | 13:2b51f5267c92 | 199 | * |
dan_ackme | 13:2b51f5267c92 | 200 | * @param[in] domain Optional, the domain name to ping |
dan_ackme | 13:2b51f5267c92 | 201 | * @param[out] timeMsPtr Optional, pointer to uint32 to hold time in milliseconds the ping took |
dan_ackme | 13:2b51f5267c92 | 202 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 11:ea484e1b7fc4 | 203 | */ |
dan_ackme | 0:ea85c4bb5e1f | 204 | WiconnectResult ping(const char *domain = NULL, uint32_t *timeMsPtr = NULL); |
dan_ackme | 11:ea484e1b7fc4 | 205 | |
dan_ackme | 11:ea484e1b7fc4 | 206 | /** |
dan_ackme | 11:ea484e1b7fc4 | 207 | * @ingroup api_network_util |
dan_ackme | 11:ea484e1b7fc4 | 208 | * |
dan_ackme | 11:ea484e1b7fc4 | 209 | * @brief Resolve domain name into IP address. |
dan_ackme | 13:2b51f5267c92 | 210 | * |
dan_ackme | 13:2b51f5267c92 | 211 | * @param[in] domain The domain name to resolve |
dan_ackme | 13:2b51f5267c92 | 212 | * @param[out] ipAddressPtr pointer to uint32 to hold resolved IP address. Note, the IP address is in network-byte-order. |
dan_ackme | 13:2b51f5267c92 | 213 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 11:ea484e1b7fc4 | 214 | */ |
dan_ackme | 0:ea85c4bb5e1f | 215 | WiconnectResult lookup(const char *domain, uint32_t *ipAddressPtr); |
dan_ackme | 0:ea85c4bb5e1f | 216 | |
dan_ackme | 11:ea484e1b7fc4 | 217 | |
dan_ackme | 11:ea484e1b7fc4 | 218 | // ------------------------------------------------------------------------ |
dan_ackme | 11:ea484e1b7fc4 | 219 | |
dan_ackme | 11:ea484e1b7fc4 | 220 | |
dan_ackme | 11:ea484e1b7fc4 | 221 | /** |
dan_ackme | 11:ea484e1b7fc4 | 222 | * @ingroup api_network_settings |
dan_ackme | 11:ea484e1b7fc4 | 223 | * |
dan_ackme | 11:ea484e1b7fc4 | 224 | * @brief Set DHCP enabled. |
dan_ackme | 13:2b51f5267c92 | 225 | * |
dan_ackme | 13:2b51f5267c92 | 226 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 11:ea484e1b7fc4 | 227 | */ |
dan_ackme | 0:ea85c4bb5e1f | 228 | WiconnectResult setDhcpEnabled(bool enabled); |
dan_ackme | 11:ea484e1b7fc4 | 229 | |
dan_ackme | 11:ea484e1b7fc4 | 230 | /** |
dan_ackme | 11:ea484e1b7fc4 | 231 | * @ingroup api_network_settings |
dan_ackme | 11:ea484e1b7fc4 | 232 | * |
dan_ackme | 11:ea484e1b7fc4 | 233 | * @brief Get if DHCP enabled. |
dan_ackme | 11:ea484e1b7fc4 | 234 | */ |
dan_ackme | 0:ea85c4bb5e1f | 235 | WiconnectResult getDhcpEnabled(bool *enabledPtr); |
dan_ackme | 11:ea484e1b7fc4 | 236 | |
dan_ackme | 11:ea484e1b7fc4 | 237 | /** |
dan_ackme | 11:ea484e1b7fc4 | 238 | * @ingroup api_network_settings |
dan_ackme | 11:ea484e1b7fc4 | 239 | * |
dan_ackme | 11:ea484e1b7fc4 | 240 | * @brief Set static IP settings |
dan_ackme | 11:ea484e1b7fc4 | 241 | */ |
dan_ackme | 0:ea85c4bb5e1f | 242 | WiconnectResult setIpSettings(uint32_t ip, uint32_t netmask, uint32_t gateway); |
dan_ackme | 11:ea484e1b7fc4 | 243 | |
dan_ackme | 11:ea484e1b7fc4 | 244 | /** |
dan_ackme | 11:ea484e1b7fc4 | 245 | * @ingroup api_network_settings |
dan_ackme | 11:ea484e1b7fc4 | 246 | * |
dan_ackme | 11:ea484e1b7fc4 | 247 | * @brief Set static IP settings (with string parameters) |
dan_ackme | 11:ea484e1b7fc4 | 248 | */ |
dan_ackme | 0:ea85c4bb5e1f | 249 | WiconnectResult setIpSettings(const char* ip, const char* netmask, const char* gateway); |
dan_ackme | 11:ea484e1b7fc4 | 250 | |
dan_ackme | 11:ea484e1b7fc4 | 251 | /** |
dan_ackme | 11:ea484e1b7fc4 | 252 | * @ingroup api_network_settings |
dan_ackme | 11:ea484e1b7fc4 | 253 | * |
dan_ackme | 11:ea484e1b7fc4 | 254 | * @brief Get network IP settings |
dan_ackme | 11:ea484e1b7fc4 | 255 | */ |
dan_ackme | 0:ea85c4bb5e1f | 256 | WiconnectResult getIpSettings(uint32_t *ip, uint32_t *netmask, uint32_t *gateway); |
dan_ackme | 11:ea484e1b7fc4 | 257 | |
dan_ackme | 11:ea484e1b7fc4 | 258 | /** |
dan_ackme | 11:ea484e1b7fc4 | 259 | * @ingroup api_network_settings |
dan_ackme | 11:ea484e1b7fc4 | 260 | * |
dan_ackme | 11:ea484e1b7fc4 | 261 | * @brief Get signal strength to WiFi network |
dan_ackme | 11:ea484e1b7fc4 | 262 | */ |
dan_ackme | 0:ea85c4bb5e1f | 263 | WiconnectResult getSignalStrength(NetworkSignalStrength *signalStrengthPtr); |
dan_ackme | 0:ea85c4bb5e1f | 264 | |
dan_ackme | 21:17bb3eddcbae | 265 | |
dan_ackme | 21:17bb3eddcbae | 266 | /** |
dan_ackme | 21:17bb3eddcbae | 267 | * @ingroup api_network_settings |
dan_ackme | 21:17bb3eddcbae | 268 | * |
dan_ackme | 21:17bb3eddcbae | 269 | * @note This method is only supported in blocking mode. |
dan_ackme | 21:17bb3eddcbae | 270 | * |
dan_ackme | 21:17bb3eddcbae | 271 | * @brief Return the current IP address of the module if possible, else |
dan_ackme | 21:17bb3eddcbae | 272 | * return 0.0.0.0 |
dan_ackme | 21:17bb3eddcbae | 273 | * @param[in] buffer Optional, buffer to IP address string. If omitted, |
dan_ackme | 21:17bb3eddcbae | 274 | * the IP address string is stored in a local static buffer (this is non-reentrant!) |
dan_ackme | 21:17bb3eddcbae | 275 | */ |
dan_ackme | 21:17bb3eddcbae | 276 | const char* getIpAddress(char *buffer = NULL); |
dan_ackme | 21:17bb3eddcbae | 277 | |
dan_ackme | 11:ea484e1b7fc4 | 278 | |
dan_ackme | 11:ea484e1b7fc4 | 279 | // ------------------------------------------------------------------------ |
dan_ackme | 11:ea484e1b7fc4 | 280 | |
dan_ackme | 11:ea484e1b7fc4 | 281 | |
dan_ackme | 11:ea484e1b7fc4 | 282 | /** |
dan_ackme | 11:ea484e1b7fc4 | 283 | * @ingroup conversion_util |
dan_ackme | 11:ea484e1b7fc4 | 284 | * |
dan_ackme | 11:ea484e1b7fc4 | 285 | * @brief Convert string to IP address |
dan_ackme | 11:ea484e1b7fc4 | 286 | */ |
dan_ackme | 0:ea85c4bb5e1f | 287 | static bool strToIp(const char *str, uint32_t *intPtr); |
dan_ackme | 11:ea484e1b7fc4 | 288 | |
dan_ackme | 11:ea484e1b7fc4 | 289 | /** |
dan_ackme | 11:ea484e1b7fc4 | 290 | * @ingroup conversion_util |
dan_ackme | 11:ea484e1b7fc4 | 291 | * |
dan_ackme | 11:ea484e1b7fc4 | 292 | * @brief Convert IP address to string |
dan_ackme | 11:ea484e1b7fc4 | 293 | */ |
dan_ackme | 0:ea85c4bb5e1f | 294 | static const char* ipToStr(uint32_t ip, char *ipStrBuffer = NULL); |
dan_ackme | 11:ea484e1b7fc4 | 295 | |
dan_ackme | 11:ea484e1b7fc4 | 296 | /** |
dan_ackme | 11:ea484e1b7fc4 | 297 | * @ingroup conversion_util |
dan_ackme | 11:ea484e1b7fc4 | 298 | * |
dan_ackme | 11:ea484e1b7fc4 | 299 | * @brief Convert @ref NetworkStatus to string |
dan_ackme | 11:ea484e1b7fc4 | 300 | */ |
dan_ackme | 0:ea85c4bb5e1f | 301 | static const char* networkStatusToStr(NetworkStatus status); |
dan_ackme | 11:ea484e1b7fc4 | 302 | |
dan_ackme | 11:ea484e1b7fc4 | 303 | /** |
dan_ackme | 11:ea484e1b7fc4 | 304 | * @ingroup conversion_util |
dan_ackme | 11:ea484e1b7fc4 | 305 | * |
dan_ackme | 11:ea484e1b7fc4 | 306 | * @brief Convert @ref NetworkSignalStrength to string |
dan_ackme | 11:ea484e1b7fc4 | 307 | */ |
dan_ackme | 0:ea85c4bb5e1f | 308 | static const char* signalStrengthToStr(NetworkSignalStrength signalStrenth); |
dan_ackme | 11:ea484e1b7fc4 | 309 | |
dan_ackme | 11:ea484e1b7fc4 | 310 | /** |
dan_ackme | 11:ea484e1b7fc4 | 311 | * @ingroup conversion_util |
dan_ackme | 11:ea484e1b7fc4 | 312 | * |
dan_ackme | 11:ea484e1b7fc4 | 313 | * @brief Convert RSSI (in dBm) to @ref NetworkSignalStrength |
dan_ackme | 11:ea484e1b7fc4 | 314 | */ |
dan_ackme | 0:ea85c4bb5e1f | 315 | static NetworkSignalStrength rssiToSignalStrength(int rssi); |
dan_ackme | 11:ea484e1b7fc4 | 316 | |
dan_ackme | 11:ea484e1b7fc4 | 317 | /** |
dan_ackme | 11:ea484e1b7fc4 | 318 | * @ingroup conversion_util |
dan_ackme | 11:ea484e1b7fc4 | 319 | * |
dan_ackme | 11:ea484e1b7fc4 | 320 | * @brief Convert string to @ref NetworkSecurity |
dan_ackme | 11:ea484e1b7fc4 | 321 | */ |
dan_ackme | 0:ea85c4bb5e1f | 322 | static NetworkSecurity strToNetworkSecurity(const char *str); |
dan_ackme | 11:ea484e1b7fc4 | 323 | |
dan_ackme | 11:ea484e1b7fc4 | 324 | /** |
dan_ackme | 11:ea484e1b7fc4 | 325 | * @ingroup conversion_util |
dan_ackme | 11:ea484e1b7fc4 | 326 | * |
dan_ackme | 11:ea484e1b7fc4 | 327 | * @brief Convert @ref NetworkSecurity to string |
dan_ackme | 11:ea484e1b7fc4 | 328 | */ |
dan_ackme | 0:ea85c4bb5e1f | 329 | static const char* networkSecurityToStr(NetworkSecurity security); |
dan_ackme | 11:ea484e1b7fc4 | 330 | |
dan_ackme | 11:ea484e1b7fc4 | 331 | /** |
dan_ackme | 11:ea484e1b7fc4 | 332 | * @ingroup conversion_util |
dan_ackme | 11:ea484e1b7fc4 | 333 | * |
dan_ackme | 11:ea484e1b7fc4 | 334 | * @brief Convert string @ref Ssid |
dan_ackme | 11:ea484e1b7fc4 | 335 | */ |
dan_ackme | 0:ea85c4bb5e1f | 336 | static bool strToSsid(const char *str, Ssid *ssid); |
dan_ackme | 11:ea484e1b7fc4 | 337 | |
dan_ackme | 11:ea484e1b7fc4 | 338 | /** |
dan_ackme | 11:ea484e1b7fc4 | 339 | * @ingroup conversion_util |
dan_ackme | 11:ea484e1b7fc4 | 340 | * |
dan_ackme | 11:ea484e1b7fc4 | 341 | * @brief Convert @ref Ssid to string |
dan_ackme | 11:ea484e1b7fc4 | 342 | */ |
dan_ackme | 0:ea85c4bb5e1f | 343 | static const char* ssidToStr(const Ssid *ssid, char *ssidStrBuffer = NULL); |
dan_ackme | 11:ea484e1b7fc4 | 344 | |
dan_ackme | 11:ea484e1b7fc4 | 345 | /** |
dan_ackme | 11:ea484e1b7fc4 | 346 | * @ingroup conversion_util |
dan_ackme | 11:ea484e1b7fc4 | 347 | * |
dan_ackme | 11:ea484e1b7fc4 | 348 | * @brief Convert string @ref MacAddress |
dan_ackme | 11:ea484e1b7fc4 | 349 | */ |
dan_ackme | 0:ea85c4bb5e1f | 350 | static bool strToMacAddress(const char *str, MacAddress *macAddress); |
dan_ackme | 11:ea484e1b7fc4 | 351 | |
dan_ackme | 11:ea484e1b7fc4 | 352 | /** |
dan_ackme | 11:ea484e1b7fc4 | 353 | * @ingroup conversion_util |
dan_ackme | 11:ea484e1b7fc4 | 354 | * |
dan_ackme | 11:ea484e1b7fc4 | 355 | * @brief Convert @ref MacAddress to string |
dan_ackme | 11:ea484e1b7fc4 | 356 | */ |
dan_ackme | 0:ea85c4bb5e1f | 357 | static const char* macAddressToStr(const MacAddress *macAddress, char *macStrBuffer = NULL); |
dan_ackme | 0:ea85c4bb5e1f | 358 | |
dan_ackme | 0:ea85c4bb5e1f | 359 | protected: |
dan_ackme | 0:ea85c4bb5e1f | 360 | NetworkInterface(Wiconnect *wiconnect); |
dan_ackme | 0:ea85c4bb5e1f | 361 | |
dan_ackme | 0:ea85c4bb5e1f | 362 | WiconnectResult processScanResults(char *resultStr, ScanResultList &resultList); |
dan_ackme | 0:ea85c4bb5e1f | 363 | |
dan_ackme | 0:ea85c4bb5e1f | 364 | #ifdef WICONNECT_ASYNC_TIMER_ENABLED |
dan_ackme | 0:ea85c4bb5e1f | 365 | Callback completeHandler; |
dan_ackme | 0:ea85c4bb5e1f | 366 | PeriodicTimer monitorTimer; |
dan_ackme | 0:ea85c4bb5e1f | 367 | |
dan_ackme | 0:ea85c4bb5e1f | 368 | void webSetupStatusMonitor(); |
dan_ackme | 0:ea85c4bb5e1f | 369 | void webSetupStatusCheckCallback(WiconnectResult result, void *arg1, void *arg2); |
dan_ackme | 0:ea85c4bb5e1f | 370 | |
dan_ackme | 0:ea85c4bb5e1f | 371 | void joinStatusMonitor(); |
dan_ackme | 0:ea85c4bb5e1f | 372 | void joinStatusCheckCallback(WiconnectResult result, void *arg1, void *arg2); |
dan_ackme | 0:ea85c4bb5e1f | 373 | |
dan_ackme | 0:ea85c4bb5e1f | 374 | //void scanCompleteCallback(WiconnectResult result, void *arg1, void *arg2); |
dan_ackme | 0:ea85c4bb5e1f | 375 | #endif |
dan_ackme | 0:ea85c4bb5e1f | 376 | |
dan_ackme | 0:ea85c4bb5e1f | 377 | private: |
dan_ackme | 0:ea85c4bb5e1f | 378 | Wiconnect *wiconnect; |
dan_ackme | 0:ea85c4bb5e1f | 379 | }; |
dan_ackme | 0:ea85c4bb5e1f | 380 | |
dan_ackme | 0:ea85c4bb5e1f | 381 | } |