Update some example text and add new modems
Signed-off-by: Sara Damiano <sdamiano@stroudcenter.org>
This commit is contained in:
@@ -24,6 +24,8 @@
|
||||
// #define TINY_GSM_MODEM_SIM868
|
||||
// #define TINY_GSM_MODEM_SIM900
|
||||
// #define TINY_GSM_MODEM_SIM7000
|
||||
// #define TINY_GSM_MODEM_SIM7000SSL
|
||||
// #define TINY_GSM_MODEM_SIM7080
|
||||
// #define TINY_GSM_MODEM_SIM5360
|
||||
// #define TINY_GSM_MODEM_SIM7600
|
||||
// #define TINY_GSM_MODEM_UBLOX
|
||||
@@ -69,13 +71,17 @@ SoftwareSerial SerialAT(2, 3); // RX, TX
|
||||
// #define LOGGING // <- Logging is for the HTTP library
|
||||
|
||||
// Range to attempt to autobaud
|
||||
// NOTE: DO NOT AUTOBAUD in production code. Once you've established
|
||||
// communication, set a fixed baud rate using modem.setBaud(#).
|
||||
#define GSM_AUTOBAUD_MIN 9600
|
||||
#define GSM_AUTOBAUD_MAX 115200
|
||||
|
||||
// Add a reception delay - may be needed for a fast processor at a slow baud rate
|
||||
// Add a reception delay, if needed.
|
||||
// This may be needed for a fast processor at a slow baud rate.
|
||||
// #define TINY_GSM_YIELD() { delay(2); }
|
||||
|
||||
// Define how you're planning to connect to the internet
|
||||
// These defines are only for this example; they are not needed in other code.
|
||||
#define TINY_GSM_USE_GPRS true
|
||||
#define TINY_GSM_USE_WIFI false
|
||||
|
||||
@@ -83,18 +89,18 @@ SoftwareSerial SerialAT(2, 3); // RX, TX
|
||||
#define GSM_PIN ""
|
||||
|
||||
// Your GPRS credentials, if any
|
||||
const char apn[] = "YourAPN";
|
||||
const char apn[] = "YourAPN";
|
||||
const char gprsUser[] = "";
|
||||
const char gprsPass[] = "";
|
||||
|
||||
// Your WiFi connection credentials, if applicable
|
||||
const char wifiSSID[] = "YourSSID";
|
||||
const char wifiSSID[] = "YourSSID";
|
||||
const char wifiPass[] = "YourWiFiPass";
|
||||
|
||||
// Server details
|
||||
const char server[] = "vsh.pp.ua";
|
||||
const char server[] = "vsh.pp.ua";
|
||||
const char resource[] = "/TinyGSM/logo.txt";
|
||||
const int port = 80;
|
||||
const int port = 80;
|
||||
|
||||
#include <TinyGsmClient.h>
|
||||
#include <ArduinoHttpClient.h>
|
||||
@@ -114,15 +120,15 @@ const int port = 80;
|
||||
#endif
|
||||
|
||||
#ifdef DUMP_AT_COMMANDS
|
||||
#include <StreamDebugger.h>
|
||||
StreamDebugger debugger(SerialAT, SerialMon);
|
||||
TinyGsm modem(debugger);
|
||||
#include <StreamDebugger.h>
|
||||
StreamDebugger debugger(SerialAT, SerialMon);
|
||||
TinyGsm modem(debugger);
|
||||
#else
|
||||
TinyGsm modem(SerialAT);
|
||||
TinyGsm modem(SerialAT);
|
||||
#endif
|
||||
|
||||
TinyGsmClient client(modem);
|
||||
HttpClient http(client, server, port);
|
||||
HttpClient http(client, server, port);
|
||||
|
||||
void setup() {
|
||||
// Set console baud rate
|
||||
@@ -152,14 +158,11 @@ void setup() {
|
||||
|
||||
#if TINY_GSM_USE_GPRS
|
||||
// Unlock your SIM card with a PIN if needed
|
||||
if ( GSM_PIN && modem.getSimStatus() != 3 ) {
|
||||
modem.simUnlock(GSM_PIN);
|
||||
}
|
||||
if (GSM_PIN && modem.getSimStatus() != 3) { modem.simUnlock(GSM_PIN); }
|
||||
#endif
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
#if TINY_GSM_USE_WIFI
|
||||
// Wifi connection parameters must be set before waiting for the network
|
||||
SerialMon.print(F("Setting SSID/password..."));
|
||||
@@ -184,24 +187,20 @@ void loop() {
|
||||
}
|
||||
SerialMon.println(" success");
|
||||
|
||||
if (modem.isNetworkConnected()) {
|
||||
SerialMon.println("Network connected");
|
||||
}
|
||||
if (modem.isNetworkConnected()) { SerialMon.println("Network connected"); }
|
||||
|
||||
#if TINY_GSM_USE_GPRS
|
||||
// GPRS connection parameters are usually set after network registration
|
||||
SerialMon.print(F("Connecting to "));
|
||||
SerialMon.print(apn);
|
||||
if (!modem.gprsConnect(apn, gprsUser, gprsPass)) {
|
||||
SerialMon.println(" fail");
|
||||
delay(10000);
|
||||
return;
|
||||
}
|
||||
SerialMon.println(" success");
|
||||
SerialMon.print(F("Connecting to "));
|
||||
SerialMon.print(apn);
|
||||
if (!modem.gprsConnect(apn, gprsUser, gprsPass)) {
|
||||
SerialMon.println(" fail");
|
||||
delay(10000);
|
||||
return;
|
||||
}
|
||||
SerialMon.println(" success");
|
||||
|
||||
if (modem.isGprsConnected()) {
|
||||
SerialMon.println("GPRS connected");
|
||||
}
|
||||
if (modem.isGprsConnected()) { SerialMon.println("GPRS connected"); }
|
||||
#endif
|
||||
|
||||
SerialMon.print(F("Performing HTTP GET request... "));
|
||||
@@ -222,7 +221,7 @@ void loop() {
|
||||
|
||||
SerialMon.println(F("Response Headers:"));
|
||||
while (http.headerAvailable()) {
|
||||
String headerName = http.readHeaderName();
|
||||
String headerName = http.readHeaderName();
|
||||
String headerValue = http.readHeaderValue();
|
||||
SerialMon.println(" " + headerName + " : " + headerValue);
|
||||
}
|
||||
@@ -249,16 +248,14 @@ void loop() {
|
||||
SerialMon.println(F("Server disconnected"));
|
||||
|
||||
#if TINY_GSM_USE_WIFI
|
||||
modem.networkDisconnect();
|
||||
SerialMon.println(F("WiFi disconnected"));
|
||||
modem.networkDisconnect();
|
||||
SerialMon.println(F("WiFi disconnected"));
|
||||
#endif
|
||||
#if TINY_GSM_USE_GPRS
|
||||
modem.gprsDisconnect();
|
||||
SerialMon.println(F("GPRS disconnected"));
|
||||
modem.gprsDisconnect();
|
||||
SerialMon.println(F("GPRS disconnected"));
|
||||
#endif
|
||||
|
||||
// Do nothing forevermore
|
||||
while (true) {
|
||||
delay(1000);
|
||||
}
|
||||
while (true) { delay(1000); }
|
||||
}
|
||||
|
Reference in New Issue
Block a user