diff --git a/system/hardware/base.py b/system/hardware/base.py index 3506be5145..e429f0e9f2 100644 --- a/system/hardware/base.py +++ b/system/hardware/base.py @@ -210,9 +210,6 @@ class HardwareBase(ABC): def configure_modem(self): pass - def reboot_modem(self): - pass - @abstractmethod def get_networks(self): pass diff --git a/system/hardware/tici/esim.nmconnection b/system/hardware/tici/esim.nmconnection new file mode 100644 index 0000000000..74f6f8e82c --- /dev/null +++ b/system/hardware/tici/esim.nmconnection @@ -0,0 +1,30 @@ +[connection] +id=esim +uuid=fff6553c-3284-4707-a6b1-acc021caaafb +type=gsm +permissions= +autoconnect=true +autoconnect-retries=100 +autoconnect-priority=2 +metered=1 + +[gsm] +apn= +home-only=false +auto-config=true +sim-id= + +[ipv4] +route-metric=1000 +dns-priority=1000 +dns-search= +method=auto + +[ipv6] +ddr-gen-mode=stable-privacy +dns-search= +route-metric=1000 +dns-priority=1000 +method=auto + +[proxy] diff --git a/system/hardware/tici/hardware.py b/system/hardware/tici/hardware.py index f46c94c4f0..8e4ba722c4 100644 --- a/system/hardware/tici/hardware.py +++ b/system/hardware/tici/hardware.py @@ -3,6 +3,7 @@ import math import os import subprocess import time +import tempfile from enum import IntEnum from functools import cached_property, lru_cache from pathlib import Path @@ -499,19 +500,18 @@ class Tici(HardwareBase): except Exception: pass - # we use the lte connection built into AGNOS. cleanup esim connection if it exists + # eSIM prime dest = "/etc/NetworkManager/system-connections/esim.nmconnection" - if os.path.exists(dest): - os.system(f"sudo nmcli con delete {dest}") - self.reboot_modem() - - def reboot_modem(self): - modem = self.get_modem() - for state in (0, 1): - try: - modem.Command(f'AT+CFUN={state}', math.ceil(TIMEOUT), dbus_interface=MM_MODEM, timeout=TIMEOUT) - except Exception: - pass + if sim_id.startswith('8985235') and not os.path.exists(dest): + with open(Path(__file__).parent/'esim.nmconnection') as f, tempfile.NamedTemporaryFile(mode='w') as tf: + dat = f.read() + dat = dat.replace("sim-id=", f"sim-id={sim_id}") + tf.write(dat) + tf.flush() + + # needs to be root + os.system(f"sudo cp {tf.name} {dest}") + os.system(f"sudo nmcli con load {dest}") def get_networks(self): r = {}