sms_functions: improved PIN input handling

This commit is contained in:
SIN admins 2020-07-28 21:29:43 +01:00
parent 333eb0578c
commit 6cdfa96267

View file

@ -62,11 +62,12 @@ def unlock_sim(modem):
logger.info("Trying to unlock %s", sim_path)
with SystemBus() as bus:
sim = bus.get('.ModemManager1', sim_path)
try:
sim.SendPin(mypin, timeout=10000)
props = modem.GetStatus()
if props and props['state'] == 2:
except GLib.Error as exc:
remaining_attempts = modem.UnlockRetries
raise SIMError('Wrong PIN! Remaining attempts: {}'.format(remaining_attempts))
raise SIMError('Failed to unlock PIN, remaining attempts: {}'.format(remaining_attempts)) from exc
def send_sms(recipients, smsstring):