From 91f4fc159bc0803cefd542cbdb1c566d87d09fa9 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Thu, 13 Jun 2024 20:00:40 +0200 Subject: [PATCH] Do not disable modem in ModemManager on reconnect using feckert pull request to OpenWRT --- modemmanager/files/lib/netifd/proto/modemmanager.sh | 13 +++++++++++-- .../lib/ModemManager/connection.d/10-report-down | 2 ++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/modemmanager/files/lib/netifd/proto/modemmanager.sh b/modemmanager/files/lib/netifd/proto/modemmanager.sh index 67545513d..89a5a09f3 100644 --- a/modemmanager/files/lib/netifd/proto/modemmanager.sh +++ b/modemmanager/files/lib/netifd/proto/modemmanager.sh @@ -710,8 +710,17 @@ proto_modemmanager_teardown() { mmcli --modem="${device}" --simple-disconnect || proto_notify_error "${interface}" DISCONNECT_FAILED - # disable - mmcli --modem="${device}" --disable + # reading variable from var state which was set in + # '/usr/lib/ModemManager/connection.d/10-report-down' + # because of a reconnect event. + # The modem therefore does not need to be disabled. + local disable="$(uci_get_state network "$interface" disable_modem "1")" + if [ "${disable}" -eq 0 ]; then + echo "Skipping modem disable" + uci_revert_state network "${interface}" disable_modem + else + mmcli --modem="${device}" --disable + fi # low power, only if requested [ "${lowpower:-0}" -lt 1 ] || diff --git a/modemmanager/files/usr/lib/ModemManager/connection.d/10-report-down b/modemmanager/files/usr/lib/ModemManager/connection.d/10-report-down index b8feb2677..a5728b6c6 100644 --- a/modemmanager/files/usr/lib/ModemManager/connection.d/10-report-down +++ b/modemmanager/files/usr/lib/ModemManager/connection.d/10-report-down @@ -32,6 +32,8 @@ IFUP=$(ifstatus "${CFG}" | jsonfilter -e "@.up") [ "${IFUP}" = "true" ] && { mm_log "info" "Reconnecting '${CFG}' on '${STATE}' event" + + uci_toggle_state network "${CFG}" disable_modem "0" ubus call network.interface down "{ 'interface': '${CFG}'}" ubus call network.interface up "{ 'interface': '${CFG}'}" }