Tutorial: Create a Shortcut to Modem Info

Today I was thinking that it would be great if the L5 could use dial codes like *#*#INFO#*#* to retrieve mobile network and modem info, just like Android phones. (It can’t at the moment.)

I had learned from skilled users here in the forum about the mmcli command. So I ran “mmcli -L” to get the identifier associated with my modem (“0”), then ran mmcli --modem=0 for a status report, which is somewhat similar to the output from the Android code. (Enter mmcli -h in the L5’s terminal to see all the other options.)

Then I recalled how @spaetz had created an automated quick-dial application a while back, and I wondered if I could use it as a guide to make a shortcut to the modem status information.

So I found a suitable icon from the GNOME Characters app and saved it as “satellite.png” in .local/share/icons:
satellite

Then I created the quick-dial/shortcut button in .local/share/applications, naming it ModemInfo.desktop.

Next I copied Spaetz’s content into ModemInfo.desktop and started adapting it and experimenting, attempting to make it open the terminal and execute mmcli --modem=0 automatically. After a little bit of research and some trial and error, I arrived at this:

[Desktop Entry]
Name=ModemInfo
Exec=gnome-terminal -x bash -c “mmcli --modem=0 | tee modeminfo.txt; exec bash”
StartupNotify=true
Terminal=false
Type=Application
Categories=Utilities;
Icon=/home/purism/.local/share/icons/satellite.png

…And it works!

Tapping my ModemInfo icon from the app grid opens the terminal, runs the command, displays the output in the terminal, and also saves it as modeminfo.txt in the home folder for easy viewing (landscape view works best…or view on a larger screen). The saved file will be written over every time with the command as written, but you can use different parameters if you don’t want to overwrite.



The modeminfo.txt output (redacted with “xxxxxx”):

  ----------------------------------
  General  |                   path: /org/freedesktop/ModemManager1/Modem/0
           |              device id: xxxxxxx
  ----------------------------------
  Hardware |           manufacturer: QUALCOMM INCORPORATED
           |                  model: 0
           |      firmware revision: MPSS.JO.2.0.2.c1.1-00032-9607_GENNS_PACK-1  1  [Feb 25 2019 01:00:00]
           |         carrier config: default
           |           h/w revision: 10000
           |              supported: gsm-umts, lte
           |                current: gsm-umts, lte
           |           equipment id: xxxxxxx
  ----------------------------------
  System   |                 device: /sys/devices/platform/soc@0/38200000.usb/xhci-hcd.4.auto/usb1/1-1/1-1.2
           |                drivers: qmi_wwan, option
           |                 plugin: broadmobi
           |           primary port: cdc-wdm0
           |                  ports: cdc-wdm0 (qmi), ttyUSB0 (qcdm), ttyUSB1 (at), ttyUSB2 (at), 
           |                         ttyUSB3 (at), wwan0 (net)
  ----------------------------------
  Status   |                   lock: sim-pin2
           |         unlock retries: sim-pin (3), sim-puk (10), sim-pin2 (3), sim-puk2 (10)
           |                  state: e[32mconnectede[0m
           |            power state: on
           |            access tech: lte
           |         signal quality: 60% (cached)
  ----------------------------------
  Modes    |              supported: allowed: 2g; preferred: none
           |                         allowed: 3g; preferred: none
           |                         allowed: 4g; preferred: none
           |                         allowed: 2g, 3g; preferred: 3g
           |                         allowed: 2g, 3g; preferred: 2g
           |                         allowed: 2g, 4g; preferred: 4g
           |                         allowed: 2g, 4g; preferred: 2g
           |                         allowed: 3g, 4g; preferred: 4g
           |                         allowed: 3g, 4g; preferred: 3g
           |                         allowed: 2g, 3g, 4g; preferred: 4g
           |                         allowed: 2g, 3g, 4g; preferred: 3g
           |                         allowed: 2g, 3g, 4g; preferred: 2g
           |                current: allowed: 2g, 3g, 4g; preferred: 4g
  ----------------------------------
  Bands    |              supported: pcs, g850, utran-4, utran-5, utran-2, eutran-2, eutran-3, 
           |                         eutran-4, eutran-5, eutran-12, eutran-13, eutran-17, eutran-25, 
           |                         eutran-26, eutran-41, eutran-66
           |                current: pcs, g850, utran-4, utran-5, utran-2, eutran-2, eutran-3, 
           |                         eutran-4, eutran-5, eutran-12, eutran-13, eutran-17, eutran-25, 
           |                         eutran-26, eutran-41, eutran-66
  ----------------------------------
  IP       |              supported: ipv4, ipv6, ipv4v6
  ----------------------------------
  3GPP     |                   imei: xxxxxxx
           |          enabled locks: fixed-dialing
           |            operator id: 310410
           |          operator name: Truphone
           |           registration: home
  ----------------------------------
  3GPP EPS |   ue mode of operation: csps-1
           |    initial bearer path: /org/freedesktop/ModemManager1/Bearer/2
           | initial bearer ip type: ipv4v6
  ----------------------------------
  SIM      |       primary sim path: /org/freedesktop/ModemManager1/SIM/0
  ----------------------------------
  Bearer   |                  paths: /org/freedesktop/ModemManager1/Bearer/0

Take that, Android!

10 Likes

P.S. Thanks, @spaetz! :slightly_smiling_face:

1 Like

Some other mmcli options:

purism@pureos:~$ mmcli -h
Usage:
  mmcli [OPTION…] - Control and monitor the ModemManager

Help Options:
  -h, --help                                                     Show help options
  --help-all                                                     Show all help options
  --help-manager                                                 Show manager options
  --help-common                                                  Show common options
  --help-modem                                                   Show modem options
  --help-3gpp                                                    Show 3GPP related options
  --help-3gpp-profile-manager                                    Show 3GPP profile management related options
  --help-3gpp-ussd                                               Show 3GPP USSD related options
  --help-cdma                                                    Show CDMA related options
  --help-simple                                                  Show Simple options
  --help-location                                                Show Location options
  --help-messaging                                               Show Messaging options
  --help-voice                                                   Show Voice options
  --help-time                                                    Show Time options
  --help-firmware                                                Show Firmware options
  --help-signal                                                  Show Signal options
  --help-oma                                                     Show OMA options
  --help-sim                                                     Show SIM options
  --help-bearer                                                  Show bearer options
  --help-sms                                                     Show SMS options
  --help-call                                                    Show call options

Application Options:
  -K, --output-keyvalue                                          Run action with machine-friendly key-value output
  -J, --output-json                                              Run action with machine-friendly json output
  -v, --verbose                                                  Run action with verbose logs
  -V, --version                                                  Print version
  -a, --async                                                    Use asynchronous methods
  --timeout=[SECONDS]                                            Timeout for the operation
2 Likes

I’m glad you’re here. I’d know way less about the phone otherwise.

3 Likes

And note that, provided you only have one modem, you can do: mmcli -m any

2 Likes

Glad my quick hack was useful. It is an easy way to “create” a new app. I think you can also dial these USSD codes through mmcli if not even through the dialer app, the only thing that does not work, is these visual menus that you can browse with some mobile phone operators.

2 Likes

Another option for the ModemInfo icon: the actual BM818 image:

EDIT: I added this tutorial to the community wiki.

3 Likes