QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
GPSNMEAFamilyProtocol.h
Go to the documentation of this file.
1#pragma once
2
3#include <chrono>
4#include <string_view>
5
6#include "GPSCommandChannel.h"
7#include "GPSFamilyProtocol.h"
8#include "GPSNMEAStream.h"
9
14{
15public:
16 GPSReceiveUpdates onFrame(const GPSFrame& frame, GPSDecodeContext& context) final
17 {
18 return _nmea.onFrame(frame, context,
19 [this, &context](std::string_view line) { return _decodeLine(line, context); });
20 }
21
23 void flush(GPSDecodeContext& context) final
24 {
25 _expire(context);
26 _nmea.flush(context);
27 }
28
29 bool receiverReady() const final { return _ready; }
30
32 GPSReceiveUpdates receive(GPSCommandChannel& channel, std::chrono::milliseconds timeout) final
33 {
34 const GPSReceiveUpdates updates = _nmea.receive(channel, timeout);
35 if (channel.failed()) {
36 (void) channel.flush();
37 }
38 return updates;
39 }
40
41protected:
43 static constexpr std::chrono::seconds STATUS_MAX_AGE{5};
45 static constexpr std::chrono::milliseconds STATUS_POLL{1000};
46
52
54 virtual GPSReceiveUpdates _decodeLine(std::string_view line, GPSDecodeContext& context) = 0;
55
57 virtual void _expire(GPSDecodeContext& context) { Q_UNUSED(context) }
58
61 bool _ready = false;
62};
GPSReceiveUpdates receive(GPSCommandChannel &channel, std::chrono::milliseconds timeout) final
After a failure, flushes at once so the expiry it causes is published with it.
virtual GPSReceiveUpdates _decodeLine(std::string_view line, GPSDecodeContext &context)=0
Decodes one line after standard NMEA did.
static constexpr std::chrono::seconds STATUS_MAX_AGE
How long a periodic receiver report, such as base status or time metadata, stays current.
virtual void _expire(GPSDecodeContext &context)
Drops state that is stale or that a recorded failure invalidated; runs before each decode.
bool _ready
Whether the receiver runs as the latest configure() set it up.
static constexpr std::chrono::milliseconds STATUS_POLL
The longest read of a family that expires its status, so expiry runs on a silent link too.
GPSReceiveUpdates onFrame(const GPSFrame &frame, GPSDecodeContext &context) final
void flush(GPSDecodeContext &context) final
Expires the family's stale state, then flushes the NMEA stream.
bool receiverReady() const final
GPSNMEAFamilyProtocol(GPSNMEAStream::Navigation navigation=GPSNMEAStream::Navigation::StandardNMEA)
GPSReceiveUpdates receive(GPSCommandChannel &channel, std::chrono::milliseconds timeout) const
void flush(GPSDecodeContext &context)
Expires untimed metadata and publishes satellite epochs that became due.
GPSReceiveUpdates onFrame(const GPSFrame &frame, GPSDecodeContext &context, Vendor &&vendor)
Navigation
Who turns sentences into positions: this stream from standard NMEA, or the family's own sentences.
void setRTCMEnabled(bool enabled)