for TwitterMbed
Fork of GSwifi_old by
Diff: GSwifi.cpp
- Revision:
- 12:63e714550791
- Parent:
- 11:983f4e832a3e
- Child:
- 13:03b420e152b7
--- a/GSwifi.cpp Tue Sep 04 07:15:13 2012 +0000 +++ b/GSwifi.cpp Tue Sep 11 03:45:53 2012 +0000 @@ -208,6 +208,12 @@ // data _gs_sock[_cid].data->put(dat); len ++; + if (len < GS_DATA_SIZE && _gs_sock[_cid].data->available() == 0) { + // buffer full + if (_gs_sock[_cid].onGsReceive != NULL) { + _gs_sock[_cid].onGsReceive(_cid, _gs_sock[_cid].data->use()); + } + } } } break; @@ -268,6 +274,12 @@ _gs_sock[_cid].data->put(dat); } len --; + if (len && _gs_sock[_cid].data->available() == 0) { + // buffer full + if (_gs_sock[_cid].onGsReceive != NULL) { + _gs_sock[_cid].onGsReceive(_cid, _gs_sock[_cid].data->use()); + } + } if (len == 0) { DBG("recv binary %d\r\n", _cid); _gs_sock[_cid].received = 1; @@ -285,15 +297,16 @@ } } -int GSwifi::command (char *cmd, GSRESPONCE res, int timeout) { +int GSwifi::command (const char *cmd, GSRESPONCE res, int timeout) { int i; if (! cmd) { // dummy CR+LF _gs.printf("\r\n"); - wait_ms(100); - while (_gs.readable()) { - i = _gs_getc(); // dummy read + for (i = 0; i < 10; i ++) { + wait_ms(10); + poll(); + ring_clear(_buf_cmd); } return 0; } @@ -909,8 +922,13 @@ if (_gs_sock[i].received && _gs_sock[i].data->use()) { // recv interrupt _gs_sock[i].received = 0; - if (_gs_sock[i].onGsReceive != NULL) - _gs_sock[i].onGsReceive(i, _gs_sock[i].data->use()); + if (_gs_sock[i].onGsReceive != NULL) { + int j; + for (j = 0; j < 1500 / GS_DATA_SIZE + 1; j ++) { + if (! _gs_sock[i].data->use()) break; + _gs_sock[i].onGsReceive(i, _gs_sock[i].data->use()); + } + } } } }