Commit b60d4dae authored by Beat Küng's avatar Beat Küng

AirMapManager: update AirMapFlightManager to latest AirMap API

This includes polling for a flight permission.
The steps are:
- get pilot id (new API requires to provide it, even though it does not
  make much sense)
- create a flight plan
- call the briefing (to check if SITA registration id's are valid)
- call the submit -> returns the actual flight id
- poll on the briefing until the flight gets approved

Since there can only be one flight, on startup, we list the pilot's flights
and end the one that ends in future
parent caca0d0b
This diff is collapsed.
......@@ -255,17 +255,51 @@ signals:
private slots:
void _parseJson(QJsonParseError parseError, QJsonDocument doc);
void _error(QNetworkReply::NetworkError code, const QString& errorString, const QString& serverErrorMessage);
void _sendBriefingRequest();
private:
/**
* upload flight stored in _flight
*/
void _uploadFlight();
/**
* implementation of endFlight()
*/
void _endFlight(const QString& flightID);
enum class State {
Idle,
GetPilotID,
FlightUpload,
FlightBrief,
FlightSubmit,
FlightPolling, // poll & check for approval
FlightEnd,
EndFirstFlight, // get a list of open flights & end the first one (because there can only be 1 active at a time)
};
struct Flight {
QList<QGeoCoordinate> coords;
QGeoCoordinate takeoffCoord;
float maxAltitude = 0;
void reset() {
coords.clear();
maxAltitude = 0;
}
};
Flight _flight; ///< flight pending to be uploaded
State _state = State::Idle;
AirMapNetworking _networking;
QString _currentFlightId; ///< Flight ID, empty if there is none
QString _pendingFlightId; ///< current flight ID, not necessarily accepted yet (once accepted, it's equal to _currentFlightId)
QString _pendingFlightPlan; ///< current flight plan, waiting to be submitted
AirspaceAuthorization::PermitStatus _flightPermitStatus = AirspaceAuthorization::PermitUnknown;
QString _pilotID; ///< Pilot ID in the form "auth0|abc123"
bool _noFlightCreatedYet = true;
QTimer _pollTimer; ///< timer to poll for approval check
};
/// class to send telemetry data to AirMap
......@@ -316,7 +350,7 @@ private:
uint32_t _seqNum = 1;
QUdpSocket* _socket = nullptr;
QHostAddress _udpHost;
static constexpr int _udpPort = 16060;
static constexpr int _udpPort = 32003;
float _lastHdop = 1.f;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment