Skip to content

Instantly share code, notes, and snippets.

@AgustinPelaez
Created August 29, 2016 19:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AgustinPelaez/8a910a13ee6008be56fa61e933b0f1ac to your computer and use it in GitHub Desktop.
Save AgustinPelaez/8a910a13ee6008be56fa61e933b0f1ac to your computer and use it in GitHub Desktop.
/*
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 (;;)
;
}
}
@AgustinPelaez
Copy link
Author

AgustinPelaez commented Aug 29, 2016

Current response using a Hologram Sim card:

Attach to GPRS network
Connected to APN!
connection failed

disconnecting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment