1
0
Fork 0

modem: Only modems without a SIM will be switched off, wait longer

Switch of modems without a SIM card as they might have a SIM card
now but thee is no simcard detection. Increase the sleep time to
wait for modems to become available.
This commit is contained in:
Holger Hans Peter Freyther 2012-11-09 15:13:17 +01:00
parent 8810241b04
commit a44c76a73a
1 changed files with 13 additions and 7 deletions

View File

@ -68,6 +68,9 @@ class Modem(object):
"""
return self.modem.GetProperties()[name]
def sim(self):
return sim.Sim(self.bus, self.name)
def __repr__(self):
return "<Modem('%s')>" % self.name
@ -94,11 +97,8 @@ def detect_modems(bus):
# Filter out the phonesim
modems = filter(lambda x: x.name != '/phonesim', modems)
# Force reloading..
wait = []
on = []
for mod in modems:
mod.disable()
# Enable each modem...
for mod in modems:
@ -112,7 +112,8 @@ def detect_modems(bus):
# Now... wait a bit for the modem to do some init
if len(wait) > 0:
import time
time.sleep(3)
print("I need to sleep some time for the modem to wake up")
time.sleep(20)
for mod in wait:
if mod.is_enabled():
@ -124,12 +125,17 @@ def detect_modems(bus):
return modem.manufacturer() != None
def sim_present(modem):
s = sim.Sim(bus, modem.name)
print s
return s.imsi() != None
return modem.sim().imsi() != None
on = filter(modem_vendor, on)
on = filter(sim_present, on)
# TODO: We could now disable all modems without a SIMcard
for mod in modems:
if mod in on:
continue
print("Modem %s is wihtout SIM card. Powering it down." % mod.name)
mod.disable()
return on