18 switch ((keyId >> 28) & 0x7) {
37 static_assert(std::is_arithmetic_v<T>);
43template <
typename T, u
int32_t Id>
46 static_assert(
cfgKeyValueBytes(Id) ==
sizeof(T),
"the value type size must match the key id size bits");
64 return {
i2c.
id +
static_cast<uint32_t
>(
port)};
72inline constexpr auto ITFM_ENABLE = cfgKey<uint8_t, 0x1041000d>();
79inline constexpr auto ODO_USE_COG = cfgKey<uint8_t, 0x10220002>();
80inline constexpr auto ODO_USE_ODO = cfgKey<uint8_t, 0x10220001>();
81inline constexpr auto RATE_MEAS = cfgKey<uint16_t, 0x30210001>();
82inline constexpr auto RATE_NAV = cfgKey<uint16_t, 0x30210002>();
89inline constexpr auto TMODE_LAT = cfgKey<int32_t, 0x40030009>();
91inline constexpr auto TMODE_LON = cfgKey<int32_t, 0x4003000a>();
93inline constexpr auto TMODE_MODE = cfgKey<uint8_t, 0x20030001>();
194 return width <= sizeof(uint32_t) ? static_cast<unsigned>(width) : 0;
210 : _remaining(entries)
213 bool empty()
const {
return _remaining.empty(); }
215 std::optional<ConfigurationValue>
next()
217 if (!_valid ||
empty()) {
220 const auto key = LittleEndian::read<uint32_t>(_remaining, 0);
222 if (!width || _remaining.size() <
sizeof(uint32_t) + width) {
227 for (
unsigned byte = 0;
byte < width; ++byte) {
228 value |= uint32_t(_remaining[
sizeof(uint32_t) +
byte]) << (8 * byte);
230 if ((*key >> 28) == 1 && value > 1) {
234 _remaining = _remaining.subspan(
sizeof(uint32_t) + width);
239 std::span<const uint8_t> _remaining;
249 std::array<ConfigurationValue, MAX_KEYS>
values{};
256 if (payload.size() < 4 || payload[0] != 1 || payload[1] || payload[2] || payload[3]) {
261 while (!cursor.
empty()) {
262 const auto entry = cursor.
next();
263 if (!entry || result.
count == result.
values.size()) {
273template <
size_t Capacity>
276 static_assert(Capacity >= 4);
277 std::array<uint8_t, Capacity>
bytes{0, 1};
283 return valid &&
size > 4 ? std::span<const uint8_t>(
bytes).first(
size) : std::span<const uint8_t>{};
287 std::span<const uint8_t>
entries()
const {
return std::span<const uint8_t>(
bytes).subspan(4,
size - 4); }
289 bool append(uint32_t key, uint32_t value)
292 if (!
valid || !width || (width < 4 && value >= (1u << (width * 8))) || ((key >> 28) == 1 && value > 1) ||
293 sizeof(key) + width >
bytes.size() -
size) {
298 for (
unsigned byte = 0;
byte < width; ++byte) {
299 bytes[
size +
sizeof(key) +
byte] =
static_cast<uint8_t
>(value >> (8 *
byte));
301 size +=
sizeof(key) + width;
Reads only key/value entries; VALSET and VALGET validate their different headers separately.
ConfigurationValueCursor(std::span< const uint8_t > entries)
std::optional< ConfigurationValue > next()
constexpr bool write(std::span< uint8_t > bytes, std::size_t offset, T value)
Encode an unaligned little-endian scalar. Insufficient space leaves the destination unchanged.
constexpr MsgOutKey MSGOUT_UBX_NAV_PVT
constexpr auto TMODE_LON_HP
constexpr MsgOutKey MSGOUT_RTCM_3X_TYPE1005
constexpr auto USBINPROT_SPARTN
constexpr auto USBOUTPROT_UBX
constexpr auto TMODE_SVIN_MIN_DUR
constexpr auto TMODE_FIXED_POS_ACC
constexpr MsgOutKey MSGOUT_UBX_RXM_SFRBX
constexpr auto ITFM_ENABLE
constexpr auto USBINPROT_NMEA
constexpr MsgOutKey MSGOUT_UBX_NAV_SVIN
constexpr auto ODO_OUTLPCOG
constexpr MsgOutKey MSGOUT_RTCM_3X_TYPE1097
constexpr auto TMODE_HEIGHT
constexpr auto UART1OUTPROT_NMEA
constexpr MsgOutKey MSGOUT_RTCM_3X_TYPE1094
constexpr auto USBINPROT_UBX
constexpr auto UART1_BAUDRATE
constexpr auto NAVSPG_UTCSTANDARD
constexpr auto TMODE_HEIGHT_HP
constexpr auto SEC_JAMDET_SENSITIVITY_HI
constexpr MsgOutKey MSGOUT_UBX_NAV_RELPOSNED
constexpr MsgOutKey MSGOUT_RTCM_3X_TYPE1087
constexpr MsgOutKey MSGOUT_UBX_RXM_RAWX
constexpr auto UART1_PARITY
constexpr auto TMODE_POS_TYPE
constexpr auto UART1_STOPBITS
constexpr auto TMODE_MODE
constexpr auto TMODE_SVIN_ACC_LIMIT
constexpr auto UART1INPROT_SPARTN
constexpr MsgOutKey MSGOUT_RTCM_3X_TYPE1084
constexpr MsgOutKey MSGOUT_RTCM_3X_TYPE1077
constexpr auto USBINPROT_RTCM3X
constexpr auto SIGNAL_HEALTH_L5
constexpr auto UART1OUTPROT_RTCM3X
constexpr MsgOutKey MSGOUT_RTCM_3X_TYPE1124
constexpr MsgOutKey MSGOUT_UBX_NAV_STATUS
constexpr MsgOutKey MSGOUT_RTCM_3X_TYPE1230
constexpr MsgOutKey MSGOUT_UBX_NAV_DOP
constexpr auto UART1INPROT_RTCM3X
constexpr auto NAVHPG_DGNSSMODE
constexpr auto USBOUTPROT_NMEA
constexpr MsgOutKey MSGOUT_RTCM_3X_TYPE1127
constexpr MsgOutKey MSGOUT_UBX_NAV_EOE
constexpr MsgOutKey MSGOUT_RTCM_3X_TYPE1074
constexpr auto NAVSPG_FIXMODE
constexpr auto UART1OUTPROT_UBX
constexpr MsgOutKey MSGOUT_UBX_MON_RF
constexpr auto ODO_USE_COG
constexpr auto NAVSPG_DYNMODEL
constexpr auto UART1INPROT_UBX
constexpr auto UART1_DATABITS
constexpr auto UART1INPROT_NMEA
constexpr auto ODO_USE_ODO
constexpr auto TMODE_LAT_HP
constexpr MsgOutKey MSGOUT_UBX_NAV_TIMEGPS
constexpr auto USBOUTPROT_RTCM3X
constexpr MsgOutKey MSGOUT_UBX_NAV_SAT
constexpr auto RATE_TIMEREF
constexpr MsgOutKey MSGOUT_UBX_SEC_SIG
constexpr MsgOutKey MSGOUT_UBX_NAV_HPPOSLLH
constexpr auto ODO_OUTLPVEL
u-blox receivers over UBX: CFG-VALSET configuration from protocol 27, CFG-MSG and CFG-TMODE3 before i...
std::optional< ConfigurationValues > decodeConfigurationValues(std::span< const uint8_t > payload)
Decodes a CFG-VALGET response (version 1, RAM layer) of at most ConfigurationValues::MAX_KEYS values.
consteval CfgKey< T > cfgKey()
Builds every key below, so each one checks its value type against the size bits of its id.
constexpr size_t cfgKeyValueBytes(uint32_t keyId)
Value size in bytes from bits 28-30 of a configuration key id, or 0 for a reserved size.
constexpr unsigned configurationValueBytes(uint32_t key)
Value width in bytes of key; 0 for reserved sizes and for 8-byte values, which QGC never reads or wri...
MsgOutPort
A port's CFG-MSGOUT key is the family's I2C key id plus the port's offset.
A configuration key whose value is written and read as T.
std::span< const uint8_t > entries() const
The appended key/value entries, without the header.
bool append(uint32_t key, uint32_t value)
std::array< uint8_t, Capacity > bytes
std::span< const uint8_t > payload() const
bool operator==(const ConfigurationValue &) const =default
The values of one CFG-VALGET poll or response.
std::array< ConfigurationValue, MAX_KEYS > values
static constexpr size_t MAX_KEYS
One poll reads at most this many keys.
A CFG-MSGOUT output rate key family, named by its I2C key.
constexpr CfgKey< uint8_t > port(MsgOutPort port) const