7#include <QtCore/QObject>
8#include <QtCore/QPointer>
9#include <QtCore/QString>
10#include <QtCore/QVector>
11#include <QtPositioning/QGeoCoordinate>
12#include <QtQmlIntegration/QtQmlIntegration>
56 QML_UNCREATABLE(
"Provided by the GPS manager")
57 Q_MOC_INCLUDE(
"NTRIPConnectionStats.h")
100 bool enabled =
false;
138 Q_INVOKABLE
void fetchMountpoints(
const QGeoCoordinate& sortCoordinate = QGeoCoordinate());
169 QString securityWarning;
182 bool _dispatch(
Event ev,
const QString& detail = {}, std::chrono::milliseconds retryAfter = {});
186 void _enterState(
ConnectionStatus to,
const QString& detail, std::chrono::milliseconds retryAfter = {});
189 void _onEnterState(
ConnectionStatus to, std::chrono::milliseconds retryAfter);
198 void _stopStreaming();
201 static constexpr int MAX_RECONNECT_ATTEMPTS = 100;
203 void _scheduleReconnect(std::chrono::milliseconds retryAfter = {});
205 void _cancelReconnect();
207 bool _shouldWaitForNetwork()
const;
208 bool _casterIsLoopback()
const;
209 void _waitForNetwork();
211 bool _reconnectExhausted()
const {
return _reconnectBackoff.
attempts() >= MAX_RECONNECT_ATTEMPTS; }
213 void _onTransportConnected();
215 void _onCertificatePinned(
const QString& pin);
216 void _setPinnedCertificate(
const QString& pin);
219 void _applyConfiguration();
221 bool _isEnabled()
const {
return _configuration.
enabled; }
230 QString _statusMessage;
234 QPointer<NTRIPTransport> _transport;
236 std::unique_ptr<GPSCorrectionSourceHandle> _correctionSource;
238 const QPointer<GPSCorrectionManager> _correctionManager;
239 const QPointer<QGCNetworkAvailabilityMonitor> _networkMonitor;
242 Configuration _configuration;
243 Configuration _running;
247 static constexpr std::chrono::milliseconds SETTINGS_DEBOUNCE{250};
248 ExponentialBackoff _reconnectBackoff{std::chrono::seconds(1), 2, std::chrono::seconds(30),
250 QString _lastFailureDetail;
251 bool _waitingForNetwork =
false;
252 bool _initialized =
false;
253 bool _shutdown =
false;
Retry delays that start at an initial value and grow by a factor per attempt, up to a cap.
constexpr int attempts() const
Attempts counted since construction or the last reset().
A begun correction source and the stream it delivers; destroying it ends the source.
std::function< std::optional< GPSObservation >()> PositionProvider
QString currentSource() const
std::function< NTRIPTransport *(const Configuration &configuration, QObject *parent)> TransportFactory
Creates the transport of one connection attempt, parented to parent; null opens an NTRIPHttpTransport...
void statusMessageChanged()
void setConfiguration(const Configuration &configuration)
ConnectionStatus connectionStatus() const
void certificatePinChanged(const QString &pin)
The trusted self-signed caster certificate changed, or was forgotten (empty); the settings should sto...
ConnectionStatus
Public connection status. Numeric values are stable — QML binds against them.
QString securityWarning() const
Set while a connected stream sends its credentials without TLS.
NTRIPSourceTableController * sourceTableController()
void setGgaPositionProvider(NTRIPGgaReporter::PositionSource source, NTRIPGgaReporter::PositionProvider provider)
void init()
Applies the configuration; call once the position providers are installed.
void enableRequested()
Retrying after an error turns the saved connection on.
QString connectionStatusText() const
Q_INVOKABLE void retryNTRIP()
Retry a user-visible error, preserving the enabled setting for subsequent automatic retries.
void securityWarningChanged()
QString statusMessage() const
@ StartRequested
Settings enable went true, or the user retried an error.
@ ReconnectGaveUp
The reconnect attempt ceiling was reached.
@ HotReconfigure
Transport-affecting setting changed while connected; reconnect in place.
@ TransportFatalError
NTRIPTransport emitted a non-retryable error.
@ ConfigInvalid
Connection configuration failed validation.
@ TransportError
NTRIPTransport emitted a retryable error.
@ TransportConnected
NTRIPTransport emitted connected().
@ StopRequested
Settings enable went false, or the manager shut down.
@ ReconnectDue
The reconnect delay elapsed or the network returned.
QString ggaSource() const
void shutdown()
Permanently retire this manager, including deferred settings work.
void connectionStatusChanged()
Q_INVOKABLE void fetchMountpoints(const QGeoCoordinate &sortCoordinate=QGeoCoordinate())
NTRIPConnectionStats * connectionStats()
void setTransportFactory(TransportFactory factory)
An empty factory restores NTRIPHttpTransport for every attempt.
const Configuration & configuration() const
friend class NTRIPManagerTest
Short connection state for compact views.
static constexpr std::chrono::milliseconds MAX_RETRY_AFTER
Longest caster Retry-After hint that may delay a reconnect.
Services an NTRIPManager uses, which must outlive it.
QGCNetworkAvailabilityMonitor * network
Reconnects wait for a network while it reports none.
GPSCorrectionManager * corrections
Receives the stream as the NTRIP correction source.
The NTRIP settings as values; the application's settings binding supplies them.
NTRIPRTCMFilterConfig filter
NTRIPGgaReporter::Configuration gga
NTRIPConnectionConfig connection
bool operator==(const Configuration &) const =default
The RTCM message filter as the settings store it: comma-separated message IDs, empty for every messag...
bool operator==(const NTRIPRTCMFilterConfig &) const =default
QVector< int > messageIds() const
The positive message IDs of the whitelist; entries that are not one are skipped.