private fork
Fork of GSwifiInterface by
Diff: GSwifi/GSwifi_msg.cpp
- Revision:
- 12:057089026a20
- Parent:
- 11:71d67fea5ace
- Child:
- 13:189e04ac70bd
--- a/GSwifi/GSwifi_msg.cpp Fri Nov 15 04:20:14 2013 +0000 +++ b/GSwifi/GSwifi_msg.cpp Fri Nov 22 14:03:07 2013 +0000 @@ -162,6 +162,7 @@ if (_con[cid].buf->available() > CFG_DATA_SIZE - 16) { setRts(false); _con[cid].received = true; + WARN("buf full"); } } count ++; @@ -180,7 +181,7 @@ sub ++; len = 0; count = 0; - if (_state.mode == MODE_DATA_RX_BULK) { + if (_state.mode != MODE_DATA_RXUDP_BULK) { sub = 3; } break; @@ -215,11 +216,17 @@ break; default: // data +#ifdef CFG_ENABLE_HTTPD + if (_con[cid].protocol == PROTO_HTTPD) { + httpdRecvData(cid, c); + } else +#endif if (_con[cid].buf != NULL) { _con[cid].buf->queue(c); if (_con[cid].buf->available() > CFG_DATA_SIZE - 16) { setRts(false); _con[cid].received = true; + WARN("buf full"); } } count ++; @@ -234,6 +241,8 @@ } } +#define MSG_TABLE_NUM 15 +#define RES_TABLE_NUM 10 int GSwifi::parseMessage () { int i; char buf[256]; @@ -267,7 +276,7 @@ {RES_MACADDRESS, &GSwifi::resMacAddress}, {RES_DHCP, &GSwifi::resIp}, {RES_DNSLOOKUP, &GSwifi::resLookup}, - {RES_HTTP, &GSwifi::resConnect}, + {RES_HTTP, &GSwifi::resHttp}, {RES_RSSI, &GSwifi::resRssi}, {RES_TIME, &GSwifi::resTime}, {RES_STATUS, &GSwifi::resStatus}, @@ -344,15 +353,13 @@ } } - // initalize + // initialize + initCon(acid, true); _con[acid].protocol = _con[cid].protocol; _con[acid].type = _con[cid].type; _con[acid].parent = cid; + _con[acid].func = _con[cid].func; _con[acid].accept = true; - if (_con[acid].buf == NULL) - _con[acid].buf = new CircBuffer<char>(CFG_DATA_SIZE); - _con[acid].buf->flush(); - _con[acid].connected = true; } void GSwifi::msgDisconnect (const char *buf) { @@ -410,16 +417,10 @@ if (strncmp(buf, "CONNECT ", 8) == 0 && buf[9] == 0) { cid = x2i(buf[8]); DBG("connect %d\r\n", cid); - // initalize - _con[cid].parent = -1; - _con[cid].accept = false; - if (_con[cid].buf == NULL) - _con[cid].buf = new CircBuffer<char>(CFG_DATA_SIZE); - _con[cid].buf->flush(); - _con[cid].connected = true; + // initialize + initCon(cid, true); _state.cid = cid; _state.res = RES_NULL; - return; } } @@ -530,3 +531,17 @@ _state.res = RES_NULL; } } + +void GSwifi::resHttp (const char *buf) { + int cid; + + // http client socket + if (buf[0] >= '0' && buf[0] <= 'F' && buf[1] == 0) { + cid = x2i(buf[0]); + DBG("connect %d\r\n", cid); + // initialize + initCon(cid, true); + _state.cid = cid; + _state.res = RES_NULL; + } +}