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

Committer:
dan_ackme
Date:
Mon Oct 27 13:42:26 2014 -0700
Revision:
29:b6af04b77a56
Child:
34:2616445d0823
refactored library layout

Who changed what in which revision?

UserRevisionLine numberNew 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 #include "WiconnectTypes.h"
dan_ackme 29:b6af04b77a56 32
dan_ackme 29:b6af04b77a56 33
dan_ackme 29:b6af04b77a56 34 #include "types/LogFunc.h"
dan_ackme 29:b6af04b77a56 35 #include "types/ReaderFunc.h"
dan_ackme 29:b6af04b77a56 36 #include "types/Callback.h"
dan_ackme 29:b6af04b77a56 37 #include "types/TimeoutTimer.h"
dan_ackme 29:b6af04b77a56 38 #include "types/PeriodicTimer.h"
dan_ackme 29:b6af04b77a56 39 #include "types/Gpio.h"
dan_ackme 29:b6af04b77a56 40 #include "types/WiconnectSerial.h"
dan_ackme 29:b6af04b77a56 41
dan_ackme 29:b6af04b77a56 42 #ifdef WICONNECT_ASYNC_TIMER_ENABLED
dan_ackme 29:b6af04b77a56 43 #include "types/QueuedCommand.h"
dan_ackme 29:b6af04b77a56 44 #include "types/CommandQueue.h"
dan_ackme 29:b6af04b77a56 45 #endif
dan_ackme 29:b6af04b77a56 46
dan_ackme 29:b6af04b77a56 47 #include "NetworkInterface.h"
dan_ackme 29:b6af04b77a56 48 #include "SocketInterface.h"
dan_ackme 29:b6af04b77a56 49 #include "FileInterface.h"
dan_ackme 29:b6af04b77a56 50 #include "GhmInterface.h"
dan_ackme 29:b6af04b77a56 51
dan_ackme 29:b6af04b77a56 52
dan_ackme 29:b6af04b77a56 53 #ifdef WICONNECT_ENABLE_MALLOC
dan_ackme 29:b6af04b77a56 54 /// These are optional arguments for host specific malloc/free
dan_ackme 29:b6af04b77a56 55 #define WICONNECT_MALLOC_ARGS , void* (*malloc_)(size_t) = WICONNECT_DEFAULT_MALLOC, void (*free_)(void*) = WICONNECT_DEFAULT_FREE
dan_ackme 29:b6af04b77a56 56 #else
dan_ackme 29:b6af04b77a56 57 #define WICONNECT_MALLOC_ARGS
dan_ackme 29:b6af04b77a56 58 #endif
dan_ackme 29:b6af04b77a56 59
dan_ackme 29:b6af04b77a56 60
dan_ackme 29:b6af04b77a56 61 /**
dan_ackme 29:b6af04b77a56 62 * @namespace wiconnect
dan_ackme 29:b6af04b77a56 63 */
dan_ackme 29:b6af04b77a56 64 namespace wiconnect {
dan_ackme 29:b6af04b77a56 65
dan_ackme 29:b6af04b77a56 66
dan_ackme 29:b6af04b77a56 67 /**
dan_ackme 29:b6af04b77a56 68 * @ingroup api_core_types
dan_ackme 29:b6af04b77a56 69 *
dan_ackme 29:b6af04b77a56 70 * @brief The root WiConnect library class. This class
dan_ackme 29:b6af04b77a56 71 * inheriets all WiConnect functionality.
dan_ackme 29:b6af04b77a56 72 *
dan_ackme 29:b6af04b77a56 73 * This class is implemented as a 'singleton'. This means it
dan_ackme 29:b6af04b77a56 74 * only needs to be instantiated once. Subsequent class may either
dan_ackme 29:b6af04b77a56 75 * use the class instance or the static function: @ref Wiconnect::getInstance()
dan_ackme 29:b6af04b77a56 76 *
dan_ackme 29:b6af04b77a56 77 */
dan_ackme 29:b6af04b77a56 78 class Wiconnect : public NetworkInterface,
dan_ackme 29:b6af04b77a56 79 public SocketInterface,
dan_ackme 29:b6af04b77a56 80 public FileInterface,
dan_ackme 29:b6af04b77a56 81 public GhmInterface
dan_ackme 29:b6af04b77a56 82 {
dan_ackme 29:b6af04b77a56 83 public:
dan_ackme 29:b6af04b77a56 84
dan_ackme 29:b6af04b77a56 85 /**
dan_ackme 29:b6af04b77a56 86 * @brief WiConnect class constructor
dan_ackme 29:b6af04b77a56 87 *
dan_ackme 29:b6af04b77a56 88 * @note This should only be called once within a program as the WiConnect
dan_ackme 29:b6af04b77a56 89 * library is implemented as a singleton.
dan_ackme 29:b6af04b77a56 90 *
dan_ackme 29:b6af04b77a56 91 * @note If this constructor is used, then all commands must be supplied with an external response buffer.
dan_ackme 29:b6af04b77a56 92 * This means most the API functions will not work as they use the internal buffer.
dan_ackme 29:b6af04b77a56 93 * It's recommended to use the other constructor that supplies an internal buffer. See @ref setting_alloc
dan_ackme 29:b6af04b77a56 94 *
dan_ackme 29:b6af04b77a56 95 * @param[in] serialConfig The serial (i.e. UART) configuration connected to a WiConnect module.
dan_ackme 29:b6af04b77a56 96 * @param[in] reset Optional, The pin connected to the WiConnect module reset signal. Default: No connection
dan_ackme 29:b6af04b77a56 97 * @param[in] wake Optional, The pin connected to the WiConnect module wake signal. Default: No connection
dan_ackme 29:b6af04b77a56 98 * @param[in] nonBlocking Optional, indicates if the API blocking mode. See @ref setting_blocking_modes
dan_ackme 29:b6af04b77a56 99 */
dan_ackme 29:b6af04b77a56 100 Wiconnect(const SerialConfig &serialConfig, Pin reset = PIN_NC, Pin wake = PIN_NC, bool nonBlocking = WICONNECT_DEFAULT_NONBLOCKING WICONNECT_MALLOC_ARGS);
dan_ackme 29:b6af04b77a56 101
dan_ackme 29:b6af04b77a56 102 /**
dan_ackme 29:b6af04b77a56 103 * @brief WiConnect class constructor
dan_ackme 29:b6af04b77a56 104 *
dan_ackme 29:b6af04b77a56 105 * @note This should only be called once within a program as the WiConnect
dan_ackme 29:b6af04b77a56 106 * library is implemented as a singleton.
dan_ackme 29:b6af04b77a56 107 *
dan_ackme 29:b6af04b77a56 108 * @note This is the recommended construstor as it supplies the WiConnect library with an
dan_ackme 29:b6af04b77a56 109 * internal buffer. Most API calls require the internal buffer.
dan_ackme 29:b6af04b77a56 110 *
dan_ackme 29:b6af04b77a56 111 * @param[in] serialConfig The serial (i.e. UART) configuration connected to a WiConnect module.
dan_ackme 29:b6af04b77a56 112 * @param[in] internalBufferSize The size of the internal buffer. If internalBuffer is NULL, then this size will be dynamically allocated. See @ref setting_alloc
dan_ackme 29:b6af04b77a56 113 * @param[in] internalBuffer Optional, a user allocated buffer. See @ref setting_alloc
dan_ackme 29:b6af04b77a56 114 * @param[in] reset Optional, The pin connected to the WiConnect module reset signal. Default: No connection
dan_ackme 29:b6af04b77a56 115 * @param[in] wake Optional, The pin connected to the WiConnect module wake signal. Default: No connection
dan_ackme 29:b6af04b77a56 116 * @param[in] nonBlocking Optional, indicates if the API blocking mode. See @ref setting_blocking_modes
dan_ackme 29:b6af04b77a56 117 */
dan_ackme 29:b6af04b77a56 118 Wiconnect(const SerialConfig &serialConfig, int internalBufferSize, void *internalBuffer = NULL, Pin reset = PIN_NC, Pin wake = PIN_NC, bool nonBlocking = WICONNECT_DEFAULT_NONBLOCKING WICONNECT_MALLOC_ARGS);
dan_ackme 29:b6af04b77a56 119 ~Wiconnect();
dan_ackme 29:b6af04b77a56 120
dan_ackme 29:b6af04b77a56 121
dan_ackme 29:b6af04b77a56 122 // ------------------------------------------------------------------------
dan_ackme 29:b6af04b77a56 123
dan_ackme 29:b6af04b77a56 124
dan_ackme 29:b6af04b77a56 125 /**
dan_ackme 29:b6af04b77a56 126 * @ingroup api_core_misc
dan_ackme 29:b6af04b77a56 127 *
dan_ackme 29:b6af04b77a56 128 * @brief Get instance of previously instantiated Wiconnect Library
dan_ackme 29:b6af04b77a56 129 *
dan_ackme 29:b6af04b77a56 130 * @return Pointer to instance of @ref Wiconnect Library.
dan_ackme 29:b6af04b77a56 131 */
dan_ackme 29:b6af04b77a56 132 static Wiconnect* getInstance();
dan_ackme 29:b6af04b77a56 133
dan_ackme 29:b6af04b77a56 134 /**
dan_ackme 29:b6af04b77a56 135 * @ingroup api_core_misc
dan_ackme 29:b6af04b77a56 136 *
dan_ackme 29:b6af04b77a56 137 * @brief Initialize library and communication link with WiConnect WiFi module.
dan_ackme 29:b6af04b77a56 138 *
dan_ackme 29:b6af04b77a56 139 * @note This function is always blocking regardless of configured mode.
dan_ackme 29:b6af04b77a56 140 *
dan_ackme 29:b6af04b77a56 141 * @param[in] bringNetworkUp Flag indicating if the module should try to bring the network up upon initialization.
dan_ackme 29:b6af04b77a56 142 * @return Result of initialization. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 143 */
dan_ackme 29:b6af04b77a56 144 WiconnectResult init(bool bringNetworkUp=false);
dan_ackme 29:b6af04b77a56 145
dan_ackme 29:b6af04b77a56 146 /**
dan_ackme 29:b6af04b77a56 147 * @ingroup api_core_misc
dan_ackme 29:b6af04b77a56 148 *
dan_ackme 29:b6af04b77a56 149 * @brief De-initialize library.
dan_ackme 29:b6af04b77a56 150 */
dan_ackme 29:b6af04b77a56 151 void deinit();
dan_ackme 29:b6af04b77a56 152
dan_ackme 29:b6af04b77a56 153 /**
dan_ackme 29:b6af04b77a56 154 * @ingroup api_core_misc
dan_ackme 29:b6af04b77a56 155 *
dan_ackme 29:b6af04b77a56 156 * @brief Return TRUE if library is able to communicated with WiConnect WiFi module.
dan_ackme 29:b6af04b77a56 157 * FALSE else.
dan_ackme 29:b6af04b77a56 158 *
dan_ackme 29:b6af04b77a56 159 * @return TRUE if library can communicate with WiFi module, FALSE else.
dan_ackme 29:b6af04b77a56 160 */
dan_ackme 29:b6af04b77a56 161 bool isInitialized();
dan_ackme 29:b6af04b77a56 162
dan_ackme 29:b6af04b77a56 163 /**
dan_ackme 29:b6af04b77a56 164 * @ingroup api_core_misc
dan_ackme 29:b6af04b77a56 165 *
dan_ackme 29:b6af04b77a56 166 * @brief Toggle the WiConnect WiFi module reset signal.
dan_ackme 29:b6af04b77a56 167 *
dan_ackme 29:b6af04b77a56 168 * @note This only resets the module if the library was instantiated with the 'reset' pin
dan_ackme 29:b6af04b77a56 169 * parameter in the Wiconnect::Wiconnect constructor.
dan_ackme 29:b6af04b77a56 170 * @note This method is always blocking. A small (1s) delay is added to ensure the module
dan_ackme 29:b6af04b77a56 171 * has returned from reset and ready.
dan_ackme 29:b6af04b77a56 172 *
dan_ackme 29:b6af04b77a56 173 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 174 */
dan_ackme 29:b6af04b77a56 175 WiconnectResult reset();
dan_ackme 29:b6af04b77a56 176
dan_ackme 29:b6af04b77a56 177 /**
dan_ackme 29:b6af04b77a56 178 * @ingroup api_core_misc
dan_ackme 29:b6af04b77a56 179 *
dan_ackme 29:b6af04b77a56 180 * @brief Toggle the WiConnect WiFi moduel wakeup signal.
dan_ackme 29:b6af04b77a56 181 *
dan_ackme 29:b6af04b77a56 182 * @note This only wakes the module if the library was instantiated with the 'wake' pin
dan_ackme 29:b6af04b77a56 183 * parameter in the Wiconnect::Wiconnect constructor.
dan_ackme 29:b6af04b77a56 184 * @note This method is always blocking.
dan_ackme 29:b6af04b77a56 185 *
dan_ackme 29:b6af04b77a56 186 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 187 */
dan_ackme 29:b6af04b77a56 188 WiconnectResult wakeup();
dan_ackme 29:b6af04b77a56 189
dan_ackme 29:b6af04b77a56 190 /**
dan_ackme 29:b6af04b77a56 191 * @ingroup api_core_misc
dan_ackme 29:b6af04b77a56 192 *
dan_ackme 29:b6af04b77a56 193 * @brief Flush any received data in serial RX buffer and terminate any commands on WiConnect WiFi module.
dan_ackme 29:b6af04b77a56 194 *
dan_ackme 29:b6af04b77a56 195 * The delayMs parameter is used as the delay between terminating commands on the module and flushing
dan_ackme 29:b6af04b77a56 196 * the serial RX buffer. This is needed because after terminating commands on the module, the module will
dan_ackme 29:b6af04b77a56 197 * returns a response. These responses are invalid at this point and should be flushed from the serial RX buffer.
dan_ackme 29:b6af04b77a56 198 *
dan_ackme 29:b6af04b77a56 199 * @param[in] delayMs Optional, if not specificed this only flushes the serial RX buffer.
dan_ackme 29:b6af04b77a56 200 */
dan_ackme 29:b6af04b77a56 201 void flush(int delayMs = 500);
dan_ackme 29:b6af04b77a56 202
dan_ackme 29:b6af04b77a56 203 /**
dan_ackme 29:b6af04b77a56 204 * @ingroup api_core_misc
dan_ackme 29:b6af04b77a56 205 *
dan_ackme 29:b6af04b77a56 206 * @brief Return current version of WiConnect WiFi module.
dan_ackme 29:b6af04b77a56 207 * @param[in] versionBuffer Optional, Buffer to hold received version string
dan_ackme 29:b6af04b77a56 208 * @param[in] versionBufferSize Optional, required if versionBuffer specified.
dan_ackme 29:b6af04b77a56 209 * @param[in] completeCallback Optional, callback when version is received. arg1 of callback contains version buffer pointer.
dan_ackme 29:b6af04b77a56 210 *
dan_ackme 29:b6af04b77a56 211 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 212 */
dan_ackme 29:b6af04b77a56 213 WiconnectResult getVersion(char *versionBuffer = NULL, int versionBufferSize = 0, const Callback &completeCallback = Callback());
dan_ackme 29:b6af04b77a56 214
dan_ackme 29:b6af04b77a56 215
dan_ackme 29:b6af04b77a56 216 /**
dan_ackme 29:b6af04b77a56 217 * @ingroup api_core_misc
dan_ackme 29:b6af04b77a56 218 *
dan_ackme 29:b6af04b77a56 219 * @brief Update the wifi module's internal firmware.
dan_ackme 29:b6af04b77a56 220 * @param[in] forced Optional, If true, force update of all firmware files to latest version, else only update out-dated files.
dan_ackme 29:b6af04b77a56 221 * @param[in] versionStr Optional, If specified, update to specific firmware version, else update to latest version.
dan_ackme 29:b6af04b77a56 222 * @param[in] completeCallback Optional, callback when update is complete. 'result' callback argument contains result of update.
dan_ackme 29:b6af04b77a56 223 *
dan_ackme 29:b6af04b77a56 224 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 225 */
dan_ackme 29:b6af04b77a56 226 WiconnectResult updateFirmware(bool forced = false, const char *versionStr = NULL, const Callback &completeCallback = Callback());
dan_ackme 29:b6af04b77a56 227
dan_ackme 29:b6af04b77a56 228
dan_ackme 29:b6af04b77a56 229 // ------------------------------------------------------------------------
dan_ackme 29:b6af04b77a56 230
dan_ackme 29:b6af04b77a56 231
dan_ackme 29:b6af04b77a56 232 /**
dan_ackme 29:b6af04b77a56 233 * @ingroup api_core_send_command
dan_ackme 29:b6af04b77a56 234 *
dan_ackme 29:b6af04b77a56 235 * @brief Send command to WiConnect WiFi module
dan_ackme 29:b6af04b77a56 236 *
dan_ackme 29:b6af04b77a56 237 * @note Refer to @ref send_command_desc for more info
dan_ackme 29:b6af04b77a56 238 *
dan_ackme 29:b6af04b77a56 239 * @param[in] completeCallback Callback when command completes. arg1 of callback contains responseBuffer pointer, arg2 contains the response length
dan_ackme 29:b6af04b77a56 240 * @param[in] responseBuffer Buffer to hold command response
dan_ackme 29:b6af04b77a56 241 * @param[in] responseBufferLen Length of responseBuffer
dan_ackme 29:b6af04b77a56 242 * @param[in] timeoutMs Maximum time in milliseconds this command should execute
dan_ackme 29:b6af04b77a56 243 * @param[in] reader Callback for reading data to be read from host and send to module during command
dan_ackme 29:b6af04b77a56 244 * @param[in] user User data struct used during read Callback. Library doesn't use this. Set NULL if not used.
dan_ackme 29:b6af04b77a56 245 * @param[in] cmd WiConnect command to send to module
dan_ackme 29:b6af04b77a56 246 * @param[in] vaList Varaible list of arguments
dan_ackme 29:b6af04b77a56 247 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 248 */
dan_ackme 29:b6af04b77a56 249 WiconnectResult sendCommand(const Callback &completeCallback, char *responseBuffer, int responseBufferLen,
dan_ackme 29:b6af04b77a56 250 TimerTimeout timeoutMs, const ReaderFunc &reader, void *user, const char *cmd, va_list vaList);
dan_ackme 29:b6af04b77a56 251 /**
dan_ackme 29:b6af04b77a56 252 * @ingroup api_core_send_command
dan_ackme 29:b6af04b77a56 253 *
dan_ackme 29:b6af04b77a56 254 * @brief Send command to WiConnect WiFi module
dan_ackme 29:b6af04b77a56 255 *
dan_ackme 29:b6af04b77a56 256 * @note Refer to @ref send_command_desc for more info
dan_ackme 29:b6af04b77a56 257 *
dan_ackme 29:b6af04b77a56 258 * @param[in] responseBuffer Buffer to hold command response
dan_ackme 29:b6af04b77a56 259 * @param[in] responseBufferLen Length of responseBuffer
dan_ackme 29:b6af04b77a56 260 * @param[in] timeoutMs Maximum time in milliseconds this command should execute
dan_ackme 29:b6af04b77a56 261 * @param[in] reader Callback for reading data to be read from host and send to module during command
dan_ackme 29:b6af04b77a56 262 * @param[in] user User data struct used during read Callback. Library doesn't use this. Set NULL if not used.
dan_ackme 29:b6af04b77a56 263 * @param[in] cmd WiConnect command to send to module
dan_ackme 29:b6af04b77a56 264 * @param[in] vaList Varaible list of arguments
dan_ackme 29:b6af04b77a56 265 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 266 */
dan_ackme 29:b6af04b77a56 267 WiconnectResult sendCommand(char *responseBuffer, int responseBufferLen, TimerTimeout timeoutMs, const ReaderFunc &reader,
dan_ackme 29:b6af04b77a56 268 void *user, const char *cmd, va_list vaList);
dan_ackme 29:b6af04b77a56 269
dan_ackme 29:b6af04b77a56 270 /**
dan_ackme 29:b6af04b77a56 271 * @ingroup api_core_send_command
dan_ackme 29:b6af04b77a56 272 *
dan_ackme 29:b6af04b77a56 273 * @brief Send command to WiConnect WiFi module
dan_ackme 29:b6af04b77a56 274 *
dan_ackme 29:b6af04b77a56 275 * @note Refer to @ref send_command_desc for more info
dan_ackme 29:b6af04b77a56 276 * @note This method supports variable arguments
dan_ackme 29:b6af04b77a56 277 *
dan_ackme 29:b6af04b77a56 278 * @param[in] responseBuffer Buffer to hold command response
dan_ackme 29:b6af04b77a56 279 * @param[in] responseBufferLen Length of responseBuffer
dan_ackme 29:b6af04b77a56 280 * @param[in] timeoutMs Maximum time in milliseconds this command should execute
dan_ackme 29:b6af04b77a56 281 * @param[in] reader Callback for reading data to be read from host and send to module during command
dan_ackme 29:b6af04b77a56 282 * @param[in] user User data struct used during read Callback. Library doesn't use this. Set NULL if not used.
dan_ackme 29:b6af04b77a56 283 * @param[in] cmd WiConnect command to send to module
dan_ackme 29:b6af04b77a56 284 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 285 */
dan_ackme 29:b6af04b77a56 286 WiconnectResult sendCommand(char *responseBuffer, int responseBufferLen, TimerTimeout timeoutMs, const ReaderFunc &reader,
dan_ackme 29:b6af04b77a56 287 void *user, const char *cmd, ...);
dan_ackme 29:b6af04b77a56 288
dan_ackme 29:b6af04b77a56 289 /**
dan_ackme 29:b6af04b77a56 290 * @ingroup api_core_send_command
dan_ackme 29:b6af04b77a56 291 *
dan_ackme 29:b6af04b77a56 292 * @brief Send command to WiConnect WiFi module
dan_ackme 29:b6af04b77a56 293 *
dan_ackme 29:b6af04b77a56 294 * This method uses the library internal buffer.
dan_ackme 29:b6af04b77a56 295 *
dan_ackme 29:b6af04b77a56 296 * @note Refer to @ref send_command_desc for more info
dan_ackme 29:b6af04b77a56 297 * @note This method supports variable arguments
dan_ackme 29:b6af04b77a56 298 *
dan_ackme 29:b6af04b77a56 299 * @param[in] timeoutMs Maximum time in milliseconds this command should execute
dan_ackme 29:b6af04b77a56 300 * @param[in] reader Callback for reading data to be read from host and send to module during command
dan_ackme 29:b6af04b77a56 301 * @param[in] user User data struct used during read Callback. Library doesn't use this. Set NULL if not used.
dan_ackme 29:b6af04b77a56 302 * @param[in] cmd WiConnect command to send to module
dan_ackme 29:b6af04b77a56 303 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 304 */
dan_ackme 29:b6af04b77a56 305 WiconnectResult sendCommand(TimerTimeout timeoutMs, const ReaderFunc &reader, void *user, const char *cmd, ...);
dan_ackme 29:b6af04b77a56 306
dan_ackme 29:b6af04b77a56 307 /**
dan_ackme 29:b6af04b77a56 308 * @ingroup api_core_send_command
dan_ackme 29:b6af04b77a56 309 *
dan_ackme 29:b6af04b77a56 310 * @brief Send command to WiConnect WiFi module
dan_ackme 29:b6af04b77a56 311 *
dan_ackme 29:b6af04b77a56 312 * - This method uses the library internal buffer and
dan_ackme 29:b6af04b77a56 313 * - default timeout. See setCommandDefaultTimeout()
dan_ackme 29:b6af04b77a56 314 *
dan_ackme 29:b6af04b77a56 315 * @note Refer to @ref send_command_desc for more info
dan_ackme 29:b6af04b77a56 316 * @note This method supports variable arguments
dan_ackme 29:b6af04b77a56 317 *
dan_ackme 29:b6af04b77a56 318 * @param[in] reader Callback for reading data to be read from host and send to module during command
dan_ackme 29:b6af04b77a56 319 * @param[in] user User data struct used during read Callback. Library doesn't use this. Set NULL if not used.
dan_ackme 29:b6af04b77a56 320 * @param[in] cmd WiConnect command to send to module
dan_ackme 29:b6af04b77a56 321 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 322 */
dan_ackme 29:b6af04b77a56 323 WiconnectResult sendCommand(const ReaderFunc &reader, void *user, const char *cmd, ...);
dan_ackme 29:b6af04b77a56 324
dan_ackme 29:b6af04b77a56 325 /**
dan_ackme 29:b6af04b77a56 326 * @ingroup api_core_send_command
dan_ackme 29:b6af04b77a56 327 *
dan_ackme 29:b6af04b77a56 328 * @brief Send command to WiConnect WiFi module
dan_ackme 29:b6af04b77a56 329 *
dan_ackme 29:b6af04b77a56 330 * @note Refer to @ref send_command_desc for more info
dan_ackme 29:b6af04b77a56 331 * @note This method supports variable arguments
dan_ackme 29:b6af04b77a56 332 *
dan_ackme 29:b6af04b77a56 333 * @param[in] responseBuffer Buffer to hold command response
dan_ackme 29:b6af04b77a56 334 * @param[in] responseBufferLen Length of responseBuffer
dan_ackme 29:b6af04b77a56 335 * @param[in] timeoutMs Maximum time in milliseconds this command should execute
dan_ackme 29:b6af04b77a56 336 * @param[in] cmd WiConnect command to send to module
dan_ackme 29:b6af04b77a56 337 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 338 */
dan_ackme 29:b6af04b77a56 339 WiconnectResult sendCommand(char *responseBuffer, int responseBufferLen, TimerTimeout timeoutMs, const char *cmd, ...);
dan_ackme 29:b6af04b77a56 340
dan_ackme 29:b6af04b77a56 341 /**
dan_ackme 29:b6af04b77a56 342 * @ingroup api_core_send_command
dan_ackme 29:b6af04b77a56 343 *
dan_ackme 29:b6af04b77a56 344 * @brief Send command to WiConnect WiFi module
dan_ackme 29:b6af04b77a56 345 *
dan_ackme 29:b6af04b77a56 346 * @note Refer to @ref send_command_desc for more info
dan_ackme 29:b6af04b77a56 347 * @note This method supports variable arguments
dan_ackme 29:b6af04b77a56 348 *
dan_ackme 29:b6af04b77a56 349 * @param[in] completeCallback Callback when command completes. arg1 of callback contains responseBuffer pointer, arg2 contains the response length
dan_ackme 29:b6af04b77a56 350 * @param[in] responseBuffer Buffer to hold command response
dan_ackme 29:b6af04b77a56 351 * @param[in] responseBufferLen Length of responseBuffer
dan_ackme 29:b6af04b77a56 352 * @param[in] cmd WiConnect command to send to module
dan_ackme 29:b6af04b77a56 353 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 354 */
dan_ackme 29:b6af04b77a56 355 WiconnectResult sendCommand(const Callback &completeCallback, char *responseBuffer, int responseBufferLen, const char *cmd, ...);
dan_ackme 29:b6af04b77a56 356
dan_ackme 29:b6af04b77a56 357 /**
dan_ackme 29:b6af04b77a56 358 * @ingroup api_core_send_command
dan_ackme 29:b6af04b77a56 359 *
dan_ackme 29:b6af04b77a56 360 * @brief Send command to WiConnect WiFi module
dan_ackme 29:b6af04b77a56 361 *
dan_ackme 29:b6af04b77a56 362 * @note Refer to @ref send_command_desc for more info
dan_ackme 29:b6af04b77a56 363 * @note This method supports variable arguments
dan_ackme 29:b6af04b77a56 364 *
dan_ackme 29:b6af04b77a56 365 * @param[in] responseBuffer Buffer to hold command response
dan_ackme 29:b6af04b77a56 366 * @param[in] responseBufferLen Length of responseBuffer
dan_ackme 29:b6af04b77a56 367 * @param[in] cmd WiConnect command to send to module
dan_ackme 29:b6af04b77a56 368 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 369 */
dan_ackme 29:b6af04b77a56 370 WiconnectResult sendCommand(char *responseBuffer, int responseBufferLen, const char *cmd, ...);
dan_ackme 29:b6af04b77a56 371
dan_ackme 29:b6af04b77a56 372 /**
dan_ackme 29:b6af04b77a56 373 * @ingroup api_core_send_command
dan_ackme 29:b6af04b77a56 374 *
dan_ackme 29:b6af04b77a56 375 * @brief Send command to WiConnect WiFi module
dan_ackme 29:b6af04b77a56 376 *
dan_ackme 29:b6af04b77a56 377 * - This method uses the library internal buffer and
dan_ackme 29:b6af04b77a56 378 * - default timeout. See setCommandDefaultTimeout()
dan_ackme 29:b6af04b77a56 379 *
dan_ackme 29:b6af04b77a56 380 * @note Refer to @ref send_command_desc for more info
dan_ackme 29:b6af04b77a56 381 * @note This method supports variable arguments
dan_ackme 29:b6af04b77a56 382 *
dan_ackme 29:b6af04b77a56 383 * @param[in] completeCallback Callback when command completes. arg1 of callback contains responseBuffer pointer, arg2 contains the response length
dan_ackme 29:b6af04b77a56 384 * @param[in] cmd WiConnect command to send to module
dan_ackme 29:b6af04b77a56 385 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 386 */
dan_ackme 29:b6af04b77a56 387 WiconnectResult sendCommand(const Callback &completeCallback, const char *cmd, ...);
dan_ackme 29:b6af04b77a56 388
dan_ackme 29:b6af04b77a56 389 /**
dan_ackme 29:b6af04b77a56 390 * @ingroup api_core_send_command
dan_ackme 29:b6af04b77a56 391 *
dan_ackme 29:b6af04b77a56 392 * @brief Send command to WiConnect WiFi module
dan_ackme 29:b6af04b77a56 393 *
dan_ackme 29:b6af04b77a56 394 * - This method uses the library internal buffer and
dan_ackme 29:b6af04b77a56 395 * - default timeout. See setCommandDefaultTimeout()
dan_ackme 29:b6af04b77a56 396 *
dan_ackme 29:b6af04b77a56 397 * @note Refer to @ref send_command_desc for more info
dan_ackme 29:b6af04b77a56 398 * @note This method supports variable arguments
dan_ackme 29:b6af04b77a56 399 *
dan_ackme 29:b6af04b77a56 400 * @param[in] cmd WiConnect command to send to module
dan_ackme 29:b6af04b77a56 401 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 402 */
dan_ackme 29:b6af04b77a56 403 WiconnectResult sendCommand(const char *cmd, ...);
dan_ackme 29:b6af04b77a56 404
dan_ackme 29:b6af04b77a56 405 /**
dan_ackme 29:b6af04b77a56 406 * @ingroup api_core_send_command
dan_ackme 29:b6af04b77a56 407 *
dan_ackme 29:b6af04b77a56 408 * This method uses the library internal buffer
dan_ackme 29:b6af04b77a56 409 *
dan_ackme 29:b6af04b77a56 410 * @note Refer to @ref send_command_desc for more info
dan_ackme 29:b6af04b77a56 411 * @note This method supports variable arguments
dan_ackme 29:b6af04b77a56 412 *
dan_ackme 29:b6af04b77a56 413 * @param[in] completeCallback Callback when command completes. arg1 of callback contains responseBuffer pointer, arg2 contains the response length
dan_ackme 29:b6af04b77a56 414 * @param[in] timeoutMs Maximum time in milliseconds this command should execute
dan_ackme 29:b6af04b77a56 415 * @param[in] cmd WiConnect command to send to module
dan_ackme 29:b6af04b77a56 416 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 417 */
dan_ackme 29:b6af04b77a56 418 WiconnectResult sendCommand(const Callback &completeCallback, TimerTimeout timeoutMs, const char *cmd, ...);
dan_ackme 29:b6af04b77a56 419
dan_ackme 29:b6af04b77a56 420 /**
dan_ackme 29:b6af04b77a56 421 * @ingroup api_core_send_command
dan_ackme 29:b6af04b77a56 422 *
dan_ackme 29:b6af04b77a56 423 * @brief Send command to WiConnect WiFi module
dan_ackme 29:b6af04b77a56 424 *
dan_ackme 29:b6af04b77a56 425 * This method uses the library internal buffer
dan_ackme 29:b6af04b77a56 426 *
dan_ackme 29:b6af04b77a56 427 * @note Refer to @ref send_command_desc for more info
dan_ackme 29:b6af04b77a56 428 * @note This method supports variable arguments
dan_ackme 29:b6af04b77a56 429 *
dan_ackme 29:b6af04b77a56 430 * @param[in] timeoutMs Maximum time in milliseconds this command should execute
dan_ackme 29:b6af04b77a56 431 * @param[in] cmd WiConnect command to send to module
dan_ackme 29:b6af04b77a56 432 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 433 */
dan_ackme 29:b6af04b77a56 434 WiconnectResult sendCommand(TimerTimeout timeoutMs, const char *cmd, ...);
dan_ackme 29:b6af04b77a56 435
dan_ackme 29:b6af04b77a56 436 /**
dan_ackme 29:b6af04b77a56 437 * @ingroup api_core_send_command
dan_ackme 29:b6af04b77a56 438 *
dan_ackme 29:b6af04b77a56 439 * - This method uses the library internal buffer and
dan_ackme 29:b6af04b77a56 440 * - default timeout. See setCommandDefaultTimeout()
dan_ackme 29:b6af04b77a56 441 *
dan_ackme 29:b6af04b77a56 442 * @note Refer to @ref send_command_desc for more info
dan_ackme 29:b6af04b77a56 443 *
dan_ackme 29:b6af04b77a56 444 * @param[in] cmd WiConnect command to send to module
dan_ackme 29:b6af04b77a56 445 * @param[in] vaList Varaible list of arguments
dan_ackme 29:b6af04b77a56 446 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 447 */
dan_ackme 29:b6af04b77a56 448 WiconnectResult sendCommand(const char *cmd, va_list vaList);
dan_ackme 29:b6af04b77a56 449
dan_ackme 29:b6af04b77a56 450 /**
dan_ackme 29:b6af04b77a56 451 * @ingroup api_core_send_command
dan_ackme 29:b6af04b77a56 452 *
dan_ackme 29:b6af04b77a56 453 * @brief Check the status of the currently executing command.
dan_ackme 29:b6af04b77a56 454 *
dan_ackme 29:b6af04b77a56 455 * Refer to @ref WiconnectResult for more information about the return code.
dan_ackme 29:b6af04b77a56 456 *
dan_ackme 29:b6af04b77a56 457 * @note This command is only applicable for non-blocking mode. Refer to @ref setting_blocking_modes.
dan_ackme 29:b6af04b77a56 458 *
dan_ackme 29:b6af04b77a56 459 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 460 */
dan_ackme 29:b6af04b77a56 461 WiconnectResult checkCurrentCommand();
dan_ackme 29:b6af04b77a56 462
dan_ackme 29:b6af04b77a56 463 /**
dan_ackme 29:b6af04b77a56 464 * @ingroup api_core_send_command
dan_ackme 29:b6af04b77a56 465 *
dan_ackme 29:b6af04b77a56 466 * @brief Stop the currently executing command.
dan_ackme 29:b6af04b77a56 467 *
dan_ackme 29:b6af04b77a56 468 * @note This command is only applicable for non-blocking mode. Refer to @ref setting_blocking_modes.
dan_ackme 29:b6af04b77a56 469 */
dan_ackme 29:b6af04b77a56 470 void stopCurrentCommand();
dan_ackme 29:b6af04b77a56 471
dan_ackme 29:b6af04b77a56 472
dan_ackme 29:b6af04b77a56 473 // ------------------------------------------------------------------------
dan_ackme 29:b6af04b77a56 474
dan_ackme 29:b6af04b77a56 475
dan_ackme 29:b6af04b77a56 476 /**
dan_ackme 29:b6af04b77a56 477 * @ingroup api_core_misc
dan_ackme 29:b6af04b77a56 478 *
dan_ackme 29:b6af04b77a56 479 * @brief When the WiConnect WiFi module returns a response, it contains a
dan_ackme 29:b6af04b77a56 480 * response code in the header. This function converts the previous response code
dan_ackme 29:b6af04b77a56 481 * to a readable string.
dan_ackme 29:b6af04b77a56 482 *
dan_ackme 29:b6af04b77a56 483 * @return string representation of module response code
dan_ackme 29:b6af04b77a56 484 */
dan_ackme 29:b6af04b77a56 485 const char* getLastCommandResponseCodeStr();
dan_ackme 29:b6af04b77a56 486
dan_ackme 29:b6af04b77a56 487 /**
dan_ackme 29:b6af04b77a56 488 * @ingroup api_core_misc
dan_ackme 29:b6af04b77a56 489 *
dan_ackme 29:b6af04b77a56 490 * @brief Return the length in bytes of the previous response.
dan_ackme 29:b6af04b77a56 491 *
dan_ackme 29:b6af04b77a56 492 * @return length of previous response
dan_ackme 29:b6af04b77a56 493 */
dan_ackme 29:b6af04b77a56 494 uint16_t getLastCommandResponseLength();
dan_ackme 29:b6af04b77a56 495
dan_ackme 29:b6af04b77a56 496 /**
dan_ackme 29:b6af04b77a56 497 * @ingroup api_core_misc
dan_ackme 29:b6af04b77a56 498 *
dan_ackme 29:b6af04b77a56 499 * @brief Return pointer to internal response buffer.
dan_ackme 29:b6af04b77a56 500 *
dan_ackme 29:b6af04b77a56 501 * @return pointer to internal response buffer
dan_ackme 29:b6af04b77a56 502 */
dan_ackme 29:b6af04b77a56 503 char* getResponseBuffer();
dan_ackme 29:b6af04b77a56 504
dan_ackme 29:b6af04b77a56 505 /**
dan_ackme 29:b6af04b77a56 506 * @ingroup api_core_misc
dan_ackme 29:b6af04b77a56 507 *
dan_ackme 29:b6af04b77a56 508 * @brief Helper method to convert previous response to uint32
dan_ackme 29:b6af04b77a56 509 *
dan_ackme 29:b6af04b77a56 510 * @note This uses the internal response buffer.
dan_ackme 29:b6af04b77a56 511 *
dan_ackme 29:b6af04b77a56 512 * @param[out] uint32Ptr Pointer to hold result of conversion.
dan_ackme 29:b6af04b77a56 513 * @return Result of conversion. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 514 */
dan_ackme 29:b6af04b77a56 515 WiconnectResult responseToUint32(uint32_t *uint32Ptr);
dan_ackme 29:b6af04b77a56 516
dan_ackme 29:b6af04b77a56 517 /**
dan_ackme 29:b6af04b77a56 518 * @ingroup api_core_misc
dan_ackme 29:b6af04b77a56 519 *
dan_ackme 29:b6af04b77a56 520 * @brief Helper method to convert previous response to int32
dan_ackme 29:b6af04b77a56 521 *
dan_ackme 29:b6af04b77a56 522 * @note This uses the internal response buffer.
dan_ackme 29:b6af04b77a56 523 *
dan_ackme 29:b6af04b77a56 524 * @param[out] int32Ptr Pointer to hold result of conversion.
dan_ackme 29:b6af04b77a56 525 * @return Result of conversion. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 526 */
dan_ackme 29:b6af04b77a56 527 WiconnectResult responseToInt32(int32_t *int32Ptr);
dan_ackme 29:b6af04b77a56 528
dan_ackme 29:b6af04b77a56 529
dan_ackme 29:b6af04b77a56 530 // ------------------------------------------------------------------------
dan_ackme 29:b6af04b77a56 531
dan_ackme 29:b6af04b77a56 532 /**
dan_ackme 29:b6af04b77a56 533 * @ingroup api_core_settings
dan_ackme 29:b6af04b77a56 534 *
dan_ackme 29:b6af04b77a56 535 * @brief Set a module setting
dan_ackme 29:b6af04b77a56 536 *
dan_ackme 29:b6af04b77a56 537 * Refer to: http://wiconnect.ack.me/2.0/variables
dan_ackme 29:b6af04b77a56 538 * for a list of the available settings and descriptions
dan_ackme 29:b6af04b77a56 539 *
dan_ackme 29:b6af04b77a56 540 * @param settingStr String module setting name.
dan_ackme 29:b6af04b77a56 541 * @param value The integer value to set
dan_ackme 29:b6af04b77a56 542 *
dan_ackme 29:b6af04b77a56 543 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 544 */
dan_ackme 29:b6af04b77a56 545 WiconnectResult setSetting(const char *settingStr, uint32_t value);
dan_ackme 29:b6af04b77a56 546
dan_ackme 29:b6af04b77a56 547 /**
dan_ackme 29:b6af04b77a56 548 * @ingroup api_core_settings
dan_ackme 29:b6af04b77a56 549 *
dan_ackme 29:b6af04b77a56 550 * @brief Set a module setting
dan_ackme 29:b6af04b77a56 551 *
dan_ackme 29:b6af04b77a56 552 * Refer to: http://wiconnect.ack.me/2.0/variables
dan_ackme 29:b6af04b77a56 553 * for a list of the available settings and descriptions
dan_ackme 29:b6af04b77a56 554 *
dan_ackme 29:b6af04b77a56 555 * @param settingStr String module setting name.
dan_ackme 29:b6af04b77a56 556 * @param value The string value to set
dan_ackme 29:b6af04b77a56 557 *
dan_ackme 29:b6af04b77a56 558 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 559 */
dan_ackme 29:b6af04b77a56 560 WiconnectResult setSetting(const char *settingStr, const char *value);
dan_ackme 29:b6af04b77a56 561
dan_ackme 29:b6af04b77a56 562 /**
dan_ackme 29:b6af04b77a56 563 * @ingroup api_core_settings
dan_ackme 29:b6af04b77a56 564 *
dan_ackme 29:b6af04b77a56 565 * @brief Get a module setting
dan_ackme 29:b6af04b77a56 566 *
dan_ackme 29:b6af04b77a56 567 * Refer to: http://wiconnect.ack.me/2.0/variables
dan_ackme 29:b6af04b77a56 568 * for a list of the available settings and descriptions
dan_ackme 29:b6af04b77a56 569 *
dan_ackme 29:b6af04b77a56 570 * @param settingStr String module setting name.
dan_ackme 29:b6af04b77a56 571 * @param valuePtr Pointer to buffer to contain integer value
dan_ackme 29:b6af04b77a56 572 *
dan_ackme 29:b6af04b77a56 573 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 574 */
dan_ackme 29:b6af04b77a56 575 WiconnectResult getSetting(const char *settingStr, uint32_t *valuePtr);
dan_ackme 29:b6af04b77a56 576
dan_ackme 29:b6af04b77a56 577 /**
dan_ackme 29:b6af04b77a56 578 * @ingroup api_core_settings
dan_ackme 29:b6af04b77a56 579 *
dan_ackme 29:b6af04b77a56 580 * @brief Get a module setting
dan_ackme 29:b6af04b77a56 581 *
dan_ackme 29:b6af04b77a56 582 * Refer to: http://wiconnect.ack.me/2.0/variables
dan_ackme 29:b6af04b77a56 583 * for a list of the available settings and descriptions
dan_ackme 29:b6af04b77a56 584 *
dan_ackme 29:b6af04b77a56 585 * @param settingStr String module setting name.
dan_ackme 29:b6af04b77a56 586 * @param valuePtr Pointer to hold pointer to internal API buffer containing retrieved setting result
dan_ackme 29:b6af04b77a56 587 *
dan_ackme 29:b6af04b77a56 588 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 589 */
dan_ackme 29:b6af04b77a56 590 WiconnectResult getSetting(const char *settingStr, char **valuePtr);
dan_ackme 29:b6af04b77a56 591
dan_ackme 29:b6af04b77a56 592 /**
dan_ackme 29:b6af04b77a56 593 * @ingroup api_core_settings
dan_ackme 29:b6af04b77a56 594 *
dan_ackme 29:b6af04b77a56 595 * @brief Get a module setting
dan_ackme 29:b6af04b77a56 596 *
dan_ackme 29:b6af04b77a56 597 * Refer to: http://wiconnect.ack.me/2.0/variables
dan_ackme 29:b6af04b77a56 598 * for a list of the available settings and descriptions
dan_ackme 29:b6af04b77a56 599 *
dan_ackme 29:b6af04b77a56 600 * @param settingStr String module setting name.
dan_ackme 29:b6af04b77a56 601 * @param valueBuffer Buffer to hold retrieved setting result
dan_ackme 29:b6af04b77a56 602 * @param valueBufferLen The length of the input buffer
dan_ackme 29:b6af04b77a56 603 *
dan_ackme 29:b6af04b77a56 604 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 605 */
dan_ackme 29:b6af04b77a56 606 WiconnectResult getSetting(const char *settingStr, char *valueBuffer, uint16_t valueBufferLen);
dan_ackme 29:b6af04b77a56 607
dan_ackme 29:b6af04b77a56 608
dan_ackme 29:b6af04b77a56 609 /**
dan_ackme 29:b6af04b77a56 610 * @ingroup api_core_settings
dan_ackme 29:b6af04b77a56 611 *
dan_ackme 29:b6af04b77a56 612 * @brief Sets if API calls are blocking or non-blocking.
dan_ackme 29:b6af04b77a56 613 *
dan_ackme 29:b6af04b77a56 614 * @param[in] blockingEnabled The new blocking value
dan_ackme 29:b6af04b77a56 615 */
dan_ackme 29:b6af04b77a56 616 void setBlockingEnabled(bool blockingEnabled);
dan_ackme 29:b6af04b77a56 617
dan_ackme 29:b6af04b77a56 618 /**
dan_ackme 29:b6af04b77a56 619 * @ingroup api_core_settings
dan_ackme 29:b6af04b77a56 620 *
dan_ackme 29:b6af04b77a56 621 * @brief Gets if API calls are blocking or non-blocking.
dan_ackme 29:b6af04b77a56 622 */
dan_ackme 29:b6af04b77a56 623 bool getBlockingEnabled(void);
dan_ackme 29:b6af04b77a56 624
dan_ackme 29:b6af04b77a56 625 /**
dan_ackme 29:b6af04b77a56 626 * @ingroup api_core_settings
dan_ackme 29:b6af04b77a56 627 *
dan_ackme 29:b6af04b77a56 628 * @brief Sets the default maximum time an API method may execute before
dan_ackme 29:b6af04b77a56 629 * terminating and return a timeout error code.
dan_ackme 29:b6af04b77a56 630 *
dan_ackme 29:b6af04b77a56 631 * @note All API methods (execpt some sendCommand()) use this default value.
dan_ackme 29:b6af04b77a56 632 *
dan_ackme 29:b6af04b77a56 633 * @param[in] timeoutMs Default command timeout in milliseconds
dan_ackme 29:b6af04b77a56 634 */
dan_ackme 29:b6af04b77a56 635 void setCommandDefaultTimeout(TimerTimeout timeoutMs);
dan_ackme 29:b6af04b77a56 636
dan_ackme 29:b6af04b77a56 637 /**
dan_ackme 29:b6af04b77a56 638 * @ingroup api_core_settings
dan_ackme 29:b6af04b77a56 639 *
dan_ackme 29:b6af04b77a56 640 * @brief Returns the current default maximum API execution time.
dan_ackme 29:b6af04b77a56 641 *
dan_ackme 29:b6af04b77a56 642 * @return Default command timeout in milliseconds
dan_ackme 29:b6af04b77a56 643 */
dan_ackme 29:b6af04b77a56 644 TimerTimeout getCommandDefaultTimeout();
dan_ackme 29:b6af04b77a56 645
dan_ackme 29:b6af04b77a56 646 /**
dan_ackme 29:b6af04b77a56 647 * @ingroup api_core_settings
dan_ackme 29:b6af04b77a56 648 *
dan_ackme 29:b6af04b77a56 649 * @brief Sets a mapping function used to convert from a host Pin to WiConnect WiFi module GPIO.
dan_ackme 29:b6af04b77a56 650 *
dan_ackme 29:b6af04b77a56 651 * @param[in] mapper Pin to GPIO mapper function pointer
dan_ackme 29:b6af04b77a56 652 */
dan_ackme 29:b6af04b77a56 653 void setPinToGpioMapper(PinToGpioMapper mapper);
dan_ackme 29:b6af04b77a56 654
dan_ackme 29:b6af04b77a56 655 /**
dan_ackme 29:b6af04b77a56 656 * @ingroup api_core_settings
dan_ackme 29:b6af04b77a56 657 *
dan_ackme 29:b6af04b77a56 658 * @brief Sets callback function used to debug WiConnect WiFi module RX/TX serial data.
dan_ackme 29:b6af04b77a56 659 *
dan_ackme 29:b6af04b77a56 660 * @param[in] logFunc Logging function pointer
dan_ackme 29:b6af04b77a56 661 */
dan_ackme 29:b6af04b77a56 662 void setDebugLogger(LogFunc logFunc);
dan_ackme 29:b6af04b77a56 663
dan_ackme 29:b6af04b77a56 664 /**
dan_ackme 29:b6af04b77a56 665 * @ingroup api_core_settings
dan_ackme 29:b6af04b77a56 666 *
dan_ackme 29:b6af04b77a56 667 * @brief Sets callback used when Wiconnect Library hits and internal assertion.
dan_ackme 29:b6af04b77a56 668 *
dan_ackme 29:b6af04b77a56 669 * @note This is mainly for debugging. There's nothing the callback can do to fix the assertion.
dan_ackme 29:b6af04b77a56 670 *
dan_ackme 29:b6af04b77a56 671 * @param[in] assertLogFunc Logging function pointer
dan_ackme 29:b6af04b77a56 672 */
dan_ackme 29:b6af04b77a56 673 void setAssertLogger(LogFunc assertLogFunc);
dan_ackme 29:b6af04b77a56 674
dan_ackme 29:b6af04b77a56 675 // ------------------------------------------------------------------------
dan_ackme 29:b6af04b77a56 676
dan_ackme 29:b6af04b77a56 677
dan_ackme 29:b6af04b77a56 678 #ifdef WICONNECT_ASYNC_TIMER_ENABLED
dan_ackme 29:b6af04b77a56 679 /**
dan_ackme 29:b6af04b77a56 680 * @ingroup api_core_send_command
dan_ackme 29:b6af04b77a56 681 *
dan_ackme 29:b6af04b77a56 682 * @brief Add user command to be executed asynchronously.
dan_ackme 29:b6af04b77a56 683 *
dan_ackme 29:b6af04b77a56 684 * Refer to @ref setting_async_processing for more info.
dan_ackme 29:b6af04b77a56 685 *
dan_ackme 29:b6af04b77a56 686 * @param[in] command Pointer to QueuedCommand to be executed asynchronously
dan_ackme 29:b6af04b77a56 687 * @param[in] commandCompleteHandler Callback to be executed when processing is complete.
dan_ackme 29:b6af04b77a56 688 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 689 */
dan_ackme 29:b6af04b77a56 690 WiconnectResult enqueueCommand(QueuedCommand *command, const Callback &commandCompleteHandler = Callback());
dan_ackme 29:b6af04b77a56 691
dan_ackme 29:b6af04b77a56 692 /**
dan_ackme 29:b6af04b77a56 693 * @ingroup api_core_settings
dan_ackme 29:b6af04b77a56 694 *
dan_ackme 29:b6af04b77a56 695 * @brief Set the period at which an asynchronous command should be processed.
dan_ackme 29:b6af04b77a56 696 *
dan_ackme 29:b6af04b77a56 697 * Refer to @ref setting_async_processing for more info.
dan_ackme 29:b6af04b77a56 698 *
dan_ackme 29:b6af04b77a56 699 * @param[in] periodMs Processing period in milliseconds
dan_ackme 29:b6af04b77a56 700 */
dan_ackme 29:b6af04b77a56 701 void setCommandProcessingPeriod(uint32_t periodMs);
dan_ackme 29:b6af04b77a56 702 #endif
dan_ackme 29:b6af04b77a56 703
dan_ackme 29:b6af04b77a56 704
dan_ackme 29:b6af04b77a56 705 /**
dan_ackme 29:b6af04b77a56 706 * @ingroup conversion_util
dan_ackme 29:b6af04b77a56 707 *
dan_ackme 29:b6af04b77a56 708 * @brief Converts a @ref WiconnectResult to string representation.
dan_ackme 29:b6af04b77a56 709 *
dan_ackme 29:b6af04b77a56 710 * @param[in] wiconnectResult Result code
dan_ackme 29:b6af04b77a56 711 * @return String representaion of result code
dan_ackme 29:b6af04b77a56 712 */
dan_ackme 29:b6af04b77a56 713 static const char* getWiconnectResultStr(WiconnectResult wiconnectResult);
dan_ackme 29:b6af04b77a56 714
dan_ackme 29:b6af04b77a56 715 protected:
dan_ackme 29:b6af04b77a56 716
dan_ackme 29:b6af04b77a56 717 #ifdef WICONNECT_ENABLE_MALLOC
dan_ackme 29:b6af04b77a56 718 void* (*_malloc)(size_t);
dan_ackme 29:b6af04b77a56 719 void (*_free)(void *);
dan_ackme 29:b6af04b77a56 720 friend class QueuedCommand;
dan_ackme 29:b6af04b77a56 721 friend class WiconnectSerial;
dan_ackme 29:b6af04b77a56 722 friend class ScanResult;
dan_ackme 29:b6af04b77a56 723 #endif
dan_ackme 29:b6af04b77a56 724
dan_ackme 29:b6af04b77a56 725 wiconnect::WiconnectSerial serial;
dan_ackme 29:b6af04b77a56 726 wiconnect::Gpio resetGpio;
dan_ackme 29:b6af04b77a56 727 wiconnect::Gpio wakeGpio;
dan_ackme 29:b6af04b77a56 728
dan_ackme 29:b6af04b77a56 729 volatile bool commandExecuting;
dan_ackme 29:b6af04b77a56 730 bool initialized;
dan_ackme 29:b6af04b77a56 731 bool nonBlocking;
dan_ackme 29:b6af04b77a56 732
dan_ackme 29:b6af04b77a56 733 PinToGpioMapper pinToGpioMapper;
dan_ackme 29:b6af04b77a56 734
dan_ackme 29:b6af04b77a56 735 char *internalBuffer;
dan_ackme 29:b6af04b77a56 736 int internalBufferSize;
dan_ackme 29:b6af04b77a56 737 bool internalBufferAlloc;
dan_ackme 29:b6af04b77a56 738 uint8_t internalProcessingState;
dan_ackme 29:b6af04b77a56 739 void *currentCommandId;
dan_ackme 29:b6af04b77a56 740
dan_ackme 29:b6af04b77a56 741 wiconnect::TimeoutTimer timeoutTimer;
dan_ackme 29:b6af04b77a56 742 TimerTimeout defaultTimeoutMs;
dan_ackme 29:b6af04b77a56 743
dan_ackme 29:b6af04b77a56 744 uint8_t commandHeaderBuffer[32];
dan_ackme 29:b6af04b77a56 745 char commandFormatBuffer[WICONNECT_MAX_CMD_SIZE];
dan_ackme 29:b6af04b77a56 746 uint8_t commandContext[96];
dan_ackme 29:b6af04b77a56 747
dan_ackme 29:b6af04b77a56 748 void prepare(void *internalBuffer, int internalBufferSize, bool nonBlocking);
dan_ackme 29:b6af04b77a56 749 bool configureModuleDataBus(void);
dan_ackme 29:b6af04b77a56 750 WiconnectResult inline receiveResponse();
dan_ackme 29:b6af04b77a56 751 WiconnectResult inline receivePacket();
dan_ackme 29:b6af04b77a56 752 void issueCommandCallback(WiconnectResult result);
dan_ackme 29:b6af04b77a56 753
dan_ackme 29:b6af04b77a56 754 #ifdef WICONNECT_ENABLE_DEBUGGING
dan_ackme 29:b6af04b77a56 755 LogFunc debugLogger;
dan_ackme 29:b6af04b77a56 756 #endif
dan_ackme 29:b6af04b77a56 757 LogFunc assertLogger;
dan_ackme 29:b6af04b77a56 758
dan_ackme 29:b6af04b77a56 759 void debugLog(const char *msg, ...);
dan_ackme 29:b6af04b77a56 760
dan_ackme 29:b6af04b77a56 761 #ifdef WICONNECT_ASYNC_TIMER_ENABLED
dan_ackme 29:b6af04b77a56 762 wiconnect::PeriodicTimer commandProcessorTimer;
dan_ackme 29:b6af04b77a56 763 uint32_t commandProcessingPeriod;
dan_ackme 29:b6af04b77a56 764 CommandQueue commandQueue;
dan_ackme 29:b6af04b77a56 765 wiconnect::QueuedCommand *currentQueuedCommand;
dan_ackme 29:b6af04b77a56 766
dan_ackme 29:b6af04b77a56 767 void commandProcessingTimerHandler(void);
dan_ackme 29:b6af04b77a56 768 void processNextQueuedCommand();
dan_ackme 29:b6af04b77a56 769 void checkQueuedCommandTimeout();
dan_ackme 29:b6af04b77a56 770 #endif
dan_ackme 29:b6af04b77a56 771
dan_ackme 29:b6af04b77a56 772 friend class NetworkInterface;
dan_ackme 29:b6af04b77a56 773 friend class SocketInterface;
dan_ackme 29:b6af04b77a56 774 friend class FileInterface;
dan_ackme 29:b6af04b77a56 775 friend class GhmInterface;
dan_ackme 29:b6af04b77a56 776 friend class GhmMessageList;
dan_ackme 29:b6af04b77a56 777 friend class GhmMessage;
dan_ackme 29:b6af04b77a56 778 friend class ScanResultList;
dan_ackme 29:b6af04b77a56 779 friend class WiconnectFile;
dan_ackme 29:b6af04b77a56 780 friend class WiconnectSocket;
dan_ackme 29:b6af04b77a56 781 friend class WiconnectUdpServer;
dan_ackme 29:b6af04b77a56 782 };
dan_ackme 29:b6af04b77a56 783
dan_ackme 29:b6af04b77a56 784 }
dan_ackme 29:b6af04b77a56 785
dan_ackme 29:b6af04b77a56 786
dan_ackme 29:b6af04b77a56 787 #include "sdkTypes.h"
dan_ackme 29:b6af04b77a56 788