Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/ubx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2301,6 +2301,22 @@ GPSDriverUBX::payloadRxDone()
#endif
}

// Parse lastCorrectionAge from flags3 bits 4..1
{
static constexpr uint16_t correction_age_lut[] = {
0xFFFF, 0, 1, 3, 7, 12, 17, 25, 37, 52, 75, 105, 120
};

uint8_t age_bin = (_buf.payload_rx_nav_pvt.flags3 >> 1) & 0xF;

if (age_bin < sizeof(correction_age_lut) / sizeof(correction_age_lut[0])) {
_gps_position->diff_age = correction_age_lut[age_bin];

} else {
_gps_position->diff_age = 120; // >120s
}
}

_gps_position->timestamp = gps_absolute_time();
_last_timestamp_time = _gps_position->timestamp;

Expand Down Expand Up @@ -2621,8 +2637,20 @@ GPSDriverUBX::payloadRxDone()
UBX_TRACE_RXMSG("Rx MON-RF");

_gps_position->noise_per_ms = _buf.payload_rx_mon_rf.block[0].noisePerMS;
_gps_position->automatic_gain_control = _buf.payload_rx_mon_rf.block[0].agcCnt;
_gps_position->jamming_indicator = _buf.payload_rx_mon_rf.block[0].jamInd;
_gps_position->jamming_state = _buf.payload_rx_mon_rf.block[0].flags;
_gps_position->antenna_status = _buf.payload_rx_mon_rf.block[0].antStatus;
_gps_position->antenna_power = _buf.payload_rx_mon_rf.block[0].antPower;

// Derive ANTENNA system error from antStatus
if (_buf.payload_rx_mon_rf.block[0].antStatus == 3 /* SHORT */
|| _buf.payload_rx_mon_rf.block[0].antStatus == 4 /* OPEN */) {
_gps_position->system_error |= sensor_gps_s::SYSTEM_ERROR_ANTENNA;

} else {
_gps_position->system_error &= ~sensor_gps_s::SYSTEM_ERROR_ANTENNA;
}

ret = 1;
break;
Expand Down
9 changes: 5 additions & 4 deletions src/ubx.h
Original file line number Diff line number Diff line change
Expand Up @@ -533,10 +533,11 @@ typedef struct {
uint32_t sAcc; /**< Speed accuracy estimate [mm/s] */
uint32_t headAcc; /**< Heading accuracy estimate (motion and vehicle) [1e-5 deg] */
uint16_t pDOP; /**< Position DOP [0.01] */
uint16_t reserved2;
uint32_t reserved3;
int32_t headVeh; /**< (ubx8+ only) Heading of vehicle (2-D) [1e-5 deg] */
uint32_t reserved4; /**< (ubx8+ only) */
uint16_t flags3; /**< Additional flags (bit0: invalidLlh, bits4..1: lastCorrectionAge) */
uint32_t reserved0;
int32_t headVeh; /**< (ubx8+ only) Heading of vehicle (2-D), this is only valid when headVehValid is set, otherwise the output is set to the heading of motion */
int16_t magDec; /**< (ubx8+ only) Magnetic declination. Only supported in ADR 4.10 and later.*/
uint16_t magAcc; /**< (ubx8+ only) Magnetic declination accuracy. Only supported in ADR 4.10 and later.*/
} ubx_payload_rx_nav_pvt_t;

/* Rx NAV-TIMEUTC */
Expand Down