Automated LTE Modem script for uConsole CM4

main
SleepingCows 2024-06-06 04:01:38 -04:00
parent 0fb9dae4a1
commit 4f3268ccdc
1 changed files with 20 additions and 0 deletions

20
uConsole/modem.sh Normal file
View File

@ -0,0 +1,20 @@
#!/bin/bash
#reset modem first
APN="Wholesale" #set your APN name here for network manager.
#power-off the modem in case it's already on.
uconsole-4g-cm4 disable
#power-on modem.
uconsole-4g-cm4 enable
echo "sudo: restart modemmanager"
sudo systemctl restart ModemManager.service
echo "waiting 10s for modem detection"
sleep 10
#todo: check 'mmcli -m any | grep "primary port"'
# save the ttyUSB port value, inject it into socat and nmcli commands.
echo "attempting startup"
echo -en "AT+CUSBPIDSWITCH?\r\n" | sudo socat - /dev/ttyUSB2,crnl
echo "sudo: reset & re-add modem to network manager"
sudo nmcli c del 4gnet
sudo nmcli c add type gsm ifname ttyUSB3 con-name 4gnet apn $APN