Browse Source

Fix all Wextra warnings

v_master
Sara Damiano 5 years ago
parent
commit
dac86a22cd
14 changed files with 253 additions and 86 deletions
  1. +23
    -4
      src/TinyGsmClientA6.h
  2. +18
    -5
      src/TinyGsmClientBG96.h
  3. +10
    -7
      src/TinyGsmClientESP8266.h
  4. +20
    -4
      src/TinyGsmClientM590.h
  5. +23
    -7
      src/TinyGsmClientM95.h
  6. +19
    -5
      src/TinyGsmClientMC60.h
  7. +20
    -4
      src/TinyGsmClientSIM5360.h
  8. +18
    -4
      src/TinyGsmClientSIM7000.h
  9. +46
    -38
      src/TinyGsmClientSIM7600.h
  10. +13
    -2
      src/TinyGsmClientSIM800.h
  11. +6
    -2
      src/TinyGsmClientSaraR4.h
  12. +16
    -2
      src/TinyGsmClientSequansMonarch.h
  13. +4
    -0
      src/TinyGsmClientUBLOX.h
  14. +17
    -2
      src/TinyGsmClientXBee.h

+ 23
- 4
src/TinyGsmClientA6.h View File

@ -122,7 +122,7 @@ public:
{ {
memset(sockets, 0, sizeof(sockets)); memset(sockets, 0, sizeof(sockets));
} }
virtual ~TinyGsmA6() {} virtual ~TinyGsmA6() {}
/* /*
@ -135,20 +135,38 @@ public:
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()) {
return false; return false;
} }
sendAT(GF("&FZE0")); // Factory + Reset + Echo Off sendAT(GF("&FZE0")); // Factory + Reset + Echo Off
if (waitResponse() != 1) { if (waitResponse() != 1) {
return false; return false;
} }
sendAT(GF("+CMEE=0")); // Turn off verbose errors
#ifdef TINY_GSM_DEBUG
sendAT(GF("+CMEE=2")); // turn on verbose error codes
#else
sendAT(GF("+CMEE=0")); // turn off error codes
#endif
waitResponse(); waitResponse();
sendAT(GF("+CMER=3,0,0,2")); // Set unsolicited result code output destination sendAT(GF("+CMER=3,0,0,2")); // Set unsolicited result code output destination
waitResponse(); waitResponse();
DBG(GF("### Modem:"), getModemName()); DBG(GF("### Modem:"), getModemName());
getSimStatus();
return true;
int ret = getSimStatus();
// if the sim isn't ready and a pin has been provided, try to unlock the sim
if (ret != SIM_READY && pin != NULL && strlen(pin) > 0) {
simUnlock(pin);
return (getSimStatus() == SIM_READY);
}
// if the sim is ready, or it's locked but no pin has been provided, return
// true
else {
return (ret == SIM_READY || ret == SIM_LOCKED);
}
} }
String getModemName() { String getModemName() {
@ -525,6 +543,7 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
} }
chargeState = stream.readStringUntil(',').toInt(); chargeState = stream.readStringUntil(',').toInt();
percent = stream.readStringUntil('\n').toInt(); percent = stream.readStringUntil('\n').toInt();
milliVolts = 0;
// Wait for final OK // Wait for final OK
waitResponse(); waitResponse();
return true; return true;


+ 18
- 5
src/TinyGsmClientBG96.h View File

@ -158,16 +158,29 @@ public:
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()) {
return false; return false;
} }
sendAT(GF("&FZE0")); // Factory + Reset + Echo Off sendAT(GF("&FZE0")); // Factory + Reset + Echo Off
if (waitResponse() != 1) { if (waitResponse() != 1) {
return false; return false;
} }
DBG(GF("### Modem:"), getModemName()); DBG(GF("### Modem:"), getModemName());
getSimStatus();
return true;
int ret = getSimStatus();
// if the sim isn't ready and a pin has been provided, try to unlock the sim
if (ret != SIM_READY && pin != NULL && strlen(pin) > 0) {
simUnlock(pin);
return (getSimStatus() == SIM_READY);
}
// if the sim is ready, or it's locked but no pin has been provided, return
// true
else {
return (ret == SIM_READY || ret == SIM_LOCKED);
}
} }
String getModemName() { String getModemName() {
@ -497,10 +510,10 @@ TINY_GSM_MODEM_GET_GPRS_IP_CONNECTED()
protected: protected:
bool modemConnect(const char* host, uint16_t port, uint8_t mux, bool modemConnect(const char* host, uint16_t port, uint8_t mux,
bool ssl = false, int timeout_s = 20)
{
bool ssl = false, int timeout_s = 20) {
if (ssl) DBG("SSL not yet supported on this module!");
int rsp; int rsp;
uint32_t timeout_ms = ((uint32_t)timeout_s)*1000;
uint32_t timeout_ms = ((uint32_t)timeout_s) * 1000;
// <PDPcontextID>(1-16), <connectID>(0-11),"TCP/UDP/TCP LISTENER/UDP SERVICE", // <PDPcontextID>(1-16), <connectID>(0-11),"TCP/UDP/TCP LISTENER/UDP SERVICE",
// "<IP_address>/<domain_name>",<remote_port>,<local_port>,<access_mode>(0-2 0=buffer) // "<IP_address>/<domain_name>",<remote_port>,<local_port>,<access_mode>(0-2 0=buffer)


+ 10
- 7
src/TinyGsmClientESP8266.h View File

@ -31,15 +31,14 @@ static unsigned TINY_GSM_TCP_KEEP_ALIVE = 120;
// 4 : the TCP or UDP transmission of ESP8266 station disconnected // 4 : the TCP or UDP transmission of ESP8266 station disconnected
// 5 : ESP8266 station did NOT connect to an AP // 5 : ESP8266 station did NOT connect to an AP
enum RegStatus { enum RegStatus {
REG_OK_IP = 2,
REG_OK_TCP = 3,
REG_UNREGISTERED = 4,
REG_DENIED = 5,
REG_UNKNOWN = 6,
REG_OK_IP = 2,
REG_OK_TCP = 3,
REG_OK_NO_TCP = 4,
REG_DENIED = 5,
REG_UNKNOWN = 6,
}; };
class TinyGsmESP8266 class TinyGsmESP8266
{ {
@ -157,6 +156,9 @@ public:
if (!testAT()) { if (!testAT()) {
return false; return false;
} }
if (pin != NULL) {
DBG("ESP8266 modules do not use an unlock pin!");
}
sendAT(GF("E0")); // Echo Off sendAT(GF("E0")); // Echo Off
if (waitResponse() != 1) { if (waitResponse() != 1) {
return false; return false;
@ -249,7 +251,8 @@ TINY_GSM_MODEM_MAINTAIN_LISTEN()
RegStatus getRegistrationStatus() { RegStatus getRegistrationStatus() {
sendAT(GF("+CIPSTATUS")); sendAT(GF("+CIPSTATUS"));
if (waitResponse(3000, GF("STATUS:")) != 1) return REG_UNKNOWN; if (waitResponse(3000, GF("STATUS:")) != 1) return REG_UNKNOWN;
int status = waitResponse(GFP(GSM_ERROR), GF("2"), GF("3"), GF("4"), GF("5"));
int status =
waitResponse(GFP(GSM_ERROR), GF("2"), GF("3"), GF("4"), GF("5"));
waitResponse(); // Returns an OK after the status waitResponse(); // Returns an OK after the status
return (RegStatus)status; return (RegStatus)status;
} }


+ 20
- 4
src/TinyGsmClientM590.h View File

@ -133,20 +133,36 @@ public:
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()) {
return false; return false;
} }
sendAT(GF("&FZE0")); // Factory + Reset + Echo Off sendAT(GF("&FZE0")); // Factory + Reset + Echo Off
if (waitResponse() != 1) { if (waitResponse() != 1) {
return false; return false;
} }
#ifdef TINY_GSM_DEBUG #ifdef TINY_GSM_DEBUG
sendAT(GF("+CMEE=2"));
waitResponse();
sendAT(GF("+CMEE=2")); // turn on verbose error codes
#else
sendAT(GF("+CMEE=0")); // turn off error codes
#endif #endif
waitResponse();
DBG(GF("### Modem:"), getModemName()); DBG(GF("### Modem:"), getModemName());
getSimStatus();
return true;
int ret = getSimStatus();
// if the sim isn't ready and a pin has been provided, try to unlock the sim
if (ret != SIM_READY && pin != NULL && strlen(pin) > 0) {
simUnlock(pin);
return (getSimStatus() == SIM_READY);
}
// if the sim is ready, or it's locked but no pin has been provided, return
// true
else {
return (ret == SIM_READY || ret == SIM_LOCKED);
}
} }
String getModemName() { String getModemName() {


+ 23
- 7
src/TinyGsmClientM95.h View File

@ -157,20 +157,36 @@ public:
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()) {
return false; return false;
} }
sendAT(GF("&FZE0")); // Factory + Reset + Echo Off sendAT(GF("&FZE0")); // Factory + Reset + Echo Off
if (waitResponse() != 1) { if (waitResponse() != 1) {
return false; return false;
} }
#ifdef TINY_GSM_DEBUG #ifdef TINY_GSM_DEBUG
sendAT(GF("+CMEE=2"));
waitResponse();
sendAT(GF("+CMEE=2")); // turn on verbose error codes
#else
sendAT(GF("+CMEE=0")); // turn off error codes
#endif #endif
waitResponse();
DBG(GF("### Modem:"), getModemName()); DBG(GF("### Modem:"), getModemName());
getSimStatus();
return true;
int ret = getSimStatus();
// if the sim isn't ready and a pin has been provided, try to unlock the sim
if (ret != SIM_READY && pin != NULL && strlen(pin) > 0) {
simUnlock(pin);
return (getSimStatus() == SIM_READY);
}
// if the sim is ready, or it's locked but no pin has been provided, return
// true
else {
return (ret == SIM_READY || ret == SIM_LOCKED);
}
} }
String getModemName() { String getModemName() {
@ -557,9 +573,9 @@ TINY_GSM_MODEM_GET_GPRS_IP_CONNECTED()
protected: protected:
bool modemConnect(const char* host, uint16_t port, uint8_t mux, bool modemConnect(const char* host, uint16_t port, uint8_t mux,
bool ssl = false, int timeout_s = 75)
{
uint32_t timeout_ms = ((uint32_t)timeout_s)*1000;
bool ssl = false, int timeout_s = 75) {
if (ssl) DBG("SSL not yet supported on this module!");
uint32_t timeout_ms = ((uint32_t)timeout_s) * 1000;
sendAT(GF("+QIOPEN="), mux, GF("\"TCP"), GF("\",\""), host, GF("\","), port); sendAT(GF("+QIOPEN="), mux, GF("\"TCP"), GF("\",\""), host, GF("\","), port);
int rsp = waitResponse(timeout_ms, int rsp = waitResponse(timeout_ms,
GF("CONNECT OK" GSM_NL), GF("CONNECT OK" GSM_NL),


+ 19
- 5
src/TinyGsmClientMC60.h View File

@ -161,18 +161,32 @@ public:
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()) {
return false; return false;
} }
sendAT(GF("&FZ")); // Factory + Reset sendAT(GF("&FZ")); // Factory + Reset
waitResponse(); waitResponse();
sendAT(GF("E0")); // Echo Off sendAT(GF("E0")); // Echo Off
if (waitResponse() != 1) { if (waitResponse() != 1) {
return false; return false;
} }
DBG(GF("### Modem:"), getModemName()); DBG(GF("### Modem:"), getModemName());
getSimStatus();
return true;
int ret = getSimStatus();
// if the sim isn't ready and a pin has been provided, try to unlock the sim
if (ret != SIM_READY && pin != NULL && strlen(pin) > 0) {
simUnlock(pin);
return (getSimStatus() == SIM_READY);
}
// if the sim is ready, or it's locked but no pin has been provided, return
// true
else {
return (ret == SIM_READY || ret == SIM_LOCKED);
}
} }
String getModemName() { String getModemName() {
@ -563,9 +577,9 @@ TINY_GSM_MODEM_GET_GPRS_IP_CONNECTED()
protected: protected:
bool modemConnect(const char* host, uint16_t port, uint8_t mux, bool modemConnect(const char* host, uint16_t port, uint8_t mux,
bool ssl = false, int timeout_s = 75)
{
uint32_t timeout_ms = ((uint32_t)timeout_s)*1000;
bool ssl = false, int timeout_s = 75) {
if (ssl) DBG("SSL not yet supported on this module!");
uint32_t timeout_ms = ((uint32_t)timeout_s) * 1000;
sendAT(GF("+QIOPEN="), mux, GF("\"TCP"), GF("\",\""), host, GF("\","), port); sendAT(GF("+QIOPEN="), mux, GF("\"TCP"), GF("\",\""), host, GF("\","), port);
int rsp = waitResponse(timeout_ms, int rsp = waitResponse(timeout_ms,
GF("CONNECT OK" GSM_NL), GF("CONNECT OK" GSM_NL),


+ 20
- 4
src/TinyGsmClientSIM5360.h View File

@ -142,16 +142,29 @@ public:
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()) {
return false; return false;
} }
sendAT(GF("E0")); // Echo Off sendAT(GF("E0")); // Echo Off
if (waitResponse() != 1) { if (waitResponse() != 1) {
return false; return false;
} }
DBG(GF("### Modem:"), getModemName()); DBG(GF("### Modem:"), getModemName());
getSimStatus();
return true;
int ret = getSimStatus();
// if the sim isn't ready and a pin has been provided, try to unlock the sim
if (ret != SIM_READY && pin != NULL && strlen(pin) > 0) {
simUnlock(pin);
return (getSimStatus() == SIM_READY);
}
// if the sim is ready, or it's locked but no pin has been provided, return
// true
else {
return (ret == SIM_READY || ret == SIM_LOCKED);
}
} }
String getModemName() { String getModemName() {
@ -640,17 +653,20 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
protected: protected:
bool modemConnect(const char* host, uint16_t port, uint8_t mux, bool modemConnect(const char* host, uint16_t port, uint8_t mux,
bool ssl = false, int timeout_s = 75) {
bool ssl = false, int timeout_s = 15) {
// Make sure we'll be getting data manually on this connection // Make sure we'll be getting data manually on this connection
sendAT(GF("+CIPRXGET=1")); sendAT(GF("+CIPRXGET=1"));
if (waitResponse() != 1) { if (waitResponse() != 1) {
return false; return false;
} }
if (ssl) DBG("SSL not yet supported on this module!");
// Establish a connection in multi-socket mode // Establish a connection in multi-socket mode
uint32_t timeout_ms = ((uint32_t)timeout_s) * 1000;
sendAT(GF("+CIPOPEN="), mux, ',', GF("\"TCP"), GF("\",\""), host, GF("\","), port); sendAT(GF("+CIPOPEN="), mux, ',', GF("\"TCP"), GF("\",\""), host, GF("\","), port);
// The reply is +CIPOPEN: ## of socket created // The reply is +CIPOPEN: ## of socket created
if (waitResponse(15000L, GF(GSM_NL "+CIPOPEN:")) != 1) {
if (waitResponse(timeout_ms, GF(GSM_NL "+CIPOPEN:")) != 1) {
return false; return false;
} }
return true; return true;


+ 18
- 4
src/TinyGsmClientSIM7000.h View File

@ -166,16 +166,29 @@ public:
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()) {
return false; return false;
} }
sendAT(GF("E0")); // Echo Off sendAT(GF("E0")); // Echo Off
if (waitResponse() != 1) { if (waitResponse() != 1) {
return false; return false;
} }
DBG(GF("### Modem:"), getModemName()); DBG(GF("### Modem:"), getModemName());
getSimStatus();
return true;
int ret = getSimStatus();
// if the sim isn't ready and a pin has been provided, try to unlock the sim
if (ret != SIM_READY && pin != NULL && strlen(pin) > 0) {
simUnlock(pin);
return (getSimStatus() == SIM_READY);
}
// if the sim is ready, or it's locked but no pin has been provided, return
// true
else {
return (ret == SIM_READY || ret == SIM_LOCKED);
}
} }
String getModemName() { String getModemName() {
@ -801,8 +814,9 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
protected: protected:
bool modemConnect(const char* host, uint16_t port, uint8_t mux, bool modemConnect(const char* host, uint16_t port, uint8_t mux,
bool ssl = false, int timeout_s = 75)
{
bool ssl = false, int timeout_s = 75) {
if (ssl) DBG("SSL not yet supported on this module!");
int rsp; int rsp;
uint32_t timeout_ms = ((uint32_t)timeout_s)*1000; uint32_t timeout_ms = ((uint32_t)timeout_s)*1000;
sendAT(GF("+CIPSTART="), mux, ',', GF("\"TCP"), GF("\",\""), host, GF("\","), port); sendAT(GF("+CIPSTART="), mux, ',', GF("\"TCP"), GF("\",\""), host, GF("\","), port);


+ 46
- 38
src/TinyGsmClientSIM7600.h View File

@ -142,16 +142,29 @@ public:
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()) {
return false; return false;
} }
sendAT(GF("E0")); // Echo Off sendAT(GF("E0")); // Echo Off
if (waitResponse() != 1) { if (waitResponse() != 1) {
return false; return false;
} }
DBG(GF("### Modem:"), getModemName()); DBG(GF("### Modem:"), getModemName());
getSimStatus();
return true;
int ret = getSimStatus();
// if the sim isn't ready and a pin has been provided, try to unlock the sim
if (ret != SIM_READY && pin != NULL && strlen(pin) > 0) {
simUnlock(pin);
return (getSimStatus() == SIM_READY);
}
// if the sim is ready, or it's locked but no pin has been provided, return
// true
else {
return (ret == SIM_READY || ret == SIM_LOCKED);
}
} }
String getModemName() { String getModemName() {
@ -555,7 +568,7 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
} }
// get GPS informations // get GPS informations
bool getGPS(float *lat, float *lon, float *speed=0, int *alt=0, int *vsat=0, int *usat=0) {
bool getGPS(float *lat, float *lon, float *speed=0, int *alt=0) {
//String buffer = ""; //String buffer = "";
bool fix = false; bool fix = false;
@ -567,14 +580,14 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
//stream.readStringUntil(','); // mode //stream.readStringUntil(','); // mode
if ( stream.readStringUntil(',').toInt() == 1 ) fix = true; if ( stream.readStringUntil(',').toInt() == 1 ) fix = true;
stream.readStringUntil(','); //gps stream.readStringUntil(','); //gps
stream.readStringUntil(','); // glonass
stream.readStringUntil(','); // beidu
stream.readStringUntil(','); // glonass
stream.readStringUntil(','); // beidu
*lat = stream.readStringUntil(',').toFloat(); //lat *lat = stream.readStringUntil(',').toFloat(); //lat
stream.readStringUntil(','); // N/S
stream.readStringUntil(','); // N/S
*lon = stream.readStringUntil(',').toFloat(); //lon *lon = stream.readStringUntil(',').toFloat(); //lon
stream.readStringUntil(','); // E/W
stream.readStringUntil(','); // date
stream.readStringUntil(','); // UTC time
stream.readStringUntil(','); // E/W
stream.readStringUntil(','); // date
stream.readStringUntil(','); // UTC time
if (alt != NULL) *alt = stream.readStringUntil(',').toFloat(); //alt if (alt != NULL) *alt = stream.readStringUntil(',').toFloat(); //alt
if (speed != NULL) *speed = stream.readStringUntil(',').toFloat(); //speed if (speed != NULL) *speed = stream.readStringUntil(',').toFloat(); //speed
stream.readStringUntil(','); //course stream.readStringUntil(','); //course
@ -582,8 +595,6 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
stream.readStringUntil(',');//PDOP stream.readStringUntil(',');//PDOP
stream.readStringUntil(',');//HDOP stream.readStringUntil(',');//HDOP
stream.readStringUntil(',');//VDOP stream.readStringUntil(',');//VDOP
//if (vsat != NULL) *vsat = stream.readStringUntil(',').toInt(); //viewed satelites
//if (usat != NULL) *usat = stream.readStringUntil(',').toInt(); //used satelites
stream.readStringUntil('\n'); stream.readStringUntil('\n');
waitResponse(); waitResponse();
@ -610,7 +621,7 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
// Wait for final OK // Wait for final OK
waitResponse(); waitResponse();
// Return millivolts // Return millivolts
uint16_t res = voltage*1000;
uint16_t res = voltage*1000;
return res; return res;
} }
@ -618,16 +629,11 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
uint8_t getBattChargeState() TINY_GSM_ATTR_NOT_AVAILABLE; uint8_t getBattChargeState() TINY_GSM_ATTR_NOT_AVAILABLE;
bool getBattStats(uint8_t &chargeState, int8_t &percent, uint16_t &milliVolts) {
sendAT(GF("+CBC?"));
if (waitResponse(GF(GSM_NL "+CBC:")) != 1) {
return false;
}
// get voltage in VOLTS
float voltage = stream.readStringUntil('\n').toFloat();
milliVolts = voltage*1000;
// Wait for final OK
waitResponse();
bool getBattStats(uint8_t& chargeState, int8_t& percent,
uint16_t& milliVolts) {
chargeState = 0;
percent = 0;
milliVolts = getBattVoltage();
return true; return true;
} }
@ -649,22 +655,24 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
*/ */
protected: protected:
bool modemConnect(const char* host, uint16_t port, uint8_t mux,
bool ssl = false, int timeout_s = 75) {
// Make sure we'll be getting data manually on this connection
sendAT(GF("+CIPRXGET=1"));
if (waitResponse() != 1) {
return false;
}
// Establish a connection in multi-socket mode
sendAT(GF("+CIPOPEN="), mux, ',', GF("\"TCP"), GF("\",\""), host, GF("\","), port);
// The reply is +CIPOPEN: ## of socket created
if (waitResponse(15000L, GF(GSM_NL "+CIPOPEN:")) != 1) {
return false;
}
return true;
bool modemConnect(const char* host, uint16_t port, uint8_t mux,
bool ssl = false, int timeout_s = 15) {
if (ssl) DBG("SSL not yet supported on this module!");
// Make sure we'll be getting data manually on this connection
sendAT(GF("+CIPRXGET=1"));
if (waitResponse() != 1) {
return false;
}
// Establish a connection in multi-socket mode
uint32_t timeout_ms = ((uint32_t)timeout_s) * 1000;
sendAT(GF("+CIPOPEN="), mux, ',', GF("\"TCP"), GF("\",\""), host, GF("\","),
port);
// The reply is +CIPOPEN: ## of socket created
if (waitResponse(timeout_ms, GF(GSM_NL "+CIPOPEN:")) != 1) {
return false;
}
return true;
} }
int16_t modemSend(const void* buff, size_t len, uint8_t mux) { int16_t modemSend(const void* buff, size_t len, uint8_t mux) {


+ 13
- 2
src/TinyGsmClientSIM800.h View File

@ -165,6 +165,7 @@ public:
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()) {
return false; return false;
} }
@ -174,9 +175,19 @@ public:
if (waitResponse() != 1) { if (waitResponse() != 1) {
return false; return false;
} }
DBG(GF("### Modem:"), getModemName()); DBG(GF("### Modem:"), getModemName());
getSimStatus();
return true;
int ret = getSimStatus();
// if the sim isn't ready and a pin has been provided, try to unlock the sim
if (ret != SIM_READY && pin != NULL && strlen(pin) > 0) {
simUnlock(pin);
return (getSimStatus() == SIM_READY);
}
// if the sim is ready, or it's locked but no pin has been provided, return true
else {
return (ret == SIM_READY || ret == SIM_LOCKED);
}
} }
String getModemName() { String getModemName() {


+ 6
- 2
src/TinyGsmClientSaraR4.h View File

@ -176,9 +176,11 @@ public:
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()) {
return false; return false;
} }
sendAT(GF("E0")); // Echo Off sendAT(GF("E0")); // Echo Off
if (waitResponse() != 1) { if (waitResponse() != 1) {
return false; return false;
@ -191,7 +193,7 @@ public:
#endif #endif
waitResponse(); waitResponse();
getModemName();
DBG(GF("### Modem:"), getModemName());
int ret = getSimStatus(); int ret = getSimStatus();
// if the sim isn't ready and a pin has been provided, try to unlock the sim // if the sim isn't ready and a pin has been provided, try to unlock the sim
@ -509,6 +511,8 @@ TINY_GSM_MODEM_GET_GPRS_IP_CONNECTED()
bool getBattStats(uint8_t &chargeState, int8_t &percent, uint16_t &milliVolts) { bool getBattStats(uint8_t &chargeState, int8_t &percent, uint16_t &milliVolts) {
percent = getBattPercent(); percent = getBattPercent();
chargeState = 0;
milliVolts = 0;
return true; return true;
} }
@ -525,7 +529,7 @@ TINY_GSM_MODEM_GET_GPRS_IP_CONNECTED()
streamSkipUntil(','); // Skip units (C/F) streamSkipUntil(','); // Skip units (C/F)
int16_t res = stream.readStringUntil('\n').toInt(); int16_t res = stream.readStringUntil('\n').toInt();
float temp = -9999; float temp = -9999;
if (res != 65535) {
if (res != -1) {
temp = ((float)res)/10; temp = ((float)res)/10;
} }
return temp; return temp;


+ 16
- 2
src/TinyGsmClientSequansMonarch.h View File

@ -195,15 +195,29 @@ public:
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()) {
return false; return false;
} }
sendAT(GF("E0")); // Echo Off sendAT(GF("E0")); // Echo Off
if (waitResponse() != 1) { if (waitResponse() != 1) {
return false; return false;
} }
getSimStatus();
return true;
DBG(GF("### Modem:"), getModemName());
int ret = getSimStatus();
// if the sim isn't ready and a pin has been provided, try to unlock the sim
if (ret != SIM_READY && pin != NULL && strlen(pin) > 0) {
simUnlock(pin);
return (getSimStatus() == SIM_READY);
}
// if the sim is ready, or it's locked but no pin has been provided, return
// true
else {
return (ret == SIM_READY || ret == SIM_LOCKED);
}
} }
String getModemName() { String getModemName() {


+ 4
- 0
src/TinyGsmClientUBLOX.h View File

@ -176,9 +176,11 @@ public:
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()) {
return false; return false;
} }
sendAT(GF("E0")); // Echo Off sendAT(GF("E0")); // Echo Off
if (waitResponse() != 1) { if (waitResponse() != 1) {
return false; return false;
@ -535,7 +537,9 @@ TINY_GSM_MODEM_GET_GPRS_IP_CONNECTED()
uint8_t getBattChargeState() TINY_GSM_ATTR_NOT_AVAILABLE; uint8_t getBattChargeState() TINY_GSM_ATTR_NOT_AVAILABLE;
bool getBattStats(uint8_t &chargeState, int8_t &percent, uint16_t &milliVolts) { bool getBattStats(uint8_t &chargeState, int8_t &percent, uint16_t &milliVolts) {
chargeState = 0;
percent = getBattPercent(); percent = getBattPercent();
milliVolts = 0;
return true; return true;
} }


+ 17
- 2
src/TinyGsmClientXBee.h View File

@ -305,6 +305,10 @@ public:
digitalWrite(resetPin, HIGH); digitalWrite(resetPin, HIGH);
} }
if (pin != NULL) {
DBG("XBee's do not support SIMs that require an unlock pin!");
}
XBEE_COMMAND_START_DECORATOR(10, false) XBEE_COMMAND_START_DECORATOR(10, false)
sendAT(GF("AP0")); // Put in transparent mode sendAT(GF("AP0")); // Put in transparent mode
@ -524,6 +528,9 @@ public:
*/ */
bool simUnlock(const char *pin) { // Not supported bool simUnlock(const char *pin) { // Not supported
if (pin != NULL) {
DBG("XBee's do not support SIMs that require an unlock pin!");
}
return false; return false;
} }
@ -535,7 +542,7 @@ public:
return sendATGetString(GF("IM")); return sendATGetString(GF("IM"));
} }
SimStatus getSimStatus(unsigned long timeout_ms = 10000L) {
SimStatus getSimStatus() {
return SIM_READY; // unsupported return SIM_READY; // unsupported
} }
@ -734,7 +741,14 @@ 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 (user != NULL) {
DBG("XBee's do not support SIMs that a user name/password!");
}
if (pwd != NULL) {
DBG("XBee's do not support SIMs that a user name/password!");
}
XBEE_COMMAND_START_DECORATOR(5, false) XBEE_COMMAND_START_DECORATOR(5, false)
sendAT(GF("AN"), apn); // Set the APN sendAT(GF("AN"), apn); // Set the APN
bool success = waitResponse() == 1; bool success = waitResponse() == 1;
@ -922,6 +936,7 @@ protected:
} }
int16_t modemSend(const void* buff, size_t len, uint8_t mux = 0) { int16_t modemSend(const void* buff, size_t len, uint8_t mux = 0) {
if (mux != 0) DBG("XBee only supports 1 IP channel in transparent mode!");
stream.write((uint8_t*)buff, len); stream.write((uint8_t*)buff, len);
stream.flush(); stream.flush();
return len; return len;


Loading…
Cancel
Save