diff --git a/examples/AllFunctions/AllFunctions.ino b/examples/AllFunctions/AllFunctions.ino index e1376ce..573222d 100644 --- a/examples/AllFunctions/AllFunctions.ino +++ b/examples/AllFunctions/AllFunctions.ino @@ -13,6 +13,8 @@ #define TINY_GSM_MODEM_SIM800 // #define TINY_GSM_MODEM_SIM808 // #define TINY_GSM_MODEM_SIM900 +// #define TINY_GSM_MODEM_UBLOX +// #define TINY_GSM_MODEM_BG96 // #define TINY_GSM_MODEM_A6 // #define TINY_GSM_MODEM_A7 // #define TINY_GSM_MODEM_M590 @@ -123,7 +125,8 @@ void loop() { } #endif - bool res; + bool res = modem.isGprsConnected(); + DBG("GPRS status:", res ? "connected" : "not connected"); String ccid = modem.getSimCCID(); DBG("CCID:", ccid); diff --git a/examples/BlynkClient/BlynkClient.ino b/examples/BlynkClient/BlynkClient.ino index 821e8b4..d3d7ce3 100644 --- a/examples/BlynkClient/BlynkClient.ino +++ b/examples/BlynkClient/BlynkClient.ino @@ -32,6 +32,8 @@ #define TINY_GSM_MODEM_SIM800 // #define TINY_GSM_MODEM_SIM808 // #define TINY_GSM_MODEM_SIM900 +// #define TINY_GSM_MODEM_UBLOX +// #define TINY_GSM_MODEM_BG96 // #define TINY_GSM_MODEM_A6 // #define TINY_GSM_MODEM_A7 // #define TINY_GSM_MODEM_M590 diff --git a/examples/FileDownload/FileDownload.ino b/examples/FileDownload/FileDownload.ino index f7eecc3..19c73a6 100644 --- a/examples/FileDownload/FileDownload.ino +++ b/examples/FileDownload/FileDownload.ino @@ -17,6 +17,8 @@ #define TINY_GSM_MODEM_SIM800 // #define TINY_GSM_MODEM_SIM808 // #define TINY_GSM_MODEM_SIM900 +// #define TINY_GSM_MODEM_UBLOX +// #define TINY_GSM_MODEM_BG96 // #define TINY_GSM_MODEM_A6 // #define TINY_GSM_MODEM_A7 // #define TINY_GSM_MODEM_M590 diff --git a/examples/HttpClient/HttpClient.ino b/examples/HttpClient/HttpClient.ino index c52a664..95b3453 100644 --- a/examples/HttpClient/HttpClient.ino +++ b/examples/HttpClient/HttpClient.ino @@ -18,6 +18,8 @@ #define TINY_GSM_MODEM_SIM800 // #define TINY_GSM_MODEM_SIM808 // #define TINY_GSM_MODEM_SIM900 +// #define TINY_GSM_MODEM_UBLOX +// #define TINY_GSM_MODEM_BG96 // #define TINY_GSM_MODEM_A6 // #define TINY_GSM_MODEM_A7 // #define TINY_GSM_MODEM_M590 diff --git a/examples/HttpsClient/HttpsClient.ino b/examples/HttpsClient/HttpsClient.ino index 73cd3be..bd892d7 100644 --- a/examples/HttpsClient/HttpsClient.ino +++ b/examples/HttpsClient/HttpsClient.ino @@ -10,7 +10,8 @@ * TinyGSM Getting Started guide: * http://tiny.cc/tiny-gsm-readme * - * SSL/TLS is currently supported only with SIM8xx series + * SSL/TLS is currently supported only with: SIM8xx, uBlox + * * For more HTTP API examples, see ArduinoHttpClient library * **************************************************************/ @@ -18,6 +19,7 @@ // Select your modem: #define TINY_GSM_MODEM_SIM800 // #define TINY_GSM_MODEM_SIM808 +// #define TINY_GSM_MODEM_UBLOX // Increase RX buffer if needed //#define TINY_GSM_RX_BUFFER 512 diff --git a/examples/MqttClient/MqttClient.ino b/examples/MqttClient/MqttClient.ino index b398d15..da5933a 100644 --- a/examples/MqttClient/MqttClient.ino +++ b/examples/MqttClient/MqttClient.ino @@ -31,6 +31,8 @@ #define TINY_GSM_MODEM_SIM800 // #define TINY_GSM_MODEM_SIM808 // #define TINY_GSM_MODEM_SIM900 +// #define TINY_GSM_MODEM_UBLOX +// #define TINY_GSM_MODEM_BG96 // #define TINY_GSM_MODEM_A6 // #define TINY_GSM_MODEM_A7 // #define TINY_GSM_MODEM_M590 @@ -119,7 +121,14 @@ void setup() { boolean mqttConnect() { SerialMon.print("Connecting to "); SerialMon.print(broker); - if (!mqtt.connect("GsmClientTest")) { + + // Connect to MQTT Broker + boolean status = mqtt.connect("GsmClientTest"); + + // Or, if you want to authenticate MQTT: + //boolean status = mqtt.connect("GsmClientName", "mqtt_user", "mqtt_pass"); + + if (status == false) { SerialMon.println(" fail"); return false; } @@ -131,9 +140,8 @@ boolean mqttConnect() { void loop() { - if (mqtt.connected()) { - mqtt.loop(); - } else { + if (!mqtt.connected()) { + SerialMon.println("=== MQTT NOT CONNECTED ==="); // Reconnect every 10 seconds unsigned long t = millis(); if (t - lastReconnectAttempt > 10000L) { @@ -142,8 +150,11 @@ void loop() { lastReconnectAttempt = 0; } } + delay(100); + return; } + mqtt.loop(); } void mqttCallback(char* topic, byte* payload, unsigned int len) { diff --git a/examples/WebClient/WebClient.ino b/examples/WebClient/WebClient.ino index 5fa5111..e1127fd 100644 --- a/examples/WebClient/WebClient.ino +++ b/examples/WebClient/WebClient.ino @@ -12,6 +12,8 @@ #define TINY_GSM_MODEM_SIM800 // #define TINY_GSM_MODEM_SIM808 // #define TINY_GSM_MODEM_SIM900 +// #define TINY_GSM_MODEM_UBLOX +// #define TINY_GSM_MODEM_BG96 // #define TINY_GSM_MODEM_A6 // #define TINY_GSM_MODEM_A7 // #define TINY_GSM_MODEM_M590 diff --git a/library.json b/library.json index e858420..c63718e 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "TinyGSM", - "version": "0.3.40", + "version": "0.3.50", "description": "A small Arduino library for GPRS modules, that just works. Includes examples for Blynk, MQTT, File Download, and Web Client. Supports GSM modules with AT command interface: SIM800, SIM800A, SIM800C, SIM800L, SIM800H, SIM808, SIM868, SIM900, SIM900A, SIM900D, SIM908, SIM968, Quectel M95", "keywords": "GSM, AT commands, AT, SIM800, SIM900, A6, A7, M590, ESP8266, SIM800A, SIM800C, SIM800L, SIM800H, SIM808, SIM868, SIM900A, SIM900D, SIM908, SIM968, M95", "authors": diff --git a/library.properties b/library.properties index cc1dd21..63af60b 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=TinyGSM -version=0.3.40 +version=0.3.50 author=Volodymyr Shymanskyy maintainer=Volodymyr Shymanskyy sentence=A small Arduino library for GPRS modules, that just works. diff --git a/src/TinyGsmClientA6.h b/src/TinyGsmClientA6.h index 64ab6f1..7a6f6ba 100644 --- a/src/TinyGsmClientA6.h +++ b/src/TinyGsmClientA6.h @@ -49,7 +49,7 @@ class TinyGsmA6 //============================================================================// //============================================================================// -// The A6 Internal Client Class +// The Internal A6 Client Class //============================================================================// //============================================================================// @@ -120,6 +120,11 @@ public: return write(&c, 1); } + virtual size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual int available() { TINY_GSM_YIELD(); if (!rx.size() && sock_connected) { diff --git a/src/TinyGsmClientBG96.h b/src/TinyGsmClientBG96.h index 0772ff2..461f378 100644 --- a/src/TinyGsmClientBG96.h +++ b/src/TinyGsmClientBG96.h @@ -50,7 +50,7 @@ class TinyGsmBG96 //============================================================================// //============================================================================// -// The BG96 Internal Client Class +// The Internal BG96 Client Class //============================================================================// //============================================================================// @@ -120,6 +120,11 @@ public: return write(&c, 1); } + virtual size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual int available() { TINY_GSM_YIELD(); if (!rx.size()) { diff --git a/src/TinyGsmClientESP8266.h b/src/TinyGsmClientESP8266.h index 90c534f..e6cfaa4 100644 --- a/src/TinyGsmClientESP8266.h +++ b/src/TinyGsmClientESP8266.h @@ -117,6 +117,11 @@ public: return write(&c, 1); } + virtual size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual int available() { TINY_GSM_YIELD(); if (!rx.size() && sock_connected) { diff --git a/src/TinyGsmClientM590.h b/src/TinyGsmClientM590.h index eacccbc..9889180 100644 --- a/src/TinyGsmClientM590.h +++ b/src/TinyGsmClientM590.h @@ -118,6 +118,11 @@ public: return write(&c, 1); } + virtual size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual int available() { TINY_GSM_YIELD(); if (!rx.size() && sock_connected) { diff --git a/src/TinyGsmClientSIM800.h b/src/TinyGsmClientSIM800.h index 963f316..c696516 100644 --- a/src/TinyGsmClientSIM800.h +++ b/src/TinyGsmClientSIM800.h @@ -50,7 +50,7 @@ class TinyGsmSim800 //============================================================================// //============================================================================// -// The Sim800 Internal Client Class +// The Internal SIM800 Client Class //============================================================================// //============================================================================// @@ -121,6 +121,11 @@ public: return write(&c, 1); } + virtual size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual int available() { TINY_GSM_YIELD(); if (!rx.size() && sock_connected) { @@ -337,6 +342,7 @@ public: return false; } //Enable Local Time Stamp for getting network time + // TODO: Find a better place for this sendAT(GF("+CLTS=1")); if (waitResponse(10000L) != 1) { return false; diff --git a/src/TinyGsmClientUBLOX.h b/src/TinyGsmClientUBLOX.h index 14e1450..c91ed98 100644 --- a/src/TinyGsmClientUBLOX.h +++ b/src/TinyGsmClientUBLOX.h @@ -118,6 +118,11 @@ public: return write(&c, 1); } + virtual size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual int available() { TINY_GSM_YIELD(); if (!rx.size() && sock_connected) { diff --git a/src/TinyGsmClientXBee.h b/src/TinyGsmClientXBee.h index b823726..b8832b9 100644 --- a/src/TinyGsmClientXBee.h +++ b/src/TinyGsmClientXBee.h @@ -136,6 +136,11 @@ public: return write(&c, 1); } + virtual size_t write(const char *str) { + if (str == NULL) return 0; + return write((const uint8_t *)str, strlen(str)); + } + virtual int available() { TINY_GSM_YIELD(); return at->stream.available(); diff --git a/tools/AT_Debug/AT_Debug.ino b/tools/AT_Debug/AT_Debug.ino index 878d7d2..e8e985d 100644 --- a/tools/AT_Debug/AT_Debug.ino +++ b/tools/AT_Debug/AT_Debug.ino @@ -12,6 +12,8 @@ #define TINY_GSM_MODEM_SIM800 // #define TINY_GSM_MODEM_SIM808 // #define TINY_GSM_MODEM_SIM900 +// #define TINY_GSM_MODEM_UBLOX +// #define TINY_GSM_MODEM_BG96 // #define TINY_GSM_MODEM_A6 // #define TINY_GSM_MODEM_A7 // #define TINY_GSM_MODEM_M590 diff --git a/tools/Diagnostics/Diagnostics.ino b/tools/Diagnostics/Diagnostics.ino index 38d3ffa..a57f2b8 100644 --- a/tools/Diagnostics/Diagnostics.ino +++ b/tools/Diagnostics/Diagnostics.ino @@ -14,6 +14,7 @@ // #define TINY_GSM_MODEM_SIM808 // #define TINY_GSM_MODEM_SIM900 // #define TINY_GSM_MODEM_UBLOX +// #define TINY_GSM_MODEM_BG96 // #define TINY_GSM_MODEM_A6 // #define TINY_GSM_MODEM_A7 // #define TINY_GSM_MODEM_M590 @@ -56,6 +57,7 @@ const char resource[] = "/TinyGSM/logo.txt"; const int port = 80; TinyGsmClient client(modem); +// For SSL: //const int port = 443; //TinyGsmClientSecure client(modem); @@ -155,7 +157,7 @@ void loop() { while (client.connected() && millis() - timeout < 10000L) { while (client.available()) { char c = client.read(); - SerialMon.print(c); + //SerialMon.print(c); bytesReceived += 1; timeout = millis(); } diff --git a/tools/FactoryReset/FactoryReset.ino b/tools/FactoryReset/FactoryReset.ino index 305c67c..1570cfc 100644 --- a/tools/FactoryReset/FactoryReset.ino +++ b/tools/FactoryReset/FactoryReset.ino @@ -13,6 +13,8 @@ #define TINY_GSM_MODEM_SIM800 // #define TINY_GSM_MODEM_SIM808 // #define TINY_GSM_MODEM_SIM900 +// #define TINY_GSM_MODEM_UBLOX +// #define TINY_GSM_MODEM_BG96 // #define TINY_GSM_MODEM_A6 // #define TINY_GSM_MODEM_A7 // #define TINY_GSM_MODEM_M590