mirror of
				https://github.com/KevinMidboe/TinyGSM.git
				synced 2025-10-29 18:00:18 +00:00 
			
		
		
		
	Added IMSI
This commit is contained in:
		| @@ -836,6 +836,10 @@ class TinyGsmXBee | |||||||
|     return sendATGetString(GF("IM")); |     return sendATGetString(GF("IM")); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   String getIMSIImpl() { | ||||||
|  |     return sendATGetString(GF("II")); | ||||||
|  |   } | ||||||
|  |  | ||||||
|   SimStatus getSimStatusImpl(uint32_t) { |   SimStatus getSimStatusImpl(uint32_t) { | ||||||
|     return SIM_READY;  // unsupported |     return SIM_READY;  // unsupported | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -117,18 +117,3 @@ uint32_t TinyGsmAutoBaud(T& SerialAT, uint32_t minimum = 9600, | |||||||
| } | } | ||||||
|  |  | ||||||
| #endif  // SRC_TINYGSMCOMMON_H_ | #endif  // SRC_TINYGSMCOMMON_H_ | ||||||
|  |  | ||||||
| // Asks for International Mobile Subscriber Identity IMSI via the AT+CIMI command |  | ||||||
| #define TINY_GSM_MODEM_GET_IMSI_CIMI() \ |  | ||||||
|   String getIMSI() { \ |  | ||||||
|     sendAT(GF("+CIMI")); \ |  | ||||||
|     if (waitResponse(GF(GSM_NL)) != 1) { \ |  | ||||||
|       return ""; \ |  | ||||||
|     } \ |  | ||||||
|     String res = stream.readStringUntil('\n'); \ |  | ||||||
|     waitResponse(); \ |  | ||||||
|     res.trim(); \ |  | ||||||
|     return res; \ |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -38,6 +38,10 @@ class TinyGsmGPRS { | |||||||
|   String getIMEI() { |   String getIMEI() { | ||||||
|     return thisModem().getIMEIImpl(); |     return thisModem().getIMEIImpl(); | ||||||
|   } |   } | ||||||
|  |   // Asks for International Mobile Subscriber Identity IMSI | ||||||
|  |   String getIMSI() { | ||||||
|  |     return thisModem().getIMSIImpl(); | ||||||
|  |   } | ||||||
|   SimStatus getSimStatus(uint32_t timeout_ms = 10000L) { |   SimStatus getSimStatus(uint32_t timeout_ms = 10000L) { | ||||||
|     return thisModem().getSimStatusImpl(timeout_ms); |     return thisModem().getSimStatusImpl(timeout_ms); | ||||||
|   } |   } | ||||||
| @@ -105,6 +109,16 @@ class TinyGsmGPRS { | |||||||
|     return res; |     return res; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   // Asks for International Mobile Subscriber Identity IMSI via the AT+CIMI | ||||||
|  |   // command | ||||||
|  |   String getIMSIImpl() { | ||||||
|  |     thisModem().sendAT(GF("+CIMI")); | ||||||
|  |     String res = thisModem().stream.readStringUntil('\n'); | ||||||
|  |     thisModem().waitResponse(); | ||||||
|  |     res.trim(); | ||||||
|  |     return res; | ||||||
|  |   } | ||||||
|  |  | ||||||
|   SimStatus getSimStatusImpl(uint32_t timeout_ms = 10000L) { |   SimStatus getSimStatusImpl(uint32_t timeout_ms = 10000L) { | ||||||
|     for (uint32_t start = millis(); millis() - start < timeout_ms;) { |     for (uint32_t start = millis(); millis() - start < timeout_ms;) { | ||||||
|       thisModem().sendAT(GF("+CPIN?")); |       thisModem().sendAT(GF("+CPIN?")); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user