41 _lateRejection =
false;
42 _awaitingMessage = message;
48 _lastMessage = _awaitingMessage;
49 _awaitingMessage.reset();
61 (_lastMessage == response.
message || _unacknowledgedConfiguration == response.
message)) {
62 _lateRejection =
true;
69 if (_takeReadbackReply()) {
70 _readbackRejected =
true;
74 if (_ratePoll->rates) {
75 _ratePoll->acknowledged =
true;
77 ++_ratePoll->repliesBeforeRates;
78 _ratePoll->rejected = _ratePoll->rejected || !response.
accepted;
86 _readbackPending = !
keys.empty() &&
keys.size() <= _readback.
values.size();
87 _readbackReady =
false;
88 _readbackRejected =
false;
89 _readbackReplied =
false;
90 if (_readbackPending) {
92 for (
size_t index = 0; index <
keys.size(); ++index) {
101 if (_readbackPending && !_readbackReplied) {
102 _readbackReplyOutstanding =
true;
104 _readbackPending =
false;
120 void accept(
const std::optional<ConfigurationValues>& response)
123 _takeReadbackReply();
124 if (!_readbackPending || !response || response->count != _readback.
count) {
127 std::array<ConfigurationValue, ConfigurationValues::MAX_KEYS> values{};
129 for (
size_t entry = 0; entry < response->count; ++entry) {
131 while (index < _readback.
count && _readback.
values[index].key != response->values[entry].key) {
134 if (index == _readback.
count || (seen & (1u << index))) {
137 values[index] = response->values[entry];
140 _readback.
values = values;
141 _readbackReady =
true;
142 _readbackReplied =
true;
148 void beginRatePoll(uint16_t message) { _ratePoll = RatePoll{.message = message}; }
155 std::optional<std::array<uint8_t, 6>>
polledRates()
const {
return _ratePoll ? _ratePoll->rates : std::nullopt; }
164 return _ratePoll && ((_ratePoll->rates && _ratePoll->acknowledged) || _ratePoll->repliesBeforeRates >= 2);
169 if (_ratePoll && response.
message == _ratePoll->message && !_ratePoll->rates) {
170 _ratePoll->rates = response.
rates;
177 uint16_t message = 0;
178 std::optional<std::array<uint8_t, 6>> rates{};
179 unsigned repliesBeforeRates = 0;
180 bool rejected =
false;
181 bool acknowledged =
false;
186 bool _takeReadbackReply()
188 if (std::exchange(_readbackReplyOutstanding,
false) || !_readbackPending) {
191 _readbackReplied =
true;
195 std::optional<uint16_t> _unacknowledgedConfiguration;
196 std::optional<uint16_t> _awaitingMessage;
197 std::optional<uint16_t> _lastMessage;
198 bool _lateRejection =
false;
200 ConfigurationValues _readback;
201 bool _readbackPending =
false;
202 bool _readbackReady =
false;
203 bool _readbackRejected =
false;
204 bool _readbackReplied =
false;
205 bool _readbackReplyOutstanding =
false;
206 std::optional<RatePoll> _ratePoll;
std::array< MsgOutKey, 4 > keys
Owns control-response correlation: decoding reports replies through accept(); only configuration open...
bool readbackRejected() const
The receiver rejected the pending readback: at least one of its keys is unknown.
void beginAcknowledgement(uint16_t message)
bool configurationReadbackRequired() const
bool readbackReplyOutstanding() const
A reply to a readback settled without it can still arrive.
std::optional< std::array< uint8_t, 6 > > polledRates() const
The polled rates, once they arrived.
void accept(const std::optional< ConfigurationValues > &response)
A CFG-VALGET response; nullopt when it is malformed.
bool ratePollRejected() const
A NAK came before the polled rates: the receiver rejected the rate or the poll.
bool lateRejection() const
bool readbackReady() const
void accept(Acknowledgement response)
GPSCommandOutcome acknowledgement() const
void beginReadback(std::span< const uint32_t > keys)
void finishAcknowledgement()
void requireConfigurationReadback(uint16_t message)
A baud change can lose its ACK on UART; subsequent VALSETs must prove their values by readback.
bool ratePollSettled() const
void accept(const MessageRates &response)
bool readbackPending() const
bool awaitingAcknowledgement() const
bool ratePollPending() const
void beginRatePoll(uint16_t message)
const ConfigurationValues & readback() const
constexpr MessageId CFG_VALGET
constexpr MessageId CFG_MSG
u-blox receivers over UBX: CFG-VALSET configuration from protocol 27, CFG-MSG and CFG-TMODE3 before i...
The values of one CFG-VALGET poll or response.
std::array< ConfigurationValue, MAX_KEYS > values
constexpr uint16_t value() const
The CFG-MSG output rates of one message on each I/O port, as a poll returns them.
std::array< uint8_t, 6 > rates