sms_functions.unlock_sim: read PIN from modem_pin.txt
This commit is contained in:
parent
ee8e997dff
commit
333eb0578c
@ -55,15 +55,18 @@ def unlock_sim(modem):
|
||||
props = modem.GetStatus()
|
||||
print(props)
|
||||
if props and props['state'] == 2:
|
||||
logger.info("Trying to unlock %s", sim_path)
|
||||
with SystemBus() as bus:
|
||||
sim = bus.get('.ModemManager1', sim_path)
|
||||
sim.SendPin("1234", timeout=10000)
|
||||
props = modem.GetStatus()
|
||||
if props and props['state'] == 2:
|
||||
remaining_attempts = modem.UnlockRetries
|
||||
print(remaining_attempts)
|
||||
raise SIMError('Wrong PIN!')
|
||||
# check if the modem_pin.txt file exists
|
||||
with open('modem_pin.txt', 'r') as mp:
|
||||
mypin = mp.readline().rstrip('\n')
|
||||
|
||||
logger.info("Trying to unlock %s", sim_path)
|
||||
with SystemBus() as bus:
|
||||
sim = bus.get('.ModemManager1', sim_path)
|
||||
sim.SendPin(mypin, timeout=10000)
|
||||
props = modem.GetStatus()
|
||||
if props and props['state'] == 2:
|
||||
remaining_attempts = modem.UnlockRetries
|
||||
raise SIMError('Wrong PIN! Remaining attempts: {}'.format(remaining_attempts))
|
||||
|
||||
def send_sms(recipients, smsstring):
|
||||
|
||||
@ -95,7 +98,7 @@ def send_sms(recipients, smsstring):
|
||||
modem_msg = modem['org.freedesktop.ModemManager1.Modem.Messaging']
|
||||
smses = modem_msg.List()
|
||||
|
||||
while not modem.GetStatus()['signal-quality'][1]:
|
||||
while not modem.GetStatus().get('signal-quality', None) or not modem.GetStatus()['signal-quality'][1]:
|
||||
modem = get_modem()
|
||||
print(modem.GetStatus()['signal-quality'])
|
||||
time.sleep(2)
|
||||
|
Loading…
Reference in New Issue
Block a user