@@ -789,6 +789,9 @@ boolean SFE_UBLOX_GNSS::checkAutomatic(uint8_t Class, uint8_t ID)
789789 case UBX_NAV_CLOCK:
790790 if (packetUBXNAVCLOCK != NULL ) result = true ;
791791 break ;
792+ case UBX_NAV_TIMELS:
793+ if (packetUBXNAVTIMELS != NULL ) result = true ;
794+ break ;
792795 case UBX_NAV_SVIN:
793796 if (packetUBXNAVSVIN != NULL ) result = true ;
794797 break ;
@@ -916,6 +919,9 @@ uint16_t SFE_UBLOX_GNSS::getMaxPayloadSize(uint8_t Class, uint8_t ID)
916919 case UBX_NAV_CLOCK:
917920 maxSize = UBX_NAV_CLOCK_LEN;
918921 break ;
922+ case UBX_NAV_TIMELS:
923+ maxSize = UBX_NAV_TIMELS_LEN;
924+ break ;
919925 case UBX_NAV_SVIN:
920926 maxSize = UBX_NAV_SVIN_LEN;
921927 break ;
@@ -1949,6 +1955,26 @@ void SFE_UBLOX_GNSS::processUBXpacket(ubxPacket *msg)
19491955 }
19501956 }
19511957 }
1958+ else if (msg->id == UBX_NAV_TIMELS && msg->len == UBX_NAV_TIMELS_LEN)
1959+ {
1960+ // Parse various byte fields into storage - but only if we have memory allocated for it
1961+ if (packetUBXNAVTIMELS != NULL )
1962+ {
1963+ packetUBXNAVTIMELS->data .iTOW = extractLong (msg, 0 );
1964+ packetUBXNAVTIMELS->data .version = extractByte (msg, 4 );
1965+ packetUBXNAVTIMELS->data .srcOfCurrLs = extractByte (msg, 8 );
1966+ packetUBXNAVTIMELS->data .currLs = extractSignedChar (msg, 9 );
1967+ packetUBXNAVTIMELS->data .srcOfLsChange = extractByte (msg, 10 );
1968+ packetUBXNAVTIMELS->data .lsChange = extractSignedChar (msg, 11 );
1969+ packetUBXNAVTIMELS->data .timeToLsEvent = extractSignedLong (msg, 12 );
1970+ packetUBXNAVTIMELS->data .dateOfLsGpsWn = extractInt (msg, 16 );
1971+ packetUBXNAVTIMELS->data .dateOfLsGpsDn = extractInt (msg, 18 );
1972+ packetUBXNAVTIMELS->data .valid = extractSignedChar (msg, 23 );
1973+
1974+ // Mark all datums as fresh (not read before)
1975+ packetUBXNAVTIMELS->moduleQueried .moduleQueried .all = 0xFFFFFFFF ;
1976+ }
1977+ }
19521978 else if (msg->id == UBX_NAV_SVIN && msg->len == UBX_NAV_SVIN_LEN)
19531979 {
19541980 // Parse various byte fields into storage - but only if we have memory allocated for it
@@ -6862,6 +6888,53 @@ void SFE_UBLOX_GNSS::logNAVCLOCK(boolean enabled)
68626888 packetUBXNAVCLOCK->automaticFlags .flags .bits .addToFileBuffer = (uint8_t )enabled;
68636889}
68646890
6891+ // ***** NAV TIMELS automatic support
6892+
6893+ // Reads leap second event information and sets the global variables
6894+ // for future leap second change and number of leap seconds since GPS epoch
6895+ // Returns true if commands was successful
6896+ boolean SFE_UBLOX_GNSS::getLeapSecondEvent (uint16_t maxWait)
6897+ {
6898+ if (packetUBXNAVTIMELS == NULL ) initPacketUBXNAVTIMELS (); // Check that RAM has been allocated for the TIMELS data
6899+ if (packetUBXNAVTIMELS == NULL ) // Abort if the RAM allocation failed
6900+ return (false );
6901+
6902+ packetCfg.cls = UBX_CLASS_NAV;
6903+ packetCfg.id = UBX_NAV_TIMELS;
6904+ packetCfg.len = 0 ;
6905+ packetCfg.startingSpot = 0 ;
6906+
6907+ // The data is parsed as part of processing the response
6908+ sfe_ublox_status_e retVal = sendCommand (&packetCfg, maxWait);
6909+
6910+ if (retVal == SFE_UBLOX_STATUS_DATA_RECEIVED)
6911+ return (true );
6912+
6913+ if (retVal == SFE_UBLOX_STATUS_DATA_OVERWRITTEN)
6914+ {
6915+ return (true );
6916+ }
6917+
6918+ return (false );
6919+ }
6920+
6921+ // PRIVATE: Allocate RAM for packetUBXNAVTIMELS and initialize it
6922+ boolean SFE_UBLOX_GNSS::initPacketUBXNAVTIMELS ()
6923+ {
6924+ packetUBXNAVTIMELS = new UBX_NAV_TIMELS_t; // Allocate RAM for the main struct
6925+ if (packetUBXNAVTIMELS == NULL )
6926+ {
6927+ if ((_printDebug == true ) || (_printLimitedDebug == true )) // This is important. Print this if doing limited debugging
6928+ _debugSerial->println (F (" initPacketUBXNAVTIMELS: PANIC! RAM allocation failed!" ));
6929+ return (false );
6930+ }
6931+ packetUBXNAVTIMELS->automaticFlags .flags .all = 0 ;
6932+ packetUBXNAVTIMELS->callbackPointer = NULL ;
6933+ packetUBXNAVTIMELS->callbackData = NULL ;
6934+ packetUBXNAVTIMELS->moduleQueried .moduleQueried .all = 0 ;
6935+ return (true );
6936+ }
6937+
68656938// ***** NAV SVIN automatic support
68666939
68676940// Reads survey in status and sets the global variables
@@ -10178,6 +10251,45 @@ float SFE_UBLOX_GNSS::getSurveyInMeanAccuracy(uint16_t maxWait) // Returned as m
1017810251 return (((float )tempFloat) / 10000.0 ); // Convert 0.1mm to m
1017910252}
1018010253
10254+ // ***** TIMELS Helper Functions
10255+
10256+ uint8_t SFE_UBLOX_GNSS::getLeapIndicator (int32_t & timeToLsEvent, uint16_t maxWait)
10257+ {
10258+ if (packetUBXNAVTIMELS == NULL ) initPacketUBXNAVTIMELS (); // Check that RAM has been allocated for the TIMELS data
10259+ if (packetUBXNAVTIMELS == NULL ) // Bail if the RAM allocation failed
10260+ return 3 ;
10261+
10262+ if (packetUBXNAVTIMELS->moduleQueried .moduleQueried .bits .valid == false )
10263+ getLeapSecondEvent (maxWait);
10264+ packetUBXNAVTIMELS->moduleQueried .moduleQueried .bits .valid = false ; // Since we are about to give this to user, mark this data as stale
10265+ packetUBXNAVTIMELS->moduleQueried .moduleQueried .bits .lsChange = false ;
10266+ packetUBXNAVTIMELS->moduleQueried .moduleQueried .bits .timeToLsEvent = false ;
10267+ packetUBXNAVTIMELS->moduleQueried .moduleQueried .bits .all = false ;
10268+ timeToLsEvent = packetUBXNAVTIMELS->data .timeToLsEvent ;
10269+ // returns NTP Leap Indicator
10270+ // 0 -no warning
10271+ // 1 -last minute of the day has 61 seconds
10272+ // 2 -last minute of the day has 59 seconds
10273+ // 3 -unknown (clock unsynchronized)
10274+ return ((boolean)packetUBXNAVTIMELS->data .valid ? (uint8_t )(packetUBXNAVTIMELS->data .lsChange == -1 ? 2 : packetUBXNAVTIMELS->data .lsChange ) : 3 );
10275+ }
10276+
10277+ int8_t SFE_UBLOX_GNSS::getCurrentLeapSeconds (sfe_ublox_ls_src_e& source, uint16_t maxWait)
10278+ {
10279+ if (packetUBXNAVTIMELS == NULL ) initPacketUBXNAVTIMELS (); // Check that RAM has been allocated for the TIMELS data
10280+ if (packetUBXNAVTIMELS == NULL ) // Bail if the RAM allocation failed
10281+ return false ;
10282+
10283+ if (packetUBXNAVTIMELS->moduleQueried .moduleQueried .bits .valid == false )
10284+ getLeapSecondEvent (maxWait);
10285+ packetUBXNAVTIMELS->moduleQueried .moduleQueried .bits .valid = false ; // Since we are about to give this to user, mark this data as stale
10286+ packetUBXNAVTIMELS->moduleQueried .moduleQueried .bits .srcOfCurrLs = false ;
10287+ packetUBXNAVTIMELS->moduleQueried .moduleQueried .bits .currLs = false ;
10288+ packetUBXNAVTIMELS->moduleQueried .moduleQueried .bits .all = false ;
10289+ source = ((sfe_ublox_ls_src_e)packetUBXNAVTIMELS->data .srcOfCurrLs );
10290+ return ((int8_t )packetUBXNAVTIMELS->data .currLs );
10291+ }
10292+
1018110293// ***** RELPOSNED Helper Functions and automatic support
1018210294
1018310295float SFE_UBLOX_GNSS::getRelPosN (uint16_t maxWait) // Returned as m
0 commit comments