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:
Wed Aug 13 03:14:30 2014 -0700
Revision:
13:2b51f5267c92
Parent:
11:ea484e1b7fc4
Child:
16:7f1d6d359787
doc updates

Who changed what in which revision?

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