16#include <QtCore/QByteArray>
17#include <QtCore/QByteArrayView>
50 uint64_t startedAtUs = 0;
51 int acceptedBytes = 0;
86 return !_accepted.empty() && _accepted.size() <= _window.size() && _rejected.size() <= _window.size();
89 void append(std::span<const uint8_t> bytes)
94 for (
const uint8_t
byte : bytes) {
95 if (_size == _window.size()) {
96 std::move(_window.begin() + 1, _window.end(), _window.begin());
99 _window[_size++] =
static_cast<char>(byte);
100 const std::string_view received(_window.data(), _size);
101 if (!_rejected.empty() && received.ends_with(_rejected)) {
112 std::string_view _accepted;
113 std::string_view _rejected;
114 std::array<char, 256> _window{};
135 std::variant<GPSTextMatcher, RawReply>
reply{};
142 std::optional<size_t> failedStep = std::nullopt;
143 QByteArray failedLabel{};
147 [[nodiscard]]
bool succeeded()
const {
return !failedStep.has_value(); }
163 QByteArray wire, std::chrono::milliseconds timeout,
164 std::variant<GPSTextMatcher, GPSCommandSequence::RawReply> reply,
GPSCommandOptions options = {})
168 .required = options.required};
169 return {.step = std::move(step), .wire = std::move(wire), .reply = std::move(reply)};
std::function< GPSCommandOutcome(const GPSFrame &frame)> GPSFrameMatcher
Resolves the outstanding command from each dispatched frame, after the family decoded it; Pending kee...
std::function< GPSCommandOutcome()> GPSReplyPoll
Polled after each decoded chunk, for replies a family tracks in its own decoder state; Pending keeps ...
GPSProtocolError
Sticky failure of the current receiver session; I/O and control stop until the next configure().
@ InvalidArgument
The driver requested an invalid write, or received before configuring.
@ Protocol
The receiver violated or rejected the control protocol.
@ Cancelled
A stop was requested; not a receiver or link fault.
@ ConsentRequired
Configuration needs a persistent receiver change the caller did not allow.
@ Transport
The link could not read, write, or change its baud rate.
GPSCommandSequence::Command gpsCommand(QByteArray wire, std::chrono::milliseconds timeout, std::variant< GPSTextMatcher, GPSCommandSequence::RawReply > reply, GPSCommandOptions options={})
std::function< GPSCommandOutcome(std::string_view reply)> GPSTextMatcher
Resolves the outstanding command from one text reply a decoder offers; Pending keeps waiting.
Bounded raw-byte matching for receivers whose replies need not be complete ASCII lines.
void append(std::span< const uint8_t > bytes)
GPSRawAckMatcher(QByteArrayView accepted, QByteArrayView rejected)
GPSCommandOutcome outcome() const
QByteArray label
Names the command in evidence instead of its wire text, such as when the text carries base coordinate...
GPSConfigurationStep step
Evidence label and per-attempt timeout. A required command that fails ends the sequence.
std::variant< GPSTextMatcher, RawReply > reply
Matched in the raw received bytes, for replies that need not be complete frames (see GPSRawAckMatcher...
std::vector< Command > steps
Evidence from one configuration command, not a claim of physical receiver operation.
std::chrono::milliseconds timeout