modemmanager: add option to force connection
authorOliver Sedlbauer <osedlbauer@tdt.de>
Tue, 11 Jun 2024 13:48:51 +0000 (15:48 +0200)
committerOliver Sedlbauer <osedlbauer@tdt.de>
Tue, 11 Jun 2024 13:59:45 +0000 (15:59 +0200)
This commit improves the automatic reconnect logic. If the modem cannot
establish a connection, for example due to poor reception, the
proto_block_restart prevents the interface from trying to reconnect.
To enforce the connection, this commit adds a new option that allows the
system to attempt to establish a connection indefinitely.

Signed-off-by: Oliver Sedlbauer <osedlbauer@tdt.de>
net/modemmanager/Makefile
net/modemmanager/README.md
net/modemmanager/files/lib/netifd/proto/modemmanager.sh

index 0cfb304b6b6c0f8104236c0abf00dff1a4edb05c..87a6c6a22bd21fced43916a5cb855417e910e279 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=modemmanager
 PKG_VERSION:=1.22.0
-PKG_RELEASE:=13
+PKG_RELEASE:=14
 
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_URL:=https://gitlab.freedesktop.org/mobile-broadband/ModemManager.git
index 1def1c354f3464523e7c14e0d390f8d95104ba0c..473815170fb1d989516f6557d16aee411123bf98 100644 (file)
@@ -26,6 +26,7 @@ Once installed, you can configure the 2G/3G/4G modem connections directly in
         option lowpower    '1'
         option signalrate  '30'
         option allow_roaming '1'
+        option force_connection '1'
         option init_epsbearer '<none|default|custom>'
 
 Only 'device' and 'proto' are mandatory options, the remaining ones are all
@@ -44,6 +45,10 @@ The 'plmn' option allows to set the network operator MCCMNC.
 The 'signalrate' option set's the signal refresh rate (in seconds) for the device.
 You can call signal info with command: mmcli -m 0 --signal-get
 
+The 'force_connection' option is designed to ensure that the modem automatically
+attempts to reconnect regardless of any errors encountered during the
+connection process.
+
 If there is no Circuit switch network available, then an initial EPS
 bearer must be set, so this could be used during the network registration
 process in 4G and 5G network. For this resaon a new configuration option
index 67545513d0553105c89b13ea790db68de0f6cf10..ce051a76392f58fd7fe4821192c0472a84e98fdf 100644 (file)
@@ -274,6 +274,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)'
@@ -421,6 +422,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
@@ -430,7 +432,7 @@ proto_modemmanager_setup() {
 
        json_get_vars device apn allowedauth username password
        json_get_vars pincode iptype 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
@@ -471,8 +473,14 @@ 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
                }
        }
@@ -574,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
        }