mmcli command examples
mmcli – Control and monitor the ModemManager
Send the PIN to the SIM card
You’ll need first to know which the proper path/index is for the SIM in your modem:
$ mmcli -m 0 | grep SIM SIM | path: '/org/freedesktop/ModemManager1/SIM/0'
And after that, you can just use the SIM index:
$ mmcli -i 0 --pin=1234 successfully sent PIN code to the SIM
Simple connect and disconnect
You can launch the simple connection process like:
$ mmcli -m 0 --simple-connect="pin=1234,apn=internet" successfully connected the modem
Then, you can disconnect it like:
$ mmcli -m 0 --simple-disconnect successfully disconnected all bearers in the modem
3GPP network scan
Scanning for 3GPP networks may really take a long time, so a specific timeout must be given:
$ mmcli -m 0 --3gpp-scan --timeout=300
Found 4 networks: 21404 - Yoigo (umts, available) 21407 - Movistar (umts, current) 21401 - vodafone ES (umts, forbidden) 21403 - Orange (umts, forbidden)
Creating a new SMS message & storing it
Using the “sm” (SIM), you can do this using:
$ mmcli -m 0 --messaging-create-sms="text='Hello world',number='+1234567890'" Successfully created new SMS: /org/freedesktop/ModemManager1/SMS/21 (unknown)
$ sudo mmcli -s 21 --store-in-storage="sm" successfully stored the SMS
$ sudo mmcli -s 21 SMS '/org/freedesktop/ModemManager1/SMS/21'
Content | number: '+1234567890' | text: 'Hello world' Properties | PDU type: 'submit' | state: 'stored' | smsc: 'unknown' | validity: '0' | class: '0' | storage: 'sm' | delivery report: 'not requested' | message reference: '0'
$ sudo mmcli -m 0 --messaging-status /org/freedesktop/ModemManager1/Modem/0 Messaging | supported storages: 'sm, me' | default storage: 'me'
Sending SMS messages from files
As you can see below, the important part is the –messaging-create-sms-with-data and the PATH provided.
$ sudo mmcli -m 0 \ --messaging-create-sms="number='+1234567890'" \ --messaging-create-sms-with-data=/path/to/your/file Successfully created new SMS: /org/freedesktop/ModemManager1/SMS/22 (unknown)
$ sudo mmcli -s 22 --send successfully sent the SMS
Listing SMS messages
When the receiver gets all the parts of the message, they can now recover the sent file with another mmcli command in their ModemManager setup:
$> sudo mmcli -m 0 --messaging-list-sms
Found 1 SMS messages: /org/freedesktop/ModemManager1/SMS/0 (received)
$> sudo mmcli -s 0 --create-file-with-data=/path/to/the/output/file
GPS location status
You first need to check whether the modem has GPS-specific location capabilities. Note that we’ll assume the modem is exposed as index 0; if you have more than one modem, just use –list-modems to check the proper modem index:
$ mmcli -m 0 --location-status /org/freedesktop/ModemManager1/Modem/0 Location | capabilities: '3gpp-lac-ci, gps-raw, gps-nmea' | enabled: 'none' | signals: 'no'
The output says that the modem supports 3GPP Location area code/Cell ID, GPS raw and GPS-NMEA location sources. None is enabled yet, as we didn’t enable the modem, which we can do issuing:
$ sudo mmcli -m 0 --enable successfully enabled the modem
$ mmcli -m 0 --location-status /org/freedesktop/ModemManager1/Modem/0 Location | capabilities: '3gpp-lac-ci, gps-raw, gps-nmea' | enabled: '3gpp-lac-ci' | signals: 'no'
GPS location technology enabling
We can enable the RAW and NMEA GPS location sources using:
$ sudo mmcli -m 0 \ --location-enable-gps-raw \ --location-enable-gps-nmea successfully setup location gathering
If we do check again the status, we’ll see the GPS-specific locations are enabled:
$ mmcli -m 0 --location-status /org/freedesktop/ModemManager1/Modem/0 Location | capabilities: '3gpp-lac-ci, gps-raw, gps-nmea' | enabled: '3gpp-lac-ci, gps-raw, gps-nmea' | signals: 'no'
GPS location retrieval
You can query location source specific information with –location-get-3gpp, –location-get-gps-nmea and –location-get-gps-raw; but also for all at the same time:
$ sudo mmcli -m 0 --location-get /org/freedesktop/ModemManager1/Modem/0
3GPP location | Mobile country code: '214' | Mobile network code: '3' | Location area code: '21071' | Cell ID: '7033737'
GPS NMEA traces | $GPGGA,,,,,,0,,,,,,,,*66 | $GPRMC,,V,,,,,,,,,,N*53 | $GPGSA,A,1,,,,,,,,,,,,,,,*1E | $GPGSV,4,1,16,24,,,,29,,,,05,,,,18,,,*7A | $GPGSV,4,2,16,22,,,,14,,,,11,,,,17,,,*7B | $GPGSV,4,3,16,03,,,,12,,,,30,,,,13,,,*78 | $GPGSV,4,4,16,23,,,,15,,,,27,,,,07,,,*79 | $GPVTG,,T,,M,,N,,K,N*2C Raw GPS | Not available CDMA BS | Not available
An example of RAW GPS location information:
$ sudo mmcli -m 0 --location-get-gps-raw /org/freedesktop/ModemManager1/Modem/0
Raw GPS | UTC time: '155142.2' | Longitude: '-3.513941' | Latitude: '40.502603' | Altitude: '18.000000'