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