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:
Tue Aug 26 16:38:19 2014 -0700
Revision:
21:17bb3eddcbae
Parent:
17:7268f365676b
Child:
24:e27e23297f02
Child:
26:8067e3d463d3
Add TCP server API

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dan_ackme 21:17bb3eddcbae 1 /**
dan_ackme 21:17bb3eddcbae 2 * ACKme WiConnect Host Library is licensed under the BSD licence:
dan_ackme 21:17bb3eddcbae 3 *
dan_ackme 21:17bb3eddcbae 4 * Copyright (c)2014 ACKme Networks.
dan_ackme 21:17bb3eddcbae 5 * All rights reserved.
dan_ackme 21:17bb3eddcbae 6 *
dan_ackme 21:17bb3eddcbae 7 * Redistribution and use in source and binary forms, with or without modification,
dan_ackme 21:17bb3eddcbae 8 * are permitted provided that the following conditions are met:
dan_ackme 21:17bb3eddcbae 9 *
dan_ackme 21:17bb3eddcbae 10 * 1. Redistributions of source code must retain the above copyright notice,
dan_ackme 21:17bb3eddcbae 11 * this list of conditions and the following disclaimer.
dan_ackme 21:17bb3eddcbae 12 * 2. Redistributions in binary form must reproduce the above copyright notice,
dan_ackme 21:17bb3eddcbae 13 * this list of conditions and the following disclaimer in the documentation
dan_ackme 21:17bb3eddcbae 14 * and/or other materials provided with the distribution.
dan_ackme 21:17bb3eddcbae 15 * 3. The name of the author may not be used to endorse or promote products
dan_ackme 21:17bb3eddcbae 16 * derived from this software without specific prior written permission.
dan_ackme 21:17bb3eddcbae 17 *
dan_ackme 21:17bb3eddcbae 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS AND ANY EXPRESS OR IMPLIED
dan_ackme 21:17bb3eddcbae 19 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
dan_ackme 21:17bb3eddcbae 20 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
dan_ackme 21:17bb3eddcbae 21 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
dan_ackme 21:17bb3eddcbae 22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
dan_ackme 21:17bb3eddcbae 23 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
dan_ackme 21:17bb3eddcbae 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
dan_ackme 21:17bb3eddcbae 25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
dan_ackme 21:17bb3eddcbae 26 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
dan_ackme 21:17bb3eddcbae 27 * OF SUCH DAMAGE.
dan_ackme 0:ea85c4bb5e1f 28 */
dan_ackme 0:ea85c4bb5e1f 29 #pragma once
dan_ackme 0:ea85c4bb5e1f 30
dan_ackme 0:ea85c4bb5e1f 31 #include <stdint.h>
dan_ackme 0:ea85c4bb5e1f 32 #include <stdarg.h>
dan_ackme 21:17bb3eddcbae 33 #include <cstddef>
dan_ackme 0:ea85c4bb5e1f 34
dan_ackme 0:ea85c4bb5e1f 35 #include "sdk.h"
dan_ackme 0:ea85c4bb5e1f 36
dan_ackme 11:ea484e1b7fc4 37 /**
dan_ackme 11:ea484e1b7fc4 38 * @namespace wiconnect
dan_ackme 11:ea484e1b7fc4 39 *
dan_ackme 11:ea484e1b7fc4 40 * @brief The entire Wiconnect Library is contained within the 'wiconnect' namespace
dan_ackme 11:ea484e1b7fc4 41 */
dan_ackme 0:ea85c4bb5e1f 42 namespace wiconnect {
dan_ackme 0:ea85c4bb5e1f 43
dan_ackme 0:ea85c4bb5e1f 44
dan_ackme 0:ea85c4bb5e1f 45 #ifndef MIN
dan_ackme 11:ea484e1b7fc4 46 /**
dan_ackme 11:ea484e1b7fc4 47 * @ingroup api_core_macro
dan_ackme 11:ea484e1b7fc4 48 * @def MIN(x,y)
dan_ackme 11:ea484e1b7fc4 49 * @brief Computes the minimum of \a x and \a y.
dan_ackme 11:ea484e1b7fc4 50 */
dan_ackme 0:ea85c4bb5e1f 51 #define MIN(x,y) ((x) < (y) ? (x) : (y))
dan_ackme 0:ea85c4bb5e1f 52 #endif
dan_ackme 0:ea85c4bb5e1f 53 #ifndef MAX
dan_ackme 11:ea484e1b7fc4 54 /**
dan_ackme 11:ea484e1b7fc4 55 * @ingroup api_core_macro
dan_ackme 11:ea484e1b7fc4 56 * @def MAX(x,y)
dan_ackme 11:ea484e1b7fc4 57 * @brief Computes the maximum of \a x and \a y.
dan_ackme 11:ea484e1b7fc4 58 */
dan_ackme 0:ea85c4bb5e1f 59 #define MAX(x,y) ((x) > (y) ? (x) : (y))
dan_ackme 0:ea85c4bb5e1f 60 #endif
dan_ackme 11:ea484e1b7fc4 61 /**
dan_ackme 11:ea484e1b7fc4 62 * @ingroup api_core_macro
dan_ackme 11:ea484e1b7fc4 63 * @def ALIGN_n(x, n)
dan_ackme 11:ea484e1b7fc4 64 * @brief Align \a x to \a n bytes (\a n must be power of 2)
dan_ackme 11:ea484e1b7fc4 65 */
dan_ackme 0:ea85c4bb5e1f 66 #define ALIGN_n(x, n) ((((uint32_t)x) + ((n)-1)) & ~((n)-1))
dan_ackme 11:ea484e1b7fc4 67 /**
dan_ackme 11:ea484e1b7fc4 68 * @ingroup api_core_macro
dan_ackme 11:ea484e1b7fc4 69 * @def ALIGN_8(x)
dan_ackme 11:ea484e1b7fc4 70 * @brief Align \a x to 8 bytes
dan_ackme 11:ea484e1b7fc4 71 */
dan_ackme 0:ea85c4bb5e1f 72 #define ALIGN_8(x) ALIGN_n(x, 8)
dan_ackme 11:ea484e1b7fc4 73 /**
dan_ackme 11:ea484e1b7fc4 74 * @ingroup api_core_macro
dan_ackme 11:ea484e1b7fc4 75 * @def ALIGN_4(x)
dan_ackme 11:ea484e1b7fc4 76 * @brief Align \a x to 4 bytes
dan_ackme 11:ea484e1b7fc4 77 */
dan_ackme 0:ea85c4bb5e1f 78 #define ALIGN_4(x) ALIGN_n(x, 4)
dan_ackme 11:ea484e1b7fc4 79 /**
dan_ackme 11:ea484e1b7fc4 80 * @ingroup api_core_macro
dan_ackme 11:ea484e1b7fc4 81 * @def ARRAY_COUNT(x)
dan_ackme 11:ea484e1b7fc4 82 * @brief Return number of elements in static array \a x
dan_ackme 11:ea484e1b7fc4 83 */
dan_ackme 0:ea85c4bb5e1f 84 #define ARRAY_COUNT(x) (sizeof (x) / sizeof *(x))
dan_ackme 0:ea85c4bb5e1f 85
dan_ackme 0:ea85c4bb5e1f 86
dan_ackme 11:ea484e1b7fc4 87 /**
dan_ackme 11:ea484e1b7fc4 88 * @ingroup api_core_macro
dan_ackme 11:ea484e1b7fc4 89 * @def WICONNECT_FAILED(result, func)
dan_ackme 11:ea484e1b7fc4 90 * @brief Populates \a result with return value from \a func, returns TRUE if return value contains error.
dan_ackme 11:ea484e1b7fc4 91 */
dan_ackme 0:ea85c4bb5e1f 92 #define WICONNECT_FAILED(result, func) ((int)(result = (func)) < (int)wiconnect::WICONNECT_SUCCESS)
dan_ackme 11:ea484e1b7fc4 93
dan_ackme 11:ea484e1b7fc4 94 /**
dan_ackme 11:ea484e1b7fc4 95 * @ingroup api_core_macro
dan_ackme 11:ea484e1b7fc4 96 * @def WICONNECT_SUCCEEDED(result, func)
dan_ackme 11:ea484e1b7fc4 97 * @brief Populates \a result with return value from \a func, returns TRUE if return value is WICONNECT_SUCCESS.
dan_ackme 11:ea484e1b7fc4 98 */
dan_ackme 0:ea85c4bb5e1f 99 #define WICONNECT_SUCCEEDED(result, func) ((result = (func)) == wiconnect::WICONNECT_SUCCESS)
dan_ackme 0:ea85c4bb5e1f 100
dan_ackme 0:ea85c4bb5e1f 101
dan_ackme 11:ea484e1b7fc4 102 /**
dan_ackme 11:ea484e1b7fc4 103 * @ingroup api_core_macro
dan_ackme 11:ea484e1b7fc4 104 * @brief The maximum command size that may be sent to the WiConnect WiFi module
dan_ackme 11:ea484e1b7fc4 105 */
dan_ackme 0:ea85c4bb5e1f 106 #define WICONNECT_MAX_CMD_SIZE 128
dan_ackme 11:ea484e1b7fc4 107 /**
dan_ackme 11:ea484e1b7fc4 108 * @ingroup api_core_macro
dan_ackme 11:ea484e1b7fc4 109 * @brief The maximum WiConnect WiFi module version string size
dan_ackme 11:ea484e1b7fc4 110 */
dan_ackme 0:ea85c4bb5e1f 111 #define WICONNECT_MAX_VERSION_SIZE 96
dan_ackme 11:ea484e1b7fc4 112 /**
dan_ackme 11:ea484e1b7fc4 113 * @ingroup api_core_macro
dan_ackme 11:ea484e1b7fc4 114 * @brief The maximum number of simulanteous opened sockets
dan_ackme 11:ea484e1b7fc4 115 */
dan_ackme 0:ea85c4bb5e1f 116 #define WICONNECT_MAX_SOCKETS 8
dan_ackme 11:ea484e1b7fc4 117 /**
dan_ackme 11:ea484e1b7fc4 118 * @ingroup api_core_macro
dan_ackme 11:ea484e1b7fc4 119 * @brief The maximum server string length
dan_ackme 11:ea484e1b7fc4 120 */
dan_ackme 11:ea484e1b7fc4 121 #define WICONNECT_MAX_HOST_SIZE 64
dan_ackme 11:ea484e1b7fc4 122 /**
dan_ackme 11:ea484e1b7fc4 123 * @ingroup api_core_macro
dan_ackme 11:ea484e1b7fc4 124 * @brief The maximum Wiconnect Module flash filesystem filename length
dan_ackme 11:ea484e1b7fc4 125 */
dan_ackme 11:ea484e1b7fc4 126 #define WICONNECT_MAX_FILENAME_SIZE 96
dan_ackme 21:17bb3eddcbae 127 /**
dan_ackme 21:17bb3eddcbae 128 * @ingroup api_core_macro
dan_ackme 21:17bb3eddcbae 129 * @brief Never timeout
dan_ackme 21:17bb3eddcbae 130 */
dan_ackme 21:17bb3eddcbae 131 #define WICONNECT_WAIT_FOREVER 0xFFFFFFFF
dan_ackme 21:17bb3eddcbae 132 /**
dan_ackme 21:17bb3eddcbae 133 * @ingroup api_core_macro
dan_ackme 21:17bb3eddcbae 134 * @brief Timeout immediately
dan_ackme 21:17bb3eddcbae 135 */
dan_ackme 21:17bb3eddcbae 136 #define WICONNECT_NO_WAIT 0
dan_ackme 0:ea85c4bb5e1f 137
dan_ackme 11:ea484e1b7fc4 138
dan_ackme 11:ea484e1b7fc4 139 /**
dan_ackme 11:ea484e1b7fc4 140 * @ingroup api_socket_macro
dan_ackme 11:ea484e1b7fc4 141 * @brief Default which indicates to use the most optimal port
dan_ackme 11:ea484e1b7fc4 142 */
dan_ackme 11:ea484e1b7fc4 143 #define SOCKET_ANY_PORT (uint16_t)0
dan_ackme 11:ea484e1b7fc4 144 /**
dan_ackme 11:ea484e1b7fc4 145 * @ingroup api_socket_macro
dan_ackme 11:ea484e1b7fc4 146 * @brief Default which indicates to use the most optimal port
dan_ackme 11:ea484e1b7fc4 147 */
dan_ackme 0:ea85c4bb5e1f 148 #define SOCKET_INVALID_HANDLE ((uint8_t)0xFF)
dan_ackme 0:ea85c4bb5e1f 149
dan_ackme 0:ea85c4bb5e1f 150
dan_ackme 11:ea484e1b7fc4 151 /**
dan_ackme 13:2b51f5267c92 152 * @ingroup api_core_types
dan_ackme 11:ea484e1b7fc4 153 * @brief API Result code
dan_ackme 11:ea484e1b7fc4 154 */
dan_ackme 0:ea85c4bb5e1f 155 typedef enum
dan_ackme 0:ea85c4bb5e1f 156 {
dan_ackme 11:ea484e1b7fc4 157 // Status Codes
dan_ackme 11:ea484e1b7fc4 158 WICONNECT_ABORTED = 3, ///< Command was aborted
dan_ackme 11:ea484e1b7fc4 159 WICONNECT_IDLE = 2, ///< Library not processing any commands
dan_ackme 11:ea484e1b7fc4 160 WICONNECT_PROCESSING = 1, ///< Library processing current command
dan_ackme 11:ea484e1b7fc4 161 WICONNECT_SUCCESS = 0, ///< Command successfully completed
dan_ackme 11:ea484e1b7fc4 162
dan_ackme 11:ea484e1b7fc4 163 // Error codes
dan_ackme 11:ea484e1b7fc4 164 WICONNECT_ERROR = -1, ///< Generic error
dan_ackme 11:ea484e1b7fc4 165 WICONNECT_CMD_RESPONSE_ERROR = -2, ///< Module returned error code
dan_ackme 11:ea484e1b7fc4 166 WICONNECT_NULL_BUFFER = -3, ///< Null buffer supplied
dan_ackme 11:ea484e1b7fc4 167 WICONNECT_NOT_INITIALIZED = -4, ///< Library not initialed
dan_ackme 11:ea484e1b7fc4 168 WICONNECT_OVERFLOW = -5, ///< Buffer overflowed
dan_ackme 11:ea484e1b7fc4 169 WICONNECT_TIMEOUT = -6, ///< Command timed out
dan_ackme 11:ea484e1b7fc4 170 // WICONNECT_RESPONSE_HANDLER_NULL = -7, ///<
dan_ackme 11:ea484e1b7fc4 171 WICONNECT_RESPONSE_PARSE_ERROR = -8, ///< Failed to parse module response
dan_ackme 11:ea484e1b7fc4 172 WICONNECT_ANOTHER_CMD_EXECUTING = -9, ///< Currently executing another command
dan_ackme 11:ea484e1b7fc4 173 WICONNECT_BAD_ARG = -10, ///< Bad argument supplied
dan_ackme 11:ea484e1b7fc4 174 WICONNECT_UNSUPPORTED = -11, ///< Command / parameter not supported
dan_ackme 11:ea484e1b7fc4 175 WICONNECT_PINNAME_TO_GPIO_MAPPER_NULL = -12, ///< The pinToGpioMapper hasn't been set
dan_ackme 11:ea484e1b7fc4 176 WICONNECT_DUPLICATE = -13, ///< Duplicate value
dan_ackme 11:ea484e1b7fc4 177 WICONNECT_NOT_FOUND = -14, ///< Not found
dan_ackme 11:ea484e1b7fc4 178 WICONNECT_PINNAME_TO_GPIO_NO_MAPPING = -15, ///< No mapping found for given pin
dan_ackme 11:ea484e1b7fc4 179 WICONNECT_NOT_CONNECTED = -16, ///< Not connected
dan_ackme 11:ea484e1b7fc4 180 WICONNECT_UNDERFLOW = -17, ///< Data underflow
dan_ackme 11:ea484e1b7fc4 181 WICONNECT_MONITOR_NOT_AVAILABLE = -18, ///< Background processing monitor is not available (i.e in use)
dan_ackme 11:ea484e1b7fc4 182 WICONNECT_NOT_OPENED_FOR_READING = -19, ///< The file is not open for reading
dan_ackme 0:ea85c4bb5e1f 183 } WiconnectResult;
dan_ackme 0:ea85c4bb5e1f 184
dan_ackme 0:ea85c4bb5e1f 185
dan_ackme 11:ea484e1b7fc4 186 /**
dan_ackme 11:ea484e1b7fc4 187 * @ingroup types_core
dan_ackme 11:ea484e1b7fc4 188 * @brief Function pointer for mapping from a host pin to a WiConnect Module GPIO.
dan_ackme 11:ea484e1b7fc4 189 *
dan_ackme 11:ea484e1b7fc4 190 * @param[in] pin A host pin
dan_ackme 11:ea484e1b7fc4 191 * @return The corresponding WiConnect Module GPIO (which the given pin is physically connected).
dan_ackme 11:ea484e1b7fc4 192 * Return -1 if no mapping is available.
dan_ackme 11:ea484e1b7fc4 193 */
dan_ackme 11:ea484e1b7fc4 194 typedef int8_t (*PinToGpioMapper)(Pin pin);
dan_ackme 11:ea484e1b7fc4 195
dan_ackme 11:ea484e1b7fc4 196 /**
dan_ackme 11:ea484e1b7fc4 197 * @brief Generic buffer type
dan_ackme 13:2b51f5267c92 198 *
dan_ackme 13:2b51f5267c92 199 * @note Internal use only
dan_ackme 11:ea484e1b7fc4 200 */
dan_ackme 11:ea484e1b7fc4 201 typedef struct
dan_ackme 11:ea484e1b7fc4 202 {
dan_ackme 11:ea484e1b7fc4 203 int size;
dan_ackme 11:ea484e1b7fc4 204 uint8_t *buffer;
dan_ackme 11:ea484e1b7fc4 205 uint8_t *ptr;
dan_ackme 11:ea484e1b7fc4 206 int bytesPending;
dan_ackme 11:ea484e1b7fc4 207 bool allocated;
dan_ackme 11:ea484e1b7fc4 208 } Buffer;
dan_ackme 11:ea484e1b7fc4 209
dan_ackme 11:ea484e1b7fc4 210
dan_ackme 11:ea484e1b7fc4 211 // ----------------------------------------------------------------------------
dan_ackme 11:ea484e1b7fc4 212
dan_ackme 11:ea484e1b7fc4 213
dan_ackme 11:ea484e1b7fc4 214
dan_ackme 11:ea484e1b7fc4 215 /**
dan_ackme 13:2b51f5267c92 216 * @ingroup api_network_types
dan_ackme 11:ea484e1b7fc4 217 * @brief Network connection status
dan_ackme 11:ea484e1b7fc4 218 */
dan_ackme 0:ea85c4bb5e1f 219 typedef enum
dan_ackme 0:ea85c4bb5e1f 220 {
dan_ackme 11:ea484e1b7fc4 221 NETWORK_STATUS_DOWN, ///< Not connected to network
dan_ackme 11:ea484e1b7fc4 222 NETWORK_STATUS_WIFI_ONLY, ///< Connected to network but don't have IP address
dan_ackme 13:2b51f5267c92 223 NETWORK_STATUS_UP, ///< Conntected to network and have IP address
dan_ackme 13:2b51f5267c92 224 NETWORK_STATUS_JOINING ///< Joining a network
dan_ackme 0:ea85c4bb5e1f 225 } NetworkStatus;
dan_ackme 0:ea85c4bb5e1f 226
dan_ackme 11:ea484e1b7fc4 227 /**
dan_ackme 13:2b51f5267c92 228 * @ingroup api_network_types
dan_ackme 11:ea484e1b7fc4 229 * @brief Network RSSI signal level
dan_ackme 11:ea484e1b7fc4 230 */
dan_ackme 0:ea85c4bb5e1f 231 typedef enum
dan_ackme 0:ea85c4bb5e1f 232 {
dan_ackme 11:ea484e1b7fc4 233 NETWORK_RSSI_EXCELLENT = 0, ///< \> -20 dBm
dan_ackme 11:ea484e1b7fc4 234 NETWORK_RSSI_VERY_GOOD = 1, ///< \> -35 dBm
dan_ackme 11:ea484e1b7fc4 235 NETWORK_RSSI_GOOD = 2, ///< \> -50 dBm
dan_ackme 11:ea484e1b7fc4 236 NETWORK_RSSI_POOR = 3, ///< \> -70 dBm
dan_ackme 0:ea85c4bb5e1f 237 NETWORK_RSSI_VERY_POOR = 4, ///< < -71 dBm
dan_ackme 0:ea85c4bb5e1f 238 NETWORK_RSSI_UNKNOWN = 5 ///< Not available
dan_ackme 0:ea85c4bb5e1f 239 } NetworkSignalStrength;
dan_ackme 0:ea85c4bb5e1f 240
dan_ackme 11:ea484e1b7fc4 241 /**
dan_ackme 13:2b51f5267c92 242 * @ingroup api_network_types
dan_ackme 11:ea484e1b7fc4 243 * @brief Network security type
dan_ackme 11:ea484e1b7fc4 244 */
dan_ackme 0:ea85c4bb5e1f 245 typedef enum
dan_ackme 0:ea85c4bb5e1f 246 {
dan_ackme 0:ea85c4bb5e1f 247 NETWORK_SECURITY_OPEN,
dan_ackme 0:ea85c4bb5e1f 248 NETWORK_SECURITY_WEP_PSK,
dan_ackme 0:ea85c4bb5e1f 249 NETWORK_SECURITY_WPA_AES_PSK,
dan_ackme 0:ea85c4bb5e1f 250 NETWORK_SECURITY_WPA_TKIP_PSK,
dan_ackme 0:ea85c4bb5e1f 251 NETWORK_SECURITY_WPA2_AES_PSK,
dan_ackme 0:ea85c4bb5e1f 252 NETWORK_SECURITY_WPA2_MIXED_PSK,
dan_ackme 0:ea85c4bb5e1f 253 NETWORK_SECURITY_WPA2_TKIP_PSK,
dan_ackme 0:ea85c4bb5e1f 254 NETWORK_SECURITY_UNKNOWN
dan_ackme 0:ea85c4bb5e1f 255 } NetworkSecurity;
dan_ackme 0:ea85c4bb5e1f 256
dan_ackme 11:ea484e1b7fc4 257 /**
dan_ackme 13:2b51f5267c92 258 * @ingroup api_network_types
dan_ackme 11:ea484e1b7fc4 259 * @brief Network SSID type
dan_ackme 11:ea484e1b7fc4 260 */
dan_ackme 0:ea85c4bb5e1f 261 typedef struct
dan_ackme 0:ea85c4bb5e1f 262 {
dan_ackme 11:ea484e1b7fc4 263 uint8_t val[32]; ///< The raw data of the SSID (not necessarily a string)
dan_ackme 11:ea484e1b7fc4 264 uint8_t len; ///< The length in bytes of the SSID raw data
dan_ackme 0:ea85c4bb5e1f 265 } Ssid;
dan_ackme 0:ea85c4bb5e1f 266
dan_ackme 11:ea484e1b7fc4 267 /**
dan_ackme 13:2b51f5267c92 268 * @ingroup api_network_types
dan_ackme 11:ea484e1b7fc4 269 * @brief Network MAC Address type
dan_ackme 11:ea484e1b7fc4 270 */
dan_ackme 0:ea85c4bb5e1f 271 typedef struct
dan_ackme 0:ea85c4bb5e1f 272 {
dan_ackme 0:ea85c4bb5e1f 273 uint8_t octet[6];
dan_ackme 0:ea85c4bb5e1f 274 } MacAddress;
dan_ackme 11:ea484e1b7fc4 275
dan_ackme 11:ea484e1b7fc4 276 /**
dan_ackme 13:2b51f5267c92 277 * @ingroup api_network_types
dan_ackme 11:ea484e1b7fc4 278 * @brief Buffer to hold a MAC address string
dan_ackme 11:ea484e1b7fc4 279 */
dan_ackme 0:ea85c4bb5e1f 280 typedef char MacAddressStrBuffer[18];
dan_ackme 11:ea484e1b7fc4 281
dan_ackme 11:ea484e1b7fc4 282 /**
dan_ackme 13:2b51f5267c92 283 * @ingroup api_network_types
dan_ackme 11:ea484e1b7fc4 284 * @brief Buffer to hold a SSID string
dan_ackme 11:ea484e1b7fc4 285 */
dan_ackme 0:ea85c4bb5e1f 286 typedef char SsidStrBuffer[129];
dan_ackme 11:ea484e1b7fc4 287
dan_ackme 11:ea484e1b7fc4 288 /**
dan_ackme 13:2b51f5267c92 289 * @ingroup api_network_types
dan_ackme 11:ea484e1b7fc4 290 * @brief Buffer to hold an IP address string
dan_ackme 11:ea484e1b7fc4 291 */
dan_ackme 0:ea85c4bb5e1f 292 typedef char IpStrBuffer[18];
dan_ackme 0:ea85c4bb5e1f 293
dan_ackme 0:ea85c4bb5e1f 294
dan_ackme 11:ea484e1b7fc4 295 // ----------------------------------------------------------------------------
dan_ackme 11:ea484e1b7fc4 296
dan_ackme 0:ea85c4bb5e1f 297
dan_ackme 11:ea484e1b7fc4 298 /**
dan_ackme 13:2b51f5267c92 299 * @ingroup api_socket_types
dan_ackme 11:ea484e1b7fc4 300 * @brief Socket type
dan_ackme 11:ea484e1b7fc4 301 */
dan_ackme 0:ea85c4bb5e1f 302 typedef enum
dan_ackme 0:ea85c4bb5e1f 303 {
dan_ackme 11:ea484e1b7fc4 304 SOCKET_TYPE_UNKNOWN, ///< Socket type not known
dan_ackme 11:ea484e1b7fc4 305 SOCKET_TYPE_TCP, ///< TCP Socket type
dan_ackme 11:ea484e1b7fc4 306 SOCKET_TYPE_TLS, ///< TLS Socket type
dan_ackme 11:ea484e1b7fc4 307 SOCKET_TYPE_UDP, ///< UDP Socket type
dan_ackme 11:ea484e1b7fc4 308 SOCKET_TYPE_HTTP, ///< HTTP Socket type
dan_ackme 11:ea484e1b7fc4 309 } SocketType;
dan_ackme 0:ea85c4bb5e1f 310
dan_ackme 11:ea484e1b7fc4 311 /**
dan_ackme 13:2b51f5267c92 312 * @ingroup api_socket_types
dan_ackme 11:ea484e1b7fc4 313 * @brief HTTP Socket sub-type
dan_ackme 11:ea484e1b7fc4 314 */
dan_ackme 0:ea85c4bb5e1f 315 typedef enum
dan_ackme 0:ea85c4bb5e1f 316 {
dan_ackme 11:ea484e1b7fc4 317 SOCKET_HTTP_GET, ///< HTTP GET Request socket type
dan_ackme 11:ea484e1b7fc4 318 SOCKET_HTTP_POST, ///< HTTP POST Request socket type
dan_ackme 11:ea484e1b7fc4 319 SOCKET_HTTP_HEAD, ///< HTTP HEAD Request socket type
dan_ackme 11:ea484e1b7fc4 320 } HttpSocketType;
dan_ackme 0:ea85c4bb5e1f 321
dan_ackme 11:ea484e1b7fc4 322 /**
dan_ackme 13:2b51f5267c92 323 * @ingroup api_socket_types
dan_ackme 11:ea484e1b7fc4 324 * @brief Struct for hold HTTP socket configuration
dan_ackme 11:ea484e1b7fc4 325 */
dan_ackme 11:ea484e1b7fc4 326 typedef struct
dan_ackme 11:ea484e1b7fc4 327 {
dan_ackme 11:ea484e1b7fc4 328 const char *contextType; ///< A POST Request 'context-type' value
dan_ackme 11:ea484e1b7fc4 329 const char *certName; ///< TLS certificate filename on module flash file system
dan_ackme 11:ea484e1b7fc4 330 bool openOnly; ///< Only open the connection, don't issue the request yet
dan_ackme 11:ea484e1b7fc4 331 HttpSocketType type; ///< The type of HTTP connection
dan_ackme 11:ea484e1b7fc4 332 } HttpSocketArgs;
dan_ackme 0:ea85c4bb5e1f 333
dan_ackme 11:ea484e1b7fc4 334
dan_ackme 11:ea484e1b7fc4 335 // ----------------------------------------------------------------------------
dan_ackme 11:ea484e1b7fc4 336
dan_ackme 0:ea85c4bb5e1f 337
dan_ackme 11:ea484e1b7fc4 338 /**
dan_ackme 13:2b51f5267c92 339 * @ingroup api_file_types
dan_ackme 11:ea484e1b7fc4 340 * @brief File flags type
dan_ackme 11:ea484e1b7fc4 341 */
dan_ackme 0:ea85c4bb5e1f 342 typedef enum
dan_ackme 0:ea85c4bb5e1f 343 {
dan_ackme 11:ea484e1b7fc4 344 FILE_FLAG_NONE = 0, ///< No flags
dan_ackme 0:ea85c4bb5e1f 345
dan_ackme 11:ea484e1b7fc4 346 FILE_FLAG_VALID = (1 << 0), ///< File valid
dan_ackme 11:ea484e1b7fc4 347 FILE_FLAG_EXECUTABLE = (1 << 1), ///< File executable
dan_ackme 11:ea484e1b7fc4 348 FILE_FLAG_ENCRYPTED = (1 << 2), ///< File encrypted
dan_ackme 11:ea484e1b7fc4 349 FILE_FLAG_INTERNAL = (1 << 3), ///< File on internal module flash
dan_ackme 11:ea484e1b7fc4 350 FILE_FLAG_BOOTABLE = (1 << 4), ///< File bootable
dan_ackme 11:ea484e1b7fc4 351 FILE_FLAG_USER = (1 << 5), ///< File created by user
dan_ackme 11:ea484e1b7fc4 352 FILE_FLAG_ESSENTIAL = (1 << 6), ///< File is essential
dan_ackme 11:ea484e1b7fc4 353
dan_ackme 11:ea484e1b7fc4 354 FILE_FLAG_INVALID = 0xFFFF ///< File flags invalid
dan_ackme 11:ea484e1b7fc4 355 } FileFlags;
dan_ackme 0:ea85c4bb5e1f 356
dan_ackme 11:ea484e1b7fc4 357 /**
dan_ackme 13:2b51f5267c92 358 * @ingroup api_file_types
dan_ackme 11:ea484e1b7fc4 359 * @brief File type type
dan_ackme 11:ea484e1b7fc4 360 */
dan_ackme 11:ea484e1b7fc4 361 typedef enum
dan_ackme 11:ea484e1b7fc4 362 {
dan_ackme 11:ea484e1b7fc4 363 FILE_TYPE_UPGRADE_APP = 0x00, ///< Internal upgrade application
dan_ackme 11:ea484e1b7fc4 364 FILE_TYPE_WIFI_FW = 0x01, ///< Wifi firmware binary
dan_ackme 11:ea484e1b7fc4 365
dan_ackme 11:ea484e1b7fc4 366 FILE_TYPE_REGULAR_APP = 0x81, ///< Regular application
dan_ackme 0:ea85c4bb5e1f 367
dan_ackme 11:ea484e1b7fc4 368 FILE_TYPE_USER_RANGE_START = 150, ///< User type start index
dan_ackme 11:ea484e1b7fc4 369 FILE_TYPE_USER_RANGE_END = 199, ///< User type end index
dan_ackme 11:ea484e1b7fc4 370
dan_ackme 11:ea484e1b7fc4 371 FILE_TYPE_TEMPORY = 0xF9, ///< Temporary file
dan_ackme 11:ea484e1b7fc4 372 FILE_TYPE_GPIO_CONFIG = 0xFA, ///< GPIO configuration file
dan_ackme 11:ea484e1b7fc4 373 FILE_TYPE_COMMAND_HELP = 0xFB, ///< WiConnect command help file
dan_ackme 11:ea484e1b7fc4 374 FILE_TYPE_SDC_CAPS = 0xFC, ///< SDC / goHACK.me file
dan_ackme 11:ea484e1b7fc4 375 FILE_TYPE_SETUP_SCRIPT = 0xFD, ///< Setup script file
dan_ackme 11:ea484e1b7fc4 376 FILE_TYPE_MISC_FIX_LEN = 0xFE, ///< Miscellaneous fixed length file
dan_ackme 11:ea484e1b7fc4 377 FILE_TYPE_UNKNOWN = 0xFF, ///< Unknown file type
dan_ackme 0:ea85c4bb5e1f 378 FILE_TYPE_ANY = FILE_TYPE_UNKNOWN
dan_ackme 0:ea85c4bb5e1f 379 } FileType;
dan_ackme 0:ea85c4bb5e1f 380
dan_ackme 11:ea484e1b7fc4 381
dan_ackme 0:ea85c4bb5e1f 382
dan_ackme 0:ea85c4bb5e1f 383
dan_ackme 11:ea484e1b7fc4 384 // Forward declarations
dan_ackme 11:ea484e1b7fc4 385
dan_ackme 0:ea85c4bb5e1f 386 class Wiconnect;
dan_ackme 0:ea85c4bb5e1f 387 class TimeoutTimer;
dan_ackme 0:ea85c4bb5e1f 388 class PeriodicTimer;
dan_ackme 0:ea85c4bb5e1f 389 class QueuedCommand;
dan_ackme 0:ea85c4bb5e1f 390 class CommandQueue;
dan_ackme 0:ea85c4bb5e1f 391 class LogFunc;
dan_ackme 0:ea85c4bb5e1f 392 class ReaderFunc;
dan_ackme 0:ea85c4bb5e1f 393 class Callback;
dan_ackme 0:ea85c4bb5e1f 394 class ScanResult;
dan_ackme 0:ea85c4bb5e1f 395 class ScanResultList;
dan_ackme 17:7268f365676b 396 class WiconnectSocket;
dan_ackme 0:ea85c4bb5e1f 397 class WiconnectSerial;
dan_ackme 17:7268f365676b 398 class WiconnectFile;
dan_ackme 0:ea85c4bb5e1f 399 class FileList;
dan_ackme 0:ea85c4bb5e1f 400 class Gpio;
dan_ackme 0:ea85c4bb5e1f 401 class SocketIrqHandlerMap;
dan_ackme 0:ea85c4bb5e1f 402
dan_ackme 0:ea85c4bb5e1f 403 }