Moved begin above init, reset historic buffer sizes

This commit is contained in:
Sara Damiano
2019-05-17 16:40:01 -04:00
parent 5411535870
commit 70ca06dc9d
16 changed files with 189 additions and 97 deletions

View File

@@ -42,6 +42,9 @@
// else data will be lost (and the http library will fail). // else data will be lost (and the http library will fail).
#define TINY_GSM_RX_BUFFER 650 #define TINY_GSM_RX_BUFFER 650
// See all AT commands, if wanted
//#define DUMP_AT_COMMANDS
// See the debugging, if wanted // See the debugging, if wanted
//#define TINY_GSM_DEBUG Serial //#define TINY_GSM_DEBUG Serial
//#define LOGGING //#define LOGGING
@@ -52,12 +55,10 @@
#include <TinyGsmClient.h> #include <TinyGsmClient.h>
#include <ArduinoHttpClient.h> #include <ArduinoHttpClient.h>
// Uncomment this if you want to see all AT commands
//#define DUMP_AT_COMMANDS
// Set serial for debug console (to the Serial Monitor, default speed 115200) // Set serial for debug console (to the Serial Monitor, default speed 115200)
#define SerialMon Serial #define SerialMon Serial
// Set serial for AT commands (to the module)
// Use Hardware Serial on Mega, Leonardo, Micro // Use Hardware Serial on Mega, Leonardo, Micro
#define SerialAT Serial1 #define SerialAT Serial1
@@ -65,6 +66,11 @@
//#include <SoftwareSerial.h> //#include <SoftwareSerial.h>
//SoftwareSerial SerialAT(2, 3); // RX, TX //SoftwareSerial SerialAT(2, 3); // RX, TX
#define TINY_GSM_USE_GPRS true
#define TINY_GSM_USE_WIFI false
// set GSM PIN, if any
#define GSM_PIN ""
// Your GPRS credentials // Your GPRS credentials
// Leave empty, if missing user or pass // Leave empty, if missing user or pass
@@ -94,7 +100,15 @@ void setup() {
// Set console baud rate // Set console baud rate
SerialMon.begin(115200); SerialMon.begin(115200);
delay(10); delay(10);
SerialMon.println(F("Wait..."));
// Set your reset, enable, power pins here
pinMode(20, OUTPUT);
digitalWrite(20, HIGH);
pinMode(23, OUTPUT);
digitalWrite(23, HIGH);
SerialMon.println("Wait...");
// Set GSM module baud rate // Set GSM module baud rate
SerialAT.begin(115200); SerialAT.begin(115200);
@@ -102,11 +116,11 @@ void setup() {
// Restart takes quite some time // Restart takes quite some time
// To skip it, call init() instead of restart() // To skip it, call init() instead of restart()
SerialMon.println(F("Initializing modem...")); SerialMon.println("Initializing modem...");
modem.restart(); modem.restart();
String modemInfo = modem.getModemInfo(); String modemInfo = modem.getModemInfo();
SerialMon.print(F("Modem: ")); SerialMon.print("Modem: ");
SerialMon.println(modemInfo); SerialMon.println(modemInfo);
// Unlock your SIM card with a PIN // Unlock your SIM card with a PIN
@@ -115,17 +129,17 @@ void setup() {
void loop() { void loop() {
if (modem.hasWifi()) { #if TINY_GSM_USE_WIFI
SerialMon.print(F("Setting SSID/password...")); SerialMon.print(F("Setting SSID/password..."));
if (!modem.networkConnect(wifiSSID, wifiPass)) { if (!modem.networkConnect(wifiSSID, wifiPass)) {
SerialMon.println(" fail"); SerialMon.println(" fail");
delay(10000); delay(10000);
return; return;
}
SerialMon.println(" OK");
} }
SerialMon.println(" OK");
#endif
SerialMon.print(F("Waiting for network...")); SerialMon.print("Waiting for network...");
if (!modem.waitForNetwork()) { if (!modem.waitForNetwork()) {
SerialMon.println(" fail"); SerialMon.println(" fail");
delay(10000); delay(10000);
@@ -133,7 +147,11 @@ void loop() {
} }
SerialMon.println(" OK"); SerialMon.println(" OK");
if (modem.hasGPRS()) { if (modem.isNetworkConnected()) {
SerialMon.print("Network connected");
}
#if TINY_GSM_USE_GPRS
SerialMon.print(F("Connecting to ")); SerialMon.print(F("Connecting to "));
SerialMon.print(apn); SerialMon.print(apn);
if (!modem.gprsConnect(apn, gprsUser, gprsPass)) { if (!modem.gprsConnect(apn, gprsUser, gprsPass)) {
@@ -142,7 +160,7 @@ void loop() {
return; return;
} }
SerialMon.println(" OK"); SerialMon.println(" OK");
} #endif
SerialMon.print(F("Performing HTTP GET request... ")); SerialMon.print(F("Performing HTTP GET request... "));
int err = http.get(resource); int err = http.get(resource);
@@ -188,8 +206,14 @@ void loop() {
http.stop(); http.stop();
SerialMon.println(F("Server disconnected")); SerialMon.println(F("Server disconnected"));
modem.gprsDisconnect(); #if TINY_GSM_USE_WIFI
SerialMon.println(F("GPRS disconnected")); modem.networkDisconnect();
SerialMon.println(F("WiFi disconnected"));
#endif
#if TINY_GSM_USE_GPRS
modem.gprsDisconnect();
SerialMon.println(F("GPRS disconnected"));
#endif
// Do nothing forevermore // Do nothing forevermore
while (true) { while (true) {

View File

@@ -30,6 +30,9 @@
// else data will be lost (and the http library will fail). // else data will be lost (and the http library will fail).
#define TINY_GSM_RX_BUFFER 650 #define TINY_GSM_RX_BUFFER 650
// See all AT commands, if wanted
//#define DUMP_AT_COMMANDS
// See the debugging, if wanted // See the debugging, if wanted
//#define TINY_GSM_DEBUG Serial //#define TINY_GSM_DEBUG Serial
//#define LOGGING //#define LOGGING
@@ -40,12 +43,10 @@
#include <TinyGsmClient.h> #include <TinyGsmClient.h>
#include <ArduinoHttpClient.h> #include <ArduinoHttpClient.h>
// Uncomment this if you want to see all AT commands
//#define DUMP_AT_COMMANDS
// Set serial for debug console (to the Serial Monitor, default speed 115200) // Set serial for debug console (to the Serial Monitor, default speed 115200)
#define SerialMon Serial #define SerialMon Serial
// Set serial for AT commands (to the module)
// Use Hardware Serial on Mega, Leonardo, Micro // Use Hardware Serial on Mega, Leonardo, Micro
#define SerialAT Serial1 #define SerialAT Serial1
@@ -53,6 +54,11 @@
//#include <SoftwareSerial.h> //#include <SoftwareSerial.h>
//SoftwareSerial SerialAT(2, 3); // RX, TX //SoftwareSerial SerialAT(2, 3); // RX, TX
#define TINY_GSM_USE_GPRS true
#define TINY_GSM_USE_WIFI false
// set GSM PIN, if any
#define GSM_PIN ""
// Your GPRS credentials // Your GPRS credentials
// Leave empty, if missing user or pass // Leave empty, if missing user or pass
@@ -82,7 +88,15 @@ void setup() {
// Set console baud rate // Set console baud rate
SerialMon.begin(115200); SerialMon.begin(115200);
delay(10); delay(10);
SerialMon.println(F("Wait..."));
// Set your reset, enable, power pins here
pinMode(20, OUTPUT);
digitalWrite(20, HIGH);
pinMode(23, OUTPUT);
digitalWrite(23, HIGH);
SerialMon.println("Wait...");
// Set GSM module baud rate // Set GSM module baud rate
SerialAT.begin(115200); SerialAT.begin(115200);
@@ -90,11 +104,11 @@ void setup() {
// Restart takes quite some time // Restart takes quite some time
// To skip it, call init() instead of restart() // To skip it, call init() instead of restart()
SerialMon.println(F("Initializing modem...")); SerialMon.println("Initializing modem...");
modem.restart(); modem.restart();
String modemInfo = modem.getModemInfo(); String modemInfo = modem.getModemInfo();
SerialMon.print(F("Modem: ")); SerialMon.print("Modem: ");
SerialMon.println(modemInfo); SerialMon.println(modemInfo);
// Unlock your SIM card with a PIN // Unlock your SIM card with a PIN
@@ -108,17 +122,17 @@ void setup() {
void loop() { void loop() {
if (modem.hasWifi()) { #if TINY_GSM_USE_WIFI
SerialMon.print(F("Setting SSID/password...")); SerialMon.print(F("Setting SSID/password..."));
if (!modem.networkConnect(wifiSSID, wifiPass)) { if (!modem.networkConnect(wifiSSID, wifiPass)) {
SerialMon.println(" fail"); SerialMon.println(" fail");
delay(10000); delay(10000);
return; return;
}
SerialMon.println(" OK");
} }
SerialMon.println(" OK");
#endif
SerialMon.print(F("Waiting for network...")); SerialMon.print("Waiting for network...");
if (!modem.waitForNetwork()) { if (!modem.waitForNetwork()) {
SerialMon.println(" fail"); SerialMon.println(" fail");
delay(10000); delay(10000);
@@ -126,7 +140,11 @@ void loop() {
} }
SerialMon.println(" OK"); SerialMon.println(" OK");
if (modem.hasGPRS()) { if (modem.isNetworkConnected()) {
SerialMon.print("Network connected");
}
#if TINY_GSM_USE_GPRS
SerialMon.print(F("Connecting to ")); SerialMon.print(F("Connecting to "));
SerialMon.print(apn); SerialMon.print(apn);
if (!modem.gprsConnect(apn, gprsUser, gprsPass)) { if (!modem.gprsConnect(apn, gprsUser, gprsPass)) {
@@ -135,7 +153,7 @@ void loop() {
return; return;
} }
SerialMon.println(" OK"); SerialMon.println(" OK");
} #endif
SerialMon.print(F("Performing HTTPS GET request... ")); SerialMon.print(F("Performing HTTPS GET request... "));
http.connectionKeepAlive(); // Currently, this is needed for HTTPS http.connectionKeepAlive(); // Currently, this is needed for HTTPS
@@ -182,8 +200,14 @@ void loop() {
http.stop(); http.stop();
SerialMon.println(F("Server disconnected")); SerialMon.println(F("Server disconnected"));
modem.gprsDisconnect(); #if TINY_GSM_USE_WIFI
SerialMon.println(F("GPRS disconnected")); modem.networkDisconnect();
SerialMon.println(F("WiFi disconnected"));
#endif
#if TINY_GSM_USE_GPRS
modem.gprsDisconnect();
SerialMon.println(F("GPRS disconnected"));
#endif
// Do nothing forevermore // Do nothing forevermore
while (true) { while (true) {

View File

@@ -9,7 +9,7 @@
**************************************************************/ **************************************************************/
// Select your modem: // Select your modem:
#define TINY_GSM_MODEM_SIM800 // #define TINY_GSM_MODEM_SIM800
// #define TINY_GSM_MODEM_SIM808 // #define TINY_GSM_MODEM_SIM808
// #define TINY_GSM_MODEM_SIM868 // #define TINY_GSM_MODEM_SIM868
// #define TINY_GSM_MODEM_SIM900 // #define TINY_GSM_MODEM_SIM900
@@ -65,7 +65,7 @@
// Your GPRS credentials // Your GPRS credentials
// Leave empty, if missing user or pass // Leave empty, if missing user or pass
const char apn[] = "YourAPN"; const char apn[] = "hologram";
const char gprsUser[] = ""; const char gprsUser[] = "";
const char gprsPass[] = ""; const char gprsPass[] = "";
const char wifiSSID[] = "YourSSID"; const char wifiSSID[] = "YourSSID";
@@ -106,11 +106,11 @@ void setup() {
digitalWrite(23, HIGH); digitalWrite(23, HIGH);
SerialMon.println("Wait..."); SerialMon.println("Wait...");
delay(3000);
// Set GSM module baud rate // Set GSM module baud rate
// TinyGsmAutoBaud(SerialAT,GSM_AUTOBAUD_MIN,GSM_AUTOBAUD_MAX); // TinyGsmAutoBaud(SerialAT,GSM_AUTOBAUD_MIN,GSM_AUTOBAUD_MAX);
SerialAT.begin(9600); SerialAT.begin(9600);
delay(3000);
// Restart takes quite some time // Restart takes quite some time
// To skip it, call init() instead of restart() // To skip it, call init() instead of restart()
@@ -139,9 +139,11 @@ void loop() {
SerialMon.print("Waiting for network..."); SerialMon.print("Waiting for network...");
if (!modem.waitForNetwork()) { if (!modem.waitForNetwork()) {
SerialMon.println(" fail");
delay(10000); delay(10000);
return; return;
} }
SerialMon.println(" OK");
if (modem.isNetworkConnected()) { if (modem.isNetworkConnected()) {
SerialMon.print("Network connected"); SerialMon.print("Network connected");

View File

@@ -12,6 +12,10 @@
//#define TINY_GSM_DEBUG Serial //#define TINY_GSM_DEBUG Serial
#if !defined(TINY_GSM_RX_BUFFER)
#define TINY_GSM_RX_BUFFER 256
#endif
#define TINY_GSM_MUX_COUNT 8 #define TINY_GSM_MUX_COUNT 8
#include <TinyGsmCommon.h> #include <TinyGsmCommon.h>
@@ -119,6 +123,10 @@ public:
* Basic functions * Basic functions
*/ */
bool begin(const char* pin = NULL) {
return init(pin);
}
bool init(const char* pin = NULL) { bool init(const char* pin = NULL) {
DBG(GF("### TinyGSM Version:"), TINYGSM_VERSION); DBG(GF("### TinyGSM Version:"), TINYGSM_VERSION);
if (!testAT()) { if (!testAT()) {
@@ -137,10 +145,6 @@ public:
return true; return true;
} }
bool begin(const char* pin = NULL) {
return init(pin);
}
String getModemName() { String getModemName() {
#if defined(TINY_GSM_MODEM_A6) #if defined(TINY_GSM_MODEM_A6)
return "AI-Thinker A6"; return "AI-Thinker A6";
@@ -269,6 +273,7 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
/* /*
* GPRS functions * GPRS functions
*/ */
bool gprsConnect(const char* apn, const char* user = NULL, const char* pwd = NULL) { bool gprsConnect(const char* apn, const char* user = NULL, const char* pwd = NULL) {
gprsDisconnect(); gprsDisconnect();

View File

@@ -13,6 +13,10 @@
//#define TINY_GSM_DEBUG Serial //#define TINY_GSM_DEBUG Serial
//#define TINY_GSM_USE_HEX //#define TINY_GSM_USE_HEX
#if !defined(TINY_GSM_RX_BUFFER)
#define TINY_GSM_RX_BUFFER 64
#endif
#define TINY_GSM_MUX_COUNT 12 #define TINY_GSM_MUX_COUNT 12
#include <TinyGsmCommon.h> #include <TinyGsmCommon.h>
@@ -152,6 +156,10 @@ public:
* Basic functions * Basic functions
*/ */
bool begin(const char* pin = NULL) {
return init(pin);
}
bool init(const char* pin = NULL) { bool init(const char* pin = NULL) {
DBG(GF("### TinyGSM Version:"), TINYGSM_VERSION); DBG(GF("### TinyGSM Version:"), TINYGSM_VERSION);
if (!testAT()) { if (!testAT()) {
@@ -166,10 +174,6 @@ public:
return true; return true;
} }
bool begin(const char* pin = NULL) {
return init(pin);
}
String getModemName() { String getModemName() {
return "Quectel BG96"; return "Quectel BG96";
} }
@@ -292,6 +296,7 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
/* /*
* GPRS functions * GPRS functions
*/ */
bool gprsConnect(const char* apn, const char* user = NULL, const char* pwd = NULL) { bool gprsConnect(const char* apn, const char* user = NULL, const char* pwd = NULL) {
gprsDisconnect(); gprsDisconnect();

View File

@@ -12,6 +12,10 @@
//#define TINY_GSM_DEBUG Serial //#define TINY_GSM_DEBUG Serial
#if !defined(TINY_GSM_RX_BUFFER)
#define TINY_GSM_RX_BUFFER 512
#endif
#define TINY_GSM_MUX_COUNT 5 #define TINY_GSM_MUX_COUNT 5
#include <TinyGsmCommon.h> #include <TinyGsmCommon.h>
@@ -119,10 +123,6 @@ public:
TINY_GSM_YIELD(); TINY_GSM_YIELD();
rx.clear(); rx.clear();
sock_connected = at->modemConnect(host, port, mux, true); sock_connected = at->modemConnect(host, port, mux, true);
// sock_connected = at->modemConnect(host, port, &mux);
// at->sockets[mux] = this;
// ^^ TODO: attach the socket after attempting connection or above at init?
// Currently done inconsistently between modems
return sock_connected; return sock_connected;
} }
}; };
@@ -140,6 +140,10 @@ public:
* Basic functions * Basic functions
*/ */
bool begin(const char* pin = NULL) {
return init(pin);
}
bool init(const char* pin = NULL) { bool init(const char* pin = NULL) {
DBG(GF("### TinyGSM Version:"), TINYGSM_VERSION); DBG(GF("### TinyGSM Version:"), TINYGSM_VERSION);
if (!testAT()) { if (!testAT()) {
@@ -161,10 +165,6 @@ public:
return true; return true;
} }
bool begin(const char* pin = NULL) {
return init(pin);
}
String getModemName() { String getModemName() {
return "ESP8266"; return "ESP8266";
} }
@@ -289,6 +289,7 @@ TINY_GSM_MODEM_MAINTAIN_LISTEN()
/* /*
* WiFi functions * WiFi functions
*/ */
bool networkConnect(const char* ssid, const char* pwd) { bool networkConnect(const char* ssid, const char* pwd) {
sendAT(GF("+CWJAP_CUR=\""), ssid, GF("\",\""), pwd, GF("\"")); sendAT(GF("+CWJAP_CUR=\""), ssid, GF("\",\""), pwd, GF("\""));
if (waitResponse(30000L, GFP(GSM_OK), GF(GSM_NL "FAIL" GSM_NL)) != 1) { if (waitResponse(30000L, GFP(GSM_OK), GF(GSM_NL "FAIL" GSM_NL)) != 1) {

View File

@@ -12,6 +12,10 @@
//#define TINY_GSM_DEBUG Serial //#define TINY_GSM_DEBUG Serial
#if !defined(TINY_GSM_RX_BUFFER)
#define TINY_GSM_RX_BUFFER 256
#endif
#define TINY_GSM_MUX_COUNT 2 #define TINY_GSM_MUX_COUNT 2
#include <TinyGsmCommon.h> #include <TinyGsmCommon.h>
@@ -117,6 +121,10 @@ public:
* Basic functions * Basic functions
*/ */
bool begin(const char* pin = NULL) {
return init(pin);
}
bool init(const char* pin = NULL) { bool init(const char* pin = NULL) {
DBG(GF("### TinyGSM Version:"), TINYGSM_VERSION); DBG(GF("### TinyGSM Version:"), TINYGSM_VERSION);
if (!testAT()) { if (!testAT()) {
@@ -135,10 +143,6 @@ public:
return true; return true;
} }
bool begin(const char* pin = NULL) {
return init(pin);
}
String getModemName() { String getModemName() {
return "Neoway M590"; return "Neoway M590";
} }
@@ -254,6 +258,7 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
/* /*
* GPRS functions * GPRS functions
*/ */
bool gprsConnect(const char* apn, const char* user = NULL, const char* pwd = NULL) { bool gprsConnect(const char* apn, const char* user = NULL, const char* pwd = NULL) {
gprsDisconnect(); gprsDisconnect();

View File

@@ -13,6 +13,10 @@
//#define TINY_GSM_DEBUG Serial //#define TINY_GSM_DEBUG Serial
//#define TINY_GSM_USE_HEX //#define TINY_GSM_USE_HEX
#if !defined(TINY_GSM_RX_BUFFER)
#define TINY_GSM_RX_BUFFER 64
#endif
#define TINY_GSM_MUX_COUNT 6 #define TINY_GSM_MUX_COUNT 6
#include <TinyGsmCommon.h> #include <TinyGsmCommon.h>
@@ -152,6 +156,10 @@ public:
* Basic functions * Basic functions
*/ */
bool begin(const char* pin = NULL) {
return init(pin);
}
bool init(const char* pin = NULL) { bool init(const char* pin = NULL) {
DBG(GF("### TinyGSM Version:"), TINYGSM_VERSION); DBG(GF("### TinyGSM Version:"), TINYGSM_VERSION);
if (!testAT()) { if (!testAT()) {
@@ -170,10 +178,6 @@ public:
return true; return true;
} }
bool begin(const char* pin = NULL) {
return init(pin);
}
String getModemName() { String getModemName() {
return "Quectel M95"; return "Quectel M95";
} }
@@ -309,6 +313,7 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
/* /*
* GPRS functions * GPRS functions
*/ */
bool gprsConnect(const char* apn, const char* user = NULL, const char* pwd = NULL) { bool gprsConnect(const char* apn, const char* user = NULL, const char* pwd = NULL) {
gprsDisconnect(); gprsDisconnect();

View File

@@ -16,6 +16,10 @@
//#define TINY_GSM_DEBUG Serial //#define TINY_GSM_DEBUG Serial
//#define TINY_GSM_USE_HEX //#define TINY_GSM_USE_HEX
#if !defined(TINY_GSM_RX_BUFFER)
#define TINY_GSM_RX_BUFFER 64
#endif
#define TINY_GSM_MUX_COUNT 6 #define TINY_GSM_MUX_COUNT 6
#include <TinyGsmCommon.h> #include <TinyGsmCommon.h>
@@ -156,6 +160,10 @@ public:
* Basic functions * Basic functions
*/ */
bool begin(const char* pin = NULL) {
return init(pin);
}
bool init(const char* pin = NULL) { bool init(const char* pin = NULL) {
DBG(GF("### TinyGSM Version:"), TINYGSM_VERSION); DBG(GF("### TinyGSM Version:"), TINYGSM_VERSION);
if (!testAT()) { if (!testAT()) {
@@ -172,10 +180,6 @@ public:
return true; return true;
} }
bool begin(const char* pin = NULL) {
return init(pin);
}
String getModemName() { String getModemName() {
#if defined(TINY_GSM_MODEM_MC60) #if defined(TINY_GSM_MODEM_MC60)
return "Quectel MC60"; return "Quectel MC60";
@@ -315,6 +319,7 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
/* /*
* GPRS functions * GPRS functions
*/ */
bool gprsConnect(const char* apn, const char* user = NULL, const char* pwd = NULL) { bool gprsConnect(const char* apn, const char* user = NULL, const char* pwd = NULL) {
gprsDisconnect(); gprsDisconnect();

View File

@@ -165,6 +165,10 @@ public:
* Basic functions * Basic functions
*/ */
bool begin(const char* pin = NULL) {
return init(pin);
}
bool init(const char* pin = NULL) { bool init(const char* pin = NULL) {
DBG(GF("### TinyGSM Version:"), TINYGSM_VERSION); DBG(GF("### TinyGSM Version:"), TINYGSM_VERSION);
if (!testAT()) { if (!testAT()) {
@@ -179,10 +183,6 @@ public:
return true; return true;
} }
bool begin(const char* pin = NULL) {
return init(pin);
}
String getModemName() { String getModemName() {
return "SIMCom SIM7000"; return "SIMCom SIM7000";
} }
@@ -352,6 +352,7 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
/* /*
* GPRS functions * GPRS functions
*/ */
bool gprsConnect(const char* apn, const char* user = NULL, const char* pwd = NULL) { bool gprsConnect(const char* apn, const char* user = NULL, const char* pwd = NULL) {
gprsDisconnect(); gprsDisconnect();
@@ -656,6 +657,7 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
/* /*
* Time functions * Time functions
*/ */
String getGSMDateTime(TinyGSMDateTimeFormat format) { String getGSMDateTime(TinyGSMDateTimeFormat format) {
sendAT(GF("+CCLK?")); sendAT(GF("+CCLK?"));
if (waitResponse(2000L, GF(GSM_NL "+CCLK: \"")) != 1) { if (waitResponse(2000L, GF(GSM_NL "+CCLK: \"")) != 1) {
@@ -729,6 +731,7 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
/* /*
* Battery functions * Battery functions
*/ */
// Use: float vBatt = modem.getBattVoltage() / 1000.0; // Use: float vBatt = modem.getBattVoltage() / 1000.0;
uint16_t getBattVoltage() { uint16_t getBattVoltage() {
sendAT(GF("+CBC")); sendAT(GF("+CBC"));

View File

@@ -13,6 +13,10 @@
//#define TINY_GSM_DEBUG Serial //#define TINY_GSM_DEBUG Serial
//#define TINY_GSM_USE_HEX //#define TINY_GSM_USE_HEX
#if !defined(TINY_GSM_RX_BUFFER)
#define TINY_GSM_RX_BUFFER 64
#endif
#define TINY_GSM_MUX_COUNT 5 #define TINY_GSM_MUX_COUNT 5
#include <TinyGsmCommon.h> #include <TinyGsmCommon.h>
@@ -162,6 +166,10 @@ public:
* Basic functions * Basic functions
*/ */
bool begin(const char* pin = NULL) {
return init(pin);
}
bool init(const char* pin = NULL) { bool init(const char* pin = NULL) {
DBG(GF("### TinyGSM Version:"), TINYGSM_VERSION); DBG(GF("### TinyGSM Version:"), TINYGSM_VERSION);
if (!testAT()) { if (!testAT()) {
@@ -178,10 +186,6 @@ public:
return true; return true;
} }
bool begin(const char* pin = NULL) {
return init(pin);
}
String getModemName() { String getModemName() {
#if defined(TINY_GSM_MODEM_SIM800) #if defined(TINY_GSM_MODEM_SIM800)
return "SIMCom SIM800"; return "SIMCom SIM800";
@@ -339,6 +343,7 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
/* /*
* GPRS functions * GPRS functions
*/ */
bool gprsConnect(const char* apn, const char* user = NULL, const char* pwd = NULL) { bool gprsConnect(const char* apn, const char* user = NULL, const char* pwd = NULL) {
gprsDisconnect(); gprsDisconnect();
@@ -621,6 +626,7 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
/* /*
* Time functions * Time functions
*/ */
String getGSMDateTime(TinyGSMDateTimeFormat format) { String getGSMDateTime(TinyGSMDateTimeFormat format) {
sendAT(GF("+CCLK?")); sendAT(GF("+CCLK?"));
if (waitResponse(2000L, GF(GSM_NL "+CCLK: \"")) != 1) { if (waitResponse(2000L, GF(GSM_NL "+CCLK: \"")) != 1) {

View File

@@ -12,6 +12,10 @@
//#define TINY_GSM_DEBUG Serial //#define TINY_GSM_DEBUG Serial
#if !defined(TINY_GSM_RX_BUFFER)
#define TINY_GSM_RX_BUFFER 64
#endif
#define TINY_GSM_MUX_COUNT 7 #define TINY_GSM_MUX_COUNT 7
#include <TinyGsmCommon.h> #include <TinyGsmCommon.h>
@@ -181,6 +185,10 @@ public:
* Basic functions * Basic functions
*/ */
bool begin(const char* pin = NULL) {
return init(pin);
}
bool init(const char* pin = NULL) { bool init(const char* pin = NULL) {
DBG(GF("### TinyGSM Version:"), TINYGSM_VERSION); DBG(GF("### TinyGSM Version:"), TINYGSM_VERSION);
if (!testAT()) { if (!testAT()) {
@@ -212,10 +220,6 @@ public:
} }
} }
bool begin(const char* pin = NULL) {
return init(pin);
}
String getModemName() { String getModemName() {
sendAT(GF("+CGMI")); sendAT(GF("+CGMI"));
String res1; String res1;

View File

@@ -194,6 +194,10 @@ public:
* Basic functions * Basic functions
*/ */
bool begin(const char* pin = NULL) {
return init(pin);
}
bool init(const char* pin = NULL) { bool init(const char* pin = NULL) {
DBG(GF("### TinyGSM Version:"), TINYGSM_VERSION); DBG(GF("### TinyGSM Version:"), TINYGSM_VERSION);
if (!testAT()) { if (!testAT()) {
@@ -207,10 +211,6 @@ public:
return true; return true;
} }
bool begin(const char* pin = NULL) {
return init(pin);
}
String getModemName() { String getModemName() {
return "Sequans Monarch"; return "Sequans Monarch";
} }
@@ -361,6 +361,7 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
/* /*
* GPRS functions * GPRS functions
*/ */
bool gprsConnect(const char* apn, const char* user = NULL, const char* pwd = NULL) { bool gprsConnect(const char* apn, const char* user = NULL, const char* pwd = NULL) {
gprsDisconnect(); gprsDisconnect();

View File

@@ -12,6 +12,10 @@
//#define TINY_GSM_DEBUG Serial //#define TINY_GSM_DEBUG Serial
#if !defined(TINY_GSM_RX_BUFFER)
#define TINY_GSM_RX_BUFFER 64
#endif
#define TINY_GSM_MUX_COUNT 7 #define TINY_GSM_MUX_COUNT 7
#include <TinyGsmCommon.h> #include <TinyGsmCommon.h>
@@ -165,6 +169,10 @@ public:
* Basic functions * Basic functions
*/ */
bool begin(const char* pin = NULL) {
return init(pin);
}
bool init(const char* pin = NULL) { bool init(const char* pin = NULL) {
DBG(GF("### TinyGSM Version:"), TINYGSM_VERSION); DBG(GF("### TinyGSM Version:"), TINYGSM_VERSION);
if (!testAT()) { if (!testAT()) {
@@ -196,10 +204,6 @@ public:
} }
} }
bool begin(const char* pin = NULL) {
return init(pin);
}
String getModemName() { String getModemName() {
sendAT(GF("+CGMI")); sendAT(GF("+CGMI"));
String res1; String res1;

View File

@@ -282,6 +282,10 @@ public:
* Basic functions * Basic functions
*/ */
bool begin(const char* pin = NULL) {
return init(pin);
}
bool init(const char* pin = NULL) { bool init(const char* pin = NULL) {
DBG(GF("### TinyGSM Version:"), TINYGSM_VERSION); DBG(GF("### TinyGSM Version:"), TINYGSM_VERSION);
@@ -307,10 +311,6 @@ public:
return ret_val; return ret_val;
} }
bool begin(const char* pin = NULL) {
return init(pin);
}
String getModemName() { String getModemName() {
return getBeeName(); return getBeeName();
} }
@@ -672,6 +672,7 @@ public:
/* /*
* WiFi functions * WiFi functions
*/ */
bool networkConnect(const char* ssid, const char* pwd) { bool networkConnect(const char* ssid, const char* pwd) {
if (!commandMode()) return false; // return immediately if (!commandMode()) return false; // return immediately
@@ -730,6 +731,7 @@ public:
/* /*
* GPRS functions * GPRS functions
*/ */
bool gprsConnect(const char* apn, const char* user = NULL, const char* pwd = NULL) { bool gprsConnect(const char* apn, const char* user = NULL, const char* pwd = NULL) {
if (!commandMode()) return false; // Return immediately if (!commandMode()) return false; // Return immediately
sendAT(GF("AN"), apn); // Set the APN sendAT(GF("AN"), apn); // Set the APN

View File

@@ -34,10 +34,6 @@
#define TINY_GSM_YIELD() { delay(0); } #define TINY_GSM_YIELD() { delay(0); }
#endif #endif
#if !defined(TINY_GSM_RX_BUFFER)
#define TINY_GSM_RX_BUFFER 64
#endif
#define TINY_GSM_ATTR_NOT_AVAILABLE __attribute__((error("Not available on this modem type"))) #define TINY_GSM_ATTR_NOT_AVAILABLE __attribute__((error("Not available on this modem type")))
#define TINY_GSM_ATTR_NOT_IMPLEMENTED __attribute__((error("Not implemented"))) #define TINY_GSM_ATTR_NOT_IMPLEMENTED __attribute__((error("Not implemented")))