qmi-network.service: improve reliablity for slower and unstable networks (some go up and down like a yo-yo) and devices

This commit is contained in:
mpmc 2022-07-05 11:58:26 +01:00
parent 16402ce2b3
commit 4611223e21
1 changed files with 10 additions and 6 deletions

View File

@ -18,6 +18,9 @@ Type=simple
Restart=always
TimeoutSec=300s
# Make sure the state is cleared before starting.
ExecStartPre=-rm /tmp/qmi-network-state-cdc-wdm%i
# Stop wwan so it can be reconfigured.
ExecStartPre=networkctl down wwan%i
@ -25,21 +28,22 @@ ExecStartPre=networkctl down wwan%i
ExecStartPre=sh -c "echo 'Y' | tee /sys/class/net/wwan%i/qmi/raw_ip"
# Start the network via qmi-network scripts.
ExecStartPre=qmi-network /dev/cdc-wdm%i start
# As some networks and/or devices take a long time to connect we should
# give it some time to be ready before starting the connection process.
ExecStartPre=sh -e -c "sleep 60; qmi-network /dev/cdc-wdm%i start"
# Bring up the network.
ExecStartPre=networkctl up wwan%i
# We need to wait for dhcp to settle, then use ping to test connection
# is alive.
ExecStartPre=sh -e -c "sleep 10; ping -w 30 -I wwan%i -c 5 one.one.one.one"
# Small loop as the main process to watchdog the connection.
ExecStart=sh -e -c "while true; do sleep 300; ping -w 120 -I wwan%i -c 5 one.one.one.one; done;"
# (NOTE: DHCP must be given a little time to settle before pinging).
ExecStart=sh -e -c "sleep 10; while true; do ping -w 120 -I wwan%i -c 5 one.one.one.one; sleep 300; done;"
# Stop.. DOWN TIME!
ExecStop=networkctl down wwan%i
ExecStop=qmi-network /dev/cdc-wdm%i stop
# Be sure the network state is cleared on stop too.
ExecStop=-rm /tmp/qmi-network-state-cdc-wdm%i
[Install]
WantedBy=sys-subsystem-net-devices-wwan%i.device