Joe Tijerina / M2XStreamClient

Dependents:   STM32_MTS_Wifi_Connect_M2X M2X_STM32_MTS_Temp MTS_WiFi_Connect_M2X_Example

Fork of M2XStreamClient by AT&T M2X Team

Files at this revision

API Documentation at this revision

Comitter:
joe_tijerina
Date:
Fri Jul 25 16:29:47 2014 +0000
Parent:
0:f479e4f4db0e
Child:
2:6fbc104d1321
Commit message:
Added a 100ms wait before the while loop of M2XStreamClient::readLocation() and M2XStreamClient::readStreamValue() as a workaround to get data fetches to work. Without these delays, the M2XStreamClient does not call the callback

Changed in this revision

M2XStreamClient.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/M2XStreamClient.cpp	Wed Feb 12 19:43:34 2014 +0000
+++ b/M2XStreamClient.cpp	Fri Jul 25 16:29:47 2014 +0000
@@ -317,9 +317,11 @@
   jsonlite_parser_set_callback(p, &cbs);
 
   jsonlite_result result = jsonlite_result_unknown;
+  
+  wait_ms(100);    // Workaround - 100ms delay necessary for data fetches to work
   while (index < length) {
     int i = 0;
-
+    
     DBG("%s", "Received Data: ");
     while ((i < BUF_LEN) && _client->available()) {
       buf[i++] = _client->read();
@@ -355,20 +357,20 @@
                                   void* context) {
   const int BUF_LEN = 40;
   char buf[BUF_LEN];
-
+    
   int length = readContentLength();
   if (length < 0) {
     close();
     return length;
   }
-
+  
   int index = skipHttpHeader();
   if (index != E_OK) {
     close();
     return index;
   }
   index = 0;
-
+  
   location_parsing_context_state state;
   state.state = state.index = 0;
   state.callback = callback;
@@ -383,9 +385,11 @@
   jsonlite_parser_set_callback(p, &cbs);
 
   jsonlite_result result = jsonlite_result_unknown;
+  
+  wait_ms(100);    // Workaround - 100ms delay necessary for data fetches to work
   while (index < length) {
     int i = 0;
-
+          
     DBG("%s", "Received Data: ");
     while ((i < BUF_LEN) && _client->available()) {
       buf[i++] = _client->read();
@@ -411,7 +415,7 @@
 
     index += i;
   }
-
+  
   jsonlite_parser_release(p);
   close();
   return (result == jsonlite_result_ok) ? (E_OK) : (E_JSON_INVALID);