From 4cd0e107b1a900058c6717bf9fc45d055a691414 Mon Sep 17 00:00:00 2001 From: Jonathan Cave Date: Tue, 9 Aug 2022 14:09:55 +0100 Subject: Change: detect modem primary port using mmcli The control interface needed to be specified in the checkbox.conf to execute the gsm connection test. This is a minimal change to now pull that information from mmcli --- bin/wwan_tests.py | 14 +++++++++++--- units/wwan/jobs.pxu | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/bin/wwan_tests.py b/bin/wwan_tests.py index a2af54e..39764d4 100755 --- a/bin/wwan_tests.py +++ b/bin/wwan_tests.py @@ -209,6 +209,9 @@ class MMCLI(): def get_model_name(self, mm_id): return _value_from_table('modem', mm_id, 'model') + def get_primary_port(self, mm_id): + return _value_from_table("modem", mm_id, "primary port") + def sim_present(self, mm_id): if self._get_sim_id(mm_id) is None: return False @@ -296,8 +299,8 @@ class ThreeGppConnection(): def invoked(self): parser = argparse.ArgumentParser() - parser.add_argument('wwan_control_if', type=str, - help='The control interface for the device') + parser.add_argument('hw_id', type=str, + help='The hardware ID of the modem') parser.add_argument('wwan_net_if', type=str, help='The network interface used when connected') parser.add_argument('apn', type=str, @@ -305,9 +308,14 @@ class ThreeGppConnection(): parser.add_argument('wwan_setup_time', type=int, default=30, help='delay before ping test') args = parser.parse_args(sys.argv[2:]) + + mm = MMCLI() + mm_id = mm.equipment_id_to_mm_id(args.hw_id) + wwan_control_if = mm.get_primary_port(mm_id) + ret_code = 1 try: - _create_3gpp_connection(args.wwan_control_if, args.apn) + _create_3gpp_connection(wwan_control_if, args.apn) _wwan_radio_on() time.sleep(args.wwan_setup_time) ret_code = _ping_test(args.wwan_net_if) diff --git a/units/wwan/jobs.pxu b/units/wwan/jobs.pxu index 93f9c68..f651a42 100644 --- a/units/wwan/jobs.pxu +++ b/units/wwan/jobs.pxu @@ -37,7 +37,7 @@ _description: plugin: shell command: BEGIN_CONNECTION_TEST_TS=$(date '+%Y-%m-%d %H:%M:%S') - wwan_tests.py 3gpp-connection "$WWAN_CONTROL_IF" "$WWAN_NET_IF" "$WWAN_APN" "${{WWAN_SETUPTIME:-30}}" + wwan_tests.py 3gpp-connection {hw_id} "$WWAN_NET_IF" "$WWAN_APN" "${{WWAN_SETUPTIME:-30}}" RETVAL=$? if [ $RETVAL -ne 0 ]; then echo "==== Service units logs ====" -- cgit v1.2.3