@@ -792,6 +792,9 @@ boolean SFE_UBLOX_GNSS::checkAutomatic(uint8_t Class, uint8_t ID)
792792 case UBX_NAV_CLOCK:
793793 if (packetUBXNAVCLOCK != NULL ) result = true ;
794794 break ;
795+ case UBX_NAV_TIMELS:
796+ if (packetUBXNAVTIMELS != NULL ) result = true ;
797+ break ;
795798 case UBX_NAV_SVIN:
796799 if (packetUBXNAVSVIN != NULL ) result = true ;
797800 break ;
@@ -919,6 +922,9 @@ uint16_t SFE_UBLOX_GNSS::getMaxPayloadSize(uint8_t Class, uint8_t ID)
919922 case UBX_NAV_CLOCK:
920923 maxSize = UBX_NAV_CLOCK_LEN;
921924 break ;
925+ case UBX_NAV_TIMELS:
926+ maxSize = UBX_NAV_TIMELS_LEN;
927+ break ;
922928 case UBX_NAV_SVIN:
923929 maxSize = UBX_NAV_SVIN_LEN;
924930 break ;
@@ -2060,6 +2066,26 @@ void SFE_UBLOX_GNSS::processUBXpacket(ubxPacket *msg)
20602066 }
20612067 }
20622068 }
2069+ else if (msg->id == UBX_NAV_TIMELS && msg->len == UBX_NAV_TIMELS_LEN)
2070+ {
2071+ // Parse various byte fields into storage - but only if we have memory allocated for it
2072+ if (packetUBXNAVTIMELS != NULL )
2073+ {
2074+ packetUBXNAVTIMELS->data .iTOW = extractLong (msg, 0 );
2075+ packetUBXNAVTIMELS->data .version = extractByte (msg, 4 );
2076+ packetUBXNAVTIMELS->data .srcOfCurrLs = extractByte (msg, 8 );
2077+ packetUBXNAVTIMELS->data .currLs = extractSignedChar (msg, 9 );
2078+ packetUBXNAVTIMELS->data .srcOfLsChange = extractByte (msg, 10 );
2079+ packetUBXNAVTIMELS->data .lsChange = extractSignedChar (msg, 11 );
2080+ packetUBXNAVTIMELS->data .timeToLsEvent = extractSignedLong (msg, 12 );
2081+ packetUBXNAVTIMELS->data .dateOfLsGpsWn = extractInt (msg, 16 );
2082+ packetUBXNAVTIMELS->data .dateOfLsGpsDn = extractInt (msg, 18 );
2083+ packetUBXNAVTIMELS->data .valid = extractSignedChar (msg, 23 );
2084+
2085+ // Mark all datums as fresh (not read before)
2086+ packetUBXNAVTIMELS->moduleQueried .moduleQueried .all = 0xFFFFFFFF ;
2087+ }
2088+ }
20632089 else if (msg->id == UBX_NAV_SVIN && msg->len == UBX_NAV_SVIN_LEN)
20642090 {
20652091 // Parse various byte fields into storage - but only if we have memory allocated for it
@@ -6973,6 +6999,53 @@ void SFE_UBLOX_GNSS::logNAVCLOCK(boolean enabled)
69736999 packetUBXNAVCLOCK->automaticFlags .flags .bits .addToFileBuffer = (uint8_t )enabled;
69747000}
69757001
7002+ // ***** NAV TIMELS automatic support
7003+
7004+ // Reads leap second event information and sets the global variables
7005+ // for future leap second change and number of leap seconds since GPS epoch
7006+ // Returns true if commands was successful
7007+ boolean SFE_UBLOX_GNSS::getLeapSecondEvent (uint16_t maxWait)
7008+ {
7009+ if (packetUBXNAVTIMELS == NULL ) initPacketUBXNAVTIMELS (); // Check that RAM has been allocated for the TIMELS data
7010+ if (packetUBXNAVTIMELS == NULL ) // Abort if the RAM allocation failed
7011+ return (false );
7012+
7013+ packetCfg.cls = UBX_CLASS_NAV;
7014+ packetCfg.id = UBX_NAV_TIMELS;
7015+ packetCfg.len = 0 ;
7016+ packetCfg.startingSpot = 0 ;
7017+
7018+ // The data is parsed as part of processing the response
7019+ sfe_ublox_status_e retVal = sendCommand (&packetCfg, maxWait);
7020+
7021+ if (retVal == SFE_UBLOX_STATUS_DATA_RECEIVED)
7022+ return (true );
7023+
7024+ if (retVal == SFE_UBLOX_STATUS_DATA_OVERWRITTEN)
7025+ {
7026+ return (true );
7027+ }
7028+
7029+ return (false );
7030+ }
7031+
7032+ // PRIVATE: Allocate RAM for packetUBXNAVTIMELS and initialize it
7033+ boolean SFE_UBLOX_GNSS::initPacketUBXNAVTIMELS ()
7034+ {
7035+ packetUBXNAVTIMELS = new UBX_NAV_TIMELS_t; // Allocate RAM for the main struct
7036+ if (packetUBXNAVTIMELS == NULL )
7037+ {
7038+ if ((_printDebug == true ) || (_printLimitedDebug == true )) // This is important. Print this if doing limited debugging
7039+ _debugSerial->println (F (" initPacketUBXNAVTIMELS: PANIC! RAM allocation failed!" ));
7040+ return (false );
7041+ }
7042+ packetUBXNAVTIMELS->automaticFlags .flags .all = 0 ;
7043+ packetUBXNAVTIMELS->callbackPointer = NULL ;
7044+ packetUBXNAVTIMELS->callbackData = NULL ;
7045+ packetUBXNAVTIMELS->moduleQueried .moduleQueried .all = 0 ;
7046+ return (true );
7047+ }
7048+
69767049// ***** NAV SVIN automatic support
69777050
69787051// Reads survey in status and sets the global variables
@@ -10304,6 +10377,45 @@ float SFE_UBLOX_GNSS::getSurveyInMeanAccuracy(uint16_t maxWait) // Returned as m
1030410377 return (((float )tempFloat) / 10000.0 ); // Convert 0.1mm to m
1030510378}
1030610379
10380+ // ***** TIMELS Helper Functions
10381+
10382+ uint8_t SFE_UBLOX_GNSS::getLeapIndicator (int32_t & timeToLsEvent, uint16_t maxWait)
10383+ {
10384+ if (packetUBXNAVTIMELS == NULL ) initPacketUBXNAVTIMELS (); // Check that RAM has been allocated for the TIMELS data
10385+ if (packetUBXNAVTIMELS == NULL ) // Bail if the RAM allocation failed
10386+ return 3 ;
10387+
10388+ if (packetUBXNAVTIMELS->moduleQueried .moduleQueried .bits .valid == false )
10389+ getLeapSecondEvent (maxWait);
10390+ packetUBXNAVTIMELS->moduleQueried .moduleQueried .bits .valid = false ; // Since we are about to give this to user, mark this data as stale
10391+ packetUBXNAVTIMELS->moduleQueried .moduleQueried .bits .lsChange = false ;
10392+ packetUBXNAVTIMELS->moduleQueried .moduleQueried .bits .timeToLsEvent = false ;
10393+ packetUBXNAVTIMELS->moduleQueried .moduleQueried .bits .all = false ;
10394+ timeToLsEvent = packetUBXNAVTIMELS->data .timeToLsEvent ;
10395+ // returns NTP Leap Indicator
10396+ // 0 -no warning
10397+ // 1 -last minute of the day has 61 seconds
10398+ // 2 -last minute of the day has 59 seconds
10399+ // 3 -unknown (clock unsynchronized)
10400+ return ((boolean)packetUBXNAVTIMELS->data .valid ? (uint8_t )(packetUBXNAVTIMELS->data .lsChange == -1 ? 2 : packetUBXNAVTIMELS->data .lsChange ) : 3 );
10401+ }
10402+
10403+ int8_t SFE_UBLOX_GNSS::getCurrentLeapSeconds (sfe_ublox_ls_src_e& source, uint16_t maxWait)
10404+ {
10405+ if (packetUBXNAVTIMELS == NULL ) initPacketUBXNAVTIMELS (); // Check that RAM has been allocated for the TIMELS data
10406+ if (packetUBXNAVTIMELS == NULL ) // Bail if the RAM allocation failed
10407+ return false ;
10408+
10409+ if (packetUBXNAVTIMELS->moduleQueried .moduleQueried .bits .valid == false )
10410+ getLeapSecondEvent (maxWait);
10411+ packetUBXNAVTIMELS->moduleQueried .moduleQueried .bits .valid = false ; // Since we are about to give this to user, mark this data as stale
10412+ packetUBXNAVTIMELS->moduleQueried .moduleQueried .bits .srcOfCurrLs = false ;
10413+ packetUBXNAVTIMELS->moduleQueried .moduleQueried .bits .currLs = false ;
10414+ packetUBXNAVTIMELS->moduleQueried .moduleQueried .bits .all = false ;
10415+ source = ((sfe_ublox_ls_src_e)packetUBXNAVTIMELS->data .srcOfCurrLs );
10416+ return ((int8_t )packetUBXNAVTIMELS->data .currLs );
10417+ }
10418+
1030710419// ***** RELPOSNED Helper Functions and automatic support
1030810420
1030910421float SFE_UBLOX_GNSS::getRelPosN (uint16_t maxWait) // Returned as m
0 commit comments