@@ -466,7 +466,7 @@ void SFE_UBLOX_GPS::processUBX(uint8_t incoming, ubxPacket *incomingUBX)
466
466
// If a UBX_NAV_PVT packet comes in asynchronously, we need to fudge the startingSpot
467
467
uint16_t startingSpot = incomingUBX->startingSpot ;
468
468
if (incomingUBX->cls == UBX_CLASS_NAV && incomingUBX->id == UBX_NAV_PVT)
469
- startingSpot = 20 ;
469
+ startingSpot = 0 ;
470
470
// Begin recording if counter goes past startingSpot
471
471
if ((incomingUBX->counter - 4 ) >= startingSpot)
472
472
{
@@ -501,7 +501,15 @@ void SFE_UBLOX_GPS::processUBXpacket(ubxPacket *msg)
501
501
if (msg->id == UBX_NAV_PVT && msg->len == 92 )
502
502
{
503
503
// 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
+
505
513
fixType = extractByte (20 - startingSpot);
506
514
carrierSolution = extractByte (21 - startingSpot) >> 6 ; // Get 6th&7th bits of this byte
507
515
SIV = extractByte (23 - startingSpot);
@@ -514,6 +522,13 @@ void SFE_UBLOX_GPS::processUBXpacket(ubxPacket *msg)
514
522
pDOP = extractLong (76 - startingSpot);
515
523
516
524
// 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
+
517
532
moduleQueried.all = true ;
518
533
moduleQueried.longitude = true ;
519
534
moduleQueried.latitude = true ;
@@ -1204,6 +1219,60 @@ uint8_t SFE_UBLOX_GPS::extractByte(uint8_t spotToStart)
1204
1219
return (payloadCfg[spotToStart]);
1205
1220
}
1206
1221
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
+
1207
1276
// Get the latest Position/Velocity/Time solution and fill all global variables
1208
1277
boolean SFE_UBLOX_GPS::getPVT (uint16_t maxWait)
1209
1278
{
0 commit comments