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
SocketInterface.h@17:7268f365676b, 2014-08-23 (annotated)
- Committer:
- dan_ackme
- Date:
- Sat Aug 23 05:39:17 2014 -0700
- Revision:
- 17:7268f365676b
- Parent:
- 16:7f1d6d359787
- Child:
- 21:17bb3eddcbae
Fixes and documentation updates
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dan_ackme | 16:7f1d6d359787 | 1 | /** |
dan_ackme | 16:7f1d6d359787 | 2 | * ACKme WiConnect Host Library is licensed under the BSD licence: |
dan_ackme | 16:7f1d6d359787 | 3 | * |
dan_ackme | 16:7f1d6d359787 | 4 | * Copyright (c)2014 ACKme Networks. |
dan_ackme | 16:7f1d6d359787 | 5 | * All rights reserved. |
dan_ackme | 16:7f1d6d359787 | 6 | * |
dan_ackme | 16:7f1d6d359787 | 7 | * Redistribution and use in source and binary forms, with or without modification, |
dan_ackme | 16:7f1d6d359787 | 8 | * are permitted provided that the following conditions are met: |
dan_ackme | 16:7f1d6d359787 | 9 | * |
dan_ackme | 16:7f1d6d359787 | 10 | * 1. Redistributions of source code must retain the above copyright notice, |
dan_ackme | 16:7f1d6d359787 | 11 | * this list of conditions and the following disclaimer. |
dan_ackme | 16:7f1d6d359787 | 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
dan_ackme | 16:7f1d6d359787 | 13 | * this list of conditions and the following disclaimer in the documentation |
dan_ackme | 16:7f1d6d359787 | 14 | * and/or other materials provided with the distribution. |
dan_ackme | 16:7f1d6d359787 | 15 | * 3. The name of the author may not be used to endorse or promote products |
dan_ackme | 16:7f1d6d359787 | 16 | * derived from this software without specific prior written permission. |
dan_ackme | 16:7f1d6d359787 | 17 | * |
dan_ackme | 16:7f1d6d359787 | 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS AND ANY EXPRESS OR IMPLIED |
dan_ackme | 16:7f1d6d359787 | 19 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
dan_ackme | 16:7f1d6d359787 | 20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
dan_ackme | 16:7f1d6d359787 | 21 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
dan_ackme | 16:7f1d6d359787 | 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT |
dan_ackme | 16:7f1d6d359787 | 23 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
dan_ackme | 16:7f1d6d359787 | 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
dan_ackme | 16:7f1d6d359787 | 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
dan_ackme | 16:7f1d6d359787 | 26 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY |
dan_ackme | 16:7f1d6d359787 | 27 | * OF SUCH DAMAGE. |
dan_ackme | 0:ea85c4bb5e1f | 28 | */ |
dan_ackme | 0:ea85c4bb5e1f | 29 | #pragma once |
dan_ackme | 0:ea85c4bb5e1f | 30 | |
dan_ackme | 0:ea85c4bb5e1f | 31 | #include "Wiconnect.h" |
dan_ackme | 17:7268f365676b | 32 | #include "types/WiconnectSocket.h" |
dan_ackme | 0:ea85c4bb5e1f | 33 | #include "types/SocketIrqHandlerMap.h" |
dan_ackme | 0:ea85c4bb5e1f | 34 | |
dan_ackme | 0:ea85c4bb5e1f | 35 | |
dan_ackme | 11:ea484e1b7fc4 | 36 | /** |
dan_ackme | 11:ea484e1b7fc4 | 37 | * @namespace wiconnect |
dan_ackme | 11:ea484e1b7fc4 | 38 | */ |
dan_ackme | 0:ea85c4bb5e1f | 39 | namespace wiconnect { |
dan_ackme | 0:ea85c4bb5e1f | 40 | |
dan_ackme | 0:ea85c4bb5e1f | 41 | |
dan_ackme | 11:ea484e1b7fc4 | 42 | /** |
dan_ackme | 13:2b51f5267c92 | 43 | * @ingroup api_socket_types |
dan_ackme | 11:ea484e1b7fc4 | 44 | * |
dan_ackme | 11:ea484e1b7fc4 | 45 | * @brief The provides an interface for creating TCP/UDP/TLS/HTTP client sockets. |
dan_ackme | 11:ea484e1b7fc4 | 46 | * A client socket connects to a remote server. |
dan_ackme | 11:ea484e1b7fc4 | 47 | * |
dan_ackme | 13:2b51f5267c92 | 48 | * @note This class is an interface to the Wiconnect class. It should never be |
dan_ackme | 13:2b51f5267c92 | 49 | * independently instantiated or the parent of another class. |
dan_ackme | 11:ea484e1b7fc4 | 50 | */ |
dan_ackme | 0:ea85c4bb5e1f | 51 | class SocketInterface |
dan_ackme | 0:ea85c4bb5e1f | 52 | { |
dan_ackme | 0:ea85c4bb5e1f | 53 | public: |
dan_ackme | 11:ea484e1b7fc4 | 54 | /** |
dan_ackme | 11:ea484e1b7fc4 | 55 | * @ingroup api_socket_misc |
dan_ackme | 11:ea484e1b7fc4 | 56 | * |
dan_ackme | 11:ea484e1b7fc4 | 57 | * @brief Close all opened sockets. |
dan_ackme | 13:2b51f5267c92 | 58 | * |
dan_ackme | 13:2b51f5267c92 | 59 | * @note This closes all open sockets on the MODULE side. |
dan_ackme | 13:2b51f5267c92 | 60 | * Socket objects on the HOST side will be still open until |
dan_ackme | 13:2b51f5267c92 | 61 | * issuing a read/write command to the module using the socket handle. |
dan_ackme | 13:2b51f5267c92 | 62 | * |
dan_ackme | 13:2b51f5267c92 | 63 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 11:ea484e1b7fc4 | 64 | */ |
dan_ackme | 0:ea85c4bb5e1f | 65 | WiconnectResult closeAllSockets(); |
dan_ackme | 11:ea484e1b7fc4 | 66 | |
dan_ackme | 11:ea484e1b7fc4 | 67 | /** |
dan_ackme | 11:ea484e1b7fc4 | 68 | * @ingroup api_socket_misc |
dan_ackme | 11:ea484e1b7fc4 | 69 | * |
dan_ackme | 11:ea484e1b7fc4 | 70 | * @brief Register a host pin as an external interrupt. When the external interrupt is |
dan_ackme | 11:ea484e1b7fc4 | 71 | * triggered, the supplied callback is executed. |
dan_ackme | 13:2b51f5267c92 | 72 | * |
dan_ackme | 13:2b51f5267c92 | 73 | * This should be called before calling one of the connect methods below |
dan_ackme | 13:2b51f5267c92 | 74 | * with an irqPin parameter. |
dan_ackme | 13:2b51f5267c92 | 75 | * |
dan_ackme | 13:2b51f5267c92 | 76 | * Basically how this works is: |
dan_ackme | 13:2b51f5267c92 | 77 | * 1. The supplied irqPin is configured as an external interrupt pin. |
dan_ackme | 13:2b51f5267c92 | 78 | * 2. A connection is opened and configured with the same irqPin. This |
dan_ackme | 13:2b51f5267c92 | 79 | * irqPin physically connected to a GPIO on the WiFi module. |
dan_ackme | 13:2b51f5267c92 | 80 | * 3. When the WiFi module has data to send to the HOST it asserts the irqPin. |
dan_ackme | 13:2b51f5267c92 | 81 | * 4. The irqPin interrupt executes and calls the supplied handler. |
dan_ackme | 13:2b51f5267c92 | 82 | * 5. The handler should notify the HOST that the given irqPin has triggered |
dan_ackme | 13:2b51f5267c92 | 83 | * and have the associated socket read data from the module. |
dan_ackme | 13:2b51f5267c92 | 84 | * |
dan_ackme | 13:2b51f5267c92 | 85 | * @note arg1 of the handler contains the irqPin |
dan_ackme | 13:2b51f5267c92 | 86 | * |
dan_ackme | 13:2b51f5267c92 | 87 | * |
dan_ackme | 13:2b51f5267c92 | 88 | * @param[in] irqPin The HOST pin to configure as an external interrupt. |
dan_ackme | 13:2b51f5267c92 | 89 | * This pin should be physically connected to a module GPIO. |
dan_ackme | 13:2b51f5267c92 | 90 | * @param[in] handler Callback to be executed with the external irqPin interrupt triggers |
dan_ackme | 13:2b51f5267c92 | 91 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 11:ea484e1b7fc4 | 92 | */ |
dan_ackme | 0:ea85c4bb5e1f | 93 | WiconnectResult registerSocketIrqHandler(Pin irqPin, const Callback &handler); |
dan_ackme | 11:ea484e1b7fc4 | 94 | |
dan_ackme | 11:ea484e1b7fc4 | 95 | /** |
dan_ackme | 11:ea484e1b7fc4 | 96 | * @ingroup api_socket_misc |
dan_ackme | 11:ea484e1b7fc4 | 97 | * |
dan_ackme | 11:ea484e1b7fc4 | 98 | * @brief Unregister a previously registered IRQ pin. |
dan_ackme | 13:2b51f5267c92 | 99 | * |
dan_ackme | 13:2b51f5267c92 | 100 | * This disables the given irqPin as an external interrupt. |
dan_ackme | 13:2b51f5267c92 | 101 | * Refer to registerSocketIrqHandler() for more information. |
dan_ackme | 13:2b51f5267c92 | 102 | * |
dan_ackme | 13:2b51f5267c92 | 103 | * @param[in] irqPin The HOST pin to unregister |
dan_ackme | 13:2b51f5267c92 | 104 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 11:ea484e1b7fc4 | 105 | */ |
dan_ackme | 0:ea85c4bb5e1f | 106 | WiconnectResult unregisterSocketIrqHandler(Pin irqPin); |
dan_ackme | 0:ea85c4bb5e1f | 107 | |
dan_ackme | 11:ea484e1b7fc4 | 108 | |
dan_ackme | 11:ea484e1b7fc4 | 109 | /** |
dan_ackme | 11:ea484e1b7fc4 | 110 | * @ingroup api_socket_misc |
dan_ackme | 11:ea484e1b7fc4 | 111 | * |
dan_ackme | 11:ea484e1b7fc4 | 112 | * @brief Connect to remote server. |
dan_ackme | 13:2b51f5267c92 | 113 | * |
dan_ackme | 13:2b51f5267c92 | 114 | * This is the base method used by all the other connect methods. |
dan_ackme | 13:2b51f5267c92 | 115 | * |
dan_ackme | 17:7268f365676b | 116 | * @param[out] socket @ref WiconnectSocket object of opened connection. |
dan_ackme | 13:2b51f5267c92 | 117 | * @param[in] type The @ref SocketType of connection to open |
dan_ackme | 13:2b51f5267c92 | 118 | * @param[in] host The host/IP address of the remote server |
dan_ackme | 13:2b51f5267c92 | 119 | * @param[in] remortPort The port of the remote server |
dan_ackme | 13:2b51f5267c92 | 120 | * @param[in] localPort The port of the module's side of the connection |
dan_ackme | 13:2b51f5267c92 | 121 | * @param[in] args Depedent on the connection type |
dan_ackme | 13:2b51f5267c92 | 122 | * @param[in] irqPin Data available external interrupt pin. See registerSocketIrqHandler() for more info |
dan_ackme | 13:2b51f5267c92 | 123 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 11:ea484e1b7fc4 | 124 | */ |
dan_ackme | 17:7268f365676b | 125 | WiconnectResult connect(WiconnectSocket &socket, SocketType type, const char *host, uint16_t remortPort, uint16_t localPort, const void *args, Pin irqPin); |
dan_ackme | 11:ea484e1b7fc4 | 126 | |
dan_ackme | 11:ea484e1b7fc4 | 127 | |
dan_ackme | 11:ea484e1b7fc4 | 128 | // ------------------------------------------------------------------------ |
dan_ackme | 11:ea484e1b7fc4 | 129 | |
dan_ackme | 11:ea484e1b7fc4 | 130 | /** |
dan_ackme | 11:ea484e1b7fc4 | 131 | * @ingroup api_socket_tcp |
dan_ackme | 11:ea484e1b7fc4 | 132 | * |
dan_ackme | 11:ea484e1b7fc4 | 133 | * @brief Connect to remote TCP server. |
dan_ackme | 13:2b51f5267c92 | 134 | * |
dan_ackme | 17:7268f365676b | 135 | * @param[out] socket TCP @ref WiconnectSocket object of opened connection. |
dan_ackme | 13:2b51f5267c92 | 136 | * @param[in] host The host/IP address of the remote TCP server |
dan_ackme | 13:2b51f5267c92 | 137 | * @param[in] remortPort The port of the remote server |
dan_ackme | 13:2b51f5267c92 | 138 | * @param[in] irqPin Optional, Data available external interrupt pin. See registerSocketIrqHandler() for more info |
dan_ackme | 13:2b51f5267c92 | 139 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 11:ea484e1b7fc4 | 140 | */ |
dan_ackme | 17:7268f365676b | 141 | WiconnectResult tcpConnect(WiconnectSocket &socket, const char *host, uint16_t remortPort, Pin irqPin = NC); |
dan_ackme | 11:ea484e1b7fc4 | 142 | |
dan_ackme | 11:ea484e1b7fc4 | 143 | |
dan_ackme | 11:ea484e1b7fc4 | 144 | // ------------------------------------------------------------------------ |
dan_ackme | 11:ea484e1b7fc4 | 145 | |
dan_ackme | 11:ea484e1b7fc4 | 146 | /** |
dan_ackme | 11:ea484e1b7fc4 | 147 | * @ingroup api_socket_tls |
dan_ackme | 11:ea484e1b7fc4 | 148 | * |
dan_ackme | 11:ea484e1b7fc4 | 149 | * @brief Connect to remote TLS server. |
dan_ackme | 13:2b51f5267c92 | 150 | * |
dan_ackme | 17:7268f365676b | 151 | * @param[out] socket TLS @ref WiconnectSocket object of opened connection. |
dan_ackme | 13:2b51f5267c92 | 152 | * @param[in] host The host/IP address of the remote TLS server |
dan_ackme | 13:2b51f5267c92 | 153 | * @param[in] remortPort The port of the remote server |
dan_ackme | 13:2b51f5267c92 | 154 | * @param[in] certFilename Optional, filename of certificate on module's file system |
dan_ackme | 13:2b51f5267c92 | 155 | * @param[in] irqPin Optional, Data available external interrupt pin. See registerSocketIrqHandler() for more info |
dan_ackme | 13:2b51f5267c92 | 156 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 11:ea484e1b7fc4 | 157 | */ |
dan_ackme | 17:7268f365676b | 158 | WiconnectResult tlsConnect(WiconnectSocket &socket, const char *host, uint16_t remortPort, const char *certFilename = NULL, Pin irqPin = NC); |
dan_ackme | 11:ea484e1b7fc4 | 159 | |
dan_ackme | 11:ea484e1b7fc4 | 160 | |
dan_ackme | 11:ea484e1b7fc4 | 161 | // ------------------------------------------------------------------------ |
dan_ackme | 11:ea484e1b7fc4 | 162 | |
dan_ackme | 11:ea484e1b7fc4 | 163 | /** |
dan_ackme | 11:ea484e1b7fc4 | 164 | * @ingroup api_socket_udp |
dan_ackme | 11:ea484e1b7fc4 | 165 | * |
dan_ackme | 11:ea484e1b7fc4 | 166 | * @brief Connect to remote UDP server. |
dan_ackme | 13:2b51f5267c92 | 167 | * |
dan_ackme | 17:7268f365676b | 168 | * @param[out] socket UDP @ref WiconnectSocket object of opened connection. |
dan_ackme | 13:2b51f5267c92 | 169 | * @param[in] host The host/IP address of the remote UDP server |
dan_ackme | 13:2b51f5267c92 | 170 | * @param[in] remortPort The port of the remote server |
dan_ackme | 13:2b51f5267c92 | 171 | * @param[in] localPort Optional, port of module's side of the connection |
dan_ackme | 13:2b51f5267c92 | 172 | * @param[in] irqPin Optional, Data available external interrupt pin. See registerSocketIrqHandler() for more info |
dan_ackme | 13:2b51f5267c92 | 173 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 11:ea484e1b7fc4 | 174 | */ |
dan_ackme | 17:7268f365676b | 175 | WiconnectResult udpConnect(WiconnectSocket &socket, const char *host, uint16_t remortPort, uint16_t localPort = SOCKET_ANY_PORT, Pin irqPin = NC); |
dan_ackme | 11:ea484e1b7fc4 | 176 | |
dan_ackme | 11:ea484e1b7fc4 | 177 | |
dan_ackme | 11:ea484e1b7fc4 | 178 | // ------------------------------------------------------------------------ |
dan_ackme | 11:ea484e1b7fc4 | 179 | |
dan_ackme | 11:ea484e1b7fc4 | 180 | /** |
dan_ackme | 11:ea484e1b7fc4 | 181 | * @ingroup api_socket_http |
dan_ackme | 11:ea484e1b7fc4 | 182 | * |
dan_ackme | 11:ea484e1b7fc4 | 183 | * @brief Connect to remote HTTP server. |
dan_ackme | 13:2b51f5267c92 | 184 | * |
dan_ackme | 13:2b51f5267c92 | 185 | * This is the base method for the other HTTP methods. |
dan_ackme | 13:2b51f5267c92 | 186 | * |
dan_ackme | 13:2b51f5267c92 | 187 | * @section secure_http_connection Secure HTTP |
dan_ackme | 13:2b51f5267c92 | 188 | * Each HTTP method is able to connect to a secure HTTP server. To do this, |
dan_ackme | 13:2b51f5267c92 | 189 | * the URL string parameter must start with 'https://' |
dan_ackme | 13:2b51f5267c92 | 190 | * To connect to a secure HTTP server a TLS certificate is needed. The certificate |
dan_ackme | 13:2b51f5267c92 | 191 | * is specified in the certFilename parameter of the method (or @ref HttpSocketArgs parameter). |
dan_ackme | 13:2b51f5267c92 | 192 | * This is the filename of an existing certificate on the module file system. |
dan_ackme | 13:2b51f5267c92 | 193 | * |
dan_ackme | 13:2b51f5267c92 | 194 | * @note If the URL starts with 'https://' and no certificate filename is specified, |
dan_ackme | 13:2b51f5267c92 | 195 | * the module's default certificate is used. |
dan_ackme | 13:2b51f5267c92 | 196 | * |
dan_ackme | 17:7268f365676b | 197 | * @param[out] socket HTTP @ref WiconnectSocket object of opened connection. |
dan_ackme | 13:2b51f5267c92 | 198 | * @param[in] url URL of HTTP request |
dan_ackme | 13:2b51f5267c92 | 199 | * @param[in] args Configuration @ref HttpSocketArgs for HTTP connection |
dan_ackme | 13:2b51f5267c92 | 200 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 11:ea484e1b7fc4 | 201 | */ |
dan_ackme | 17:7268f365676b | 202 | WiconnectResult httpConnect(WiconnectSocket &socket, const char *url, const HttpSocketArgs *args); |
dan_ackme | 11:ea484e1b7fc4 | 203 | |
dan_ackme | 11:ea484e1b7fc4 | 204 | /** |
dan_ackme | 11:ea484e1b7fc4 | 205 | * @ingroup api_socket_http |
dan_ackme | 11:ea484e1b7fc4 | 206 | * |
dan_ackme | 11:ea484e1b7fc4 | 207 | * @brief Issue HTTP GET Request |
dan_ackme | 13:2b51f5267c92 | 208 | * |
dan_ackme | 13:2b51f5267c92 | 209 | * This method has the open to only 'open' the connection (disabled by default). This means a connection |
dan_ackme | 13:2b51f5267c92 | 210 | * to the remote HTTP server is opened, but the HTTP request isn't issued. This |
dan_ackme | 13:2b51f5267c92 | 211 | * allow for addition data to be added to the request. For instance, use httpAddHeader() to add |
dan_ackme | 13:2b51f5267c92 | 212 | * additional headers to the request. |
dan_ackme | 13:2b51f5267c92 | 213 | * Use httpGetStatus() to issue the HTTP request and receive the HTTP response. |
dan_ackme | 13:2b51f5267c92 | 214 | * |
dan_ackme | 17:7268f365676b | 215 | * @param[out] socket HTTP @ref WiconnectSocket object of opened connection. |
dan_ackme | 13:2b51f5267c92 | 216 | * @param[in] url URL of HTTP GET request |
dan_ackme | 13:2b51f5267c92 | 217 | * @param[in] openOnly Optional, if TRUE this will only open a connection to the server (it won't issue the request) |
dan_ackme | 13:2b51f5267c92 | 218 | * @param[in] certFilename Optional, filename of existing TLS certificate on module's file system. See @ref secure_http_connection |
dan_ackme | 13:2b51f5267c92 | 219 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 11:ea484e1b7fc4 | 220 | */ |
dan_ackme | 17:7268f365676b | 221 | WiconnectResult httpGet(WiconnectSocket &socket, const char *url, bool openOnly = false, const char *certFilename = NULL); |
dan_ackme | 11:ea484e1b7fc4 | 222 | |
dan_ackme | 11:ea484e1b7fc4 | 223 | /** |
dan_ackme | 11:ea484e1b7fc4 | 224 | * @ingroup api_socket_http |
dan_ackme | 11:ea484e1b7fc4 | 225 | * |
dan_ackme | 11:ea484e1b7fc4 | 226 | * @brief Issue HTTP POST Request |
dan_ackme | 13:2b51f5267c92 | 227 | * |
dan_ackme | 13:2b51f5267c92 | 228 | * This method has the open to only 'open' the connection which enabled by default. This means a connection |
dan_ackme | 13:2b51f5267c92 | 229 | * to the remote HTTP server is opened, but the HTTP request isn't issued. This |
dan_ackme | 17:7268f365676b | 230 | * allow for addition data to be added to the request. Use the returned @ref WiconnectSocket object's 'write' methods |
dan_ackme | 13:2b51f5267c92 | 231 | * to add POST data to the request. |
dan_ackme | 13:2b51f5267c92 | 232 | * When all POST data has been written, use httpGetStatus() to issue the HTTP request and receive the HTTP response. |
dan_ackme | 13:2b51f5267c92 | 233 | * |
dan_ackme | 17:7268f365676b | 234 | * @param[out] socket HTTP @ref WiconnectSocket object of opened connection. |
dan_ackme | 13:2b51f5267c92 | 235 | * @param[in] url URL of HTTP POST request |
dan_ackme | 13:2b51f5267c92 | 236 | * @param[in] contextType The value to go into the 'content-type' HTTP header (e.g. 'application/json') |
dan_ackme | 13:2b51f5267c92 | 237 | * @param[in] openOnly Optional, if FALSE this will immediately issue the POST request. |
dan_ackme | 13:2b51f5267c92 | 238 | * @param[in] certFilename Optional, filename of existing TLS certificate on module's file system. See @ref secure_http_connection |
dan_ackme | 13:2b51f5267c92 | 239 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 11:ea484e1b7fc4 | 240 | */ |
dan_ackme | 17:7268f365676b | 241 | WiconnectResult httpPost(WiconnectSocket &socket, const char *url, const char *contextType, bool openOnly = true, const char *certFilename = NULL); |
dan_ackme | 11:ea484e1b7fc4 | 242 | |
dan_ackme | 11:ea484e1b7fc4 | 243 | /** |
dan_ackme | 11:ea484e1b7fc4 | 244 | * @ingroup api_socket_http |
dan_ackme | 11:ea484e1b7fc4 | 245 | * |
dan_ackme | 11:ea484e1b7fc4 | 246 | * @brief Issue HTTP HEAD Request |
dan_ackme | 13:2b51f5267c92 | 247 | * |
dan_ackme | 17:7268f365676b | 248 | * @param[out] socket HTTP @ref WiconnectSocket object of opened connection. |
dan_ackme | 13:2b51f5267c92 | 249 | * @param[in] url URL of HTTP HEAD request |
dan_ackme | 13:2b51f5267c92 | 250 | * @param[in] certFilename Optional, filename of existing TLS certificate on module's file system. See @ref secure_http_connection |
dan_ackme | 13:2b51f5267c92 | 251 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 11:ea484e1b7fc4 | 252 | */ |
dan_ackme | 17:7268f365676b | 253 | WiconnectResult httpHead(WiconnectSocket &socket, const char *url, const char *certFilename = NULL); |
dan_ackme | 11:ea484e1b7fc4 | 254 | |
dan_ackme | 11:ea484e1b7fc4 | 255 | /** |
dan_ackme | 11:ea484e1b7fc4 | 256 | * @ingroup api_socket_http |
dan_ackme | 11:ea484e1b7fc4 | 257 | * |
dan_ackme | 11:ea484e1b7fc4 | 258 | * @brief Add HTTP header key/value pair to opened HTTP request. |
dan_ackme | 13:2b51f5267c92 | 259 | * |
dan_ackme | 17:7268f365676b | 260 | * To use this function, the supplied @ref WiconnectSocket parameter must have been created |
dan_ackme | 13:2b51f5267c92 | 261 | * using either httpGet() or httpPost() and the 'openOnly' parameter TRUE. |
dan_ackme | 13:2b51f5267c92 | 262 | * |
dan_ackme | 13:2b51f5267c92 | 263 | * This will add additional header to the HTTP request. |
dan_ackme | 13:2b51f5267c92 | 264 | * |
dan_ackme | 13:2b51f5267c92 | 265 | * Use httpGetStatus() to issue the request. |
dan_ackme | 13:2b51f5267c92 | 266 | * |
dan_ackme | 13:2b51f5267c92 | 267 | * @param[in] socket Opened socket to add additonal HTTP header |
dan_ackme | 13:2b51f5267c92 | 268 | * @param[in] key Header key (e.g. 'content-type') |
dan_ackme | 13:2b51f5267c92 | 269 | * @param[in] value Header value (e.g. 'application/json') |
dan_ackme | 13:2b51f5267c92 | 270 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 11:ea484e1b7fc4 | 271 | */ |
dan_ackme | 17:7268f365676b | 272 | WiconnectResult httpAddHeader(WiconnectSocket &socket, const char *key, const char *value); |
dan_ackme | 11:ea484e1b7fc4 | 273 | |
dan_ackme | 11:ea484e1b7fc4 | 274 | /** |
dan_ackme | 11:ea484e1b7fc4 | 275 | * @ingroup api_socket_http |
dan_ackme | 11:ea484e1b7fc4 | 276 | * |
dan_ackme | 11:ea484e1b7fc4 | 277 | * @brief Get the HTTP status code from HTTP request. |
dan_ackme | 13:2b51f5267c92 | 278 | * |
dan_ackme | 13:2b51f5267c92 | 279 | * This may be used to either issue an HTTP request of an opened HTTP connection |
dan_ackme | 13:2b51f5267c92 | 280 | * or return the status code of a request already issued. |
dan_ackme | 13:2b51f5267c92 | 281 | * |
dan_ackme | 13:2b51f5267c92 | 282 | * @param[in] socket Opened socket to get http response status code |
dan_ackme | 13:2b51f5267c92 | 283 | * @param[out] statusCodePtr Pointer to uint32 to hold http status code |
dan_ackme | 13:2b51f5267c92 | 284 | * @return Result of method. See @ref WiconnectResult |
dan_ackme | 11:ea484e1b7fc4 | 285 | */ |
dan_ackme | 17:7268f365676b | 286 | WiconnectResult httpGetStatus(WiconnectSocket &socket, uint32_t *statusCodePtr); |
dan_ackme | 0:ea85c4bb5e1f | 287 | |
dan_ackme | 0:ea85c4bb5e1f | 288 | protected: |
dan_ackme | 1:6ec9998427ad | 289 | SocketInterface(Wiconnect *wiconnect); |
dan_ackme | 1:6ec9998427ad | 290 | |
dan_ackme | 0:ea85c4bb5e1f | 291 | SocketIrqHandlerMap irqHandlers; |
dan_ackme | 0:ea85c4bb5e1f | 292 | |
dan_ackme | 0:ea85c4bb5e1f | 293 | private: |
dan_ackme | 0:ea85c4bb5e1f | 294 | Wiconnect *wiconnect; |
dan_ackme | 0:ea85c4bb5e1f | 295 | }; |
dan_ackme | 0:ea85c4bb5e1f | 296 | |
dan_ackme | 0:ea85c4bb5e1f | 297 | } |