Archiv der Kategorie: PinePhone

Update PP modem time from internet

My provider (bob in Austria) does not provide time via the mobile network. Consequently, the Pinephone modem does not have current time which can lead to problems using AGPS and also with SMS.

The Pinephone has two clocks, the baseband time and the modem userspace time. The modem userspace time can be set with the date command (via adb). However, the newest open source firmware from biktorgj will use the baseband time if that is available. So it suffices to set the baseband (CCLK) time.

We do this via a systemd timer unit, as there is no crontab on mobian,

  1. enable time-sync target so we only start syncing the modem once we have internet time
sudo systemctl enable systemd-time-wait-sync

2. create files

sudo vi /etc/systemd/system/setmodemtime.service

Description=Set Modem Time from Internet Time
ExecStart=/bin/bash /home/mobian/scripts/

sudo vi /etc/systemd/system/setmodemtime.timer

Description=Timer for setting Modem time from internet time



vi /home/mobian/scripts/

#! /bin/sh
set -x

if  [ "$(id -u)" -ne 0 ]; then
  echo "Please run as root"

# Set timezone offset, for me thats UTC/GMT+1
# CCLK wants the timezone offset in two-digits of quarterhours, so GMT+1 is "+04"
# set modem baseband time via AT command
mmcli -m any --command=$(echo AT+CCLK=\"`date -u +%y/%m/%d,%H:%M:%S$offset`\")

chmod +x /home/mobian/scripts/

3. Allow ModemManager to send AT commands

Nowadays ModemManager is running in a restricted mode which bars it from sending AT commands to the modem. We need to enable AT commands by setting it into „debug mode“

sudo vi /usr/lib/systemd/system/ModemManager.service.d/mobile-tweaks.conf
Add --debug to the ExecStart Command
sudo systemctl daemon-reload
sudo service ModemManager restart

4. enable timer

sudo systemctl enable setmodemtime.timer

5. check that it works

systemctl list-timers --all
sudo systemctl status setmodemtime.service
sudo mmcli -m any --command='AT+CCLK?'