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 Sep 06 20:34:01 2014 -0700
Revision:
24:e27e23297f02
Parent:
21:17bb3eddcbae
Child:
27:b63f5a9cdefa
add api to get/set module settings

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dan_ackme 21:17bb3eddcbae 1 /**
dan_ackme 21:17bb3eddcbae 2 * ACKme WiConnect Host Library is licensed under the BSD licence:
dan_ackme 21:17bb3eddcbae 3 *
dan_ackme 21:17bb3eddcbae 4 * Copyright (c)2014 ACKme Networks.
dan_ackme 21:17bb3eddcbae 5 * All rights reserved.
dan_ackme 21:17bb3eddcbae 6 *
dan_ackme 21:17bb3eddcbae 7 * Redistribution and use in source and binary forms, with or without modification,
dan_ackme 21:17bb3eddcbae 8 * are permitted provided that the following conditions are met:
dan_ackme 21:17bb3eddcbae 9 *
dan_ackme 21:17bb3eddcbae 10 * 1. Redistributions of source code must retain the above copyright notice,
dan_ackme 21:17bb3eddcbae 11 * this list of conditions and the following disclaimer.
dan_ackme 21:17bb3eddcbae 12 * 2. Redistributions in binary form must reproduce the above copyright notice,
dan_ackme 21:17bb3eddcbae 13 * this list of conditions and the following disclaimer in the documentation
dan_ackme 21:17bb3eddcbae 14 * and/or other materials provided with the distribution.
dan_ackme 21:17bb3eddcbae 15 * 3. The name of the author may not be used to endorse or promote products
dan_ackme 21:17bb3eddcbae 16 * derived from this software without specific prior written permission.
dan_ackme 21:17bb3eddcbae 17 *
dan_ackme 21:17bb3eddcbae 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS AND ANY EXPRESS OR IMPLIED
dan_ackme 21:17bb3eddcbae 19 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
dan_ackme 21:17bb3eddcbae 20 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
dan_ackme 21:17bb3eddcbae 21 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
dan_ackme 21:17bb3eddcbae 22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
dan_ackme 21:17bb3eddcbae 23 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
dan_ackme 21:17bb3eddcbae 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
dan_ackme 21:17bb3eddcbae 25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
dan_ackme 21:17bb3eddcbae 26 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
dan_ackme 21:17bb3eddcbae 27 * OF SUCH DAMAGE.
dan_ackme 0:ea85c4bb5e1f 28 */
dan_ackme 0:ea85c4bb5e1f 29 #pragma once
dan_ackme 0:ea85c4bb5e1f 30
dan_ackme 0:ea85c4bb5e1f 31 #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 24:e27e23297f02 454 /**
dan_ackme 24:e27e23297f02 455 * @ingroup api_core_misc
dan_ackme 24:e27e23297f02 456 *
dan_ackme 24:e27e23297f02 457 * @brief Set a module setting
dan_ackme 24:e27e23297f02 458 *
dan_ackme 24:e27e23297f02 459 * @param setting @ref WiconnectSetting
dan_ackme 24:e27e23297f02 460 * @param value The value to set
dan_ackme 24:e27e23297f02 461 *
dan_ackme 24:e27e23297f02 462 * @return Result of method. See @ref WiconnectResult
dan_ackme 24:e27e23297f02 463 */
dan_ackme 24:e27e23297f02 464 WiconnectResult setSetting(WiconnectSetting setting, uint32_t value);
dan_ackme 24:e27e23297f02 465 WiconnectResult setSetting(WiconnectSetting setting, const char *value);
dan_ackme 11:ea484e1b7fc4 466
dan_ackme 24:e27e23297f02 467 /**
dan_ackme 24:e27e23297f02 468 * @ingroup api_core_misc
dan_ackme 24:e27e23297f02 469 *
dan_ackme 24:e27e23297f02 470 * @brief Get a module setting
dan_ackme 24:e27e23297f02 471 *
dan_ackme 24:e27e23297f02 472 * @param setting @ref WiconnectSetting
dan_ackme 24:e27e23297f02 473 * @param value Pointer to buffer to contain value
dan_ackme 24:e27e23297f02 474 *
dan_ackme 24:e27e23297f02 475 * @return Result of method. See @ref WiconnectResult
dan_ackme 24:e27e23297f02 476 */
dan_ackme 24:e27e23297f02 477 WiconnectResult getSetting(WiconnectSetting setting, uint32_t *valuePtr);
dan_ackme 24:e27e23297f02 478 WiconnectResult getSetting(WiconnectSetting setting, char **valuePtr);
dan_ackme 24:e27e23297f02 479 WiconnectResult getSetting(WiconnectSetting setting, char *valueBuffer, uint16_t valueBufferLen);
dan_ackme 11:ea484e1b7fc4 480
dan_ackme 11:ea484e1b7fc4 481 // ------------------------------------------------------------------------
dan_ackme 11:ea484e1b7fc4 482
dan_ackme 11:ea484e1b7fc4 483
dan_ackme 11:ea484e1b7fc4 484 /**
dan_ackme 11:ea484e1b7fc4 485 * @ingroup api_core_misc
dan_ackme 11:ea484e1b7fc4 486 *
dan_ackme 11:ea484e1b7fc4 487 * @brief When the WiConnect WiFi module returns a response, it contains a
dan_ackme 11:ea484e1b7fc4 488 * response code in the header. This function converts the previous response code
dan_ackme 11:ea484e1b7fc4 489 * to a readable string.
dan_ackme 13:2b51f5267c92 490 *
dan_ackme 13:2b51f5267c92 491 * @return string representation of module response code
dan_ackme 11:ea484e1b7fc4 492 */
dan_ackme 11:ea484e1b7fc4 493 const char* getLastCommandResponseCodeStr();
dan_ackme 11:ea484e1b7fc4 494
dan_ackme 11:ea484e1b7fc4 495 /**
dan_ackme 11:ea484e1b7fc4 496 * @ingroup api_core_misc
dan_ackme 11:ea484e1b7fc4 497 *
dan_ackme 11:ea484e1b7fc4 498 * @brief Return the length in bytes of the previous response.
dan_ackme 13:2b51f5267c92 499 *
dan_ackme 13:2b51f5267c92 500 * @return length of previous response
dan_ackme 11:ea484e1b7fc4 501 */
dan_ackme 11:ea484e1b7fc4 502 uint16_t getLastCommandResponseLength();
dan_ackme 11:ea484e1b7fc4 503
dan_ackme 11:ea484e1b7fc4 504 /**
dan_ackme 11:ea484e1b7fc4 505 * @ingroup api_core_misc
dan_ackme 11:ea484e1b7fc4 506 *
dan_ackme 11:ea484e1b7fc4 507 * @brief Return pointer to internal response buffer.
dan_ackme 13:2b51f5267c92 508 *
dan_ackme 13:2b51f5267c92 509 * @return pointer to internal response buffer
dan_ackme 11:ea484e1b7fc4 510 */
dan_ackme 11:ea484e1b7fc4 511 char* getResponseBuffer();
dan_ackme 11:ea484e1b7fc4 512
dan_ackme 11:ea484e1b7fc4 513 /**
dan_ackme 11:ea484e1b7fc4 514 * @ingroup api_core_misc
dan_ackme 11:ea484e1b7fc4 515 *
dan_ackme 11:ea484e1b7fc4 516 * @brief Helper method to convert previous response to uint32
dan_ackme 13:2b51f5267c92 517 *
dan_ackme 13:2b51f5267c92 518 * @note This uses the internal response buffer.
dan_ackme 13:2b51f5267c92 519 *
dan_ackme 13:2b51f5267c92 520 * @param[out] uint32Ptr Pointer to hold result of conversion.
dan_ackme 13:2b51f5267c92 521 * @return Result of conversion. See @ref WiconnectResult
dan_ackme 11:ea484e1b7fc4 522 */
dan_ackme 11:ea484e1b7fc4 523 WiconnectResult responseToUint32(uint32_t *uint32Ptr);
dan_ackme 11:ea484e1b7fc4 524
dan_ackme 11:ea484e1b7fc4 525 /**
dan_ackme 11:ea484e1b7fc4 526 * @ingroup api_core_misc
dan_ackme 11:ea484e1b7fc4 527 *
dan_ackme 11:ea484e1b7fc4 528 * @brief Helper method to convert previous response to int32
dan_ackme 13:2b51f5267c92 529 *
dan_ackme 13:2b51f5267c92 530 * @note This uses the internal response buffer.
dan_ackme 13:2b51f5267c92 531 *
dan_ackme 13:2b51f5267c92 532 * @param[out] int32Ptr Pointer to hold result of conversion.
dan_ackme 13:2b51f5267c92 533 * @return Result of conversion. See @ref WiconnectResult
dan_ackme 11:ea484e1b7fc4 534 */
dan_ackme 11:ea484e1b7fc4 535 WiconnectResult responseToInt32(int32_t *int32Ptr);
dan_ackme 11:ea484e1b7fc4 536
dan_ackme 11:ea484e1b7fc4 537
dan_ackme 11:ea484e1b7fc4 538 // ------------------------------------------------------------------------
dan_ackme 11:ea484e1b7fc4 539
dan_ackme 11:ea484e1b7fc4 540
dan_ackme 9:b6218dc218ad 541 /**
dan_ackme 9:b6218dc218ad 542 * @ingroup api_core_settings
dan_ackme 9:b6218dc218ad 543 *
dan_ackme 11:ea484e1b7fc4 544 * @brief Sets the default maximum time an API method may execute before
dan_ackme 9:b6218dc218ad 545 * terminating and return a timeout error code.
dan_ackme 9:b6218dc218ad 546 *
dan_ackme 13:2b51f5267c92 547 * @note All API methods (execpt some sendCommand()) use this default value.
dan_ackme 13:2b51f5267c92 548 *
dan_ackme 13:2b51f5267c92 549 * @param[in] timeoutMs Default command timeout in milliseconds
dan_ackme 9:b6218dc218ad 550 */
dan_ackme 0:ea85c4bb5e1f 551 void setCommandDefaultTimeout(int timeoutMs);
dan_ackme 9:b6218dc218ad 552
dan_ackme 9:b6218dc218ad 553 /**
dan_ackme 9:b6218dc218ad 554 * @ingroup api_core_settings
dan_ackme 9:b6218dc218ad 555 *
dan_ackme 11:ea484e1b7fc4 556 * @brief Returns the current default maximum API execution time.
dan_ackme 13:2b51f5267c92 557 *
dan_ackme 13:2b51f5267c92 558 * @return Default command timeout in milliseconds
dan_ackme 9:b6218dc218ad 559 */
dan_ackme 0:ea85c4bb5e1f 560 int getCommandDefaultTimeout();
dan_ackme 0:ea85c4bb5e1f 561
dan_ackme 9:b6218dc218ad 562 /**
dan_ackme 9:b6218dc218ad 563 * @ingroup api_core_settings
dan_ackme 9:b6218dc218ad 564 *
dan_ackme 11:ea484e1b7fc4 565 * @brief Sets a mapping function used to convert from a host Pin to WiConnect WiFi module GPIO.
dan_ackme 13:2b51f5267c92 566 *
dan_ackme 13:2b51f5267c92 567 * @param[in] mapper Pin to GPIO mapper function pointer
dan_ackme 9:b6218dc218ad 568 */
dan_ackme 0:ea85c4bb5e1f 569 void setPinToGpioMapper(PinToGpioMapper mapper);
dan_ackme 0:ea85c4bb5e1f 570
dan_ackme 9:b6218dc218ad 571 /**
dan_ackme 9:b6218dc218ad 572 * @ingroup api_core_settings
dan_ackme 9:b6218dc218ad 573 *
dan_ackme 11:ea484e1b7fc4 574 * @brief Sets callback function used to debug WiConnect WiFi module RX/TX serial data.
dan_ackme 13:2b51f5267c92 575 *
dan_ackme 13:2b51f5267c92 576 * @param[in] logFunc Logging function pointer
dan_ackme 9:b6218dc218ad 577 */
dan_ackme 0:ea85c4bb5e1f 578 void setDebugLogger(LogFunc logFunc);
dan_ackme 9:b6218dc218ad 579
dan_ackme 9:b6218dc218ad 580 /**
dan_ackme 9:b6218dc218ad 581 * @ingroup api_core_settings
dan_ackme 9:b6218dc218ad 582 *
dan_ackme 11:ea484e1b7fc4 583 * @brief Sets callback used when Wiconnect Library hits and internal assertion.
dan_ackme 9:b6218dc218ad 584 *
dan_ackme 9:b6218dc218ad 585 * @note This is mainly for debugging. There's nothing the callback can do to fix the assertion.
dan_ackme 13:2b51f5267c92 586 *
dan_ackme 13:2b51f5267c92 587 * @param[in] assertLogFunc Logging function pointer
dan_ackme 9:b6218dc218ad 588 */
dan_ackme 6:8a87a59d0d21 589 void setAssertLogger(LogFunc assertLogFunc);
dan_ackme 0:ea85c4bb5e1f 590
dan_ackme 11:ea484e1b7fc4 591
dan_ackme 11:ea484e1b7fc4 592 // ------------------------------------------------------------------------
dan_ackme 11:ea484e1b7fc4 593
dan_ackme 11:ea484e1b7fc4 594
dan_ackme 0:ea85c4bb5e1f 595 #ifdef WICONNECT_ASYNC_TIMER_ENABLED
dan_ackme 9:b6218dc218ad 596 /**
dan_ackme 9:b6218dc218ad 597 * @ingroup api_core_send_command
dan_ackme 9:b6218dc218ad 598 *
dan_ackme 11:ea484e1b7fc4 599 * @brief Add user command to be executed asynchronously.
dan_ackme 9:b6218dc218ad 600 *
dan_ackme 13:2b51f5267c92 601 * Refer to @ref setting_async_processing for more info.
dan_ackme 13:2b51f5267c92 602 *
dan_ackme 13:2b51f5267c92 603 * @param[in] command Pointer to QueuedCommand to be executed asynchronously
dan_ackme 13:2b51f5267c92 604 * @param[in] commandCompleteHandler Callback to be executed when processing is complete.
dan_ackme 13:2b51f5267c92 605 * @return Result of method. See @ref WiconnectResult
dan_ackme 9:b6218dc218ad 606 */
dan_ackme 0:ea85c4bb5e1f 607 WiconnectResult enqueueCommand(QueuedCommand *command, const Callback &commandCompleteHandler = Callback());
dan_ackme 9:b6218dc218ad 608
dan_ackme 9:b6218dc218ad 609 /**
dan_ackme 9:b6218dc218ad 610 * @ingroup api_core_settings
dan_ackme 9:b6218dc218ad 611 *
dan_ackme 11:ea484e1b7fc4 612 * @brief Set the period at which an asynchronous command should be processed.
dan_ackme 13:2b51f5267c92 613 *
dan_ackme 13:2b51f5267c92 614 * Refer to @ref setting_async_processing for more info.
dan_ackme 13:2b51f5267c92 615 *
dan_ackme 13:2b51f5267c92 616 * @param[in] periodMs Processing period in milliseconds
dan_ackme 9:b6218dc218ad 617 */
dan_ackme 0:ea85c4bb5e1f 618 void setCommandProcessingPeriod(uint32_t periodMs);
dan_ackme 0:ea85c4bb5e1f 619 #endif
dan_ackme 0:ea85c4bb5e1f 620
dan_ackme 9:b6218dc218ad 621
dan_ackme 9:b6218dc218ad 622 /**
dan_ackme 9:b6218dc218ad 623 * @ingroup conversion_util
dan_ackme 9:b6218dc218ad 624 *
dan_ackme 11:ea484e1b7fc4 625 * @brief Converts a @ref WiconnectResult to string representation.
dan_ackme 13:2b51f5267c92 626 *
dan_ackme 13:2b51f5267c92 627 * @param[in] wiconnectResult Result code
dan_ackme 13:2b51f5267c92 628 * @return String representaion of result code
dan_ackme 9:b6218dc218ad 629 */
dan_ackme 9:b6218dc218ad 630 static const char* getWiconnectResultStr(WiconnectResult wiconnectResult);
dan_ackme 9:b6218dc218ad 631
dan_ackme 0:ea85c4bb5e1f 632 protected:
dan_ackme 0:ea85c4bb5e1f 633
dan_ackme 0:ea85c4bb5e1f 634 #ifdef WICONNECT_ENABLE_MALLOC
dan_ackme 0:ea85c4bb5e1f 635 void* (*_malloc)(size_t);
dan_ackme 0:ea85c4bb5e1f 636 void (*_free)(void *);
dan_ackme 0:ea85c4bb5e1f 637 friend class QueuedCommand;
dan_ackme 0:ea85c4bb5e1f 638 friend class WiconnectSerial;
dan_ackme 0:ea85c4bb5e1f 639 friend class ScanResult;
dan_ackme 6:8a87a59d0d21 640 friend class ScanResultList;
dan_ackme 17:7268f365676b 641 friend class WiconnectSocket;
dan_ackme 17:7268f365676b 642 friend class WiconnectFile;
dan_ackme 0:ea85c4bb5e1f 643 #endif
dan_ackme 0:ea85c4bb5e1f 644
dan_ackme 0:ea85c4bb5e1f 645 wiconnect::WiconnectSerial serial;
dan_ackme 0:ea85c4bb5e1f 646 wiconnect::Gpio resetGpio;
dan_ackme 0:ea85c4bb5e1f 647 wiconnect::Gpio wakeGpio;
dan_ackme 0:ea85c4bb5e1f 648
dan_ackme 0:ea85c4bb5e1f 649 volatile bool commandExecuting;
dan_ackme 0:ea85c4bb5e1f 650 bool initialized;
dan_ackme 0:ea85c4bb5e1f 651 bool nonBlocking;
dan_ackme 0:ea85c4bb5e1f 652
dan_ackme 0:ea85c4bb5e1f 653 PinToGpioMapper pinToGpioMapper;
dan_ackme 0:ea85c4bb5e1f 654
dan_ackme 0:ea85c4bb5e1f 655 char *internalBuffer;
dan_ackme 0:ea85c4bb5e1f 656 int internalBufferSize;
dan_ackme 0:ea85c4bb5e1f 657 bool internalBufferAlloc;
dan_ackme 0:ea85c4bb5e1f 658 uint8_t internalProcessingState;
dan_ackme 0:ea85c4bb5e1f 659 void *currentCommandId;
dan_ackme 0:ea85c4bb5e1f 660
dan_ackme 0:ea85c4bb5e1f 661 wiconnect::TimeoutTimer timeoutTimer;
dan_ackme 0:ea85c4bb5e1f 662 int defaultTimeoutMs;
dan_ackme 0:ea85c4bb5e1f 663
dan_ackme 0:ea85c4bb5e1f 664 uint8_t commandHeaderBuffer[32];
dan_ackme 0:ea85c4bb5e1f 665 char commandFormatBuffer[WICONNECT_MAX_CMD_SIZE];
dan_ackme 0:ea85c4bb5e1f 666 uint8_t commandContext[96];
dan_ackme 0:ea85c4bb5e1f 667
dan_ackme 0:ea85c4bb5e1f 668 void prepare(void *internalBuffer, int internalBufferSize, bool nonBlocking);
dan_ackme 0:ea85c4bb5e1f 669 WiconnectResult inline receiveResponse();
dan_ackme 0:ea85c4bb5e1f 670 WiconnectResult inline receivePacket();
dan_ackme 0:ea85c4bb5e1f 671 void issueCommandCallback(WiconnectResult result);
dan_ackme 0:ea85c4bb5e1f 672
dan_ackme 6:8a87a59d0d21 673 LogFunc debugLogger;
dan_ackme 6:8a87a59d0d21 674 LogFunc assertLogger;
dan_ackme 0:ea85c4bb5e1f 675 void debugLog(const char *msg, ...);
dan_ackme 0:ea85c4bb5e1f 676
dan_ackme 0:ea85c4bb5e1f 677 #ifdef WICONNECT_ASYNC_TIMER_ENABLED
dan_ackme 0:ea85c4bb5e1f 678 wiconnect::PeriodicTimer commandProcessorTimer;
dan_ackme 0:ea85c4bb5e1f 679 uint32_t commandProcessingPeriod;
dan_ackme 0:ea85c4bb5e1f 680 CommandQueue commandQueue;
dan_ackme 0:ea85c4bb5e1f 681 wiconnect::QueuedCommand *currentQueuedCommand;
dan_ackme 0:ea85c4bb5e1f 682
dan_ackme 0:ea85c4bb5e1f 683 void commandProcessingTimerHandler(void);
dan_ackme 0:ea85c4bb5e1f 684 void processNextQueuedCommand();
dan_ackme 0:ea85c4bb5e1f 685 void checkQueuedCommandTimeout();
dan_ackme 0:ea85c4bb5e1f 686 #endif
dan_ackme 0:ea85c4bb5e1f 687
dan_ackme 0:ea85c4bb5e1f 688 friend class NetworkInterface;
dan_ackme 0:ea85c4bb5e1f 689 friend class SocketInterface;
dan_ackme 0:ea85c4bb5e1f 690 friend class FileInterface;
dan_ackme 0:ea85c4bb5e1f 691 };
dan_ackme 0:ea85c4bb5e1f 692
dan_ackme 0:ea85c4bb5e1f 693 }
dan_ackme 21:17bb3eddcbae 694
dan_ackme 21:17bb3eddcbae 695
dan_ackme 21:17bb3eddcbae 696 #include "sdkTypes.h"
dan_ackme 21:17bb3eddcbae 697