Own fork of MbedSmartRestMain
Dependencies: C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed
Fork of MbedSmartRestMain by
Diff: operation/PollThread.cpp
- Revision:
- 105:c61f0d62b625
- Parent:
- 100:dbcd3bc51758
- Child:
- 106:fc5f25f0e0d5
--- a/operation/PollThread.cpp Fri May 08 14:50:43 2015 +0000 +++ b/operation/PollThread.cpp Mon May 11 18:10:44 2015 +0000 @@ -6,10 +6,10 @@ bool PollThread::handshake() { - int l = snprintf(buf2, SMARRESTBODY_SIZE, "%s", "80\r\n"); - l = snprintf(buf, SMARTREST_SIZE, fmtSmartRest, uri, l, buf2); - sock.set_blocking(false); - l = sock.sendAndReceive(buf, l, SMARTREST_SIZE); + int l = snprintf(buf2, sizeof(buf2), "%s", "80\r\n"); + l = snprintf(buf, sizeof(buf), fmtSmartRest, uri, l, buf2); + sock.setBlocking(3000); + l = sock.sendAndReceive(buf, l, sizeof(buf)); if (l < 0) return false; size_t i = 0; @@ -22,19 +22,19 @@ bool PollThread::subscribe() { - int l = snprintf(buf2, SMARRESTBODY_SIZE, "81,%s,%s\r\n", bayeuxId, chn); - l = snprintf(buf, SMARTREST_SIZE, fmtSmartRest, uri, l, buf2); - sock.set_blocking(false); + int l = snprintf(buf2, sizeof(buf2), "81,%s,%s\r\n", bayeuxId, chn); + l = snprintf(buf, sizeof(buf), fmtSmartRest, uri, l, buf2); + sock.setBlocking(3000); l = sock.sendOnly(buf, l); return l>=0; } bool PollThread::connect() { - int l = snprintf(buf2, SMARRESTBODY_SIZE, "83,%s\r\n", bayeuxId); - l = snprintf(buf, SMARTREST_SIZE, fmtSmartRest, uri, l, buf2); - sock.set_blocking(true); - l = sock.sendAndReceive(buf, l, SMARTREST_SIZE); + int l = snprintf(buf2, sizeof(buf2), "83,%s\r\n", bayeuxId); + l = snprintf(buf, sizeof(buf), fmtSmartRest, uri, l, buf2); + sock.setBlocking(-1); + l = sock.sendAndReceive(buf, l, sizeof(buf)); return l>=0; }