Merge updates from original version

Conflicts:
	library.json
	library.properties
	src/TinyGsmClientA6.h
	src/TinyGsmClientESP8266.h
	src/TinyGsmClientM590.h
	src/TinyGsmClientSIM800.h
	src/TinyGsmClientU201.h
	src/TinyGsmClientXBee.h
This commit is contained in:
SRGDamia1
2018-03-15 16:47:43 -04:00
24 changed files with 737 additions and 258 deletions

View File

@@ -82,6 +82,7 @@ public:
public:
virtual int connect(const char *host, uint16_t port) {
stop();
TINY_GSM_YIELD();
rx.clear();
uint8_t newMux = -1;
@@ -110,6 +111,7 @@ public:
at->sendAT(GF("+CIPCLOSE="), mux);
sock_connected = false;
at->waitResponse();
rx.clear();
}
virtual size_t write(const uint8_t *buf, size_t size) {
@@ -252,9 +254,7 @@ public:
}
void maintain() {
//while (stream.available()) {
waitResponse(10, NULL, NULL);
//}
waitResponse(10, NULL, NULL);
}
bool factoryDefault() {
@@ -276,7 +276,9 @@ public:
return res;
}
bool hasSSL() { return false; }
bool hasSSL() {
return false;
}
/*
* Power functions
@@ -427,7 +429,7 @@ public:
/*
* GPRS functions
*/
bool gprsConnect(const char* apn, const char* user, const char* pwd) {
bool gprsConnect(const char* apn, const char* user = NULL, const char* pwd = NULL) {
gprsDisconnect();
sendAT(GF("+CGATT=1"));
@@ -458,8 +460,10 @@ public:
}
bool gprsDisconnect() {
// Shut the TCP/IP connection
sendAT(GF("+CIPSHUT"));
waitResponse(5000L);
if (waitResponse(60000L) != 1)
return false;
for (int i = 0; i<3; i++) {
sendAT(GF("+CGATT=0"));
@@ -572,12 +576,12 @@ protected:
int modemSend(const void* buff, size_t len, uint8_t mux) {
sendAT(GF("+CIPSEND="), mux, ',', len);
if (waitResponse(2000L, GF(GSM_NL ">")) != 1) {
return -1;
return 0;
}
stream.write((uint8_t*)buff, len);
stream.flush();
if (waitResponse(10000L, GFP(GSM_OK), GF(GSM_NL "FAIL")) != 1) {
return -1;
return 0;
}
return len;
}
@@ -713,8 +717,10 @@ finish:
return waitResponse(1000, r1, r2, r3, r4, r5);
}
protected:
public:
Stream& stream;
protected:
GsmClient* sockets[TINY_GSM_MUX_COUNT];
};

View File

@@ -80,6 +80,7 @@ public:
public:
virtual int connect(const char *host, uint16_t port) {
stop();
TINY_GSM_YIELD();
rx.clear();
sock_connected = at->modemConnect(host, port, mux);
@@ -103,6 +104,7 @@ public:
at->sendAT(GF("+CIPCLOSE="), mux);
sock_connected = false;
at->waitResponse();
rx.clear();
}
virtual size_t write(const uint8_t *buf, size_t size) {
@@ -194,6 +196,7 @@ public:
public:
virtual int connect(const char *host, uint16_t port) {
stop();
TINY_GSM_YIELD();
rx.clear();
sock_connected = at->modemConnect(host, port, mux, true);
@@ -255,7 +258,7 @@ public:
}
void maintain() {
waitResponse(10, NULL, NULL);
waitResponse(10, NULL, NULL);
}
bool factoryDefault() {
@@ -443,12 +446,12 @@ protected:
int modemSend(const void* buff, size_t len, uint8_t mux) {
sendAT(GF("+CIPSEND="), mux, ',', len);
if (waitResponse(GF(">")) != 1) {
return -1;
return 0;
}
stream.write((uint8_t*)buff, len);
stream.flush();
if (waitResponse(10000L, GF(GSM_NL "SEND OK" GSM_NL)) != 1) {
return -1;
return 0;
}
return len;
}
@@ -584,8 +587,10 @@ finish:
return waitResponse(1000, r1, r2, r3, r4, r5);
}
protected:
public:
Stream& stream;
protected:
GsmClient* sockets[TINY_GSM_MUX_COUNT];
};

View File

@@ -80,6 +80,7 @@ public:
public:
virtual int connect(const char *host, uint16_t port) {
stop();
TINY_GSM_YIELD();
rx.clear();
sock_connected = at->modemConnect(host, port, mux);
@@ -103,6 +104,7 @@ public:
at->sendAT(GF("+TCPCLOSE="), mux);
sock_connected = false;
at->waitResponse();
rx.clear();
}
virtual size_t write(const uint8_t *buf, size_t size) {
@@ -273,7 +275,9 @@ public:
return res;
}
bool hasSSL() { return false; }
bool hasSSL() {
return false;
}
/*
* Power functions
@@ -428,7 +432,7 @@ public:
/*
* GPRS functions
*/
bool gprsConnect(const char* apn, const char* user = "", const char* pwd = "") {
bool gprsConnect(const char* apn, const char* user = NULL, const char* pwd = NULL) {
gprsDisconnect();
sendAT(GF("+XISP=0"));
@@ -724,8 +728,10 @@ finish:
return waitResponse(1000, r1, r2, r3, r4, r5);
}
protected:
public:
Stream& stream;
protected:
GsmClient* sockets[TINY_GSM_MUX_COUNT];
};

View File

@@ -85,6 +85,7 @@ public:
public:
virtual int connect(const char *host, uint16_t port) {
stop();
TINY_GSM_YIELD();
rx.clear();
sock_connected = at->modemConnect(host, port, mux);
@@ -108,6 +109,7 @@ public:
at->sendAT(GF("+CIPCLOSE="), mux);
sock_connected = false;
at->waitResponse();
rx.clear();
}
virtual size_t write(const uint8_t *buf, size_t size) {
@@ -211,6 +213,7 @@ public:
public:
virtual int connect(const char *host, uint16_t port) {
stop();
TINY_GSM_YIELD();
rx.clear();
sock_connected = at->modemConnect(host, port, mux, true);
@@ -320,11 +323,15 @@ public:
}
bool hasSSL() {
#if defined(TINY_GSM_MODEM_SIM900)
return false;
#else
sendAT(GF("+CIPSSL=?"));
if (waitResponse(GF(GSM_NL "+CIPSSL:")) != 1) {
return false;
}
return waitResponse() == 1;
#endif
}
/*
@@ -495,7 +502,7 @@ public:
/*
* GPRS functions
*/
bool gprsConnect(const char* apn, const char* user = "", const char* pwd = "") {
bool gprsConnect(const char* apn, const char* user = NULL, const char* pwd = NULL) {
gprsDisconnect();
// Set the Bearer for the IP
@@ -583,7 +590,8 @@ public:
}
bool gprsDisconnect() {
sendAT(GF("+CIPSHUT")); // Shut the TCP/IP connection
// Shut the TCP/IP connection
sendAT(GF("+CIPSHUT"));
if (waitResponse(60000L) != 1)
return false;
@@ -644,6 +652,7 @@ public:
bool sendSMS(const String& number, const String& text) {
sendAT(GF("+CMGF=1"));
waitResponse();
//Set GSM 7 bit default alphabet (3GPP TS 23.038)
sendAT(GF("+CSCS=\"GSM\""));
waitResponse();
sendAT(GF("+CMGS=\""), number, GF("\""));
@@ -731,28 +740,33 @@ public:
protected:
bool modemConnect(const char* host, uint16_t port, uint8_t mux, bool ssl = false) {
#if !defined(TINY_GSM_MODEM_SIM900)
sendAT(GF("+CIPSSL="), ssl);
int rsp = waitResponse();
if (ssl && rsp != 1) {
return false;
}
#endif
sendAT(GF("+CIPSTART="), mux, ',', GF("\"TCP"), GF("\",\""), host, GF("\","), port);
rsp = waitResponse(75000L,
GF("CONNECT OK" GSM_NL),
GF("CONNECT FAIL" GSM_NL),
GF("ALREADY CONNECT" GSM_NL));
GF("ALREADY CONNECT" GSM_NL),
GF("ERROR" GSM_NL),
GF("CLOSE OK" GSM_NL) // Happens when HTTPS handshake fails
);
return (1 == rsp);
}
int modemSend(const void* buff, size_t len, uint8_t mux) {
sendAT(GF("+CIPSEND="), mux, ',', len);
if (waitResponse(GF(">")) != 1) {
return -1;
return 0;
}
stream.write((uint8_t*)buff, len);
stream.flush();
if (waitResponse(GF(GSM_NL "DATA ACCEPT:")) != 1) {
return -1;
return 0;
}
streamSkipUntil(','); // Skip mux
return stream.readStringUntil('\n').toInt();
@@ -934,8 +948,10 @@ finish:
return waitResponse(1000, r1, r2, r3, r4, r5);
}
protected:
public:
Stream& stream;
protected:
GsmClient* sockets[TINY_GSM_MUX_COUNT];
};

View File

@@ -81,6 +81,7 @@ public:
public:
virtual int connect(const char *host, uint16_t port) {
stop();
TINY_GSM_YIELD();
rx.clear();
sock_connected = at->modemConnect(host, port, &mux);
@@ -105,6 +106,7 @@ public:
at->sendAT(GF("+USOCL="), mux);
sock_connected = false;
at->waitResponse();
rx.clear();
}
virtual size_t write(const uint8_t *buf, size_t size) {
@@ -119,7 +121,7 @@ public:
virtual int available() {
TINY_GSM_YIELD();
if (!rx.size() && sock_connected) { // TODO
if (!rx.size() && sock_connected) {
at->maintain();
}
return rx.size() + sock_available;
@@ -200,6 +202,7 @@ public:
public:
virtual int connect(const char *host, uint16_t port) {
stop();
TINY_GSM_YIELD();
rx.clear();
sock_connected = at->modemConnect(host, port, &mux, true);
@@ -287,7 +290,9 @@ public:
String getModemInfo() TINY_GSM_ATTR_NOT_IMPLEMENTED;
bool hasSSL() { return true; }
bool hasSSL() {
return true;
}
/*
* Power functions
@@ -433,7 +438,7 @@ public:
/*
* GPRS functions
*/
bool gprsConnect(const char* apn, const char* user = "", const char* pwd = "") {
bool gprsConnect(const char* apn, const char* user = NULL, const char* pwd = NULL) {
gprsDisconnect();
sendAT(GF("+CGATT=1"));
@@ -732,8 +737,10 @@ finish:
return waitResponse(1000, r1, r2, r3, r4, r5);
}
protected:
public:
Stream& stream;
protected:
GsmClient* sockets[TINY_GSM_MUX_COUNT];
};

View File

@@ -9,7 +9,7 @@
#ifndef TinyGsmClientXBee_h
#define TinyGsmClientXBee_h
// #define TINY_GSM_DEBUG Serial
//#define TINY_GSM_DEBUG Serial
#define TINY_GSM_MUX_COUNT 1 // Multi-plexing isn't supported using command mode
@@ -597,7 +597,7 @@ fail:
/*
* GPRS functions
*/
bool gprsConnect(const char* apn, const char* user = "", const char* pwd = "") {
bool gprsConnect(const char* apn, const char* user = NULL, const char* pwd = NULL) {
if (!commandMode()) return false; // Return immediately
sendAT(GF("AN"), apn); // Set the APN
waitResponse();
@@ -626,9 +626,7 @@ fail:
* Messaging functions
*/
void sendUSSD() TINY_GSM_ATTR_NOT_AVAILABLE;
void sendSMS() TINY_GSM_ATTR_NOT_IMPLEMENTED;
String sendUSSD(const String& code) TINY_GSM_ATTR_NOT_IMPLEMENTED;
bool sendSMS(const String& number, const String& text) {
if (!commandMode()) return false; // Return immediately
@@ -870,10 +868,12 @@ finish:
return waitResponse(1000, r1, r2, r3, r4, r5);
}
public:
Stream& stream;
protected:
int guardTime;
XBeeType beeType;
Stream& stream;
GsmClient* sockets[TINY_GSM_MUX_COUNT];
};