faucamp / python-gsmmodem

Python module to control a GSM modem attached to the system: send/receive SMS messages, handle calls, etc
GNU Lesser General Public License v3.0
385 stars 303 forks source link

SIM card with removed PIN #117

Open Jancs-E opened 1 week ago

Jancs-E commented 1 week ago

Hi! I have an issue using your library with the PIN-disable/removed SIM card - the command AT+CPIN? gives response: +CPIN:READY /OK, but if I simply try to connect either by modem.connect(), modem.connect(pin=None), modem.connect(pin=''), I always get an error ('CME 11 (SIM card PIN is required)'.

How could it be solved?

Jancs-E commented 1 week ago

I found a problem: originally, the line #431 in modem.py looks so if cpinResponse != '+CPIN: READY': which means, it will fail if the response does no contain space. I modified it so: if cpinResponse.replace(' ', '') != '+CPIN:READY': and now it works as it will accept any response - with or without spaces. It also solved my problem.

Would be nice, if you could release an update.