@@ -85,6 +85,12 @@ void SFE_UBLOX_GNSS::end(void)
85
85
delete[] currentGeofenceParams;
86
86
currentGeofenceParams = NULL; // Redundant?
87
87
}
88
+
89
+ if (packetUBXNAVTIMELS != NULL)
90
+ {
91
+ delete[] packetUBXNAVTIMELS;
92
+ packetUBXNAVTIMELS = NULL; // Redundant?
93
+ }
88
94
89
95
if (packetUBXNAVPOSECEF != NULL)
90
96
{
@@ -792,6 +798,9 @@ boolean SFE_UBLOX_GNSS::checkAutomatic(uint8_t Class, uint8_t ID)
792
798
case UBX_NAV_CLOCK:
793
799
if (packetUBXNAVCLOCK != NULL) result = true;
794
800
break;
801
+ case UBX_NAV_TIMELS:
802
+ if (packetUBXNAVTIMELS != NULL) result = true;
803
+ break;
795
804
case UBX_NAV_SVIN:
796
805
if (packetUBXNAVSVIN != NULL) result = true;
797
806
break;
@@ -919,6 +928,9 @@ uint16_t SFE_UBLOX_GNSS::getMaxPayloadSize(uint8_t Class, uint8_t ID)
919
928
case UBX_NAV_CLOCK:
920
929
maxSize = UBX_NAV_CLOCK_LEN;
921
930
break;
931
+ case UBX_NAV_TIMELS:
932
+ maxSize = UBX_NAV_TIMELS_LEN;
933
+ break;
922
934
case UBX_NAV_SVIN:
923
935
maxSize = UBX_NAV_SVIN_LEN;
924
936
break;
@@ -2060,6 +2072,26 @@ void SFE_UBLOX_GNSS::processUBXpacket(ubxPacket *msg)
2060
2072
}
2061
2073
}
2062
2074
}
2075
+ else if (msg->id == UBX_NAV_TIMELS && msg->len == UBX_NAV_TIMELS_LEN)
2076
+ {
2077
+ //Parse various byte fields into storage - but only if we have memory allocated for it
2078
+ if (packetUBXNAVTIMELS != NULL)
2079
+ {
2080
+ packetUBXNAVTIMELS->data.iTOW = extractLong(msg, 0);
2081
+ packetUBXNAVTIMELS->data.version = extractByte(msg, 4);
2082
+ packetUBXNAVTIMELS->data.srcOfCurrLs = extractByte(msg, 8);
2083
+ packetUBXNAVTIMELS->data.currLs = extractSignedChar(msg, 9);
2084
+ packetUBXNAVTIMELS->data.srcOfLsChange = extractByte(msg, 10);
2085
+ packetUBXNAVTIMELS->data.lsChange = extractSignedChar(msg, 11);
2086
+ packetUBXNAVTIMELS->data.timeToLsEvent = extractSignedLong(msg, 12);
2087
+ packetUBXNAVTIMELS->data.dateOfLsGpsWn = extractInt(msg, 16);
2088
+ packetUBXNAVTIMELS->data.dateOfLsGpsDn = extractInt(msg, 18);
2089
+ packetUBXNAVTIMELS->data.valid.all = extractSignedChar(msg, 23);
2090
+
2091
+ //Mark all datums as fresh (not read before)
2092
+ packetUBXNAVTIMELS->moduleQueried.moduleQueried.all = 0xFFFFFFFF;
2093
+ }
2094
+ }
2063
2095
else if (msg->id == UBX_NAV_SVIN && msg->len == UBX_NAV_SVIN_LEN)
2064
2096
{
2065
2097
//Parse various byte fields into storage - but only if we have memory allocated for it
@@ -6973,6 +7005,53 @@ void SFE_UBLOX_GNSS::logNAVCLOCK(boolean enabled)
6973
7005
packetUBXNAVCLOCK->automaticFlags.flags.bits.addToFileBuffer = (uint8_t)enabled;
6974
7006
}
6975
7007
7008
+ // ***** NAV TIMELS automatic support
7009
+
7010
+ //Reads leap second event information and sets the global variables
7011
+ //for future leap second change and number of leap seconds since GPS epoch
7012
+ //Returns true if commands was successful
7013
+ boolean SFE_UBLOX_GNSS::getLeapSecondEvent(uint16_t maxWait)
7014
+ {
7015
+ if (packetUBXNAVTIMELS == NULL) initPacketUBXNAVTIMELS(); //Check that RAM has been allocated for the TIMELS data
7016
+ if (packetUBXNAVTIMELS == NULL) // Abort if the RAM allocation failed
7017
+ return (false);
7018
+
7019
+ packetCfg.cls = UBX_CLASS_NAV;
7020
+ packetCfg.id = UBX_NAV_TIMELS;
7021
+ packetCfg.len = 0;
7022
+ packetCfg.startingSpot = 0;
7023
+
7024
+ //The data is parsed as part of processing the response
7025
+ sfe_ublox_status_e retVal = sendCommand(&packetCfg, maxWait);
7026
+
7027
+ if (retVal == SFE_UBLOX_STATUS_DATA_RECEIVED)
7028
+ return (true);
7029
+
7030
+ if (retVal == SFE_UBLOX_STATUS_DATA_OVERWRITTEN)
7031
+ {
7032
+ return (true);
7033
+ }
7034
+
7035
+ return (false);
7036
+ }
7037
+
7038
+ // PRIVATE: Allocate RAM for packetUBXNAVTIMELS and initialize it
7039
+ boolean SFE_UBLOX_GNSS::initPacketUBXNAVTIMELS()
7040
+ {
7041
+ packetUBXNAVTIMELS = new UBX_NAV_TIMELS_t; //Allocate RAM for the main struct
7042
+ if (packetUBXNAVTIMELS == NULL)
7043
+ {
7044
+ if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging
7045
+ _debugSerial->println(F("initPacketUBXNAVTIMELS: PANIC! RAM allocation failed!"));
7046
+ return (false);
7047
+ }
7048
+ packetUBXNAVTIMELS->automaticFlags.flags.all = 0;
7049
+ packetUBXNAVTIMELS->callbackPointer = NULL;
7050
+ packetUBXNAVTIMELS->callbackData = NULL;
7051
+ packetUBXNAVTIMELS->moduleQueried.moduleQueried.all = 0;
7052
+ return (true);
7053
+ }
7054
+
6976
7055
// ***** NAV SVIN automatic support
6977
7056
6978
7057
//Reads survey in status and sets the global variables
@@ -10304,6 +10383,45 @@ float SFE_UBLOX_GNSS::getSurveyInMeanAccuracy(uint16_t maxWait) // Returned as m
10304
10383
return (((float)tempFloat) / 10000.0); //Convert 0.1mm to m
10305
10384
}
10306
10385
10386
+ // ***** TIMELS Helper Functions
10387
+
10388
+ uint8_t SFE_UBLOX_GNSS::getLeapIndicator(int32_t& timeToLsEvent, uint16_t maxWait)
10389
+ {
10390
+ if (packetUBXNAVTIMELS == NULL) initPacketUBXNAVTIMELS(); //Check that RAM has been allocated for the TIMELS data
10391
+ if (packetUBXNAVTIMELS == NULL) //Bail if the RAM allocation failed
10392
+ return 3;
10393
+
10394
+ if (packetUBXNAVTIMELS->moduleQueried.moduleQueried.bits.validTimeToLsEvent == false)
10395
+ getLeapSecondEvent(maxWait);
10396
+ packetUBXNAVTIMELS->moduleQueried.moduleQueried.bits.validTimeToLsEvent = false; //Since we are about to give this to user, mark this data as stale
10397
+ packetUBXNAVTIMELS->moduleQueried.moduleQueried.bits.lsChange = false;
10398
+ packetUBXNAVTIMELS->moduleQueried.moduleQueried.bits.timeToLsEvent = false;
10399
+ packetUBXNAVTIMELS->moduleQueried.moduleQueried.bits.all = false;
10400
+ timeToLsEvent = packetUBXNAVTIMELS->data.timeToLsEvent;
10401
+ // returns NTP Leap Indicator
10402
+ // 0 -no warning
10403
+ // 1 -last minute of the day has 61 seconds
10404
+ // 2 -last minute of the day has 59 seconds
10405
+ // 3 -unknown (clock unsynchronized)
10406
+ return ((boolean)packetUBXNAVTIMELS->data.valid.bits.validTimeToLsEvent ? (uint8_t)(packetUBXNAVTIMELS->data.lsChange == -1 ? 2 : packetUBXNAVTIMELS->data.lsChange) : 3);
10407
+ }
10408
+
10409
+ int8_t SFE_UBLOX_GNSS::getCurrentLeapSeconds(sfe_ublox_ls_src_e& source, uint16_t maxWait)
10410
+ {
10411
+ if (packetUBXNAVTIMELS == NULL) initPacketUBXNAVTIMELS(); //Check that RAM has been allocated for the TIMELS data
10412
+ if (packetUBXNAVTIMELS == NULL) //Bail if the RAM allocation failed
10413
+ return false;
10414
+
10415
+ if (packetUBXNAVTIMELS->moduleQueried.moduleQueried.bits.validCurrLs == false)
10416
+ getLeapSecondEvent(maxWait);
10417
+ packetUBXNAVTIMELS->moduleQueried.moduleQueried.bits.validCurrLs = false; //Since we are about to give this to user, mark this data as stale
10418
+ packetUBXNAVTIMELS->moduleQueried.moduleQueried.bits.srcOfCurrLs = false;
10419
+ packetUBXNAVTIMELS->moduleQueried.moduleQueried.bits.currLs = false;
10420
+ packetUBXNAVTIMELS->moduleQueried.moduleQueried.bits.all = false;
10421
+ source = ((sfe_ublox_ls_src_e)packetUBXNAVTIMELS->data.srcOfCurrLs);
10422
+ return ((int8_t)packetUBXNAVTIMELS->data.currLs);
10423
+ }
10424
+
10307
10425
// ***** RELPOSNED Helper Functions and automatic support
10308
10426
10309
10427
float SFE_UBLOX_GNSS::getRelPosN(uint16_t maxWait) // Returned as m
0 commit comments