QNmeaSatelliteInfoSource Class | Qt Positioning | Qt 6.11.1
Description: The QNmeaSatelliteInfoSource class provides satellite information using an NMEA data source.

- Qt 6.11
- Qt Positioning
- C++ Classes
- QNmeaSatelliteInfoSource
- Qt 6.11.1 Reference Documentation

# QNmeaSatelliteInfoSource Class

The QNmeaSatelliteInfoSource class provides satellite information using an NMEA data source. More...

Header: | `#include <QNmeaSatelliteInfoSource>`
CMake: | `find_package(Qt6 REQUIRED COMPONENTS Positioning)` `target_link_libraries(mytarget PRIVATE Qt6::Positioning)`
qmake: | `QT += positioning`
Since: | Qt 6.2
Inherits: | QGeoSatelliteInfoSource

- List of all members, including inherited members

## Public Types

enum class | UpdateMode { RealTimeMode, SimulationMode }

## Public Functions

| QNmeaSatelliteInfoSource(QNmeaSatelliteInfoSource::UpdateMode mode, QObject *parent = nullptr)
virtual | ~QNmeaSatelliteInfoSource() override
QIODevice * | device() const
void | setDevice(QIODevice *device)
QNmeaSatelliteInfoSource::UpdateMode | updateMode() const

## Reimplemented Public Functions

virtual QVariant | backendProperty(const QString &name) const override
virtual QGeoSatelliteInfoSource::Error | error() const override
virtual int | minimumUpdateInterval() const override
virtual bool | setBackendProperty(const QString &name, const QVariant &value) override
virtual void | setUpdateInterval(int msec) override

## Public Slots

virtual void | requestUpdate(int msec = 0) override
virtual void | startUpdates() override
virtual void | stopUpdates() override

## Static Public Members

QString | SimulationUpdateInterval

## Protected Types

enum | SatelliteInfoParseStatus { NotParsed, PartiallyParsed, FullyParsed }

## Protected Functions

virtual QNmeaSatelliteInfoSource::SatelliteInfoParseStatus | parseSatelliteInfoFromNmea(const char *data, int size, QList<QGeoSatelliteInfo> &infos, QGeoSatelliteInfo::SatelliteSystem &system)
virtual QGeoSatelliteInfo::SatelliteSystem | parseSatellitesInUseFromNmea(const char *data, int size, QList<int> &pnrsInUse)

## Detailed Description

NMEA is a commonly used protocol for the specification of one's global position at a certain point in time. The QNmeaSatelliteInfoSource class reads NMEA data and uses it to provide information about satellites in view and satellites in use in form of lists of QGeoSatelliteInfo objects.

A QNmeaSatelliteInfoSource instance operates in either RealTimeMode or SimulationMode. These modes allow NMEA data to be read from either a live source of data, or replayed for simulation purposes from previously recorded NMEA data.

The source of NMEA data is set via setDevice().

Use startUpdates() to start receiving regular satellite information updates and stopUpdates() to stop these updates. If you only require updates occasionally, you can call requestUpdate() to request a single update of both satellites in view and satellites in use.

The information about satellites in view is received via the satellitesInViewUpdated() signal.

The information about satellites in use is received via the satellitesInUseUpdated() signal.

## Member Type Documentation

### enum QNmeaSatelliteInfoSource::SatelliteInfoParseStatus

Defines the parse status of satellite information. The satellite information can be split into multiple sentences, and we need to parse all of them.

Constant | Value | Description
--- | --- | ---
`QNmeaSatelliteInfoSource::NotParsed` | `0` | The data does not contain information about satellites.
`QNmeaSatelliteInfoSource::PartiallyParsed` | `1` | A valid satellite information is received and parsed, but it's not complete, so we need to wait for another NMEA sentence.
`QNmeaSatelliteInfoSource::FullyParsed` | `2` | Satellite information was fully collected and parsed.

### enum class QNmeaSatelliteInfoSource::UpdateMode

Defines the available update modes.

Constant | Value | Description
--- | --- | ---
`QNmeaSatelliteInfoSource::UpdateMode::RealTimeMode` | `1` | Satellite information is read and distributed from the data source as it becomes available. Use this mode if you are using a live source of NMEA data (for example a GPS hardware device).
`QNmeaSatelliteInfoSource::UpdateMode::SimulationMode` | `2` | Satellite information is read and distributed from the data source at the given rate. The rate is determined by the SimulationUpdateInterval parameter. Use this mode if the data source contains previously recorded NMEA data and you want to replay the data for simulation purposes.

## Member Function Documentation

### `[explicit]` QNmeaSatelliteInfoSource::QNmeaSatelliteInfoSource(QNmeaSatelliteInfoSource::UpdateMode mode, QObject *parent = nullptr)

Constructs a QNmeaSatelliteInfoSource instance with the given parent and mode.

### `[override virtual noexcept]` QNmeaSatelliteInfoSource::~QNmeaSatelliteInfoSource()

Destroys the satellite information source.

### `[override virtual]` QVariant QNmeaSatelliteInfoSource::backendProperty(const QString &name) const

Reimplements: QGeoSatelliteInfoSource::backendProperty(const QString &name) const.

See also setBackendProperty().

### QIODevice *QNmeaSatelliteInfoSource::device() const

Returns the NMEA data source.

See also setDevice().

### `[override virtual]` QGeoSatelliteInfoSource::Error QNmeaSatelliteInfoSource::error() const

Reimplements: QGeoSatelliteInfoSource::error() const.

### `[override virtual]` int QNmeaSatelliteInfoSource::minimumUpdateInterval() const

Reimplements an access function for property: QGeoSatelliteInfoSource::minimumUpdateInterval.

### `[virtual protected]` QNmeaSatelliteInfoSource::SatelliteInfoParseStatus QNmeaSatelliteInfoSource::parseSatelliteInfoFromNmea(const char *data, int size, QList<QGeoSatelliteInfo> &infos, QGeoSatelliteInfo::SatelliteSystem &system)

Parses an NMEA sentence string to extract the information about satellites in view.

The default implementation will parse standard NMEA $GPGSV sentences. This method should be reimplemented in a subclass whenever the need to deal with non-standard NMEA sentences arises.

The parser reads size bytes from data and uses that information to fill infos list.

Returns SatelliteInfoParseStatus with parse result. Modifies infos list in case PartiallyParsed or FullyParsed is returned. Also sets the system to correct satellite system type. This is required to determine the system type in case there are no satellites in view.

### `[virtual protected]` QGeoSatelliteInfo::SatelliteSystem QNmeaSatelliteInfoSource::parseSatellitesInUseFromNmea(const char *data, int size, QList<int> &pnrsInUse)

Parses an NMEA sentence string to extract the IDs of satelites in use.

The default implementation will parse standard NMEA $GPGSA sentences. This method should be reimplemented in a subclass whenever the need to deal with non-standard NMEA sentences arises.

The parser reads size bytes from data and uses that information to fill pnrsInUse list.

Returns system type if the sentence was successfully parsed, otherwise returns QGeoSatelliteInfo::Undefined and should not modifiy pnrsInUse.

### `[override virtual slot]` void QNmeaSatelliteInfoSource::requestUpdate(int msec = 0)

Reimplements: QGeoSatelliteInfoSource::requestUpdate(int timeout).

### `[override virtual]` bool QNmeaSatelliteInfoSource::setBackendProperty(const QString &name, const QVariant &value)

Reimplements: QGeoSatelliteInfoSource::setBackendProperty(const QString &name, const QVariant &value).

See also backendProperty().

### void QNmeaSatelliteInfoSource::setDevice(QIODevice *device)

Sets the NMEA data source to device. If the device is not open, it will be opened in ReadOnly mode.

The source device can only be set once and must be set before calling startUpdates() or requestUpdate().

Note: The device must emit QIODevice::readyRead() for the source to be notified when data is available for reading. QNmeaSatelliteInfoSource does not assume the ownership of the device, and hence does not deallocate it upon destruction.

See also device().

### `[override virtual]` void QNmeaSatelliteInfoSource::setUpdateInterval(int msec)

Reimplements an access function for property: QGeoSatelliteInfoSource::updateInterval.

### `[override virtual slot]` void QNmeaSatelliteInfoSource::startUpdates()

Reimplements: QGeoSatelliteInfoSource::startUpdates().

### `[override virtual slot]` void QNmeaSatelliteInfoSource::stopUpdates()

Reimplements: QGeoSatelliteInfoSource::stopUpdates().

### QNmeaSatelliteInfoSource::UpdateMode QNmeaSatelliteInfoSource::updateMode() const

Returns the update mode.

## Member Variable Documentation

### QString QNmeaSatelliteInfoSource::SimulationUpdateInterval

This variable holds the backend property name for data read rate in the SimulationMode. The value for this property is the integer number representing the amount of milliseconds between the subsequent reads. Use this parameter in the setBackendProperty() and backendProperty() methods.

Note: This property is different from the interval that can be set via setUpdateInterval(). The value set via setUpdateInterval() denotes an interval for the user notification, while this parameter specifies the internal frequency of reading the data from source file. It means that one can have multiple (or none) reads during the updateInterval() period.