Latest firmware for PinePhone modem!
(05-06-2022, 01:29 PM)robthebold Wrote: I wonder if there's anything I can do script-wise that can periodically check on cellular connectivity and alert me that I should reboot the phone. I'll post if I find anything useful on that.

Sorry for reviving a dead thread, but I could not see your profile to pm you and I saw that your account seems to still be active.

Here is a script that you can put in either your user or the root's crontab depending on if you want your phone to reboot automatically upon a modem crash.

Here is the ugly script that I use to do that and I adapted it with notify-send if you would rather have notifications instead of a cold reboot.

Notes
- this assumes a non systemd distro (I am not familiar with systemd) (iirc, you use postmarketos)
- It is not php code, it is only the text editor that puts that title

Desktop notification on modem crash (non automatic reboot)
0. Create the directory `/opt/sbin/`

Code:
# mkdir -p /otp/sbin


1. Put this script in `/opt/sbin/modem-check`


PHP Code:
#!/bin/sh
export LANG="en_US.UTF-8"
MODEM_STATE=`nmcli device|grep cdc-wdm0|head -n1|xargs|cut -f3 -d' '`
MODEM_STATE_CONNECTED="connected"

if [ "$MODEM_STATE!= "$MODEM_STATE_CONNECTED]; then
        notify
-send "Modem crashed. Reboot in order to bring it back online."
fi 


2.1 Open the crontab for your user (not root, not through sudo)

PHP Code:
crontab -


2.2 Add the following line at the bottom of your crontab

PHP Code:
*/30    *      *      *      *      /opt/sbin/modem-check 


2.3 Save it and quit

3. Enable crond

PHP Code:
# rc-update add crond 


4. Start crontab monitoring without rebooting

PHP Code:
# rc-service crond start 


Automatic reboot on modem crash
If you want to reboot your phone automatically (Be careful, as you could experience data loss if you are using the phone while the phone reboots)

0. Create the directory `/opt/sbin/`

PHP Code:
# mkdir /otp/sbin 


1. Put the script code in `/opt/sbin/modem-check`


PHP Code:
#!/bin/sh
export LANG="en_US.UTF-8"
MODEM_STATE=`nmcli device|grep cdc-wdm0|head -n1|xargs|cut -f3 -d' '`
MODEM_STATE_CONNECTED="connected"
LOG="/var/log/modem-check-crash"

if [ "$MODEM_STATE!= "$MODEM_STATE_CONNECTED]; then
        
echo "`date '+%Y-%m-%d %T'`: modem crashed, rebooting." >> "$LOG"
        reboot
fi 


2.1 Open the crontab for the root user

PHP Code:
# crontab -e 


2.2 Add the following line at the bottom of the root's crontab

PHP Code:
*/30    *      *      *      *      /opt/sbin/modem-check 


2.3 Save it and quit

3. Enable crond

PHP Code:
# rc-update add crond 


4. Start crontab monitoring without rebooting

PHP Code:
# rc-service crond start 
  Reply


Messages In This Thread
RE: Latest firmware for PinePhone modem! - by bacydentir85 - 02-02-2025, 08:47 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  asterisk or FreePBX on pinephone? vanja 0 34 6 hours ago
Last Post: vanja
  Jami on Pinephone [ IM and VOIP ] p1trson 15 21,955 11 hours ago
Last Post: marlboro1950
  Movuan distribution for PinePhone merom 6 6,393 06-04-2026, 02:10 AM
Last Post: merom
  Fedora + Phosh for PinePhone njha 77 215,782 01-14-2026, 12:22 AM
Last Post: tllim
  Difficulty with openSUSE Tumbleweed Install PinePhone Beta danm1988 0 709 11-17-2025, 07:49 AM
Last Post: danm1988
  baremetal via Zig on PinePhone - JumpDrive help please WhiteHexagon 1 3,847 07-07-2025, 10:33 AM
Last Post: WhiteHexagon
  Slarm64 on PinePhone [Unofficial Slackware ARM - 64 bit] acid andy 40 63,781 12-28-2024, 12:19 AM
Last Post: mara
  Office applications for the Pinephone Peter Gamma 2 5,156 09-05-2024, 09:22 AM
Last Post: Peter Gamma
  Struggle to install LibreOffice on the PinePhone Peter Gamma 50 71,872 07-26-2024, 10:35 PM
Last Post: Peter Gamma
  Why does Pine64 sabotage office on the Pinephone? Peter Gamma 5 6,835 07-04-2024, 07:34 AM
Last Post: Kevin Kofler

Forum Jump:


Users browsing this thread: 3 Guest(s)