mbed.org implementation of the abstract SmartREST library for the Cumulocity Platform SmartREST protocol.

Dependents:   MbedSmartRestMain MbedSmartRestMain

Revision:
6:cd7ba1ddb664
Parent:
4:059b8b90e0d9
Child:
11:e1bee9a77652
--- a/Parser.cpp	Thu Jul 10 16:20:31 2014 +0200
+++ b/Parser.cpp	Mon Jul 28 12:11:02 2014 +0200
@@ -49,27 +49,32 @@
     record.clear();
 
     while ((_state < STATE_COMPLETE) &&
-           (((read = source.read()) > 0 ) ||
+           (((read = source.read()) > 0) ||
             ((status = source.status()) == DS_STATUS_OK)))
         parse(read);
 
+    // successfully read record
     if (_state == STATE_COMPLETE) {
         if (!record.set(_buffer, _count))
             return PARSER_INTERNAL_ERROR;
+        return PARSER_SUCCESS;
+    }
+
+    if (_state == STATE_BLANK) {
+        if (status == DS_STATUS_CLOSED)
+            return PARSER_END_OF_RESPONSE;
+        else if (status == DS_STATUS_TIMEOUT)
+            return PARSER_TIMEOUT_ERROR;
+        else
+            return PARSER_INTERNAL_ERROR;
     }
 
-    if (_state == STATE_COMPLETE)
-        return PARSER_SUCCESS;
-    else if (_state == STATE_BLANK)
-        if (status == DS_STATUS_CLOSED)
-            return PARSER_END_OF_RESPONSE;
-        else
-            return PARSER_TIMEOUT_ERROR;
+    if (status == DS_STATUS_TIMEOUT)
+        return PARSER_TIMEOUT_ERROR;
+    else if (status == DS_STATUS_ERROR)
+        return PARSER_INTERNAL_ERROR;
     else
-        if (status == DS_STATUS_TIMEOUT)
-            return PARSER_TIMEOUT_ERROR;
-        else
-            return PARSER_PARSE_ERROR;
+        return PARSER_PARSE_ERROR;
 }
 
 void Parser::parse(char c)