private fork
Fork of GSwifiInterface by
Diff: GSwifi/GSwifi_http.cpp
- Revision:
- 12:057089026a20
- Parent:
- 11:71d67fea5ace
--- a/GSwifi/GSwifi_http.cpp Fri Nov 15 04:20:14 2013 +0000 +++ b/GSwifi/GSwifi_http.cpp Fri Nov 22 14:03:07 2013 +0000 @@ -18,11 +18,11 @@ #include "GSwifi.h" -int GSwifi::httpGet (const char *host, int port, const char *uri, bool ssl, const char *user, const char *pwd) { +int GSwifi::httpGet (const char *host, int port, const char *uri, bool ssl, const char *user, const char *pwd, void(*func)(int)) { char ip[17]; int cid; - if (!isConnected() && _state.status == STAT_READY) return -1; + if (!isAssociated() || _state.status != STAT_READY) return -1; if (getHostByName(host, ip)) return -1; if (! port) { @@ -53,17 +53,18 @@ cid = _state.cid; _con[cid].protocol = PROTO_HTTPGET; _con[cid].type = TYPE_CLIENT; + _con[cid].func = func; cmdHTTPSEND(cid, false, uri); // GET return cid; } -int GSwifi::httpPost (const char *host, int port, const char *uri, const char *body, bool ssl, const char *user, const char *pwd) { +int GSwifi::httpPost (const char *host, int port, const char *uri, const char *body, bool ssl, const char *user, const char *pwd, void(*func)(int)) { char cmd[CFG_CMD_SIZE]; char ip[17]; int cid, len; - if (!isConnected() && _state.status == STAT_READY) return -1; + if (!isAssociated() || _state.status != STAT_READY) return -1; if (getHostByName(host, ip)) return -1; if (! port) { @@ -96,6 +97,7 @@ cid = _state.cid; _con[cid].protocol = PROTO_HTTPPOST; _con[cid].type = TYPE_CLIENT; + _con[cid].func = func; cmdHTTPSEND(cid, true, uri, len); // POST sprintf(cmd, "\x1bH%X", cid); @@ -104,7 +106,6 @@ } - /* base64encode code from * Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com) */