Created
August 29, 2016 19:32
-
-
Save AgustinPelaez/8a910a13ee6008be56fa61e933b0f1ac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Web client | |
This sketch connects to a website through GPRS on LinkIt platform. | |
Specifically, | |
this example downloads the URL "http://arduino.cc/asciilogo.txt" and | |
prints it to the Serial monitor. | |
created 8 Mar 2012 | |
by Tom Igoe | |
Modified 20 Aug 2014 | |
by MediaTek Inc. | |
*/ | |
#include <LGPRS.h> | |
#include <LGPRSClient.h> | |
#include <LGPRSServer.h> | |
char server[] = "arduino.cc"; | |
char path[] = "/asciilogo.txt"; | |
int port = 80; // HTTP | |
LGPRSClient client; | |
void setup() | |
{ | |
// setup Serial po | |
Serial.begin(115200); | |
Serial.println("Attach to GPRS network"); | |
while (!LGPRS.attachGPRS("apn.konekt.io","","")) | |
{ | |
delay(500); | |
} | |
// if you get a connection, report back via serial: | |
Serial.print("Connected to APN!"); | |
Serial.println(server); | |
if (client.connect(server, port)) | |
{ | |
Serial.println("Client connected"); | |
// Make a HTTP request: | |
client.print("GET "); | |
client.print(path); | |
client.println(" HTTP/1.1"); | |
client.print("Host: "); | |
client.println(server); | |
client.println("Connection: close"); | |
client.println(); | |
} | |
else | |
{ | |
// if you didn't get a connection to the server: | |
Serial.println("connection failed"); | |
} | |
} | |
void loop() | |
{ | |
// if there are incoming bytes available | |
// from the server, read them and print them: | |
if (client.available()) | |
{ | |
char c = client.read(); | |
Serial.print(c); | |
} | |
// if the server's disconnected, stop the client: | |
if (!client.available() && !client.connected()) | |
{ | |
Serial.println(); | |
Serial.println("disconnecting."); | |
client.stop(); | |
// do nothing forevermore: | |
for (;;) | |
; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Current response using a Hologram Sim card: