Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Michael Krumpus
2018-11-02 13:52:11 -05:00
19 changed files with 80 additions and 50 deletions

View File

@@ -13,6 +13,8 @@
#define TINY_GSM_MODEM_SIM800 #define TINY_GSM_MODEM_SIM800
// #define TINY_GSM_MODEM_SIM808 // #define TINY_GSM_MODEM_SIM808
// #define TINY_GSM_MODEM_SIM900 // #define TINY_GSM_MODEM_SIM900
// #define TINY_GSM_MODEM_UBLOX
// #define TINY_GSM_MODEM_BG96
// #define TINY_GSM_MODEM_A6 // #define TINY_GSM_MODEM_A6
// #define TINY_GSM_MODEM_A7 // #define TINY_GSM_MODEM_A7
// #define TINY_GSM_MODEM_M590 // #define TINY_GSM_MODEM_M590
@@ -97,7 +99,8 @@ void loop() {
return; return;
} }
bool res; bool res = modem.isGprsConnected();
DBG("GPRS status:", res ? "connected" : "not connected");
String ccid = modem.getSimCCID(); String ccid = modem.getSimCCID();
DBG("CCID:", ccid); DBG("CCID:", ccid);

View File

@@ -32,6 +32,8 @@
#define TINY_GSM_MODEM_SIM800 #define TINY_GSM_MODEM_SIM800
// #define TINY_GSM_MODEM_SIM808 // #define TINY_GSM_MODEM_SIM808
// #define TINY_GSM_MODEM_SIM900 // #define TINY_GSM_MODEM_SIM900
// #define TINY_GSM_MODEM_UBLOX
// #define TINY_GSM_MODEM_BG96
// #define TINY_GSM_MODEM_A6 // #define TINY_GSM_MODEM_A6
// #define TINY_GSM_MODEM_A7 // #define TINY_GSM_MODEM_A7
// #define TINY_GSM_MODEM_M590 // #define TINY_GSM_MODEM_M590

View File

@@ -17,6 +17,8 @@
#define TINY_GSM_MODEM_SIM800 #define TINY_GSM_MODEM_SIM800
// #define TINY_GSM_MODEM_SIM808 // #define TINY_GSM_MODEM_SIM808
// #define TINY_GSM_MODEM_SIM900 // #define TINY_GSM_MODEM_SIM900
// #define TINY_GSM_MODEM_UBLOX
// #define TINY_GSM_MODEM_BG96
// #define TINY_GSM_MODEM_A6 // #define TINY_GSM_MODEM_A6
// #define TINY_GSM_MODEM_A7 // #define TINY_GSM_MODEM_A7
// #define TINY_GSM_MODEM_M590 // #define TINY_GSM_MODEM_M590

View File

@@ -18,6 +18,8 @@
#define TINY_GSM_MODEM_SIM800 #define TINY_GSM_MODEM_SIM800
// #define TINY_GSM_MODEM_SIM808 // #define TINY_GSM_MODEM_SIM808
// #define TINY_GSM_MODEM_SIM900 // #define TINY_GSM_MODEM_SIM900
// #define TINY_GSM_MODEM_UBLOX
// #define TINY_GSM_MODEM_BG96
// #define TINY_GSM_MODEM_A6 // #define TINY_GSM_MODEM_A6
// #define TINY_GSM_MODEM_A7 // #define TINY_GSM_MODEM_A7
// #define TINY_GSM_MODEM_M590 // #define TINY_GSM_MODEM_M590

View File

@@ -10,7 +10,8 @@
* TinyGSM Getting Started guide: * TinyGSM Getting Started guide:
* http://tiny.cc/tiny-gsm-readme * 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 * For more HTTP API examples, see ArduinoHttpClient library
* *
**************************************************************/ **************************************************************/
@@ -18,6 +19,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_UBLOX
// Increase RX buffer if needed // Increase RX buffer if needed
//#define TINY_GSM_RX_BUFFER 512 //#define TINY_GSM_RX_BUFFER 512

View File

@@ -31,6 +31,8 @@
#define TINY_GSM_MODEM_SIM800 #define TINY_GSM_MODEM_SIM800
// #define TINY_GSM_MODEM_SIM808 // #define TINY_GSM_MODEM_SIM808
// #define TINY_GSM_MODEM_SIM900 // #define TINY_GSM_MODEM_SIM900
// #define TINY_GSM_MODEM_UBLOX
// #define TINY_GSM_MODEM_BG96
// #define TINY_GSM_MODEM_A6 // #define TINY_GSM_MODEM_A6
// #define TINY_GSM_MODEM_A7 // #define TINY_GSM_MODEM_A7
// #define TINY_GSM_MODEM_M590 // #define TINY_GSM_MODEM_M590
@@ -119,7 +121,14 @@ void setup() {
boolean mqttConnect() { boolean mqttConnect() {
SerialMon.print("Connecting to "); SerialMon.print("Connecting to ");
SerialMon.print(broker); 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"); SerialMon.println(" fail");
return false; return false;
} }
@@ -131,9 +140,8 @@ boolean mqttConnect() {
void loop() { void loop() {
if (mqtt.connected()) { if (!mqtt.connected()) {
mqtt.loop(); SerialMon.println("=== MQTT NOT CONNECTED ===");
} else {
// Reconnect every 10 seconds // Reconnect every 10 seconds
unsigned long t = millis(); unsigned long t = millis();
if (t - lastReconnectAttempt > 10000L) { if (t - lastReconnectAttempt > 10000L) {
@@ -142,8 +150,11 @@ void loop() {
lastReconnectAttempt = 0; lastReconnectAttempt = 0;
} }
} }
delay(100);
return;
} }
mqtt.loop();
} }
void mqttCallback(char* topic, byte* payload, unsigned int len) { void mqttCallback(char* topic, byte* payload, unsigned int len) {

View File

@@ -12,6 +12,8 @@
#define TINY_GSM_MODEM_SIM800 #define TINY_GSM_MODEM_SIM800
// #define TINY_GSM_MODEM_SIM808 // #define TINY_GSM_MODEM_SIM808
// #define TINY_GSM_MODEM_SIM900 // #define TINY_GSM_MODEM_SIM900
// #define TINY_GSM_MODEM_UBLOX
// #define TINY_GSM_MODEM_BG96
// #define TINY_GSM_MODEM_A6 // #define TINY_GSM_MODEM_A6
// #define TINY_GSM_MODEM_A7 // #define TINY_GSM_MODEM_A7
// #define TINY_GSM_MODEM_M590 // #define TINY_GSM_MODEM_M590

View File

@@ -1,6 +1,6 @@
{ {
"name": "TinyGSM", "name": "TinyGSM",
"version": "0.3.3", "version": "0.3.5",
"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", "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",
"keywords": "GSM, AT commands, AT, SIM800, SIM900, A6, A7, M590, ESP8266, SIM800A, SIM800C, SIM800L, SIM800H, SIM808, SIM868, SIM900A, SIM900D, SIM908, SIM968", "keywords": "GSM, AT commands, AT, SIM800, SIM900, A6, A7, M590, ESP8266, SIM800A, SIM800C, SIM800L, SIM800H, SIM808, SIM868, SIM900A, SIM900D, SIM908, SIM968",
"authors": "authors":

View File

@@ -1,5 +1,5 @@
name=TinyGSM name=TinyGSM
version=0.3.3 version=0.3.5
author=Volodymyr Shymanskyy author=Volodymyr Shymanskyy
maintainer=Volodymyr Shymanskyy maintainer=Volodymyr Shymanskyy
sentence=A small Arduino library for GPRS modules, that just works. sentence=A small Arduino library for GPRS modules, that just works.

View File

@@ -120,6 +120,11 @@ public:
return write(&c, 1); 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() { virtual int available() {
TINY_GSM_YIELD(); TINY_GSM_YIELD();
if (!rx.size() && sock_connected) { if (!rx.size() && sock_connected) {

View File

@@ -120,6 +120,11 @@ public:
return write(&c, 1); 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() { virtual int available() {
TINY_GSM_YIELD(); TINY_GSM_YIELD();
if (!rx.size()) { if (!rx.size()) {

View File

@@ -117,6 +117,11 @@ public:
return write(&c, 1); 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() { virtual int available() {
TINY_GSM_YIELD(); TINY_GSM_YIELD();
if (!rx.size() && sock_connected) { if (!rx.size() && sock_connected) {

View File

@@ -118,6 +118,11 @@ public:
return write(&c, 1); 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() { virtual int available() {
TINY_GSM_YIELD(); TINY_GSM_YIELD();
if (!rx.size() && sock_connected) { if (!rx.size() && sock_connected) {

View File

@@ -45,22 +45,9 @@ enum TinyGSMDateTimeFormat {
DATE_DATE = 2 DATE_DATE = 2
}; };
//============================================================================//
//============================================================================//
// Declaration of the TinyGsmSim800 Class
//============================================================================//
//============================================================================//
class TinyGsmSim800 class TinyGsmSim800
{ {
//============================================================================//
//============================================================================//
// The Sim800 Internal Client Class
//============================================================================//
//============================================================================//
public: public:
class GsmClient : public Client class GsmClient : public Client
@@ -127,6 +114,11 @@ public:
return write(&c, 1); 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() { virtual int available() {
TINY_GSM_YIELD(); TINY_GSM_YIELD();
if (!rx.size() && sock_connected) { if (!rx.size() && sock_connected) {
@@ -200,13 +192,6 @@ private:
RxFifo rx; RxFifo rx;
}; };
//============================================================================//
//============================================================================//
// The SIM800 Secure Client
//============================================================================//
//============================================================================//
class GsmClientSecure : public GsmClient class GsmClientSecure : public GsmClient
{ {
public: public:
@@ -226,19 +211,9 @@ public:
} }
}; };
//============================================================================//
//============================================================================//
// The SIM800 Modem Functions
//============================================================================//
//============================================================================//
public: public:
#ifdef GSM_DEFAULT_STREAM
TinyGsmSim800(Stream& stream = GSM_DEFAULT_STREAM)
#else
TinyGsmSim800(Stream& stream) TinyGsmSim800(Stream& stream)
#endif
: stream(stream) : stream(stream)
{ {
memset(sockets, 0, sizeof(sockets)); memset(sockets, 0, sizeof(sockets));
@@ -343,6 +318,7 @@ public:
return false; return false;
} }
//Enable Local Time Stamp for getting network time //Enable Local Time Stamp for getting network time
// TODO: Find a better place for this
sendAT(GF("+CLTS=1")); sendAT(GF("+CLTS=1"));
if (waitResponse(10000L) != 1) { if (waitResponse(10000L) != 1) {
return false; return false;
@@ -486,10 +462,6 @@ public:
return false; return false;
} }
/*
* WiFi functions
*/
/* /*
* GPRS functions * GPRS functions
*/ */
@@ -926,8 +898,7 @@ public:
streamWrite(tail...); streamWrite(tail...);
} }
bool streamSkipUntil(char c) { bool streamSkipUntil(const char c, const unsigned long timeout = 3000L) {
const unsigned long timeout = 1000L;
unsigned long startMillis = millis(); unsigned long startMillis = millis();
while (millis() - startMillis < timeout) { while (millis() - startMillis < timeout) {
while (millis() - startMillis < timeout && !stream.available()) { while (millis() - startMillis < timeout && !stream.available()) {
@@ -1013,7 +984,6 @@ finish:
} }
data = ""; data = "";
} }
//DBG('<', index, '>');
return index; return index;
} }

View File

@@ -118,6 +118,11 @@ public:
return write(&c, 1); 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() { virtual int available() {
TINY_GSM_YIELD(); TINY_GSM_YIELD();
if (!rx.size() && sock_connected) { if (!rx.size() && sock_connected) {

View File

@@ -136,6 +136,11 @@ public:
return write(&c, 1); 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() { virtual int available() {
TINY_GSM_YIELD(); TINY_GSM_YIELD();
return at->stream.available(); return at->stream.available();

View File

@@ -12,6 +12,8 @@
#define TINY_GSM_MODEM_SIM800 #define TINY_GSM_MODEM_SIM800
// #define TINY_GSM_MODEM_SIM808 // #define TINY_GSM_MODEM_SIM808
// #define TINY_GSM_MODEM_SIM900 // #define TINY_GSM_MODEM_SIM900
// #define TINY_GSM_MODEM_UBLOX
// #define TINY_GSM_MODEM_BG96
// #define TINY_GSM_MODEM_A6 // #define TINY_GSM_MODEM_A6
// #define TINY_GSM_MODEM_A7 // #define TINY_GSM_MODEM_A7
// #define TINY_GSM_MODEM_M590 // #define TINY_GSM_MODEM_M590

View File

@@ -14,6 +14,7 @@
// #define TINY_GSM_MODEM_SIM808 // #define TINY_GSM_MODEM_SIM808
// #define TINY_GSM_MODEM_SIM900 // #define TINY_GSM_MODEM_SIM900
// #define TINY_GSM_MODEM_UBLOX // #define TINY_GSM_MODEM_UBLOX
// #define TINY_GSM_MODEM_BG96
// #define TINY_GSM_MODEM_A6 // #define TINY_GSM_MODEM_A6
// #define TINY_GSM_MODEM_A7 // #define TINY_GSM_MODEM_A7
// #define TINY_GSM_MODEM_M590 // #define TINY_GSM_MODEM_M590
@@ -56,6 +57,7 @@ const char resource[] = "/TinyGSM/logo.txt";
const int port = 80; const int port = 80;
TinyGsmClient client(modem); TinyGsmClient client(modem);
// For SSL:
//const int port = 443; //const int port = 443;
//TinyGsmClientSecure client(modem); //TinyGsmClientSecure client(modem);
@@ -155,7 +157,7 @@ void loop() {
while (client.connected() && millis() - timeout < 10000L) { while (client.connected() && millis() - timeout < 10000L) {
while (client.available()) { while (client.available()) {
char c = client.read(); char c = client.read();
SerialMon.print(c); //SerialMon.print(c);
bytesReceived += 1; bytesReceived += 1;
timeout = millis(); timeout = millis();
} }

View File

@@ -13,6 +13,8 @@
#define TINY_GSM_MODEM_SIM800 #define TINY_GSM_MODEM_SIM800
// #define TINY_GSM_MODEM_SIM808 // #define TINY_GSM_MODEM_SIM808
// #define TINY_GSM_MODEM_SIM900 // #define TINY_GSM_MODEM_SIM900
// #define TINY_GSM_MODEM_UBLOX
// #define TINY_GSM_MODEM_BG96
// #define TINY_GSM_MODEM_A6 // #define TINY_GSM_MODEM_A6
// #define TINY_GSM_MODEM_A7 // #define TINY_GSM_MODEM_A7
// #define TINY_GSM_MODEM_M590 // #define TINY_GSM_MODEM_M590