Browse Source

Check for non-empty pin

v_master
Sara Damiano 5 years ago
parent
commit
2092163a36
4 changed files with 14 additions and 11 deletions
  1. +2
    -2
      examples/MqttClient/MqttClient.ino
  2. +1
    -1
      src/TinyGsmClientESP8266.h
  3. +5
    -5
      src/TinyGsmClientXBee.h
  4. +6
    -3
      src/TinyGsmCommon.h

+ 2
- 2
examples/MqttClient/MqttClient.ino View File

@ -73,8 +73,8 @@
//#define TINY_GSM_YIELD() { delay(2); } //#define TINY_GSM_YIELD() { delay(2); }
// Define how you're planning to connect to the internet // Define how you're planning to connect to the internet
#define TINY_GSM_USE_GPRS false
#define TINY_GSM_USE_WIFI true
#define TINY_GSM_USE_GPRS true
#define TINY_GSM_USE_WIFI false
// set GSM PIN, if any // set GSM PIN, if any
#define GSM_PIN "" #define GSM_PIN ""


+ 1
- 1
src/TinyGsmClientESP8266.h View File

@ -156,7 +156,7 @@ public:
if (!testAT()) { if (!testAT()) {
return false; return false;
} }
if (pin != NULL) {
if (pin && strlen(pin) > 0) {
DBG("ESP8266 modules do not use an unlock pin!"); DBG("ESP8266 modules do not use an unlock pin!");
} }
sendAT(GF("E0")); // Echo Off sendAT(GF("E0")); // Echo Off


+ 5
- 5
src/TinyGsmClientXBee.h View File

@ -305,7 +305,7 @@ public:
digitalWrite(resetPin, HIGH); digitalWrite(resetPin, HIGH);
} }
if (pin != NULL) {
if (pin && strlen(pin) > 0) {
DBG("XBee's do not support SIMs that require an unlock pin!"); DBG("XBee's do not support SIMs that require an unlock pin!");
} }
@ -528,7 +528,7 @@ public:
*/ */
bool simUnlock(const char *pin) { // Not supported bool simUnlock(const char *pin) { // Not supported
if (pin != NULL) {
if (pin && strlen(pin) > 0) {
DBG("XBee's do not support SIMs that require an unlock pin!"); DBG("XBee's do not support SIMs that require an unlock pin!");
} }
return false; return false;
@ -687,7 +687,7 @@ public:
//nh For no pwd don't set setscurity or pwd //nh For no pwd don't set setscurity or pwd
if (ssid == NULL) retVal = false;; if (ssid == NULL) retVal = false;;
if (pwd != NULL)
if (pwd && strlen(pwd) > 0)
{ {
sendAT(GF("EE"), 2); // Set security to WPA2 sendAT(GF("EE"), 2); // Set security to WPA2
if (waitResponse() != 1) retVal = false; if (waitResponse() != 1) retVal = false;
@ -743,10 +743,10 @@ public:
bool gprsConnect(const char* apn, const char* user = NULL, bool gprsConnect(const char* apn, const char* user = NULL,
const char* pwd = NULL) { const char* pwd = NULL) {
if (user != NULL) {
if (user && strlen(user) > 0) {
DBG("XBee's do not support SIMs that a user name/password!"); DBG("XBee's do not support SIMs that a user name/password!");
} }
if (pwd != NULL) {
if (pwd && strlen(pwd) > 0) {
DBG("XBee's do not support SIMs that a user name/password!"); DBG("XBee's do not support SIMs that a user name/password!");
} }
XBEE_COMMAND_START_DECORATOR(5, false) XBEE_COMMAND_START_DECORATOR(5, false)


+ 6
- 3
src/TinyGsmCommon.h View File

@ -490,9 +490,12 @@ String TinyGsmDecodeHex16bit(String &instr) {
// Unlocks a sim via the 3GPP TS command AT+CPIN // Unlocks a sim via the 3GPP TS command AT+CPIN
#define TINY_GSM_MODEM_SIM_UNLOCK_CPIN() \ #define TINY_GSM_MODEM_SIM_UNLOCK_CPIN() \
bool simUnlock(const char *pin) { \
sendAT(GF("+CPIN=\""), pin, GF("\"")); \
return waitResponse() == 1; \
bool simUnlock(const char *pin) { \
if (pin && strlen(pin) > 0) { \
sendAT(GF("+CPIN=\""), pin, GF("\"")); \
return waitResponse() == 1; \
} \
return true; \
} }


Loading…
Cancel
Save