Enabling GPS location in ModemManager

Location information in ModemManager

Since MM 0.5 at least, ModemManager comes with a Location interface which is defined to expose not only 3GPP-specific location information (operator MMC/MNC + Location area code + Cell ID), but also GPS-specific location information (cached NMEA traces and raw location information). In MM 0.7, this Location interface will actually work for GPS location, at least for Option modems with GPS capabilities.

The HSO plugin

The High-Speed Option plugin is probably one of the most complex plugins being handled in ModemManager. In the new ModemManager 0.7 codebase, HSO modems (MMBroadbandModemHso) are implemented as a subclass of the standard Option modems (MMBroadbandModemOption), as they share lots of common features (allowed modes management, access technology and signal quality reporting…); but they also implement lots of connection related HSO-specific features (e.g. success of a connection establishment gets notified via unsolicited messages), which are most of them handled in a new HSO-specific bearer. Some of these advanced Option modems come with additional surprises: GPS-specific ports (AT port for control, raw serial port for NMEA traces).

The HSO modems provide detailed information about the type of each port being exposed in the USB interface; and so during the probing phase we are able to easily grab the GPS-control AT port and the additional serial port for NMEA traces (handled by a new MMGpsSerialPort port type). Once the HSO modem knows it has these two ports, it will allow to enable or disable any of the two GPS-specific location sources (NMEA or raw), or both at the same time. The NMEA location source will enable the modem to expose the last cached NMEA traces; while the raw location source will tell the modem to just expose generic location information such as time, latitude, longitude and altitude. In the case of the HSO modem (and possibly in every other case), both location sources are actually implemented based on the same NMEA traces received (raw information is parsed from $GTGGA traces). In addition to the core GPS location handling and the HSO-specific implementation, libmm-glib and mmcli where also improved to easily play with the new features.

Trying the GPS location retrieval with your Option modem

If you want to give a quick try to these capabilities, grab ModemManager git master, compile, install and plug in your modem. 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
  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
  Location | capabilities: '3gpp-lac-ci, gps-raw, gps-nmea'
           |      enabled: '3gpp-lac-ci'
           |      signals: 'no'

The 3GPP location source will always be enabled by default if it is supported by the modem, while the GPS-specific ones will always be disabled by default. The reasoning behind this is that the 3GPP LAC/CI comes for free in C(G)REG notifications when C(G)REG=2 is supported, while the GPS location is usually an additional module in the modem, with high power consumption. Using mmcli, we can now enable both GPS raw and NMEA location sources:

$ sudo mmcli -m 0 \
             --location-enable-gps-raw \
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
  Location | capabilities: '3gpp-lac-ci, gps-raw, gps-nmea'
           |      enabled: '3gpp-lac-ci, gps-raw, gps-nmea'
           |      signals: 'no'

Once they are enabled, ModemManager will start receiving NMEA traces in the GPS raw port, and will start to cache and process them. mmcli allows to show location-source-specific information with --location-get-3gpp, --location-get-gps-nmea and --location-get-gps-raw; but it also allows to query for all at the same time:

$ sudo mmcli -m 0 --location-get
  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

Note that ModemManager will expose only the last received NMEA traces of each kind, except for those ($GPGSV here) that are actually building a sequence.

Once the GPS module fixes a position, we’ll process the $GPGGA NMEA trace to get valid GPS location information:

$ sudo mmcli -m 0 --location-get-gps-raw
  Raw GPS         |  UTC time: '155142.2'
                  | Longitude: '-3.513941'
                  |  Latitude: '40.502603'
                  |  Altitude: '18.000000'

What about other modems?

Well, if the modem exposes GPS-specific ports in the same USB interface, it shouldn’t be difficult to add support for them, specially now that all the core/libmm-glib/mmcli work is already available.

A special case is when the modem exposes a single AT port via USB and the GPS port via RS232 (e.g. Sierra Wireless FXT009 with GPS extension). This case is a bit more tricky as there is no easy way for ModemManager to tell that the RS232 port is to be managed by the same modem object created after grabbing the AT port. In this case, the user may need to explicitly set some magic udev tags to let ModemManager handle the needed logic, but that also may get tricky if the user has more than one such modem plugged in (not sure for what, but anyway).


Posted on March 29, 2012, in Development, GNU Planet, Planets, Programs and tagged , , , , . Bookmark the permalink. 22 Comments.

  1. Ralf Habacker

    Tried MM 0.7 on opensuse 11.4 with Dell wireless 5540 card
    Bus 002 Device 004: ID 413c:8184 Dell Computer Corp. F3607gw v2 Mobile Broadband Module

    which has a gps device onboard, but mm did not detect it

    mmcli -m 0 –location-status
    Location | capabilities: ‘3gpp-lac-ci’
    | enabled: ‘3gpp-lac-ci’
    | signals: ‘no’

    Any idea how to solve the problem ?

  2. GPS location support is currently only developed for Option/HSO modems :-/

  3. Rohit Salunke

    sudo mmcli -m 0 –location-get-gps-raw this line does not return anything. It gives me output as :
    Raw GPS | Not available

  4. What modem is this? Did you get any NMEA trace reported in --location-get-gps-nmea? That reply you got is common when the GPS didn’t get a position fix yet.

  5. Rohit Salunke

    This is the reply I got:

    pi@pi-desktop:~$ sudo mmcli -m 0 –location-get

    3GPP location | Mobile country code: ‘404’
    | Mobile network code: ’27’
    | Location area code: ‘3061’
    | Cell ID: ‘340881’
    GPS NMEA traces | $GPGGA,,,,,,0,,,,,,,,*66
    | $GPGSV,4,1,16,09,,,,25,,,,05,,,,13,,,*72
    | $GPGSV,4,2,16,32,,,,24,,,,29,,,,18,,,*7D
    | $GPGSV,4,3,16,22,,,,04,,,,11,,,,17,,,*7B
    | $GPGSV,4,4,16,03,,,,12,,,,30,,,,01,,,*7C
    | $GPVTG,,T,,M,,N,,K,N*2C
    | $GPRMC,,V,,,,,,,,,,N*53
    | $GPGSA,A,1,,,,,,,,,,,,,,,*1E
    Raw GPS | Not available
    CDMA BS | Not available

  6. Rohit Salunke

    This modem is Huawei MU609…and i have mounted installed it in MiniPCIE of my mother board…
    I have enabled modem and followed all steps….I got output as mentioned above… Can u pls look after this?

  7. Well, this all looks good to me. You just need to have better coverage in the GPS antenna so that you get a position fix, which you don’t have yet. You’ll see the “raw GPS” contents processed in the DBus API only when you get some valid data in the $GPGGA NMEA trace.

  8. Rohit Salunke

    Ok, thanks for reply. I will try for the same. 🙂

  9. How do I connect this GPS data to gpsd? ie. How do I cause an NMEA stream to come out of /dev/USB2?

  10. In recent ModemManager versions we support the “unmanaged GPS” location setting. When that is enabled, ModemManager takes care of telling the modem to enable GPS, but it will not try to read the NMEA GPS traces from the tty, that is left for other apps to do, like gpsd.

  11. How do I tell which port I can read the data from (i.e. with gpsd)? I have a modem where –location-get shows me the Raw GPS location, but I can’t seem to get any data from any tty. What am I missing?

  12. If you enable either the “gps raw” or “gps nmea” sources, then ModemManager takes full control of the TTY where the GPS traces are dumped; i.e. you cannot run gpsd in that case. What we do have is the “gps unmanaged” source; if you enable that we will just instruct the modem to start GPS tracking and ModemManager will not touch the TTY so that gpsd can use it; you should try that.

  13. Thanks for your fast reply, I really appreciate that. Here is what I found:
    $ mmcli –version

    mmcli 1.4.12

    $ mmcli -m 2 –location-enable-gps-unmanaged
    error: couldn’t setup location gathering: ‘GDBus.Error:org.freedesktop.ModemManager1.Error.Core.Unsupported: Cannot enable unsupported location sources: ‘gps-unmanaged”

    But, if I do this, it starts working right away:

    $ stty raw -F /dev/ttyUSB2; echo \$GPS_START > /dev/ttyUSB2


  14. Ah, wait, you’re probably using a QMI based modem, where we control the GPS location via QMI messages, not through AT+NMEA. In this case, the “unmanaged” location setup isn’t implemented, as it really depends on vendor-specific commands to start/stop GPS, and no one got around to do that yet.

    What device model is this?

  15. It is a Sierra Wireless MC8355 – Gobi 3000(TM) Module.

    Thanks again!

  16. Yeah, so that’s it; we’re likely using the QMI interface to manage it. In order to support “unmanaged GPS” we would need to add that support in the Sierra plugin.

  17. Or; you could try to blacklist completely the TTYs with udev rules; something like this but for your device VID:PID

    $ vim /lib/udev/rules.d/77-mm-MC8355-ignore-TTYs.rules
    ATTRS{idVendor}=="1199", ATTRS{idProduct}=="XXXX", SUBSYSTEM=="tty", ENV{ID_MM_PORT_IGNORE}="1"

    By doing that you should be able to use the AT-capable TTY yourself to start GPS when needed, and read the NMEA traces from the GPS data TTY. ModemManager shouldn’t even probe the TTYs. BUT you’ll need a recent enough ModemManager, latest 1.6.x at least, because 1.4.12 doesn’t support that. Which distribution rolls such an old ModemManager? what a pity. 1.6.x is totally compatible with 1.4.x.

  18. I’m running Linux Mint 18.1, which is brand-new. 😐

    But why does my using the raw tty to send the start command work?

  19. Well then Mint, or whatever other distro they’re based on, are not doing a good job. 1.4.12 isn’t even the latest release in the 1.4.x series…

    The raw command works because you’re forcing the write in the TTY even if MM may have it grabbed. The udev rule just makes it work more reliably.

  20. geronimo928347

    Hello, how to set these changes (–location-enable-gps-raw –location-enable-gps-nmea) permanently?

  21. There’s no standard way to do so. Ideally, applications that want to use the location information would explicitly enable or disable it when required.

  1. Pingback: Links 29/3/2012: Red Hat’s Results, GNOME 3.4 Released | Techrights

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: