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()
|
props = modem.GetStatus()
|
||||||
print(props)
|
print(props)
|
||||||
if props and props['state'] == 2:
|
if props and props['state'] == 2:
|
||||||
logger.info("Trying to unlock %s", sim_path)
|
# check if the modem_pin.txt file exists
|
||||||
with SystemBus() as bus:
|
with open('modem_pin.txt', 'r') as mp:
|
||||||
sim = bus.get('.ModemManager1', sim_path)
|
mypin = mp.readline().rstrip('\n')
|
||||||
sim.SendPin("1234", timeout=10000)
|
|
||||||
props = modem.GetStatus()
|
logger.info("Trying to unlock %s", sim_path)
|
||||||
if props and props['state'] == 2:
|
with SystemBus() as bus:
|
||||||
remaining_attempts = modem.UnlockRetries
|
sim = bus.get('.ModemManager1', sim_path)
|
||||||
print(remaining_attempts)
|
sim.SendPin(mypin, timeout=10000)
|
||||||
raise SIMError('Wrong PIN!')
|
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):
|
def send_sms(recipients, smsstring):
|
||||||
|
|
||||||
@ -95,7 +98,7 @@ def send_sms(recipients, smsstring):
|
|||||||
modem_msg = modem['org.freedesktop.ModemManager1.Modem.Messaging']
|
modem_msg = modem['org.freedesktop.ModemManager1.Modem.Messaging']
|
||||||
smses = modem_msg.List()
|
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()
|
modem = get_modem()
|
||||||
print(modem.GetStatus()['signal-quality'])
|
print(modem.GetStatus()['signal-quality'])
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
Loading…
Reference in New Issue
Block a user