Go Down

Topic: can't read HTTP/1.1 request with GPRS (sim900), only first rows shown correctly (Read 2289 times) previous topic - next topic

Hi, I have one task I need to get done: Get html file from HTTP/1.1 server using GPRS.

Parts: Sim900 module with this shield: http://www.open-electronics.org/arduino-gsm-shield/

Same site offers also: GSM_Shield_Library which hides AT-commands (from http://code.google.com/p/gsm-shield-arduino/). I have tested it and I can send SMS's. But it doesn't yet have way to download web page with GPRS. (First question: Is there any other library with this functionality for this module?)


I copied initialization etc from GSM_Shield_Library and worked with AT-commands (using NewSoftSerial).

I can download small file using HTTP/1.0 (which is NOT I need, but first test)

WORKING SNIPPET
(
for this functionality
telnet cc.oulu.fi 80
GET /~rantalai/humidity.html HTTP/1.0
)

Code: [Select]
char* host = "cc.oulu.fi";
char* address= "/~rantalai/humidity.html";

char cipstart [100];
sprintf (cipstart, "AT+CIPSTART=\"TCP\",\"%s\",\"80\"", host);
cell.println(cipstart);
delay(1000);


int message_length;
char request [100];
message_length=sprintf (request, "GET %s HTTP/1.0\r\n\r\n", address);

cell.print("AT+CIPSEND=");
cell.println(message_length);

cell.println(request);
delay(1000);

while(cell.available())
   {
    buffer[index] = (char)cell.read();
    index++;
   }



Not working
(
for this
telnet cc.oulu.fi 80
GET /~rantalai/humidity.html HTTP/1.1
Host: cc.oulu.fi
)

Same than below, but:
Code: [Select]
-message_length=sprintf (request, "GET %s HTTP/1.0\r\n\r\n", address);
+message_length=sprintf (request, "GET %s HTTP/1.1\r\nHost: cc.oulu.fi\r\n\r\n", address);


Now responses get messed. They start clear, but end is messed. Look:
Code: [Select]
Date: Sun, 30 Oct 2011 1Lat-odfid:S8
id:Sat 2 Ot 01 202053GM
Eag "49
onen8
onentTye tet/tm

hu4
!DCTPE TM E50 Mth8


I checked with HTTP/1.0 and LONG html-pages and they have same garbage effect at the end of the files (header part is correct always).

Any ideas?


I'm using baudrate 9600. It is only working baudrate (every others aren't do anything).



footswitch

Buffer overflow on the Software Serial Port. I'm quite confident that's the reason why characters stop making sense.
I'm trying to figure that one out myself.

I thought that by setting the buffer to a larger value would solve it, but in my case it freezes the arduino after a few larger responses.

But then again, I'm not sure if it's enough to just change the line
#define _NewSS_MAX_RX_BUFF 256 // RX buffer size (default 64)
in NewSoftSerial.h

:/


footswitch

PeterH

You have no buffer overflow protection on your receive buffer. At the very least, you should stop incrementing the index when it reaches (buffer length-1).

I don't see the code outputting the buffer content. Are you terminating the buffer before you print it? If not, and you treat the buffer as if it was a string, your string will run off into free memory until it happens to hit a zero. Printing that will have undefined consequences. (This may well be why your Arduino locks up when you increases the GPRS buffer size.)
I only provide help via the forum - please do not contact me for private consultancy.

Go Up