Own fork of MbedSmartRest

Dependents:   MbedSmartRestMain MbedSmartRestMain

Fork of MbedSmartRest by Cumulocity Official

Revision:
20:505d29d5bdfc
Parent:
18:16192696c106
--- a/MbedDataSource.cpp	Fri Mar 20 14:26:52 2015 +0000
+++ b/MbedDataSource.cpp	Mon Apr 13 14:24:44 2015 +0000
@@ -25,9 +25,9 @@
  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
-
+#include <stdio.h>
 #include "MbedDataSource.h"
-#include "stdio.h"
+#include "rtos.h"
 
 MbedDataSource::MbedDataSource(TCPSocketConnection& sock) :
     _sock(sock),
@@ -48,7 +48,6 @@
             return 0;
         }
     }
-    
     return _buf[_offset++];
 }
 
@@ -56,11 +55,10 @@
 {
     if (!_sock.is_connected())
         return DS_STATUS_CLOSED;
-    
-    if (_isTimedOut)
+    else if (_isTimedOut)
         return DS_STATUS_TIMEOUT;
-    
-    return DS_STATUS_OK;
+    else
+        return DS_STATUS_OK;
 }
 
 void MbedDataSource::setTimeout(size_t timeout)
@@ -72,20 +70,20 @@
 {
     if (status() != DS_STATUS_OK)
         return false;
-    
-//    _sock.set_blocking(true, _timeout);
-    _sock.set_blocking(false, 300000); 
+
+    _sock.set_blocking(false, _timeout);
+//    _sock.set_blocking(false, 300000);
+//    _sock.set_blocking(true);
     int ret = _sock.receive(_buf, MBED_SOURCE_BUFFER_SIZE);
-    
+
     if (ret <= 0) {
         _isTimedOut = true;
         return false;
+    } else {
+        _len = (size_t)ret;
+        _offset = 0;
+        return true;
     }
-    
-    _len = (size_t)ret;
-    _offset = 0;
-    
-    return true;
 }
 
 void MbedDataSource::reset()