Skip to content
Snippets Groups Projects

Draft: Implement initial functionality

Closed Martin Matějek requested to merge dev into master
All threads resolved!
Files
9
@@ -45,6 +45,7 @@ class WWanUci:
res = WWanUci._match_wwan_interface(if_name, dev_no, qmi_ctl_device, sim_status)
if not res:
# We could not find existing uci configuration for given device -> return defaults
qmi_devices.append({
"id": dev_no,
"enabled": False,
@@ -54,7 +55,7 @@ class WWanUci:
"pincode": "",
"authentication": {"auth_type": "none"},
"sim_status": sim_status,
}) # default/empty values
})
else:
qmi_devices.append(res)
@@ -100,7 +101,7 @@ class WWanUci:
else:
extra_auth = {"auth_type": "none"}
enabled = WWanUci._is_designated_as_wan(if_name)
enabled = NetworksUci.is_designated_as_wan(if_name)
return {
"id": dev_no,
@@ -181,16 +182,6 @@ class WWanUci:
return int(match.group(1))
@staticmethod
def _is_designated_as_wan(if_name: str) -> bool:
"""Check whether given interface is designated as WAN."""
wan_interfaces = NetworksUci.get_active_wan_interfaces()
if not wan_interfaces:
return False
# NOTE: is set really needed here?
return set(wan_interfaces) == {if_name}
class WWanCmd(BaseCmdLine):
@staticmethod
@@ -202,6 +193,14 @@ class WWanCmd(BaseCmdLine):
just whether SIM card is 'working' or not.
"""
try:
# There are two utilities to fetch information from QMI modem - 'qmicli' and 'uqmi'.
# 'qmicli' is more recent and it looks like it is actively
# maintained, but at the moment it can produce only text output.
# 'uqmi' is older and it could get stuck while trying to fetch SIM
# state informations on certain modems. But it produces json output.
#
# Therefore I decided to go with 'uqmi' and set timeout for its
# process, in case it gets stuck.
stdout, _ = WWanCmd._run_command_and_check_retval(
["/sbin/uqmi", "-d", ctl_device, "--uim-get-sim-state"],
expected_retval=0, timeout=20