ArduinoGeneral

WIDO-Carriots: Stuck-up in HTTP Header send

userHead arnoldvillasanta 2016-03-24 19:19:16 2163 Views2 Replies
I have WIDO v1.1 board (without sensor) and Device1 setup in Carriots.
I used the 1-line CURL command in MAC terminal to verify if my Carriots setup is okay (passed - data stream received).

To test WIDO, I used the Wido2Carriots sample app under Adafruit_CC3000_Llibrary-master. The app is stuck sending the HTTP Header (after 'Mark 3' is printed) for more than 60 seconds for each succeeding header block.


I added a marker and RAM print to debug like this:
Code: Select all
//Make an HTTP request to the Carriots server
Serial.print(F("Sending Http Headers..."));
WidoClient.fastrprintln(F("POST /streams HTTP/1.1"));
Serial.print("Mark 1");
Serial.println("Free RAM: "); Serial.println(getFreeRam(), DEC);
WidoClient.fastrprintln(F("Host: api.carriots.com"));
Serial.println("Mark 2");
Serial.println("Free RAM: "); Serial.println(getFreeRam(), DEC);
WidoClient.fastrprintln(F("Accept: application/json"));
Serial.println("Mark 3");
Serial.println("Free RAM: "); Serial.println(getFreeRam(), DEC);
WidoClient.fastrprintln(F("User-Agent: Arduino-Carriots"));
Serial.println("Mark 4");
Serial.println("Free RAM: "); Serial.println(getFreeRam(), DEC);
WidoClient.fastrprintln(F("Content-Type: application/json"));
Serial.println("Mark 5");
Serial.println("Free RAM: "); Serial.println(getFreeRam(), DEC);
WidoClient.fastrprint(F("carriots.apikey: "));
Serial.println("Mark 6");
Serial.println("Free RAM: "); Serial.println(getFreeRam(), DEC);
WidoClient.fastrprintln(API_key);
Serial.println("Mark 7");
Serial.println("Free RAM: "); Serial.println(getFreeRam(), DEC);
WidoClient.fastrprint(F("Content-Length: "));
Serial.println("Mark 8");
Serial.println("Free RAM: "); Serial.println(getFreeRam(), DEC);
WidoClient.println(String(httpBodyPackage.length()));
Serial.println("Mark 9");
Serial.println("Free RAM: "); Serial.println(getFreeRam(), DEC);
WidoClient.fastrprintln(F("Connection: close"));
Serial.println("Mark 10");
Serial.println("Free RAM: "); Serial.println(getFreeRam(), DEC);
WidoClient.fastrprintln("");

Serial.println(F("Sending Http Data Body..."));
Serial.println("Free RAM: "); Serial.println(getFreeRam(), DEC);
WidoClient.println(httpBodyPackage);

Serial.println(F("Done....."));
}



And this is the log.
MESSAGE BLOCK was not sent properly, and I assume that is because the header is not received properly by Carriots. I also revised the sending of message block into chunks because I read that CC3000 has limitations on data length for sending too large block.

Code: Select all
Sending Http Headers...Mark 1Free RAM: 
898
Mark 2
Free RAM:
898
Mark 3
Free RAM:
898
Mark 4
Free RAM:
898
Mark 5
Free RAM:
898
Mark 6
Free RAM:
898
Mark 7
Free RAM:
898
Mark 8
Free RAM:
898
Mark 9
Free RAM:
898
Mark 10
Free RAM:
898
Sending Http Data Body...
Free RAM:
898


I adjusted the tx/rx buffer to 160 but still no progress.
Please help.
2016-03-25 23:16:55 Hi arnoldvillasanta,

Good to hear it was solved, but yes, the delay in the program is not good, maybe you can replace it with "millis()" function to avoid using delay(); or to check if the first command was sent successfully and then send the next command.(I know few about IoT..)
userHeadPic Leff
2016-03-25 03:01:07 While waiting for the right solution for this, I thought that maybe there's a clog somewhere... thus I placed a delay in between calls for the next fastprintln...
It works, but not elegant because of the unnecessary delays.
It seems that the tx must be monitored for completion before sending another message, else there's overrun... (I have a very slow internet connection btw)
Code: Select all
 //Make an HTTP request to the Carriots server
  Serial.println(F("Sending Http Headers..."));
  WidoClient.fastrprintln(F("POST /streams HTTP/1.1"));
  delay(1000);
  Serial.print("Mark 1 = ");
  Serial.println(WidoClient.connected());
  WidoClient.fastrprintln(F("Host: api.carriots.com"));
  delay(2000);
  Serial.print("Mark 2 = ");
  Serial.println(WidoClient.connected());
  WidoClient.fastrprintln(F("Accept: application/json"));
  delay(2000);
  Serial.print("Mark 3 = ");
  Serial.println(WidoClient.connected());
userHeadPic arnoldvillasanta