AirMapTelemetry.h 1.64 KB
Newer Older
1 2
/****************************************************************************
 *
3
 * (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
4 5 6 7 8 9 10 11
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/

#pragma once

Gus Grubba's avatar
Gus Grubba committed
12
#include "LifetimeChecker.h"
Gus Grubba's avatar
Gus Grubba committed
13
#include "AirMapSharedState.h"
Gus Grubba's avatar
Gus Grubba committed
14

Gus Grubba's avatar
Gus Grubba committed
15
#include <QGCMAVLink.h>
Gus Grubba's avatar
Gus Grubba committed
16

Gus Grubba's avatar
Gus Grubba committed
17
#include <QObject>
18
#include <QElapsedTimer>
19

20
/// Class to send telemetry data to AirMap
21 22 23 24
class AirMapTelemetry : public QObject, public LifetimeChecker
{
    Q_OBJECT
public:
25 26
    AirMapTelemetry                 (AirMapSharedState& shared);
    virtual ~AirMapTelemetry        () = default;
27

28 29 30
    void startTelemetryStream       (const QString& flightID);
    void stopTelemetryStream        ();
    bool isTelemetryStreaming       ();
31 32

signals:
33
    void error                      (const QString& what, const QString& airmapdMessage, const QString& airmapdDetails);
34 35

public slots:
36
    void vehicleMessageReceived     (const mavlink_message_t& message);
37 38 39

private:

40 41
    void _handleGlobalPositionInt   (const mavlink_message_t& message);
    void _handleGPSRawInt           (const mavlink_message_t& message);
42 43 44 45 46 47 48 49 50 51

    enum class State {
        Idle,
        StartCommunication,
        EndCommunication,
        Streaming,
    };

    State                   _state = State::Idle;
    AirMapSharedState&      _shared;
52
    std::string             _key; ///< key for AES encryption (16 bytes)
53 54
    QString                 _flightID;
    float                   _lastHdop = 1.f;
55
    QElapsedTimer           _timerLastSent;
56 57
};