Closed xabierlegasa closed 11 years ago
I'd suggest not using delay() in your code. When delay() is called it stops the Arduino from doing anything for that period of time, so the serial buffer overflows and you miss out on the rest of the data.
The String type should also be avoided. It's a memory hog and will eat up the RAM.
Solved!
You were totally right. delay() is not a good idea here... After deleting all the delay() calls (and the String), now I get all the page. So now I'm using at my loop() function the code from WiflyHQ Library/examples/ htttpclient.ino file:
void loop() {
if (wifly.available() > 0) {
ch = wifly.read();
Serial.write(ch);
if (ch == '\n') {
/* add a carriage return */
Serial.write('\r');
}
}
}
NOTE: Using Serial.println(ch) instead of Serial.write(ch) was giving me incorrect letters on my Serial Monitor (only in the body!, headers were ok) so check this if you experiment same problem.
Thank you!!
I'm able to make successfully a GET request with this code:
Im sure the request arrives to the server because I create a record on a certain database each time it happens. BUT after my request, I'm getting only 62 characters back!. Exactly I get this:
While if I go to the same URL with my browser, it gives me the full headers and page.
My problem is that I don't really know where to look at to solve this. Could it be a memory issue (RN module?) Maybe the memory of the RN-XV is full? How can I check this? I thought wifly.read() would make free the memory. Do I have to do flush() somewhere or it has nothing to do with this?
Any idea? Thanks!
I'm taking the characters in my loop() function this way:
I tryed to debug and added this line in each loop:
This tells me that first time bytesToRead is 62 and then it goes decreasing in each loop (because I do wifly.read() ) and it finally arrives to 0.