Gracefully handling signal loss and reconnect
rusttree
rusttree at gmail.com
Sat May 19 03:56:50 UTC 2018
I have a 4G LTE modem (Sierra Wireless MC7354) on an embedded Linux device.
I'm struggling to understand the best way to detect a loss of signal and
gracefully reconnect. On power up, I can connect to the Verizon LTE network
using this script:
### Script Begin ###
if [ ! -f /etc/qmi-network.conf ]; then
#only needs to run once ever
echo "APN=WE01.VZWSTATIC" > /etc/qmi-network.conf
echo "PROXY=yes" >> /etc/qmi-network.conf
fi
qmicli -p -d /dev/cdc-wdm0 --wda-set-data-format=802-3
qmi-network /dev/cdc-wdm0 start
ip link set wwan0 up
udhcpc -t 2 -n -i wwan0
### Script End ###
My first issue is just detecting when the signal is lost. I simulate a bad
connection by unplugging the LTE antenna. If I run
--wds-get-packet-service-status, it just keeps telling me "connected" even
when the signal is completely lost for several minutes. I've found I have
to ping a server (usually 8.8.8.8) to know the signal is lost.
Then, when I plug the antenna back in after several minutes, it continues
to think it's connected, but I can't ping anything. I do this:
qmi-network /dev/cdc-wdm0 stop
qmi-network /dev/cdc-wdm0 start
udhcpc -t 2 -n -i wwan0
But I get a "CallFailed" error with reason "generic-no-service". Something
seems to be hung up after it losses the signal and it can't recover, even
after the antenna is back in place and it should be getting good signal.
So then I tried enabling autoconnect. When it's enabled on bootup, I run
the following commands at the prompt:
ip link set wwan0 up
udhcpc -t 2 -n -i wwan0
But the udhcpc call fails. So I figured out I have to disable autoconnect
on bootup, run the original script above, then re-enable autoconnect. Under
those conditions, I can run udhcpc after the signal is lost and recovered
and *usually* it will re-obtain the IP address and let me back on the
network. Even if that usually works, my script would fail if the LTE signal
is not present at the beginning on power-up.
I feel like I'm approaching this wrong. It seems like dealing with finicky
signal strength is par for the course in any wireless device. I'd
appreciate any pointers on best practices for gracefully handling lost
connections and reconnects. Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libqmi-devel/attachments/20180518/c1401982/attachment.html>
More information about the libqmi-devel
mailing list