2
2
Web client
3
3
4
4
This sketch connects to a website through a GSM shield. Specifically,
5
- this example downloads the URL "http://arduino.cc/" and prints it
6
- to the Serial monitor.
5
+ this example downloads the URL "http://arduino.cc/asciilogo.txt " and
6
+ prints it to the Serial monitor.
7
7
8
8
Circuit:
9
9
* GSM shield attached to an Arduino
@@ -34,7 +34,7 @@ GSM gsmAccess;
34
34
35
35
// URL, path & port (for example: arduino.cc)
36
36
char server[] = " arduino.cc" ;
37
- char path[] = " /" ;
37
+ char path[] = " /asciilogo.txt " ;
38
38
int port = 80 ; // port 80 is the default for HTTP
39
39
40
40
void setup ()
@@ -48,13 +48,13 @@ void setup()
48
48
Serial.println (" Starting Arduino web client." );
49
49
// connection state
50
50
boolean notConnected = true ;
51
-
51
+
52
52
// After starting the modem with GSM.begin()
53
53
// attach the shield to the GPRS network with the APN, login and password
54
54
while (notConnected)
55
55
{
56
56
if ((gsmAccess.begin (PINNUMBER)==GSM_READY) &
57
- (gprs.attachGPRS (GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY))
57
+ (gprs.attachGPRS (GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY))
58
58
notConnected = false ;
59
59
else
60
60
{
@@ -72,10 +72,10 @@ void setup()
72
72
// Make a HTTP request:
73
73
client.print (" GET " );
74
74
client.print (path);
75
- client.println (" HTTP/1.0" );
76
- client.println ();
77
- client.print (" HOST: " );
75
+ client.println (" HTTP/1.1" );
76
+ client.print (" Host: " );
78
77
client.println (server);
78
+ client.println (" Connection: close" );
79
79
client.println ();
80
80
}
81
81
else
@@ -94,7 +94,7 @@ void loop()
94
94
char c = client.read ();
95
95
Serial.print (c);
96
96
}
97
-
97
+
98
98
// if the server's disconnected, stop the client:
99
99
if (!client.available () && !client.connected ())
100
100
{
0 commit comments