see http://mbed.org/users/okini3939/notebook/wattmeter-shield-on-mbed/

Dependencies:   mbed

Fork of GSwifi_xively by gs fan

Committer:
okini3939
Date:
Wed Nov 27 08:18:45 2013 +0000
Revision:
4:9a2415f2ab07
update GSwifiInterface library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
okini3939 4:9a2415f2ab07 1 /* Copyright (C) 2013 gsfan, MIT License
okini3939 4:9a2415f2ab07 2 *
okini3939 4:9a2415f2ab07 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
okini3939 4:9a2415f2ab07 4 * and associated documentation files (the "Software"), to deal in the Software without restriction,
okini3939 4:9a2415f2ab07 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
okini3939 4:9a2415f2ab07 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
okini3939 4:9a2415f2ab07 7 * furnished to do so, subject to the following conditions:
okini3939 4:9a2415f2ab07 8 *
okini3939 4:9a2415f2ab07 9 * The above copyright notice and this permission notice shall be included in all copies or
okini3939 4:9a2415f2ab07 10 * substantial portions of the Software.
okini3939 4:9a2415f2ab07 11 *
okini3939 4:9a2415f2ab07 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
okini3939 4:9a2415f2ab07 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
okini3939 4:9a2415f2ab07 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
okini3939 4:9a2415f2ab07 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
okini3939 4:9a2415f2ab07 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
okini3939 4:9a2415f2ab07 17 *
okini3939 4:9a2415f2ab07 18 * @section DESCRIPTION
okini3939 4:9a2415f2ab07 19 *
okini3939 4:9a2415f2ab07 20 * GainSpan GS1011, Wi-Fi module
okini3939 4:9a2415f2ab07 21 *
okini3939 4:9a2415f2ab07 22 * http://www.gainspan.com/modules
okini3939 4:9a2415f2ab07 23 */
okini3939 4:9a2415f2ab07 24 /** @file
okini3939 4:9a2415f2ab07 25 * @brief Gainspan wi-fi module library for mbed
okini3939 4:9a2415f2ab07 26 * GS1011MIC, GS1011MIP, GainSpan WiFi Breakout, etc.
okini3939 4:9a2415f2ab07 27 */
okini3939 4:9a2415f2ab07 28
okini3939 4:9a2415f2ab07 29 #ifndef GSwifi_H
okini3939 4:9a2415f2ab07 30 #define GSwifi_H
okini3939 4:9a2415f2ab07 31
okini3939 4:9a2415f2ab07 32 #include "GSwifi_conf.h"
okini3939 4:9a2415f2ab07 33
okini3939 4:9a2415f2ab07 34 #include "mbed.h"
okini3939 4:9a2415f2ab07 35 #include "RawSerial.h"
okini3939 4:9a2415f2ab07 36 #include "CBuffer.h"
okini3939 4:9a2415f2ab07 37 #include <ctype.h>
okini3939 4:9a2415f2ab07 38 #include <stdlib.h>
okini3939 4:9a2415f2ab07 39 #include <string.h>
okini3939 4:9a2415f2ab07 40
okini3939 4:9a2415f2ab07 41 #ifdef CFG_ENABLE_RTOS
okini3939 4:9a2415f2ab07 42 #include "rtos.h"
okini3939 4:9a2415f2ab07 43 #endif
okini3939 4:9a2415f2ab07 44
okini3939 4:9a2415f2ab07 45 //Debug is disabled by default
okini3939 4:9a2415f2ab07 46 #if defined(DEBUG) and (!defined(TARGET_LPC11U24))
okini3939 4:9a2415f2ab07 47 #define DBG(x, ...) std::printf("[DBG]" x "\r\n", ##__VA_ARGS__);
okini3939 4:9a2415f2ab07 48 #define WARN(x, ...) std::printf("[WARN]" x "\r\n", ##__VA_ARGS__);
okini3939 4:9a2415f2ab07 49 #define ERR(x, ...) std::printf("[ERR]" x "\r\n", ##__VA_ARGS__);
okini3939 4:9a2415f2ab07 50 #define INFO(x, ...) std::printf("[INFO]" x "\r\n", ##__VA_ARGS__);
okini3939 4:9a2415f2ab07 51 #else
okini3939 4:9a2415f2ab07 52 #define DBG(x, ...)
okini3939 4:9a2415f2ab07 53 #define WARN(x, ...)
okini3939 4:9a2415f2ab07 54 #define ERR(x, ...)
okini3939 4:9a2415f2ab07 55 #define INFO(x, ...)
okini3939 4:9a2415f2ab07 56 #endif
okini3939 4:9a2415f2ab07 57
okini3939 4:9a2415f2ab07 58
okini3939 4:9a2415f2ab07 59 /** GSwifi class
okini3939 4:9a2415f2ab07 60 */
okini3939 4:9a2415f2ab07 61 class GSwifi
okini3939 4:9a2415f2ab07 62 {
okini3939 4:9a2415f2ab07 63
okini3939 4:9a2415f2ab07 64 public:
okini3939 4:9a2415f2ab07 65
okini3939 4:9a2415f2ab07 66 /** Wi-Fi mode
okini3939 4:9a2415f2ab07 67 */
okini3939 4:9a2415f2ab07 68 enum WiFiMode {
okini3939 4:9a2415f2ab07 69 WM_INFRASTRUCTURE,
okini3939 4:9a2415f2ab07 70 WM_ADHOCK,
okini3939 4:9a2415f2ab07 71 WM_LIMITEDAP,
okini3939 4:9a2415f2ab07 72 };
okini3939 4:9a2415f2ab07 73
okini3939 4:9a2415f2ab07 74 /** Wi-Fi security
okini3939 4:9a2415f2ab07 75 */
okini3939 4:9a2415f2ab07 76 enum Security {
okini3939 4:9a2415f2ab07 77 SEC_AUTO = 0,
okini3939 4:9a2415f2ab07 78 SEC_NONE = 0,
okini3939 4:9a2415f2ab07 79 SEC_OPEN = 1,
okini3939 4:9a2415f2ab07 80 SEC_WEP = 2,
okini3939 4:9a2415f2ab07 81 SEC_WPA_PSK = 4,
okini3939 4:9a2415f2ab07 82 SEC_WPA2_PSK = 8,
okini3939 4:9a2415f2ab07 83 SEC_WPA_ENT = 16,
okini3939 4:9a2415f2ab07 84 SEC_WPA2_ENT = 32,
okini3939 4:9a2415f2ab07 85 SEC_WPS_BUTTON = 64,
okini3939 4:9a2415f2ab07 86 SEC_WPS_PIN,
okini3939 4:9a2415f2ab07 87 };
okini3939 4:9a2415f2ab07 88
okini3939 4:9a2415f2ab07 89 /** TCP/IP protocol
okini3939 4:9a2415f2ab07 90 */
okini3939 4:9a2415f2ab07 91 enum Protocol {
okini3939 4:9a2415f2ab07 92 PROTO_UDP = 0,
okini3939 4:9a2415f2ab07 93 PROTO_TCP = 1,
okini3939 4:9a2415f2ab07 94 PROTO_HTTPGET,
okini3939 4:9a2415f2ab07 95 PROTO_HTTPPOST,
okini3939 4:9a2415f2ab07 96 PROTO_HTTPD,
okini3939 4:9a2415f2ab07 97 };
okini3939 4:9a2415f2ab07 98
okini3939 4:9a2415f2ab07 99 /** Client/Server
okini3939 4:9a2415f2ab07 100 */
okini3939 4:9a2415f2ab07 101 enum Type {
okini3939 4:9a2415f2ab07 102 TYPE_CLIENT = 0,
okini3939 4:9a2415f2ab07 103 TYPE_SERVER = 1,
okini3939 4:9a2415f2ab07 104 };
okini3939 4:9a2415f2ab07 105
okini3939 4:9a2415f2ab07 106 enum Response {
okini3939 4:9a2415f2ab07 107 RES_NULL,
okini3939 4:9a2415f2ab07 108 RES_CONNECT,
okini3939 4:9a2415f2ab07 109 RES_WPAPSK,
okini3939 4:9a2415f2ab07 110 RES_WPS,
okini3939 4:9a2415f2ab07 111 RES_MACADDRESS,
okini3939 4:9a2415f2ab07 112 RES_DHCP,
okini3939 4:9a2415f2ab07 113 RES_DNSLOOKUP,
okini3939 4:9a2415f2ab07 114 RES_HTTP,
okini3939 4:9a2415f2ab07 115 RES_RSSI,
okini3939 4:9a2415f2ab07 116 RES_TIME,
okini3939 4:9a2415f2ab07 117 RES_STATUS,
okini3939 4:9a2415f2ab07 118 };
okini3939 4:9a2415f2ab07 119
okini3939 4:9a2415f2ab07 120 enum Mode {
okini3939 4:9a2415f2ab07 121 MODE_COMMAND,
okini3939 4:9a2415f2ab07 122 MODE_CMDRESP,
okini3939 4:9a2415f2ab07 123 MODE_ESCAPE,
okini3939 4:9a2415f2ab07 124 MODE_DATA_RX,
okini3939 4:9a2415f2ab07 125 MODE_DATA_RX_BULK,
okini3939 4:9a2415f2ab07 126 MODE_DATA_RXUDP,
okini3939 4:9a2415f2ab07 127 MODE_DATA_RXUDP_BULK,
okini3939 4:9a2415f2ab07 128 MODE_DATA_RXHTTP,
okini3939 4:9a2415f2ab07 129 MODE_DATA_RAW,
okini3939 4:9a2415f2ab07 130 };
okini3939 4:9a2415f2ab07 131
okini3939 4:9a2415f2ab07 132 enum Status {
okini3939 4:9a2415f2ab07 133 STAT_NONE,
okini3939 4:9a2415f2ab07 134 STAT_READY,
okini3939 4:9a2415f2ab07 135 STAT_STANDBY,
okini3939 4:9a2415f2ab07 136 STAT_WAKEUP,
okini3939 4:9a2415f2ab07 137 STAT_DEEPSLEEP,
okini3939 4:9a2415f2ab07 138 };
okini3939 4:9a2415f2ab07 139
okini3939 4:9a2415f2ab07 140 // ----- GSwifi.cpp -----
okini3939 4:9a2415f2ab07 141 /** Constructor
okini3939 4:9a2415f2ab07 142 * \param tx mbed pin to use for tx line of Serial interface
okini3939 4:9a2415f2ab07 143 * \param rx mbed pin to use for rx line of Serial interface
okini3939 4:9a2415f2ab07 144 * \param cts mbed pin to use for cts line of Serial interface
okini3939 4:9a2415f2ab07 145 * \param rts mbed pin to use for rts line of Serial interface
okini3939 4:9a2415f2ab07 146 * \param reset reset pin of the wifi module
okini3939 4:9a2415f2ab07 147 * \param alarm alarm pin of the wifi module (default NULL)
okini3939 4:9a2415f2ab07 148 * \param baud baud rate of Serial interface (default 9600)
okini3939 4:9a2415f2ab07 149 */
okini3939 4:9a2415f2ab07 150 GSwifi (PinName tx, PinName rx, PinName cts, PinName rts, PinName reset, PinName alarm = NC, int baud = 9600);
okini3939 4:9a2415f2ab07 151
okini3939 4:9a2415f2ab07 152 /** Connect the wifi module to the ssid contained in the constructor.
okini3939 4:9a2415f2ab07 153 * @param sec Security type (NONE, WEP_128 or WPA)
okini3939 4:9a2415f2ab07 154 * @param ssid ssid of the network
okini3939 4:9a2415f2ab07 155 * @param phrase WEP or WPA key
okini3939 4:9a2415f2ab07 156 * @return 0 if connected, -1 otherwise
okini3939 4:9a2415f2ab07 157 */
okini3939 4:9a2415f2ab07 158 int join ();
okini3939 4:9a2415f2ab07 159
okini3939 4:9a2415f2ab07 160 /** Connect the wifi module to the adhock in the constructor.
okini3939 4:9a2415f2ab07 161 * @param sec Security type (NONE, WEP_128 or WPA)
okini3939 4:9a2415f2ab07 162 * @param ssid ssid of the network
okini3939 4:9a2415f2ab07 163 * @param phrase WEP or WPA key
okini3939 4:9a2415f2ab07 164 * @return 0 if connected, -1 otherwise
okini3939 4:9a2415f2ab07 165 */
okini3939 4:9a2415f2ab07 166 int adhock ();
okini3939 4:9a2415f2ab07 167
okini3939 4:9a2415f2ab07 168 /** Connect the wifi module to the limited AP in the constructor.
okini3939 4:9a2415f2ab07 169 * @param sec Security type (NONE, WEP_128 or WPA)
okini3939 4:9a2415f2ab07 170 * @param ssid ssid of the network
okini3939 4:9a2415f2ab07 171 * @param phrase WEP or WPA key
okini3939 4:9a2415f2ab07 172 * @return 0 if connected, -1 otherwise
okini3939 4:9a2415f2ab07 173 */
okini3939 4:9a2415f2ab07 174 int limitedap ();
okini3939 4:9a2415f2ab07 175
okini3939 4:9a2415f2ab07 176 /** Disconnect the wifi module from the access point
okini3939 4:9a2415f2ab07 177 * @returns 0 if successful
okini3939 4:9a2415f2ab07 178 */
okini3939 4:9a2415f2ab07 179 int dissociate ();
okini3939 4:9a2415f2ab07 180 int disconnect () {
okini3939 4:9a2415f2ab07 181 return dissociate();
okini3939 4:9a2415f2ab07 182 }
okini3939 4:9a2415f2ab07 183
okini3939 4:9a2415f2ab07 184 /** Check if a Wi-Fi link is active
okini3939 4:9a2415f2ab07 185 * @returns true if successful
okini3939 4:9a2415f2ab07 186 */
okini3939 4:9a2415f2ab07 187 bool isAssociated();
okini3939 4:9a2415f2ab07 188
okini3939 4:9a2415f2ab07 189 /** polling if not use rtos
okini3939 4:9a2415f2ab07 190 */
okini3939 4:9a2415f2ab07 191 void poll ();
okini3939 4:9a2415f2ab07 192
okini3939 4:9a2415f2ab07 193 /** get Wi-Fi modue status
okini3939 4:9a2415f2ab07 194 * @return Status
okini3939 4:9a2415f2ab07 195 */
okini3939 4:9a2415f2ab07 196 Status getStatus ();
okini3939 4:9a2415f2ab07 197
okini3939 4:9a2415f2ab07 198 /** set MAC address
okini3939 4:9a2415f2ab07 199 */
okini3939 4:9a2415f2ab07 200 int setMacAddress (const char *mac);
okini3939 4:9a2415f2ab07 201 /** get MAC address
okini3939 4:9a2415f2ab07 202 */
okini3939 4:9a2415f2ab07 203 int getMacAddress (char *mac);
okini3939 4:9a2415f2ab07 204
okini3939 4:9a2415f2ab07 205 /** use DHCP
okini3939 4:9a2415f2ab07 206 */
okini3939 4:9a2415f2ab07 207 int setAddress (const char *name = NULL);
okini3939 4:9a2415f2ab07 208 /** use static IP address
okini3939 4:9a2415f2ab07 209 * @param ip my ip address (dhcp start address)
okini3939 4:9a2415f2ab07 210 * @param netmask subnet mask
okini3939 4:9a2415f2ab07 211 * @param gateway default gateway
okini3939 4:9a2415f2ab07 212 * @param dns my host name (default NULL)
okini3939 4:9a2415f2ab07 213 */
okini3939 4:9a2415f2ab07 214 int setAddress (const char *ip, const char *netmask, const char *gateway, const char *name = NULL);
okini3939 4:9a2415f2ab07 215 /** get IP address
okini3939 4:9a2415f2ab07 216 */
okini3939 4:9a2415f2ab07 217 int getAddress (char *ip, char *netmask, char *gateway);
okini3939 4:9a2415f2ab07 218
okini3939 4:9a2415f2ab07 219 /** set Wi-Fi security parameter
okini3939 4:9a2415f2ab07 220 * @param sec Security
okini3939 4:9a2415f2ab07 221 * @param ssid SSID
okini3939 4:9a2415f2ab07 222 * @param pass pass phrase
okini3939 4:9a2415f2ab07 223 */
okini3939 4:9a2415f2ab07 224 int setSsid (Security sec, const char *ssid, const char *phrase);
okini3939 4:9a2415f2ab07 225
okini3939 4:9a2415f2ab07 226 static GSwifi * getInstance() {
okini3939 4:9a2415f2ab07 227 return _inst;
okini3939 4:9a2415f2ab07 228 };
okini3939 4:9a2415f2ab07 229
okini3939 4:9a2415f2ab07 230 // ----- GSwifi_util.cpp -----
okini3939 4:9a2415f2ab07 231 int setRegion (int reg);
okini3939 4:9a2415f2ab07 232
okini3939 4:9a2415f2ab07 233 /** get RSSI
okini3939 4:9a2415f2ab07 234 * @return RSSI (dBm)
okini3939 4:9a2415f2ab07 235 */
okini3939 4:9a2415f2ab07 236 int getRssi ();
okini3939 4:9a2415f2ab07 237
okini3939 4:9a2415f2ab07 238 /** power save mode
okini3939 4:9a2415f2ab07 239 * @param active rx radio 0:switched off, 1:always on
okini3939 4:9a2415f2ab07 240 * @param save power save 0:disable, 1:enable
okini3939 4:9a2415f2ab07 241 */
okini3939 4:9a2415f2ab07 242 int powerSave (int active, int save);
okini3939 4:9a2415f2ab07 243
okini3939 4:9a2415f2ab07 244 /** RF power
okini3939 4:9a2415f2ab07 245 * @param power 0(high)-7(low)
okini3939 4:9a2415f2ab07 246 */
okini3939 4:9a2415f2ab07 247 int setRfPower (int power);
okini3939 4:9a2415f2ab07 248
okini3939 4:9a2415f2ab07 249 /** set system time
okini3939 4:9a2415f2ab07 250 * @param time date time (UTC)
okini3939 4:9a2415f2ab07 251 */
okini3939 4:9a2415f2ab07 252 int setTime (time_t time);
okini3939 4:9a2415f2ab07 253
okini3939 4:9a2415f2ab07 254 /** get system time
okini3939 4:9a2415f2ab07 255 * @return date time (UTC)
okini3939 4:9a2415f2ab07 256 */
okini3939 4:9a2415f2ab07 257 time_t getTime ();
okini3939 4:9a2415f2ab07 258
okini3939 4:9a2415f2ab07 259 /** set NTP server
okini3939 4:9a2415f2ab07 260 * @param host SNTP server
okini3939 4:9a2415f2ab07 261 * @param sec time sync interval, 0:one time
okini3939 4:9a2415f2ab07 262 */
okini3939 4:9a2415f2ab07 263 int ntpdate (char *host, int sec = 0);
okini3939 4:9a2415f2ab07 264
okini3939 4:9a2415f2ab07 265 /** GPIO output
okini3939 4:9a2415f2ab07 266 * @param port 10,11,30,31
okini3939 4:9a2415f2ab07 267 * @param out 0:set(high), 1:reset(low)
okini3939 4:9a2415f2ab07 268 */
okini3939 4:9a2415f2ab07 269 int setGpio (int port, int out);
okini3939 4:9a2415f2ab07 270
okini3939 4:9a2415f2ab07 271 /** Web server
okini3939 4:9a2415f2ab07 272 */
okini3939 4:9a2415f2ab07 273 int provisioning (char *user, char *pass);
okini3939 4:9a2415f2ab07 274
okini3939 4:9a2415f2ab07 275 /** standby mode
okini3939 4:9a2415f2ab07 276 * @param msec wakeup after
okini3939 4:9a2415f2ab07 277 * wakeup after msec or alarm1/2
okini3939 4:9a2415f2ab07 278 * core off, save to RTC ram
okini3939 4:9a2415f2ab07 279 */
okini3939 4:9a2415f2ab07 280 int standby (int msec);
okini3939 4:9a2415f2ab07 281
okini3939 4:9a2415f2ab07 282 /** deep sleep mode
okini3939 4:9a2415f2ab07 283 */
okini3939 4:9a2415f2ab07 284 int deepSleep ();
okini3939 4:9a2415f2ab07 285
okini3939 4:9a2415f2ab07 286 /** restore standby or deep sleep
okini3939 4:9a2415f2ab07 287 */
okini3939 4:9a2415f2ab07 288 int wakeup ();
okini3939 4:9a2415f2ab07 289
okini3939 4:9a2415f2ab07 290 // ----- GSwifi_sock.cpp -----
okini3939 4:9a2415f2ab07 291 /** Resolv hostname
okini3939 4:9a2415f2ab07 292 * @param name hostname
okini3939 4:9a2415f2ab07 293 * @param ip resolved ip address
okini3939 4:9a2415f2ab07 294 */
okini3939 4:9a2415f2ab07 295 int getHostByName(const char * host, char * ip);
okini3939 4:9a2415f2ab07 296
okini3939 4:9a2415f2ab07 297 /** TCP/UDP client
okini3939 4:9a2415f2ab07 298 * @return CID, -1:failure
okini3939 4:9a2415f2ab07 299 */
okini3939 4:9a2415f2ab07 300 int open (Protocol proto, const char *ip, int port, int src = 0, void(*func)(int) = NULL);
okini3939 4:9a2415f2ab07 301
okini3939 4:9a2415f2ab07 302 /** TCP/UDP server
okini3939 4:9a2415f2ab07 303 * @return CID, -1:failure
okini3939 4:9a2415f2ab07 304 */
okini3939 4:9a2415f2ab07 305 int listen (Protocol proto, int port, void(*func)(int) = NULL);
okini3939 4:9a2415f2ab07 306
okini3939 4:9a2415f2ab07 307 /** close client/server
okini3939 4:9a2415f2ab07 308 */
okini3939 4:9a2415f2ab07 309 int close (int cid);
okini3939 4:9a2415f2ab07 310
okini3939 4:9a2415f2ab07 311 /** send data tcp(s/c), udp(c)
okini3939 4:9a2415f2ab07 312 */
okini3939 4:9a2415f2ab07 313 int send (int cid, const char *buf, int len);
okini3939 4:9a2415f2ab07 314
okini3939 4:9a2415f2ab07 315 /** send data udp(s)
okini3939 4:9a2415f2ab07 316 */
okini3939 4:9a2415f2ab07 317 int sendto (int cid, const char *buf, int len, const char *ip, int port);
okini3939 4:9a2415f2ab07 318
okini3939 4:9a2415f2ab07 319 /** recv data tcp(s/c), udp(c)
okini3939 4:9a2415f2ab07 320 * @return length
okini3939 4:9a2415f2ab07 321 */
okini3939 4:9a2415f2ab07 322 int recv (int cid, char *buf, int len);
okini3939 4:9a2415f2ab07 323
okini3939 4:9a2415f2ab07 324 /** recv data udp(s)
okini3939 4:9a2415f2ab07 325 * @return length
okini3939 4:9a2415f2ab07 326 */
okini3939 4:9a2415f2ab07 327 int recvfrom (int cid, char *buf, int len, char *ip, int *port);
okini3939 4:9a2415f2ab07 328
okini3939 4:9a2415f2ab07 329 /** readable recv data
okini3939 4:9a2415f2ab07 330 */
okini3939 4:9a2415f2ab07 331 int readable (int cid);
okini3939 4:9a2415f2ab07 332
okini3939 4:9a2415f2ab07 333 /** tcp/udp connected
okini3939 4:9a2415f2ab07 334 */
okini3939 4:9a2415f2ab07 335 bool isConnected (int cid);
okini3939 4:9a2415f2ab07 336
okini3939 4:9a2415f2ab07 337 int accept (int cid);
okini3939 4:9a2415f2ab07 338 int getRemote(int cid, char **ip, int *port);
okini3939 4:9a2415f2ab07 339
okini3939 4:9a2415f2ab07 340 // ----- GSwifi_http.cpp -----
okini3939 4:9a2415f2ab07 341 /** http request (GET method)
okini3939 4:9a2415f2ab07 342 */
okini3939 4:9a2415f2ab07 343 int httpGet (const char *host, int port, const char *uri, bool ssl = false, const char *user = NULL, const char *pwd = NULL, void(*func)(int) = NULL);
okini3939 4:9a2415f2ab07 344 int httpGet (const char *host, int port, const char *uri, void(*func)(int) = NULL) {
okini3939 4:9a2415f2ab07 345 return httpGet(host, port, uri, false, NULL, NULL, func);
okini3939 4:9a2415f2ab07 346 }
okini3939 4:9a2415f2ab07 347 /** http request (POST method)
okini3939 4:9a2415f2ab07 348 */
okini3939 4:9a2415f2ab07 349 int httpPost (const char *host, int port, const char *uri, const char *body, bool ssl = false, const char *user = NULL, const char *pwd = NULL, void(*func)(int) = NULL);
okini3939 4:9a2415f2ab07 350 int httpPost (const char *host, int port, const char *uri, const char *body, void(*func)(int) = NULL) {
okini3939 4:9a2415f2ab07 351 return httpPost(host, port, uri, body, false, NULL, NULL, func);
okini3939 4:9a2415f2ab07 352 }
okini3939 4:9a2415f2ab07 353
okini3939 4:9a2415f2ab07 354 int base64encode (const char *input, int length, char *output, int len);
okini3939 4:9a2415f2ab07 355 int urlencode (const char *str, char *buf, int len);
okini3939 4:9a2415f2ab07 356 int urldecode (const char *str, char *buf, int len);
okini3939 4:9a2415f2ab07 357
okini3939 4:9a2415f2ab07 358 #ifdef CFG_ENABLE_HTTPD
okini3939 4:9a2415f2ab07 359 // ----- GSwifi_httpd.cpp -----
okini3939 4:9a2415f2ab07 360 /** start http server
okini3939 4:9a2415f2ab07 361 * @param port
okini3939 4:9a2415f2ab07 362 */
okini3939 4:9a2415f2ab07 363 int httpd (int port = 80);
okini3939 4:9a2415f2ab07 364
okini3939 4:9a2415f2ab07 365 // ----- GSwifi_httpd_util.cpp -----
okini3939 4:9a2415f2ab07 366 /** attach uri to dirctory handler
okini3939 4:9a2415f2ab07 367 */
okini3939 4:9a2415f2ab07 368 void httpdError (int cid, int err);
okini3939 4:9a2415f2ab07 369 /** attach uri to dirctory handler
okini3939 4:9a2415f2ab07 370 */
okini3939 4:9a2415f2ab07 371 int httpdAttach (const char *uri, const char *dir);
okini3939 4:9a2415f2ab07 372 /** attach uri to cgi handler
okini3939 4:9a2415f2ab07 373 */
okini3939 4:9a2415f2ab07 374 int httpdAttach (const char *uri, void (*funcCgi)(int));
okini3939 4:9a2415f2ab07 375 #endif
okini3939 4:9a2415f2ab07 376
okini3939 4:9a2415f2ab07 377 #ifdef CFG_ENABLE_WEBSOCKET
okini3939 4:9a2415f2ab07 378 // ----- GSwifi_httpd_ws.cpp -----
okini3939 4:9a2415f2ab07 379 /** websocket request (Upgrade method)
okini3939 4:9a2415f2ab07 380 * @return CID, -1:failure
okini3939 4:9a2415f2ab07 381 */
okini3939 4:9a2415f2ab07 382 int wsOpen (const char *host, int port, const char *uri, const char *user = NULL, const char *pwd = NULL);
okini3939 4:9a2415f2ab07 383 /** send websocket data
okini3939 4:9a2415f2ab07 384 */
okini3939 4:9a2415f2ab07 385 int wsSend (int cid, const char *buf, int len, const char *mask = NULL);
okini3939 4:9a2415f2ab07 386 #endif
okini3939 4:9a2415f2ab07 387
okini3939 4:9a2415f2ab07 388 #ifdef CFG_ENABLE_SMTP
okini3939 4:9a2415f2ab07 389 // ----- GSwifi_smtp.cpp -----
okini3939 4:9a2415f2ab07 390 /** send mail (smtp)
okini3939 4:9a2415f2ab07 391 * @param host SMTP server
okini3939 4:9a2415f2ab07 392 * @param port SMTP port (25 or 587 or etc.)
okini3939 4:9a2415f2ab07 393 * @param to To address
okini3939 4:9a2415f2ab07 394 * @param from From address
okini3939 4:9a2415f2ab07 395 * @param subject Subject
okini3939 4:9a2415f2ab07 396 * @param mesg Message
okini3939 4:9a2415f2ab07 397 * @param user username (SMTP Auth)
okini3939 4:9a2415f2ab07 398 * @param pwd password (SMTP Auth)
okini3939 4:9a2415f2ab07 399 * @retval 0 success
okini3939 4:9a2415f2ab07 400 * @retval -1 failure
okini3939 4:9a2415f2ab07 401 */
okini3939 4:9a2415f2ab07 402 int mail (const char *host, int port, const char *to, const char *from, const char *subject, const char *mesg, const char *user = NULL, const char *pwd = NULL);
okini3939 4:9a2415f2ab07 403 #endif
okini3939 4:9a2415f2ab07 404
okini3939 4:9a2415f2ab07 405 // ----- GSwifi_msg.cpp -----
okini3939 4:9a2415f2ab07 406
okini3939 4:9a2415f2ab07 407 // ----- GSwifi_at.cpp -----
okini3939 4:9a2415f2ab07 408 /** Send a command to the wifi module. Check if the module is in command mode. If not enter in command mode
okini3939 4:9a2415f2ab07 409 * @param cmd string to be sent
okini3939 4:9a2415f2ab07 410 * @param res need response
okini3939 4:9a2415f2ab07 411 * @param timeout
okini3939 4:9a2415f2ab07 412 * @returns 0 if successful
okini3939 4:9a2415f2ab07 413 */
okini3939 4:9a2415f2ab07 414 int sendCommand(const char * cmd, Response res = RES_NULL, int timeout = DEFAULT_WAIT_RESP_TIMEOUT);
okini3939 4:9a2415f2ab07 415
okini3939 4:9a2415f2ab07 416 /** Send a command to the wifi module. Check if the module is in command mode. If not enter in command mode
okini3939 4:9a2415f2ab07 417 * @param data string to be sent
okini3939 4:9a2415f2ab07 418 * @param res need response
okini3939 4:9a2415f2ab07 419 * @param timeout
okini3939 4:9a2415f2ab07 420 * @param cmd
okini3939 4:9a2415f2ab07 421 * @returns 0 if successful
okini3939 4:9a2415f2ab07 422 */
okini3939 4:9a2415f2ab07 423 int sendData(const char * data, int len, int timeout = CFG_TIMEOUT, const char * cmd = NULL);
okini3939 4:9a2415f2ab07 424
okini3939 4:9a2415f2ab07 425
okini3939 4:9a2415f2ab07 426 protected:
okini3939 4:9a2415f2ab07 427
okini3939 4:9a2415f2ab07 428 static GSwifi * _inst;
okini3939 4:9a2415f2ab07 429 #ifdef CFG_ENABLE_RTOS
okini3939 4:9a2415f2ab07 430 Thread *_threadPoll;
okini3939 4:9a2415f2ab07 431 Mutex _mutexUart;
okini3939 4:9a2415f2ab07 432 #endif
okini3939 4:9a2415f2ab07 433
okini3939 4:9a2415f2ab07 434 // Serial _gs;
okini3939 4:9a2415f2ab07 435 RawSerial _gs;
okini3939 4:9a2415f2ab07 436 int _baud;
okini3939 4:9a2415f2ab07 437 DigitalIn *_cts;
okini3939 4:9a2415f2ab07 438 DigitalOut *_rts;
okini3939 4:9a2415f2ab07 439 int _flow;
okini3939 4:9a2415f2ab07 440 #if defined(TARGET_LPC1768) || defined(TARGET_LPC2368) || defined(TARGET_LPC4088)
okini3939 4:9a2415f2ab07 441 LPC_UART1_TypeDef *_uart;
okini3939 4:9a2415f2ab07 442 #elif defined(TARGET_LPC11U24)
okini3939 4:9a2415f2ab07 443 LPC_USART_Type *_uart;
okini3939 4:9a2415f2ab07 444 #elif defined(TARGET_LPC11XX)
okini3939 4:9a2415f2ab07 445 LPC_UART_TypeDef *_uart;
okini3939 4:9a2415f2ab07 446 #endif
okini3939 4:9a2415f2ab07 447 DigitalInOut _reset;
okini3939 4:9a2415f2ab07 448 DigitalInOut *_alarm;
okini3939 4:9a2415f2ab07 449
okini3939 4:9a2415f2ab07 450 struct STATE {
okini3939 4:9a2415f2ab07 451 WiFiMode wm;
okini3939 4:9a2415f2ab07 452 Security sec;
okini3939 4:9a2415f2ab07 453 char ssid[35];
okini3939 4:9a2415f2ab07 454 char pass[66];
okini3939 4:9a2415f2ab07 455 char ip[16];
okini3939 4:9a2415f2ab07 456 char netmask[16];
okini3939 4:9a2415f2ab07 457 char gateway[16];
okini3939 4:9a2415f2ab07 458 char nameserver[16];
okini3939 4:9a2415f2ab07 459 char mac[18];
okini3939 4:9a2415f2ab07 460 char resolv[16];
okini3939 4:9a2415f2ab07 461 char name[32];
okini3939 4:9a2415f2ab07 462 int rssi;
okini3939 4:9a2415f2ab07 463 bool dhcp;
okini3939 4:9a2415f2ab07 464 time_t time;
okini3939 4:9a2415f2ab07 465
okini3939 4:9a2415f2ab07 466 bool initialized;
okini3939 4:9a2415f2ab07 467 bool associated;
okini3939 4:9a2415f2ab07 468 volatile Mode mode;
okini3939 4:9a2415f2ab07 469 volatile Status status;
okini3939 4:9a2415f2ab07 470 bool escape;
okini3939 4:9a2415f2ab07 471 volatile bool ok, failure;
okini3939 4:9a2415f2ab07 472 volatile Response res;
okini3939 4:9a2415f2ab07 473 int cid;
okini3939 4:9a2415f2ab07 474 int n;
okini3939 4:9a2415f2ab07 475 CircBuffer<char> *buf;
okini3939 4:9a2415f2ab07 476 } _state;
okini3939 4:9a2415f2ab07 477
okini3939 4:9a2415f2ab07 478 struct CONNECTION {
okini3939 4:9a2415f2ab07 479 Protocol protocol;
okini3939 4:9a2415f2ab07 480 Type type;
okini3939 4:9a2415f2ab07 481 bool connected;
okini3939 4:9a2415f2ab07 482 char ip[16];
okini3939 4:9a2415f2ab07 483 int port;
okini3939 4:9a2415f2ab07 484 CircBuffer<char> *buf;
okini3939 4:9a2415f2ab07 485 volatile bool received;
okini3939 4:9a2415f2ab07 486 volatile int parent;
okini3939 4:9a2415f2ab07 487 volatile bool accept;
okini3939 4:9a2415f2ab07 488 void(*func)(int);
okini3939 4:9a2415f2ab07 489 } _con[16];
okini3939 4:9a2415f2ab07 490
okini3939 4:9a2415f2ab07 491 #ifdef CFG_ENABLE_HTTPD
okini3939 4:9a2415f2ab07 492 enum HttpdMode {
okini3939 4:9a2415f2ab07 493 HTTPDMODE_REQUEST,
okini3939 4:9a2415f2ab07 494 HTTPDMODE_REQUEST_STR,
okini3939 4:9a2415f2ab07 495 HTTPDMODE_HEADER,
okini3939 4:9a2415f2ab07 496 HTTPDMODE_BODY,
okini3939 4:9a2415f2ab07 497 HTTPDMODE_ENTER,
okini3939 4:9a2415f2ab07 498 HTTPDMODE_ERROR,
okini3939 4:9a2415f2ab07 499 HTTPDMODE_WEBSOCKET,
okini3939 4:9a2415f2ab07 500 HTTPDMODE_WEBSOCKET_MASK,
okini3939 4:9a2415f2ab07 501 HTTPDMODE_WEBSOCKET_BODY,
okini3939 4:9a2415f2ab07 502 HTTPDMODE_WEBSOCKET_ENTER,
okini3939 4:9a2415f2ab07 503 };
okini3939 4:9a2415f2ab07 504
okini3939 4:9a2415f2ab07 505 enum HttpdReq {
okini3939 4:9a2415f2ab07 506 REQ_HTTPGET,
okini3939 4:9a2415f2ab07 507 REQ_HTTPPOST,
okini3939 4:9a2415f2ab07 508 };
okini3939 4:9a2415f2ab07 509
okini3939 4:9a2415f2ab07 510 struct HTTPD {
okini3939 4:9a2415f2ab07 511 HttpdMode mode;
okini3939 4:9a2415f2ab07 512 HttpdReq req;
okini3939 4:9a2415f2ab07 513 CircBuffer <char>*buf;
okini3939 4:9a2415f2ab07 514 char *uri;
okini3939 4:9a2415f2ab07 515 char *filename;
okini3939 4:9a2415f2ab07 516 char *querystring;
okini3939 4:9a2415f2ab07 517 int enter;
okini3939 4:9a2415f2ab07 518 int length;
okini3939 4:9a2415f2ab07 519 int n;
okini3939 4:9a2415f2ab07 520 int keepalive;
okini3939 4:9a2415f2ab07 521 #ifdef CFG_ENABLE_WEBSOCKET
okini3939 4:9a2415f2ab07 522 int websocket;
okini3939 4:9a2415f2ab07 523 char *websocket_key;
okini3939 4:9a2415f2ab07 524 int websocket_opcode;
okini3939 4:9a2415f2ab07 525 int websocket_flg;
okini3939 4:9a2415f2ab07 526 char websocket_mask[4];
okini3939 4:9a2415f2ab07 527 int websocket_payload;
okini3939 4:9a2415f2ab07 528 #endif
okini3939 4:9a2415f2ab07 529 } _httpd[16];
okini3939 4:9a2415f2ab07 530
okini3939 4:9a2415f2ab07 531 struct HTTPD_HANDLER {
okini3939 4:9a2415f2ab07 532 char *uri;
okini3939 4:9a2415f2ab07 533 char *dir;
okini3939 4:9a2415f2ab07 534 void (*func)(int);
okini3939 4:9a2415f2ab07 535 } _httpd_handler[CFG_HTTPD_HANDLER_NUM];
okini3939 4:9a2415f2ab07 536
okini3939 4:9a2415f2ab07 537 int _httpd_cid;
okini3939 4:9a2415f2ab07 538 int _handler_count;
okini3939 4:9a2415f2ab07 539 #endif // CFG_ENABLE_HTTPD
okini3939 4:9a2415f2ab07 540
okini3939 4:9a2415f2ab07 541
okini3939 4:9a2415f2ab07 542 // ----- GSwifi.cpp -----
okini3939 4:9a2415f2ab07 543 #ifdef CFG_ENABLE_RTOS
okini3939 4:9a2415f2ab07 544 static void threadPoll (void const *args);
okini3939 4:9a2415f2ab07 545 #endif
okini3939 4:9a2415f2ab07 546
okini3939 4:9a2415f2ab07 547 // ----- GSwifi_sock.cpp -----
okini3939 4:9a2415f2ab07 548 void initCon (int cid, bool connected);
okini3939 4:9a2415f2ab07 549
okini3939 4:9a2415f2ab07 550 // ----- GSwifi_util.cpp -----
okini3939 4:9a2415f2ab07 551 int x2i (char c);
okini3939 4:9a2415f2ab07 552 char i2x (int i);
okini3939 4:9a2415f2ab07 553 int from_hex (int ch);
okini3939 4:9a2415f2ab07 554 int to_hex (int code);
okini3939 4:9a2415f2ab07 555
okini3939 4:9a2415f2ab07 556 // ----- GSwifi_http.cpp -----
okini3939 4:9a2415f2ab07 557
okini3939 4:9a2415f2ab07 558 #ifdef CFG_ENABLE_HTTPD
okini3939 4:9a2415f2ab07 559 // ----- GSwifi_httpd.cpp -----
okini3939 4:9a2415f2ab07 560 void httpdRecvData (int cid, char c);
okini3939 4:9a2415f2ab07 561 int httpdParseRequest (int cid);
okini3939 4:9a2415f2ab07 562 void httpdPoll ();
okini3939 4:9a2415f2ab07 563 int httpdParseHeader (int cid);
okini3939 4:9a2415f2ab07 564 void reqContentLength (int cid, const char *buf);
okini3939 4:9a2415f2ab07 565 void reqConnection (int cid, const char *buf);
okini3939 4:9a2415f2ab07 566 void reqUpgrade (int cid, const char *buf);
okini3939 4:9a2415f2ab07 567 void reqWebSocketVersion (int cid, const char *buf);
okini3939 4:9a2415f2ab07 568 void reqWebSocketKey (int cid, const char *buf);
okini3939 4:9a2415f2ab07 569
okini3939 4:9a2415f2ab07 570 // ----- GSwifi_httpd_util.cpp -----
okini3939 4:9a2415f2ab07 571 int httpdFile (int cid, char *dir);
okini3939 4:9a2415f2ab07 572 int httpdGetHandler (const char *uri);
okini3939 4:9a2415f2ab07 573 char *mimetype (char *file);
okini3939 4:9a2415f2ab07 574 int strnicmp (const char *p1, const char *p2, int n);
okini3939 4:9a2415f2ab07 575 #endif
okini3939 4:9a2415f2ab07 576
okini3939 4:9a2415f2ab07 577 #ifdef CFG_ENABLE_WEBSOCKET
okini3939 4:9a2415f2ab07 578 // ----- GSwifi_httpd_ws.cpp -----
okini3939 4:9a2415f2ab07 579 int wsWait (int cid, int code);
okini3939 4:9a2415f2ab07 580 #ifdef CFG_ENABLE_HTTPD
okini3939 4:9a2415f2ab07 581 void wsRecvData (int cid, char c);
okini3939 4:9a2415f2ab07 582 int wsParseRequest (int cid);
okini3939 4:9a2415f2ab07 583 int wsAccept (int cid);
okini3939 4:9a2415f2ab07 584 #endif
okini3939 4:9a2415f2ab07 585 #endif
okini3939 4:9a2415f2ab07 586
okini3939 4:9a2415f2ab07 587 #ifdef CFG_ENABLE_SMTP
okini3939 4:9a2415f2ab07 588 // ----- GSwifi_smtp.cpp -----
okini3939 4:9a2415f2ab07 589 int smtpWait (int cid, int code);
okini3939 4:9a2415f2ab07 590 #endif
okini3939 4:9a2415f2ab07 591
okini3939 4:9a2415f2ab07 592 // ----- GSwifi_msg.cpp -----
okini3939 4:9a2415f2ab07 593 void recvData (char c);
okini3939 4:9a2415f2ab07 594 int parseMessage ();
okini3939 4:9a2415f2ab07 595 void msgOk (const char*);
okini3939 4:9a2415f2ab07 596 void msgError (const char*);
okini3939 4:9a2415f2ab07 597 void msgConnect (const char*);
okini3939 4:9a2415f2ab07 598 void msgDisconnect (const char*);
okini3939 4:9a2415f2ab07 599 void msgDisassociated (const char*);
okini3939 4:9a2415f2ab07 600 void msgReset (const char*);
okini3939 4:9a2415f2ab07 601 void msgOutofStandby (const char*);
okini3939 4:9a2415f2ab07 602 void msgOutofDeepsleep (const char*);
okini3939 4:9a2415f2ab07 603 void resNormal (const char*);
okini3939 4:9a2415f2ab07 604 void resConnect (const char*);
okini3939 4:9a2415f2ab07 605 void resWpapsk (const char *buf);
okini3939 4:9a2415f2ab07 606 void resWps (const char*);
okini3939 4:9a2415f2ab07 607 void resMacAddress (const char*);
okini3939 4:9a2415f2ab07 608 void resIp (const char*);
okini3939 4:9a2415f2ab07 609 void resLookup (const char*);
okini3939 4:9a2415f2ab07 610 void resRssi (const char*);
okini3939 4:9a2415f2ab07 611 void resTime (const char*);
okini3939 4:9a2415f2ab07 612 void resChannel (const char*);
okini3939 4:9a2415f2ab07 613 void resStatus (const char*);
okini3939 4:9a2415f2ab07 614 void resHttp (const char *buf);
okini3939 4:9a2415f2ab07 615
okini3939 4:9a2415f2ab07 616 // ----- GSwifi_at.cpp -----
okini3939 4:9a2415f2ab07 617 void clearFlags ();
okini3939 4:9a2415f2ab07 618 int cmdAT ();
okini3939 4:9a2415f2ab07 619 int cmdE (bool n);
okini3939 4:9a2415f2ab07 620 int cmdR (bool n);
okini3939 4:9a2415f2ab07 621 int cmdNMAC (const char *s = NULL);
okini3939 4:9a2415f2ab07 622 int cmdWREGDOMAIN (int n = CFG_WREGDOMAIN);
okini3939 4:9a2415f2ab07 623 int cmdWS ();
okini3939 4:9a2415f2ab07 624 int cmdWM (int n);
okini3939 4:9a2415f2ab07 625 int cmdWA (const char *s);
okini3939 4:9a2415f2ab07 626 int cmdWD ();
okini3939 4:9a2415f2ab07 627 int cmdWWPS (bool n, const char *p = NULL);
okini3939 4:9a2415f2ab07 628 int cmdNSTAT ();
okini3939 4:9a2415f2ab07 629 int cmdWSTATUS ();
okini3939 4:9a2415f2ab07 630 int cmdWRSSI ();
okini3939 4:9a2415f2ab07 631 int cmdWAUTH (int n);
okini3939 4:9a2415f2ab07 632 int cmdWWEP (int n, const char *s);
okini3939 4:9a2415f2ab07 633 int cmdWPAPSK (const char *s, const char *p);
okini3939 4:9a2415f2ab07 634 int cmdWRXACTIVE (bool n);
okini3939 4:9a2415f2ab07 635 int cmdWRXPS (bool n);
okini3939 4:9a2415f2ab07 636 int cmdWP (int n);
okini3939 4:9a2415f2ab07 637 int cmdNDHCP (bool n, const char *s = NULL, int m = CFG_TIMEOUT);
okini3939 4:9a2415f2ab07 638 int cmdDHCPSRVR (bool n);
okini3939 4:9a2415f2ab07 639 int cmdNSET (const char *s, const char *t, const char *u);
okini3939 4:9a2415f2ab07 640 int cmdDNS (bool n, const char *s);
okini3939 4:9a2415f2ab07 641 int cmdDNSLOOKUP (const char *s);
okini3939 4:9a2415f2ab07 642 int cmdDNSSET (const char *s);
okini3939 4:9a2415f2ab07 643 int cmdSTORENWCONN ();
okini3939 4:9a2415f2ab07 644 int cmdRESTORENWCONN ();
okini3939 4:9a2415f2ab07 645 int cmdBDATA (bool n);
okini3939 4:9a2415f2ab07 646 int cmdNCTCP (const char *s, int n);
okini3939 4:9a2415f2ab07 647 int cmdNCUDP (const char *s, int n, int m = 0);
okini3939 4:9a2415f2ab07 648 int cmdNSTCP (int n);
okini3939 4:9a2415f2ab07 649 int cmdNSUDP (int n);
okini3939 4:9a2415f2ab07 650 int cmdNCLOSE (int n);
okini3939 4:9a2415f2ab07 651 int cmdNCLOSEALL ();
okini3939 4:9a2415f2ab07 652 int cmdHTTPCONF (int n, const char *s);
okini3939 4:9a2415f2ab07 653 int cmdHTTPCONFDEL (int n);
okini3939 4:9a2415f2ab07 654 int cmdHTTPOPEN (const char *s, int n = 80, bool m = false);
okini3939 4:9a2415f2ab07 655 int cmdHTTPSEND (int n, bool m, const char *s, int t = 0);
okini3939 4:9a2415f2ab07 656 int cmdHTTPCLOSE (int n);
okini3939 4:9a2415f2ab07 657 int cmdPSDPSLEEP (int n = 0);
okini3939 4:9a2415f2ab07 658 int cmdPSSTBY (int n, int m = 0);
okini3939 4:9a2415f2ab07 659 int cmdWEBPROV (const char *s, const char *p);
okini3939 4:9a2415f2ab07 660 int cmdSETTIME (const char *s, const char *t);
okini3939 4:9a2415f2ab07 661 int cmdGETTIME ();
okini3939 4:9a2415f2ab07 662 int cmdNTIMESYNC (bool n, const char *s, int m = 0);
okini3939 4:9a2415f2ab07 663 int cmdDGPIO (int n, int m);
okini3939 4:9a2415f2ab07 664
okini3939 4:9a2415f2ab07 665 // ----- GSwifi_hal.cpp -----
okini3939 4:9a2415f2ab07 666 void setReset (bool flg);
okini3939 4:9a2415f2ab07 667 void setAlarm (bool flg);
okini3939 4:9a2415f2ab07 668 void isrUart ();
okini3939 4:9a2415f2ab07 669 int getUart ();
okini3939 4:9a2415f2ab07 670 void putUart (char c);
okini3939 4:9a2415f2ab07 671 void setRts (bool flg);
okini3939 4:9a2415f2ab07 672 int lockUart (int ms);
okini3939 4:9a2415f2ab07 673 void unlockUart ();
okini3939 4:9a2415f2ab07 674 void initUart (PinName cts, PinName rts, PinName alarm, int baud);
okini3939 4:9a2415f2ab07 675
okini3939 4:9a2415f2ab07 676 };
okini3939 4:9a2415f2ab07 677
okini3939 4:9a2415f2ab07 678 #endif