@@ -466,7 +466,7 @@ void SFE_UBLOX_GPS::processUBX(uint8_t incoming, ubxPacket *incomingUBX)
466466 // If a UBX_NAV_PVT packet comes in asynchronously, we need to fudge the startingSpot
467467 uint16_t startingSpot = incomingUBX->startingSpot ;
468468 if (incomingUBX->cls == UBX_CLASS_NAV && incomingUBX->id == UBX_NAV_PVT)
469- startingSpot = 20 ;
469+ startingSpot = 0 ;
470470 // Begin recording if counter goes past startingSpot
471471 if ((incomingUBX->counter - 4 ) >= startingSpot)
472472 {
@@ -501,7 +501,15 @@ void SFE_UBLOX_GPS::processUBXpacket(ubxPacket *msg)
501501 if (msg->id == UBX_NAV_PVT && msg->len == 92 )
502502 {
503503 // Parse various byte fields into global vars
504- constexpr int startingSpot = 20 ; // fixed value used in processUBX
504+ constexpr int startingSpot = 0 ; // fixed value used in processUBX
505+
506+ gpsYear = extractInt (4 );
507+ gpsMonth = extractByte (6 );
508+ gpsDay = extractByte (7 );
509+ gpsHour = extractByte (8 );
510+ gpsMinute = extractByte (9 );
511+ gpsSecond = extractByte (10 );
512+
505513 fixType = extractByte (20 - startingSpot);
506514 carrierSolution = extractByte (21 - startingSpot) >> 6 ; // Get 6th&7th bits of this byte
507515 SIV = extractByte (23 - startingSpot);
@@ -514,6 +522,13 @@ void SFE_UBLOX_GPS::processUBXpacket(ubxPacket *msg)
514522 pDOP = extractLong (76 - startingSpot);
515523
516524 // Mark all datums as fresh (not read before)
525+ moduleQueried.gpsYear = true ;
526+ moduleQueried.gpsMonth = true ;
527+ moduleQueried.gpsDay = true ;
528+ moduleQueried.gpsHour = true ;
529+ moduleQueried.gpsMinute = true ;
530+ moduleQueried.gpsSecond = true ;
531+
517532 moduleQueried.all = true ;
518533 moduleQueried.longitude = true ;
519534 moduleQueried.latitude = true ;
@@ -1204,6 +1219,60 @@ uint8_t SFE_UBLOX_GPS::extractByte(uint8_t spotToStart)
12041219 return (payloadCfg[spotToStart]);
12051220}
12061221
1222+ // Get the current year
1223+ uint16_t SFE_UBLOX_GPS::getYear (uint16_t maxWait)
1224+ {
1225+ if (moduleQueried.gpsYear == false )
1226+ getPVT ();
1227+ moduleQueried.gpsYear = false ; // Since we are about to give this to user, mark this data as stale
1228+ return (gpsYear);
1229+ }
1230+
1231+ // Get the current month
1232+ uint8_t SFE_UBLOX_GPS::getMonth (uint16_t maxWait)
1233+ {
1234+ if (moduleQueried.gpsMonth == false )
1235+ getPVT ();
1236+ moduleQueried.gpsMonth = false ; // Since we are about to give this to user, mark this data as stale
1237+ return (gpsMonth);
1238+ }
1239+
1240+ // Get the current year
1241+ uint8_t SFE_UBLOX_GPS::getDay (uint16_t maxWait)
1242+ {
1243+ if (moduleQueried.gpsDay == false )
1244+ getPVT ();
1245+ moduleQueried.gpsDay = false ; // Since we are about to give this to user, mark this data as stale
1246+ return (gpsDay);
1247+ }
1248+
1249+ // Get the current year
1250+ uint8_t SFE_UBLOX_GPS::getHour (uint16_t maxWait)
1251+ {
1252+ if (moduleQueried.gpsHour == false )
1253+ getPVT ();
1254+ moduleQueried.gpsHour = false ; // Since we are about to give this to user, mark this data as stale
1255+ return (gpsHour);
1256+ }
1257+
1258+ // Get the current year
1259+ uint8_t SFE_UBLOX_GPS::getMinute (uint16_t maxWait)
1260+ {
1261+ if (moduleQueried.gpsMinute == false )
1262+ getPVT ();
1263+ moduleQueried.gpsMinute = false ; // Since we are about to give this to user, mark this data as stale
1264+ return (gpsMinute);
1265+ }
1266+
1267+ // Get the current year
1268+ uint8_t SFE_UBLOX_GPS::getSecond (uint16_t maxWait)
1269+ {
1270+ if (moduleQueried.gpsSecond == false )
1271+ getPVT ();
1272+ moduleQueried.gpsSecond = false ; // Since we are about to give this to user, mark this data as stale
1273+ return (gpsSecond);
1274+ }
1275+
12071276// Get the latest Position/Velocity/Time solution and fill all global variables
12081277boolean SFE_UBLOX_GPS::getPVT (uint16_t maxWait)
12091278{
0 commit comments