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:
aymangrais
Date:
Mon Sep 28 03:38:43 2015 +0000
Revision:
42:8ffb253b09e7
Parent:
37:5ee74d72efe4
increase ota timeout to be 5 seconds (instead of 1.5 sec)

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 34:2616445d0823 166 * @brief Return TRUE if the WiFi module's firmware supports the SDK version,
dan_ackme 34:2616445d0823 167 * FALSE if the WiFi module's firmware needs to be updated. See
dan_ackme 34:2616445d0823 168 * @ref updateFirmware() to update the module's firmware.
dan_ackme 34:2616445d0823 169 *
dan_ackme 34:2616445d0823 170 * @return TRUE WiFi firmware version is supported, FALSE else
dan_ackme 34:2616445d0823 171 */
dan_ackme 34:2616445d0823 172 bool updateRequired();
dan_ackme 34:2616445d0823 173
dan_ackme 34:2616445d0823 174 /**
dan_ackme 34:2616445d0823 175 * @ingroup api_core_misc
dan_ackme 34:2616445d0823 176 *
dan_ackme 29:b6af04b77a56 177 * @brief Toggle the WiConnect WiFi module reset signal.
dan_ackme 29:b6af04b77a56 178 *
dan_ackme 29:b6af04b77a56 179 * @note This only resets the module if the library was instantiated with the 'reset' pin
dan_ackme 29:b6af04b77a56 180 * parameter in the Wiconnect::Wiconnect constructor.
dan_ackme 29:b6af04b77a56 181 * @note This method is always blocking. A small (1s) delay is added to ensure the module
dan_ackme 29:b6af04b77a56 182 * has returned from reset and ready.
dan_ackme 29:b6af04b77a56 183 *
dan_ackme 29:b6af04b77a56 184 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 185 */
dan_ackme 29:b6af04b77a56 186 WiconnectResult reset();
dan_ackme 29:b6af04b77a56 187
dan_ackme 29:b6af04b77a56 188 /**
dan_ackme 29:b6af04b77a56 189 * @ingroup api_core_misc
dan_ackme 29:b6af04b77a56 190 *
dan_ackme 29:b6af04b77a56 191 * @brief Toggle the WiConnect WiFi moduel wakeup signal.
dan_ackme 29:b6af04b77a56 192 *
dan_ackme 29:b6af04b77a56 193 * @note This only wakes the module if the library was instantiated with the 'wake' pin
dan_ackme 29:b6af04b77a56 194 * parameter in the Wiconnect::Wiconnect constructor.
dan_ackme 29:b6af04b77a56 195 * @note This method is always blocking.
dan_ackme 29:b6af04b77a56 196 *
dan_ackme 29:b6af04b77a56 197 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 198 */
dan_ackme 29:b6af04b77a56 199 WiconnectResult wakeup();
dan_ackme 29:b6af04b77a56 200
dan_ackme 29:b6af04b77a56 201 /**
dan_ackme 29:b6af04b77a56 202 * @ingroup api_core_misc
dan_ackme 29:b6af04b77a56 203 *
dan_ackme 29:b6af04b77a56 204 * @brief Flush any received data in serial RX buffer and terminate any commands on WiConnect WiFi module.
dan_ackme 29:b6af04b77a56 205 *
dan_ackme 29:b6af04b77a56 206 * The delayMs parameter is used as the delay between terminating commands on the module and flushing
dan_ackme 29:b6af04b77a56 207 * the serial RX buffer. This is needed because after terminating commands on the module, the module will
dan_ackme 29:b6af04b77a56 208 * returns a response. These responses are invalid at this point and should be flushed from the serial RX buffer.
dan_ackme 29:b6af04b77a56 209 *
dan_ackme 29:b6af04b77a56 210 * @param[in] delayMs Optional, if not specificed this only flushes the serial RX buffer.
dan_ackme 29:b6af04b77a56 211 */
dan_ackme 29:b6af04b77a56 212 void flush(int delayMs = 500);
dan_ackme 29:b6af04b77a56 213
dan_ackme 29:b6af04b77a56 214 /**
dan_ackme 29:b6af04b77a56 215 * @ingroup api_core_misc
dan_ackme 29:b6af04b77a56 216 *
dan_ackme 29:b6af04b77a56 217 * @brief Return current version of WiConnect WiFi module.
dan_ackme 29:b6af04b77a56 218 * @param[in] versionBuffer Optional, Buffer to hold received version string
dan_ackme 29:b6af04b77a56 219 * @param[in] versionBufferSize Optional, required if versionBuffer specified.
dan_ackme 29:b6af04b77a56 220 * @param[in] completeCallback Optional, callback when version is received. arg1 of callback contains version buffer pointer.
dan_ackme 29:b6af04b77a56 221 *
dan_ackme 29:b6af04b77a56 222 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 223 */
dan_ackme 29:b6af04b77a56 224 WiconnectResult getVersion(char *versionBuffer = NULL, int versionBufferSize = 0, const Callback &completeCallback = Callback());
dan_ackme 29:b6af04b77a56 225
dan_ackme 29:b6af04b77a56 226
dan_ackme 29:b6af04b77a56 227 /**
dan_ackme 29:b6af04b77a56 228 * @ingroup api_core_misc
dan_ackme 29:b6af04b77a56 229 *
dan_ackme 29:b6af04b77a56 230 * @brief Update the wifi module's internal firmware.
dan_ackme 29:b6af04b77a56 231 * @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 232 * @param[in] versionStr Optional, If specified, update to specific firmware version, else update to latest version.
dan_ackme 29:b6af04b77a56 233 * @param[in] completeCallback Optional, callback when update is complete. 'result' callback argument contains result of update.
dan_ackme 29:b6af04b77a56 234 *
dan_ackme 29:b6af04b77a56 235 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 236 */
dan_ackme 29:b6af04b77a56 237 WiconnectResult updateFirmware(bool forced = false, const char *versionStr = NULL, const Callback &completeCallback = Callback());
dan_ackme 29:b6af04b77a56 238
dan_ackme 29:b6af04b77a56 239
dan_ackme 29:b6af04b77a56 240 // ------------------------------------------------------------------------
dan_ackme 29:b6af04b77a56 241
dan_ackme 29:b6af04b77a56 242
dan_ackme 29:b6af04b77a56 243 /**
dan_ackme 29:b6af04b77a56 244 * @ingroup api_core_send_command
dan_ackme 29:b6af04b77a56 245 *
dan_ackme 29:b6af04b77a56 246 * @brief Send command to WiConnect WiFi module
dan_ackme 29:b6af04b77a56 247 *
dan_ackme 29:b6af04b77a56 248 * @note Refer to @ref send_command_desc for more info
dan_ackme 29:b6af04b77a56 249 *
dan_ackme 29:b6af04b77a56 250 * @param[in] completeCallback Callback when command completes. arg1 of callback contains responseBuffer pointer, arg2 contains the response length
dan_ackme 29:b6af04b77a56 251 * @param[in] responseBuffer Buffer to hold command response
dan_ackme 29:b6af04b77a56 252 * @param[in] responseBufferLen Length of responseBuffer
dan_ackme 29:b6af04b77a56 253 * @param[in] timeoutMs Maximum time in milliseconds this command should execute
dan_ackme 29:b6af04b77a56 254 * @param[in] reader Callback for reading data to be read from host and send to module during command
dan_ackme 29:b6af04b77a56 255 * @param[in] user User data struct used during read Callback. Library doesn't use this. Set NULL if not used.
dan_ackme 29:b6af04b77a56 256 * @param[in] cmd WiConnect command to send to module
dan_ackme 29:b6af04b77a56 257 * @param[in] vaList Varaible list of arguments
dan_ackme 29:b6af04b77a56 258 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 259 */
dan_ackme 29:b6af04b77a56 260 WiconnectResult sendCommand(const Callback &completeCallback, char *responseBuffer, int responseBufferLen,
dan_ackme 29:b6af04b77a56 261 TimerTimeout timeoutMs, const ReaderFunc &reader, void *user, const char *cmd, va_list vaList);
dan_ackme 29:b6af04b77a56 262 /**
dan_ackme 29:b6af04b77a56 263 * @ingroup api_core_send_command
dan_ackme 29:b6af04b77a56 264 *
dan_ackme 29:b6af04b77a56 265 * @brief Send command to WiConnect WiFi module
dan_ackme 29:b6af04b77a56 266 *
dan_ackme 29:b6af04b77a56 267 * @note Refer to @ref send_command_desc for more info
dan_ackme 29:b6af04b77a56 268 *
dan_ackme 29:b6af04b77a56 269 * @param[in] responseBuffer Buffer to hold command response
dan_ackme 29:b6af04b77a56 270 * @param[in] responseBufferLen Length of responseBuffer
dan_ackme 29:b6af04b77a56 271 * @param[in] timeoutMs Maximum time in milliseconds this command should execute
dan_ackme 29:b6af04b77a56 272 * @param[in] reader Callback for reading data to be read from host and send to module during command
dan_ackme 29:b6af04b77a56 273 * @param[in] user User data struct used during read Callback. Library doesn't use this. Set NULL if not used.
dan_ackme 29:b6af04b77a56 274 * @param[in] cmd WiConnect command to send to module
dan_ackme 29:b6af04b77a56 275 * @param[in] vaList Varaible list of arguments
dan_ackme 29:b6af04b77a56 276 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 277 */
dan_ackme 29:b6af04b77a56 278 WiconnectResult sendCommand(char *responseBuffer, int responseBufferLen, TimerTimeout timeoutMs, const ReaderFunc &reader,
dan_ackme 29:b6af04b77a56 279 void *user, const char *cmd, va_list vaList);
dan_ackme 29:b6af04b77a56 280
dan_ackme 29:b6af04b77a56 281 /**
dan_ackme 29:b6af04b77a56 282 * @ingroup api_core_send_command
dan_ackme 29:b6af04b77a56 283 *
dan_ackme 29:b6af04b77a56 284 * @brief Send command to WiConnect WiFi module
dan_ackme 29:b6af04b77a56 285 *
dan_ackme 29:b6af04b77a56 286 * @note Refer to @ref send_command_desc for more info
dan_ackme 29:b6af04b77a56 287 * @note This method supports variable arguments
dan_ackme 29:b6af04b77a56 288 *
dan_ackme 29:b6af04b77a56 289 * @param[in] responseBuffer Buffer to hold command response
dan_ackme 29:b6af04b77a56 290 * @param[in] responseBufferLen Length of responseBuffer
dan_ackme 29:b6af04b77a56 291 * @param[in] timeoutMs Maximum time in milliseconds this command should execute
dan_ackme 29:b6af04b77a56 292 * @param[in] reader Callback for reading data to be read from host and send to module during command
dan_ackme 29:b6af04b77a56 293 * @param[in] user User data struct used during read Callback. Library doesn't use this. Set NULL if not used.
dan_ackme 29:b6af04b77a56 294 * @param[in] cmd WiConnect command to send to module
dan_ackme 29:b6af04b77a56 295 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 296 */
dan_ackme 29:b6af04b77a56 297 WiconnectResult sendCommand(char *responseBuffer, int responseBufferLen, TimerTimeout timeoutMs, const ReaderFunc &reader,
dan_ackme 29:b6af04b77a56 298 void *user, const char *cmd, ...);
dan_ackme 29:b6af04b77a56 299
dan_ackme 29:b6af04b77a56 300 /**
dan_ackme 29:b6af04b77a56 301 * @ingroup api_core_send_command
dan_ackme 29:b6af04b77a56 302 *
dan_ackme 29:b6af04b77a56 303 * @brief Send command to WiConnect WiFi module
dan_ackme 29:b6af04b77a56 304 *
dan_ackme 29:b6af04b77a56 305 * This method uses the library internal buffer.
dan_ackme 29:b6af04b77a56 306 *
dan_ackme 29:b6af04b77a56 307 * @note Refer to @ref send_command_desc for more info
dan_ackme 29:b6af04b77a56 308 * @note This method supports variable arguments
dan_ackme 29:b6af04b77a56 309 *
dan_ackme 29:b6af04b77a56 310 * @param[in] timeoutMs Maximum time in milliseconds this command should execute
dan_ackme 29:b6af04b77a56 311 * @param[in] reader Callback for reading data to be read from host and send to module during command
dan_ackme 29:b6af04b77a56 312 * @param[in] user User data struct used during read Callback. Library doesn't use this. Set NULL if not used.
dan_ackme 29:b6af04b77a56 313 * @param[in] cmd WiConnect command to send to module
dan_ackme 29:b6af04b77a56 314 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 315 */
dan_ackme 29:b6af04b77a56 316 WiconnectResult sendCommand(TimerTimeout timeoutMs, const ReaderFunc &reader, void *user, const char *cmd, ...);
dan_ackme 29:b6af04b77a56 317
dan_ackme 29:b6af04b77a56 318 /**
dan_ackme 29:b6af04b77a56 319 * @ingroup api_core_send_command
dan_ackme 29:b6af04b77a56 320 *
dan_ackme 29:b6af04b77a56 321 * @brief Send command to WiConnect WiFi module
dan_ackme 29:b6af04b77a56 322 *
dan_ackme 29:b6af04b77a56 323 * - This method uses the library internal buffer and
dan_ackme 29:b6af04b77a56 324 * - default timeout. See setCommandDefaultTimeout()
dan_ackme 29:b6af04b77a56 325 *
dan_ackme 29:b6af04b77a56 326 * @note Refer to @ref send_command_desc for more info
dan_ackme 29:b6af04b77a56 327 * @note This method supports variable arguments
dan_ackme 29:b6af04b77a56 328 *
dan_ackme 29:b6af04b77a56 329 * @param[in] reader Callback for reading data to be read from host and send to module during command
dan_ackme 29:b6af04b77a56 330 * @param[in] user User data struct used during read Callback. Library doesn't use this. Set NULL if not used.
dan_ackme 29:b6af04b77a56 331 * @param[in] cmd WiConnect command to send to module
dan_ackme 29:b6af04b77a56 332 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 333 */
dan_ackme 29:b6af04b77a56 334 WiconnectResult sendCommand(const ReaderFunc &reader, void *user, const char *cmd, ...);
dan_ackme 29:b6af04b77a56 335
dan_ackme 29:b6af04b77a56 336 /**
dan_ackme 29:b6af04b77a56 337 * @ingroup api_core_send_command
dan_ackme 29:b6af04b77a56 338 *
dan_ackme 29:b6af04b77a56 339 * @brief Send command to WiConnect WiFi module
dan_ackme 29:b6af04b77a56 340 *
dan_ackme 29:b6af04b77a56 341 * @note Refer to @ref send_command_desc for more info
dan_ackme 29:b6af04b77a56 342 * @note This method supports variable arguments
dan_ackme 29:b6af04b77a56 343 *
dan_ackme 29:b6af04b77a56 344 * @param[in] responseBuffer Buffer to hold command response
dan_ackme 29:b6af04b77a56 345 * @param[in] responseBufferLen Length of responseBuffer
dan_ackme 29:b6af04b77a56 346 * @param[in] timeoutMs Maximum time in milliseconds this command should execute
dan_ackme 29:b6af04b77a56 347 * @param[in] cmd WiConnect command to send to module
dan_ackme 29:b6af04b77a56 348 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 349 */
dan_ackme 29:b6af04b77a56 350 WiconnectResult sendCommand(char *responseBuffer, int responseBufferLen, TimerTimeout timeoutMs, const char *cmd, ...);
dan_ackme 29:b6af04b77a56 351
dan_ackme 29:b6af04b77a56 352 /**
dan_ackme 29:b6af04b77a56 353 * @ingroup api_core_send_command
dan_ackme 29:b6af04b77a56 354 *
dan_ackme 29:b6af04b77a56 355 * @brief Send command to WiConnect WiFi module
dan_ackme 29:b6af04b77a56 356 *
dan_ackme 29:b6af04b77a56 357 * @note Refer to @ref send_command_desc for more info
dan_ackme 29:b6af04b77a56 358 * @note This method supports variable arguments
dan_ackme 29:b6af04b77a56 359 *
dan_ackme 29:b6af04b77a56 360 * @param[in] completeCallback Callback when command completes. arg1 of callback contains responseBuffer pointer, arg2 contains the response length
dan_ackme 29:b6af04b77a56 361 * @param[in] responseBuffer Buffer to hold command response
dan_ackme 29:b6af04b77a56 362 * @param[in] responseBufferLen Length of responseBuffer
dan_ackme 29:b6af04b77a56 363 * @param[in] cmd WiConnect command to send to module
dan_ackme 29:b6af04b77a56 364 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 365 */
dan_ackme 29:b6af04b77a56 366 WiconnectResult sendCommand(const Callback &completeCallback, char *responseBuffer, int responseBufferLen, const char *cmd, ...);
dan_ackme 29:b6af04b77a56 367
dan_ackme 29:b6af04b77a56 368 /**
dan_ackme 29:b6af04b77a56 369 * @ingroup api_core_send_command
dan_ackme 29:b6af04b77a56 370 *
dan_ackme 29:b6af04b77a56 371 * @brief Send command to WiConnect WiFi module
dan_ackme 29:b6af04b77a56 372 *
dan_ackme 29:b6af04b77a56 373 * @note Refer to @ref send_command_desc for more info
dan_ackme 29:b6af04b77a56 374 * @note This method supports variable arguments
dan_ackme 29:b6af04b77a56 375 *
dan_ackme 29:b6af04b77a56 376 * @param[in] responseBuffer Buffer to hold command response
dan_ackme 29:b6af04b77a56 377 * @param[in] responseBufferLen Length of responseBuffer
dan_ackme 29:b6af04b77a56 378 * @param[in] cmd WiConnect command to send to module
dan_ackme 29:b6af04b77a56 379 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 380 */
dan_ackme 29:b6af04b77a56 381 WiconnectResult sendCommand(char *responseBuffer, int responseBufferLen, const char *cmd, ...);
dan_ackme 29:b6af04b77a56 382
dan_ackme 29:b6af04b77a56 383 /**
dan_ackme 29:b6af04b77a56 384 * @ingroup api_core_send_command
dan_ackme 29:b6af04b77a56 385 *
dan_ackme 29:b6af04b77a56 386 * @brief Send command to WiConnect WiFi module
dan_ackme 29:b6af04b77a56 387 *
dan_ackme 29:b6af04b77a56 388 * - This method uses the library internal buffer and
dan_ackme 29:b6af04b77a56 389 * - default timeout. See setCommandDefaultTimeout()
dan_ackme 29:b6af04b77a56 390 *
dan_ackme 29:b6af04b77a56 391 * @note Refer to @ref send_command_desc for more info
dan_ackme 29:b6af04b77a56 392 * @note This method supports variable arguments
dan_ackme 29:b6af04b77a56 393 *
dan_ackme 29:b6af04b77a56 394 * @param[in] completeCallback Callback when command completes. arg1 of callback contains responseBuffer pointer, arg2 contains the response length
dan_ackme 29:b6af04b77a56 395 * @param[in] cmd WiConnect command to send to module
dan_ackme 29:b6af04b77a56 396 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 397 */
dan_ackme 29:b6af04b77a56 398 WiconnectResult sendCommand(const Callback &completeCallback, const char *cmd, ...);
dan_ackme 29:b6af04b77a56 399
dan_ackme 29:b6af04b77a56 400 /**
dan_ackme 29:b6af04b77a56 401 * @ingroup api_core_send_command
dan_ackme 29:b6af04b77a56 402 *
dan_ackme 29:b6af04b77a56 403 * @brief Send command to WiConnect WiFi module
dan_ackme 29:b6af04b77a56 404 *
dan_ackme 29:b6af04b77a56 405 * - This method uses the library internal buffer and
dan_ackme 29:b6af04b77a56 406 * - default timeout. See setCommandDefaultTimeout()
dan_ackme 29:b6af04b77a56 407 *
dan_ackme 29:b6af04b77a56 408 * @note Refer to @ref send_command_desc for more info
dan_ackme 29:b6af04b77a56 409 * @note This method supports variable arguments
dan_ackme 29:b6af04b77a56 410 *
dan_ackme 29:b6af04b77a56 411 * @param[in] cmd WiConnect command to send to module
dan_ackme 29:b6af04b77a56 412 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 413 */
dan_ackme 29:b6af04b77a56 414 WiconnectResult sendCommand(const char *cmd, ...);
dan_ackme 29:b6af04b77a56 415
dan_ackme 29:b6af04b77a56 416 /**
dan_ackme 29:b6af04b77a56 417 * @ingroup api_core_send_command
dan_ackme 29:b6af04b77a56 418 *
dan_ackme 29:b6af04b77a56 419 * This method uses the library internal buffer
dan_ackme 29:b6af04b77a56 420 *
dan_ackme 29:b6af04b77a56 421 * @note Refer to @ref send_command_desc for more info
dan_ackme 29:b6af04b77a56 422 * @note This method supports variable arguments
dan_ackme 29:b6af04b77a56 423 *
dan_ackme 29:b6af04b77a56 424 * @param[in] completeCallback Callback when command completes. arg1 of callback contains responseBuffer pointer, arg2 contains the response length
dan_ackme 29:b6af04b77a56 425 * @param[in] timeoutMs Maximum time in milliseconds this command should execute
dan_ackme 29:b6af04b77a56 426 * @param[in] cmd WiConnect command to send to module
dan_ackme 29:b6af04b77a56 427 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 428 */
dan_ackme 29:b6af04b77a56 429 WiconnectResult sendCommand(const Callback &completeCallback, TimerTimeout timeoutMs, const char *cmd, ...);
dan_ackme 29:b6af04b77a56 430
dan_ackme 29:b6af04b77a56 431 /**
dan_ackme 29:b6af04b77a56 432 * @ingroup api_core_send_command
dan_ackme 29:b6af04b77a56 433 *
dan_ackme 29:b6af04b77a56 434 * @brief Send command to WiConnect WiFi module
dan_ackme 29:b6af04b77a56 435 *
dan_ackme 29:b6af04b77a56 436 * This method uses the library internal buffer
dan_ackme 29:b6af04b77a56 437 *
dan_ackme 29:b6af04b77a56 438 * @note Refer to @ref send_command_desc for more info
dan_ackme 29:b6af04b77a56 439 * @note This method supports variable arguments
dan_ackme 29:b6af04b77a56 440 *
dan_ackme 29:b6af04b77a56 441 * @param[in] timeoutMs Maximum time in milliseconds this command should execute
dan_ackme 29:b6af04b77a56 442 * @param[in] cmd WiConnect command to send to module
dan_ackme 29:b6af04b77a56 443 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 444 */
dan_ackme 29:b6af04b77a56 445 WiconnectResult sendCommand(TimerTimeout timeoutMs, const char *cmd, ...);
dan_ackme 29:b6af04b77a56 446
dan_ackme 29:b6af04b77a56 447 /**
dan_ackme 29:b6af04b77a56 448 * @ingroup api_core_send_command
dan_ackme 29:b6af04b77a56 449 *
dan_ackme 29:b6af04b77a56 450 * - This method uses the library internal buffer and
dan_ackme 29:b6af04b77a56 451 * - default timeout. See setCommandDefaultTimeout()
dan_ackme 29:b6af04b77a56 452 *
dan_ackme 29:b6af04b77a56 453 * @note Refer to @ref send_command_desc for more info
dan_ackme 29:b6af04b77a56 454 *
dan_ackme 29:b6af04b77a56 455 * @param[in] cmd WiConnect command to send to module
dan_ackme 29:b6af04b77a56 456 * @param[in] vaList Varaible list of arguments
dan_ackme 29:b6af04b77a56 457 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 458 */
dan_ackme 29:b6af04b77a56 459 WiconnectResult sendCommand(const char *cmd, va_list vaList);
dan_ackme 29:b6af04b77a56 460
dan_ackme 29:b6af04b77a56 461 /**
dan_ackme 29:b6af04b77a56 462 * @ingroup api_core_send_command
dan_ackme 29:b6af04b77a56 463 *
dan_ackme 29:b6af04b77a56 464 * @brief Check the status of the currently executing command.
dan_ackme 29:b6af04b77a56 465 *
dan_ackme 29:b6af04b77a56 466 * Refer to @ref WiconnectResult for more information about the return code.
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 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 471 */
dan_ackme 29:b6af04b77a56 472 WiconnectResult checkCurrentCommand();
dan_ackme 29:b6af04b77a56 473
dan_ackme 29:b6af04b77a56 474 /**
dan_ackme 29:b6af04b77a56 475 * @ingroup api_core_send_command
dan_ackme 29:b6af04b77a56 476 *
dan_ackme 29:b6af04b77a56 477 * @brief Stop the currently executing command.
dan_ackme 29:b6af04b77a56 478 *
dan_ackme 29:b6af04b77a56 479 * @note This command is only applicable for non-blocking mode. Refer to @ref setting_blocking_modes.
dan_ackme 29:b6af04b77a56 480 */
dan_ackme 29:b6af04b77a56 481 void stopCurrentCommand();
dan_ackme 29:b6af04b77a56 482
dan_ackme 29:b6af04b77a56 483
dan_ackme 29:b6af04b77a56 484 // ------------------------------------------------------------------------
dan_ackme 29:b6af04b77a56 485
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 When the WiConnect WiFi module returns a response, it contains a
dan_ackme 29:b6af04b77a56 491 * response code in the header. This function converts the previous response code
dan_ackme 29:b6af04b77a56 492 * to a readable string.
dan_ackme 29:b6af04b77a56 493 *
dan_ackme 29:b6af04b77a56 494 * @return string representation of module response code
dan_ackme 29:b6af04b77a56 495 */
dan_ackme 29:b6af04b77a56 496 const char* getLastCommandResponseCodeStr();
dan_ackme 29:b6af04b77a56 497
dan_ackme 29:b6af04b77a56 498 /**
dan_ackme 29:b6af04b77a56 499 * @ingroup api_core_misc
dan_ackme 29:b6af04b77a56 500 *
dan_ackme 29:b6af04b77a56 501 * @brief Return the length in bytes of the previous response.
dan_ackme 29:b6af04b77a56 502 *
dan_ackme 29:b6af04b77a56 503 * @return length of previous response
dan_ackme 29:b6af04b77a56 504 */
dan_ackme 29:b6af04b77a56 505 uint16_t getLastCommandResponseLength();
dan_ackme 29:b6af04b77a56 506
dan_ackme 29:b6af04b77a56 507 /**
dan_ackme 29:b6af04b77a56 508 * @ingroup api_core_misc
dan_ackme 29:b6af04b77a56 509 *
dan_ackme 29:b6af04b77a56 510 * @brief Return pointer to internal response buffer.
dan_ackme 29:b6af04b77a56 511 *
dan_ackme 29:b6af04b77a56 512 * @return pointer to internal response buffer
dan_ackme 29:b6af04b77a56 513 */
dan_ackme 29:b6af04b77a56 514 char* getResponseBuffer();
dan_ackme 29:b6af04b77a56 515
dan_ackme 29:b6af04b77a56 516 /**
dan_ackme 29:b6af04b77a56 517 * @ingroup api_core_misc
dan_ackme 29:b6af04b77a56 518 *
dan_ackme 29:b6af04b77a56 519 * @brief Helper method to convert previous response to uint32
dan_ackme 29:b6af04b77a56 520 *
dan_ackme 29:b6af04b77a56 521 * @note This uses the internal response buffer.
dan_ackme 29:b6af04b77a56 522 *
dan_ackme 29:b6af04b77a56 523 * @param[out] uint32Ptr Pointer to hold result of conversion.
dan_ackme 29:b6af04b77a56 524 * @return Result of conversion. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 525 */
dan_ackme 29:b6af04b77a56 526 WiconnectResult responseToUint32(uint32_t *uint32Ptr);
dan_ackme 29:b6af04b77a56 527
dan_ackme 29:b6af04b77a56 528 /**
dan_ackme 29:b6af04b77a56 529 * @ingroup api_core_misc
dan_ackme 29:b6af04b77a56 530 *
dan_ackme 29:b6af04b77a56 531 * @brief Helper method to convert previous response to int32
dan_ackme 29:b6af04b77a56 532 *
dan_ackme 29:b6af04b77a56 533 * @note This uses the internal response buffer.
dan_ackme 29:b6af04b77a56 534 *
dan_ackme 29:b6af04b77a56 535 * @param[out] int32Ptr Pointer to hold result of conversion.
dan_ackme 29:b6af04b77a56 536 * @return Result of conversion. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 537 */
dan_ackme 29:b6af04b77a56 538 WiconnectResult responseToInt32(int32_t *int32Ptr);
dan_ackme 29:b6af04b77a56 539
dan_ackme 29:b6af04b77a56 540
dan_ackme 29:b6af04b77a56 541 // ------------------------------------------------------------------------
dan_ackme 29:b6af04b77a56 542
dan_ackme 29:b6af04b77a56 543 /**
dan_ackme 29:b6af04b77a56 544 * @ingroup api_core_settings
dan_ackme 29:b6af04b77a56 545 *
dan_ackme 29:b6af04b77a56 546 * @brief Set a module setting
dan_ackme 29:b6af04b77a56 547 *
dan_ackme 29:b6af04b77a56 548 * Refer to: http://wiconnect.ack.me/2.0/variables
dan_ackme 29:b6af04b77a56 549 * for a list of the available settings and descriptions
dan_ackme 29:b6af04b77a56 550 *
dan_ackme 29:b6af04b77a56 551 * @param settingStr String module setting name.
dan_ackme 29:b6af04b77a56 552 * @param value The integer value to set
dan_ackme 29:b6af04b77a56 553 *
dan_ackme 29:b6af04b77a56 554 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 555 */
dan_ackme 29:b6af04b77a56 556 WiconnectResult setSetting(const char *settingStr, uint32_t value);
dan_ackme 29:b6af04b77a56 557
dan_ackme 29:b6af04b77a56 558 /**
dan_ackme 29:b6af04b77a56 559 * @ingroup api_core_settings
dan_ackme 29:b6af04b77a56 560 *
dan_ackme 29:b6af04b77a56 561 * @brief Set a module setting
dan_ackme 29:b6af04b77a56 562 *
dan_ackme 29:b6af04b77a56 563 * Refer to: http://wiconnect.ack.me/2.0/variables
dan_ackme 29:b6af04b77a56 564 * for a list of the available settings and descriptions
dan_ackme 29:b6af04b77a56 565 *
dan_ackme 29:b6af04b77a56 566 * @param settingStr String module setting name.
dan_ackme 29:b6af04b77a56 567 * @param value The string value to set
dan_ackme 29:b6af04b77a56 568 *
dan_ackme 29:b6af04b77a56 569 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 570 */
dan_ackme 29:b6af04b77a56 571 WiconnectResult setSetting(const char *settingStr, const char *value);
dan_ackme 29:b6af04b77a56 572
dan_ackme 29:b6af04b77a56 573 /**
dan_ackme 29:b6af04b77a56 574 * @ingroup api_core_settings
dan_ackme 29:b6af04b77a56 575 *
dan_ackme 29:b6af04b77a56 576 * @brief Get a module setting
dan_ackme 29:b6af04b77a56 577 *
dan_ackme 29:b6af04b77a56 578 * Refer to: http://wiconnect.ack.me/2.0/variables
dan_ackme 29:b6af04b77a56 579 * for a list of the available settings and descriptions
dan_ackme 29:b6af04b77a56 580 *
dan_ackme 29:b6af04b77a56 581 * @param settingStr String module setting name.
dan_ackme 29:b6af04b77a56 582 * @param valuePtr Pointer to buffer to contain integer value
dan_ackme 29:b6af04b77a56 583 *
dan_ackme 29:b6af04b77a56 584 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 585 */
dan_ackme 29:b6af04b77a56 586 WiconnectResult getSetting(const char *settingStr, uint32_t *valuePtr);
dan_ackme 29:b6af04b77a56 587
dan_ackme 29:b6af04b77a56 588 /**
dan_ackme 29:b6af04b77a56 589 * @ingroup api_core_settings
dan_ackme 29:b6af04b77a56 590 *
dan_ackme 29:b6af04b77a56 591 * @brief Get a module setting
dan_ackme 29:b6af04b77a56 592 *
dan_ackme 29:b6af04b77a56 593 * Refer to: http://wiconnect.ack.me/2.0/variables
dan_ackme 29:b6af04b77a56 594 * for a list of the available settings and descriptions
dan_ackme 29:b6af04b77a56 595 *
dan_ackme 29:b6af04b77a56 596 * @param settingStr String module setting name.
dan_ackme 29:b6af04b77a56 597 * @param valuePtr Pointer to hold pointer to internal API buffer containing retrieved setting result
dan_ackme 29:b6af04b77a56 598 *
dan_ackme 29:b6af04b77a56 599 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 600 */
dan_ackme 29:b6af04b77a56 601 WiconnectResult getSetting(const char *settingStr, char **valuePtr);
dan_ackme 29:b6af04b77a56 602
dan_ackme 29:b6af04b77a56 603 /**
dan_ackme 29:b6af04b77a56 604 * @ingroup api_core_settings
dan_ackme 29:b6af04b77a56 605 *
dan_ackme 29:b6af04b77a56 606 * @brief Get a module setting
dan_ackme 29:b6af04b77a56 607 *
dan_ackme 29:b6af04b77a56 608 * Refer to: http://wiconnect.ack.me/2.0/variables
dan_ackme 29:b6af04b77a56 609 * for a list of the available settings and descriptions
dan_ackme 29:b6af04b77a56 610 *
dan_ackme 29:b6af04b77a56 611 * @param settingStr String module setting name.
dan_ackme 29:b6af04b77a56 612 * @param valueBuffer Buffer to hold retrieved setting result
dan_ackme 29:b6af04b77a56 613 * @param valueBufferLen The length of the input buffer
dan_ackme 29:b6af04b77a56 614 *
dan_ackme 29:b6af04b77a56 615 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 616 */
dan_ackme 29:b6af04b77a56 617 WiconnectResult getSetting(const char *settingStr, char *valueBuffer, uint16_t valueBufferLen);
dan_ackme 29:b6af04b77a56 618
dan_ackme 37:5ee74d72efe4 619 /**
dan_ackme 37:5ee74d72efe4 620 * @ingroup api_core_settings
dan_ackme 37:5ee74d72efe4 621 *
dan_ackme 37:5ee74d72efe4 622 * @brief Save settings to Non-Volatile Memory
dan_ackme 37:5ee74d72efe4 623 *
dan_ackme 37:5ee74d72efe4 624 * @return Result of method. See @ref WiconnectResult
dan_ackme 37:5ee74d72efe4 625 */
dan_ackme 37:5ee74d72efe4 626 WiconnectResult saveSettings();
dan_ackme 29:b6af04b77a56 627
dan_ackme 29:b6af04b77a56 628 /**
dan_ackme 29:b6af04b77a56 629 * @ingroup api_core_settings
dan_ackme 29:b6af04b77a56 630 *
dan_ackme 29:b6af04b77a56 631 * @brief Sets if API calls are blocking or non-blocking.
dan_ackme 29:b6af04b77a56 632 *
dan_ackme 29:b6af04b77a56 633 * @param[in] blockingEnabled The new blocking value
dan_ackme 29:b6af04b77a56 634 */
dan_ackme 29:b6af04b77a56 635 void setBlockingEnabled(bool blockingEnabled);
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 Gets if API calls are blocking or non-blocking.
dan_ackme 29:b6af04b77a56 641 */
dan_ackme 29:b6af04b77a56 642 bool getBlockingEnabled(void);
dan_ackme 29:b6af04b77a56 643
dan_ackme 29:b6af04b77a56 644 /**
dan_ackme 29:b6af04b77a56 645 * @ingroup api_core_settings
dan_ackme 29:b6af04b77a56 646 *
dan_ackme 29:b6af04b77a56 647 * @brief Sets the default maximum time an API method may execute before
dan_ackme 29:b6af04b77a56 648 * terminating and return a timeout error code.
dan_ackme 29:b6af04b77a56 649 *
dan_ackme 29:b6af04b77a56 650 * @note All API methods (execpt some sendCommand()) use this default value.
dan_ackme 29:b6af04b77a56 651 *
dan_ackme 29:b6af04b77a56 652 * @param[in] timeoutMs Default command timeout in milliseconds
dan_ackme 29:b6af04b77a56 653 */
dan_ackme 29:b6af04b77a56 654 void setCommandDefaultTimeout(TimerTimeout timeoutMs);
dan_ackme 29:b6af04b77a56 655
dan_ackme 29:b6af04b77a56 656 /**
dan_ackme 29:b6af04b77a56 657 * @ingroup api_core_settings
dan_ackme 29:b6af04b77a56 658 *
dan_ackme 29:b6af04b77a56 659 * @brief Returns the current default maximum API execution time.
dan_ackme 29:b6af04b77a56 660 *
dan_ackme 29:b6af04b77a56 661 * @return Default command timeout in milliseconds
dan_ackme 29:b6af04b77a56 662 */
dan_ackme 29:b6af04b77a56 663 TimerTimeout getCommandDefaultTimeout();
dan_ackme 29:b6af04b77a56 664
dan_ackme 29:b6af04b77a56 665 /**
dan_ackme 29:b6af04b77a56 666 * @ingroup api_core_settings
dan_ackme 29:b6af04b77a56 667 *
dan_ackme 29:b6af04b77a56 668 * @brief Sets a mapping function used to convert from a host Pin to WiConnect WiFi module GPIO.
dan_ackme 29:b6af04b77a56 669 *
dan_ackme 29:b6af04b77a56 670 * @param[in] mapper Pin to GPIO mapper function pointer
dan_ackme 29:b6af04b77a56 671 */
dan_ackme 29:b6af04b77a56 672 void setPinToGpioMapper(PinToGpioMapper mapper);
dan_ackme 29:b6af04b77a56 673
dan_ackme 29:b6af04b77a56 674 /**
dan_ackme 29:b6af04b77a56 675 * @ingroup api_core_settings
dan_ackme 29:b6af04b77a56 676 *
dan_ackme 29:b6af04b77a56 677 * @brief Sets callback function used to debug WiConnect WiFi module RX/TX serial data.
dan_ackme 29:b6af04b77a56 678 *
dan_ackme 29:b6af04b77a56 679 * @param[in] logFunc Logging function pointer
dan_ackme 29:b6af04b77a56 680 */
dan_ackme 29:b6af04b77a56 681 void setDebugLogger(LogFunc logFunc);
dan_ackme 29:b6af04b77a56 682
dan_ackme 29:b6af04b77a56 683 /**
dan_ackme 29:b6af04b77a56 684 * @ingroup api_core_settings
dan_ackme 29:b6af04b77a56 685 *
dan_ackme 29:b6af04b77a56 686 * @brief Sets callback used when Wiconnect Library hits and internal assertion.
dan_ackme 29:b6af04b77a56 687 *
dan_ackme 29:b6af04b77a56 688 * @note This is mainly for debugging. There's nothing the callback can do to fix the assertion.
dan_ackme 29:b6af04b77a56 689 *
dan_ackme 29:b6af04b77a56 690 * @param[in] assertLogFunc Logging function pointer
dan_ackme 29:b6af04b77a56 691 */
dan_ackme 29:b6af04b77a56 692 void setAssertLogger(LogFunc assertLogFunc);
dan_ackme 29:b6af04b77a56 693
dan_ackme 29:b6af04b77a56 694 // ------------------------------------------------------------------------
dan_ackme 29:b6af04b77a56 695
dan_ackme 29:b6af04b77a56 696
dan_ackme 29:b6af04b77a56 697 #ifdef WICONNECT_ASYNC_TIMER_ENABLED
dan_ackme 29:b6af04b77a56 698 /**
dan_ackme 29:b6af04b77a56 699 * @ingroup api_core_send_command
dan_ackme 29:b6af04b77a56 700 *
dan_ackme 29:b6af04b77a56 701 * @brief Add user command to be executed asynchronously.
dan_ackme 29:b6af04b77a56 702 *
dan_ackme 29:b6af04b77a56 703 * Refer to @ref setting_async_processing for more info.
dan_ackme 29:b6af04b77a56 704 *
dan_ackme 29:b6af04b77a56 705 * @param[in] command Pointer to QueuedCommand to be executed asynchronously
dan_ackme 29:b6af04b77a56 706 * @param[in] commandCompleteHandler Callback to be executed when processing is complete.
dan_ackme 29:b6af04b77a56 707 * @return Result of method. See @ref WiconnectResult
dan_ackme 29:b6af04b77a56 708 */
dan_ackme 29:b6af04b77a56 709 WiconnectResult enqueueCommand(QueuedCommand *command, const Callback &commandCompleteHandler = Callback());
dan_ackme 29:b6af04b77a56 710
dan_ackme 29:b6af04b77a56 711 /**
dan_ackme 29:b6af04b77a56 712 * @ingroup api_core_settings
dan_ackme 29:b6af04b77a56 713 *
dan_ackme 29:b6af04b77a56 714 * @brief Set the period at which an asynchronous command should be processed.
dan_ackme 29:b6af04b77a56 715 *
dan_ackme 29:b6af04b77a56 716 * Refer to @ref setting_async_processing for more info.
dan_ackme 29:b6af04b77a56 717 *
dan_ackme 29:b6af04b77a56 718 * @param[in] periodMs Processing period in milliseconds
dan_ackme 29:b6af04b77a56 719 */
dan_ackme 29:b6af04b77a56 720 void setCommandProcessingPeriod(uint32_t periodMs);
dan_ackme 29:b6af04b77a56 721 #endif
dan_ackme 29:b6af04b77a56 722
dan_ackme 29:b6af04b77a56 723
dan_ackme 29:b6af04b77a56 724 /**
dan_ackme 29:b6af04b77a56 725 * @ingroup conversion_util
dan_ackme 29:b6af04b77a56 726 *
dan_ackme 29:b6af04b77a56 727 * @brief Converts a @ref WiconnectResult to string representation.
dan_ackme 29:b6af04b77a56 728 *
dan_ackme 29:b6af04b77a56 729 * @param[in] wiconnectResult Result code
dan_ackme 29:b6af04b77a56 730 * @return String representaion of result code
dan_ackme 29:b6af04b77a56 731 */
dan_ackme 29:b6af04b77a56 732 static const char* getWiconnectResultStr(WiconnectResult wiconnectResult);
dan_ackme 29:b6af04b77a56 733
dan_ackme 34:2616445d0823 734 /**
dan_ackme 34:2616445d0823 735 * @ingroup conversion_util
dan_ackme 34:2616445d0823 736 *
dan_ackme 34:2616445d0823 737 * @brief Converts wiconnect version string to uint32_t representation.
dan_ackme 34:2616445d0823 738 *
dan_ackme 34:2616445d0823 739 * @param[in] Output of @ref getVersion() API call.
dan_ackme 34:2616445d0823 740 * @return 32bit integer WiConnect firmware version
dan_ackme 34:2616445d0823 741 */
dan_ackme 34:2616445d0823 742 static uint32_t wiconnectVersionToInt(char *versionStr);
dan_ackme 34:2616445d0823 743
dan_ackme 29:b6af04b77a56 744 protected:
dan_ackme 29:b6af04b77a56 745
dan_ackme 29:b6af04b77a56 746 #ifdef WICONNECT_ENABLE_MALLOC
dan_ackme 29:b6af04b77a56 747 void* (*_malloc)(size_t);
dan_ackme 29:b6af04b77a56 748 void (*_free)(void *);
dan_ackme 29:b6af04b77a56 749 friend class QueuedCommand;
dan_ackme 29:b6af04b77a56 750 friend class WiconnectSerial;
dan_ackme 29:b6af04b77a56 751 friend class ScanResult;
dan_ackme 29:b6af04b77a56 752 #endif
dan_ackme 29:b6af04b77a56 753
dan_ackme 29:b6af04b77a56 754 wiconnect::WiconnectSerial serial;
dan_ackme 29:b6af04b77a56 755 wiconnect::Gpio resetGpio;
dan_ackme 29:b6af04b77a56 756 wiconnect::Gpio wakeGpio;
dan_ackme 29:b6af04b77a56 757
dan_ackme 29:b6af04b77a56 758 volatile bool commandExecuting;
dan_ackme 29:b6af04b77a56 759 bool initialized;
dan_ackme 34:2616445d0823 760 bool needUpdate;
dan_ackme 29:b6af04b77a56 761 bool nonBlocking;
dan_ackme 29:b6af04b77a56 762
dan_ackme 29:b6af04b77a56 763 PinToGpioMapper pinToGpioMapper;
dan_ackme 29:b6af04b77a56 764
dan_ackme 29:b6af04b77a56 765 char *internalBuffer;
dan_ackme 29:b6af04b77a56 766 int internalBufferSize;
dan_ackme 29:b6af04b77a56 767 bool internalBufferAlloc;
dan_ackme 29:b6af04b77a56 768 uint8_t internalProcessingState;
dan_ackme 29:b6af04b77a56 769 void *currentCommandId;
dan_ackme 29:b6af04b77a56 770
dan_ackme 29:b6af04b77a56 771 wiconnect::TimeoutTimer timeoutTimer;
dan_ackme 29:b6af04b77a56 772 TimerTimeout defaultTimeoutMs;
dan_ackme 29:b6af04b77a56 773
dan_ackme 29:b6af04b77a56 774 uint8_t commandHeaderBuffer[32];
dan_ackme 29:b6af04b77a56 775 char commandFormatBuffer[WICONNECT_MAX_CMD_SIZE];
dan_ackme 29:b6af04b77a56 776 uint8_t commandContext[96];
dan_ackme 29:b6af04b77a56 777
dan_ackme 29:b6af04b77a56 778 void prepare(void *internalBuffer, int internalBufferSize, bool nonBlocking);
dan_ackme 29:b6af04b77a56 779 bool configureModuleDataBus(void);
dan_ackme 29:b6af04b77a56 780 WiconnectResult inline receiveResponse();
dan_ackme 29:b6af04b77a56 781 WiconnectResult inline receivePacket();
dan_ackme 29:b6af04b77a56 782 void issueCommandCallback(WiconnectResult result);
dan_ackme 29:b6af04b77a56 783
dan_ackme 29:b6af04b77a56 784 #ifdef WICONNECT_ENABLE_DEBUGGING
dan_ackme 29:b6af04b77a56 785 LogFunc debugLogger;
dan_ackme 29:b6af04b77a56 786 #endif
dan_ackme 29:b6af04b77a56 787 LogFunc assertLogger;
dan_ackme 29:b6af04b77a56 788
dan_ackme 29:b6af04b77a56 789 void debugLog(const char *msg, ...);
dan_ackme 29:b6af04b77a56 790
dan_ackme 29:b6af04b77a56 791 #ifdef WICONNECT_ASYNC_TIMER_ENABLED
dan_ackme 29:b6af04b77a56 792 wiconnect::PeriodicTimer commandProcessorTimer;
dan_ackme 29:b6af04b77a56 793 uint32_t commandProcessingPeriod;
dan_ackme 29:b6af04b77a56 794 CommandQueue commandQueue;
dan_ackme 29:b6af04b77a56 795 wiconnect::QueuedCommand *currentQueuedCommand;
dan_ackme 29:b6af04b77a56 796
dan_ackme 29:b6af04b77a56 797 void commandProcessingTimerHandler(void);
dan_ackme 29:b6af04b77a56 798 void processNextQueuedCommand();
dan_ackme 29:b6af04b77a56 799 void checkQueuedCommandTimeout();
dan_ackme 29:b6af04b77a56 800 #endif
dan_ackme 29:b6af04b77a56 801
dan_ackme 29:b6af04b77a56 802 friend class NetworkInterface;
dan_ackme 29:b6af04b77a56 803 friend class SocketInterface;
dan_ackme 29:b6af04b77a56 804 friend class FileInterface;
dan_ackme 29:b6af04b77a56 805 friend class GhmInterface;
dan_ackme 29:b6af04b77a56 806 friend class GhmMessageList;
dan_ackme 29:b6af04b77a56 807 friend class GhmMessage;
dan_ackme 29:b6af04b77a56 808 friend class ScanResultList;
dan_ackme 29:b6af04b77a56 809 friend class WiconnectFile;
dan_ackme 29:b6af04b77a56 810 friend class WiconnectSocket;
dan_ackme 29:b6af04b77a56 811 friend class WiconnectUdpServer;
dan_ackme 29:b6af04b77a56 812 };
dan_ackme 29:b6af04b77a56 813
dan_ackme 29:b6af04b77a56 814 }
dan_ackme 29:b6af04b77a56 815
dan_ackme 29:b6af04b77a56 816
dan_ackme 29:b6af04b77a56 817 #include "sdkTypes.h"
dan_ackme 29:b6af04b77a56 818