mirror of
				https://github.com/KevinMidboe/TinyGSM.git
				synced 2025-10-29 18:00:18 +00:00 
			
		
		
		
	Check for non-empty pin
This commit is contained in:
		@@ -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_GPRS true
 | 
				
			||||||
#define TINY_GSM_USE_WIFI true
 | 
					#define TINY_GSM_USE_WIFI false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// set GSM PIN, if any
 | 
					// set GSM PIN, if any
 | 
				
			||||||
#define GSM_PIN ""
 | 
					#define GSM_PIN ""
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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) { \
 | 
					  bool simUnlock(const char *pin) {      \
 | 
				
			||||||
    sendAT(GF("+CPIN=\""), pin, GF("\"")); \
 | 
					    if (pin && strlen(pin) > 0) { \
 | 
				
			||||||
    return waitResponse() == 1; \
 | 
					      sendAT(GF("+CPIN=\""), pin, GF("\"")); \
 | 
				
			||||||
 | 
					      return waitResponse() == 1; \
 | 
				
			||||||
 | 
					    } \
 | 
				
			||||||
 | 
					    return true; \
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user