From 380117a15529a81c88335910bbaf77645f88d72a Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Fri, 21 Jun 2024 19:35:03 +0200 Subject: [PATCH] Add force connection setting to ModemManager --- .../files/lib/netifd/proto/modemmanager.sh | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/modemmanager/files/lib/netifd/proto/modemmanager.sh b/modemmanager/files/lib/netifd/proto/modemmanager.sh index b38637ab0..d6e4fb689 100644 --- a/modemmanager/files/lib/netifd/proto/modemmanager.sh +++ b/modemmanager/files/lib/netifd/proto/modemmanager.sh @@ -276,6 +276,7 @@ proto_modemmanager_init_config() { proto_config_add_int signalrate proto_config_add_boolean lowpower proto_config_add_boolean allow_roaming + proto_config_add_boolean force_connection proto_config_add_string init_epsbearer proto_config_add_string init_iptype proto_config_add_string 'init_allowedauth:list(string)' @@ -423,6 +424,7 @@ proto_modemmanager_setup() { local device apn allowedauth username password pincode local iptype plmn metric signalrate allow_roaming + local force_connection local init_epsbearer local init_iptype init_allowedauth @@ -432,7 +434,7 @@ proto_modemmanager_setup() { json_get_vars device apn allowedauth username password json_get_vars pincode iptype sourcefilter plmn metric signalrate allow_roaming - json_get_vars allowedmode preferredmode + json_get_vars allowedmode preferredmode force_connection json_get_vars init_epsbearer json_get_vars init_iptype init_allowedauth @@ -473,8 +475,13 @@ proto_modemmanager_setup() { mmcli --modem="${device}" \ --timeout 120 \ --3gpp-register-in-operator="${plmn}" || { - proto_notify_error "${interface}" MM_3GPP_OPERATOR_REGISTRATION_FAILED - proto_block_restart "${interface}" + if [ -n "${force_connection}" ] && [ "${force_connection}" -eq 1 ]; then + echo "3GPP operator registration failed -> attempting restart" + proto_notify_error "${interface}" MM_INTERFACE_RESTART + else + proto_notify_error "${interface}" MM_3GPP_OPERATOR_REGISTRATION_FAILED + proto_block_restart "${interface}" + fi return 1 } } @@ -551,7 +558,6 @@ proto_modemmanager_setup() { # setup connect args; APN mandatory (even if it may be empty) echo "starting connection with apn '${apn}'..." - proto_notify_error "${interface}" MM_CONNECT_IN_PROGRESS # setup allow-roaming parameter if [ -n "${allow_roaming}" ] && [ "${allow_roaming}" -eq 0 ];then @@ -576,8 +582,13 @@ proto_modemmanager_setup() { append_param "${password:+password=${password}}" mmcli --modem="${device}" --timeout 120 --simple-connect="${connectargs}" || { - proto_notify_error "${interface}" MM_CONNECT_FAILED - proto_block_restart "${interface}" + if [ -n "${force_connection}" ] && [ "${force_connection}" -eq 1 ]; then + echo "Connection failed -> attempting restart" + proto_notify_error "${interface}" MM_INTERFACE_RESTART + else + proto_notify_error "${interface}" MM_CONNECT_FAILED + proto_block_restart "${interface}" + fi return 1 }