Get NMEA sentences from the GNSS sub-system
Device
Only available on imps with cellular modems
Name | Type | Description |
---|---|---|
infoCallback | Function |
The information delivery callback
|
sentenceType | String |
The format for returned sentences
|
Nothing
This method retrieves NMEA sentence data from the GNSS sub-system, which must be enabled before this call can be made. Additionally, the GNSS sub-system must have been configured to output NMEA sentences — see gnss-session.configure(). This is the default but if you have changed the value of the NMEA setting key nmeasrc to 0, you must set it to 1 before calling gnss-session.readnmea().
Note It is also possible to disable sentence output by passing the value of 0 for any of the following NMEA settings:
In this case, it is still possible to retrieve NMEA sentence data, but you will only receive the most recently acquired data and then only if sentences have been acquired in this session.
The value passed into the optional parameter sentenceType is a string which specifies the format of the sentences to be returned. The possible values are:
GGA
RMC
GSV
GSA
VTG
GNS
For more information on the meaning of these values, please see NMEA Revealed: Standard Sentences.
The data is returned in a table which is passed to the supplied infoCallback function. The table contains at least two keys: status and nmea. The value of status will be zero if no error occurred, or an error code (see gnss-session for details).
The value of the key nmea will be an array containing the strings returned by the modem.
The following code retrieves sentences of the GSV type — they describe the sky positions of GNSS satellites the modem can see. Each sentence has the following field structure:
$<TID>GSV,<F1>,<F2>,<F3>,<F4>,<F5>,<F6>,<F7>,...*<CS>
The fields are:
<TID>
— Talker ID: the source of the information, eg. GP
for GPS.<CS>
— checksum.The code uses an existing gnss-session object, gnssSession. See gnss-session.enable() for example code showing session object instantiation.