Skip to content

Commit

Permalink
Add a imei check around modem detection loop
Browse files Browse the repository at this point in the history
  • Loading branch information
parker-hologram committed Sep 15, 2023
1 parent 45f1f4a commit fe9b619
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions Hologram/Network/Cellular.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,22 @@ def _does_modem_exist_for_handler(modemHandler):
@staticmethod
def scan_for_all_usable_modems() -> list[Modem]:
modems = []
unique_imeis = set()
for (_, modemHandler) in Cellular._modemHandlers.items():
modem_exists = Cellular._does_modem_exist_for_handler(modemHandler)
if modem_exists:
test_handler = modemHandler()
usable_ports = test_handler.detect_usable_serial_port(stop_on_first=False)
for port in usable_ports:
modem = modemHandler(device_name=port)
modems.append(modem)
try:
test_handler = modemHandler()
usable_ports = test_handler.detect_usable_serial_port(stop_on_first=False)
for port in usable_ports:
modem = modemHandler(device_name=port)
imei = modem.imei
if imei not in unique_imeis:
unique_imeis.add(imei)
modems.append(modem)
except Exception:
# Any exception already logged up the chain
pass
return modems


Expand Down

0 comments on commit fe9b619

Please # to comment.