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:
Sat Aug 23 05:39:17 2014 -0700
Revision:
17:7268f365676b
Parent:
16:7f1d6d359787
Child:
21:17bb3eddcbae
Fixes and documentation updates

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dan_ackme 16:7f1d6d359787 1 /**
dan_ackme 16:7f1d6d359787 2 * ACKme WiConnect Host Library is licensed under the BSD licence:
dan_ackme 16:7f1d6d359787 3 *
dan_ackme 16:7f1d6d359787 4 * Copyright (c)2014 ACKme Networks.
dan_ackme 16:7f1d6d359787 5 * All rights reserved.
dan_ackme 16:7f1d6d359787 6 *
dan_ackme 16:7f1d6d359787 7 * Redistribution and use in source and binary forms, with or without modification,
dan_ackme 16:7f1d6d359787 8 * are permitted provided that the following conditions are met:
dan_ackme 16:7f1d6d359787 9 *
dan_ackme 16:7f1d6d359787 10 * 1. Redistributions of source code must retain the above copyright notice,
dan_ackme 16:7f1d6d359787 11 * this list of conditions and the following disclaimer.
dan_ackme 16:7f1d6d359787 12 * 2. Redistributions in binary form must reproduce the above copyright notice,
dan_ackme 16:7f1d6d359787 13 * this list of conditions and the following disclaimer in the documentation
dan_ackme 16:7f1d6d359787 14 * and/or other materials provided with the distribution.
dan_ackme 16:7f1d6d359787 15 * 3. The name of the author may not be used to endorse or promote products
dan_ackme 16:7f1d6d359787 16 * derived from this software without specific prior written permission.
dan_ackme 16:7f1d6d359787 17 *
dan_ackme 16:7f1d6d359787 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS AND ANY EXPRESS OR IMPLIED
dan_ackme 16:7f1d6d359787 19 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
dan_ackme 16:7f1d6d359787 20 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
dan_ackme 16:7f1d6d359787 21 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
dan_ackme 16:7f1d6d359787 22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
dan_ackme 16:7f1d6d359787 23 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
dan_ackme 16:7f1d6d359787 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
dan_ackme 16:7f1d6d359787 25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
dan_ackme 16:7f1d6d359787 26 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
dan_ackme 16:7f1d6d359787 27 * OF SUCH DAMAGE.
dan_ackme 0:ea85c4bb5e1f 28 */
dan_ackme 0:ea85c4bb5e1f 29 #pragma once
dan_ackme 0:ea85c4bb5e1f 30
dan_ackme 0:ea85c4bb5e1f 31 #include "WiconnectTypes.h"
dan_ackme 0:ea85c4bb5e1f 32
dan_ackme 0:ea85c4bb5e1f 33
dan_ackme 0:ea85c4bb5e1f 34 #include "types/LogFunc.h"
dan_ackme 0:ea85c4bb5e1f 35 #include "types/ReaderFunc.h"
dan_ackme 0:ea85c4bb5e1f 36 #include "types/Callback.h"
dan_ackme 0:ea85c4bb5e1f 37 #include "types/QueuedCommand.h"
dan_ackme 0:ea85c4bb5e1f 38 #include "types/CommandQueue.h"
dan_ackme 0:ea85c4bb5e1f 39 #include "types/TimeoutTimer.h"
dan_ackme 0:ea85c4bb5e1f 40 #include "types/PeriodicTimer.h"
dan_ackme 0:ea85c4bb5e1f 41 #include "types/Gpio.h"
dan_ackme 0:ea85c4bb5e1f 42 #include "types/WiconnectSerial.h"
dan_ackme 0:ea85c4bb5e1f 43
dan_ackme 0:ea85c4bb5e1f 44 #include "NetworkInterface.h"
dan_ackme 0:ea85c4bb5e1f 45 #include "SocketInterface.h"
dan_ackme 0:ea85c4bb5e1f 46 #include "FileInterface.h"
dan_ackme 0:ea85c4bb5e1f 47
dan_ackme 0:ea85c4bb5e1f 48
dan_ackme 0:ea85c4bb5e1f 49 #ifdef WICONNECT_ENABLE_MALLOC
dan_ackme 9:b6218dc218ad 50 /// These are optional arguments for host specific malloc/free
dan_ackme 0:ea85c4bb5e1f 51 #define WICONNECT_MALLOC_ARGS , void* (*malloc_)(size_t) = WICONNECT_DEFAULT_MALLOC, void (*free_)(void*) = WICONNECT_DEFAULT_FREE
dan_ackme 0:ea85c4bb5e1f 52 #else
dan_ackme 0:ea85c4bb5e1f 53 #define WICONNECT_MALLOC_ARGS
dan_ackme 0:ea85c4bb5e1f 54 #endif
dan_ackme 0:ea85c4bb5e1f 55
dan_ackme 0:ea85c4bb5e1f 56
dan_ackme 11:ea484e1b7fc4 57 /**
dan_ackme 11:ea484e1b7fc4 58 * @namespace wiconnect
dan_ackme 11:ea484e1b7fc4 59 */
dan_ackme 0:ea85c4bb5e1f 60 namespace wiconnect {
dan_ackme 0:ea85c4bb5e1f 61
dan_ackme 0:ea85c4bb5e1f 62
dan_ackme 9:b6218dc218ad 63 /**
dan_ackme 13:2b51f5267c92 64 * @ingroup api_core_types
dan_ackme 9:b6218dc218ad 65 *
dan_ackme 11:ea484e1b7fc4 66 * @brief The root WiConnect library class. This class
dan_ackme 9:b6218dc218ad 67 * inheriets all WiConnect functionality.
dan_ackme 9:b6218dc218ad 68 *
dan_ackme 9:b6218dc218ad 69 * This class is implemented as a 'singleton'. This means it
dan_ackme 9:b6218dc218ad 70 * only needs to be instantiated once. Subsequent class may either
dan_ackme 9:b6218dc218ad 71 * use the class instance or the static function: @ref Wiconnect::getInstance()
dan_ackme 9:b6218dc218ad 72 *
dan_ackme 9:b6218dc218ad 73 */
dan_ackme 0:ea85c4bb5e1f 74 class Wiconnect : public NetworkInterface,
dan_ackme 0:ea85c4bb5e1f 75 public SocketInterface,
dan_ackme 0:ea85c4bb5e1f 76 public FileInterface
dan_ackme 0:ea85c4bb5e1f 77 {
dan_ackme 0:ea85c4bb5e1f 78 public:
dan_ackme 9:b6218dc218ad 79
dan_ackme 9:b6218dc218ad 80 /**
dan_ackme 11:ea484e1b7fc4 81 * @brief WiConnect class constructor
dan_ackme 9:b6218dc218ad 82 *
dan_ackme 9:b6218dc218ad 83 * @note This should only be called once within a program as the WiConnect
dan_ackme 9:b6218dc218ad 84 * library is implemented as a singleton.
dan_ackme 9:b6218dc218ad 85 *
dan_ackme 9:b6218dc218ad 86 * @note If this constructor is used, then all commands must be supplied with an external response buffer.
dan_ackme 9:b6218dc218ad 87 * This means most the API functions will not work as they use the internal buffer.
dan_ackme 9:b6218dc218ad 88 * It's recommended to use the other constructor that supplies an internal buffer. See @ref setting_alloc
dan_ackme 9:b6218dc218ad 89 *
dan_ackme 9:b6218dc218ad 90 * @param[in] serialConfig The serial (i.e. UART) configuration connected to a WiConnect module.
dan_ackme 9:b6218dc218ad 91 * @param[in] reset Optional, The pin connected to the WiConnect module reset signal. Default: No connection
dan_ackme 9:b6218dc218ad 92 * @param[in] wake Optional, The pin connected to the WiConnect module wake signal. Default: No connection
dan_ackme 9:b6218dc218ad 93 * @param[in] nonBlocking Optional, indicates if the API blocking mode. See @ref setting_blocking_modes
dan_ackme 9:b6218dc218ad 94 */
dan_ackme 0:ea85c4bb5e1f 95 Wiconnect(const SerialConfig &serialConfig, Pin reset = PIN_NC, Pin wake = PIN_NC, bool nonBlocking = WICONNECT_DEFAULT_NONBLOCKING WICONNECT_MALLOC_ARGS);
dan_ackme 9:b6218dc218ad 96
dan_ackme 9:b6218dc218ad 97 /**
dan_ackme 11:ea484e1b7fc4 98 * @brief WiConnect class constructor
dan_ackme 9:b6218dc218ad 99 *
dan_ackme 9:b6218dc218ad 100 * @note This should only be called once within a program as the WiConnect
dan_ackme 9:b6218dc218ad 101 * library is implemented as a singleton.
dan_ackme 9:b6218dc218ad 102 *
dan_ackme 9:b6218dc218ad 103 * @note This is the recommended construstor as it supplies the WiConnect library with an
dan_ackme 9:b6218dc218ad 104 * internal buffer. Most API calls require the internal buffer.
dan_ackme 9:b6218dc218ad 105 *
dan_ackme 9:b6218dc218ad 106 * @param[in] serialConfig The serial (i.e. UART) configuration connected to a WiConnect module.
dan_ackme 13:2b51f5267c92 107 * @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 9:b6218dc218ad 108 * @param[in] internalBuffer Optional, a user allocated buffer. See @ref setting_alloc
dan_ackme 9:b6218dc218ad 109 * @param[in] reset Optional, The pin connected to the WiConnect module reset signal. Default: No connection
dan_ackme 9:b6218dc218ad 110 * @param[in] wake Optional, The pin connected to the WiConnect module wake signal. Default: No connection
dan_ackme 9:b6218dc218ad 111 * @param[in] nonBlocking Optional, indicates if the API blocking mode. See @ref setting_blocking_modes
dan_ackme 9:b6218dc218ad 112 */
dan_ackme 13:2b51f5267c92 113 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 0:ea85c4bb5e1f 114 ~Wiconnect();
dan_ackme 0:ea85c4bb5e1f 115
dan_ackme 11:ea484e1b7fc4 116
dan_ackme 11:ea484e1b7fc4 117 // ------------------------------------------------------------------------
dan_ackme 11:ea484e1b7fc4 118
dan_ackme 11:ea484e1b7fc4 119
dan_ackme 9:b6218dc218ad 120 /**
dan_ackme 9:b6218dc218ad 121 * @ingroup api_core_misc
dan_ackme 9:b6218dc218ad 122 *
dan_ackme 11:ea484e1b7fc4 123 * @brief Get instance of previously instantiated Wiconnect Library
dan_ackme 9:b6218dc218ad 124 *
dan_ackme 9:b6218dc218ad 125 * @return Pointer to instance of @ref Wiconnect Library.
dan_ackme 9:b6218dc218ad 126 */
dan_ackme 0:ea85c4bb5e1f 127 static Wiconnect* getInstance();
dan_ackme 0:ea85c4bb5e1f 128
dan_ackme 9:b6218dc218ad 129 /**
dan_ackme 9:b6218dc218ad 130 * @ingroup api_core_misc
dan_ackme 9:b6218dc218ad 131 *
dan_ackme 11:ea484e1b7fc4 132 * @brief Initialize library and communication link with WiConnect WiFi module.
dan_ackme 9:b6218dc218ad 133 *
dan_ackme 9:b6218dc218ad 134 * @note This function is always blocking regardless of configured mode.
dan_ackme 9:b6218dc218ad 135 *
dan_ackme 9:b6218dc218ad 136 * @param[in] bringNetworkUp Flag indicating if the module should try to bring the network up upon initialization.
dan_ackme 9:b6218dc218ad 137 * @return Result of initialization. See @ref WiconnectResult
dan_ackme 9:b6218dc218ad 138 */
dan_ackme 17:7268f365676b 139 WiconnectResult init(bool bringNetworkUp=true);
dan_ackme 9:b6218dc218ad 140
dan_ackme 9:b6218dc218ad 141 /**
dan_ackme 9:b6218dc218ad 142 * @ingroup api_core_misc
dan_ackme 9:b6218dc218ad 143 *
dan_ackme 11:ea484e1b7fc4 144 * @brief De-initialize library.
dan_ackme 9:b6218dc218ad 145 */
dan_ackme 0:ea85c4bb5e1f 146 void deinit();
dan_ackme 9:b6218dc218ad 147
dan_ackme 9:b6218dc218ad 148 /**
dan_ackme 9:b6218dc218ad 149 * @ingroup api_core_misc
dan_ackme 9:b6218dc218ad 150 *
dan_ackme 11:ea484e1b7fc4 151 * @brief Return TRUE if library is able to communicated with WiConnect WiFi module.
dan_ackme 9:b6218dc218ad 152 * FALSE else.
dan_ackme 9:b6218dc218ad 153 *
dan_ackme 9:b6218dc218ad 154 * @return TRUE if library can communicate with WiFi module, FALSE else.
dan_ackme 9:b6218dc218ad 155 */
dan_ackme 0:ea85c4bb5e1f 156 bool isInitialized();
dan_ackme 9:b6218dc218ad 157
dan_ackme 9:b6218dc218ad 158 /**
dan_ackme 9:b6218dc218ad 159 * @ingroup api_core_misc
dan_ackme 9:b6218dc218ad 160 *
dan_ackme 11:ea484e1b7fc4 161 * @brief Toggle the WiConnect WiFi module reset signal.
dan_ackme 9:b6218dc218ad 162 *
dan_ackme 9:b6218dc218ad 163 * @note This only resets the module if the library was instantiated with the 'reset' pin
dan_ackme 9:b6218dc218ad 164 * parameter in the Wiconnect::Wiconnect constructor.
dan_ackme 9:b6218dc218ad 165 * @note This method is always blocking. A small (1s) delay is added to ensure the module
dan_ackme 9:b6218dc218ad 166 * has returned from reset and ready.
dan_ackme 9:b6218dc218ad 167 *
dan_ackme 9:b6218dc218ad 168 * @return Result of method. See @ref WiconnectResult
dan_ackme 9:b6218dc218ad 169 */
dan_ackme 0:ea85c4bb5e1f 170 WiconnectResult reset();
dan_ackme 9:b6218dc218ad 171
dan_ackme 9:b6218dc218ad 172 /**
dan_ackme 9:b6218dc218ad 173 * @ingroup api_core_misc
dan_ackme 9:b6218dc218ad 174 *
dan_ackme 11:ea484e1b7fc4 175 * @brief Toggle the WiConnect WiFi moduel wakeup signal.
dan_ackme 9:b6218dc218ad 176 *
dan_ackme 9:b6218dc218ad 177 * @note This only wakes the module if the library was instantiated with the 'wake' pin
dan_ackme 9:b6218dc218ad 178 * parameter in the Wiconnect::Wiconnect constructor.
dan_ackme 9:b6218dc218ad 179 * @note This method is always blocking.
dan_ackme 9:b6218dc218ad 180 *
dan_ackme 9:b6218dc218ad 181 * @return Result of method. See @ref WiconnectResult
dan_ackme 9:b6218dc218ad 182 */
dan_ackme 0:ea85c4bb5e1f 183 WiconnectResult wakeup();
dan_ackme 9:b6218dc218ad 184
dan_ackme 9:b6218dc218ad 185 /**
dan_ackme 9:b6218dc218ad 186 * @ingroup api_core_misc
dan_ackme 9:b6218dc218ad 187 *
dan_ackme 11:ea484e1b7fc4 188 * @brief Flush any received data in serial RX buffer and terminate any commands on WiConnect WiFi module.
dan_ackme 13:2b51f5267c92 189 *
dan_ackme 13:2b51f5267c92 190 * The delayMs parameter is used as the delay between terminating commands on the module and flushing
dan_ackme 13:2b51f5267c92 191 * the serial RX buffer. This is needed because after terminating commands on the module, the module will
dan_ackme 13:2b51f5267c92 192 * returns a response. These responses are invalid at this point and should be flushed from the serial RX buffer.
dan_ackme 13:2b51f5267c92 193 *
dan_ackme 13:2b51f5267c92 194 * @param[in] delayMs Optional, if not specificed this only flushes the serial RX buffer.
dan_ackme 9:b6218dc218ad 195 */
dan_ackme 0:ea85c4bb5e1f 196 void flush(int delayMs = 500);
dan_ackme 0:ea85c4bb5e1f 197
dan_ackme 9:b6218dc218ad 198 /**
dan_ackme 9:b6218dc218ad 199 * @ingroup api_core_misc
dan_ackme 9:b6218dc218ad 200 *
dan_ackme 11:ea484e1b7fc4 201 * @brief Return current version of WiConnect WiFi module.
dan_ackme 13:2b51f5267c92 202 * @param[in] versionBuffer Optional, Buffer to hold received version string
dan_ackme 13:2b51f5267c92 203 * @param[in] versionBufferSize Optional, required if versionBuffer specified.
dan_ackme 13:2b51f5267c92 204 * @param[in] completeCallback Optional, callback when version is received. arg1 of callback contains version buffer pointer.
dan_ackme 13:2b51f5267c92 205 *
dan_ackme 13:2b51f5267c92 206 * @return Result of method. See @ref WiconnectResult
dan_ackme 9:b6218dc218ad 207 */
dan_ackme 0:ea85c4bb5e1f 208 WiconnectResult getVersion(char *versionBuffer = NULL, int versionBufferSize = 0, const Callback &completeCallback = Callback());
dan_ackme 0:ea85c4bb5e1f 209
dan_ackme 11:ea484e1b7fc4 210
dan_ackme 11:ea484e1b7fc4 211 // ------------------------------------------------------------------------
dan_ackme 11:ea484e1b7fc4 212
dan_ackme 11:ea484e1b7fc4 213
dan_ackme 9:b6218dc218ad 214 /**
dan_ackme 9:b6218dc218ad 215 * @ingroup api_core_send_command
dan_ackme 9:b6218dc218ad 216 *
dan_ackme 9:b6218dc218ad 217 * @brief Send command to WiConnect WiFi module
dan_ackme 13:2b51f5267c92 218 *
dan_ackme 13:2b51f5267c92 219 * @note Refer to @ref send_command_desc for more info
dan_ackme 13:2b51f5267c92 220 *
dan_ackme 13:2b51f5267c92 221 * @param[in] completeCallback Callback when command completes. arg1 of callback contains responseBuffer pointer, arg2 contains the response length
dan_ackme 13:2b51f5267c92 222 * @param[in] responseBuffer Buffer to hold command response
dan_ackme 13:2b51f5267c92 223 * @param[in] responseBufferLen Length of responseBuffer
dan_ackme 13:2b51f5267c92 224 * @param[in] timeoutMs Maximum time in milliseconds this command should execute
dan_ackme 13:2b51f5267c92 225 * @param[in] reader Callback for reading data to be read from host and send to module during command
dan_ackme 13:2b51f5267c92 226 * @param[in] user User data struct used during read Callback. Library doesn't use this. Set NULL if not used.
dan_ackme 13:2b51f5267c92 227 * @param[in] cmd WiConnect command to send to module
dan_ackme 13:2b51f5267c92 228 * @param[in] vaList Varaible list of arguments
dan_ackme 13:2b51f5267c92 229 * @return Result of method. See @ref WiconnectResult
dan_ackme 9:b6218dc218ad 230 */
dan_ackme 0:ea85c4bb5e1f 231 WiconnectResult sendCommand(const Callback &completeCallback, char *responseBuffer, int responseBufferLen,
dan_ackme 0:ea85c4bb5e1f 232 int timeoutMs, const ReaderFunc &reader, void *user, const char *cmd, va_list vaList);
dan_ackme 9:b6218dc218ad 233 /**
dan_ackme 9:b6218dc218ad 234 * @ingroup api_core_send_command
dan_ackme 9:b6218dc218ad 235 *
dan_ackme 9:b6218dc218ad 236 * @brief Send command to WiConnect WiFi module
dan_ackme 13:2b51f5267c92 237 *
dan_ackme 13:2b51f5267c92 238 * @note Refer to @ref send_command_desc for more info
dan_ackme 13:2b51f5267c92 239 *
dan_ackme 13:2b51f5267c92 240 * @param[in] responseBuffer Buffer to hold command response
dan_ackme 13:2b51f5267c92 241 * @param[in] responseBufferLen Length of responseBuffer
dan_ackme 13:2b51f5267c92 242 * @param[in] timeoutMs Maximum time in milliseconds this command should execute
dan_ackme 13:2b51f5267c92 243 * @param[in] reader Callback for reading data to be read from host and send to module during command
dan_ackme 13:2b51f5267c92 244 * @param[in] user User data struct used during read Callback. Library doesn't use this. Set NULL if not used.
dan_ackme 13:2b51f5267c92 245 * @param[in] cmd WiConnect command to send to module
dan_ackme 13:2b51f5267c92 246 * @param[in] vaList Varaible list of arguments
dan_ackme 13:2b51f5267c92 247 * @return Result of method. See @ref WiconnectResult
dan_ackme 9:b6218dc218ad 248 */
dan_ackme 0:ea85c4bb5e1f 249 WiconnectResult sendCommand(char *responseBuffer, int responseBufferLen, int timeoutMs, const ReaderFunc &reader,
dan_ackme 0:ea85c4bb5e1f 250 void *user, const char *cmd, va_list vaList);
dan_ackme 9:b6218dc218ad 251
dan_ackme 9:b6218dc218ad 252 /**
dan_ackme 9:b6218dc218ad 253 * @ingroup api_core_send_command
dan_ackme 9:b6218dc218ad 254 *
dan_ackme 9:b6218dc218ad 255 * @brief Send command to WiConnect WiFi module
dan_ackme 9:b6218dc218ad 256 *
dan_ackme 13:2b51f5267c92 257 * @note Refer to @ref send_command_desc for more info
dan_ackme 9:b6218dc218ad 258 * @note This method supports variable arguments
dan_ackme 9:b6218dc218ad 259 *
dan_ackme 13:2b51f5267c92 260 * @param[in] responseBuffer Buffer to hold command response
dan_ackme 13:2b51f5267c92 261 * @param[in] responseBufferLen Length of responseBuffer
dan_ackme 13:2b51f5267c92 262 * @param[in] timeoutMs Maximum time in milliseconds this command should execute
dan_ackme 13:2b51f5267c92 263 * @param[in] reader Callback for reading data to be read from host and send to module during command
dan_ackme 13:2b51f5267c92 264 * @param[in] user User data struct used during read Callback. Library doesn't use this. Set NULL if not used.
dan_ackme 13:2b51f5267c92 265 * @param[in] cmd WiConnect command to send to module
dan_ackme 13:2b51f5267c92 266 * @return Result of method. See @ref WiconnectResult
dan_ackme 9:b6218dc218ad 267 */
dan_ackme 0:ea85c4bb5e1f 268 WiconnectResult sendCommand(char *responseBuffer, int responseBufferLen, int timeoutMs, const ReaderFunc &reader,
dan_ackme 0:ea85c4bb5e1f 269 void *user, const char *cmd, ...);
dan_ackme 9:b6218dc218ad 270
dan_ackme 9:b6218dc218ad 271 /**
dan_ackme 9:b6218dc218ad 272 * @ingroup api_core_send_command
dan_ackme 9:b6218dc218ad 273 *
dan_ackme 9:b6218dc218ad 274 * @brief Send command to WiConnect WiFi module
dan_ackme 9:b6218dc218ad 275 *
dan_ackme 13:2b51f5267c92 276 * This method uses the library internal buffer.
dan_ackme 13:2b51f5267c92 277 *
dan_ackme 13:2b51f5267c92 278 * @note Refer to @ref send_command_desc for more info
dan_ackme 9:b6218dc218ad 279 * @note This method supports variable arguments
dan_ackme 9:b6218dc218ad 280 *
dan_ackme 13:2b51f5267c92 281 * @param[in] timeoutMs Maximum time in milliseconds this command should execute
dan_ackme 13:2b51f5267c92 282 * @param[in] reader Callback for reading data to be read from host and send to module during command
dan_ackme 13:2b51f5267c92 283 * @param[in] user User data struct used during read Callback. Library doesn't use this. Set NULL if not used.
dan_ackme 13:2b51f5267c92 284 * @param[in] cmd WiConnect command to send to module
dan_ackme 13:2b51f5267c92 285 * @return Result of method. See @ref WiconnectResult
dan_ackme 9:b6218dc218ad 286 */
dan_ackme 0:ea85c4bb5e1f 287 WiconnectResult sendCommand( int timeoutMs, const ReaderFunc &reader, void *user, const char *cmd, ...);
dan_ackme 9:b6218dc218ad 288
dan_ackme 9:b6218dc218ad 289 /**
dan_ackme 9:b6218dc218ad 290 * @ingroup api_core_send_command
dan_ackme 9:b6218dc218ad 291 *
dan_ackme 9:b6218dc218ad 292 * @brief Send command to WiConnect WiFi module
dan_ackme 9:b6218dc218ad 293 *
dan_ackme 13:2b51f5267c92 294 * - This method uses the library internal buffer and
dan_ackme 13:2b51f5267c92 295 * - default timeout. See setCommandDefaultTimeout()
dan_ackme 13:2b51f5267c92 296 *
dan_ackme 13:2b51f5267c92 297 * @note Refer to @ref send_command_desc for more info
dan_ackme 9:b6218dc218ad 298 * @note This method supports variable arguments
dan_ackme 9:b6218dc218ad 299 *
dan_ackme 13:2b51f5267c92 300 * @param[in] reader Callback for reading data to be read from host and send to module during command
dan_ackme 13:2b51f5267c92 301 * @param[in] user User data struct used during read Callback. Library doesn't use this. Set NULL if not used.
dan_ackme 13:2b51f5267c92 302 * @param[in] cmd WiConnect command to send to module
dan_ackme 13:2b51f5267c92 303 * @return Result of method. See @ref WiconnectResult
dan_ackme 9:b6218dc218ad 304 */
dan_ackme 0:ea85c4bb5e1f 305 WiconnectResult sendCommand(const ReaderFunc &reader, void *user, const char *cmd, ...);
dan_ackme 9:b6218dc218ad 306
dan_ackme 9:b6218dc218ad 307 /**
dan_ackme 9:b6218dc218ad 308 * @ingroup api_core_send_command
dan_ackme 9:b6218dc218ad 309 *
dan_ackme 9:b6218dc218ad 310 * @brief Send command to WiConnect WiFi module
dan_ackme 9:b6218dc218ad 311 *
dan_ackme 13:2b51f5267c92 312 * @note Refer to @ref send_command_desc for more info
dan_ackme 9:b6218dc218ad 313 * @note This method supports variable arguments
dan_ackme 9:b6218dc218ad 314 *
dan_ackme 13:2b51f5267c92 315 * @param[in] responseBuffer Buffer to hold command response
dan_ackme 13:2b51f5267c92 316 * @param[in] responseBufferLen Length of responseBuffer
dan_ackme 13:2b51f5267c92 317 * @param[in] timeoutMs Maximum time in milliseconds this command should execute
dan_ackme 13:2b51f5267c92 318 * @param[in] cmd WiConnect command to send to module
dan_ackme 13:2b51f5267c92 319 * @return Result of method. See @ref WiconnectResult
dan_ackme 9:b6218dc218ad 320 */
dan_ackme 0:ea85c4bb5e1f 321 WiconnectResult sendCommand(char *responseBuffer, int responseBufferLen, int timeoutMs, const char *cmd, ...);
dan_ackme 9:b6218dc218ad 322
dan_ackme 9:b6218dc218ad 323 /**
dan_ackme 9:b6218dc218ad 324 * @ingroup api_core_send_command
dan_ackme 9:b6218dc218ad 325 *
dan_ackme 9:b6218dc218ad 326 * @brief Send command to WiConnect WiFi module
dan_ackme 9:b6218dc218ad 327 *
dan_ackme 13:2b51f5267c92 328 * @note Refer to @ref send_command_desc for more info
dan_ackme 9:b6218dc218ad 329 * @note This method supports variable arguments
dan_ackme 9:b6218dc218ad 330 *
dan_ackme 13:2b51f5267c92 331 * @param[in] completeCallback Callback when command completes. arg1 of callback contains responseBuffer pointer, arg2 contains the response length
dan_ackme 13:2b51f5267c92 332 * @param[in] responseBuffer Buffer to hold command response
dan_ackme 13:2b51f5267c92 333 * @param[in] responseBufferLen Length of responseBuffer
dan_ackme 13:2b51f5267c92 334 * @param[in] cmd WiConnect command to send to module
dan_ackme 13:2b51f5267c92 335 * @return Result of method. See @ref WiconnectResult
dan_ackme 9:b6218dc218ad 336 */
dan_ackme 0:ea85c4bb5e1f 337 WiconnectResult sendCommand(const Callback &completeCallback, char *responseBuffer, int responseBufferLen, const char *cmd, ...);
dan_ackme 9:b6218dc218ad 338
dan_ackme 9:b6218dc218ad 339 /**
dan_ackme 9:b6218dc218ad 340 * @ingroup api_core_send_command
dan_ackme 9:b6218dc218ad 341 *
dan_ackme 9:b6218dc218ad 342 * @brief Send command to WiConnect WiFi module
dan_ackme 9:b6218dc218ad 343 *
dan_ackme 13:2b51f5267c92 344 * @note Refer to @ref send_command_desc for more info
dan_ackme 9:b6218dc218ad 345 * @note This method supports variable arguments
dan_ackme 9:b6218dc218ad 346 *
dan_ackme 13:2b51f5267c92 347 * @param[in] responseBuffer Buffer to hold command response
dan_ackme 13:2b51f5267c92 348 * @param[in] responseBufferLen Length of responseBuffer
dan_ackme 13:2b51f5267c92 349 * @param[in] cmd WiConnect command to send to module
dan_ackme 13:2b51f5267c92 350 * @return Result of method. See @ref WiconnectResult
dan_ackme 9:b6218dc218ad 351 */
dan_ackme 0:ea85c4bb5e1f 352 WiconnectResult sendCommand(char *responseBuffer, int responseBufferLen, const char *cmd, ...);
dan_ackme 9:b6218dc218ad 353
dan_ackme 9:b6218dc218ad 354 /**
dan_ackme 9:b6218dc218ad 355 * @ingroup api_core_send_command
dan_ackme 9:b6218dc218ad 356 *
dan_ackme 9:b6218dc218ad 357 * @brief Send command to WiConnect WiFi module
dan_ackme 9:b6218dc218ad 358 *
dan_ackme 13:2b51f5267c92 359 * - This method uses the library internal buffer and
dan_ackme 13:2b51f5267c92 360 * - default timeout. See setCommandDefaultTimeout()
dan_ackme 13:2b51f5267c92 361 *
dan_ackme 13:2b51f5267c92 362 * @note Refer to @ref send_command_desc for more info
dan_ackme 9:b6218dc218ad 363 * @note This method supports variable arguments
dan_ackme 9:b6218dc218ad 364 *
dan_ackme 13:2b51f5267c92 365 * @param[in] completeCallback Callback when command completes. arg1 of callback contains responseBuffer pointer, arg2 contains the response length
dan_ackme 13:2b51f5267c92 366 * @param[in] cmd WiConnect command to send to module
dan_ackme 13:2b51f5267c92 367 * @return Result of method. See @ref WiconnectResult
dan_ackme 9:b6218dc218ad 368 */
dan_ackme 0:ea85c4bb5e1f 369 WiconnectResult sendCommand(const Callback &completeCallback, const char *cmd, ...);
dan_ackme 9:b6218dc218ad 370
dan_ackme 9:b6218dc218ad 371 /**
dan_ackme 9:b6218dc218ad 372 * @ingroup api_core_send_command
dan_ackme 9:b6218dc218ad 373 *
dan_ackme 9:b6218dc218ad 374 * @brief Send command to WiConnect WiFi module
dan_ackme 9:b6218dc218ad 375 *
dan_ackme 13:2b51f5267c92 376 * - This method uses the library internal buffer and
dan_ackme 13:2b51f5267c92 377 * - default timeout. See setCommandDefaultTimeout()
dan_ackme 13:2b51f5267c92 378 *
dan_ackme 13:2b51f5267c92 379 * @note Refer to @ref send_command_desc for more info
dan_ackme 9:b6218dc218ad 380 * @note This method supports variable arguments
dan_ackme 9:b6218dc218ad 381 *
dan_ackme 13:2b51f5267c92 382 * @param[in] cmd WiConnect command to send to module
dan_ackme 13:2b51f5267c92 383 * @return Result of method. See @ref WiconnectResult
dan_ackme 9:b6218dc218ad 384 */
dan_ackme 0:ea85c4bb5e1f 385 WiconnectResult sendCommand(const char *cmd, ...);
dan_ackme 9:b6218dc218ad 386
dan_ackme 9:b6218dc218ad 387 /**
dan_ackme 9:b6218dc218ad 388 * @ingroup api_core_send_command
dan_ackme 9:b6218dc218ad 389 *
dan_ackme 13:2b51f5267c92 390 * This method uses the library internal buffer
dan_ackme 9:b6218dc218ad 391 *
dan_ackme 13:2b51f5267c92 392 * @note Refer to @ref send_command_desc for more info
dan_ackme 9:b6218dc218ad 393 * @note This method supports variable arguments
dan_ackme 9:b6218dc218ad 394 *
dan_ackme 13:2b51f5267c92 395 * @param[in] completeCallback Callback when command completes. arg1 of callback contains responseBuffer pointer, arg2 contains the response length
dan_ackme 13:2b51f5267c92 396 * @param[in] timeoutMs Maximum time in milliseconds this command should execute
dan_ackme 13:2b51f5267c92 397 * @param[in] cmd WiConnect command to send to module
dan_ackme 13:2b51f5267c92 398 * @return Result of method. See @ref WiconnectResult
dan_ackme 9:b6218dc218ad 399 */
dan_ackme 0:ea85c4bb5e1f 400 WiconnectResult sendCommand(const Callback &completeCallback, int timeoutMs, const char *cmd, ...);
dan_ackme 9:b6218dc218ad 401
dan_ackme 9:b6218dc218ad 402 /**
dan_ackme 9:b6218dc218ad 403 * @ingroup api_core_send_command
dan_ackme 9:b6218dc218ad 404 *
dan_ackme 9:b6218dc218ad 405 * @brief Send command to WiConnect WiFi module
dan_ackme 9:b6218dc218ad 406 *
dan_ackme 13:2b51f5267c92 407 * This method uses the library internal buffer
dan_ackme 13:2b51f5267c92 408 *
dan_ackme 13:2b51f5267c92 409 * @note Refer to @ref send_command_desc for more info
dan_ackme 9:b6218dc218ad 410 * @note This method supports variable arguments
dan_ackme 9:b6218dc218ad 411 *
dan_ackme 13:2b51f5267c92 412 * @param[in] timeoutMs Maximum time in milliseconds this command should execute
dan_ackme 13:2b51f5267c92 413 * @param[in] cmd WiConnect command to send to module
dan_ackme 13:2b51f5267c92 414 * @return Result of method. See @ref WiconnectResult
dan_ackme 9:b6218dc218ad 415 */
dan_ackme 0:ea85c4bb5e1f 416 WiconnectResult sendCommand(int timeoutMs, const char *cmd, ...);
dan_ackme 9:b6218dc218ad 417
dan_ackme 9:b6218dc218ad 418 /**
dan_ackme 9:b6218dc218ad 419 * @ingroup api_core_send_command
dan_ackme 9:b6218dc218ad 420 *
dan_ackme 13:2b51f5267c92 421 * - This method uses the library internal buffer and
dan_ackme 13:2b51f5267c92 422 * - default timeout. See setCommandDefaultTimeout()
dan_ackme 9:b6218dc218ad 423 *
dan_ackme 13:2b51f5267c92 424 * @note Refer to @ref send_command_desc for more info
dan_ackme 13:2b51f5267c92 425 *
dan_ackme 13:2b51f5267c92 426 * @param[in] cmd WiConnect command to send to module
dan_ackme 13:2b51f5267c92 427 * @param[in] vaList Varaible list of arguments
dan_ackme 13:2b51f5267c92 428 * @return Result of method. See @ref WiconnectResult
dan_ackme 9:b6218dc218ad 429 */
dan_ackme 0:ea85c4bb5e1f 430 WiconnectResult sendCommand(const char *cmd, va_list vaList);
dan_ackme 0:ea85c4bb5e1f 431
dan_ackme 9:b6218dc218ad 432 /**
dan_ackme 9:b6218dc218ad 433 * @ingroup api_core_send_command
dan_ackme 9:b6218dc218ad 434 *
dan_ackme 11:ea484e1b7fc4 435 * @brief Check the status of the currently executing command.
dan_ackme 9:b6218dc218ad 436 *
dan_ackme 9:b6218dc218ad 437 * Refer to @ref WiconnectResult for more information about the return code.
dan_ackme 9:b6218dc218ad 438 *
dan_ackme 9:b6218dc218ad 439 * @note This command is only applicable for non-blocking mode. Refer to @ref setting_blocking_modes.
dan_ackme 13:2b51f5267c92 440 *
dan_ackme 13:2b51f5267c92 441 * @return Result of method. See @ref WiconnectResult
dan_ackme 9:b6218dc218ad 442 */
dan_ackme 0:ea85c4bb5e1f 443 WiconnectResult checkCurrentCommand();
dan_ackme 9:b6218dc218ad 444
dan_ackme 9:b6218dc218ad 445 /**
dan_ackme 9:b6218dc218ad 446 * @ingroup api_core_send_command
dan_ackme 9:b6218dc218ad 447 *
dan_ackme 11:ea484e1b7fc4 448 * @brief Stop the currently executing command.
dan_ackme 9:b6218dc218ad 449 *
dan_ackme 9:b6218dc218ad 450 * @note This command is only applicable for non-blocking mode. Refer to @ref setting_blocking_modes.
dan_ackme 9:b6218dc218ad 451 */
dan_ackme 0:ea85c4bb5e1f 452 void stopCurrentCommand();
dan_ackme 9:b6218dc218ad 453
dan_ackme 11:ea484e1b7fc4 454
dan_ackme 11:ea484e1b7fc4 455
dan_ackme 11:ea484e1b7fc4 456 // ------------------------------------------------------------------------
dan_ackme 11:ea484e1b7fc4 457
dan_ackme 11:ea484e1b7fc4 458
dan_ackme 11:ea484e1b7fc4 459 /**
dan_ackme 11:ea484e1b7fc4 460 * @ingroup api_core_misc
dan_ackme 11:ea484e1b7fc4 461 *
dan_ackme 11:ea484e1b7fc4 462 * @brief When the WiConnect WiFi module returns a response, it contains a
dan_ackme 11:ea484e1b7fc4 463 * response code in the header. This function converts the previous response code
dan_ackme 11:ea484e1b7fc4 464 * to a readable string.
dan_ackme 13:2b51f5267c92 465 *
dan_ackme 13:2b51f5267c92 466 * @return string representation of module response code
dan_ackme 11:ea484e1b7fc4 467 */
dan_ackme 11:ea484e1b7fc4 468 const char* getLastCommandResponseCodeStr();
dan_ackme 11:ea484e1b7fc4 469
dan_ackme 11:ea484e1b7fc4 470 /**
dan_ackme 11:ea484e1b7fc4 471 * @ingroup api_core_misc
dan_ackme 11:ea484e1b7fc4 472 *
dan_ackme 11:ea484e1b7fc4 473 * @brief Return the length in bytes of the previous response.
dan_ackme 13:2b51f5267c92 474 *
dan_ackme 13:2b51f5267c92 475 * @return length of previous response
dan_ackme 11:ea484e1b7fc4 476 */
dan_ackme 11:ea484e1b7fc4 477 uint16_t getLastCommandResponseLength();
dan_ackme 11:ea484e1b7fc4 478
dan_ackme 11:ea484e1b7fc4 479 /**
dan_ackme 11:ea484e1b7fc4 480 * @ingroup api_core_misc
dan_ackme 11:ea484e1b7fc4 481 *
dan_ackme 11:ea484e1b7fc4 482 * @brief Return pointer to internal response buffer.
dan_ackme 13:2b51f5267c92 483 *
dan_ackme 13:2b51f5267c92 484 * @return pointer to internal response buffer
dan_ackme 11:ea484e1b7fc4 485 */
dan_ackme 11:ea484e1b7fc4 486 char* getResponseBuffer();
dan_ackme 11:ea484e1b7fc4 487
dan_ackme 11:ea484e1b7fc4 488 /**
dan_ackme 11:ea484e1b7fc4 489 * @ingroup api_core_misc
dan_ackme 11:ea484e1b7fc4 490 *
dan_ackme 11:ea484e1b7fc4 491 * @brief Helper method to convert previous response to uint32
dan_ackme 13:2b51f5267c92 492 *
dan_ackme 13:2b51f5267c92 493 * @note This uses the internal response buffer.
dan_ackme 13:2b51f5267c92 494 *
dan_ackme 13:2b51f5267c92 495 * @param[out] uint32Ptr Pointer to hold result of conversion.
dan_ackme 13:2b51f5267c92 496 * @return Result of conversion. See @ref WiconnectResult
dan_ackme 11:ea484e1b7fc4 497 */
dan_ackme 11:ea484e1b7fc4 498 WiconnectResult responseToUint32(uint32_t *uint32Ptr);
dan_ackme 11:ea484e1b7fc4 499
dan_ackme 11:ea484e1b7fc4 500 /**
dan_ackme 11:ea484e1b7fc4 501 * @ingroup api_core_misc
dan_ackme 11:ea484e1b7fc4 502 *
dan_ackme 11:ea484e1b7fc4 503 * @brief Helper method to convert previous response to int32
dan_ackme 13:2b51f5267c92 504 *
dan_ackme 13:2b51f5267c92 505 * @note This uses the internal response buffer.
dan_ackme 13:2b51f5267c92 506 *
dan_ackme 13:2b51f5267c92 507 * @param[out] int32Ptr Pointer to hold result of conversion.
dan_ackme 13:2b51f5267c92 508 * @return Result of conversion. See @ref WiconnectResult
dan_ackme 11:ea484e1b7fc4 509 */
dan_ackme 11:ea484e1b7fc4 510 WiconnectResult responseToInt32(int32_t *int32Ptr);
dan_ackme 11:ea484e1b7fc4 511
dan_ackme 11:ea484e1b7fc4 512
dan_ackme 11:ea484e1b7fc4 513 // ------------------------------------------------------------------------
dan_ackme 11:ea484e1b7fc4 514
dan_ackme 11:ea484e1b7fc4 515
dan_ackme 9:b6218dc218ad 516 /**
dan_ackme 9:b6218dc218ad 517 * @ingroup api_core_settings
dan_ackme 9:b6218dc218ad 518 *
dan_ackme 11:ea484e1b7fc4 519 * @brief Sets the default maximum time an API method may execute before
dan_ackme 9:b6218dc218ad 520 * terminating and return a timeout error code.
dan_ackme 9:b6218dc218ad 521 *
dan_ackme 13:2b51f5267c92 522 * @note All API methods (execpt some sendCommand()) use this default value.
dan_ackme 13:2b51f5267c92 523 *
dan_ackme 13:2b51f5267c92 524 * @param[in] timeoutMs Default command timeout in milliseconds
dan_ackme 9:b6218dc218ad 525 */
dan_ackme 0:ea85c4bb5e1f 526 void setCommandDefaultTimeout(int timeoutMs);
dan_ackme 9:b6218dc218ad 527
dan_ackme 9:b6218dc218ad 528 /**
dan_ackme 9:b6218dc218ad 529 * @ingroup api_core_settings
dan_ackme 9:b6218dc218ad 530 *
dan_ackme 11:ea484e1b7fc4 531 * @brief Returns the current default maximum API execution time.
dan_ackme 13:2b51f5267c92 532 *
dan_ackme 13:2b51f5267c92 533 * @return Default command timeout in milliseconds
dan_ackme 9:b6218dc218ad 534 */
dan_ackme 0:ea85c4bb5e1f 535 int getCommandDefaultTimeout();
dan_ackme 0:ea85c4bb5e1f 536
dan_ackme 9:b6218dc218ad 537 /**
dan_ackme 9:b6218dc218ad 538 * @ingroup api_core_settings
dan_ackme 9:b6218dc218ad 539 *
dan_ackme 11:ea484e1b7fc4 540 * @brief Sets a mapping function used to convert from a host Pin to WiConnect WiFi module GPIO.
dan_ackme 13:2b51f5267c92 541 *
dan_ackme 13:2b51f5267c92 542 * @param[in] mapper Pin to GPIO mapper function pointer
dan_ackme 9:b6218dc218ad 543 */
dan_ackme 0:ea85c4bb5e1f 544 void setPinToGpioMapper(PinToGpioMapper mapper);
dan_ackme 0:ea85c4bb5e1f 545
dan_ackme 9:b6218dc218ad 546 /**
dan_ackme 9:b6218dc218ad 547 * @ingroup api_core_settings
dan_ackme 9:b6218dc218ad 548 *
dan_ackme 11:ea484e1b7fc4 549 * @brief Sets callback function used to debug WiConnect WiFi module RX/TX serial data.
dan_ackme 13:2b51f5267c92 550 *
dan_ackme 13:2b51f5267c92 551 * @param[in] logFunc Logging function pointer
dan_ackme 9:b6218dc218ad 552 */
dan_ackme 0:ea85c4bb5e1f 553 void setDebugLogger(LogFunc logFunc);
dan_ackme 9:b6218dc218ad 554
dan_ackme 9:b6218dc218ad 555 /**
dan_ackme 9:b6218dc218ad 556 * @ingroup api_core_settings
dan_ackme 9:b6218dc218ad 557 *
dan_ackme 11:ea484e1b7fc4 558 * @brief Sets callback used when Wiconnect Library hits and internal assertion.
dan_ackme 9:b6218dc218ad 559 *
dan_ackme 9:b6218dc218ad 560 * @note This is mainly for debugging. There's nothing the callback can do to fix the assertion.
dan_ackme 13:2b51f5267c92 561 *
dan_ackme 13:2b51f5267c92 562 * @param[in] assertLogFunc Logging function pointer
dan_ackme 9:b6218dc218ad 563 */
dan_ackme 6:8a87a59d0d21 564 void setAssertLogger(LogFunc assertLogFunc);
dan_ackme 0:ea85c4bb5e1f 565
dan_ackme 11:ea484e1b7fc4 566
dan_ackme 11:ea484e1b7fc4 567 // ------------------------------------------------------------------------
dan_ackme 11:ea484e1b7fc4 568
dan_ackme 11:ea484e1b7fc4 569
dan_ackme 0:ea85c4bb5e1f 570 #ifdef WICONNECT_ASYNC_TIMER_ENABLED
dan_ackme 9:b6218dc218ad 571 /**
dan_ackme 9:b6218dc218ad 572 * @ingroup api_core_send_command
dan_ackme 9:b6218dc218ad 573 *
dan_ackme 11:ea484e1b7fc4 574 * @brief Add user command to be executed asynchronously.
dan_ackme 9:b6218dc218ad 575 *
dan_ackme 13:2b51f5267c92 576 * Refer to @ref setting_async_processing for more info.
dan_ackme 13:2b51f5267c92 577 *
dan_ackme 13:2b51f5267c92 578 * @param[in] command Pointer to QueuedCommand to be executed asynchronously
dan_ackme 13:2b51f5267c92 579 * @param[in] commandCompleteHandler Callback to be executed when processing is complete.
dan_ackme 13:2b51f5267c92 580 * @return Result of method. See @ref WiconnectResult
dan_ackme 9:b6218dc218ad 581 */
dan_ackme 0:ea85c4bb5e1f 582 WiconnectResult enqueueCommand(QueuedCommand *command, const Callback &commandCompleteHandler = Callback());
dan_ackme 9:b6218dc218ad 583
dan_ackme 9:b6218dc218ad 584 /**
dan_ackme 9:b6218dc218ad 585 * @ingroup api_core_settings
dan_ackme 9:b6218dc218ad 586 *
dan_ackme 11:ea484e1b7fc4 587 * @brief Set the period at which an asynchronous command should be processed.
dan_ackme 13:2b51f5267c92 588 *
dan_ackme 13:2b51f5267c92 589 * Refer to @ref setting_async_processing for more info.
dan_ackme 13:2b51f5267c92 590 *
dan_ackme 13:2b51f5267c92 591 * @param[in] periodMs Processing period in milliseconds
dan_ackme 9:b6218dc218ad 592 */
dan_ackme 0:ea85c4bb5e1f 593 void setCommandProcessingPeriod(uint32_t periodMs);
dan_ackme 0:ea85c4bb5e1f 594 #endif
dan_ackme 0:ea85c4bb5e1f 595
dan_ackme 9:b6218dc218ad 596
dan_ackme 9:b6218dc218ad 597 /**
dan_ackme 9:b6218dc218ad 598 * @ingroup conversion_util
dan_ackme 9:b6218dc218ad 599 *
dan_ackme 11:ea484e1b7fc4 600 * @brief Converts a @ref WiconnectResult to string representation.
dan_ackme 13:2b51f5267c92 601 *
dan_ackme 13:2b51f5267c92 602 * @param[in] wiconnectResult Result code
dan_ackme 13:2b51f5267c92 603 * @return String representaion of result code
dan_ackme 9:b6218dc218ad 604 */
dan_ackme 9:b6218dc218ad 605 static const char* getWiconnectResultStr(WiconnectResult wiconnectResult);
dan_ackme 9:b6218dc218ad 606
dan_ackme 0:ea85c4bb5e1f 607 protected:
dan_ackme 0:ea85c4bb5e1f 608
dan_ackme 0:ea85c4bb5e1f 609 #ifdef WICONNECT_ENABLE_MALLOC
dan_ackme 0:ea85c4bb5e1f 610 void* (*_malloc)(size_t);
dan_ackme 0:ea85c4bb5e1f 611 void (*_free)(void *);
dan_ackme 0:ea85c4bb5e1f 612 friend class QueuedCommand;
dan_ackme 0:ea85c4bb5e1f 613 friend class WiconnectSerial;
dan_ackme 0:ea85c4bb5e1f 614 friend class ScanResult;
dan_ackme 6:8a87a59d0d21 615 friend class ScanResultList;
dan_ackme 17:7268f365676b 616 friend class WiconnectSocket;
dan_ackme 17:7268f365676b 617 friend class WiconnectFile;
dan_ackme 0:ea85c4bb5e1f 618 #endif
dan_ackme 0:ea85c4bb5e1f 619
dan_ackme 0:ea85c4bb5e1f 620 wiconnect::WiconnectSerial serial;
dan_ackme 0:ea85c4bb5e1f 621 wiconnect::Gpio resetGpio;
dan_ackme 0:ea85c4bb5e1f 622 wiconnect::Gpio wakeGpio;
dan_ackme 0:ea85c4bb5e1f 623
dan_ackme 0:ea85c4bb5e1f 624 volatile bool commandExecuting;
dan_ackme 0:ea85c4bb5e1f 625 bool initialized;
dan_ackme 0:ea85c4bb5e1f 626 bool nonBlocking;
dan_ackme 0:ea85c4bb5e1f 627
dan_ackme 0:ea85c4bb5e1f 628 PinToGpioMapper pinToGpioMapper;
dan_ackme 0:ea85c4bb5e1f 629
dan_ackme 0:ea85c4bb5e1f 630 char *internalBuffer;
dan_ackme 0:ea85c4bb5e1f 631 int internalBufferSize;
dan_ackme 0:ea85c4bb5e1f 632 bool internalBufferAlloc;
dan_ackme 0:ea85c4bb5e1f 633 uint8_t internalProcessingState;
dan_ackme 0:ea85c4bb5e1f 634 void *currentCommandId;
dan_ackme 0:ea85c4bb5e1f 635
dan_ackme 0:ea85c4bb5e1f 636 wiconnect::TimeoutTimer timeoutTimer;
dan_ackme 0:ea85c4bb5e1f 637 int defaultTimeoutMs;
dan_ackme 0:ea85c4bb5e1f 638
dan_ackme 0:ea85c4bb5e1f 639 uint8_t commandHeaderBuffer[32];
dan_ackme 0:ea85c4bb5e1f 640 char commandFormatBuffer[WICONNECT_MAX_CMD_SIZE];
dan_ackme 0:ea85c4bb5e1f 641 uint8_t commandContext[96];
dan_ackme 0:ea85c4bb5e1f 642
dan_ackme 0:ea85c4bb5e1f 643 void prepare(void *internalBuffer, int internalBufferSize, bool nonBlocking);
dan_ackme 0:ea85c4bb5e1f 644 WiconnectResult inline receiveResponse();
dan_ackme 0:ea85c4bb5e1f 645 WiconnectResult inline receivePacket();
dan_ackme 0:ea85c4bb5e1f 646 void issueCommandCallback(WiconnectResult result);
dan_ackme 0:ea85c4bb5e1f 647
dan_ackme 6:8a87a59d0d21 648 LogFunc debugLogger;
dan_ackme 6:8a87a59d0d21 649 LogFunc assertLogger;
dan_ackme 0:ea85c4bb5e1f 650 void debugLog(const char *msg, ...);
dan_ackme 0:ea85c4bb5e1f 651
dan_ackme 0:ea85c4bb5e1f 652 #ifdef WICONNECT_ASYNC_TIMER_ENABLED
dan_ackme 0:ea85c4bb5e1f 653 wiconnect::PeriodicTimer commandProcessorTimer;
dan_ackme 0:ea85c4bb5e1f 654 uint32_t commandProcessingPeriod;
dan_ackme 0:ea85c4bb5e1f 655 CommandQueue commandQueue;
dan_ackme 0:ea85c4bb5e1f 656 wiconnect::QueuedCommand *currentQueuedCommand;
dan_ackme 0:ea85c4bb5e1f 657
dan_ackme 0:ea85c4bb5e1f 658 void commandProcessingTimerHandler(void);
dan_ackme 0:ea85c4bb5e1f 659 void processNextQueuedCommand();
dan_ackme 0:ea85c4bb5e1f 660 void checkQueuedCommandTimeout();
dan_ackme 0:ea85c4bb5e1f 661 #endif
dan_ackme 0:ea85c4bb5e1f 662
dan_ackme 0:ea85c4bb5e1f 663 friend class NetworkInterface;
dan_ackme 0:ea85c4bb5e1f 664 friend class SocketInterface;
dan_ackme 0:ea85c4bb5e1f 665 friend class FileInterface;
dan_ackme 0:ea85c4bb5e1f 666 };
dan_ackme 0:ea85c4bb5e1f 667
dan_ackme 0:ea85c4bb5e1f 668 }
dan_ackme 17:7268f365676b 669
dan_ackme 17:7268f365676b 670
dan_ackme 17:7268f365676b 671 #include "sdkTypes.h"
dan_ackme 17:7268f365676b 672