{ "title": "modemmanager", "subtitle": "Handling modems from the Linux command line", "aliases": [ "/articles/modemmanager-essentials" ] } #### Introduction The software [ModemManager][4] handles modems on Linux operating systems. It has the `mmcli` command line utility included which exposes its functionality. It is possible to use `mmcli` to setup mobile internet connections, make phone calls and send SMS. This article summarizes some basic `mmcli` commands. It was written to further debug the issue described in [this postmarketOS issue][5]. #### Get modem summary With this command a summary about the modem is printed. It assumes just one connected modem (`-m any`) which should be given on nearly all devices: ``` mmcli -m any ``` #### Unlock a SIM card To actually do something with the modem it might be necessary to unlock the inserted SIM card: ``` # this command needs appropriate polkit authentication or root permissions mmcli -i "/org/freedesktop/ModemManager1/SIM/0" --pin "1234" ``` Use the SIM path listed in the summary (see section above). #### Enable modem In addition to unlocking the SIM card it is required to enable the modem: ``` # this command needs appropriate polkit authentication or root permissions mmcli -m any -e ``` #### List calls This command lists active, ringing, terminated and other calls: ``` mmcli -m any --voice-list-calls ``` The idea is that calls are tracked with the identifiers printed by this command which allows to send additional commands like accept or hangup. #### Accept a call An incoming call can be accepted like this: ``` # this command needs appropriate polkit authentication or root permissions mmcli -m any -o "/org/freedesktop/ModemManager1/Call/0" --accept ``` #### Hangup a call Any active call can be hung up like this: ``` # this command needs appropriate polkit authentication or root permissions mmcli -m any -o "/org/freedesktop/ModemManager1/Call/0" --hangup ``` #### Create a call To create a call one can use the following command. Take care to select the right phone number format. Given is an example phone number with German international prefix `+49`. ``` mmcli -m any --voice-create-call "number=+49123456789" ``` This command just registeres a new call. To actually start it one has to get its identifier with listing all calls and then start it like this: ``` # this command needs appropriate polkit authentication or root permissions mmcli -m any -o "/org/freedesktop/ModemManager1/Call/4" --start ``` It can be hung up like incoming calls. #### Further documentation Running `mmcli --help` and the there listed help commands provide a summary of all the functionality ModemManager provides. This article is just a brief subset of it. The [SXMO modem scripts][1] from the [SXMO project][2] helped me a lot to write this summary aswell as the [Chromium mmcli help page][3]. Of course the [ModemManager homepage][4] is the most official entry point to search for further documentation. [1]: https://git.sr.ht/~mil/sxmo-utils/tree/master/item/scripts/modem [2]: https://sxmo.org/ [3]: https://www.chromium.org/chromium-os/how-tos-and-troubleshooting/debugging-3g/modem-debugging-with-mmcli/ [4]: https://www.freedesktop.org/wiki/Software/ModemManager/ [5]: https://gitlab.com/postmarketOS/pmaports/-/issues/2113