Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of SPWF01SA by
Revision 23:38b37bf10da7, committed 2016-10-14
- Comitter:
- mapellil
- Date:
- Fri Oct 14 15:24:17 2016 +0000
- Parent:
- 22:0fb8db6110be
- Commit message:
- removed old recv
Changed in this revision
SPWFSA01.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/SPWFSA01.cpp Mon Oct 10 15:43:23 2016 +0000 +++ b/SPWFSA01.cpp Fri Oct 14 15:24:17 2016 +0000 @@ -287,126 +287,6 @@ return false; } -#if 0 -int32_t SPWFSA01::recv(int id, void *data, uint32_t amount) -{ - uint32_t recv_amount; - int recv_id; - bool wind_recv = true; - - if (!(_parser.recv("+WIND:55:Pending Data:%d:%u", &recv_id, &recv_amount) - && recv_id == id - && recv_amount <= amount - && recv_amount%730 - && _parser.send("AT+S.SOCKQ=%d", id) //send a query (will be required for secure sockets) - && _parser.recv(" DATALEN: %u", &recv_amount) - && _parser.recv("OK") - && recv_amount > 0 - && _parser.send("AT+S.SOCKR=%d,%d", id, recv_amount) - && (_parser.read((char*)data, recv_amount) >0) - && _parser.recv("OK"))) { - if(!(recv_amount%730)) - { - // receive all the WIND messages - do { - if (!(_parser.recv("+WIND:55:Pending Data:%d:%u", &recv_id, &recv_amount) - && recv_id == id - && recv_amount <= amount - && recv_amount > 0)) - wind_recv = false; - } while (!(recv_amount%730) && wind_recv); - - // Read all the data pending on a socket - if(!( recv_amount > 0 - && _parser.send("AT+S.SOCKR=%d,%d", id, recv_amount) - && (_parser.read((char*)data, recv_amount) >0) - && _parser.recv("OK"))) { - return -1; - } - } - else { - return -2; - } - } - return recv_amount; -} - - -int32_t SPWFSA01::recv(int id, void *data, uint32_t amount) -{ - Timer timer; - timer.start(); - - uint32_t recv_amount=0; - int recv_id; - - if(!(_parser.recv("+WIND:55:Pending Data:%d:", &recv_id))) { - //do nothing; - debug_if(dbg_on, "SPWF> WIND:55 Timeout\r\n"); - } - - while(!recv_amount) { - if(!(_parser.send("AT+S.SOCKQ=%d", id) //send a query (will be required for secure sockets) - && _parser.recv(" DATALEN: %u", &recv_amount) - && _parser.recv("OK"))) { - return -2; - } - if (timer.read_ms() > SPWFSA01_SOCKQ_TIMEOUT) { - return -2; - } - } - if(recv_amount > amount) - recv_amount = amount; - - _parser.flush(); - if(!(_parser.send("AT+S.SOCKR=%d,%d", id, recv_amount))) - return -2; - - /* only when the data recv is greater than 3 bytes */ - if(recv_amount > 3) { - /* look for WIND messages in data */ - - // get first 3 bytes of data - for(int i=0;i<3;i++) { - int c = -1; - while(c < 0) { - c = _parser.getc(); - } - ((char *)data)[i] = c; - } - - /* 0xD: \r && 0xA: \n */ - if(((char *)data)[0] == 0xD - &&((char *)data)[1] == 0xA - &&((char *)data)[2] == '+') { - ((char *)data)[0] = 0; - while(((char *)data)[0] != 0xA) { - ((char *)data)[0] = _parser.getc(); - } - - // complete data is yet to be read - if(!((_parser.read((char*)data, recv_amount) >0) - && _parser.recv("OK"))) { - return -2; - } - } - else { - // data left to be read is 3 bytes less. - if(!((_parser.read((char*)data+3, recv_amount-3) >0) - && _parser.recv("OK"))) { - return -2; - } - } - } - else { - if(!((_parser.read((char*)data, recv_amount) >0) - && _parser.recv("OK"))) { - return -2; - } - } - return recv_amount; -} -#endif int32_t SPWFSA01::recv(int id, void *data, uint32_t amount) {