Example HTTP client application

Let's suppose you want to connect your embedded device to an HTTP server and retrieve an HTML page using the EASY GPRS feature.

Initial data:
Server to be contacted: www.gsm-modem.com
Application Layer Protocol: HTTP1.0 (RFC1945)
Page to be retrieved: homepage of server

GPRS settings:
APN: internet.gprs
IP of GPRS device: dynamically assigned by the network
DNS: assigned by the network
USERID: Happy User

Checking on the RFC990 the HTTP service we can found that the port 80 is dedicated for HTTP service, therefore our HTTP server will be waiting for incoming connections on that port and we will fix the EASY GPRS port to be contacted on the remote server exactly to 80.Second thing we have to discover is whether the transport protocol has to be TCP or UDP; on theRFC1945 we can read that the HTTP Application layer protocol is meant to be on top of TCP/IPprotocol, therefore the transport protocol choice will fall on TCP. Now we have all the information needed to configure our system. With your microcontroller you issue to the GM862-GPRS the following AT commands:

AT+CGDCONT = 1,"IP","internet.gprs","",0,0<cr>(1-GPRS context setting)
AT#USERID = "Happy User"<cr>(2-Authentication setting)
AT#PASSW = "EASY GPRS"<cr>(2-Authentication setting)
AT#SKTSET= 0,80," www.gsm-modem.de"<cr>(3-remote host setting)

For our convenience we store all these parameters with the command:
Now we can activate the GPRS connection and let the GPRS module contact the server:
When we receive the CONNECT indication, then we are exchanging data with the HTTP server program on the remote host machine. Now following the HTTP protocol we ask for the homepage by sending the following lines on the serial line:

GET / HTTP/1.0<cr><lf>
Connection: keep-alive<cr><lf>

As a response to our query the HTTP server will reply with the HTML code of the homepage and some debugging responses that we will see directly on the serial line:

HTTP/1.0 200 OK
Date: Thu, 06 2003 10:21:58 GMT
Server: Apache/1.3.27 (Unix)
Last-Modified: Thu, 06 2003 10:21:58 GMT
Content-Type: text/html
X-Cache: MISS from proxy.telital.com
Connection: close
… here is all the HTML code of the page..


HTTP request

German version