Own fork of MbedSmartRestMain
Dependencies: C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed
Fork of MbedSmartRestMain by
Diff: operation/PollThread.cpp
- Revision:
- 98:e369fc75c000
- Parent:
- 95:5dfdc8568e9f
- Child:
- 100:dbcd3bc51758
--- a/operation/PollThread.cpp Mon Apr 27 13:30:21 2015 +0000 +++ b/operation/PollThread.cpp Thu May 07 09:57:55 2015 +0000 @@ -7,7 +7,8 @@ bool PollThread::handshake() { int l = snprintf(buf2, SMARRESTBODY_SIZE, "%s", "80\r\n"); - l = snprintf(buf, SMARTREST_SIZE, getSmartRestFmt(), uri, l, buf2); + l = snprintf(buf, SMARTREST_SIZE, fmtSmartRest, uri, l, buf2); + sock.set_blocking(false); l = sock.sendAndReceive(buf, l, SMARTREST_SIZE); if (l < 0) return false; @@ -22,22 +23,24 @@ bool PollThread::subscribe() { int l = snprintf(buf2, SMARRESTBODY_SIZE, "81,%s,/%s\r\n", bayeuxId, chn); - l = snprintf(buf, SMARTREST_SIZE, getSmartRestFmt(), uri, l, buf2); - l = sock.sendAndReceive(buf, l, SMARTREST_SIZE); + l = snprintf(buf, SMARTREST_SIZE, fmtSmartRest, uri, l, buf2); + sock.set_blocking(false); + l = sock.sendOnly(buf, l, SMARTREST_SIZE); return l>=0; } bool PollThread::connect() { int l = snprintf(buf2, SMARRESTBODY_SIZE, "83,%s\r\n", bayeuxId); - l = snprintf(buf, SMARTREST_SIZE, getSmartRestFmt(), uri, l, buf2); + l = snprintf(buf, SMARTREST_SIZE, fmtSmartRest, uri, l, buf2); + sock.set_blocking(true); l = sock.sendAndReceive(buf, l, SMARTREST_SIZE); return l>=0; } void PollThread::threadFunc() { - uint8_t state = 1; + unsigned short state = 1; aInfo("Poll thread: %p\n", Thread::gettid()); while (true) { switch (state) { @@ -55,7 +58,7 @@ state = 1; break; } - default: parser.handleControlMessage(buf); + default: parser.parse(buf); if (parser.getBayeuxAdvice() == BA_HANDSHAKE) state = 1; else