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
WiconnectInterface.h@26:8067e3d463d3, 2014-10-23 (annotated)
- Committer:
- dan_ackme
- Date:
- Thu Oct 23 15:16:06 2014 -0700
- Revision:
- 26:8067e3d463d3
- Parent:
- 21:17bb3eddcbae
- Child:
- 27:b63f5a9cdefa
Added 'updateFirmware' and 'networkGetJoinResult' api methods
Various bug fixes
Updated documentation
Who changed what in which revision?
User | Revision | Line number | New 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 | 26:8067e3d463d3 | 139 | WiconnectResult init(bool bringNetworkUp=false); |
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 | 26:8067e3d463d3 | 211 | /** |
dan_ackme | 26:8067e3d463d3 | 212 | * @ingroup api_core_misc |
dan_ackme | 26:8067e3d463d3 | 213 | * |
dan_ackme | 26:8067e3d463d3 | 214 | * @brief Update the wifi module's internal firmware. |
dan_ackme | 26:8067e3d463d3 | 215 | * @param[in] forced Optional, If true, force update of all firmware files to latest version, else only update out-dated files. |
dan_ackme | 26:8067e3d463d3 | 216 | * @param[in] versionStr Optional, If specified, update to specific firmware version, else update to latest version. |
dan_ackme | 26:8067e3d463d3 | 217 | * @param[in] completeCallback Optional, callback when update is complete. 'result' callback argument contains result of update. |
dan_ackme | 26:8067e3d463d3 | 218 | * |
dan_ackme | 26:8067e3d463d3 | 219 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 26:8067e3d463d3 | 220 | */ |
dan_ackme | 26:8067e3d463d3 | 221 | WiconnectResult updateFirmware(bool forced = false, const char *versionStr = NULL, const Callback &completeCallback = Callback()); |
dan_ackme | 26:8067e3d463d3 | 222 | |
dan_ackme | 26:8067e3d463d3 | 223 | |
dan_ackme | 11:ea484e1b7fc4 | 224 | // ------------------------------------------------------------------------ |
dan_ackme | 11:ea484e1b7fc4 | 225 | |
dan_ackme | 11:ea484e1b7fc4 | 226 | |
dan_ackme | 9:b6218dc218ad | 227 | /** |
dan_ackme | 9:b6218dc218ad | 228 | * @ingroup api_core_send_command |
dan_ackme | 9:b6218dc218ad | 229 | * |
dan_ackme | 9:b6218dc218ad | 230 | * @brief Send command to WiConnect WiFi module |
dan_ackme | 13:2b51f5267c92 | 231 | * |
dan_ackme | 13:2b51f5267c92 | 232 | * @note Refer to @ref send_command_desc for more info |
dan_ackme | 13:2b51f5267c92 | 233 | * |
dan_ackme | 13:2b51f5267c92 | 234 | * @param[in] completeCallback Callback when command completes. arg1 of callback contains responseBuffer pointer, arg2 contains the response length |
dan_ackme | 13:2b51f5267c92 | 235 | * @param[in] responseBuffer Buffer to hold command response |
dan_ackme | 13:2b51f5267c92 | 236 | * @param[in] responseBufferLen Length of responseBuffer |
dan_ackme | 13:2b51f5267c92 | 237 | * @param[in] timeoutMs Maximum time in milliseconds this command should execute |
dan_ackme | 13:2b51f5267c92 | 238 | * @param[in] reader Callback for reading data to be read from host and send to module during command |
dan_ackme | 13:2b51f5267c92 | 239 | * @param[in] user User data struct used during read Callback. Library doesn't use this. Set NULL if not used. |
dan_ackme | 13:2b51f5267c92 | 240 | * @param[in] cmd WiConnect command to send to module |
dan_ackme | 13:2b51f5267c92 | 241 | * @param[in] vaList Varaible list of arguments |
dan_ackme | 13:2b51f5267c92 | 242 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 9:b6218dc218ad | 243 | */ |
dan_ackme | 0:ea85c4bb5e1f | 244 | WiconnectResult sendCommand(const Callback &completeCallback, char *responseBuffer, int responseBufferLen, |
dan_ackme | 0:ea85c4bb5e1f | 245 | int timeoutMs, const ReaderFunc &reader, void *user, const char *cmd, va_list vaList); |
dan_ackme | 9:b6218dc218ad | 246 | /** |
dan_ackme | 9:b6218dc218ad | 247 | * @ingroup api_core_send_command |
dan_ackme | 9:b6218dc218ad | 248 | * |
dan_ackme | 9:b6218dc218ad | 249 | * @brief Send command to WiConnect WiFi module |
dan_ackme | 13:2b51f5267c92 | 250 | * |
dan_ackme | 13:2b51f5267c92 | 251 | * @note Refer to @ref send_command_desc for more info |
dan_ackme | 13:2b51f5267c92 | 252 | * |
dan_ackme | 13:2b51f5267c92 | 253 | * @param[in] responseBuffer Buffer to hold command response |
dan_ackme | 13:2b51f5267c92 | 254 | * @param[in] responseBufferLen Length of responseBuffer |
dan_ackme | 13:2b51f5267c92 | 255 | * @param[in] timeoutMs Maximum time in milliseconds this command should execute |
dan_ackme | 13:2b51f5267c92 | 256 | * @param[in] reader Callback for reading data to be read from host and send to module during command |
dan_ackme | 13:2b51f5267c92 | 257 | * @param[in] user User data struct used during read Callback. Library doesn't use this. Set NULL if not used. |
dan_ackme | 13:2b51f5267c92 | 258 | * @param[in] cmd WiConnect command to send to module |
dan_ackme | 13:2b51f5267c92 | 259 | * @param[in] vaList Varaible list of arguments |
dan_ackme | 13:2b51f5267c92 | 260 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 9:b6218dc218ad | 261 | */ |
dan_ackme | 0:ea85c4bb5e1f | 262 | WiconnectResult sendCommand(char *responseBuffer, int responseBufferLen, int timeoutMs, const ReaderFunc &reader, |
dan_ackme | 0:ea85c4bb5e1f | 263 | void *user, const char *cmd, va_list vaList); |
dan_ackme | 9:b6218dc218ad | 264 | |
dan_ackme | 9:b6218dc218ad | 265 | /** |
dan_ackme | 9:b6218dc218ad | 266 | * @ingroup api_core_send_command |
dan_ackme | 9:b6218dc218ad | 267 | * |
dan_ackme | 9:b6218dc218ad | 268 | * @brief Send command to WiConnect WiFi module |
dan_ackme | 9:b6218dc218ad | 269 | * |
dan_ackme | 13:2b51f5267c92 | 270 | * @note Refer to @ref send_command_desc for more info |
dan_ackme | 9:b6218dc218ad | 271 | * @note This method supports variable arguments |
dan_ackme | 9:b6218dc218ad | 272 | * |
dan_ackme | 13:2b51f5267c92 | 273 | * @param[in] responseBuffer Buffer to hold command response |
dan_ackme | 13:2b51f5267c92 | 274 | * @param[in] responseBufferLen Length of responseBuffer |
dan_ackme | 13:2b51f5267c92 | 275 | * @param[in] timeoutMs Maximum time in milliseconds this command should execute |
dan_ackme | 13:2b51f5267c92 | 276 | * @param[in] reader Callback for reading data to be read from host and send to module during command |
dan_ackme | 13:2b51f5267c92 | 277 | * @param[in] user User data struct used during read Callback. Library doesn't use this. Set NULL if not used. |
dan_ackme | 13:2b51f5267c92 | 278 | * @param[in] cmd WiConnect command to send to module |
dan_ackme | 13:2b51f5267c92 | 279 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 9:b6218dc218ad | 280 | */ |
dan_ackme | 0:ea85c4bb5e1f | 281 | WiconnectResult sendCommand(char *responseBuffer, int responseBufferLen, int timeoutMs, const ReaderFunc &reader, |
dan_ackme | 0:ea85c4bb5e1f | 282 | void *user, const char *cmd, ...); |
dan_ackme | 9:b6218dc218ad | 283 | |
dan_ackme | 9:b6218dc218ad | 284 | /** |
dan_ackme | 9:b6218dc218ad | 285 | * @ingroup api_core_send_command |
dan_ackme | 9:b6218dc218ad | 286 | * |
dan_ackme | 9:b6218dc218ad | 287 | * @brief Send command to WiConnect WiFi module |
dan_ackme | 9:b6218dc218ad | 288 | * |
dan_ackme | 13:2b51f5267c92 | 289 | * This method uses the library internal buffer. |
dan_ackme | 13:2b51f5267c92 | 290 | * |
dan_ackme | 13:2b51f5267c92 | 291 | * @note Refer to @ref send_command_desc for more info |
dan_ackme | 9:b6218dc218ad | 292 | * @note This method supports variable arguments |
dan_ackme | 9:b6218dc218ad | 293 | * |
dan_ackme | 13:2b51f5267c92 | 294 | * @param[in] timeoutMs Maximum time in milliseconds this command should execute |
dan_ackme | 13:2b51f5267c92 | 295 | * @param[in] reader Callback for reading data to be read from host and send to module during command |
dan_ackme | 13:2b51f5267c92 | 296 | * @param[in] user User data struct used during read Callback. Library doesn't use this. Set NULL if not used. |
dan_ackme | 13:2b51f5267c92 | 297 | * @param[in] cmd WiConnect command to send to module |
dan_ackme | 13:2b51f5267c92 | 298 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 9:b6218dc218ad | 299 | */ |
dan_ackme | 0:ea85c4bb5e1f | 300 | WiconnectResult sendCommand( int timeoutMs, const ReaderFunc &reader, void *user, const char *cmd, ...); |
dan_ackme | 9:b6218dc218ad | 301 | |
dan_ackme | 9:b6218dc218ad | 302 | /** |
dan_ackme | 9:b6218dc218ad | 303 | * @ingroup api_core_send_command |
dan_ackme | 9:b6218dc218ad | 304 | * |
dan_ackme | 9:b6218dc218ad | 305 | * @brief Send command to WiConnect WiFi module |
dan_ackme | 9:b6218dc218ad | 306 | * |
dan_ackme | 13:2b51f5267c92 | 307 | * - This method uses the library internal buffer and |
dan_ackme | 13:2b51f5267c92 | 308 | * - default timeout. See setCommandDefaultTimeout() |
dan_ackme | 13:2b51f5267c92 | 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] reader Callback for reading data to be read from host and send to module during command |
dan_ackme | 13:2b51f5267c92 | 314 | * @param[in] user User data struct used during read Callback. Library doesn't use this. Set NULL if not used. |
dan_ackme | 13:2b51f5267c92 | 315 | * @param[in] cmd WiConnect command to send to module |
dan_ackme | 13:2b51f5267c92 | 316 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 9:b6218dc218ad | 317 | */ |
dan_ackme | 0:ea85c4bb5e1f | 318 | WiconnectResult sendCommand(const ReaderFunc &reader, void *user, const char *cmd, ...); |
dan_ackme | 9:b6218dc218ad | 319 | |
dan_ackme | 9:b6218dc218ad | 320 | /** |
dan_ackme | 9:b6218dc218ad | 321 | * @ingroup api_core_send_command |
dan_ackme | 9:b6218dc218ad | 322 | * |
dan_ackme | 9:b6218dc218ad | 323 | * @brief Send command to WiConnect WiFi module |
dan_ackme | 9:b6218dc218ad | 324 | * |
dan_ackme | 13:2b51f5267c92 | 325 | * @note Refer to @ref send_command_desc for more info |
dan_ackme | 9:b6218dc218ad | 326 | * @note This method supports variable arguments |
dan_ackme | 9:b6218dc218ad | 327 | * |
dan_ackme | 13:2b51f5267c92 | 328 | * @param[in] responseBuffer Buffer to hold command response |
dan_ackme | 13:2b51f5267c92 | 329 | * @param[in] responseBufferLen Length of responseBuffer |
dan_ackme | 13:2b51f5267c92 | 330 | * @param[in] timeoutMs Maximum time in milliseconds this command should execute |
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, int timeoutMs, 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 | * @note Refer to @ref send_command_desc for more info |
dan_ackme | 9:b6218dc218ad | 342 | * @note This method supports variable arguments |
dan_ackme | 9:b6218dc218ad | 343 | * |
dan_ackme | 13:2b51f5267c92 | 344 | * @param[in] completeCallback Callback when command completes. arg1 of callback contains responseBuffer pointer, arg2 contains the response length |
dan_ackme | 13:2b51f5267c92 | 345 | * @param[in] responseBuffer Buffer to hold command response |
dan_ackme | 13:2b51f5267c92 | 346 | * @param[in] responseBufferLen Length of responseBuffer |
dan_ackme | 13:2b51f5267c92 | 347 | * @param[in] cmd WiConnect command to send to module |
dan_ackme | 13:2b51f5267c92 | 348 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 9:b6218dc218ad | 349 | */ |
dan_ackme | 0:ea85c4bb5e1f | 350 | WiconnectResult sendCommand(const Callback &completeCallback, char *responseBuffer, int responseBufferLen, const char *cmd, ...); |
dan_ackme | 9:b6218dc218ad | 351 | |
dan_ackme | 9:b6218dc218ad | 352 | /** |
dan_ackme | 9:b6218dc218ad | 353 | * @ingroup api_core_send_command |
dan_ackme | 9:b6218dc218ad | 354 | * |
dan_ackme | 9:b6218dc218ad | 355 | * @brief Send command to WiConnect WiFi module |
dan_ackme | 9:b6218dc218ad | 356 | * |
dan_ackme | 13:2b51f5267c92 | 357 | * @note Refer to @ref send_command_desc for more info |
dan_ackme | 9:b6218dc218ad | 358 | * @note This method supports variable arguments |
dan_ackme | 9:b6218dc218ad | 359 | * |
dan_ackme | 13:2b51f5267c92 | 360 | * @param[in] responseBuffer Buffer to hold command response |
dan_ackme | 13:2b51f5267c92 | 361 | * @param[in] responseBufferLen Length of responseBuffer |
dan_ackme | 13:2b51f5267c92 | 362 | * @param[in] cmd WiConnect command to send to module |
dan_ackme | 13:2b51f5267c92 | 363 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 9:b6218dc218ad | 364 | */ |
dan_ackme | 0:ea85c4bb5e1f | 365 | WiconnectResult sendCommand(char *responseBuffer, int responseBufferLen, const char *cmd, ...); |
dan_ackme | 9:b6218dc218ad | 366 | |
dan_ackme | 9:b6218dc218ad | 367 | /** |
dan_ackme | 9:b6218dc218ad | 368 | * @ingroup api_core_send_command |
dan_ackme | 9:b6218dc218ad | 369 | * |
dan_ackme | 9:b6218dc218ad | 370 | * @brief Send command to WiConnect WiFi module |
dan_ackme | 9:b6218dc218ad | 371 | * |
dan_ackme | 13:2b51f5267c92 | 372 | * - This method uses the library internal buffer and |
dan_ackme | 13:2b51f5267c92 | 373 | * - default timeout. See setCommandDefaultTimeout() |
dan_ackme | 13:2b51f5267c92 | 374 | * |
dan_ackme | 13:2b51f5267c92 | 375 | * @note Refer to @ref send_command_desc for more info |
dan_ackme | 9:b6218dc218ad | 376 | * @note This method supports variable arguments |
dan_ackme | 9:b6218dc218ad | 377 | * |
dan_ackme | 13:2b51f5267c92 | 378 | * @param[in] completeCallback Callback when command completes. arg1 of callback contains responseBuffer pointer, arg2 contains the response length |
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, 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 and |
dan_ackme | 13:2b51f5267c92 | 390 | * - default timeout. See setCommandDefaultTimeout() |
dan_ackme | 13:2b51f5267c92 | 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] 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(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 |
dan_ackme | 9:b6218dc218ad | 404 | * |
dan_ackme | 13:2b51f5267c92 | 405 | * @note Refer to @ref send_command_desc for more info |
dan_ackme | 9:b6218dc218ad | 406 | * @note This method supports variable arguments |
dan_ackme | 9:b6218dc218ad | 407 | * |
dan_ackme | 13:2b51f5267c92 | 408 | * @param[in] completeCallback Callback when command completes. arg1 of callback contains responseBuffer pointer, arg2 contains the response length |
dan_ackme | 13:2b51f5267c92 | 409 | * @param[in] timeoutMs Maximum time in milliseconds this command should execute |
dan_ackme | 13:2b51f5267c92 | 410 | * @param[in] cmd WiConnect command to send to module |
dan_ackme | 13:2b51f5267c92 | 411 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 9:b6218dc218ad | 412 | */ |
dan_ackme | 0:ea85c4bb5e1f | 413 | WiconnectResult sendCommand(const Callback &completeCallback, int timeoutMs, const char *cmd, ...); |
dan_ackme | 9:b6218dc218ad | 414 | |
dan_ackme | 9:b6218dc218ad | 415 | /** |
dan_ackme | 9:b6218dc218ad | 416 | * @ingroup api_core_send_command |
dan_ackme | 9:b6218dc218ad | 417 | * |
dan_ackme | 9:b6218dc218ad | 418 | * @brief Send command to WiConnect WiFi module |
dan_ackme | 9:b6218dc218ad | 419 | * |
dan_ackme | 13:2b51f5267c92 | 420 | * This method uses the library internal buffer |
dan_ackme | 13:2b51f5267c92 | 421 | * |
dan_ackme | 13:2b51f5267c92 | 422 | * @note Refer to @ref send_command_desc for more info |
dan_ackme | 9:b6218dc218ad | 423 | * @note This method supports variable arguments |
dan_ackme | 9:b6218dc218ad | 424 | * |
dan_ackme | 13:2b51f5267c92 | 425 | * @param[in] timeoutMs Maximum time in milliseconds this command should execute |
dan_ackme | 13:2b51f5267c92 | 426 | * @param[in] cmd WiConnect command to send to module |
dan_ackme | 13:2b51f5267c92 | 427 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 9:b6218dc218ad | 428 | */ |
dan_ackme | 0:ea85c4bb5e1f | 429 | WiconnectResult sendCommand(int timeoutMs, const char *cmd, ...); |
dan_ackme | 9:b6218dc218ad | 430 | |
dan_ackme | 9:b6218dc218ad | 431 | /** |
dan_ackme | 9:b6218dc218ad | 432 | * @ingroup api_core_send_command |
dan_ackme | 9:b6218dc218ad | 433 | * |
dan_ackme | 13:2b51f5267c92 | 434 | * - This method uses the library internal buffer and |
dan_ackme | 13:2b51f5267c92 | 435 | * - default timeout. See setCommandDefaultTimeout() |
dan_ackme | 9:b6218dc218ad | 436 | * |
dan_ackme | 13:2b51f5267c92 | 437 | * @note Refer to @ref send_command_desc for more info |
dan_ackme | 13:2b51f5267c92 | 438 | * |
dan_ackme | 13:2b51f5267c92 | 439 | * @param[in] cmd WiConnect command to send to module |
dan_ackme | 13:2b51f5267c92 | 440 | * @param[in] vaList Varaible list of arguments |
dan_ackme | 13:2b51f5267c92 | 441 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 9:b6218dc218ad | 442 | */ |
dan_ackme | 0:ea85c4bb5e1f | 443 | WiconnectResult sendCommand(const char *cmd, va_list vaList); |
dan_ackme | 0:ea85c4bb5e1f | 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 Check the status of the currently executing command. |
dan_ackme | 9:b6218dc218ad | 449 | * |
dan_ackme | 9:b6218dc218ad | 450 | * Refer to @ref WiconnectResult for more information about the return code. |
dan_ackme | 9:b6218dc218ad | 451 | * |
dan_ackme | 9:b6218dc218ad | 452 | * @note This command is only applicable for non-blocking mode. Refer to @ref setting_blocking_modes. |
dan_ackme | 13:2b51f5267c92 | 453 | * |
dan_ackme | 13:2b51f5267c92 | 454 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 9:b6218dc218ad | 455 | */ |
dan_ackme | 0:ea85c4bb5e1f | 456 | WiconnectResult checkCurrentCommand(); |
dan_ackme | 9:b6218dc218ad | 457 | |
dan_ackme | 9:b6218dc218ad | 458 | /** |
dan_ackme | 9:b6218dc218ad | 459 | * @ingroup api_core_send_command |
dan_ackme | 9:b6218dc218ad | 460 | * |
dan_ackme | 11:ea484e1b7fc4 | 461 | * @brief Stop the currently executing command. |
dan_ackme | 9:b6218dc218ad | 462 | * |
dan_ackme | 9:b6218dc218ad | 463 | * @note This command is only applicable for non-blocking mode. Refer to @ref setting_blocking_modes. |
dan_ackme | 9:b6218dc218ad | 464 | */ |
dan_ackme | 0:ea85c4bb5e1f | 465 | void stopCurrentCommand(); |
dan_ackme | 9:b6218dc218ad | 466 | |
dan_ackme | 11:ea484e1b7fc4 | 467 | |
dan_ackme | 11:ea484e1b7fc4 | 468 | // ------------------------------------------------------------------------ |
dan_ackme | 11:ea484e1b7fc4 | 469 | |
dan_ackme | 11:ea484e1b7fc4 | 470 | |
dan_ackme | 11:ea484e1b7fc4 | 471 | /** |
dan_ackme | 11:ea484e1b7fc4 | 472 | * @ingroup api_core_misc |
dan_ackme | 11:ea484e1b7fc4 | 473 | * |
dan_ackme | 11:ea484e1b7fc4 | 474 | * @brief When the WiConnect WiFi module returns a response, it contains a |
dan_ackme | 11:ea484e1b7fc4 | 475 | * response code in the header. This function converts the previous response code |
dan_ackme | 11:ea484e1b7fc4 | 476 | * to a readable string. |
dan_ackme | 13:2b51f5267c92 | 477 | * |
dan_ackme | 13:2b51f5267c92 | 478 | * @return string representation of module response code |
dan_ackme | 11:ea484e1b7fc4 | 479 | */ |
dan_ackme | 11:ea484e1b7fc4 | 480 | const char* getLastCommandResponseCodeStr(); |
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 Return the length in bytes of the previous response. |
dan_ackme | 13:2b51f5267c92 | 486 | * |
dan_ackme | 13:2b51f5267c92 | 487 | * @return length of previous response |
dan_ackme | 11:ea484e1b7fc4 | 488 | */ |
dan_ackme | 11:ea484e1b7fc4 | 489 | uint16_t getLastCommandResponseLength(); |
dan_ackme | 11:ea484e1b7fc4 | 490 | |
dan_ackme | 11:ea484e1b7fc4 | 491 | /** |
dan_ackme | 11:ea484e1b7fc4 | 492 | * @ingroup api_core_misc |
dan_ackme | 11:ea484e1b7fc4 | 493 | * |
dan_ackme | 11:ea484e1b7fc4 | 494 | * @brief Return pointer to internal response buffer. |
dan_ackme | 13:2b51f5267c92 | 495 | * |
dan_ackme | 13:2b51f5267c92 | 496 | * @return pointer to internal response buffer |
dan_ackme | 11:ea484e1b7fc4 | 497 | */ |
dan_ackme | 11:ea484e1b7fc4 | 498 | char* getResponseBuffer(); |
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 uint32 |
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] uint32Ptr 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 responseToUint32(uint32_t *uint32Ptr); |
dan_ackme | 11:ea484e1b7fc4 | 511 | |
dan_ackme | 11:ea484e1b7fc4 | 512 | /** |
dan_ackme | 11:ea484e1b7fc4 | 513 | * @ingroup api_core_misc |
dan_ackme | 11:ea484e1b7fc4 | 514 | * |
dan_ackme | 11:ea484e1b7fc4 | 515 | * @brief Helper method to convert previous response to int32 |
dan_ackme | 13:2b51f5267c92 | 516 | * |
dan_ackme | 13:2b51f5267c92 | 517 | * @note This uses the internal response buffer. |
dan_ackme | 13:2b51f5267c92 | 518 | * |
dan_ackme | 13:2b51f5267c92 | 519 | * @param[out] int32Ptr Pointer to hold result of conversion. |
dan_ackme | 13:2b51f5267c92 | 520 | * @return Result of conversion. See @ref WiconnectResult |
dan_ackme | 11:ea484e1b7fc4 | 521 | */ |
dan_ackme | 11:ea484e1b7fc4 | 522 | WiconnectResult responseToInt32(int32_t *int32Ptr); |
dan_ackme | 11:ea484e1b7fc4 | 523 | |
dan_ackme | 11:ea484e1b7fc4 | 524 | |
dan_ackme | 11:ea484e1b7fc4 | 525 | // ------------------------------------------------------------------------ |
dan_ackme | 11:ea484e1b7fc4 | 526 | |
dan_ackme | 26:8067e3d463d3 | 527 | /** |
dan_ackme | 26:8067e3d463d3 | 528 | * @ingroup api_core_settings |
dan_ackme | 26:8067e3d463d3 | 529 | * |
dan_ackme | 26:8067e3d463d3 | 530 | * @brief Set a module setting |
dan_ackme | 26:8067e3d463d3 | 531 | * |
dan_ackme | 26:8067e3d463d3 | 532 | * Refer to: http://wiconnect.ack.me/2.0/variables |
dan_ackme | 26:8067e3d463d3 | 533 | * for a list of the available settings and descriptions |
dan_ackme | 26:8067e3d463d3 | 534 | * |
dan_ackme | 26:8067e3d463d3 | 535 | * @param settingStr String module setting name. |
dan_ackme | 26:8067e3d463d3 | 536 | * @param value The integer value to set |
dan_ackme | 26:8067e3d463d3 | 537 | * |
dan_ackme | 26:8067e3d463d3 | 538 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 26:8067e3d463d3 | 539 | */ |
dan_ackme | 26:8067e3d463d3 | 540 | WiconnectResult setSetting(const char *settingStr, uint32_t value); |
dan_ackme | 26:8067e3d463d3 | 541 | |
dan_ackme | 26:8067e3d463d3 | 542 | /** |
dan_ackme | 26:8067e3d463d3 | 543 | * @ingroup api_core_settings |
dan_ackme | 26:8067e3d463d3 | 544 | * |
dan_ackme | 26:8067e3d463d3 | 545 | * @brief Set a module setting |
dan_ackme | 26:8067e3d463d3 | 546 | * |
dan_ackme | 26:8067e3d463d3 | 547 | * Refer to: http://wiconnect.ack.me/2.0/variables |
dan_ackme | 26:8067e3d463d3 | 548 | * for a list of the available settings and descriptions |
dan_ackme | 26:8067e3d463d3 | 549 | * |
dan_ackme | 26:8067e3d463d3 | 550 | * @param settingStr String module setting name. |
dan_ackme | 26:8067e3d463d3 | 551 | * @param value The string value to set |
dan_ackme | 26:8067e3d463d3 | 552 | * |
dan_ackme | 26:8067e3d463d3 | 553 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 26:8067e3d463d3 | 554 | */ |
dan_ackme | 26:8067e3d463d3 | 555 | WiconnectResult setSetting(const char *settingStr, const char *value); |
dan_ackme | 26:8067e3d463d3 | 556 | |
dan_ackme | 26:8067e3d463d3 | 557 | /** |
dan_ackme | 26:8067e3d463d3 | 558 | * @ingroup api_core_settings |
dan_ackme | 26:8067e3d463d3 | 559 | * |
dan_ackme | 26:8067e3d463d3 | 560 | * @brief Get a module setting |
dan_ackme | 26:8067e3d463d3 | 561 | * |
dan_ackme | 26:8067e3d463d3 | 562 | * Refer to: http://wiconnect.ack.me/2.0/variables |
dan_ackme | 26:8067e3d463d3 | 563 | * for a list of the available settings and descriptions |
dan_ackme | 26:8067e3d463d3 | 564 | * |
dan_ackme | 26:8067e3d463d3 | 565 | * @param settingStr String module setting name. |
dan_ackme | 26:8067e3d463d3 | 566 | * @param valuePtr Pointer to buffer to contain integer value |
dan_ackme | 26:8067e3d463d3 | 567 | * |
dan_ackme | 26:8067e3d463d3 | 568 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 26:8067e3d463d3 | 569 | */ |
dan_ackme | 26:8067e3d463d3 | 570 | WiconnectResult getSetting(const char *settingStr, uint32_t *valuePtr); |
dan_ackme | 26:8067e3d463d3 | 571 | |
dan_ackme | 26:8067e3d463d3 | 572 | /** |
dan_ackme | 26:8067e3d463d3 | 573 | * @ingroup api_core_settings |
dan_ackme | 26:8067e3d463d3 | 574 | * |
dan_ackme | 26:8067e3d463d3 | 575 | * @brief Get a module setting |
dan_ackme | 26:8067e3d463d3 | 576 | * |
dan_ackme | 26:8067e3d463d3 | 577 | * Refer to: http://wiconnect.ack.me/2.0/variables |
dan_ackme | 26:8067e3d463d3 | 578 | * for a list of the available settings and descriptions |
dan_ackme | 26:8067e3d463d3 | 579 | * |
dan_ackme | 26:8067e3d463d3 | 580 | * @param settingStr String module setting name. |
dan_ackme | 26:8067e3d463d3 | 581 | * @param valuePtr Pointer to hold pointer to internal API buffer containing retrieved setting result |
dan_ackme | 26:8067e3d463d3 | 582 | * |
dan_ackme | 26:8067e3d463d3 | 583 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 26:8067e3d463d3 | 584 | */ |
dan_ackme | 26:8067e3d463d3 | 585 | WiconnectResult getSetting(const char *settingStr, char **valuePtr); |
dan_ackme | 26:8067e3d463d3 | 586 | |
dan_ackme | 26:8067e3d463d3 | 587 | /** |
dan_ackme | 26:8067e3d463d3 | 588 | * @ingroup api_core_settings |
dan_ackme | 26:8067e3d463d3 | 589 | * |
dan_ackme | 26:8067e3d463d3 | 590 | * @brief Get a module setting |
dan_ackme | 26:8067e3d463d3 | 591 | * |
dan_ackme | 26:8067e3d463d3 | 592 | * Refer to: http://wiconnect.ack.me/2.0/variables |
dan_ackme | 26:8067e3d463d3 | 593 | * for a list of the available settings and descriptions |
dan_ackme | 26:8067e3d463d3 | 594 | * |
dan_ackme | 26:8067e3d463d3 | 595 | * @param settingStr String module setting name. |
dan_ackme | 26:8067e3d463d3 | 596 | * @param valueBuffer Buffer to hold retrieved setting result |
dan_ackme | 26:8067e3d463d3 | 597 | * @param valueBufferLen The length of the input buffer |
dan_ackme | 26:8067e3d463d3 | 598 | * |
dan_ackme | 26:8067e3d463d3 | 599 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 26:8067e3d463d3 | 600 | */ |
dan_ackme | 26:8067e3d463d3 | 601 | WiconnectResult getSetting(const char *settingStr, char *valueBuffer, uint16_t valueBufferLen); |
dan_ackme | 26:8067e3d463d3 | 602 | |
dan_ackme | 11:ea484e1b7fc4 | 603 | |
dan_ackme | 9:b6218dc218ad | 604 | /** |
dan_ackme | 9:b6218dc218ad | 605 | * @ingroup api_core_settings |
dan_ackme | 9:b6218dc218ad | 606 | * |
dan_ackme | 11:ea484e1b7fc4 | 607 | * @brief Sets the default maximum time an API method may execute before |
dan_ackme | 9:b6218dc218ad | 608 | * terminating and return a timeout error code. |
dan_ackme | 9:b6218dc218ad | 609 | * |
dan_ackme | 13:2b51f5267c92 | 610 | * @note All API methods (execpt some sendCommand()) use this default value. |
dan_ackme | 13:2b51f5267c92 | 611 | * |
dan_ackme | 13:2b51f5267c92 | 612 | * @param[in] timeoutMs Default command timeout in milliseconds |
dan_ackme | 9:b6218dc218ad | 613 | */ |
dan_ackme | 0:ea85c4bb5e1f | 614 | void setCommandDefaultTimeout(int timeoutMs); |
dan_ackme | 9:b6218dc218ad | 615 | |
dan_ackme | 9:b6218dc218ad | 616 | /** |
dan_ackme | 9:b6218dc218ad | 617 | * @ingroup api_core_settings |
dan_ackme | 9:b6218dc218ad | 618 | * |
dan_ackme | 11:ea484e1b7fc4 | 619 | * @brief Returns the current default maximum API execution time. |
dan_ackme | 13:2b51f5267c92 | 620 | * |
dan_ackme | 13:2b51f5267c92 | 621 | * @return Default command timeout in milliseconds |
dan_ackme | 9:b6218dc218ad | 622 | */ |
dan_ackme | 0:ea85c4bb5e1f | 623 | int getCommandDefaultTimeout(); |
dan_ackme | 0:ea85c4bb5e1f | 624 | |
dan_ackme | 9:b6218dc218ad | 625 | /** |
dan_ackme | 9:b6218dc218ad | 626 | * @ingroup api_core_settings |
dan_ackme | 9:b6218dc218ad | 627 | * |
dan_ackme | 11:ea484e1b7fc4 | 628 | * @brief Sets a mapping function used to convert from a host Pin to WiConnect WiFi module GPIO. |
dan_ackme | 13:2b51f5267c92 | 629 | * |
dan_ackme | 13:2b51f5267c92 | 630 | * @param[in] mapper Pin to GPIO mapper function pointer |
dan_ackme | 9:b6218dc218ad | 631 | */ |
dan_ackme | 0:ea85c4bb5e1f | 632 | void setPinToGpioMapper(PinToGpioMapper mapper); |
dan_ackme | 0:ea85c4bb5e1f | 633 | |
dan_ackme | 9:b6218dc218ad | 634 | /** |
dan_ackme | 9:b6218dc218ad | 635 | * @ingroup api_core_settings |
dan_ackme | 9:b6218dc218ad | 636 | * |
dan_ackme | 11:ea484e1b7fc4 | 637 | * @brief Sets callback function used to debug WiConnect WiFi module RX/TX serial data. |
dan_ackme | 13:2b51f5267c92 | 638 | * |
dan_ackme | 13:2b51f5267c92 | 639 | * @param[in] logFunc Logging function pointer |
dan_ackme | 9:b6218dc218ad | 640 | */ |
dan_ackme | 0:ea85c4bb5e1f | 641 | void setDebugLogger(LogFunc logFunc); |
dan_ackme | 9:b6218dc218ad | 642 | |
dan_ackme | 9:b6218dc218ad | 643 | /** |
dan_ackme | 9:b6218dc218ad | 644 | * @ingroup api_core_settings |
dan_ackme | 9:b6218dc218ad | 645 | * |
dan_ackme | 11:ea484e1b7fc4 | 646 | * @brief Sets callback used when Wiconnect Library hits and internal assertion. |
dan_ackme | 9:b6218dc218ad | 647 | * |
dan_ackme | 9:b6218dc218ad | 648 | * @note This is mainly for debugging. There's nothing the callback can do to fix the assertion. |
dan_ackme | 13:2b51f5267c92 | 649 | * |
dan_ackme | 13:2b51f5267c92 | 650 | * @param[in] assertLogFunc Logging function pointer |
dan_ackme | 9:b6218dc218ad | 651 | */ |
dan_ackme | 6:8a87a59d0d21 | 652 | void setAssertLogger(LogFunc assertLogFunc); |
dan_ackme | 0:ea85c4bb5e1f | 653 | |
dan_ackme | 11:ea484e1b7fc4 | 654 | |
dan_ackme | 11:ea484e1b7fc4 | 655 | // ------------------------------------------------------------------------ |
dan_ackme | 11:ea484e1b7fc4 | 656 | |
dan_ackme | 11:ea484e1b7fc4 | 657 | |
dan_ackme | 0:ea85c4bb5e1f | 658 | #ifdef WICONNECT_ASYNC_TIMER_ENABLED |
dan_ackme | 9:b6218dc218ad | 659 | /** |
dan_ackme | 9:b6218dc218ad | 660 | * @ingroup api_core_send_command |
dan_ackme | 9:b6218dc218ad | 661 | * |
dan_ackme | 11:ea484e1b7fc4 | 662 | * @brief Add user command to be executed asynchronously. |
dan_ackme | 9:b6218dc218ad | 663 | * |
dan_ackme | 13:2b51f5267c92 | 664 | * Refer to @ref setting_async_processing for more info. |
dan_ackme | 13:2b51f5267c92 | 665 | * |
dan_ackme | 13:2b51f5267c92 | 666 | * @param[in] command Pointer to QueuedCommand to be executed asynchronously |
dan_ackme | 13:2b51f5267c92 | 667 | * @param[in] commandCompleteHandler Callback to be executed when processing is complete. |
dan_ackme | 13:2b51f5267c92 | 668 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 9:b6218dc218ad | 669 | */ |
dan_ackme | 0:ea85c4bb5e1f | 670 | WiconnectResult enqueueCommand(QueuedCommand *command, const Callback &commandCompleteHandler = Callback()); |
dan_ackme | 9:b6218dc218ad | 671 | |
dan_ackme | 9:b6218dc218ad | 672 | /** |
dan_ackme | 9:b6218dc218ad | 673 | * @ingroup api_core_settings |
dan_ackme | 9:b6218dc218ad | 674 | * |
dan_ackme | 11:ea484e1b7fc4 | 675 | * @brief Set the period at which an asynchronous command should be processed. |
dan_ackme | 13:2b51f5267c92 | 676 | * |
dan_ackme | 13:2b51f5267c92 | 677 | * Refer to @ref setting_async_processing for more info. |
dan_ackme | 13:2b51f5267c92 | 678 | * |
dan_ackme | 13:2b51f5267c92 | 679 | * @param[in] periodMs Processing period in milliseconds |
dan_ackme | 9:b6218dc218ad | 680 | */ |
dan_ackme | 0:ea85c4bb5e1f | 681 | void setCommandProcessingPeriod(uint32_t periodMs); |
dan_ackme | 0:ea85c4bb5e1f | 682 | #endif |
dan_ackme | 0:ea85c4bb5e1f | 683 | |
dan_ackme | 9:b6218dc218ad | 684 | |
dan_ackme | 9:b6218dc218ad | 685 | /** |
dan_ackme | 9:b6218dc218ad | 686 | * @ingroup conversion_util |
dan_ackme | 9:b6218dc218ad | 687 | * |
dan_ackme | 11:ea484e1b7fc4 | 688 | * @brief Converts a @ref WiconnectResult to string representation. |
dan_ackme | 13:2b51f5267c92 | 689 | * |
dan_ackme | 13:2b51f5267c92 | 690 | * @param[in] wiconnectResult Result code |
dan_ackme | 13:2b51f5267c92 | 691 | * @return String representaion of result code |
dan_ackme | 9:b6218dc218ad | 692 | */ |
dan_ackme | 9:b6218dc218ad | 693 | static const char* getWiconnectResultStr(WiconnectResult wiconnectResult); |
dan_ackme | 9:b6218dc218ad | 694 | |
dan_ackme | 0:ea85c4bb5e1f | 695 | protected: |
dan_ackme | 0:ea85c4bb5e1f | 696 | |
dan_ackme | 0:ea85c4bb5e1f | 697 | #ifdef WICONNECT_ENABLE_MALLOC |
dan_ackme | 0:ea85c4bb5e1f | 698 | void* (*_malloc)(size_t); |
dan_ackme | 0:ea85c4bb5e1f | 699 | void (*_free)(void *); |
dan_ackme | 0:ea85c4bb5e1f | 700 | friend class QueuedCommand; |
dan_ackme | 0:ea85c4bb5e1f | 701 | friend class WiconnectSerial; |
dan_ackme | 0:ea85c4bb5e1f | 702 | friend class ScanResult; |
dan_ackme | 6:8a87a59d0d21 | 703 | friend class ScanResultList; |
dan_ackme | 17:7268f365676b | 704 | friend class WiconnectSocket; |
dan_ackme | 17:7268f365676b | 705 | friend class WiconnectFile; |
dan_ackme | 0:ea85c4bb5e1f | 706 | #endif |
dan_ackme | 0:ea85c4bb5e1f | 707 | |
dan_ackme | 0:ea85c4bb5e1f | 708 | wiconnect::WiconnectSerial serial; |
dan_ackme | 0:ea85c4bb5e1f | 709 | wiconnect::Gpio resetGpio; |
dan_ackme | 0:ea85c4bb5e1f | 710 | wiconnect::Gpio wakeGpio; |
dan_ackme | 0:ea85c4bb5e1f | 711 | |
dan_ackme | 0:ea85c4bb5e1f | 712 | volatile bool commandExecuting; |
dan_ackme | 0:ea85c4bb5e1f | 713 | bool initialized; |
dan_ackme | 0:ea85c4bb5e1f | 714 | bool nonBlocking; |
dan_ackme | 0:ea85c4bb5e1f | 715 | |
dan_ackme | 0:ea85c4bb5e1f | 716 | PinToGpioMapper pinToGpioMapper; |
dan_ackme | 0:ea85c4bb5e1f | 717 | |
dan_ackme | 0:ea85c4bb5e1f | 718 | char *internalBuffer; |
dan_ackme | 0:ea85c4bb5e1f | 719 | int internalBufferSize; |
dan_ackme | 0:ea85c4bb5e1f | 720 | bool internalBufferAlloc; |
dan_ackme | 0:ea85c4bb5e1f | 721 | uint8_t internalProcessingState; |
dan_ackme | 0:ea85c4bb5e1f | 722 | void *currentCommandId; |
dan_ackme | 0:ea85c4bb5e1f | 723 | |
dan_ackme | 0:ea85c4bb5e1f | 724 | wiconnect::TimeoutTimer timeoutTimer; |
dan_ackme | 0:ea85c4bb5e1f | 725 | int defaultTimeoutMs; |
dan_ackme | 0:ea85c4bb5e1f | 726 | |
dan_ackme | 0:ea85c4bb5e1f | 727 | uint8_t commandHeaderBuffer[32]; |
dan_ackme | 0:ea85c4bb5e1f | 728 | char commandFormatBuffer[WICONNECT_MAX_CMD_SIZE]; |
dan_ackme | 0:ea85c4bb5e1f | 729 | uint8_t commandContext[96]; |
dan_ackme | 0:ea85c4bb5e1f | 730 | |
dan_ackme | 0:ea85c4bb5e1f | 731 | void prepare(void *internalBuffer, int internalBufferSize, bool nonBlocking); |
dan_ackme | 0:ea85c4bb5e1f | 732 | WiconnectResult inline receiveResponse(); |
dan_ackme | 0:ea85c4bb5e1f | 733 | WiconnectResult inline receivePacket(); |
dan_ackme | 0:ea85c4bb5e1f | 734 | void issueCommandCallback(WiconnectResult result); |
dan_ackme | 0:ea85c4bb5e1f | 735 | |
dan_ackme | 6:8a87a59d0d21 | 736 | LogFunc debugLogger; |
dan_ackme | 6:8a87a59d0d21 | 737 | LogFunc assertLogger; |
dan_ackme | 0:ea85c4bb5e1f | 738 | void debugLog(const char *msg, ...); |
dan_ackme | 0:ea85c4bb5e1f | 739 | |
dan_ackme | 0:ea85c4bb5e1f | 740 | #ifdef WICONNECT_ASYNC_TIMER_ENABLED |
dan_ackme | 0:ea85c4bb5e1f | 741 | wiconnect::PeriodicTimer commandProcessorTimer; |
dan_ackme | 0:ea85c4bb5e1f | 742 | uint32_t commandProcessingPeriod; |
dan_ackme | 0:ea85c4bb5e1f | 743 | CommandQueue commandQueue; |
dan_ackme | 0:ea85c4bb5e1f | 744 | wiconnect::QueuedCommand *currentQueuedCommand; |
dan_ackme | 0:ea85c4bb5e1f | 745 | |
dan_ackme | 0:ea85c4bb5e1f | 746 | void commandProcessingTimerHandler(void); |
dan_ackme | 0:ea85c4bb5e1f | 747 | void processNextQueuedCommand(); |
dan_ackme | 0:ea85c4bb5e1f | 748 | void checkQueuedCommandTimeout(); |
dan_ackme | 0:ea85c4bb5e1f | 749 | #endif |
dan_ackme | 0:ea85c4bb5e1f | 750 | |
dan_ackme | 0:ea85c4bb5e1f | 751 | friend class NetworkInterface; |
dan_ackme | 0:ea85c4bb5e1f | 752 | friend class SocketInterface; |
dan_ackme | 0:ea85c4bb5e1f | 753 | friend class FileInterface; |
dan_ackme | 0:ea85c4bb5e1f | 754 | }; |
dan_ackme | 0:ea85c4bb5e1f | 755 | |
dan_ackme | 0:ea85c4bb5e1f | 756 | } |
dan_ackme | 21:17bb3eddcbae | 757 | |
dan_ackme | 21:17bb3eddcbae | 758 | |
dan_ackme | 21:17bb3eddcbae | 759 | #include "sdkTypes.h" |
dan_ackme | 21:17bb3eddcbae | 760 |