diff --git a/examples/MqttClient/MqttClient.ino b/examples/MqttClient/MqttClient.ino index 12649b7..1e269d8 100644 --- a/examples/MqttClient/MqttClient.ino +++ b/examples/MqttClient/MqttClient.ino @@ -73,8 +73,8 @@ //#define TINY_GSM_YIELD() { delay(2); } // 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 #define GSM_PIN "" diff --git a/src/TinyGsmClientESP8266.h b/src/TinyGsmClientESP8266.h index c44c221..f701e8d 100644 --- a/src/TinyGsmClientESP8266.h +++ b/src/TinyGsmClientESP8266.h @@ -156,7 +156,7 @@ public: if (!testAT()) { return false; } - if (pin != NULL) { + if (pin && strlen(pin) > 0) { DBG("ESP8266 modules do not use an unlock pin!"); } sendAT(GF("E0")); // Echo Off diff --git a/src/TinyGsmClientXBee.h b/src/TinyGsmClientXBee.h index 519c04f..4d4eaa9 100644 --- a/src/TinyGsmClientXBee.h +++ b/src/TinyGsmClientXBee.h @@ -305,7 +305,7 @@ public: digitalWrite(resetPin, HIGH); } - if (pin != NULL) { + if (pin && strlen(pin) > 0) { DBG("XBee's do not support SIMs that require an unlock pin!"); } @@ -528,7 +528,7 @@ public: */ 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!"); } return false; @@ -687,7 +687,7 @@ public: //nh For no pwd don't set setscurity or pwd if (ssid == NULL) retVal = false;; - if (pwd != NULL) + if (pwd && strlen(pwd) > 0) { sendAT(GF("EE"), 2); // Set security to WPA2 if (waitResponse() != 1) retVal = false; @@ -743,10 +743,10 @@ public: bool gprsConnect(const char* apn, const char* user = 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!"); } - if (pwd != NULL) { + if (pwd && strlen(pwd) > 0) { DBG("XBee's do not support SIMs that a user name/password!"); } XBEE_COMMAND_START_DECORATOR(5, false) diff --git a/src/TinyGsmCommon.h b/src/TinyGsmCommon.h index 44c506e..ba3b43e 100644 --- a/src/TinyGsmCommon.h +++ b/src/TinyGsmCommon.h @@ -490,9 +490,12 @@ String TinyGsmDecodeHex16bit(String &instr) { // Unlocks a sim via the 3GPP TS command AT+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; \ }