6#include <QtCore/QCoreApplication>
7#include <QtCore/QString>
11#ifndef QGC_NO_SERIAL_LINK
66 bool reconnecting()
const {
return _keepConnected && !_receiver.hasReceiver(); }
79 bool _hasSavedReceiver()
const;
80 bool _discoveryEnabled()
const;
81 bool _connectConfigured(
bool allowPersistentChanges);
84 void _scheduleRetry();
85 void _cancelRetries();
86 bool _serialDeviceAvailable(
const QString& device)
const;
87 QString _serialDeviceLabel(
const QString& device)
const;
88 void _updateDiscovery();
89#ifndef QGC_NO_SERIAL_LINK
92 void _connectDiscovered(
const QString& device);
95 GPSReceiverConnector& _receiver;
96 const GPSReceiverConfiguration& _configuration;
97 RuntimeScheduler*
const _scheduler;
98 Owner _owner = Owner::None;
100 bool _startPending =
true;
102 bool _keepConnected =
false;
104 bool _paused =
false;
105 bool _waitingForPort =
false;
107#ifndef QGC_NO_SERIAL_LINK
108 SerialPortSettleTracker _waitingPorts;
110 std::optional<quint64> _retryDeadlineUs;
111 ExponentialBackoff _retryBackoff{std::chrono::seconds(1), 2, std::chrono::seconds(30)};
GPSReceiverSessionOutcome
What the policy does after a receiver session ends; the receiver words the message for it.
@ Unplugged
A discovered receiver was unplugged; discovery connects it again when it returns.
@ None
Nothing reconnects; the receiver's own message for the error applies.
@ AutoRetrying
A discovered receiver failed or was lost; discovery retries it.
@ WaitingForPort
The saved receiver was unplugged; it reconnects when its port returns.
@ Retrying
The saved receiver's connection was lost; a retry is scheduled.
friend class GPSReceiverConnectionPolicyTest
void disconnectConfigured()
Disconnects at the user's request and pauses automatic connection.
bool reconnecting() const
The saved receiver is being connected automatically and is not connected yet.
GPSReceiverConnectionPolicy(GPSReceiverConnector &receiver, const GPSReceiverConfiguration &configuration, RuntimeScheduler *scheduler)
GPSReceiverSessionOutcome sessionEnded(bool portRemoved)
void reset()
Forgets connection ownership and pending retries, before another connection replaces it.
void update()
Periodic tick: due automatic connections and USB discovery.
void configurationChanged(const GPSReceiverConfiguration &previous)
The receiver's configuration changed from previous.
bool connectConfigured(bool allowPersistentChanges)
Connects the saved receiver at the user's request and resumes automatic connection.
The receiver configuration the application's settings binding supplies as values.