Ok, I believe I have things working now:
Note that I get several clicks when stopping eg25-manager.
I haven't bothered dealing with the ofonoctl status as I don't believe it makes any difference (as in if powered / online).
You can safely ignore the output of ofonoctl wan --connect if you run Data on multiple times, it still works.
Let me know if you're having any issues.
Code:
#!/bin/bash
COLUMNS=15
PS3="Select the action: "
options=(Mobile_on Mobile_off Data_on Data_off quit)
select opt in "${options[@]}"
do
WWAN="wwan0"
case $opt in
Mobile_on)
status=$(sudo systemctl status eg25-manager | grep running)
if [ "$status" = "" ]; then
echo " Starting eg25-manager..."
sudo systemctl start eg25-manager
sleep 20
fi
echo " Modem powering on and going online..."
sudo ofonoctl poweron
sudo ofonoctl online
sleep 5
ofonoctl
break
;;
Mobile_off)
echo " Modem going offline and powering off..."
sudo ofonoctl offline
sudo ofonoctl poweroff
echo " Stopping eg25-manager..."
sudo systemctl stop eg25-manager
ofonoctl
break
;;
Data_on)
status=$(sudo systemctl status eg25-manager | grep running)
if [ "$status" = "" ]; then
echo " Starting eg25-manager..."
sudo systemctl start eg25-manager
sleep 20
fi
echo " Modem powering on and going online..."
sudo ofonoctl poweron
sudo ofonoctl online
sleep 5
sudo ip link set dev $WWAN down
sudo ip link set dev $WWAN up
#str=$(ofonoctl wan | grep $WWAN)
#echo "str=["$str"]"
echo " Running ofonoctl wan --connect"
sudo ofonoctl wan --connect
ip_addr=$(ip a | grep $WWAN | awk '/inet / {gsub("addr:","",$2); print $2}')
#echo "ip_addr="$ip_addr
ip_route=$(ip r | grep $WWAN | grep default)
#echo "ip_route="$ip_route
sudo ip r del $ip_route
echo " Adding route "$ip_route" proto dhcp metric 900"
sudo ip r add $ip_route proto dhcp metric 900
echo "ip a:"
ip a | grep $WWAN
echo "ip r:"
ip r | grep $WWAN
break
;;
Data_off)
ip_addr=$(ip a | grep $WWAN | awk '/inet / {gsub("addr:","",$2); print $2}')
sudo ip link set dev $WWAN down
sudo ip a del $ip_addr dev $WWAN
echo " Deleting route and ip address"
echo "ip a:"
ip a | grep $WWAN
echo "ip r:"
ip r | grep $WWAN
break
;;
quit)
break
exit
;;
"")
echo "Invalid input."
;;
esac
done
read -p "Press enter to exit."
Note that I get several clicks when stopping eg25-manager.
I haven't bothered dealing with the ofonoctl status as I don't believe it makes any difference (as in if powered / online).
You can safely ignore the output of ofonoctl wan --connect if you run Data on multiple times, it still works.
Let me know if you're having any issues.
Pinephone v1.2 UBports CE. Adelaide, Australia using Amaysim SIM (Optus network, VoLTE enabled) with Mobian SD card. VoLTE working also with Felix / Vodafone AU and Aldimobile / Telstra AU.
Manjaro Plasma Mobile on EMMC.
Manjaro Plasma Mobile on EMMC.