diff options
author | Cristian Maglie <c.maglie@bug.st> | 2013-04-03 13:51:04 +0200 |
---|---|---|
committer | Cristian Maglie <c.maglie@bug.st> | 2013-04-03 13:51:04 +0200 |
commit | ee90e68e86dd61d86f5d17b69080338328765b22 (patch) | |
tree | e620c0edc2690ab789b665e567910640597aa6fe /libraries/GSM/examples/Tools/TestWebServer/TestWebServer.ino | |
parent | 0ecdc5ebc96ad4c7c548c438a03d9ce00679db8b (diff) | |
parent | f50c307be280dc6ece9e70c43b301c1db36291a0 (diff) |
Merged 1.0.5
Merge remote-tracking branch 'arduino/master' into ide-1.5.x
Conflicts:
app/src/processing/app/Base.java
build/shared/revisions.txt
hardware/arduino/avr/cores/arduino/malloc.c
hardware/arduino/cores/arduino/avr-libc/malloc.c
hardware/arduino/cores/arduino/malloc.c
todo.txt
Diffstat (limited to 'libraries/GSM/examples/Tools/TestWebServer/TestWebServer.ino')
-rw-r--r-- | libraries/GSM/examples/Tools/TestWebServer/TestWebServer.ino | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/libraries/GSM/examples/Tools/TestWebServer/TestWebServer.ino b/libraries/GSM/examples/Tools/TestWebServer/TestWebServer.ino new file mode 100644 index 0000000..5cc3f8a --- /dev/null +++ b/libraries/GSM/examples/Tools/TestWebServer/TestWebServer.ino @@ -0,0 +1,85 @@ +/* + Basic Web Server + + A simple web server that replies with nothing, but prints the client's request + and the server IP address. + + Circuit: + * GSM shield attached + + created + by David Cuartielles + modified 21 Nov 2012 + by Tom Igoe + + http://arduino.cc/en/Tutorial/GSMToolsTestWebServer + + This example code is part of the public domain + */ + #include <GSM.h> + +// PIN Number +#define PINNUMBER "" + +// APN data +#define GPRS_APN "GPRS_APN" // replace your GPRS APN +#define GPRS_LOGIN "login" // replace with your GPRS login +#define GPRS_PASSWORD "password" // replace with your GPRS password + + +// initialize the library instance +GPRS gprs; +GSM gsmAccess; // include a 'true' parameter for debug enabled +GSMServer server(80); // port 80 (http default) + +// timeout +const unsigned long __TIMEOUT__ = 10*1000; + +void setup() +{ + // initialize serial communications and wait for port to open: + Serial.begin(9600); + while (!Serial) { + ; // wait for serial port to connect. Needed for Leonardo only + } + + Serial.println("starting,.."); + // connection state + boolean connected = true; + + // Start GSM shield + // If your SIM has PIN, pass it as a parameter of begin() in quotes + while(!connected) + { + if((gsmAccess.begin(PINNUMBER)==GSM_READY) & + (gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY)) + connected = true; + else + { + Serial.println("Not connected"); + delay(1000); + } + } + + Serial.println("Connected to GPRS network"); + + // start server + server.begin(); + + //Get IP. + IPAddress LocalIP = gprs.getIPAddress(); + Serial.println("Server IP address="); + Serial.println(LocalIP); +} + +void loop(){ + GSMClient client = server.available(); + + if (client) { + if (client.available()) { + Serial.write(client.read()); + } +} + +} + |