QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
GPSProtocolEvent.h
Go to the documentation of this file.
1#pragma once
2
3#include <array>
4#include <cstdint>
5#include <optional>
6#include <variant>
7#include <vector>
8
9#include <QtCore/QByteArray>
10#include <QtCore/QFlags>
11
12#include "GPSReceiverReports.h"
13#include "GPSType.h"
14
17enum class GPSReceiveUpdate : uint8_t
18{
19 Position = 0x1,
20 Satellites = 0x2,
21 Activity = 0x4,
22};
23Q_DECLARE_FLAGS(GPSReceiveUpdates, GPSReceiveUpdate)
24Q_DECLARE_OPERATORS_FOR_FLAGS(GPSReceiveUpdates)
25
26
28{
29 GPSNavigationValues navigation{};
30 bool velocityValid{};
31};
32
34{
35 static constexpr uint16_t SAT_INFO_MAX_SATELLITES = 128;
36 static constexpr uint8_t MAX_CONSTELLATIONS = 8;
37
39 {
41 uint64_t inViewTimestampUs = 0;
42 int inView = 0;
43 uint64_t inUseTimestampUs = 0;
44 std::optional<int> inUse = std::nullopt;
45 };
46
48 {
49 for (uint8_t index = 0; index < count; ++index) {
50 if (constellations[index].constellation == constellation) {
51 return &constellations[index];
52 }
53 }
54 if (count >= constellations.size()) {
55 return nullptr;
56 }
57 auto& report = constellations[count++];
58 report.constellation = constellation;
59 return &report;
60 }
61
64 void addSatellite(GPSConstellation constellation, bool used)
65 {
66 if (auto* system = ensureConstellation(constellation)) {
67 ++system->inView;
68 system->inUse = system->inUse.value_or(0) + (used ? 1 : 0);
69 }
70 }
71
72 // Full snapshots retire omitted constellations; deltas preserve them.
73 bool fullSnapshot = true;
74 uint8_t count = 0;
75 std::array<Constellation, MAX_CONSTELLATIONS> constellations{};
76};
77
79{
80 uint64_t timestampUs = 0;
81 std::optional<int> usedCount = std::nullopt;
82};
83
85[[nodiscard]] inline std::optional<uint8_t> gpsSatellitesUsed(std::optional<unsigned> count)
86{
87 return count && *count < UINT8_MAX ? std::optional<uint8_t>(static_cast<uint8_t>(*count)) : std::nullopt;
88}
89
92{
93 QByteArray bytes{};
94};
95
99{
100 GPSType family = GPSType::passive;
101};
102
105
108{
109 std::vector<GPSProtocolEvent> events{};
110 GPSReceiveUpdates updates{};
111};
std::variant< GPSDecodedPosition, GPSIntegrityReport, GPSDecodedSatellites, GPSDecodedSatelliteUsage, GPSSurveyReport, GPSRTCMFrame, GPSInputProtocol > GPSProtocolEvent
std::optional< uint8_t > gpsSatellitesUsed(std::optional< unsigned > count)
A reported used-satellite count; receivers report UINT8_MAX and above when the count is unknown.
GPSReceiveUpdate
GPSConstellation
Decoded navigation plus whether the producer accepted its velocity solution.
std::optional< int > usedCount
static constexpr uint8_t MAX_CONSTELLATIONS
static constexpr uint16_t SAT_INFO_MAX_SATELLITES
void addSatellite(GPSConstellation constellation, bool used)
std::array< Constellation, MAX_CONSTELLATIONS > constellations
Constellation * ensureConstellation(GPSConstellation constellation)
Events decoded from one span of received bytes, in publication order.
GPSReceiveUpdates updates
One RTCM3 frame the receiver produced, including its header and CRC.
QByteArray bytes