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
Diff: SPWFSA01.cpp
- Revision:
- 3:2af9df1068a5
- Parent:
- 2:40d183d7dc19
- Child:
- 4:042d5b9bb6e7
--- a/SPWFSA01.cpp Thu Jun 30 06:59:25 2016 +0000
+++ b/SPWFSA01.cpp Thu Jun 30 08:25:26 2016 +0000
@@ -232,15 +232,25 @@
return getIPAddress() != 0;
}
-bool SPWFSA01::open(const char *type, int id, const char* addr, int port)
+bool SPWFSA01::open(const char *type, int* id, const char* addr, int port)
{
- //IDs only 0-7
- if(id > 7) {
- return false;
- }
+
+ if(!_parser.send("AT+S.SOCKON=%s,%d,%s,ind", addr, port, type))
+ {
+ printf("\r\nerror opening socket\n");
+ return false;
+ }
+
+ while(1)
+ {
+ if( _parser.recv(" ID: %d", id)
+ && _parser.recv("OK"))
+ break;
+ //TODO:implement time-out functionality in case of no response
+ }
+ printf("\r\nsock id = %d\r\n", *id);
- return _parser.send("AT+CIPSTART=%d,\"%s\",\"%s\",%d", id, type, addr, port)
- && _parser.recv("OK");
+ return true;
}
bool SPWFSA01::send(int id, const void *data, uint32_t amount)
